diff --git a/.gitignore b/.gitignore index 7be47009b3..95afe75b78 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,4 @@ __pycache__/ unifont-15.0.03.ttf *.diff goalc-report.html +_new-all-types.gc \ No newline at end of file diff --git a/.vs/launch.vs.json b/.vs/launch.vs.json index 823514d6a6..720cd1af8c 100644 --- a/.vs/launch.vs.json +++ b/.vs/launch.vs.json @@ -96,6 +96,18 @@ "jak3" ] }, + { + "type": "default", + "project": "CMakeLists.txt", + "projectTarget": "offline-test.exe (bin\\offline-test.exe)", + "name": "Tests - Offline Tests - Jak X", + "args": [ + "--iso_data_path", + "${workspaceRoot}/iso_data/jakx", + "--game", + "jakx" + ] + }, { "type": "default", "project": "CMakeLists.txt", diff --git a/Taskfile.yml b/Taskfile.yml index fabd49ce3d..b97afcf9e0 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -135,6 +135,9 @@ tasks: decomp: cmds: - '{{.DECOMP_BIN_RELEASE_DIR}}/decompiler "./decompiler/config/{{.DECOMP_CONFIG}}" "./iso_data" "./decompiler_out" --version "{{.DECOMP_CONFIG_VERSION}}" --config-override ''{"decompile_code": true, "levels_extract": false}''' + disasm-file: + cmds: + - '{{.DECOMP_BIN_RELEASE_DIR}}/decompiler "./decompiler/config/{{.DECOMP_CONFIG}}" "./iso_data" "./decompiler_out" --version "{{.DECOMP_CONFIG_VERSION}}" --config-override ''{"disassemble_code": true, "decompile_code": false, "levels_extract": false, "allowed_objects": ["{{.FILE}}"]}''' decomp-file: cmds: - '{{.DECOMP_BIN_RELEASE_DIR}}/decompiler "./decompiler/config/{{.DECOMP_CONFIG}}" "./iso_data" "./decompiler_out" --version "{{.DECOMP_CONFIG_VERSION}}" --config-override ''{"decompile_code": true, "levels_extract": false, "allowed_objects": ["{{.FILE}}"]}''' diff --git a/decompiler/ObjectFile/ObjectFileDB.cpp b/decompiler/ObjectFile/ObjectFileDB.cpp index 6ce37d5149..288edd4ee2 100644 --- a/decompiler/ObjectFile/ObjectFileDB.cpp +++ b/decompiler/ObjectFile/ObjectFileDB.cpp @@ -669,7 +669,7 @@ void ObjectFileDB::write_disassembly(const fs::path& output_dir, if (dump_function_metadata) { json data = file_func_metadata_map; - file_util::write_text_file(output_dir / "func_metadata.json", data.dump(2)); + file_util::write_text_file(output_dir / "_func_metadata.json", data.dump(2)); } lg::info("Wrote functions dumps:"); diff --git a/decompiler/analysis/cfg_builder.cpp b/decompiler/analysis/cfg_builder.cpp index ae92f51d8e..ce54d193d0 100644 --- a/decompiler/analysis/cfg_builder.cpp +++ b/decompiler/analysis/cfg_builder.cpp @@ -110,13 +110,14 @@ void clean_up_cond_with_else(FormPool& pool, FormElement* ir, const Env& env) { */ void clean_up_until_loop(FormPool& pool, UntilElement* ir, const Env& env) { auto condition_branch = get_condition_branch(ir->condition); - ASSERT(condition_branch.first); + ASSERT_MSG(condition_branch.first, fmt::format("bad condition branch in {}\n", env.func->name())); if (condition_branch.first->op()->branch_delay().kind() != IR2_BranchDelay::Kind::NOP) { ASSERT_MSG( condition_branch.first->op()->branch_delay().kind() == IR2_BranchDelay::Kind::SET_REG_FALSE, fmt::format( - "bad delay slot in until loop: {} in {}\n", env.func->name(), - condition_branch.first->op()->branch_delay().to_form(env.file->labels, env).print())); + "bad delay slot in until loop: {} in {}\n", + condition_branch.first->op()->branch_delay().to_form(env.file->labels, env).print(), + env.func->name())); ir->false_destination = condition_branch.first->op()->branch_delay().var(0); } auto replacement = condition_branch.first->op()->get_condition_as_form(pool, env); @@ -1974,7 +1975,8 @@ void clean_up_while_loops(FormPool& pool, Form* sequence, const Env& env) { auto condition_branch = get_condition_branch(form_as_while->condition); - ASSERT(condition_branch.first); + ASSERT_MSG(condition_branch.first, + fmt::format("bad conditional branch in {}\n", env.func->name())); ASSERT(condition_branch.first->op()->branch_delay().kind() == IR2_BranchDelay::Kind::NOP); // printf("got while condition branch %s\n", condition_branch.first->print(file).c_str()); auto replacement = condition_branch.first->op()->get_condition_as_form(pool, env); diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index 96dd083d4d..e6bd26be06 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -7782,7 +7782,6 @@ (load-buffer-mode level-memory-mode :offset-assert 4624) ;; guessed by decompiler (display-start-time uint64 :offset-assert 4632) ;; time-frame (memory-mask uint32 :offset-assert 4640) - ; (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (task-mask task-mask :offset-assert 4644) (tfrag-gs-test gs-test :offset-assert 4648) (texture-dirty-masks texture-mask 11 :inline :offset-assert 4656) ;; guessed by decompiler @@ -7808,9 +7807,7 @@ (level-type type :offset-assert 5368) ;; guessed by decompiler (load-order uint64 :offset-assert 5376) ;; int64 (eye-slot-lowres uint8 11 :offset-assert 5384) - ; (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (eye-slot-highres uint8 11 :offset-assert 5395) - ; (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (unknown-pad uint8 14) ) :method-count-assert 30 @@ -15264,26 +15261,6 @@ :flag-assert #x900000100 ) -#| -(deftype gsf-vertex-array (UNKNOWN) - ((vtx gsf-vertex :dynamic :offset-assert 0) ;; guessed by decompiler - ) - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 - ) -|# - -#| -(deftype gsf-fx-vertex-array (UNKNOWN) - ((data gsf-fx-vertex :dynamic :offset-assert 0) ;; guessed by decompiler - ) - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 - ) -|# - (deftype gsf-vertex-array (structure) ((vtx gsf-vertex :dynamic :offset-assert 0) ) @@ -20818,6 +20795,7 @@ ;; joint-mod-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +++joint-mod-h:joint-mod-mode (defenum joint-mod-mode :bitfield #t :type uint32 @@ -20835,6 +20813,7 @@ (foot-rot) (joint-set-world) ) +;; ---joint-mod-h:joint-mod-mode ;; +++joint-mod-h:track-mode (defenum track-mode @@ -20850,6 +20829,7 @@ ) ;; ---joint-mod-h:track-mode +;; +++joint-mod-h:joint-mod-ik-flags (defenum joint-mod-ik-flags :bitfield #t :type uint32 @@ -20857,6 +20837,7 @@ (elbow-trans-neg) (elbow-rot-neg) ) +;; ---joint-mod-h:joint-mod-ik-flags (deftype joint-mod (basic) "Utility to modify a joint transform from code, rather than just getting it from animation. @@ -21045,7 +21026,6 @@ ) ;; added - I really have no idea what is going on here - (deftype joint-mod-blend-world-work (structure) ((mat1 matrix :inline) (mat2 matrix :inline) diff --git a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc index ba504a0210..e90766ecb7 100644 --- a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc +++ b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc @@ -1943,7 +1943,7 @@ "(code wait title-control)": [[16, "event-message-block"]], "(code startup title-control)": [ [16, ["array", "symbol", 10]], - [64, "event-message-block"], // this memory is reused as both mc-slot-info and event-message-block + [64, "event-message-block"], [368, ["array", "symbol", 10]] ], "(method 9 nav-node)": [[48, ["inline-array", "vector", 2]]], diff --git a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc index e30e0472a8..f9ccac2666 100644 --- a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc @@ -211,7 +211,6 @@ "dma-buffer-patch-buckets": [ [[3, 34], "a0", "dma-bucket"], [[34, 38], "a0", "dma-packet"] - // [34, "a0", "(inline-array dma-bucket)"] ], "disasm-dma-list": [ [43, "v1", "dma-packet"], @@ -255,11 +254,7 @@ [37, "t0", "(pointer int32)"] ], "texture-page-dir-inspect": [[[137, 138], "v1", "adgif-shader"]], - "(method 24 texture-pool)": [ - [[77, 100], "a1", "adgif-shader"] - // [[70, 93], "a1", "adgif-shader"], - // [92, "a1", "adgif-shader"] - ], + "(method 24 texture-pool)": [[[77, 100], "a1", "adgif-shader"]], "(method 8 res-lump)": [ [258, "s0", "array"], [[157, 239], "s0", "(array object)"] @@ -509,7 +504,7 @@ ], "merc-edge-stats": [[31, "v1", "merc-ctrl"]], "(method 8 merc-ctrl)": [ - [46, "s2", "pointer"], // was merc-fragment-control + [46, "s2", "pointer"], [[22, 45], "s2", "merc-fragment-control"], [[89, 93], "a1", "merc-blend-ctrl"], [103, "a1", "pointer"] @@ -2119,8 +2114,6 @@ [[14, 31], "s5", "adgif-shader"] ], "add-debug-bound": [ - //[105, "v1", "dma-packet"], - //[85, "a0", "dma-packet"], ["_stack_", 16, "dma-packet"], [91, "v1", "dma-packet"] ], @@ -2238,12 +2231,10 @@ [789, "v1", "float"], [792, "v1", "float"], [794, "v0", "float"], - // [784, "v1", "vector"], [589, "v1", "float"], [593, "v1", "float"], [602, "v1", "float"], [606, "v1", "float"] - // [796, "v1", "float"] ], "master-track-target": [ [53, "gp", "process-focusable"], @@ -2552,19 +2543,6 @@ [[470, 515], "s1", "prototype-bucket-shrub"], [[470, 658], "gp", "prototype-bucket-shrub"], [[13, 56], "v1", "prototype-bucket-shrub"] - // [[102, 114], "a0", "shrub-near-packet"], - // [[114, 117], "v1", "vector4w-3"], - // [118, "a1", "vector4w"], - // [123, "v1", "dma-packet"], - // [[124, 126], "v1", "vector4w"], - // [[334, 364], "s1", "prototype-bucket-shrub"], - // [416, "a0", "drawable-group"], - // [420, "s1", "prototype-bucket-shrub"], - // [525, "v1", "drawable-group"], - // [[518, 535], "s1", "prototype-bucket-shrub"], - // [558, "s1", "prototype-bucket-shrub"], - // [[677, 718], "gp", "prototype-bucket-shrub"], - // [[696, 706], "a1", "prototype-bucket-shrub"] ], "(method 8 drawable-tree-instance-shrub)": [[51, "v1", "drawable-group"]], "(method 13 drawable-tree-instance-shrub)": [ @@ -4135,7 +4113,6 @@ [191, "a3", "int"] ], "(method 9 collide-cache)": [ - //[[28, 56], "gp", "collide-shape-prim"], [33, "gp", "collide-cache-prim"], [35, "gp", "collide-shape-prim"], [[50, 56], "gp", "collide-cache-prim"], @@ -4149,10 +4126,7 @@ "command-get-float": [[20, "gp", "bfloat"]], "command-get-int": [[17, "gp", "bfloat"]], "(anon-function 2 memory-usage)": [[211, "v1", "collide-shape-moving"]], - "(method 8 process-tree)": [ - [33, "v1", "symbol"] - // [6, "a3", "symbol"] - ], + "(method 8 process-tree)": [[33, "v1", "symbol"]], "(method 11 memory-usage-block)": [[112, "v1", "int"]], "(method 14 draw-control)": [ [38, "t9", "(function object object object none)"] @@ -4328,7 +4302,6 @@ [26, "a1", "(array int32)"], [28, "v1", "(array int32)"], [32, "a0", "(pointer int64)"], - // [33, "a0", "(pointer int64)"], [44, "v1", "(pointer int32)"], [46, "v1", "(pointer int32)"] ], @@ -9421,7 +9394,7 @@ [226, "gp", "external-art-buffer"] ], "(code startup title-control)": [ - [[59, 149], "gp", "mc-slot-info"], // (+ sp-0 64) is reused as both mc-slot-info and event-message-block + [[59, 149], "gp", "mc-slot-info"], [354, "v1", "process-drawable"], [356, "s4", "quaternion"] ], diff --git a/decompiler/config/jakx/all-types.gc b/decompiler/config/jakx/all-types.gc index 0978a40e5c..4b72a110f1 100644 --- a/decompiler/config/jakx/all-types.gc +++ b/decompiler/config/jakx/all-types.gc @@ -67,6 +67,25 @@ (portuguese 9) (dutch 10) (uk-english 11) + ;; custom + (finnish 12) + (swedish 13) + (danish 14) + (norwegian 15) + (br-portuguese 16) + (hungarian 17) + (catalan 18) + (icelandic 19) + (polish 20) + (lithuanian 21) + (czech 22) + (croatian 23) + (galician 24) + ) + +(defenum language-enum-s32 + :type int32 + :copy-entries language-enum ) (define-extern *debug-segment* symbol) @@ -132,6 +151,7 @@ (define-extern *kernel-boot-message* symbol) (define-extern *kernel-boot-art-group* string) +(define-extern *user* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gcommon ;; @@ -432,7 +452,7 @@ (define-extern quad-copy! "Optimized memory copy. Must be 16-byte aligned. Size in 16-byte units." - (function pointer pointer int pointer)) + (function pointer pointer int none)) (define-extern mem-copy! (function pointer pointer int pointer)) @@ -517,6 +537,7 @@ (declare-type event-message-block structure) (declare-type level basic) +;; +++gkernel-h:process-mask (defenum process-mask :type uint32 :bitfield #t @@ -551,6 +572,7 @@ (vehicle 27) (network 28) ) +;; ---gkernel-h:process-mask (deftype kernel-context (basic) ((prevent-from-run process-mask :offset-assert 4) ;; guessed by decompiler @@ -671,9 +693,9 @@ (self process-tree :offset-assert 36) (profile-ticks uint32 :offset-assert 40) ) - :method-count-assert 14 + :method-count-assert 15 :size-assert #x2c - :flag-assert #xe0000002c + :flag-assert #xf0000002c :no-runtime-type (:methods (new "Allocate a process-tree with the kernel clock." (symbol type string) _type_) ;; 0 @@ -682,6 +704,7 @@ (init-from-entity! (_type_ entity-actor) object) ;; 11 (run-logic? "Should this process be run? Checked by execute-process-tree." (_type_) symbol) ;; 12 (process-tree-method-13 () none) ;; 13 + (process-tree-method-14 () none) ) ) @@ -693,9 +716,8 @@ :flag-assert #x110000002c (:methods (new "Allocate a dead pool and set up dead processes" (symbol type int int string) _type_) ;; 0 - (dead-pool-method-14 () none) ;; 14 (get-process "Allocate a process from the pool, or #f if it fails." (_type_ type int object) process) ;; 15 - (return-process "Return a process to the pool." (_type_ process) int) ;; 16 + (return-process "Return a process to the pool." (_type_ process) none) ;; 16 ) ) @@ -729,8 +751,8 @@ :flag-assert #x1d00000078 (:methods (new "Allocate and initialize a dead-pool-heap." (symbol type string int int) _type_) ;; 0 - (init "Allocate memory for processes and init records." (_type_ symbol int) _type_) ;; 17 - (compact "Relocate process in memory to remove gaps, increasing free memory for this dead-pool-heap." (dead-pool-heap int) int) ;; 18 + (init "Allocate memory for processes and init records." (_type_ symbol int) none) ;; 17 + (compact "Relocate process in memory to remove gaps, increasing free memory for this dead-pool-heap." (dead-pool-heap int) none) ;; 18 (shrink-heap "Shrink the heap of a process, allowing the dead pool heap to later reclaim the memory during a compact." (dead-pool-heap process) dead-pool-heap) ;; 19 (churn "Relocate process in memory, to trigger memory bugs related to process relocation." (dead-pool-heap int) none) ;; 20 (memory-used "Get the total memory used. Memory in between processes that is not used by a process is considered used." (_type_) int) ;; 21 @@ -883,9 +905,9 @@ (connection-list connectable :inline :offset-assert 128) (stack uint8 :dynamic :offset-assert 144) ;; guessed by decompiler ) - :method-count-assert 14 + :method-count-assert 15 :size-assert #x90 - :flag-assert #xe00000090 + :flag-assert #xf00000090 (:methods (new "Allocate a process, set up process heap, self/ppointer, clock." (symbol type string int) _type_) ;; 0 ) @@ -992,6 +1014,10 @@ (define-extern *bg-pool* process-tree) (define-extern *default-pool* process-tree) +(define-extern *stdcon* string) +;; from kernel +(define-extern install-handler (function int function int)) + ;; !! GENERATED ALL TYPES BEGINS HERE !! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1037,11 +1063,100 @@ ;; (define-extern deinstall-debug-handlers function) ;; (function none) ;; (define-extern resend-exception function) ;; (function object object object object none) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; gstring ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define-extern copy-string<-string + "Copy a string. No bounds check. Writes null terminator." (function string string string)) +(define-extern to-upper (function string string)) +(define-extern string= (function string string symbol)) +(define-extern nocase-string= (function string string symbol)) +(define-extern string-prefix= + "Check if a string starts with a given string." + (function string string symbol)) +(define-extern charp-prefix= + "Check if a c-string starts with a given c-string." + (function (pointer uint8) (pointer uint8) symbol)) +(define-extern string-suffix= + "Check if a string ends with a given string." + (function string string symbol)) +(define-extern string-position + "Find the point where a string occurs in another. If it doesn't, return -1." + (function string string int)) +(define-extern string-charp= + "Check if a string is equal to a c-string." (function string (pointer uint8) symbol)) +(define-extern name= + "Check if a string/symbol stores the same name as another string/symbol." + (function object object symbol)) +(define-extern copyn-string<-charp + "Copy part of a c-string to a string. Writes null terminator after num-chars." (function string (pointer uint8) int string)) +(define-extern string<-charp + "Copy a c-string to a string. Writes the null terminator." + (function string (pointer uint8) string)) +(define-extern charp<-string + "Copy a string to a c-string. Writes the null terminator." + (function (pointer uint8) string int)) +(define-extern copyn-charp<-string + "Copy part of a string to a c-string. Writes null terminator, repeatedly, to reach the given length. + If the source is longer than the length, the null terminator is still included." + (function (pointer uint8) string int none)) +(define-extern copy-charp<-charp + "C-string copy, writes null terminator." + (function (pointer uint8) (pointer uint8) (pointer uint8))) +(define-extern cat-string<-string + "Append a string to another." + (function string string string)) +(define-extern catn-string<-charp + "Append part of a string to another. Writes null terminator." + (function string (pointer uint8) int string)) +(define-extern cat-string<-string_to_charp "Append part of a string to another, up to the given pointer." + (function string string (pointer uint8) (pointer uint8))) +(define-extern append-character-to-string + "Append a single character to a string. Writes null terminator after." + (function string uint8 int)) +(define-extern charp-basename + "Strip the directory and suffix from a c-string." + (function (pointer uint8) (pointer uint8))) +(define-extern clear "Set string to the empty string." + (function string string)) +(define-extern string? "Slightly incorrect ordering of strings." (function string string symbol)) +(define-extern string<=? "Slightly incorrect ordering of strings." (function string string symbol)) +(define-extern string>=? "Slightly incorrect ordering of strings." (function string string symbol)) +(define-extern *string-tmp-str* string) +(define-extern string-skip-to-char "Advance to the given character." + (function (pointer uint8) uint (pointer uint8))) +(define-extern string-cat-to-last-char "Append append-str to end of base-str, up to the last occurance of char" (function string string uint (pointer uint8))) +(define-extern string-skip-whitespace "Jump over whitespace chars." + (function (pointer uint8) (pointer uint8))) +(define-extern string-suck-up! "Move the string forward so the pointer is now at the beginning." + (function string (pointer uint8) symbol)) +(define-extern string-strip-leading-whitespace! "Strip leading whitespace." (function string symbol)) +(define-extern string-strip-trailing-whitespace! "String trailing whitespace." (function string symbol)) +(define-extern string-strip-whitespace! "Strip whitespace from the beginning and end of a string" (function string symbol)) +(define-extern string-upcase "Uppercase characters. If convert-dash is set, - will be uppercased to _" (function string string symbol none)) +(define-extern string-get-arg!! (function string string symbol)) +(define-extern string->int "Convert string to int." (function string int)) +(define-extern string->float "Convert string to float. Finally implemented!" (function string float)) +(define-extern string-get-int32!! (function (pointer int32) string symbol)) +(define-extern string-get-float!! (function (pointer float) string symbol)) +(define-extern string-get-flag!! (function (pointer symbol) string string string symbol)) +(define-extern string-word-wrap "Wrap lines to specified width." (function string int none)) +(define-extern *debug-draw-pauseable* symbol) +(define-extern *stdcon0* string) +(define-extern *stdcon1* string) +(define-extern *null* string) +(define-extern *stdcon* string) +(define-extern *stdebug* string) +(define-extern *temp-string* string) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; dgo-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype dgo-header (structure) ((length uint32 :offset-assert 0) (rootname uint8 60 :offset-assert 4) ;; guessed by decompiler @@ -1050,9 +1165,7 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype dgo-entry (structure) ((offset uint32 :offset-assert 0) (length uint32 :offset-assert 4) @@ -1061,9 +1174,7 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype dgo-file (basic) ((num-go-files uint32 :offset-assert 4) (total-length uint32 :offset-assert 8) @@ -1074,25 +1185,23 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gstate ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern inherit-state function) ;; (function state state state) -;; (define-extern state-type? function) ;; (function state symbol symbol) -;; (define-extern enter-state function) ;; (function object object object object object object object) -;; (define-extern *event-queue* object) ;; event-message-block-array -;; (define-extern send-event-function function) ;; (function process-tree event-message-block object) -;; (define-extern looping-code function) ;; (function symbol) +(define-extern inherit-state (function state state state)) +(define-extern state-type? (function state symbol symbol)) +(define-extern enter-state (function object object object object object object object)) +(define-extern *event-queue* event-message-block-array) +(define-extern send-event-function (function process-tree event-message-block object)) +(define-extern looping-code (function symbol)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; types-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype basic-reserved (basic) () :method-count-assert 29 @@ -1121,7 +1230,6 @@ (basic-reserved-method-28 () none) ;; 28 ;; (basic-reserved-method-28 () none) ) ) -|# ;; (deftype part-id (uint32) ;; () @@ -1138,27 +1246,31 @@ ;; math ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype float-type (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype float-type (uint32) + () + :flag-assert #x900000004 + ) -;; (deftype rgba (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype rgba (uint32) + ((r uint8 :offset 0) + (g uint8 :offset 8) + (b uint8 :offset 16) + (a uint8 :offset 24) + ) + :flag-assert #x900000004 + :no-runtime-type + ) -;; (deftype xyzw (uint128) -;; () -;; :flag-assert #x900000010 -;; ) +(deftype xyzw (uint128) + () + :flag-assert #x900000010 + ) -;; (deftype xyzwh (uint128) -;; () -;; :flag-assert #x900000010 -;; ) +(deftype xyzwh (uint128) + () + :flag-assert #x900000010 + ) -#| (deftype random-generator (basic) ((seed uint32 :offset-assert 4) ) @@ -1166,531 +1278,527 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -;; (define-extern truncate function) ;; (function float float) -;; (define-extern round function) ;; (function float float) -;; (define-extern floor function) ;; (function float float) -;; (define-extern ceil function) ;; (function float float) -;; (define-extern integral? function) ;; (function float symbol) -;; (define-extern fractional-part function) ;; (function float float) -;; (define-extern odd? function) ;; (function int symbol) -;; (define-extern even? function) ;; (function int symbol) -;; (define-extern sawtooth-wave function) ;; (function float float) -;; (define-extern triangle-wave function) ;; (function float float) -;; (define-extern log-x-plus-1-order9 function) ;; (function float float) -;; (define-extern logf function) ;; (function float float) -;; (define-extern log2f function) ;; (function float float) -;; (define-extern exp-slead object) ;; (pointer float) -;; (define-extern exp-strail object) ;; (pointer float) -;; (define-extern exp function) ;; (function float float) -;; (define-extern pow function) ;; (function float float float) -;; (define-extern print-exp function) ;; (function float none) -;; (define-extern print-time function) ;; (function object time-frame none) -;; (define-extern log2 function) ;; (function int int) -;; (define-extern seek function) ;; (function float float float float) -;; (define-extern seek-ease function) ;; (function float float float float float float) -;; (define-extern seek-ease-in-out function) ;; (function float float float float float float float float) -;; (define-extern lerp function) ;; (function float float float float) -;; (define-extern lerp-scale-old function) ;; (function float float float float float float) -;; (define-extern lerp-scale function) ;; (function float float float float float float) -;; (define-extern lerp-scale-clamp function) ;; (function float float float float float float) -;; (define-extern lerp-clamp function) ;; (function float float float float) -;; (define-extern rgba-lerp function) ;; (function rgba rgba rgba rgba) -;; (define-extern seekl function) ;; (function int int int int) -;; (define-extern rand-vu-init function) ;; (function float float) -;; (define-extern rand-vu function) ;; (function float) -;; (define-extern rand-vu-nostep function) ;; (function float) -;; (define-extern rand-vu-float-range function) ;; (function float float float) -;; (define-extern rand-vu-percent? function) ;; (function float symbol) -;; (define-extern rand-vu-int-range function) ;; (function int int int) -;; (define-extern rand-vu-int-count function) ;; (function int int) -;; (define-extern rand-vu-int-count-excluding function) ;; (function int int int) -;; (define-extern rand-vu-int-range-exclude function) ;; (function int int int int) -;; (define-extern *random-generator* object) ;; random-generator -;; (define-extern rand-uint31-gen function) ;; (function random-generator uint) -;; (define-extern cube-root function) ;; (function float float) -;; (define-extern int-noise function) ;; (function int float) -;; (define-extern smooth-step function) ;; (function float float) -;; (define-extern smooth-interp function) ;; (function float float float float float float) +(define-extern truncate + "Round (toward zero) to an integer. + @param arg0 float to truncate" + (function float float)) +(define-extern round "Round to the nearest integer" (function float float)) +(define-extern floor "Round (down) to an integer" (function float float)) +(define-extern ceil "Round (up) to an integer" (function float float)) +(define-extern integral? "Is this number an integer?" (function float symbol)) +(define-extern fractional-part "Get the fractional part of a float." (function float float)) +(define-extern odd? "Is the number odd?" (function int symbol)) +(define-extern even? "Is the number even?" (function int symbol)) +(define-extern sawtooth-wave "Sample a sawtooth with period 1. In range (0, 1)" (function float float)) +(define-extern triangle-wave + "Sample a triangle wave. Period is 4, in range (-1, 1) (so slope is 1 or -1)." + (function float float)) +(define-extern log-x-plus-1-order9 + "Fast approximation of ln(x + 1). Probably only accurate for x in [0, 1]." + (function float float)) +(define-extern logf "Natural log." (function float float)) +(define-extern log2f "Log base 2." (function float float)) +(define-extern exp-slead (pointer float)) +(define-extern exp-strail (pointer float)) +(define-extern exp (function float float)) ;; +(define-extern pow "Compute arg0^arg1" (function float float float)) +(define-extern print-exp "Print in the format AeB where A is in the range (1, 10)" (function float none)) +(define-extern print-time "Print a [[time-frame]] as h:mm:ss." (function object time-frame none)) +(define-extern log2 "Log base 2." (function int int)) +(define-extern seek "Move arg0 toward arg1 by at most arg2." (function float float float float)) +(define-extern seek-ease + "Move arg0 toward arg1, and slow down before reaching the end. + When farther than arg3 away, move by at most arg2. + When closer than arg3, linearly ramp down the movement amount from arg2 to 0 but no lower than arg4." + (function float float float float float float)) +(define-extern seek-ease-in-out + "Move arg0 toward arg2, and slow down at the start and end. + When within arg4 of arg1 (at the beginning of movement), ramp up speed, with a minimum speed of arg6 + When within arg5 of arg2 (at the end of movement), ramp down speed, with a minimum speed of arg5 + Normally, move at most arg3" + (function float float float float float float float float)) +(define-extern lerp "Linearly interpolate between arg0 and arg1." (function float float float float)) +(define-extern lerp-scale-old + "Linearly remap arg2 in [arg3, arg4] to [arg0, arg1]. + This is the jak 1 implementation, which I claimed was a bad implementation..." + (function float float float float float float)) +(define-extern lerp-scale + "Linearly remap arg2 in [arg3, arg4] to [arg0, arg1]. + More efficient than the -old version." + (function float float float float float float)) +(define-extern lerp-scale-clamp + "Clamp the input, then linearly remap arg2 in [arg3, arg4] to [arg0, arg1]." + (function float float float float float float)) +(define-extern lerp-clamp + "Linearly interpolate between arg0 and arg1. arg2 is clamped to [0, 1]" + (function float float float float)) +(define-extern rgba-lerp (function rgba rgba rgba rgba)) +(define-extern seekl "Move arg0 toward arg1, by at most arg2." (function int int int int)) +(define-extern rand-vu-init "Initialize the VU0 random generator." (function float float)) +(define-extern rand-vu "Get a random number in [0, 1) and advance the random generator." (function float)) +(define-extern rand-vu-nostep + "Get the number currently in the random generator. + This will be equal to the last call of (rand-vu). + This will not update the random generator." + (function float)) +(define-extern rand-vu-float-range "Get a random float in between arg0 and arg1." (function float float float)) +(define-extern rand-vu-percent? "Get a boolean that's true with the given probability (in 0, 1)." (function float symbol)) +(define-extern rand-vu-int-range "Get an integer in the given range (inclusive)." (function int int int)) +(define-extern rand-vu-int-count "Get an integer in the range [0, max)." (function int int)) +(define-extern rand-vu-int-count-excluding + "Get an integer in the range [0, arg0). + If bit n is set in arg1, exclude this value from being returned." + (function int int int)) +(define-extern rand-vu-int-range-exclude + "Get an integer in the range [0, arg0), excluding arg2. + Note that this doesn't use bits like rand-vu-int-count-excluding." + (function int int int int)) +(define-extern *random-generator* random-generator) +(define-extern rand-uint31-gen + "Generate a supposedly random integer. + Note, this might not quite be right. + But the highest bit is always zero, like it says + and it looks kinda random to me." + (function random-generator uint)) +(define-extern cube-root "Cube root with cool trick that I don't understand." (function float float)) +(define-extern int-noise "Generate random-ish floats in range -1, 1." (function int float)) +(define-extern smooth-step + "Interpolate between 0, 1 with a cubic polynomial. + These are picked so f(0) = 0, f(1) = 1, f'(0) = f'(1) = 0." + (function float float)) +(define-extern smooth-interp + "Remap arg2 from (arg3, arg4) to (arg0, arg1), using cubic interpolation. + Satisfies: + - f(arg3) = arg0 + - f(arg4) = arg1 + - f'(arg3) = f'(arg4) = 0" + (function float float float float float float)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; vector-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype bit-array (basic) ((length int32 :offset-assert 4) (allocated-length int32 :offset-assert 8) + (_pad uint8 :offset-assert 12) + (bytes uint8 :dynamic :offset 12) ) :method-count-assert 13 :size-assert #xd :flag-assert #xd0000000d (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type int) _type_) - (bit-array-method-9 () none) ;; 9 ;; (get-bit (_type_ int) symbol) - (bit-array-method-10 () none) ;; 10 ;; (clear-bit (_type_ int) int) - (bit-array-method-11 () none) ;; 11 ;; (set-bit (_type_ int) int) - (bit-array-method-12 () none) ;; 12 ;; (clear-all! (_type_) _type_) + (new "Allocate a new bit-array with room arg0 bits." (symbol type int) _type_) ;; 0 + (get-bit "Get the nth bit as a boolean." (_type_ int) symbol) ;; 9 + (clear-bit "Set the nth bit to 0." (_type_ int) int) ;; 10 + (set-bit "Set the nth bit to 1." (_type_ int) int) ;; 11 + (clear-all! "Set all bits to 0." (_type_) _type_) ;; 12 ) ) -|# -#| + (deftype vector16ub (structure) - ((data uint8 16 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + ((data uint8 16 :offset-assert 0) + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype vector4ub (structure) - ((data uint8 4 :offset-assert 0) ;; guessed by decompiler - (x uint8 :offset-assert 0) - (y uint8 :offset-assert 1) - (z uint8 :offset-assert 2) - (w uint8 :offset-assert 3) - (clr uint32 :offset-assert 0) + ((data uint8 4 :offset-assert 0) + (x uint8 :offset 0) + (y uint8 :offset 1) + (z uint8 :offset 2) + (w uint8 :offset 3) + (clr uint32 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype vector4b (structure) - ((data int8 4 :offset-assert 0) ;; guessed by decompiler - (x int8 :offset-assert 0) - (y int8 :offset-assert 1) - (z int8 :offset-assert 2) - (w int8 :offset-assert 3) - (clr int32 :offset-assert 0) + ((data int8 4 :offset-assert 0) + (x int8 :offset 0) + (y int8 :offset 1) + (z int8 :offset 2) + (w int8 :offset 3) + (clr int32 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype vector2ub (structure) - ((data uint8 2 :offset-assert 0) ;; guessed by decompiler - (x uint8 :offset-assert 0) - (y uint8 :offset-assert 1) - (clr uint16 :offset-assert 0) + ((data uint8 2 :offset-assert 0) + (x uint8 :offset 0) + (y uint8 :offset 1) + (clr uint16 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x2 :flag-assert #x900000002 ) -|# -#| (deftype vector2b (structure) - ((data int8 2 :offset-assert 0) ;; guessed by decompiler - (x int8 :offset-assert 0) - (y int8 :offset-assert 1) - (clr int16 :offset-assert 0) + ((data int8 2 :offset-assert 0) + (x int8 :offset 0) + (y int8 :offset 1) + (clr int16 :offset 0) ) :method-count-assert 9 :size-assert #x2 :flag-assert #x900000002 ) -|# -#| (deftype vector2h (structure) - ((data int16 2 :offset-assert 0) ;; guessed by decompiler - (x int16 :offset-assert 0) - (y int16 :offset-assert 2) + ((data int16 2 :offset-assert 0 :score -1) + (x int16 :offset 0) + (y int16 :offset 2) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype vector2uh (structure) - ((data uint16 2 :offset-assert 0) ;; guessed by decompiler - (x uint16 :offset-assert 0) - (y uint16 :offset-assert 2) - (val uint32 :offset-assert 0) + ((data uint16 2 :offset-assert 0) + (x uint16 :offset 0) + (y uint16 :offset 2) + (val uint32 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype vector3h (structure) - ((data int16 3 :offset-assert 0) ;; guessed by decompiler - (x int16 :offset-assert 0) - (y int16 :offset-assert 2) - (z int16 :offset-assert 4) + ((data int16 3 :offset-assert 0) + (x int16 :offset 0) + (y int16 :offset 2) + (z int16 :offset 4) ) :method-count-assert 9 :size-assert #x6 :flag-assert #x900000006 ) -|# -#| (deftype vector3uh (structure) - ((data uint16 3 :offset-assert 0) ;; guessed by decompiler - (x uint16 :offset-assert 0) - (y uint16 :offset-assert 2) - (z uint16 :offset-assert 4) + ((data uint16 3 :offset-assert 0) + (x uint16 :offset 0) + (y uint16 :offset 2) + (z uint16 :offset 4) ) :method-count-assert 9 :size-assert #x6 :flag-assert #x900000006 ) -|# -#| (deftype vector2w (structure) - ((data int32 2 :offset-assert 0) ;; guessed by decompiler - (x int32 :offset-assert 0) - (y int32 :offset-assert 4) + ((data int32 2 :offset-assert 0) + (x int32 :offset 0) + (y int32 :offset 4) ) :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype vector3w (structure) - ((data int32 3 :offset-assert 0) ;; guessed by decompiler - (x int32 :offset-assert 0) - (y int32 :offset-assert 4) - (z int32 :offset-assert 8) + ((data int32 3 :offset-assert 0) + (x int32 :offset 0) + (y int32 :offset 4) + (z int32 :offset 8) ) :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype vector4w (structure) - ((data int32 4 :offset-assert 0) ;; guessed by decompiler - (x int32 :offset-assert 0) - (y int32 :offset-assert 4) - (z int32 :offset-assert 8) - (w int32 :offset-assert 12) - (dword uint64 2 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + ((data int32 4 :offset-assert 0 :score -1) + (x int32 :offset 0) + (y int32 :offset 4) + (z int32 :offset 8) + (w int32 :offset 12) + (dword uint64 2 :offset 0) + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype vector2 (structure) - ((data float 2 :offset-assert 0) ;; guessed by decompiler - (x float :offset-assert 0) - (y float :offset-assert 4) + ((data float 2 :offset-assert 0) + (x float :offset 0) + (y float :offset 4) ) + :allow-misaligned :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype vector3 (structure) - ((data float 3 :offset-assert 0) ;; guessed by decompiler - (x float :offset-assert 0) - (y float :offset-assert 4) - (z float :offset-assert 8) + ((data float 3 :offset-assert 0) + (x float :offset 0) + (y float :offset 4) + (z float :offset 8) ) :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype vector4 (structure) - ((data float 4 :offset-assert 0) ;; guessed by decompiler - (x float :offset-assert 0) - (y float :offset-assert 4) - (z float :offset-assert 8) - (w float :offset-assert 12) - (dword uint64 2 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + ((data float 4 :offset-assert 0 :score -1) + (x float :offset 0) + (y float :offset 4) + (z float :offset 8) + (w float :offset 12) + (dword uint64 2 :offset 0) + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype vector4w-2 (structure) - ((data int32 8 :offset-assert 0) ;; guessed by decompiler - (quad uint128 2 :offset-assert 0) ;; guessed by decompiler - (vector vector4w 2 :offset-assert 0) ;; guessed by decompiler + ((data int32 8 :offset-assert 0 :score -2) + (quad uint128 2 :offset 0 :score -1) + (vector vector4w 2 :inline :offset 0) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype vector4w-3 (structure) - ((data int32 12 :offset-assert 0) ;; guessed by decompiler - (quad uint128 3 :offset-assert 0) ;; guessed by decompiler - (vector vector4w 3 :offset-assert 0) ;; guessed by decompiler + ((data int32 12 :offset-assert 0 :score -2) + (quad uint128 3 :offset 0 :score -1) + (vector vector4w 3 :inline :offset 0) ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype vector4w-4 (structure) - ((data int32 16 :offset-assert 0) ;; guessed by decompiler - (quad uint128 4 :offset-assert 0) ;; guessed by decompiler - (vector vector4w 4 :offset-assert 0) ;; guessed by decompiler + ((data int32 16 :offset-assert 0) + (quad uint128 4 :offset 0) + (vector vector4w 4 :inline :offset 0 :score 999) ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype vector4h (structure) - ((data int16 4 :offset-assert 0) ;; guessed by decompiler - (x int16 :offset-assert 0) - (y int16 :offset-assert 2) - (z int16 :offset-assert 4) - (w int16 :offset-assert 6) - (long uint64 :offset-assert 0) + ((data int16 4 :offset-assert 0) + (x int16 :offset 0) + (y int16 :offset 2) + (z int16 :offset 4) + (w int16 :offset 6) + (long uint64 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype vector4uh (structure) - ((data UNKNOWN 4 :offset-assert 0) - (x uint16 :offset-assert 0) - (y uint16 :offset-assert 2) - (z uint16 :offset-assert 4) - (w uint16 :offset-assert 6) - (long uint64 :offset-assert 0) + ((data uint16 4 :offset-assert 0) + (x uint16 :offset 0) + (y uint16 :offset 2) + (z uint16 :offset 4) + (w uint16 :offset 6) + (long uint64 :offset 0) ) :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype vector8h (structure) - ((data int16 8 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + ((data int16 8 :offset-assert 0) + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype vector16b (structure) - ((data int8 16 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + ((data int8 16 :offset-assert 0) + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype vector4s-3 (structure) - ((data float 12 :offset-assert 0) ;; guessed by decompiler - (quad uint128 3 :offset-assert 0) ;; guessed by decompiler - (vector vector 3 :offset-assert 0) ;; guessed by decompiler + ((data float 12 :offset-assert 0) + (quad uint128 3 :offset 0) + (vector vector 3 :inline :offset 0) ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype vector-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data vector :dynamic :offset-assert 16) ;; guessed by decompiler + ((data vector :inline :dynamic :offset-assert 16 :score 10) ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype rgbaf (vector) - ((r float :offset-assert 0) - (g float :offset-assert 4) - (b float :offset-assert 8) - (a float :offset-assert 12) + ((r float :offset 0) + (g float :offset 4) + (b float :offset 8) + (a float :offset 12) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype plane (vector) - ((a float :offset-assert 0) - (b float :offset-assert 4) - (c float :offset-assert 8) - (d float :offset-assert 12) + ((a float :offset 0) + (b float :offset 4) + (c float :offset 8) + (d float :offset 12) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype sphere (vector) - ((r float :offset-assert 12) + ((r float :offset 12 :score 1) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (deftype isphere (vec4s) -;; () -;; :flag-assert #x900000010 -;; ) +(deftype isphere (vec4s) + () + ) -#| (deftype box8s (structure) - ((data float 8 :offset-assert 0) ;; guessed by decompiler - (quad uint128 2 :offset-assert 0) ;; guessed by decompiler - (vector vector 2 :offset-assert 0) ;; guessed by decompiler - (min vector :inline :offset-assert 0) - (max vector :inline :offset-assert 16) + ((data float 8 :offset-assert 0) + (quad uint128 2 :offset 0) + (vector vector 2 :offset 0) + (min vector :inline :offset 0) + (max vector :inline :offset 16) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype box8s-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data box8s :dynamic :offset-assert 16) ;; guessed by decompiler + ((data box8s :inline :dynamic :offset-assert 16) ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype vertical-planes (structure) - ((data uint128 4 :offset-assert 0) ;; guessed by decompiler + ((data uint128 4 :offset-assert 0) ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype vertical-planes-array (basic) - ((length uint32 :offset-assert 4) - (data vertical-planes :dynamic :offset-assert 16) ;; guessed by decompiler + ((length uint32 :offset-assert 4) + (data vertical-planes :inline :dynamic :offset-assert 16) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype qword (structure) - ((data uint32 4 :offset-assert 0) ;; guessed by decompiler - (byte uint8 16 :offset-assert 0) ;; guessed by decompiler - (hword uint16 8 :offset-assert 0) ;; guessed by decompiler - (word uint32 4 :offset-assert 0) ;; guessed by decompiler - (dword uint64 2 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) - (vector vector :inline :offset-assert 0) - (vector4w vector4w :inline :offset-assert 0) + ((data uint32 4 :offset-assert 0) + (byte uint8 16 :offset 0) + (hword uint16 8 :offset 0) + (word uint32 4 :offset 0) + (dword uint64 2 :offset 0) + (quad uint128 :offset 0) + (vector vector :inline :offset 0 :score -100) + (vector4w vector4w :inline :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype vector3s (structure) - ((data float 3 :offset-assert 0) ;; guessed by decompiler - (x float :offset-assert 0) - (y float :offset-assert 4) - (z float :offset-assert 8) + ((data float 3 :offset-assert 0) + (x float :offset 0) + (y float :offset 4) + (z float :offset 8) ) + :pack-me :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -;; vector is already defined! - -;; (define-extern *null-vector* object) ;; vector -;; (define-extern *identity-vector* object) ;; vector -;; (define-extern *x-vector* object) ;; vector -;; (define-extern *y-vector* object) ;; vector -;; (define-extern *z-vector* object) ;; vector -;; (define-extern *up-vector* object) ;; vector -;; (define-extern vector-dot function) ;; (function vector vector float) -;; (define-extern vector-dot-vu function) ;; (function vector vector float) -;; (define-extern vector4-dot function) ;; (function vector vector float) -;; (define-extern vector4-dot-vu function) ;; (function vector vector float) -;; (define-extern vector-xz-dot function) -;; (define-extern vector+! function) ;; (function vector vector vector vector) -;; (define-extern vector-! function) ;; (function vector vector vector vector) -;; (define-extern vector-zero! function) ;; (function vector vector) -;; (define-extern vector-reset! function) ;; (function vector vector) -;; (define-extern vector-copy! function) ;; (function vector vector vector) -;; (define-extern vector-xz-! function) -;; (define-extern vector-xz+! function) -;; (define-extern vector-vector-project-compute-length! function) -;; (define-extern vector-vector-perpendicular! function) -;; (define-extern vector-length< function) ;; (function vector float symbol) -;; (define-extern vector-length> function) ;; (function vector float symbol) -;; (define-extern *zero-vector* object) ;; vector +(define-extern *null-vector* vector) ;; +(define-extern *identity-vector* vector) ;; +(define-extern *x-vector* vector) ;; +(define-extern *y-vector* vector) +(define-extern *z-vector* vector) +(define-extern *up-vector* vector) +(define-extern vector-dot + "Take the dot product of two vectors. + Only does the x, y, z compoments. + Originally handwritten assembly to space out loads and use FPU accumulator" + (function vector vector float)) +(define-extern vector-dot-vu "Take the dot product (xyz only). Using VU0." (function vector vector float)) +(define-extern vector4-dot + "Take the dot product of two vectors. + Does the x, y, z, and w compoments" + (function vector vector float)) +(define-extern vector4-dot-vu "Take the dot product (xyzw). Using VU0." (function vector vector float)) +(define-extern vector-xz-dot + "Take the dot product of two vectors. + Only does the x and z compoments. + Originally handwritten assembly to space out loads and use FPU accumulator" + (function vector vector float)) +(define-extern vector+! "Set dst = a + b. The w component of dst is set to 0." (function vector vector vector vector)) +(define-extern vector-! "Set dst = a - b. The w componenent of dst is set to 0." (function vector vector vector vector)) +(define-extern vector-zero! "Set xyzw to 0." (function vector vector)) +(define-extern vector-reset! "Set vector to <0,0,0,1>." (function vector vector)) +(define-extern vector-copy! "Copy arg1 to arg0." (function vector vector vector)) +(define-extern vector-xz-! (function vector vector vector vector)) +(define-extern vector-xz+! (function vector vector vector vector)) +(define-extern vector-vector-project-compute-length! (function vector vector vector vector)) +(define-extern vector-vector-perpendicular! (function vector vector vector vector)) +(define-extern vector-length< (function vector float symbol)) +(define-extern vector-length> (function vector float symbol)) +(define-extern *zero-vector* vector) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gravity-h ;; @@ -1701,7 +1809,6 @@ ;; bounding-box-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype bounding-box (structure) ((min vector :inline :offset-assert 0) (max vector :inline :offset-assert 16) @@ -1710,24 +1817,31 @@ :size-assert #x20 :flag-assert #x1600000020 (:methods - (bounding-box-method-9 () none) ;; 9 ;; (add-spheres! (_type_ (inline-array sphere) int) int) - (bounding-box-method-10 () none) ;; 10 ;; (add-box! (_type_ bounding-box) int) - (bounding-box-method-11 () none) ;; 11 ;; (add-point! (_type_ vector) none) - (bounding-box-method-12 () none) ;; 12 ;; (intersects-line-segment? (_type_ vector vector) symbol) - (bounding-box-method-13 () none) ;; 13 ;; (set-from-point-offset! (_type_ vector vector) none) - (bounding-box-method-14 () none) ;; 14 ;; (set-from-point-offset-pad! (_type_ vector vector float) int) - (bounding-box-method-15 () none) ;; 15 ;; (set-to-point! (_type_ vector) none) - (bounding-box-method-16 () none) ;; 16 ;; (set-from-sphere! (_type_ sphere) none) - (bounding-box-method-17 () none) ;; 17 ;; (set-from-spheres! (_type_ (inline-array sphere) int) int) - (bounding-box-method-18 () none) ;; 18 ;; (get-bounding-sphere (_type_ vector) vector) - (bounding-box-method-19 () none) ;; 19 ;; (inside-xyz? (bounding-box vector) symbol) - (bounding-box-method-20 () none) ;; 20 ;; (inside-xz? (bounding-box vector) symbol) - (bounding-box-method-21 () none) ;; 21 + ;; TODO - some of these methods changed, some need to be adjusted + (add-spheres! "Add count spheres." (_type_ (inline-array sphere) int) int) ;; 9 + ;; - same + (add-box! "Expand the box as needed to contain the given box." (_type_ bounding-box) int) ;; 10 + (add-point! "Expand the box as needed to contain the given point." (_type_ vector) none) ;; 11 + (intersects-line-segment? + "Check intersection in xz plane, using liang-barsky. Not sure if this actually + a useful check or not..." + (_type_ vector vector) symbol) ;; 12 + (set-from-point-offset! "Set to the smallest box containing arg0, (arg0 + arg1)" (_type_ vector vector) none) ;; 13 + (set-from-point-offset-pad! "Set the box to contain arg0, arg0 + offset, with some padding." (_type_ vector vector float) int) ;; 14 + (set-to-point! "Set the box to be a single point." (_type_ vector) none) ;; 15 + (set-from-sphere! "Set the box to contain a single sphere." (_type_ sphere) none) ;; 16 + ;; - same ends + (set-from-spheres! + "Reset box to hold the given spheres. + Note: this implementation could be optimized." + (_type_ (inline-array sphere) int) int) ;; 17 + (get-bounding-sphere "Get a bounding sphere for a bounding box." (_type_ vector) vector) ;; 18 + (inside-xyz? "Is the point in the box?" (_type_ vector) symbol) ;; 19 + (inside-xz? "Is the point in the box? Check xz only." (_type_ vector) symbol) ;; 20 + (bounding-box-method-21 (_type_ (inline-array vector)) symbol) ;; 21 ) ) -|# -#| (deftype bounding-box2 (structure) ((min vector2 :inline :offset-assert 0) (max vector2 :inline :offset-assert 8) @@ -1736,9 +1850,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype bounding-box4w (structure) ((min vector4w :inline :offset-assert 0) (max vector4w :inline :offset-assert 16) @@ -1747,9 +1859,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype bounding-box-both (structure) ((box bounding-box :inline :offset-assert 0) (box4w bounding-box4w :inline :offset-assert 32) @@ -1758,117 +1868,127 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype bounding-box-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data bounding-box :dynamic :offset-assert 16) ;; guessed by decompiler + ((data bounding-box :dynamic :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; matrix-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype matrix (structure) - ((data float 16 :offset-assert 0) ;; guessed by decompiler - (vector vector 4 :offset-assert 0) ;; guessed by decompiler - (quad uint128 4 :offset-assert 0) ;; guessed by decompiler - (rvec vector :inline :offset-assert 0) - (uvec vector :inline :offset-assert 16) - (fvec vector :inline :offset-assert 32) - (trans vector :inline :offset-assert 48) + "A 4x4 matrix, stored in row-major order. + some, but not all, functions assume that a matrix is an affine transform. + others assume that the rotation has no scale or shear (and that its inverse is its transpose)." + ((data float 16 :offset-assert 0 :score -3) ;; guessed by decompiler + (vector vector 4 :inline :offset 0 :score -2) ;; guessed by decompiler + (quad uint128 4 :offset 0 :score -1) ;; guessed by decompiler + (rvec vector :inline :offset 0 :score 0) + (uvec vector :inline :offset 16 :score 0) + (fvec vector :inline :offset 32 :score 0) + (trans vector :inline :offset 48 :score 0) ) :method-count-assert 10 :size-assert #x40 :flag-assert #xa00000040 (:methods - (matrix-method-9 () none) ;; 9 ;; (transform-vectors! (_type_ (inline-array vector) (inline-array vector) int) none) + (transform-vectors! + "Transform many vectors. This acts like w = 1, even if it isn't. The value of w is copied." + (_type_ (inline-array vector) (inline-array vector) int) none) ;; 9 ) ) -|# -#| (deftype matrix3 (structure) - ((data float 12 :offset-assert 0) ;; guessed by decompiler - (vector vector 3 :offset-assert 0) ;; guessed by decompiler - (quad uint128 3 :offset-assert 0) ;; guessed by decompiler + "A 3x3 matrix, stored in row-major order. + NOTE: the rows each have an extra 4-bytes of padding, + so this is really a 3x4 matrix. + This type is rarely used." + ((data float 12 :offset-assert 0 :score -1) ;; guessed by decompiler + (vector vector 3 :inline :offset 0) ;; guessed by decompiler + (quad uint128 3 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype matrix4h (structure) - ((data int16 16 :offset-assert 0) ;; guessed by decompiler - (vector4h vector4h 4 :offset-assert 0) ;; guessed by decompiler - (long int64 4 :offset-assert 0) ;; guessed by decompiler + "A matrix stored using 16-bit integers. + Note that these usually have different scaling for the 4th row which + contains the translation in an affine transform. + So you generally should not unpack these to floats without knowing where they came from + and how they were originally packed (for example, in tie/shrub)." + ((data int16 16 :offset-assert 0 :score -1) ;; guessed by decompiler + (vector4h vector4h 4 :offset 0) ;; guessed by decompiler + (long int64 4 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -;; (define-extern matrix-copy! function) ;; (function matrix matrix matrix) -;; (define-extern matrix<-vector-yz-exact! function) ;; (function matrix vector vector matrix) -;; (define-extern matrix<-vector-yz! function) ;; (function matrix vector vector matrix) -;; (define-extern matrix<-vector-z! function) ;; (function matrix vector matrix) +(define-extern matrix-copy! "Copy arg1 to arg0" (function matrix matrix matrix)) +(define-extern matrix<-vector-yz-exact! (function matrix vector vector matrix)) +(define-extern matrix<-vector-yz! (function matrix vector vector matrix)) +(define-extern matrix<-vector-z! (function matrix vector matrix)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; quaternion-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype quaternion (structure) - ((data float 4 :offset-assert 0) ;; guessed by decompiler - (x float :offset-assert 0) - (y float :offset-assert 4) - (z float :offset-assert 8) - (w float :offset-assert 12) - (vec vector :inline :offset-assert 0) - (quad uint128 :offset-assert 0) + "Quaternion. Stored in xyzw order." + ((data float 4 :offset-assert 0 :score -1) ;; guessed by decompiler + (x float :offset 0) + (y float :offset 4) + (z float :offset 8) + (w float :offset 12) + (vec vector :inline :offset 0) + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern *unity-quaternion* object) ;; quaternion +(define-extern *unity-quaternion* quaternion) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; euler-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype euler-angles (vector) + "Just uses the same xyzw and data array as vector. + The `w` stores an integer that seems to have + bitfields for... something? Like maybe the order? + Euler angles are mostly unused, and the code is a bit of disaster." () :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern EulSafe array) ;; (array int32) -;; (define-extern EulNext array) ;; (array int32) +(define-extern EulSafe + "Maybe euler angle storage orders? + What is this naming convention?" + (array int32)) +(define-extern EulNext (array int32)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; transform-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype transformq (structure) + "Transformation. w components of vectors should be 1.0 + This can represent any rotation, translation, and scaling. + Note that the scaling is applied before rotation + (meaning it scales along the axes of the pre-transformed frame)." ((trans vector :inline :offset-assert 0) (rot vector :inline :offset-assert 16) (scale vector :inline :offset-assert 32) @@ -1877,19 +1997,22 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype trsq (basic) + "Like transform, but it's a basic. + Note that the trsq child type overrides this rotation with a quaternion. + usage of the plain trs is very limited, at least in Jak 1." ((trans vector :inline :offset-assert 16) (rot vector :inline :offset-assert 32) (scale vector :inline :offset-assert 48) ) + (:methods + (new (symbol type) _type_) ;; 0 + ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1901,7 +2024,6 @@ ;; geometry-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype curve (structure) ((cverts (inline-array vector) :offset-assert 0) ;; guessed by decompiler (num-cverts int32 :offset-assert 4) @@ -1909,13 +2031,12 @@ (num-knots int32 :offset-assert 12) (length float :offset-assert 16) ) + :allow-misaligned :method-count-assert 9 :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype line-intersection-val (structure) ((tt0 float :offset-assert 0) (tt1 float :offset-assert 4) @@ -1924,9 +2045,7 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype border-plane (basic) ((name symbol :offset-assert 4) ;; guessed by decompiler (action basic :offset-assert 8) @@ -1938,14 +2057,14 @@ :size-assert #x30 :flag-assert #xb00000030 (:methods - (border-plane-method-9 () none) ;; 9 ;; (debug-draw (_type_) int) - (border-plane-method-10 () none) ;; 10 ;; (point-past-plane? (_type_ vector) symbol) + (debug-draw (_type_) int) ;; 9 + (point-past-plane? (_type_ vector) symbol) ;; 10 ) ) -|# -#| (deftype lissajous (structure) + "A curve where the x and y position are set by two different sinusoids. + This stores the parameters and state for evaluating this curve." ((x-mag float :offset-assert 0) (y-mag float :offset-assert 4) (theta float :offset-assert 8) @@ -1954,17 +2073,19 @@ (period-shift float :offset-assert 20) (theta-rate float :offset-assert 24) ) + :pack-me :method-count-assert 10 :size-assert #x1c :flag-assert #xa0000001c (:methods - (lissajous-method-9 () none) ;; 9 ;; (evaluate! (_type_ vector) vector) + (evaluate! "Set the x and y component of the vector to the current point on the curve." + (_type_ vector) vector) ;; 9 ) ) -|# -#| (deftype lissajous-interp (structure) + "Handles interpolating between two different lissajous parameters, and also + stepping forward the dynamics." ((current lissajous :inline :offset-assert 0) (dest lissajous :inline :offset-assert 28) (rate lissajous :inline :offset-assert 56) @@ -1973,78 +2094,117 @@ :size-assert #x54 :flag-assert #xb00000054 (:methods - (lissajous-interp-method-9 () none) ;; 9 ;; (evaluate! (_type_ vector) vector) - (lissajous-interp-method-10 () none) ;; 10 ;; (update! (_type_) float) + (evaluate! "Set the x and y component of the vector to the current point on the curve." + (_type_ vector) vector) ;; 9 + (update! "Update both the interpolation, and the curves themselves." + (_type_) float) ;; 10 ) ) -|# -#| (deftype ellipsoid (vector) - ((height float :offset-assert 4) - (width float :offset-assert 0) - (length float :offset-assert 8) - (h float :offset-assert 4) - (l float :offset-assert 8) + ((width float :offset 0) + (height float :offset 4) + (length float :offset 8) + (h float :offset 4) + (l float :offset 8) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern point-in-ellipsoid? function) -;; (define-extern ellipsoid-random-point-on! function) -;; (define-extern ellipsoid-normal-at! function) +(define-extern point-in-ellipsoid? (function ellipsoid vector float)) +(define-extern ellipsoid-random-point-on! (function ellipsoid vector vector)) +(define-extern ellipsoid-normal-at! (function ellipsoid vector vector vector)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; transformq-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype trsqv (trsq) - ((pause-adjust-distance meters :offset-assert 4) - (nav-radius meters :offset-assert 8) + "A transform with: + - type information (child of [[basic]]) + - rotation stored as quaternion + - velocity information. + This is a very commonly used type to represent the position of an in-game object. + The `root` of a process-drawable (the parent 'in-game object' type) is a [[trsqv]]. + Additionally, the collision system uses [[trsqv]] as the parent type for foreground + collision objects ([[collide-shape]], [[collide-shape-moving]]). + As a result, this type has a lot of weird methods and extra stuff hidden in it." + ((pause-adjust-distance meters :offset 4) + (nav-radius meters :offset 8) (transv vector :inline :offset-assert 64) (rotv vector :inline :offset-assert 80) (scalev vector :inline :offset-assert 96) (dir-targ quaternion :inline :offset-assert 112) - (angle-change-time uint64 :offset-assert 128) ;; time-frame + (angle-change-time time-frame :offset-assert 128) (old-y-angle-diff float :offset-assert 136) ) :method-count-assert 28 :size-assert #x8c :flag-assert #x1c0000008c (:methods - (trsqv-method-9 () none) ;; 9 ;; (seek-toward-heading-vec! (_type_ vector float time-frame) quaternion) - (trsqv-method-10 () none) ;; 10 ;; (set-heading-vec! (_type_ vector) quaternion) - (trsqv-method-11 () none) ;; 11 ;; (seek-to-point-toward-point! (_type_ vector float time-frame) quaternion) - (trsqv-method-12 () none) ;; 12 ;; (point-toward-point! (_type_ vector) quaternion) - (trsqv-method-13 () none) ;; 13 ;; (seek-toward-yaw-angle! (_type_ float float time-frame) quaternion) - (trsqv-method-14 () none) ;; 14 ;; (set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion) - (trsqv-method-15 () none) ;; 15 ;; (set-roll-to-grav! (_type_ float) quaternion) - (trsqv-method-16 () none) ;; 16 ;; (set-roll-to-grav-2! (_type_ float) quaternion) - (trsqv-method-17 () none) ;; 17 ;; (rotate-toward-orientation! (_type_ quaternion float float int int float) quaternion) - (trsqv-method-18 () none) ;; 18 ;; (set-quaternion! (_type_ quaternion) quaternion) - (trsqv-method-19 () none) ;; 19 ;; (set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion) - (trsqv-method-20 () none) ;; 20 ;; (point-toward-point-clear-roll-pitch! (_type_ vector) quaternion) - (trsqv-method-21 () none) ;; 21 ;; (rot->dir-targ! (_type_) quaternion) - (trsqv-method-22 () none) ;; 22 ;; (y-angle (_type_) float) - (trsqv-method-23 () none) ;; 23 ;; (global-y-angle-to-point (_type_ vector) float) - (trsqv-method-24 () none) ;; 24 ;; (relative-y-angle-to-point (_type_ vector) float) - (trsqv-method-25 () none) ;; 25 ;; (roll-relative-to-gravity (_type_) float) - (trsqv-method-26 () none) ;; 26 ;; (set-and-limit-velocity (_type_ int vector float) trsqv) - (trsqv-method-27 () none) ;; 27 ;; (get-quaternion (_type_) quaternion) + (seek-toward-heading-vec! + "Adjust the orientation to point along dir, only changing our yaw. + The vel is a maximum velocity limit. + The frame count is the time constant (first order). + There's some logic to avoid rapidly changing directions" + (_type_ vector float time-frame) quaternion) ;; 9 + (set-heading-vec! + "Makes us look in the arg0 direction immediately. Pitch will be unchanged." + (_type_ vector) quaternion) ;; 10 + (seek-to-point-toward-point! + "Seek toward pointing toward arg0 from our current location." + (_type_ vector float time-frame) quaternion) ;; 11 + (point-toward-point! "Immediately point toward arg0." (_type_ vector) quaternion) ;; 12 + (seek-toward-yaw-angle! "Seek toward the given yaw angle." (_type_ float float time-frame) quaternion) ;; 13 + (set-yaw-angle-clear-roll-pitch! + "Immediately clear our roll and pitch and set yaw to the given angle." + (_type_ float) quaternion) ;; 14 + (set-roll-to-grav! + "Set our roll so that our local down aligns with standard gravity." + (_type_ float) quaternion) ;; 15 + (set-roll-to-grav-2! + "Set our roll so that our local down aligns with standard gravity." + (_type_ float) quaternion) ;; 16 + (rotate-toward-orientation! + "Adjust our orientation toward target, subject to some rate limits. + For Jak 1, I said: + I don't think this is a very robust function and probably doesn't work right in cases + where an axis flips by 180 degrees. + But now they use matrix-from-two-vectors-the-long-way-smooth to fix it! Good job. + This additionally uses the fancy logic of matrix-from-two-vectors-smooth." + (_type_ quaternion float float int int float) quaternion) ;; 17 + (set-quaternion! "Set this [[trsqv]]'s quaternion." (_type_ quaternion) quaternion) ;; 18 + (set-heading-vec-clear-roll-pitch! + "Set our rotation to point along the given heading, with no roll or pitch." + (_type_ vector) quaternion) ;; 19 + (point-toward-point-clear-roll-pitch! + "Set our orientation to point toward arg0, clearing roll and pitch." + (_type_ vector) quaternion) ;; 20 + (rot->dir-targ! + "Set the target direction for this [[trsqv]] to its quaternion." + (_type_) quaternion) ;; 21 + (y-angle "Get the y angle for this [[trsqv]]'s quaternion." (_type_) float) ;; 22 + (global-y-angle-to-point + "Get the angle in the xz plane from the position of this trsqv to the point arg0 + (ignores our current yaw)." + (_type_ vector) float) ;; 23 + (relative-y-angle-to-point + "Get the y angle between the current orientation and arg0 + (how much we'd have to yaw to point at arg0)." + (_type_ vector) float) ;; 24 + (roll-relative-to-gravity "Get our roll, relative to 'down' from gravity." (_type_) float) ;; 25 + (set-and-limit-velocity (_type_ int vector float) trsqv) ;; 26 + (get-quaternion "Get the quat for this [[trsqv]]." (_type_) quaternion) ;; 27 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; bounding-box ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype liang-barsky-line-clip-params (structure) ((te float :offset-assert 0) (tl float :offset-assert 4) @@ -2053,11 +2213,10 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -;; (define-extern box-vector-enside? function) ;; (function bounding-box vector symbol) -;; (define-extern box-vector-inside? function) ;; (function bounding-box vector symbol) -;; (define-extern liang-barsky-line-clipt function) ;; (function liang-barsky-line-clip-params float float symbol) +(define-extern box-vector-enside? "Is the point in the box? On the edge doesn't count." (function bounding-box vector symbol)) +(define-extern box-vector-inside? "Is the point in the box? On the edge counts." (function bounding-box vector symbol)) +(define-extern liang-barsky-line-clipt "Clip test in 1 dimension. Is arg1 in arg2?" (function liang-barsky-line-clip-params float float symbol)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; matrix ;; @@ -2067,79 +2226,159 @@ ;; matrix3 is already defined! -;; (define-extern matrix-identity! function) ;; (function matrix matrix) -;; (define-extern *identity-matrix* object) ;; matrix -;; (define-extern *hermite-matrix* object) ;; matrix -;; (define-extern matrix+! function) ;; (function matrix matrix matrix matrix) -;; (define-extern matrix-! function) ;; (function matrix matrix matrix matrix) -;; (define-extern matrix*! function) ;; (function matrix matrix matrix matrix) -;; (define-extern matrixp*! function) ;; (function matrix matrix matrix matrix) -;; (define-extern vector-matrix*! function) ;; (function vector vector matrix vector) -;; (define-extern vector-norm-matrix*! function) ;; (function vector vector matrix vector) -;; (define-extern vector-rotate*! function) ;; (function vector vector matrix vector) -;; (define-extern vector3s-matrix*! function) ;; (function vector3s vector3s matrix vector3s) -;; (define-extern vector3s-rotate*! function) ;; (function vector3s vector3s matrix vector3s) -;; (define-extern matrix-transpose! function) ;; (function matrix matrix matrix) -;; (define-extern matrix-inverse-of-rot-trans! function) ;; (function matrix matrix matrix) -;; (define-extern matrix-4x4-inverse! function) ;; (function matrix matrix matrix) -;; (define-extern matrix-translate! function) ;; (function matrix vector matrix) -;; (define-extern matrix-translate+! function) ;; (function matrix matrix vector matrix) -;; (define-extern matrix-scale! function) ;; (function matrix vector matrix) -;; (define-extern scale-matrix! function) ;; (function matrix vector matrix matrix) -;; (define-extern matrix-inv-scale! function) ;; (function matrix vector matrix) -;; (define-extern column-scale-matrix! function) ;; (function matrix vector matrix matrix) -;; (define-extern matrix-rotate-x! function) ;; (function matrix float matrix) -;; (define-extern matrix-rotate-y! function) ;; (function matrix float matrix) -;; (define-extern matrix-rotate-z! function) ;; (function matrix float matrix) -;; (define-extern matrix-rotate-zyx! function) ;; (function matrix vector matrix) -;; (define-extern matrix-rotate-xyz-2! function) ;; (function matrix vector matrix) -;; (define-extern matrix-rotate-xyz! function) ;; (function matrix vector matrix) -;; (define-extern matrix-rotate-zxy! function) ;; (function matrix vector matrix) -;; (define-extern matrix-rotate-yxz! function) ;; (function matrix vector matrix) -;; (define-extern matrix-rotate-yzx! function) ;; (function matrix vector matrix) -;; (define-extern matrix-rotate-yxy! function) ;; (function matrix vector matrix) -;; (define-extern matrix-rotate-yx! function) ;; (function matrix float float matrix) -;; (define-extern matrix-axis-sin-cos-vu! function) ;; (function matrix vector float float none) -;; (define-extern matrix-axis-sin-cos! function) ;; (function matrix vector float float matrix) -;; (define-extern matrix-axis-angle! function) ;; (function matrix vector float matrix) -;; (define-extern matrix-lerp! function) ;; (function matrix matrix matrix float matrix) -;; (define-extern matrix-3x3-determinant function) ;; (function matrix float) -;; (define-extern matrix3-determinant function) ;; (function matrix float) -;; (define-extern matrix-3x3-inverse! function) ;; (function matrix matrix matrix) -;; (define-extern matrix-3x3-inverse-transpose! function) ;; (function matrix matrix matrix) -;; (define-extern matrix3-inverse-transpose! function) ;; (function matrix matrix matrix) -;; (define-extern matrix-3x3-normalize! function) ;; (function matrix matrix matrix) -;; (define-extern matrix-4x4-determinant function) ;; (function matrix float) -;; (define-extern matrix-4x4-inverse-transpose! function) ;; (function matrix matrix matrix) -;; (define-extern matrix-y-angle function) ;; (function matrix float) -;; (define-extern matrix->trans function) ;; (function matrix vector vector) -;; (define-extern matrix<-trans function) ;; (function matrix vector matrix) -;; (define-extern matrix->scale function) ;; (function matrix vector vector) -;; (define-extern matrix-remove-scale! function) -;; (define-extern matrix<-scale function) ;; (function matrix vector matrix) -;; (define-extern matrix->quat function) ;; (function matrix quaternion quaternion) -;; (define-extern matrix<-quat function) ;; (function matrix quaternion matrix) -;; (define-extern matrix-extract-rotation! function) -;; (define-extern matrix->transformq function) ;; (function transformq matrix transformq) -;; (define-extern matrix-mirror! function) ;; (function matrix vector vector matrix) +(define-extern matrix-identity! "Set dst to the identity matrix." (function matrix matrix)) +(define-extern *identity-matrix* matrix) +(define-extern *hermite-matrix* matrix) +(define-extern matrix+! + "Set dst = src1 + src2. It is okay for any arguments to be the same data. + This is not an efficient implementation." + (function matrix matrix matrix matrix)) +(define-extern matrix-! + "Set dst = src1 - src1. It is okay for any arugments to be the same data. + This is not an efficient implementation." + (function matrix matrix matrix matrix)) +(define-extern matrix*! + "Set dst = src1 * src2. It is okay for any arguments to be the same data. + This is a moderately efficient implementation." + (function matrix matrix matrix matrix)) +(define-extern matrixp*! + "Set dst = src1 * src2. NOTE: this function is a wrapper around matrix*! + that adds no additional functionality. It seems to be a leftover from + a time when matrix*! wasn't safe to use in place. This is unused." + (function matrix matrix matrix matrix)) +(define-extern vector-matrix*! "Set dst = vec * mat. dst may be equal to src." (function vector vector matrix vector)) +(define-extern vector-norm-matrix*! (function vector vector matrix vector)) +(define-extern vector-rotate*! + "Set dst to be the input vector rotated by the rotation part of mat. + The input matrix should be a homogeneous transform with a rotation matrix as its upper-left 3x3. + dst may be equal to src." + (function vector vector matrix vector)) +(define-extern vector3s-matrix*! + "Set dst to be ([src 1.0] * mat).xyz. Doesn't touch the w of dst. + dst and vec can be the same memory" + (function vector3s vector3s matrix vector3s)) +(define-extern vector3s-rotate*! + "Set dst to vec rotated by the rotation in the homogeneous transform mat. + mat should not have a scale/shear (the upper 3x3 should be a pure rotation)." + (function vector3s vector3s matrix vector3s)) +(define-extern matrix-transpose! "Set dst = src^T. src and dst can be the same." (function matrix matrix matrix)) +(define-extern matrix-inverse-of-rot-trans! + "Set dst = src^-1, assuming src is a homogeneous tranform with only rotation/translation. + NOTE: THIS FUNCTION REQUIRES dst != src" + (function matrix matrix matrix)) +(define-extern matrix-4x4-inverse! + "Invert a 4x4 matrix. This assumes that the input is a homogeneous transform. + Src and dst can be the same." + (function matrix matrix matrix)) +(define-extern matrix-translate! "Set dst to a homogeneous transform with only a translation of trans." (function matrix vector matrix)) +(define-extern matrix-translate+! + "Add the given translation to the translation of homogenous transform mat src + and store in dst. It is okay for dst = src." + (function matrix matrix vector matrix)) +(define-extern matrix-scale! + "Set dst to a homogenous transform with only a scale. The x,y,z components + of scale become the x,y,z scaling factors" + (function matrix vector matrix)) +(define-extern scale-matrix! + "Scale an existing matrix. Okay for dst = src. The scaling is applied per row. + This means the x component of scale is used to scale the first row of src. + The w component of scale is used." + (function matrix vector matrix matrix)) +(define-extern matrix-inv-scale! + "Set dst to a homogeneous transform with only a scale. + The x,y,z components of scale are inverted and used as the x,y,z scaling factors" + (function matrix vector matrix)) +(define-extern column-scale-matrix! + "Scale an existing matrix. Okay for dst = src. The scaling is applied column-wise. + Meaning the x component of scale will scale the first column of src." + (function matrix vector matrix matrix)) +(define-extern matrix-rotate-x! + "Set dst to a homogeneous transform matrix for a rotation around the x-axis (degrees)." + (function matrix float matrix)) +(define-extern matrix-rotate-y! + "Set dst to a homoegeneous transform matrix for a rotation around the y axis (degrees)." + (function matrix float matrix)) +(define-extern matrix-rotate-z! + "Set dst to a homogeneous transform matrix for a rotation around the z-axis (degrees)." + (function matrix float matrix)) +(define-extern matrix-rotate-zyx! "Rotate in z,y,x order." (function matrix vector matrix)) +(define-extern matrix-rotate-xyz-2! + "Jak 1 version of matrix-rotate-xyz. Slower than the one below." + (function matrix vector matrix)) +(define-extern matrix-rotate-xyz! "Rotate in x,y,z order." (function matrix vector matrix)) +(define-extern matrix-rotate-zxy! "Rotate in z,x,y order." (function matrix vector matrix)) +(define-extern matrix-rotate-yxz! "Rotate in y,x,z order." (function matrix vector matrix)) +(define-extern matrix-rotate-yzx! "Rotate in y,z,x order." (function matrix vector matrix)) +(define-extern matrix-rotate-yxy! + "Rotate. I believe in yxy order? Compared to the other rotations, this one + is quite a bit more optimized and avoid repeated trig operations." + (function matrix vector matrix)) +(define-extern matrix-rotate-yx! "Rotate by y then x." (function matrix float float matrix)) +(define-extern matrix-axis-sin-cos-vu! + "Create an axis-angle rotation matrix. But given the sin/cos of the angle. Uses the VU." + (function matrix vector float float none)) +(define-extern matrix-axis-sin-cos! + "Create an axis-angle rotation matrix. But given the sin/cos of the angle." + (function matrix vector float float matrix)) +(define-extern matrix-axis-angle! "Create an axis-angle rotation matrix." (function matrix vector float matrix)) +(define-extern matrix-lerp! "Lerp an entire matrix, coefficient-wise." (function matrix matrix matrix float matrix)) +(define-extern matrix-3x3-determinant "Compute the determinant of a 3x3 matrix." (function matrix float)) +(define-extern matrix3-determinant "Unused. Not sure if this has limitations compared to the above version." (function matrix float)) +(define-extern matrix-3x3-inverse! + "Compute the inverse of a 3x3 matrix. Not very efficient. + Requires src != dst." + (function matrix matrix matrix)) +(define-extern matrix-3x3-inverse-transpose! + "Invert and transpose. + Requires dst != src." + (function matrix matrix matrix)) +(define-extern matrix3-inverse-transpose! + "Unused. Not sure if this has limitations compared to other version." + (function matrix matrix matrix)) +(define-extern matrix-3x3-normalize! "Unused." (function matrix matrix matrix)) +(define-extern matrix-4x4-determinant + "Take the determinant of a 4x4 matrix, but this is wrong." + (function matrix float)) +(define-extern matrix-4x4-inverse-transpose! + "Invert and transpose an entire 4x4. I think has no restrictions, other than dst != src. Unused. + The answer is wrong. The determinant function is wrong." + (function matrix matrix matrix)) +(define-extern matrix-y-angle + "If mat has its upper 3x3 as a rotation, gets the y axis rotation." + (function matrix float)) +(define-extern matrix->trans "Multiply xyz by 1/w."(function matrix vector vector)) +(define-extern matrix<-trans "Set the translation." (function matrix vector matrix)) +(define-extern matrix->scale "Get the scale of a matrix." (function matrix vector vector)) +(define-extern matrix-remove-scale! (function matrix matrix vector matrix)) +(define-extern matrix<-scale "Set the scale of a matrix by rescaling." (function matrix vector matrix)) +(define-extern matrix->quat + "Convert matrix to quaternion, works for matrix with scale. + unlike matrix->quaternion." + (function matrix quaternion quaternion)) +(define-extern matrix<-quat "Modify the rotation part of a transform." (function matrix quaternion matrix)) +(define-extern matrix-extract-rotation! (function matrix matrix matrix)) +(define-extern matrix->transformq + "Create a transformq from a matrix. Allowing scale, etc." + (function transformq matrix transformq)) +(define-extern matrix-mirror! "Make a matrix that mirrors. Arguments are unclear." (function matrix vector vector matrix)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; matrix-compose ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern matrix-fur-compose function) ;; (function matrix vector vector vector matrix) -;; (define-extern matrix-fu-compose function) ;; (function matrix vector vector matrix) -;; (define-extern matrix-fr-compose function) ;; (function matrix vector vector matrix) -;; (define-extern matrix-ur-compose function) ;; (function matrix vector vector vector matrix) -;; (define-extern matrix-f-u-compose function) ;; (function matrix vector vector matrix) -;; (define-extern matrix-f-r-compose function) ;; (function matrix vector vector matrix) -;; (define-extern matrix-u-f-compose function) ;; (function matrix vector vector matrix) -;; (define-extern matrix-u-r-compose function) ;; (function matrix vector vector matrix) -;; (define-extern matrix-r-f-compose function) ;; (function matrix vector vector vector matrix) -;; (define-extern matrix-r-u-compose function) ;; (function matrix vector vector vector matrix) -;; (define-extern matrix-f-compose function) ;; (function matrix vector matrix) -;; (define-extern matrix-u-compose function) ;; (function matrix vector vector vector matrix) -;; (define-extern matrix-r-compose function) ;; (function matrix vector vector vector matrix) +(define-extern matrix-fur-compose (function matrix vector vector vector matrix)) +(define-extern matrix-fu-compose (function matrix vector vector matrix)) +(define-extern matrix-fr-compose (function matrix vector vector matrix)) +(define-extern matrix-ur-compose (function matrix vector vector vector matrix)) +(define-extern matrix-f-u-compose (function matrix vector vector matrix)) +(define-extern matrix-f-r-compose (function matrix vector vector matrix)) +(define-extern matrix-u-f-compose (function matrix vector vector matrix)) +(define-extern matrix-u-r-compose (function matrix vector vector matrix)) +(define-extern matrix-r-f-compose (function matrix vector vector vector matrix)) +(define-extern matrix-r-u-compose (function matrix vector vector vector matrix)) +(define-extern matrix-f-compose (function matrix vector matrix)) +(define-extern matrix-u-compose (function matrix vector vector vector matrix)) +(define-extern matrix-r-compose (function matrix vector vector vector matrix)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; transform ;; @@ -2150,128 +2389,267 @@ ;; quaternion ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; quaternion is already defined! - -;; (define-extern quaternion-axis-angle! function) ;; (function quaternion float float float float quaternion) -;; (define-extern quaternion-vector-angle! function) ;; (function quaternion vector float quaternion) -;; (define-extern vector-angle<-quaternion! function) ;; (function vector quaternion vector) -;; (define-extern quaternion-look-at! function) ;; (function quaternion vector vector quaternion) -;; (define-extern quaternion-zero! function) ;; (function quaternion quaternion) -;; (define-extern quaternion-identity! function) ;; (function quaternion quaternion) -;; (define-extern quaternion-i! function) ;; (function quaternion quaternion) -;; (define-extern quaternion-j! function) ;; (function quaternion quaternion) -;; (define-extern quaternion-k! function) ;; (function quaternion quaternion) -;; (define-extern quaternion-copy! function) ;; (function quaternion quaternion quaternion) -;; (define-extern quaternion-set! function) ;; (function quaternion float float float float quaternion) -;; (define-extern quaternion+! function) ;; (function quaternion quaternion quaternion quaternion) -;; (define-extern quaternion-! function) ;; (function quaternion quaternion quaternion quaternion) -;; (define-extern quaternion-negate! function) ;; (function quaternion quaternion quaternion) -;; (define-extern quaternion-conjugate! function) ;; (function quaternion quaternion quaternion) -;; (define-extern quaternion-float*! function) ;; (function quaternion quaternion float quaternion) -;; (define-extern quaternion-float/! function) ;; (function quaternion quaternion float quaternion) -;; (define-extern quaternion-norm2 function) ;; (function quaternion float) -;; (define-extern quaternion-norm function) ;; (function quaternion float) -;; (define-extern quaternion-normalize! function) ;; (function quaternion quaternion) -;; (define-extern quaternion-inverse! function) ;; (function quaternion quaternion quaternion) -;; (define-extern quaternion-dot function) ;; (function quaternion quaternion float) -;; (define-extern quaternion*! function) ;; (function quaternion quaternion quaternion quaternion) -;; (define-extern quaternion-right-mult-matrix! function) ;; (function matrix quaternion matrix) -;; (define-extern quaternion-left-mult-matrix! function) ;; (function matrix quaternion matrix) -;; (define-extern quaternion->matrix function) ;; (function matrix quaternion matrix) -;; (define-extern quaternion->matrix-2 function) ;; (function matrix quaternion matrix) -;; (define-extern matrix->quaternion function) ;; (function quaternion matrix quaternion) -;; (define-extern matrix-with-scale->quaternion function) ;; (function quaternion matrix quaternion) -;; (define-extern quaternion-vector-len function) ;; (function quaternion float) -;; (define-extern quaternion-log! function) ;; (function quaternion quaternion quaternion) -;; (define-extern quaternion-exp! function) ;; (function quaternion quaternion quaternion) -;; (define-extern quaternion-slerp! function) ;; (function quaternion quaternion quaternion float quaternion) -;; (define-extern quaternion-pseudo-slerp! function) ;; (function quaternion quaternion quaternion float quaternion) -;; (define-extern quaternion-pseudo-seek function) ;; (function quaternion quaternion quaternion float quaternion) -;; (define-extern quaternion-smooth-seek! function) ;; (function quaternion quaternion quaternion float quaternion) -;; (define-extern quaternion-zxy! function) ;; (function quaternion vector quaternion) -;; (define-extern vector-x-quaternion! function) ;; (function vector quaternion vector) -;; (define-extern vector-y-quaternion! function) ;; (function vector quaternion vector) -;; (define-extern vector-z-quaternion! function) ;; (function vector quaternion vector) -;; (define-extern quaternion-x-angle function) ;; (function quaternion float) -;; (define-extern quaternion-y-angle function) ;; (function quaternion float) -;; (define-extern quaternion-z-angle function) ;; (function quaternion float) -;; (define-extern quaternion-vector-y-angle function) ;; (function quaternion vector float) -;; (define-extern quaternion-rotate-local-x! function) ;; (function quaternion quaternion float quaternion) -;; (define-extern quaternion-rotate-local-y! function) ;; (function quaternion quaternion float quaternion) -;; (define-extern quaternion-rotate-local-z! function) ;; (function quaternion quaternion float quaternion) -;; (define-extern quaternion-rotate-y! function) ;; (function quaternion quaternion float quaternion) -;; (define-extern quaternion-rotate-x! function) ;; (function quaternion quaternion float quaternion) -;; (define-extern quaternion-rotate-z! function) ;; (function quaternion quaternion float quaternion) -;; (define-extern quaternion-delta-y function) ;; (function quaternion quaternion float) -;; (define-extern quaternion-rotate-y-to-vector! function) ;; (function quaternion quaternion quaternion float quaternion) -;; (define-extern vector-rotate-around-axis! function) ;; (function vector vector float vector vector) -;; (define-extern vector-rotate-x! function) ;; (function vector vector float vector) -;; (define-extern vector-rotate-y! function) ;; (function vector vector float vector) -;; (define-extern vector-rotate-y-fast! function) -;; (define-extern vector-rotate-z! function) ;; (function vector vector float vector) -;; (define-extern vector-y-angle function) ;; (function vector float) -;; (define-extern vector-x-angle function) ;; (function vector float) -;; (define-extern quaternion<-rotate-y-vector function) ;; (function quaternion vector quaternion) -;; (define-extern quaternion-validate function) ;; (function quaternion none) -;; (define-extern quaternion-xz-angle function) ;; (function quaternion float) +(define-extern quaternion-axis-angle! + "Construct a quaternion from an axis and angle. The axis should be normalized." + (function quaternion float float float float quaternion)) +(define-extern quaternion-vector-angle! + "Construct a quaternion from an axis and angle. The axis should be normalized." + (function quaternion vector float quaternion)) +(define-extern vector-angle<-quaternion! + "Convert the quaternion arg1 to axis-angle form and store in arg0 (angle goes in w)" + (function vector quaternion vector)) +(define-extern quaternion-look-at! "Look along arg1, with arg2 as up." (function quaternion vector vector quaternion)) +(define-extern quaternion-zero! "Set quaternion to all 0's." (function quaternion quaternion)) +(define-extern quaternion-identity! "Set quaternion to 0,0,0,1 (identity)." (function quaternion quaternion)) +(define-extern quaternion-i! "Create unit i quaternion." (function quaternion quaternion)) +(define-extern quaternion-j! "Create unit j quaternion." (function quaternion quaternion)) +(define-extern quaternion-k! "Create unit k quaternion." (function quaternion quaternion)) +(define-extern quaternion-copy! "Set arg0 = arg1." (function quaternion quaternion quaternion)) +(define-extern quaternion-set! "Set arg0 = [arg1, arg2, arg3, arg4]." (function quaternion float float float float quaternion)) +(define-extern quaternion+! "Add quaternions as vectors." (function quaternion quaternion quaternion quaternion)) +(define-extern quaternion-! "Subtract quaternions as vectors." (function quaternion quaternion quaternion quaternion)) +(define-extern quaternion-negate! "Set arg0 = -arg1." (function quaternion quaternion quaternion)) +(define-extern quaternion-conjugate! + "Set arg0 to the conjugate of arg1 (negate only ijk). + If arg1 is normalized, this is equivalent to the inverse + NOTE: this gives you the inverse rotation." + (function quaternion quaternion quaternion)) +(define-extern quaternion-float*! "Multiply each element." (function quaternion quaternion float quaternion)) +(define-extern quaternion-float/! "Divide each element." (function quaternion quaternion float quaternion)) +(define-extern quaternion-norm2 "Get the squared norm of a quaternion." (function quaternion float)) +(define-extern quaternion-norm "Get the norm of a quaternion." (function quaternion float)) +(define-extern quaternion-normalize! "Normalize a quaternion." (function quaternion quaternion)) +(define-extern quaternion-inverse! + "Invert a quaternion. The inverse will satisfy q * q^-1 = identity, even if q is not normalized. + If your quaternion is normalized, it is faster/more accurate to do quaternion-conjugate!" + (function quaternion quaternion quaternion)) +(define-extern quaternion-dot + "Treat quaternions as vectors and take the dot product." + (function quaternion quaternion float)) +(define-extern quaternion*! "Real quaternion multiplication." (function quaternion quaternion quaternion quaternion)) +(define-extern quaternion-right-mult-matrix! + "Place quaternion coefficients into a matrix. + You can convert a quaternion to a matrix by taking the product of this + right-mult and left-mult matrix, but this method is not used. + Instead, quaternion->matrix is a more efficient implementation." + (function matrix quaternion matrix)) +(define-extern quaternion-left-mult-matrix! + "Place quaternion coefficients into a matrix. Unused." + (function matrix quaternion matrix)) +(define-extern quaternion->matrix "Convert quaternion to matrix." (function matrix quaternion matrix)) +(define-extern quaternion->matrix-2 "Unused alternate quaternion->matrix function." (function matrix quaternion matrix)) +(define-extern matrix->quaternion "Convert a rotation matrix to a quaternion." (function quaternion matrix quaternion)) +(define-extern matrix-with-scale->quaternion + "Convert a matrix with a rotation and scale into a quaternion (just the rotation)." + (function quaternion matrix quaternion)) +(define-extern quaternion-vector-len + "Assuming quaternion is normalized, get the length of the xyz part." + (function quaternion float)) +(define-extern quaternion-log! "Take the log of a quaternion. Unused." (function quaternion quaternion quaternion)) +(define-extern quaternion-exp! "Quaternion exponentiation. Unused." (function quaternion quaternion quaternion)) +(define-extern quaternion-slerp! + "Real quaternion slerp. Spherical-linear interpolation is a nice way to interpolate + between quaternions." + (function quaternion quaternion quaternion float quaternion)) +(define-extern quaternion-pseudo-slerp! + "This is a bad interpolation between quaternions. It lerps then normalizes. + It will behave extremely poorly for 180 rotations. + It is unused." + (function quaternion quaternion quaternion float quaternion)) +(define-extern quaternion-pseudo-seek + "Seek one quaternion toward another. Not using real slerp, so this is only good if the quaternions + are pretty similar." + (function quaternion quaternion quaternion float quaternion)) +(define-extern quaternion-smooth-seek! "Another hacky rotation interpolation." (function quaternion quaternion quaternion float quaternion)) +(define-extern quaternion-zxy! + "Make a quaternion from a sequence of z, x, y axis rotations." + (function quaternion vector quaternion)) +(define-extern vector-x-quaternion! + "Get the first row of the rotation matrix for this quaternion." + (function vector quaternion vector)) +(define-extern vector-y-quaternion! + "Get the second row of the rotation matrix for this quaternion." + (function vector quaternion vector)) +(define-extern vector-z-quaternion! + "Get the third row of the rotation matrix for this quaternion." + (function vector quaternion vector)) +(define-extern quaternion-x-angle + "Get the x rotation angle. Not very efficient." + (function quaternion float)) +(define-extern quaternion-y-angle + "Get the y rotation angle. Not very efficient." + (function quaternion float)) +(define-extern quaternion-z-angle + "Get the z rotation angle. Not very efficient." + (function quaternion float)) +(define-extern quaternion-vector-y-angle + "Not sure. Angle between quaternion and axis, projected in xz plane?" + (function quaternion vector float)) +(define-extern quaternion-rotate-local-x! + "Rotate existing quaternion along x axis." + (function quaternion quaternion float quaternion)) +(define-extern quaternion-rotate-local-y! + "Rotate existing quaternion along y axis." + (function quaternion quaternion float quaternion)) +(define-extern quaternion-rotate-local-z! + "Rotate existing quaternion along z axis." + (function quaternion quaternion float quaternion)) +(define-extern quaternion-rotate-y! + "Rotate existing quaternion along y axis (right multiply)." + (function quaternion quaternion float quaternion)) +(define-extern quaternion-rotate-x! + "Rotate existing quaternion along x axis (right multiply)." + (function quaternion quaternion float quaternion)) +(define-extern quaternion-rotate-z! + "Rotate existing quaternion along z axis (right multiply)." + (function quaternion quaternion float quaternion)) +(define-extern quaternion-delta-y "Difference in yaw between two quaternions." (function quaternion quaternion float)) +(define-extern quaternion-rotate-y-to-vector! (function quaternion quaternion quaternion float quaternion)) +(define-extern vector-rotate-around-axis! + "Rotate along y so z-axis points to match another. Use arg3 as the max rotation amount." + (function vector vector float vector vector)) +(define-extern vector-rotate-x! "Rotate vector along x axis." (function vector vector float vector)) +(define-extern vector-rotate-y! "Rotate vector along y axis." (function vector vector float vector)) +(define-extern vector-rotate-y-fast! "Rotate vector along y axis, but fast." (function vector vector float float vector)) +(define-extern vector-rotate-z! "Rotate vector along z axis." (function vector vector float vector)) +(define-extern vector-y-angle "Get the yaw angle of a vector." (function vector float)) +(define-extern vector-x-angle "Get the pitch angle of a vector." (function vector float)) +(define-extern quaternion<-rotate-y-vector "Create a quaternion representing only the yaw of the given vector." (function quaternion vector quaternion)) +(define-extern quaternion-validate + "Verify that a quaternion is valid, print an error if the length is off by more than 1%.." + (function quaternion none)) +(define-extern quaternion-xz-angle + "Yet another function to compute the yaw of a quaternion. This is a particularly inefficient version." + (function quaternion float)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; euler ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern set-eul! function) ;; (function euler-angles float float float int euler-angles) -;; (define-extern eul->matrix function) ;; (function matrix euler-angles matrix) -;; (define-extern matrix->eul function) ;; (function euler-angles matrix int euler-angles) -;; (define-extern eul->quat function) ;; (function quaternion euler-angles quaternion) -;; (define-extern quat->eul function) ;; (function euler-angles quaternion int euler-angles) +(define-extern set-eul! "Set euler angles and the flag bits." (function euler-angles float float float int euler-angles)) +(define-extern eul->matrix "Convert from euler angles to 4x4 matrix." (function matrix euler-angles matrix)) +(define-extern matrix->eul + "Convert matrix to euler angles with given order flag. + Not clear how this works if the matrix has more than just a rotation." + (function euler-angles matrix int euler-angles)) +(define-extern eul->quat + "Convert euler angles to quaternion, not very efficient." + (function quaternion euler-angles quaternion)) +(define-extern quat->eul + "Convert quaternion to euler angles with given order, not very efficient." + (function euler-angles quaternion int euler-angles)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; trigonometry ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern radmod function) ;; (function float float) -;; (define-extern deg- function) ;; (function float float float) -;; (define-extern deg-diff function) ;; (function float float float) -;; (define-extern deg-seek function) ;; (function float float float float) -;; (define-extern deg-seek-smooth function) ;; (function float float float float float) -;; (define-extern deg-lerp-clamp function) ;; (function float float float float) -;; (define-extern binary-table array) ;; (array float) -;; (define-extern sincos-table array) ;; (array float) -;; (define-extern sin function) ;; (function float float) -;; (define-extern sin-rad function) ;; (function float float) -;; (define-extern *sin-poly-vec* object) ;; vector -;; (define-extern *sin-poly-vec2* object) ;; vector -;; (define-extern vector-sin-rad! function) ;; (function vector vector vector) -;; (define-extern cos-rad function) ;; (function float float) -;; (define-extern *cos-poly-vec* object) ;; vector -;; (define-extern vector-cos-rad! function) ;; (function vector vector vector) -;; (define-extern vector-sincos-rad! function) ;; (function vector vector vector int) -;; (define-extern sincos-rad! function) ;; (function vector float int) -;; (define-extern sincos! function) ;; (function vector float int) -;; (define-extern vector-rad<-vector-deg! function) ;; (function vector vector none) -;; (define-extern vector-rad<-vector-deg/2! function) ;; (function vector vector int) -;; (define-extern vector-sincos! function) ;; (function vector vector vector int) -;; (define-extern tan-rad function) ;; (function float float) -;; (define-extern cos function) ;; (function float float) -;; (define-extern tan function) ;; (function float float) -;; (define-extern atan0 function) ;; (function float float float) -;; (define-extern atan-series-rad function) ;; (function float float) -;; (define-extern atan-rad function) ;; (function float float) -;; (define-extern sign-bit function) ;; (function int int) -;; (define-extern sign-float function) ;; (function float float) -;; (define-extern sign function) ;; (function float float) -;; (define-extern atan2-rad function) ;; (function float float float) -;; (define-extern atan function) ;; (function float float float) -;; (define-extern asin function) ;; (function float float) -;; (define-extern acos function) ;; (function float float) -;; (define-extern acos-rad function) ;; (function float float) -;; (define-extern sinerp function) ;; (function float float float float) -;; (define-extern sinerp-clamp function) ;; (function float float float float) -;; (define-extern coserp function) ;; (function float float float float) -;; (define-extern coserp-clamp function) ;; (function float float float float) -;; (define-extern coserp180 function) ;; (function float float float float) -;; (define-extern coserp180-clamp function) ;; (function float float float float) -;; (define-extern ease-in-out function) ;; (function int int float) +(define-extern radmod "Wrap arg0 to be within (-pi, pi)." (function float float)) +(define-extern deg- + "Compute arg0-arg1, unwrapped, using rotation units. + Result should be in the range (-180, 180)" + (function float float float)) +(define-extern deg-diff + "Very similar to the function above, but computes arg1 - arg0 instead." + (function float float float)) +(define-extern deg-seek + "Move in toward target by at most max-diff, using rotation units" + (function float float float float)) +(define-extern deg-seek-smooth + "Step amount of the way from in to target, by at most max-diff, using rotation units" + (function float float float float float)) +(define-extern deg-lerp-clamp + "Map [0, 1] to min-val, max-val, handling wrapping and saturating, using rotation units." + (function float float float float)) +(define-extern binary-table (array float)) +(define-extern sincos-table (array float)) +(define-extern sin + "Compute the sine of an angle in rotation units. Unwraps it." + (function float float)) +(define-extern sin-rad + "Compute the sine of an angle in radians. + No unwrap is done, should be in -pi, pi" + (function float float)) +(define-extern *sin-poly-vec* vector) +(define-extern *sin-poly-vec2* vector) +(define-extern vector-sin-rad! + "Taylor series approximation of sine on all 4 elements in a vector. + Inputs should be in radians, in -pi to pi. + Somehow their coefficients are a little bit off. + Like the first coefficient, which should obviously be 1, is not quite 1." + (function vector vector vector)) +(define-extern cos-rad + "Cosine with taylor series. Input is in radians, in -pi, pi. + - TODO constants" + (function float float)) +(define-extern *cos-poly-vec* vector) ;; vector +(define-extern vector-cos-rad! + "Compute the cosine of all 4 vector elements. + Radians, with no wrapping. Uses taylor series with 4 coefficients." + (function vector vector vector)) +(define-extern vector-sincos-rad! + "Compute the sine and cosine of each element of src, storing it in dst-sin and dst-cos. + This is more efficient than separate calls to sin and cos. + Inputs should be radians in -pi to pi. + TODO - original code contained a bad VF dependency" + (function vector vector vector int)) +(define-extern sincos-rad! + "Compute the sine and cosine of x, store it in the output array. + Has the cosine bug." + (function vector float int)) +(define-extern sincos! + "Compute the sine and cosine of x, store it in the output array. + The input is in rotation units, and is unwrapped properly. + Also has the cosine bug" + (function vector float int)) +(define-extern vector-rad<-vector-deg! + "Convert a vector in rotation units to radians, and unwrap. + Input can be anything, output will be -2pi to pi." + (function vector vector none)) +(define-extern vector-rad<-vector-deg/2! + "Divide the input by two, and then convert from rotation units to radians, unwrapping. + Not sure why this really needs to be separate the from previous function..." + (function vector vector int)) +(define-extern vector-sincos! + "Compute sine and cosine of each element in a vector, in rotation units" + (function vector vector vector int)) +(define-extern tan-rad + "This function appears to be named wrong and actually operates on rotation units." + (function float float)) +(define-extern cos "Cosine of rotation units." (function float float)) +(define-extern tan "Correctly named tangent of rotation units." (function float float)) +(define-extern atan0 + "Inverse tangent, to rotation units. y,x order. Does not handle signs correctly. + Do not use this function directly, instead use atan2." + (function float float float)) +(define-extern atan-series-rad "A helper function for atan." (function float float)) +(define-extern atan-rad "Inverse tangent in radians." (function float float)) +(define-extern sign-bit "Return 1 if bit 31 is set, otherwise 0." (function int int)) +(define-extern sign-float + "Return 1 if arg0 is positive or zero, -1 otherwise. + Fast (no branching)." + (function float float)) +(define-extern sign + "Similar to above, but returns 0 if input is 0. + But is more complicated." + (function float float)) +(define-extern atan2-rad "Atan for radians." (function float float float)) +(define-extern atan "Atan for rotation units. Signs behave like atan.." (function float float float)) +(define-extern asin "Inverse sine, rotation units." (function float float)) +(define-extern acos "Inverse cosine. Returns rotation units." (function float float)) +(define-extern acos-rad "Inverse cosine, radians." (function float float)) +(define-extern sinerp + "Map amount to min,max using sine. Kinda weird, usually people use cosine." + (function float float float float)) +(define-extern sinerp-clamp "Like sinerp, but clamp to min,max." (function float float float float)) +(define-extern coserp "Weird lerp with cosine (over 90 degrees?)." (function float float float float)) +(define-extern coserp-clamp + "Weird 90 degree lerp with cosine, clamped to min,max." + (function float float float float)) +(define-extern coserp180 "Classic lerp with cosine." (function float float float float)) +(define-extern coserp180-clamp "Classic coserp with saturation." (function float float float float)) +(define-extern ease-in-out + "Weird coserp like mapping from 0 to 1 as progress goes from 0 to total." + (function int int float)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; math-fx ;; @@ -2282,16 +2660,53 @@ ;; res-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype res-tag (uint128) -;; () -;; :flag-assert #x900000010 -;; ) +;; NOTE this is just copied from jak1 +(deftype res-tag (uint128) + "Metadata about a property in a [[res-lump]], such as name, element type and element count." + ((name symbol :offset 0) + (key-frame float :offset 32) + (elt-type type :offset 64) + (data-offset uint16 :offset 96) + (elt-count uint32 :offset 112 :size 15) + (inlined? uint8 :offset 127 :size 1) ;; guess. + ) + :flag-assert #x900000010 + ) + +(declare-type entity-links structure) +(define-extern entity-links type) + +(declare-type nav-mesh basic) +(define-extern nav-mesh type) +(declare-type collide-mesh basic) +(define-extern collide-mesh type) + +;; +++res-h:res-lump-flags +(defenum res-lump-flags + :type uint16 + :bitfield #t + (sorted 0) + (rlf1 1) + ) +;; ---res-h:res-lump-flags + +;; +++res-h:res-tag-pair +;; made-up type +(deftype res-tag-pair (uint64) + "The indices of two [[res-tag]]s. If the specific key-frame time is in between two + res-tags, this type is used to return the indices of the first res-tag before and after + the specified time." + ((lo int32 :offset 0) + (hi int32 :offset 32) + ) + ) +;; ---res-h:res-tag-pair -#| (deftype res-lump (basic) + "A collection of [[res-tag]]s and their data." ((length int32 :offset-assert 4) - (allocated-length int16 :offset-assert 8) - (flags uint16 :offset-assert 10) ;; res-lump-flags + (allocated-length int16 :offset-assert 8) ;; int32 + (flags res-lump-flags :offset-assert 10) (data-base pointer :offset-assert 12) ;; guessed by decompiler (data-top pointer :offset-assert 16) ;; guessed by decompiler (data-size int32 :offset-assert 20) @@ -2303,31 +2718,79 @@ :flag-assert #x1600000020 ;; field extra uses ~A with a signed load. (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type int int) _type_) - (res-lump-method-9 () none) ;; 9 ;; (get-property-data (_type_ symbol symbol float pointer (pointer res-tag) pointer) pointer) - (res-lump-method-10 () none) ;; 10 ;; (get-property-struct (_type_ symbol symbol float structure (pointer res-tag) pointer) structure) - (res-lump-method-11 () none) ;; 11 ;; (get-property-value (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128) - (res-lump-method-12 () none) ;; 12 ;; (get-property-value-float (_type_ symbol symbol float float (pointer res-tag) pointer) float) - (res-lump-method-13 () none) ;; 13 ;; (get-tag-index-data (_type_ int) pointer) - (res-lump-method-14 () none) ;; 14 ;; (get-tag-data (_type_ res-tag) pointer) - (res-lump-method-15 () none) ;; 15 ;; (allocate-data-memory-for-tag! (_type_ res-tag) res-tag) - (res-lump-method-16 () none) ;; 16 ;; (sort! (_type_) _type_) - (res-lump-method-17 () none) ;; 17 ;; (add-data! (_type_ res-tag pointer) res-lump) - (res-lump-method-18 () none) ;; 18 ;; (add-32bit-data! (_type_ res-tag object) res-lump) - (res-lump-method-19 () none) ;; 19 ;; (lookup-tag-idx (_type_ symbol symbol float) res-tag-pair) - (res-lump-method-20 () none) ;; 20 ;; (make-property-data (_type_ float res-tag-pair pointer) pointer) - (res-lump-method-21 () none) ;; 21 ;; (get-curve-data! (_type_ curve symbol symbol float) symbol) + (new (symbol type int int) _type_) ;; 0 + (get-property-data + "Returns an address to a given property's data at a specific time stamp, or default on error. + @param name is the name of the property you want, mode is its lookup mode ('interp 'base 'exact), time is the timestamp. + @param default is the default result returned in the case of an error. + @param tag-addr is an address to a res-tag. The current base tag is written to this. Ignored if tag-addr is #f + @param buf-addr is an address to the data buffer used to write interpolated data to. It must have enough space! Only necessary for 'interp mode." + (_type_ symbol symbol float pointer (pointer res-tag) pointer) pointer :no-virtual) ;; 9 + (get-property-struct + "Returns a given struct property's value at a specific time stamp, or default on error. + @param name is the name of the property you want, `mode` is its lookup mode ('interp 'base 'exact), `time` is the timestamp. + @param default is the default result returned in the case of an error. + @param tag-addr is an address to a [[res-tag]]. The current base tag is written to this. Ignored if tag-addr is #f. + @param buf-addr is an address to the data buffer used to write interpolated data to. + It must have enough space! Only necessary for 'interp mode." + (_type_ symbol symbol float structure (pointer res-tag) pointer) structure :no-virtual) ;; 10 + (get-property-value + "Returns a given value property's value at a specific time stamp, or default on error. + @param name is the name of the property you want, `mode` is its lookup mode ('interp 'base 'exact), `time` is the timestamp. + @param default is the default result returned in the case of an error. + @param tag-addr is an address to a res-tag. The current base tag is written to this. Ignored if `tag-addr` is #f. + @param buf-addr is an address to the data buffer used to write interpolated data to. + It must have enough space! Only necessary for 'interp mode." + (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 :no-virtual) ;; 11 + (get-property-value-float (_type_ symbol symbol float float (pointer res-tag) pointer) float) ;; 12 + (get-tag-index-data "Get the data address of the n'th tag." (_type_ int) pointer) ;; 13 + (get-tag-data "Get the data address of the specified tag." (_type_ res-tag) pointer) ;; 14 + (allocate-data-memory-for-tag! + "Find space for the data described by arg0 in this. + Returns a tag with data-offset set correctly for this res-lump. + If the lump already contains memory for the given tag, and it is big enough, + it will be reused. Alignment will be at least 8 bytes. + If the input tag has elt-count = 0, it will return a tag for elt-count = 1." + (_type_ res-tag) res-tag) ;; 15 + (sort! "Sort all tags based on name, then key-frame." (_type_) _type_) ;; 16 + (add-data! + "Given a tag and a pointer to its data, copy it to this res-lump. + This doesn't seem to do the right thing if the given tag is a non-inline tag + with > 1 element." + (_type_ res-tag pointer) res-lump) ;; 17 + (add-32bit-data! "Add a single 32-bit value using [[add-data!]]." (_type_ res-tag object) res-lump) ;; 18 + (lookup-tag-idx + "Look up the index of the tag containing with the given name and timestamp. + Correct lookups return a res-tag-pair, which contains one tag index in the lower 32 bits and one in the upper 32 bits. + Depending on the mode, they may be the same, or they may be two tags that you should interpolate + between, if the exact time was not found. + + @param name-sym should be the name of the thing you want. + @param time is for the timestamp you want. + If mode = 'base, then both the indices are the same and the timestamp is ignored. + If mode = 'interp, then it tries to get closest below/closest above (or both the same, if exact match found). + If mode = 'exact, then it requires an exact timestamp match and both indices are the same. + If things go wrong, returns a negative number." + (_type_ symbol symbol float) res-tag-pair :no-virtual) ;; 19 + (make-property-data + "Returns (a pointer to) the value data of a property with the tag-pair. + If tag-pair does not represent an exact point in the timeline, then the data is interpolated based on time + with the result written into buf. buf must have enough space to copy all of the data. + Otherwise, simply returns an address to the resource binary." + (_type_ float res-tag-pair pointer) pointer) ;; 20 + (get-curve-data! + "Read curve data and write it to curve-target. Return #t if both + control points and knots data was succesfully read, #f otherwise." + (_type_ curve symbol symbol float) symbol) ;; 21 ) ) -|# -;; (define-extern *res-key-string* object) ;; string +(define-extern *res-key-string* string) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gsound-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype sound-stream-name (structure) ((name uint8 48 :offset-assert 0) ;; guessed by decompiler ) @@ -2335,24 +2798,24 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -;; (deftype sound-id (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype sound-id (uint32) + () + :flag-assert #x900000004 + ) -;; (deftype sound-bank-id (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype sound-bank-id (uint32) + () + :flag-assert #x900000004 + ) -;; (deftype sound-name (uint128) -;; () -;; :flag-assert #x900000010 -;; ) +(deftype sound-name (uint128) + ((lo uint64 :offset 0) ;; added to help with cases where they access it by u64. + (hi uint64 :offset 64) + ) + :flag-assert #x900000010 + ) -#| (deftype sound-rpc-cmd (structure) ((rsvd1 uint16 :offset-assert 0) (command uint16 :offset-assert 2) ;; sound-command @@ -2361,9 +2824,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype sound-play-params (structure) ((mask uint8 :offset-assert 0) ;; uint16 (group uint8 :offset-assert 1) @@ -2376,9 +2837,7 @@ :size-assert #xa :flag-assert #x90000000a ) -|# -#| (deftype sound-rpc-bank-cmd (sound-rpc-cmd) ((bank-name uint128 :offset-assert 16) ;; sound-name ) @@ -2386,9 +2845,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype sound-rpc-test-cmd (sound-rpc-cmd) ((ee-addr pointer :offset-assert 4) ;; guessed by decompiler (param0 uint16 :offset-assert 8) @@ -2397,9 +2854,7 @@ :size-assert #xa :flag-assert #x90000000a ) -|# -#| (deftype sound-rpc-sound-cmd (sound-rpc-cmd) ((id sound-id :offset-assert 4) ;; guessed by decompiler ) @@ -2407,9 +2862,7 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-group-cmd (sound-rpc-cmd) ((group uint32 :offset-assert 4) ) @@ -2417,9 +2870,7 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-load-bank (sound-rpc-bank-cmd) ((ee-addr pointer :offset-assert 32) ;; guessed by decompiler (mode uint32 :offset-assert 36) @@ -2429,18 +2880,14 @@ :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype sound-rpc-load-music (sound-rpc-bank-cmd) () :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype sound-rpc-unload-bank (sound-rpc-cmd) ((mode uint32 :offset-assert 4) ) @@ -2448,9 +2895,7 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-play (sound-rpc-sound-cmd) ((name uint128 :offset-assert 16) ;; sound-name (params sound-play-params :inline :offset-assert 32) @@ -2459,36 +2904,28 @@ :size-assert #x2a :flag-assert #x90000002a ) -|# -#| (deftype sound-rpc-pause-sound (sound-rpc-sound-cmd) () :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-stop-sound (sound-rpc-sound-cmd) () :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-continue-sound (sound-rpc-sound-cmd) () :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-set-param (sound-rpc-sound-cmd) ((params sound-play-params :inline :offset-assert 16) (auto-time int32 :offset-assert 28) @@ -2498,9 +2935,7 @@ :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype sound-rpc-set-master-volume (sound-rpc-group-cmd) ((volume int32 :offset-assert 8) ) @@ -2508,36 +2943,28 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype sound-rpc-pause-group (sound-rpc-group-cmd) () :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-stop-group (sound-rpc-group-cmd) () :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-continue-group (sound-rpc-group-cmd) () :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-cancel-dgo (sound-rpc-group-cmd) ((id uint32 :offset-assert 8) ) @@ -2545,9 +2972,7 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype sound-rpc-get-irx-version (sound-rpc-cmd) ((major uint32 :offset-assert 4) (minor uint32 :offset-assert 8) @@ -2557,9 +2982,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype sound-rpc-set-language (sound-rpc-cmd) ((lang uint32 :offset-assert 4) ) @@ -2567,9 +2990,7 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-set-stereo-mode (sound-rpc-cmd) ((mode int32 :offset-assert 4) ) @@ -2577,9 +2998,7 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-set-reverb (sound-rpc-cmd) ((core uint8 :offset-assert 4) (reverb int32 :offset-assert 8) @@ -2590,9 +3009,7 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype sound-rpc-set-ear-trans (sound-rpc-cmd) ((ear-trans1 int32 3 :offset-assert 4) ;; guessed by decompiler (ear-trans0 int32 3 :offset-assert 16) ;; guessed by decompiler @@ -2606,18 +3023,14 @@ :size-assert #x48 :flag-assert #x900000048 ) -|# -#| (deftype sound-rpc-shutdown (sound-rpc-cmd) () :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype sound-rpc-set-fps (sound-rpc-cmd) ((fps uint8 :offset-assert 4) ) @@ -2625,9 +3038,7 @@ :size-assert #x5 :flag-assert #x900000005 ) -|# -#| (deftype sound-rpc-set-globals (sound-rpc-cmd) ((cam-inverted uint8 :offset-assert 4) (music-pitch-mod int16 :offset-assert 6) @@ -2636,56 +3047,48 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype sound-rpc-list-sounds (sound-rpc-cmd) () :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype sound-rpc-unload-music (sound-rpc-cmd) () :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype sound-rpc-union (structure) ((data uint32 12 :offset-assert 0) ;; guessed by decompiler - (load-bank sound-rpc-load-bank :offset-assert 0) - (unload-bank sound-rpc-unload-bank :offset-assert 0) - (play sound-rpc-play :offset-assert 0) - (pause-sound sound-rpc-pause-sound :offset-assert 0) - (stop-sound sound-rpc-stop-sound :offset-assert 0) - (continue-sound sound-rpc-continue-sound :offset-assert 0) - (set-param sound-rpc-set-param :offset-assert 0) - (set-master-volume sound-rpc-set-master-volume :offset-assert 0) - (pause-group sound-rpc-pause-group :offset-assert 0) - (stop-group sound-rpc-stop-group :offset-assert 0) - (continue-group sound-rpc-continue-group :offset-assert 0) - (get-irx-version sound-rpc-get-irx-version :offset-assert 0) - (set-language sound-rpc-set-language :offset-assert 0) - (set-reverb sound-rpc-set-reverb :offset-assert 0) - (set-fps sound-rpc-set-fps :offset-assert 0) - (set-globals sound-rpc-set-globals :offset-assert 0) - (shutdown sound-rpc-shutdown :offset-assert 0) - (list-sounds sound-rpc-list-sounds :offset-assert 0) - (unload-music sound-rpc-unload-music :offset-assert 0) + (load-bank sound-rpc-load-bank :offset 0) + (unload-bank sound-rpc-unload-bank :offset 0) + (play sound-rpc-play :offset 0) + (pause-sound sound-rpc-pause-sound :offset 0) + (stop-sound sound-rpc-stop-sound :offset 0) + (continue-sound sound-rpc-continue-sound :offset 0) + (set-param sound-rpc-set-param :offset 0) + (set-master-volume sound-rpc-set-master-volume :offset 0) + (pause-group sound-rpc-pause-group :offset 0) + (stop-group sound-rpc-stop-group :offset 0) + (continue-group sound-rpc-continue-group :offset 0) + (get-irx-version sound-rpc-get-irx-version :offset 0) + (set-language sound-rpc-set-language :offset 0) + (set-reverb sound-rpc-set-reverb :offset 0) + (set-fps sound-rpc-set-fps :offset 0) + (set-globals sound-rpc-set-globals :offset 0) + (shutdown sound-rpc-shutdown :offset 0) + (list-sounds sound-rpc-list-sounds :offset 0) + (unload-music sound-rpc-unload-music :offset 0) ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype sound-info (structure) ((flags uint32 :offset-assert 0) (num-instances uint32 :offset-assert 4) @@ -2704,9 +3107,7 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype sound-spec (sound-play-params) ((auto-time int32 :offset-assert 12) (auto-from int32 :offset-assert 16) @@ -2722,9 +3123,7 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype sound-handle (structure) ((proc uint64 :offset-assert 0) (flags uint64 :offset-assert 8) @@ -2740,9 +3139,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype sound-instance (sound-spec) ((last-update uint64 :offset-assert 64) (joint uint8 :offset-assert 72) @@ -2755,57 +3152,70 @@ :size-assert #x5c :flag-assert #x90000005c ) -|# -#| +;; +++gsound-h:sound-bank-mode +(defenum sound-bank-mode + :type uint32 + (none 0) + (unknown 1) + (common 2) + (mode 3) + (full 4) + (half 5) + (halfa 6) + (halfb 7) + (halfc 8) + (virtual 9) + ) +;; ---gsound-h:sound-bank-mode + (deftype sound-bank-state (structure) ((name symbol :offset-assert 0) ;; guessed by decompiler (mode sound-bank-mode :offset-assert 4) ;; guessed by decompiler (high basic :offset-assert 8) (str-name basic :offset-assert 12) ) + :pack-me :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| +;; +++gsound-h:stream-status +(defenum stream-status + :type uint32 + :bitfield #t + (ss1 1) ;; id-is-playing + (ss4 4) ;; is-playing + (ss6 6) ;; id-is-playing + (ss9 9) + ) +;; ---gsound-h:stream-status + (deftype sound-iop-info (structure) ((freemem uint32 :offset-assert 0) (freemem2 uint32 :offset-assert 4) (nocd uint32 :offset-assert 8) (dirtycd uint32 :offset-assert 12) (chinfo uint8 48 :offset-assert 16) ;; guessed by decompiler - (id-info UNKNOWN 48 :offset-assert 64) - (pad UNKNOWN 2 :offset-assert 256) - (music-position integer :offset-assert 264) - (music-status uint32 :offset-assert 268) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (stream-position uint32 4 :offset-assert 320) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (id-info sound-info 48 :offset-assert 64) + (pad int32 2 :offset-assert 256) + (music-position uint32 :offset-assert 264) + (music-status uint32 :offset 268) + (music-name string :offset 272) ;; might be wrong, used ~g + (stream-position uint32 4 :offset 320) ;; guessed by decompiler (stream-status stream-status 4 :offset-assert 336) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (stream-name sound-stream-name 4 :offset-assert 352) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (stream-name sound-stream-name 4 :inline :offset-assert 352) ;; guessed by decompiler (stream-id sound-id 4 :offset-assert 544) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (stream-id-signed int32 4 :offset 544) ;; guessed by decompiler + (sound-banks sound-bank-state 8 :inline :offset 560) + (sound-iop-info-pad int32 4) ) :method-count-assert 9 :size-assert #x2c0 :flag-assert #x9000002c0 ) -|# -#| (deftype ambient-sound (basic) ((playing-id sound-id :offset-assert 4) ;; guessed by decompiler (entity entity :offset-assert 8) ;; guessed by decompiler @@ -2819,7 +3229,7 @@ :size-assert #x68 :flag-assert #x1100000068 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type basic vector float) _type_) + (new "Set up ambient-sound. Can use an entity-actor (grabs from lump), sound-spec, or name as a string." (symbol type basic vector float) _type_) ;; 0 (ambient-sound-method-9 () none) ;; 9 ;; (update! (_type_) int) (ambient-sound-method-10 () none) ;; 10 ;; (change-sound! (_type_ sound-name) int) (ambient-sound-method-11 () none) ;; 11 ;; (update-trans! (_type_ vector) int) @@ -2830,14 +3240,13 @@ (ambient-sound-method-16 () none) ;; 16 ;; (stop! (_type_) int) ) ) -|# -;; (define-extern *debug-sound-sliders* object) -;; (define-extern *music-volume-ducked-by-sound* object) -;; (define-extern *music-lock* object) -;; (define-extern *current-sound-id* object) ;; sound-id -;; (define-extern *sound-iop-info* object) ;; sound-iop-info -;; (define-extern *jukebox-time* object) +(define-extern *debug-sound-sliders* symbol) +(define-extern *music-volume-ducked-by-sound* float) +(define-extern *music-lock* symbol) +(define-extern *current-sound-id* sound-id) +(define-extern *sound-iop-info* sound-iop-info) +(define-extern *jukebox-time* int) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sound-info ;; @@ -2849,46 +3258,72 @@ ;; timer-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype timer-mode (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +;; +++timer-h:timer-clock-selection +(defenum timer-clock-selection + :type uint8 + (busclk 0) + (busclk/16 1) + (busclk/256 2) + (hblank 3) + ) +;; ---timer-h:timer-clock-selection + +(deftype timer-mode (uint32) + "This matches the Tn_MODE register structure of the ps2 EE timers. + Only the lower 32 bits of these registers are usable, and the upper 16 hardwired to zero." + ((clks timer-clock-selection :offset 0 :size 2) + (gate uint8 :offset 2 :size 1) ;; gate function enable + (gats uint8 :offset 3 :size 1) ;; gate selection: 0 = hblank, 1 = vblank + ;; gate mode: + ;; 0: count while gate signal is low + ;; 1: start when gate signal rises + ;; 2: start when gate signal falls + ;; 3: start when gate signal rises/falls + (gatm uint8 :offset 4 :size 2) + (zret uint8 :offset 6 :size 1) ;; zero return: clear counter when equal to reference value + (cue uint8 :offset 7 :size 1) ;; count-up enable + (cmpe uint8 :offset 8 :size 1) ;; compare-interrupt enable + (ovfe uint8 :offset 9 :size 1) ;; overflow-interrupt enable + (equf uint8 :offset 10 :size 1) ;; equal-flag + (ovff uint8 :offset 11 :size 1) ;; overflow-flag + ) + ) -#| (deftype timer-bank (structure) + "This matches an EE timer (without a HOLD register, timers 2 and 3). + Each register is 128-bits wide, but only the lower 32-bits are usable, and the upper + 16-bits of that are hardwired to zero." ((count uint32 :offset-assert 0) - (mode timer-mode :offset-assert 16) ;; guessed by decompiler - (comp uint32 :offset-assert 32) + (mode timer-mode :offset 16) + (comp uint32 :offset 32) ) :method-count-assert 9 :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype timer-hold-bank (timer-bank) - ((hold uint32 :offset-assert 48) + "This matches an EE timer (with a HOLD register, timers 0 and 1)." + ((hold uint32 :offset 48) ) :method-count-assert 9 :size-assert #x34 :flag-assert #x900000034 ) -|# -#| (deftype stopwatch (basic) - ((prev-time-elapsed uint64 :offset-assert 8) ;; time-frame - (start-time uint64 :offset-assert 16) ;; time-frame - (begin-level int32 :offset-assert 24) + "Stopwatches are used to measure CPU clock cycles. + They don't use the timer above, but instead the Count COP0 register, + which counts CPU clock cycles directly." + ((prev-time-elapsed time-frame :offset-assert 8) + (start-time time-frame :offset-assert 16) + (begin-level int32 :offset-assert 24) ) :method-count-assert 9 :size-assert #x1c :flag-assert #x90000001c ) -|# -#| (deftype sce-cd-clock (structure) ((stat uint8 :offset-assert 0) (second uint8 :offset-assert 1) @@ -2903,180 +3338,192 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -;; (define-extern *ticks-per-frame* object) ;; int -;; (define-extern timer-init function) ;; (function timer-bank timer-mode int) -;; (define-extern bcd-conv function) -;; (define-extern *month-days* object) -;; (define-extern is-leap function) -;; (define-extern mdy-to-day function) -;; (define-extern rtclock-to-secs function) +(define-extern *ticks-per-frame* int) +(define-extern timer-init + "Initiate a timer, start counting at a rate of 1 every 256 bus clocks (BUSCLK: ~147.456MHz)." + (function timer-bank timer-mode int)) +(define-extern bcd-conv "Binary coded decimal to integer" (function uint int)) +(define-extern *month-days* (pointer uint32)) +(define-extern is-leap (function uint symbol)) +(define-extern mdy-to-day (function int int uint int)) +(define-extern rtclock-to-secs (function sce-cd-clock int)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; vif-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype vif-stat (uint32) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((vps uint8 :offset 0 :size 2) + (vew uint8 :offset 2 :size 1) + (mrk uint8 :offset 6 :size 1) + (vss uint8 :offset 8 :size 1) + (vfs uint8 :offset 9 :size 1) + (vis uint8 :offset 10 :size 1) + (int uint8 :offset 11 :size 1) + (er0 uint8 :offset 12 :size 1) + (er1 uint8 :offset 13 :size 1) + (fqc uint8 :offset 24 :size 4) ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -;; (deftype vif-fbrst (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype vif-fbrst (uint32) + ((rst uint8 :offset 0 :size 1) + (fbk uint8 :offset 1 :size 1) + (stp uint8 :offset 2 :size 1) + (stc uint8 :offset 3 :size 1) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) -;; (deftype vif-err (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype vif-err (uint32) + ((mii uint8 :offset 0 :size 1) + (me0 uint8 :offset 1 :size 1) ;; PS2 hardware bug, must set this to 1 for correct operation. + (me1 uint8 :offset 2 :size 1) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) -#| (deftype vif-bank (structure) - ((stat uint32 :offset-assert 0) - (fbrst uint32 :offset-assert 16) - (err vif-err :offset-assert 32) ;; guessed by decompiler - (mark uint32 :offset-assert 48) - (cycle uint32 :offset-assert 64) - (mode uint32 :offset-assert 80) - (num uint32 :offset-assert 96) - (mask uint32 :offset-assert 112) - (code uint32 :offset-assert 128) - (itops uint32 :offset-assert 144) - (base uint32 :offset-assert 160) - (offset uint32 :offset-assert 176) - (tops uint32 :offset-assert 192) - (itop uint32 :offset-assert 208) - (top uint32 :offset-assert 224) - (r0 uint32 :offset-assert 256) - (r1 uint32 :offset-assert 272) - (r2 uint32 :offset-assert 288) - (r3 uint32 :offset-assert 304) - (c0 uint32 :offset-assert 320) - (c1 uint32 :offset-assert 336) - (c2 uint32 :offset-assert 352) - (c3 uint32 :offset-assert 368) + ((stat uint32 :offset-assert 0) + (fbrst uint32 :offset 16) + (err vif-err :offset 32) + (mark uint32 :offset 48) + (cycle uint32 :offset 64) + (mode uint32 :offset 80) + (num uint32 :offset 96) + (mask uint32 :offset 112) + (code uint32 :offset 128) + (itops uint32 :offset 144) + (base uint32 :offset 160) + (offset uint32 :offset 176) + (tops uint32 :offset 192) + (itop uint32 :offset 208) + (top uint32 :offset 224) + (r0 uint32 :offset 256) + (r1 uint32 :offset 272) + (r2 uint32 :offset 288) + (r3 uint32 :offset 304) + (c0 uint32 :offset 320) + (c1 uint32 :offset 336) + (c2 uint32 :offset 352) + (c3 uint32 :offset 368) ) :method-count-assert 9 :size-assert #x174 :flag-assert #x900000174 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; dma-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype dma-chcr (uint32) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + "Memory mapped DMA channel control register. Typically used to start and check on DMA transfer." + ((dir uint8 :offset 0 :size 1) + (mod uint8 :offset 2 :size 2) + (asp uint8 :offset 4 :size 2) + (tte uint8 :offset 6 :size 1) + (tie uint8 :offset 7 :size 1) + (str uint8 :offset 8 :size 1) + (tag uint16 :offset 16 :size 16) ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype dma-bank (structure) - ((chcr dma-chcr :offset-assert 0) ;; guessed by decompiler - (madr uint32 :offset-assert 16) - (qwc uint32 :offset-assert 32) + "Bank of memory mapped DMA registers for a single channel. Used to control DMA." + ((chcr dma-chcr :offset 0) ;; guessed by decompiler + (madr uint32 :offset 16) + (qwc uint32 :offset 32) ) :method-count-assert 9 :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype dma-bank-source (dma-bank) - ((tadr uint32 :offset-assert 48) + "DMA channel registers for a DMA channel supporting source-chain." + ((tadr uint32 :offset 48) ) :method-count-assert 9 :size-assert #x34 :flag-assert #x900000034 ) -|# -#| (deftype dma-bank-vif (dma-bank-source) - ((as0 uint32 :offset-assert 64) - (as1 uint32 :offset-assert 80) + "DMA channel registers for a DMA channel with call/ret stack." + ((as0 uint32 :offset 64) + (as1 uint32 :offset 80) ) :method-count-assert 9 :size-assert #x54 :flag-assert #x900000054 ) -|# -#| (deftype dma-bank-spr (dma-bank-source) - ((sadr uint32 :offset-assert 128) + "DMA channel registers for a DMA channel supporting scratchpad transfer." + ((sadr uint32 :offset 128) ) :method-count-assert 9 :size-assert #x84 :flag-assert #x900000084 ) -|# -;; (deftype dma-ctrl (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype dma-ctrl (uint32) + "Main DMA control register, shared for all channels." + ((dmae uint8 :offset 0 :size 1) + (rele uint8 :offset 1 :size 1) + (mfd uint8 :offset 2 :size 2) + (sts uint8 :offset 4 :size 2) + (std uint8 :offset 6 :size 2) + (rcyc uint8 :offset 8 :size 3) + ) + :flag-assert #x900000004 + ) -;; (deftype dma-enable (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype dma-enable (uint32) + ((cpnd uint8 :offset 16 :size 1) + ) + :flag-assert #x900000004 + ) -;; (deftype dma-sqwc (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype dma-sqwc (uint32) + ((sqwc uint8 :offset 0 :size 8) + (tqwc uint8 :offset 16 :size 8) + ) + :flag-assert #x900000004 + ) -#| (deftype dma-bank-control (structure) - ((ctrl dma-ctrl :offset-assert 0) ;; guessed by decompiler - (stat uint32 :offset-assert 16) - (pcr uint32 :offset-assert 32) - (sqwc dma-sqwc :offset-assert 48) ;; guessed by decompiler - (rbsr uint32 :offset-assert 64) - (rbor uint32 :offset-assert 80) - (stadr uint32 :offset-assert 96) - (enabler uint32 :offset-assert 5408) - (enablew uint32 :offset-assert 5520) + "Memory mapping for shared DMA registers." + ((ctrl dma-ctrl :offset 0) ;; guessed by decompiler + (stat uint32 :offset 16) + (pcr uint32 :offset 32) + (sqwc dma-sqwc :offset 48) ;; guessed by decompiler + (rbsr uint32 :offset 64) + (rbor uint32 :offset 80) + (stadr uint32 :offset 96) + (enabler uint32 :offset 5408) + (enablew uint32 :offset 5520) ) :method-count-assert 9 :size-assert #x1594 :flag-assert #x900001594 ) -|# -#| (deftype vu-code-block (basic) + "Unused type for some VU code. vu-function is used instead." ((name basic :offset-assert 4) (code uint32 :offset-assert 8) (size int32 :offset-assert 12) @@ -3086,110 +3533,1009 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -;; (deftype vu-stat (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype vu-stat (uint64) + () + :flag-assert #x900000008 + ) + +;; +++dma-h:dma-tag-id +(defenum dma-tag-id + :bitfield #f + :type uint8 + (refe 0) ;; addr=ADDR, ends after this transfer + (cnt 1) ;; addr=after tag, next-tag=after data + (next 2) ;; addr=after tag, next-tag=ADDR + (ref 3) ;; addr=ADDR, next-tag=after tag + (refs 4) ;; ref, but stall controled + (call 5) ;; + (ret 6) ;; + (end 7) ;; next, but ends. + ) +;; ---dma-h:dma-tag-id -#| (deftype dma-tag (uint64) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + "The 64-bit tag used by the DMA system." + ((qwc uint16 :offset 0 :size 16) + (pce uint8 :offset 26 :size 2) + (id dma-tag-id :offset 28 :size 3) + (irq uint8 :offset 31 :size 1) + (addr uint32 :offset 32 :size 31) + (spr uint8 :offset 63 :size 1) ) :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype dma-bucket (structure) - ((tag uint64 :offset-assert 0) ;; dma-tag + "A linked list of DMA data, typically all in the same category. Used to organize the full DMA chain." + ((tag dma-tag :offset-assert 0) (last (pointer dma-tag) :offset-assert 8) ;; guessed by decompiler (dummy uint32 :offset-assert 12) - (next uint32 :offset-assert 4) - (clear uint64 :offset-assert 8) - (vif0 uint32 :offset-assert 8) - (vif1 uint32 :offset-assert 12) + (next uint32 :offset 4) + (clear uint64 :offset-assert 8 :overlay-at last) + (vif0 uint32 :offset-assert 8 :overlay-at last) + (vif1 uint32 :offset-assert 12 :overlay-at dummy) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (deftype vif-mask (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype vif-mask (uint32) + ((m0 uint8 :offset 0 :size 2) + (m1 uint8 :offset 2 :size 2) + (m2 uint8 :offset 4 :size 2) + (m3 uint8 :offset 6 :size 2) + (m4 uint8 :offset 8 :size 2) + (m5 uint8 :offset 10 :size 2) + (m6 uint8 :offset 12 :size 2) + (m7 uint8 :offset 14 :size 2) + (m8 uint8 :offset 16 :size 2) + (m9 uint8 :offset 18 :size 2) + (m10 uint8 :offset 20 :size 2) + (m11 uint8 :offset 22 :size 2) + (m12 uint8 :offset 24 :size 2) + (m13 uint8 :offset 26 :size 2) + (m14 uint8 :offset 28 :size 2) + (m15 uint8 :offset 30 :size 2) + ) + :flag-assert #x900000004 + ) -;; (deftype vif-stcycl-imm (uint16) -;; () -;; :flag-assert #x900000002 -;; ) +(deftype vif-stcycl-imm (uint16) + "The imm field of a VIF code using STCYCL, which adjusts the pattern for storing data." + ((cl uint8 :offset 0 :size 8) + (wl uint8 :offset 8 :size 8) + ) + :flag-assert #x900000002 + ) -;; (deftype vif-unpack-imm (uint16) -;; () -;; :flag-assert #x900000002 -;; ) +(deftype vif-unpack-imm (uint16) + "The imm field of a VIF code using UNPACK, which transfers data to VU memory." + ((addr uint16 :offset 0 :size 10) + (usn uint8 :offset 14 :size 1) + (flg uint8 :offset 15 :size 1) + ) + :flag-assert #x900000002 + ) +;; +++dma-h:vif-cmd +;; all these have mask (only applies to unpacks) and interrupt not set. +(defenum vif-cmd + :bitfield #f + :type uint8 + (nop 0) ;; no-op, can still have irq set. + (stcycl 1) ;; set write recycle register + (offset 2) ;; set offset register + (base 3) ;; set base register + (itop 4) ;; set data pointer register (itops) + (stmod 5) ;; set mode register + (mskpath3 6) ;; set path 3 mask + (mark 7) ;; set mark register + (pc-port 8) ;; special tag for PC Port data. + (flushe 16) ;; wait for end of microprogram + (flush 17) ;; wait for end of microprogram and transfer (path1/path2) + (flusha 19) ;; wait for end of microprogram and transfer (path1/path2/path3) + (mscal 20) ;; activate microprogram (call) + (mscalf 21) ;; flushe and activate (call) + (mscnt 23) ;; activate microprogram (continue) + (stmask 32) ;; set MASK register. + (strow 48) ;; set filling data + (stcol 49) ;; set filling data + (mpg 74) ;; transfer microprogram + (direct 80) ;; straight to GIF. + (directhl 81) + (unpack-s-32 96) + (unpack-s-16 97) + (unpack-s-8 98) + ;; 99 is invllid + (unpack-v2-32 100) + (unpack-v2-16 101) + (unpack-v2-8 102) + ;; 103 is invalid + (unpack-v3-32 104) + (unpack-v3-16 105) + (unpack-v3-8 106) + ;; 107 is invalid + (unpack-v4-32 108) + (unpack-v4-16 109) + (unpack-v4-8 110) + (unpack-v4-5 111) + (cmd-mask 239) ;; not sure what this is. + ) +;; ---dma-h:vif-cmd + +;; +++dma-h:vif-cmd-32 +;; this makes a copy of the above type, but uses a uint32. +(defenum vif-cmd-32 + :bitfield #f + :type uint32 + :copy-entries vif-cmd + ) +;; ---dma-h:vif-cmd-32 -#| (deftype vif-tag (uint32) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + "A tag consumed by the VIF, which accepts DMA data." + ((imm uint16 :offset 0 :size 16) + (num uint8 :offset 16 :size 8) + (cmd vif-cmd :offset 24 :size 7) + (irq uint8 :offset 31 :size 1) + (msk uint8 :offset 28 :size 1) ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -;; (define-extern dma-sync-fast function) ;; (function dma-bank none) -;; (define-extern dma-send-no-scratch function) ;; (function dma-bank uint32 uint32 none) -;; (define-extern dma-sync-with-count function) ;; (function dma-bank (pointer int32) int) -;; (define-extern dma-count-until-done function) ;; (function dma-bank (pointer int32) int) +(define-extern dma-sync-fast (function dma-bank none)) +(define-extern dma-send-no-scratch (function dma-bank uint32 uint32 none)) +(define-extern dma-sync-with-count (function dma-bank (pointer int32) int)) +(define-extern dma-count-until-done (function dma-bank (pointer int32) int)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; video-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype video-params (structure) + "Parameters for the framebuffer." ((set-video-mode symbol :offset-assert 0) ;; guessed by decompiler (reset-video-mode symbol :offset-assert 4) ;; guessed by decompiler - (relative-x-scale float :offset-assert 16) + (relative-x-scale float :offset 16) (display-dx int32 :offset-assert 20) (display-dy int32 :offset-assert 24) (display-sy int32 :offset-assert 28) (relative-x-scale-reciprical float :offset-assert 32) (smode2 uint64 :offset-assert 40) - (aspect-ratio basic :offset-assert 48) + (aspect-ratio symbol :offset-assert 48) ) :method-count-assert 9 :size-assert #x34 :flag-assert #x900000034 ) -|# -;; (define-extern *video-params* object) ;; video-params +(define-extern *video-params* video-params) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; vu1-user-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++vu1-user-h:tpage-category +;; TODO - copied from jak 3 +(defenum tpage-category + :type int8 + (tfrag 0) ;; + (pris 1) + (shrub 2) + (alpha 3) + (water 4) + (warp 5) + (pris2 6) + (sprite 7) + (hud 8) ;; or map? + (sky 9) + (hfrag 10) + ) +;; ---vu1-user-h:tpage-category + +;; +++vu1-user-h:tpage-category-u32 +(defenum tpage-category-u32 + :type uint32 + :copy-entries tpage-category + ) +;; ---vu1-user-h:tpage-category-u32 + +;; +++vu1-user-h:bucket-id +;; -l- +(defenum bucket-id + :type int32 + (bucket0 0) + (bucket1 1) + (bucket2 2) ;; pc vis stuff + (blit 3) + (tex-lcom-sky-pre 4) + (sky 5) ;; sky + (bucket6 6) ;; ocean + (bucket7 7) ;; unknown new jak 3 texture upload, for all levels. + (hfrag 8) ;; hfrag + (hfrag-scissor 9) ;; hfrag + + (tex-l0-tfrag 10) ;; texture + (tfrag-l0-tfrag 11) ;; tfrag + (tie-l0-tfrag 12) ;; tie + (etie-l0-tfrag 13) ;; tie + (tfrag-scissor-l0-tfrag 14) ;; tfrag + (tie-scissor-l0-tfrag 15) ;; tie + (etie-scissor-l0-tfrag 16) ;; tie + (merc-l0-tfrag 17) ;; merc + (emerc-l0-tfrag 18) ;; emerc + (gmerc-l0-tfrag 19) ;; generic + (tie-vanish-l0-tfrag 20) ;; tie + (gmerc2-l0-tfrag 21) ;; generic + + (tex-l1-tfrag 22) + (tfrag-l1-tfrag 23) + (tie-l1-tfrag 24) + (etie-l1-tfrag 25) + (tfrag-scissor-l1-tfrag 26) + (tie-scissor-l1-tfrag 27) + (etie-scissor-l1-tfrag 28) + (merc-l1-tfrag 29) + (emerc-l1-tfrag 30) + (gmerc-l1-tfrag 31) + (tie-vanish-l1-tfrag 32) + (gmerc2-l1-tfrag 33) + + (tex-l2-tfrag 34) + (tfrag-l2-tfrag 35) + (tie-l2-tfrag 36) + (etie-l2-tfrag 37) + (tfrag-scissor-l2-tfrag 38) + (tie-scissor-l2-tfrag 39) + (etie-scissor-l2-tfrag 40) + (merc-l2-tfrag 41) + (emerc-l2-tfrag 42) + (gmerc-l2-tfrag 43) + (tie-vanish-l2-tfrag 44) + (gmerc2-l2-tfrag 45) + + (tex-l3-tfrag 46) + (tfrag-l3-tfrag 47) + (tie-l3-tfrag 48) + (etie-l3-tfrag 49) + (tfrag-scissor-l3-tfrag 50) + (tie-scissor-l3-tfrag 51) + (etie-scissor-l3-tfrag 52) + (merc-l3-tfrag 53) + (emerc-l3-tfrag 54) + (gmerc-l3-tfrag 55) + (tie-vanish-l3-tfrag 56) + (gmerc2-l3-tfrag 57) + + (tex-l4-tfrag 58) + (tfrag-l4-tfrag 59) + (tie-l4-tfrag 60) + (etie-l4-tfrag 61) + (tfrag-scissor-l4-tfrag 62) + (tie-scissor-l4-tfrag 63) + (etie-scissor-l4-tfrag 64) + (merc-l4-tfrag 65) + (emerc-l4-tfrag 66) + (gmerc-l4-tfrag 67) + (tie-vanish-l4-tfrag 68) + (gmerc2-l4-tfrag 69) + + (tex-l5-tfrag 70) + (tfrag-l5-tfrag 71) + (tie-l5-tfrag 72) + (etie-l5-tfrag 73) + (tfrag-scissor-l5-tfrag 74) + (tie-scissor-l5-tfrag 75) + (etie-scissor-l5-tfrag 76) + (merc-l5-tfrag 77) + (emerc-l5-tfrag 78) + (gmerc-l5-tfrag 79) + (tie-vanish-l5-tfrag 80) + (gmerc2-l5-tfrag 81) + + (tex-l6-tfrag 82) + (tfrag-l6-tfrag 83) + (tie-l6-tfrag 84) + (etie-l6-tfrag 85) + (tfrag-scissor-l6-tfrag 86) + (tie-scissor-l6-tfrag 87) + (etie-scissor-l6-tfrag 88) + (merc-l6-tfrag 89) + (emerc-l6-tfrag 90) + (gmerc-l6-tfrag 91) + (tie-vanish-l6-tfrag 92) + (gmerc2-l6-tfrag 93) + + (tex-l7-tfrag 94) + (tfrag-l7-tfrag 95) + (tie-l7-tfrag 96) + (etie-l7-tfrag 97) + (tfrag-scissor-l7-tfrag 98) + (tie-scissor-l7-tfrag 99) + (etie-scissor-l7-tfrag 100) + (merc-l7-tfrag 101) + (emerc-l7-tfrag 102) + (gmerc-l7-tfrag 103) + (tie-vanish-l7-tfrag 104) + (gmerc2-l7-tfrag 105) + + (tex-l8-tfrag 106) + (tfrag-l8-tfrag 107) + (tie-l8-tfrag 108) + (etie-l8-tfrag 109) + (tfrag-scissor-l8-tfrag 110) + (tie-scissor-l8-tfrag 111) + (etie-scissor-l8-tfrag 112) + (merc-l8-tfrag 113) + (emerc-l8-tfrag 114) + (gmerc-l8-tfrag 115) + (tie-vanish-l8-tfrag 116) + (gmerc2-l8-tfrag 117) + + (tex-l9-tfrag 118) + (tfrag-l9-tfrag 119) + (tie-l9-tfrag 120) + (etie-l9-tfrag 121) + (tfrag-scissor-l9-tfrag 122) + (tie-scissor-l9-tfrag 123) + (etie-scissor-l9-tfrag 124) + (merc-l9-tfrag 125) + (emerc-l9-tfrag 126) + (gmerc-l9-tfrag 127) + (tie-vanish-l9-tfrag 128) + (gmerc2-l9-tfrag 129) + + (tex-l0-shrub 130) + (shrub-l0-shrub 131) + (shrub-near-l0-shrub 132) + (billboard-l0-shrub 133) + (shrub-vanish-l0-shrub 134) + (shrub-near-trans-l0-shrub 135) + (merc-l0-shrub 136) + (emerc-l0-shrub 137) + (gmerc-l0-shrub 138) + (gmerc2-l0-shrub 139) + + (tex-l1-shrub 140) + (shrub-l1-shrub 141) + (shrub-near-l1-shrub 142) + (billboard-l1-shrub 143) + (shrub-vanish-l1-shrub 144) + (shrub-near-trans-l1-shrub 145) + (merc-l1-shrub 146) + (emerc-l1-shrub 147) + (gmerc-l1-shrub 148) + (gmerc2-l1-shrub 149) + + (tex-l2-shrub 150) + (shrub-l2-shrub 151) + (shrub-near-l2-shrub 152) + (billboard-l2-shrub 153) + (shrub-vanish-l2-shrub 154) + (shrub-near-trans-l2-shrub 155) + (merc-l2-shrub 156) + (emerc-l2-shrub 157) + (gmerc-l2-shrub 158) + (gmerc2-l2-shrub 159) + + (tex-l3-shrub 160) + (shrub-l3-shrub 161) + (shrub-near-l3-shrub 162) + (billboard-l3-shrub 163) + (shrub-vanish-l3-shrub 164) + (shrub-near-trans-l3-shrub 165) + (merc-l3-shrub 166) + (emerc-l3-shrub 167) + (gmerc-l3-shrub 168) + (gmerc2-l3-shrub 169) + + (tex-l4-shrub 170) + (shrub-l4-shrub 171) + (shrub-near-l4-shrub 172) + (billboard-l4-shrub 173) + (shrub-vanish-l4-shrub 174) + (shrub-near-trans-l4-shrub 175) + (merc-l4-shrub 176) + (emerc-l4-shrub 177) + (gmerc-l4-shrub 178) + (gmerc2-l4-shrub 179) + + (tex-l5-shrub 180) + (shrub-l5-shrub 181) + (shrub-near-l5-shrub 182) + (billboard-l5-shrub 183) + (shrub-vanish-l5-shrub 184) + (shrub-near-trans-l5-shrub 185) + (merc-l5-shrub 186) + (emerc-l5-shrub 187) + (gmerc-l5-shrub 188) + (gmerc2-l5-shrub 189) + + (tex-l6-shrub 190) + (shrub-l6-shrub 191) + (shrub-near-l6-shrub 192) + (billboard-l6-shrub 193) + (shrub-vanish-l6-shrub 194) + (shrub-near-trans-l6-shrub 195) + (merc-l6-shrub 196) + (emerc-l6-shrub 197) + (gmerc-l6-shrub 198) + (gmerc2-l6-shrub 199) + + (tex-l7-shrub 200) + (shrub-l7-shrub 201) + (shrub-near-l7-shrub 202) + (billboard-l7-shrub 203) + (shrub-vanish-l7-shrub 204) + (shrub-near-trans-l7-shrub 205) + (merc-l7-shrub 206) + (emerc-l7-shrub 207) + (gmerc-l7-shrub 208) + (gmerc2-l7-shrub 209) + + (tex-l8-shrub 210) + (shrub-l8-shrub 211) + (shrub-near-l8-shrub 212) + (billboard-l8-shrub 213) + (shrub-vanish-l8-shrub 214) + (shrub-near-trans-l8-shrub 215) + (merc-l8-shrub 216) + (emerc-l8-shrub 217) + (gmerc-l8-shrub 218) + (gmerc2-l8-shrub 219) + + (tex-l9-shrub 220) + (shrub-l9-shrub 221) + (shrub-near-l9-shrub 222) + (billboard-l9-shrub 223) + (shrub-vanish-l9-shrub 224) + (shrub-near-trans-l9-shrub 225) + (merc-l9-shrub 226) + (emerc-l9-shrub 227) + (gmerc-l9-shrub 228) + (gmerc2-l9-shrub 229) + + (tex-l0-alpha 230) + (tfrag-l0-alpha 231) + (tie-l0-alpha 232) + (etie-l0-alpha 233) + (merc-l0-alpha 234) + (emerc-l0-alpha 235) + (gmerc-l0-alpha 236) + (tfrag-scissor-l0-alpha 237) + (tie-scissor-l0-alpha 238) + (etie-scissor-l0-alpha 239) + (gmerc2-l0-alpha 240) + + (tex-l1-alpha 241) + (tfrag-l1-alpha 242) + (tie-l1-alpha 243) + (etie-l1-alpha 244) + (merc-l1-alpha 245) + (emerc-l1-alpha 246) + (gmerc-l1-alpha 247) + (tfrag-scissor-l1-alpha 248) + (tie-scissor-l1-alpha 249) + (etie-scissor-l1-alpha 250) + (gmerc2-l1-alpha 251) + + (tex-l2-alpha 252) + (tfrag-l2-alpha 253) + (tie-l2-alpha 254) + (etie-l2-alpha 255) + (merc-l2-alpha 256) + (emerc-l2-alpha 257) + (gmerc-l2-alpha 258) + (tfrag-scissor-l2-alpha 259) + (tie-scissor-l2-alpha 260) + (etie-scissor-l2-alpha 261) + (gmerc2-l2-alpha 262) + + (tex-l3-alpha 263) + (tfrag-l3-alpha 264) + (tie-l3-alpha 265) + (etie-l3-alpha 266) + (merc-l3-alpha 267) + (emerc-l3-alpha 268) + (gmerc-l3-alpha 269) + (tfrag-scissor-l3-alpha 270) + (tie-scissor-l3-alpha 271) + (etie-scissor-l3-alpha 272) + (gmerc2-l3-alpha 273) + + (tex-l4-alpha 274) + (tfrag-l4-alpha 275) + (tie-l4-alpha 276) + (etie-l4-alpha 277) + (merc-l4-alpha 278) + (emerc-l4-alpha 279) + (gmerc-l4-alpha 280) + (tfrag-scissor-l4-alpha 281) + (tie-scissor-l4-alpha 282) + (etie-scissor-l4-alpha 283) + (gmerc2-l4-alpha 284) + + (tex-l5-alpha 285) + (tfrag-l5-alpha 286) + (tie-l5-alpha 287) + (etie-l5-alpha 288) + (merc-l5-alpha 289) + (emerc-l5-alpha 290) + (gmerc-l5-alpha 291) + (tfrag-scissor-l5-alpha 292) + (tie-scissor-l5-alpha 293) + (etie-scissor-l5-alpha 294) + (gmerc2-l5-alpha 295) + + (tex-l6-alpha 296) + (tfrag-l6-alpha 297) + (tie-l6-alpha 298) + (etie-l6-alpha 299) + (merc-l6-alpha 300) + (emerc-l6-alpha 301) + (gmerc-l6-alpha 302) + (tfrag-scissor-l6-alpha 303) + (tie-scissor-l6-alpha 304) + (etie-scissor-l6-alpha 305) + (gmerc2-l6-alpha 306) + + (tex-l7-alpha 307) + (tfrag-l7-alpha 308) + (tie-l7-alpha 309) + (etie-l7-alpha 310) + (merc-l7-alpha 311) + (emerc-l7-alpha 312) + (gmerc-l7-alpha 313) + (tfrag-scissor-l7-alpha 314) + (tie-scissor-l7-alpha 315) + (etie-scissor-l7-alpha 316) + (gmerc2-l7-alpha 317) + + (tex-l8-alpha 318) + (tfrag-l8-alpha 319) + (tie-l8-alpha 320) + (etie-l8-alpha 321) + (merc-l8-alpha 322) + (emerc-l8-alpha 323) + (gmerc-l8-alpha 324) + (tfrag-scissor-l8-alpha 325) + (tie-scissor-l8-alpha 326) + (etie-scissor-l8-alpha 327) + (gmerc2-l8-alpha 328) + + (tex-l9-alpha 329) + (tfrag-l9-alpha 330) + (tie-l9-alpha 331) + (etie-l9-alpha 332) + (merc-l9-alpha 333) + (emerc-l9-alpha 334) + (gmerc-l9-alpha 335) + (tfrag-scissor-l9-alpha 336) + (tie-scissor-l9-alpha 337) + (etie-scissor-l9-alpha 338) + (gmerc2-l9-alpha 339) + + (tex-lcom-tfrag 340) + (merc-lcom-tfrag 341) + (emerc-lcom-tfrag 342) + (gmerc-lcom-tfrag 343) + (gmerc2-lcom-tfrag 344) + + (tex-lcom-shrub 345) + (merc-lcom-shrub 346) + (emerc-lcom-shrub 347) + (gmerc-lcom-shrub 348) + (gmerc2-lcom-shrub 349) + + (shadow 350) + + (tex-l0-pris 351) + (merc-l0-pris 352) + (emerc-l0-pris 353) + (gmerc-l0-pris 354) + (gmerc2-l0-pris 355) + + (tex-l1-pris 356) + (merc-l1-pris 357) + (emerc-l1-pris 358) + (gmerc-l1-pris 359) + (gmerc2-l1-pris 360) + + (tex-l2-pris 361) + (merc-l2-pris 362) + (emerc-l2-pris 363) + (gmerc-l2-pris 364) + (gmerc2-l2-pris 365) + + (tex-l3-pris 366) + (merc-l3-pris 367) + (emerc-l3-pris 368) + (gmerc-l3-pris 369) + (gmerc2-l3-pris 370) + + (tex-l4-pris 371) + (merc-l4-pris 372) + (emerc-l4-pris 373) + (gmerc-l4-pris 374) + (gmerc2-l4-pris 375) + + (tex-l5-pris 376) + (merc-l5-pris 377) + (emerc-l5-pris 378) + (gmerc-l5-pris 379) + (gmerc2-l5-pris 380) + + (tex-l6-pris 381) + (merc-l6-pris 382) + (emerc-l6-pris 383) + (gmerc-l6-pris 384) + (gmerc2-l6-pris 385) + + (tex-l7-pris 386) + (merc-l7-pris 387) + (emerc-l7-pris 388) + (gmerc-l7-pris 389) + (gmerc2-l7-pris 390) + + (tex-l8-pris 391) + (merc-l8-pris 392) + (emerc-l8-pris 393) + (gmerc-l8-pris 394) + (gmerc2-l8-pris 395) + + (tex-l9-pris 396) + (merc-l9-pris 397) + (emerc-l9-pris 398) + (gmerc-l9-pris 399) + (gmerc2-l9-pris 400) + + (tex-lcom-pris 401) + (merc-lcom-pris 402) + (emerc-lcom-pris 403) + (gmerc-lcom-pris 404) + (gmerc2-lcom-pris 405) + + (tex-l0-pris2 406) + (merc-l0-pris2 407) + (emerc-l0-pris2 408) + (gmerc-l0-pris2 409) + (gmerc2-l0-pris2 410) + + (tex-l1-pris2 411) + (merc-l1-pris2 412) + (emerc-l1-pris2 413) + (gmerc-l1-pris2 414) + (gmerc2-l1-pris2 415) + + (tex-l2-pris2 416) + (merc-l2-pris2 417) + (emerc-l2-pris2 418) + (gmerc-l2-pris2 419) + (gmerc2-l2-pris2 420) + + (tex-l3-pris2 421) + (merc-l3-pris2 422) + (emerc-l3-pris2 423) + (gmerc-l3-pris2 424) + (gmerc2-l3-pris2 425) + + (tex-l4-pris2 426) + (merc-l4-pris2 427) + (emerc-l4-pris2 428) + (gmerc-l4-pris2 429) + (gmerc2-l4-pris2 430) + + (tex-l5-pris2 431) + (merc-l5-pris2 432) + (emerc-l5-pris2 433) + (gmerc-l5-pris2 434) + (gmerc2-l5-pris2 435) + + (tex-l6-pris2 436) + (merc-l6-pris2 437) + (emerc-l6-pris2 438) + (gmerc-l6-pris2 439) + (gmerc2-l6-pris2 440) + + (tex-l7-pris2 441) + (merc-l7-pris2 442) + (emerc-l7-pris2 443) + (gmerc-l7-pris2 444) + (gmerc2-l7-pris2 445) + + (tex-l8-pris2 446) + (merc-l8-pris2 447) + (emerc-l8-pris2 448) + (gmerc-l8-pris2 449) + (gmerc2-l8-pris2 450) + + (tex-l9-pris2 451) + (merc-l9-pris2 452) + (emerc-l9-pris2 453) + (gmerc-l9-pris2 454) + (gmerc2-l9-pris2 455) + + (tex-lcom-pris2 456) + (merc-lcom-pris2 457) + (emerc-lcom-pris2 458) + (gmerc-lcom-pris2 459) + (gmerc2-lcom-pris2 460) + + (tex-lcom-sky-post 461) + (bucket462 462) + + (tex-l0-water 463) + (merc-l0-water 464) + (gmerc-l0-water 465) + (tfrag-l0-water 466) + (tie-l0-water 467) + (etie-l0-water 468) + (tie-scissor-l0-water 469) + (tfrag-scissor-l0-water 470) + (etie-scissor-l0-water 471) + (gmerc2-l0-water 472) + + (tex-l1-water 473) + (merc-l1-water 474) + (gmerc-l1-water 475) + (tfrag-l1-water 476) + (tie-l1-water 477) + (etie-l1-water 478) + (tie-scissor-l1-water 479) + (tfrag-scissor-l1-water 480) + (etie-scissor-l1-water 481) + (gmerc2-l1-water 482) + + (tex-l2-water 483) + (merc-l2-water 484) + (gmerc-l2-water 485) + (tfrag-l2-water 486) + (tie-l2-water 487) + (etie-l2-water 488) + (tie-scissor-l2-water 489) + (tfrag-scissor-l2-water 490) + (etie-scissor-l2-water 491) + (gmerc2-l2-water 492) + + (tex-l3-water 493) + (merc-l3-water 494) + (gmerc-l3-water 495) + (tfrag-l3-water 496) + (tie-l3-water 497) + (etie-l3-water 498) + (tie-scissor-l3-water 499) + (tfrag-scissor-l3-water 500) + (etie-scissor-l3-water 501) + (gmerc2-l3-water 502) + + (tex-l4-water 503) + (merc-l4-water 504) + (gmerc-l4-water 505) + (tfrag-l4-water 506) + (tie-l4-water 507) + (etie-l4-water 508) + (tie-scissor-l4-water 509) + (tfrag-scissor-l4-water 510) + (etie-scissor-l4-water 511) + (gmerc2-l4-water 512) + + (tex-l5-water 513) + (merc-l5-water 514) + (gmerc-l5-water 515) + (tfrag-l5-water 516) + (tie-l5-water 517) + (etie-l5-water 518) + (tie-scissor-l5-water 519) + (tfrag-scissor-l5-water 520) + (etie-scissor-l5-water 521) + (gmerc2-l5-water 522) + + (tex-l6-water 523) + (merc-l6-water 524) + (gmerc-l6-water 525) + (tfrag-l6-water 526) + (tie-l6-water 527) + (etie-l6-water 528) + (tie-scissor-l6-water 529) + (tfrag-scissor-l6-water 530) + (etie-scissor-l6-water 531) + (gmerc2-l6-water 532) + + (tex-l7-water 533) + (merc-l7-water 534) + (gmerc-l7-water 535) + (tfrag-l7-water 536) + (tie-l7-water 537) + (etie-l7-water 538) + (tie-scissor-l7-water 539) + (tfrag-scissor-l7-water 540) + (etie-scissor-l7-water 541) + (gmerc2-l7-water 542) + + (tex-l8-water 543) + (merc-l8-water 544) + (gmerc-l8-water 545) + (tfrag-l8-water 546) + (tie-l8-water 547) + (etie-l8-water 548) + (tie-scissor-l8-water 549) + (tfrag-scissor-l8-water 550) + (etie-scissor-l8-water 551) + (gmerc2-l8-water 552) + + (tex-l9-water 553) + (merc-l9-water 554) + (gmerc-l9-water 555) + (tfrag-l9-water 556) + (tie-l9-water 557) + (etie-l9-water 558) + (tie-scissor-l9-water 559) + (tfrag-scissor-l9-water 560) + (etie-scissor-l9-water 561) + (gmerc2-l9-water 562) + + (tex-lcom-water 563) + (merc-lcom-water 564) + (gmerc-lcom-water 565) + (gmerc2-lcom-water 566) ;; default for prim + (anti-alias 567) + + (tex-sprite 568) + (generic-sprite-1 569) ;; ;prim + (particles 570) + (generic-sprite-2 571) + (shadow2 572) + (shadow3 573) + (generic-sprite-3 574) + + (tex-warp 575) + (generic-warp 576) + + (debug-no-zbuf1 577) ;; debug? + (tex-hud-hud-alpha 578) + (hud-draw-hud-alpha 579) + (tex-hud-pris2 580) + (hud-draw-pris2 581) + (bucket582 582) + (debug 583) + (debug-no-zbuf2 584) + (debug-menu 585) + (bucket586 586) + (bucket587 587) + (bucket588 588) + (bucket589 589) + (bucket590 590) + (bucket591 591) + (bucket592 592) + (bucket593 593) + (bucket594 594) + (bucket595 595) + (bucket596 596) + (bucket597 597) + (bucket598 598) + (bucket599 599) + (bucket600 600) + (bucket601 601) + (bucket602 602) + (bucket603 603) + (bucket604 604) + (bucket605 605) + (bucket606 606) + (bucket607 607) + (bucket608 608) + (bucket609 609) + (bucket610 610) + (bucket611 611) + (bucket612 612) + + (bucket621 621) + + (bucket630 630) + + (bucket633 633) + (bucket634 634) + (bucket635 635) + + (bucket642 642) + (bucket643 643) + (bucket644 644) + + (bucket651 651) + (bucket652 652) + (bucket653 653) + (bucket654 654) + + (bucket661 661) + (bucket662 662) + (bucket663 663) + + (bucket670 670) + (bucket671 671) + (bucket672 672) + (bucket673 673) + + (bucket680 680) + (bucket681 681) + (bucket682 682) + + (bucket689 689) + (bucket690 690) + (bucket691 691) + (bucket692 692) + + (bucket699 699) + (bucket700 700) + (bucket701 701) + + (bucket708 708) + (bucket709 709) + + (bucket728 728) + + (bucket747 747) + + (bucket767 767) + (bucket768 768) + + (bucket770 770) + (bucket771 771) + + (bucket773 773) + (bucket774 774) + (bucket775 775) + (bucket776 776) + (bucket777 777) + + (bucket780 780) + + (bucket785 785) + (bucket786 786) + + (bucket788 788) + ) +;; ---vu1-user-h:bucket-id + +;; +++vu1-user-h:bucket-id-16 +(defenum bucket-id-16 + :type int16 + :copy-entries bucket-id + ) +;; ---vu1-user-h:bucket-id-16 + +;; +++vu1-user-h:texture-enable-mask +(defenum texture-enable-mask + :type uint64 + :bitfield #t + (tfrag 0) + (all-pris 1) + (shrub 2) + (alpha 3) + (water 4) + (warp 5) + (sprite 6) + (hud 7) + (sky 8) + (hfrag 9) + ) +;; ---vu1-user-h:texture-enable-mask + +;; +++vu1-user-h:texture-enable-mask-u32 +(defenum texture-enable-mask-u32 + :type uint32 + :bitfield #t + :copy-entries texture-enable-mask + ) +;; ---vu1-user-h:texture-enable-mask-u32 + (deftype dma-foreground-sink (basic) - ((bucket int32 :offset-assert 4) ;; bucket-id - (foreground-texture-page int8 :offset-assert 8) ;; tpage-category + "A specification for where a foreground renderer should output its DMA data." + ((bucket bucket-id :offset-assert 4) + (foreground-texture-page tpage-category :offset-assert 8) (foreground-texture-level int8 :offset-assert 9) (foreground-output-bucket int8 :offset-assert 10) ) @@ -3197,36 +4543,39 @@ :size-assert #xb :flag-assert #x90000000b ) -|# -#| (deftype generic-bucket-state (structure) + "The state of buffers for the generic renderer. + When generating generic DMA data, you must know the previous state + of the VU's memory to properly double-buffer the input and output data." ((gifbuf-adr uint32 :offset-assert 0) (inbuf-adr uint32 :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype generic-dma-foreground-sink (dma-foreground-sink) + "A specification for where a foreground generic renderer should output DMA data, + and the state of the VU memory buffers at the end of the bucket." ((state generic-bucket-state :inline :offset-assert 12) ) :method-count-assert 9 :size-assert #x14 :flag-assert #x900000014 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; profile-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type dma-buffer structure) + (deftype profile-segment (structure) + "Confusingly, this has two uses. Either a single event, or a summary of all events within a category." ((name symbol :offset-assert 0) ;; guessed by decompiler (start-time int16 :offset-assert 4) (end-time int16 :offset-assert 6) @@ -3234,188 +4583,211 @@ (vu-count uint8 :offset-assert 9) (depth uint16 :offset-assert 10) (color rgba :offset-assert 12) ;; guessed by decompiler - (code-time uint16 :offset-assert 4) - (vu-time uint16 :offset-assert 6) + (code-time uint16 :offset-assert 4 :overlay-at start-time) + (vu-time uint16 :offset-assert 6 :overlay-at end-time) ) + :allow-misaligned :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype profile-collapse (structure) + "An array of 'summaries'. Each entry in data is a summary of all events within a category." ((count int32 :offset-assert 0) - (data profile-segment 48 :offset-assert 4) ;; guessed by decompiler + (data profile-segment 48 :inline :offset-assert 4) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x304 :flag-assert #x900000304 ) -|# -#| (deftype profile-segment-array (basic) + "All profiling data for a frame, stored as a tree of events. There is one for the VU, and one for the EE." ((count int16 :offset-assert 4) (depth int8 :offset-assert 6) (max-depth int8 :offset-assert 7) (base-time int16 :offset-assert 8) (segment profile-segment 9 :offset-assert 12) ;; guessed by decompiler - (data profile-segment 2100 :offset-assert 48) ;; guessed by decompiler + (data profile-segment 1024 :inline :offset-assert 48) ;; guessed by decompiler ) :method-count-assert 13 - :size-assert #x8370 - :flag-assert #xd00008370 + :size-assert #x4030 + :flag-assert #xd00004030 (:methods - (profile-segment-array-method-9 () none) ;; 9 ;; (get-total-time (_type_) int) - (profile-segment-array-method-10 () none) ;; 10 ;; (start-frame! (_type_) none) - (profile-segment-array-method-11 () none) ;; 11 ;; (start-segment! (_type_ symbol rgba) none) - (profile-segment-array-method-12 () none) ;; 12 ;; (end-segment! (_type_) none) + (get-total-time "Get the duration of the top-level event (typically, the whole frame)" (_type_) int) ;; 9 + (start-frame! "Restart the profiler for the start of a frame." (_type_) none) ;; 10 + (start-segment! "Start an event." (_type_ symbol rgba) none) ;; 11 + (end-segment! "Stop the most recently started event." (_type_) none) ;; 12 ) ) -|# -#| (deftype profile-array (structure) + "The EE and VU profilers, and the drawing code." ((data profile-segment-array 2 :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 12 :size-assert #x8 :flag-assert #xc00000008 (:methods - (profile-array-method-9 () none) ;; 9 ;; (postprocess-data! (_type_) none) - (profile-array-method-10 () none) ;; 10 ;; (draw-bars! (_type_ dma-buffer int) none) - (profile-array-method-11 () none) ;; 11 ;; (draw-text! (_type_) none) + (postprocess-data! "Create the collapsed summary of the collected data." (_type_) none) ;; 9 + (draw-bars! "Generate DMA data for drawing the profile bars." (_type_ dma-buffer int) none) ;; 10 + (draw-text! "Generate DMA data for drawing the profile information screen." (_type_) none) ;; 11 ) ) -|# -#| (deftype profile-spec (structure) - ((name symbol :offset-assert 0) ;; guessed by decompiler - (color rgba :offset-assert 4) ;; guessed by decompiler + "Specification for a profile category." + ((name symbol :offset-assert 0) + (color rgba :offset-assert 4) ) :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -;; (define-extern *profile-gap-color* object) ;; rgba -;; (define-extern *profile-all-color* object) ;; rgba -;; (define-extern *profile-blit-color* object) ;; rgba -;; (define-extern *profile-sky-color* object) ;; rgba -;; (define-extern *profile-ocean-color* object) ;; rgba -;; (define-extern *profile-tfrag-color* object) ;; rgba -;; (define-extern *profile-texture-color* object) ;; rgba -;; (define-extern *profile-tie-color* object) ;; rgba -;; (define-extern *profile-generic-color* object) ;; rgba -;; (define-extern *profile-merc-color* object) ;; rgba -;; (define-extern *profile-shrubbery-color* object) ;; rgba -;; (define-extern *profile-particle-color* object) ;; rgba -;; (define-extern *profile-debug-color* object) ;; rgba -;; (define-extern *profile-other-color* object) ;; rgba -;; (define-extern *profile-joints-color* object) ;; rgba -;; (define-extern *profile-draw-hook-color* object) ;; rgba -;; (define-extern *profile-background-color* object) ;; rgba -;; (define-extern *profile-foreground-color* object) ;; rgba -;; (define-extern *profile-bones-color* object) ;; rgba -;; (define-extern *profile-actors-color* object) ;; rgba -;; (define-extern *profile-collide-color* object) ;; rgba -;; (define-extern *profile-nav-color* object) ;; rgba -;; (define-extern *profile-camera-color* object) ;; rgba -;; (define-extern *profile-gs-sync-color* object) ;; rgba -;; (define-extern *profile-array* object) ;; profile-array -;; (define-extern *profile-collapse* object) ;; profile-collapse -;; (define-extern *profile-interrupt-segment* object) ;; profile-segment-array -;; (define-extern *profile-interrupt-start* object) ;; symbol +(define-extern *profile-gap-color* rgba) +(define-extern *profile-all-color* rgba) +(define-extern *profile-blit-color* rgba) +(define-extern *profile-sky-color* rgba) +(define-extern *profile-ocean-color* rgba) +(define-extern *profile-tfrag-color* rgba) +(define-extern *profile-texture-color* rgba) +(define-extern *profile-tie-color* rgba) +(define-extern *profile-generic-color* rgba) +(define-extern *profile-merc-color* rgba) +(define-extern *profile-shrubbery-color* rgba) +(define-extern *profile-particle-color* rgba) +(define-extern *profile-debug-color* rgba) +(define-extern *profile-other-color* rgba) +(define-extern *profile-joints-color* rgba) +(define-extern *profile-draw-hook-color* rgba) +(define-extern *profile-background-color* rgba) +(define-extern *profile-foreground-color* rgba) +(define-extern *profile-bones-color* rgba) +(define-extern *profile-actors-color* rgba) +(define-extern *profile-collide-color* rgba) +(define-extern *profile-nav-color* rgba) +(define-extern *profile-camera-color* rgba) +(define-extern *profile-gs-sync-color* rgba) +(define-extern *profile-array* profile-array) +(define-extern *profile-collapse* profile-collapse) +(define-extern *profile-interrupt-segment* profile-segment-array) +(define-extern *profile-interrupt-start* symbol) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; dma ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define-extern dma-sync-hang (function dma-bank none)) +(define-extern dma-sync-crash (function dma-bank none)) +(define-extern dma-send (function dma-bank uint uint none)) +(define-extern dma-send-chain (function dma-bank-source uint none)) +(define-extern dma-send-chain-no-tte (function dma-bank-source uint none)) +(define-extern dma-send-chain-no-flush (function dma-bank-source uint none)) +(define-extern dma-send-to-spr (function uint uint uint symbol none)) +(define-extern dma-send-to-spr-no-flush (function uint uint uint symbol none)) +(define-extern dma-send-from-spr (function uint uint uint symbol none)) +(define-extern dma-send-from-spr-no-flush (function uint uint uint symbol none)) +(define-extern dma-initialize (function none)) +(define-extern clear-vu0-mem (function none)) +(define-extern clear-vu1-mem (function none)) +(define-extern dump-vu1-mem (function none)) +(define-extern dump-vu1-range (function uint uint symbol)) +(define-extern reset-vif1-path (function none)) +(define-extern ultimate-memcpy (function pointer pointer uint none)) +(define-extern symlink2 (function none)) +(define-extern symlink3 (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; dma-buffer ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype dma-packet (structure) - ((dma uint64 :offset-assert 0) ;; dma-tag + "The header for a DMA transfer, containing an DMA tag, and VIF tags." + ((dma dma-tag :offset-assert 0) (vif0 vif-tag :offset-assert 8) ;; guessed by decompiler (vif1 vif-tag :offset-assert 12) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + (quad uint128 :offset-assert 0 :overlay-at dma) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype dma-packet-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data dma-packet :dynamic :offset-assert 16) ;; guessed by decompiler + "Unused dma array. Unclear how it should be used." + ((data dma-packet :dynamic :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype dma-gif (structure) + "Believed unused GIF header type." ((gif uint64 2 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + (gif0 uint64 :overlay-at (-> gif 0) :score 1) + (gif1 uint64 :overlay-at (-> gif 1) :score 1) + (quad uint128 :offset-assert 0 :overlay-at gif) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype dma-gif-packet (structure) + "The header for a DMA transfer that goes directly to GIF, containing DMA, VIF, GIF tags." ((dma-vif dma-packet :inline :offset-assert 0) (gif uint64 2 :offset-assert 16) ;; guessed by decompiler - (quad uint128 2 :offset-assert 0) ;; guessed by decompiler + (gif0 uint64 :offset 16 :score -1) + (gif1 uint64 :offset 24 :score -1) + (quad uint128 2 :offset-assert 0 :overlay-at dma-vif) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype dma-buffer (basic) + "A buffer for DMA data." ((allocated-length int32 :offset-assert 4) (base pointer :offset-assert 8) ;; guessed by decompiler (end pointer :offset-assert 12) ;; guessed by decompiler (real-buffer-end int32 :offset-assert 16) - (data uint64 1 :offset-assert 32) ;; guessed by decompiler + (data-buffer uint8 :dynamic :offset 16) ;; added + (data uint64 1 :offset 32) ;; guessed by decompiler ) + (:methods + (new "Allocate a DMA buffer to hold the given size" (symbol type int) _type_) ;; 0 + ) :method-count-assert 9 :size-assert #x28 :flag-assert #x900000028 + (:methods + (new (symbol type int) _type_) ;; 0 + ) ) -|# -;; (define-extern dma-buffer-inplace-new function) ;; (function dma-buffer int dma-buffer) -;; (define-extern dma-buffer-length function) ;; (function dma-buffer int) -;; (define-extern dma-buffer-free function) ;; (function dma-buffer int) -;; (define-extern dma-buffer-add-vu-function function) ;; (function dma-buffer vu-function int symbol) -;; (define-extern dma-buffer-send function) ;; (function dma-bank dma-buffer none) -;; (define-extern dma-buffer-send-chain function) ;; (function dma-bank-source dma-buffer none) +(define-extern dma-buffer-inplace-new (function dma-buffer int dma-buffer)) +(define-extern dma-buffer-length (function dma-buffer int)) +(define-extern dma-buffer-free (function dma-buffer int)) +(define-extern dma-buffer-add-vu-function (function dma-buffer vu-function int symbol)) +(define-extern dma-buffer-send (function dma-bank dma-buffer none)) +(define-extern dma-buffer-send-chain (function dma-bank-source dma-buffer none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; dma-bucket ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern dma-buffer-add-buckets function) ;; (function dma-buffer int (inline-array dma-bucket)) -;; (define-extern dma-buffer-patch-buckets function) ;; (function dma-bucket int dma-bucket) -;; (define-extern dma-bucket-insert-tag function) ;; (function (inline-array dma-bucket) bucket-id pointer (pointer dma-tag) pointer) +(define-extern dma-buffer-add-buckets (function dma-buffer int (inline-array dma-bucket))) +(define-extern dma-buffer-patch-buckets (function dma-bucket int dma-bucket)) +(define-extern dma-bucket-insert-tag (function (inline-array dma-bucket) bucket-id pointer (pointer dma-tag) pointer)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; dma-disasm ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype vif-disasm-element (structure) ((mask uint32 :offset-assert 0) (tag vif-cmd-32 :offset-assert 4) ;; guessed by decompiler @@ -3428,20 +4800,23 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -;; (define-extern *vif-disasm-table* array) ;; (array vif-disasm-element) -;; (define-extern disasm-vif-details function) ;; (function symbol (pointer uint8) vif-cmd int symbol) -;; (define-extern disasm-vif-tag function) ;; (function (pointer vif-tag) int symbol symbol int) -;; (define-extern disasm-dma-tag function) ;; (function dma-tag symbol none) -;; (define-extern *dma-disasm* object) ;; symbol -;; (define-extern disasm-dma-list function) ;; (function dma-packet symbol symbol symbol int symbol) +(define-extern *vif-disasm-table* (array vif-disasm-element)) +(define-extern disasm-vif-details "Disassemble the data stored in a vif unpack." (function symbol (pointer uint8) vif-cmd int symbol)) +(define-extern disasm-vif-tag "Disassemble vif tag, and possibly the associated data." (function (pointer vif-tag) int symbol symbol int)) +(define-extern disasm-dma-tag "Disassemble just the 64-byte dma tag" (function dma-tag symbol none)) +(define-extern *dma-disasm* symbol) +(define-extern disasm-dma-list "Print out an entire DMA list. + If mode is #t, print vif tags too. If mode is 'details, also print data unpacked by vif-tags. + If verbose is #t, print out the addresses of each tag, and total size statistics. + If expected size is negative, it is ignored. Otherwise, only disassemble this much dma data." + (function dma-packet symbol symbol symbol int symbol)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; view-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; TODO - fill out these basics, they are pretty obvious what they are... (deftype view (basic) ((index int8 :offset-assert 4) (control-scheme uint8 :offset-assert 5) @@ -3454,14 +4829,13 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -;; (define-extern *view-count* object) -;; (define-extern *view-assert* object) -;; (define-extern *views* array) -;; (define-extern *view-context-stack* array) -;; (define-extern *view-context-stack-ptr* object) -;; (define-extern *view-default* object) +(define-extern *view-count* int) +(define-extern *view-assert* symbol) +(define-extern *views* "Length of 2, initialized empty" (array view)) +(define-extern *view-context-stack* (array int32)) +(define-extern *view-context-stack-ptr* (pointer int32)) +(define-extern *view-default* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; pad ;; @@ -3614,57 +4988,211 @@ ;; gs ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype gs-pmode (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-psm +(defenum gs-psm + :bitfield #f + :type uint8 + (ct32 0) + (ct24 1) + (ct16 2) + (ct16s 10) + (mt8 19) + (mt4 20) + (mt8h 27) + (mt4hl 36) + (mt4hh 44) + (mz32 48) + (mz24 49) + (mz16 50) + (mz16s 58) + ) +;; ---gs:gs-psm -;; (deftype gs-smode2 (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-reg +(defenum gs-reg + :type uint8 + (prim 0) + (rgbaq 1) + (st 2) + (uv 3) + (xyzf2 4) + (xyz2 5) + (tex0-1 6) + (tex0-2 7) + (clamp-1 8) + (clamp-2 9) + (fog 10) + (xyzf3 12) + (xyz3 13) + (tex1-1 20) + (tex1-2 21) + (tex2-1 22) + (tex2-2 23) + (xyoffset-1 24) + (xyoffset-2 25) + (prmodecont 26) + (prmode 27) + (texclut 28) + (scanmsk 34) + (miptbp1-1 52) + (miptbp1-2 53) + (miptbp2-1 54) + (miptbp2-2 55) + (texa 59) + (fogcol 61) + (texflush 63) + (scissor-1 64) + (scissor-2 65) + (alpha-1 66) + (alpha-2 67) + (dimx 68) + (dthe 69) + (colclamp 70) + (test-1 71) + (test-2 72) + (pabe 73) + (fba-1 74) + (fba-2 75) + (frame-1 76) + (frame-2 77) + (zbuf-1 78) + (zbuf-2 79) + (bitbltbuf 80) + (trxpos 81) + (trxreg 82) + (trxdir 83) + (hwreg 84) + (signal 96) + (finish 97) + (label 98) + (hack 127) + ) +;; ---gs:gs-reg -;; (deftype gs-display-fb (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-reg64 +(defenum gs-reg64 + :type uint64 + :copy-entries gs-reg + ) +;; ---gs:gs-reg64 -;; (deftype gs-display (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-reg32 +(defenum gs-reg32 + :type uint32 + :copy-entries gs-reg + ) +;; ---gs:gs-reg32 -;; (deftype gs-bgcolor (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-prim-type +(defenum gs-prim-type + :type uint8 + (point 0) + (line 1) + (line-strip 2) + (tri 3) + (tri-strip 4) + (tri-fan 5) + (sprite 6) + ) +;; ---gs:gs-prim-type -;; (deftype gs-csr (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-pmode (uint64) + ((en1 uint8 :offset 0 :size 1) + (en2 uint8 :offset 1 :size 1) + (crtmd uint8 :offset 2 :size 3) + (mmod uint8 :offset 5 :size 1) + (amod uint8 :offset 6 :size 1) + (slbg uint8 :offset 7 :size 1) + (alp uint8 :offset 8 :size 8) + ) + :flag-assert #x900000008 + ) + +(deftype gs-smode2 (uint64) + ((int uint8 :offset 0 :size 1) + (ffmd uint8 :offset 1 :size 1) + (dpms uint8 :offset 2 :size 2) + ) + :flag-assert #x900000008 + ) + +(deftype gs-display-fb (uint64) + ((fbp uint16 :offset 0 :size 9) + (fbw uint8 :offset 9 :size 6) + (psm gs-psm :offset 15 :size 5) + (dbx uint16 :offset 32 :size 11) + (dby uint16 :offset 43 :size 11) + ) + :flag-assert #x900000008 + ) + +(deftype gs-display (uint64) + "the GS's DISPLAY registers make settings for the display position on the screen regarding + information on Rectangular Area Read Output Circuit n for the PCRTC. + write-only" + ((dx uint16 :offset 0 :size 12) + (dy uint16 :offset 12 :size 11) + (magh uint8 :offset 23 :size 4) + (magv uint8 :offset 27 :size 2) + (dw uint16 :offset 32 :size 12) + (dh uint16 :offset 44 :size 11) + ) + :flag-assert #x900000008 + ) + +(deftype gs-bgcolor (uint64) + "The GS's BGCOLOR register sets the background color of the PCRTC with RGB value. + write-only" + ((r uint8 :offset 0) + (g uint8 :offset 8) + (b uint8 :offset 16) + ) + :flag-assert #x900000008 + ) + +(deftype gs-csr (uint64) + "The GS's CSR register sets and obtains various GS statuses. + read-write. The fields have different effects depending on whether they're being read from + or written to. + + Bits 5 and 6 (0x20 and 0x40) should be zero." + ((signal uint8 :offset 0 :size 1) + (finish uint8 :offset 1 :size 1) + (hsint uint8 :offset 2 :size 1) + (vsint uint8 :offset 3 :size 1) + (edwint uint8 :offset 4 :size 1) + (flush uint8 :offset 8 :size 1) + (reset uint8 :offset 9 :size 1) + (nfield uint8 :offset 12 :size 1) + (field uint8 :offset 13 :size 1) + (fifo uint8 :offset 14 :size 2) + (rev uint8 :offset 16 :size 8) + (id uint8 :offset 24 :size 8) + ) + :flag-assert #x900000008 + ) -#| (deftype gs-bank (structure) - ((pmode uint64 :offset-assert 0) ;; gs-pmode - (smode2 uint64 :offset-assert 32) ;; gs-smode2 - (dspfb1 uint64 :offset-assert 112) ;; gs-display-fb - (display1 uint64 :offset-assert 128) ;; gs-display - (dspfb2 uint64 :offset-assert 144) ;; gs-display-fb - (display2 uint64 :offset-assert 160) ;; gs-display - (extbuf uint64 :offset-assert 176) - (extdata uint64 :offset-assert 192) - (extwrite uint64 :offset-assert 208) - (bgcolor uint64 :offset-assert 224) ;; gs-bgcolor - (csr uint64 :offset-assert 4096) ;; gs-csr - (imr uint64 :offset-assert 4112) - (busdir uint64 :offset-assert 4160) + "Memory layout of the GS's privileged registers (mapped to EE memory). + It is missing the SIGLBLID/LABELID register at 4224 (useless anyway?)" + ((pmode gs-pmode :offset-assert 0) + (smode2 gs-smode2 :offset 32) + (dspfb1 gs-display-fb :offset 112) + (display1 gs-display :offset 128) + (dspfb2 gs-display-fb :offset 144) + (display2 gs-display :offset 160) + (extbuf uint64 :offset 176) + (extdata uint64 :offset 192) + (extwrite uint64 :offset 208) + (bgcolor gs-bgcolor :offset 224) + (csr gs-csr :offset 4096) + (imr uint64 :offset 4112) + (busdir uint64 :offset 4160) ) :method-count-assert 9 :size-assert #x1048 :flag-assert #x900001048 ) -|# ;; (deftype gs-frame (uint64) ;; () @@ -3701,15 +5229,57 @@ ;; :flag-assert #x900000008 ;; ) -;; (deftype gs-test (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-atest +(defenum gs-atest + :type uint8 + (never 0) + (always 1) + (less 2) + (less-equal 3) + (equal 4) + (greater-equal 5) + (greater 6) + (not-equal 7) + ) +;; ---gs:gs-atest -;; (deftype gs-prim (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-ztest +(defenum gs-ztest + :type uint8 + (never 0) + (always 1) + (greater-equal 2) + (greater 3) + ) +;; ---gs:gs-ztest + +(deftype gs-test (uint64) + "The GS's TEST register performs settings related to the pixel test." + ((ate uint8 :offset 0 :size 1) ;; alpha test enable + (atst gs-atest :offset 1 :size 3) ;; alpha test method + (aref uint8 :offset 4 :size 8) ;; alpha val reference + (afail uint8 :offset 12 :size 2) ;; processing method on alpha test fail + (date uint8 :offset 14 :size 1) ;; dest alpha test enable + (datm uint8 :offset 15 :size 1) ;; dest alpha test mode + (zte uint8 :offset 16 :size 1) ;; depth test enable + (ztst gs-ztest :offset 17 :size 2) ;; depth test method + ) + :flag-assert #x900000008 + ) + +(deftype gs-prim (uint64) + ((prim gs-prim-type :offset 0 :size 3) + (iip uint8 :offset 3 :size 1) + (tme uint8 :offset 4 :size 1) + (fge uint8 :offset 5 :size 1) + (abe uint8 :offset 6 :size 1) + (aa1 uint8 :offset 7 :size 1) + (fst uint8 :offset 8 :size 1) + (ctxt uint8 :offset 9 :size 1) + (fix uint8 :offset 10 :size 1) + ) + :flag-assert #x900000008 + ) ;; (deftype gs-rgbaq (uint64) ;; () @@ -3736,350 +5306,508 @@ ;; :flag-assert #x900000008 ;; ) -#| (deftype gs-adcmd (structure) - ((word uint32 4 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) - (data uint64 :offset-assert 0) - (cmds uint64 :offset-assert 8) ;; gs-reg64 - (cmd uint8 :offset-assert 8) - (x uint32 :offset-assert 0) - (y uint32 :offset-assert 4) - (z uint32 :offset-assert 8) - (w uint32 :offset-assert 12) + ((word uint32 4 :offset-assert 0 :score -10) + (quad uint128 :offset 0 :score -10) + (data uint64 :offset 0 :score -10) + (cmds gs-reg64 :offset 8 :score 10) + (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 gs-trxpos (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-trxpos (uint64) + "The GS's TRXPOS register specifies the position and + scanning direction of the rectangular area + in each buffer where buffer transmission is performed." + ((ssax uint16 :offset 0 :size 11) + (ssay uint16 :offset 16 :size 11) + (dsax uint16 :offset 32 :size 11) + (dsay uint16 :offset 48 :size 11) + (dir uint8 :offset 59 :size 2) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-trxreg (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-trxreg (uint64) + "The GS's TRXREG register specifies the size of the rectangular area, where the transmission + between buffers is implemented, in units of pixels. + The pixel mode must be the one set by the BITBLTBUF register." + ((rrw uint16 :offset 0 :size 12) + (rrh uint16 :offset 32 :size 12) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-trxdir (uint64) -;; () -;; :flag-assert #x900000008 -;; ) -;; (deftype gs-bitbltbuf (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-trxdir (uint64) + "The GS's TRXDIR register specifies the transmission direction in the transmission between + buffers, and activates transmission. + Appropriate settings must be made by the BITBLTBUF/TRXPOS/TRXREG before activating + the transmission." + ((xdir uint8 :offset 0 :size 2) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-tex0 (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-bitbltbuf (uint64) + "The GS's BITBLTBUF register stores buffer-related settings for transmission source and + destination during transmission between buffers." + ((sbp uint16 :offset 0 :size 14) + (sbw uint8 :offset 16 :size 6) + (spsm uint8 :offset 24 :size 6) + (dbp uint16 :offset 32 :size 14) + (dbw uint8 :offset 48 :size 6) + (dpsm gs-psm :offset 56 :size 6) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-tex1 (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-tex0 (uint64) + "The GS's TEX0 registers set various kinds of information regarding the textures to be used." + ((tbp0 uint16 :offset 0 :size 14) + (tbw uint8 :offset 14 :size 6) + (psm uint8 :offset 20 :size 6) + (tw uint8 :offset 26 :size 4) + (th uint8 :offset 30 :size 4) + (tcc uint8 :offset 34 :size 1) + (tfx uint8 :offset 35 :size 2) + (cbp uint16 :offset 37 :size 14) + (cpsm uint8 :offset 51 :size 4) + (csm uint8 :offset 55 :size 1) + (csa uint8 :offset 56 :size 5) + (cld uint8 :offset 61 :size 3) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-texa (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-tex1 (uint64) + "The GS's TEX1 registers set information on the sampling method of the textures." + ((lcm uint8 :offset 0 :size 1) + (mxl uint8 :offset 2 :size 3) + (mmag uint8 :offset 5 :size 1) + (mmin uint8 :offset 6 :size 3) + (mtba uint8 :offset 9 :size 1) + (l uint8 :offset 19 :size 2) + (k int16 :offset 32 :size 12) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-texclut (uint64) -;; () -;; :flag-assert #x900000008 -;; ) -;; (deftype gs-miptbp (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-texa (uint64) + "The GS's TEXA register sets the Alpha value to be referred to when the Alpha value of the + texture is not an 8-bit value." + ((ta0 uint8 :offset 0 :size 8) + (aem uint8 :offset 15 :size 1) + (ta1 uint8 :offset 32 :size 8) + ) + :flag-assert #x900000008 + ) + +(deftype gs-texclut (uint64) + "The GS's TEXCLUT register specifies the CLUT position in the buffer when the CLUT storage mode + is CSM=1 (CSM2 mode)." + ((cbw uint8 :offset 0 :size 6) + (cou uint8 :offset 6 :size 6) + (cov uint16 :offset 12 :size 10) + ) + :flag-assert #x900000008 + ) + +(deftype gs-miptbp (uint64) + "the GS's MIPTBP registers set the buffer pointer and buffer width of textures when performing + MIPMAP. MIPTBP1 sets levels 1 to 3, MIPTBP2 sets levels 4 to 6." + ((tbp1 uint16 :offset 0 :size 14) + (tbw1 uint8 :offset 14 :size 6) + (tbp2 uint16 :offset 20 :size 14) + (tbw2 uint8 :offset 34 :size 6) + (tbp3 uint16 :offset 40 :size 14) + (tbw3 uint8 :offset 54 :size 6) + ) + :flag-assert #x900000008 + ) -#| (deftype gs-alpha (uint64) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((a uint8 :offset 0 :size 2) + (b uint8 :offset 2 :size 2) + (c uint8 :offset 4 :size 2) + (d uint8 :offset 6 :size 2) + (fix uint8 :offset 32 :size 8) ) - :method-count-assert 9 - :size-assert #x8 - :flag-assert #x900000008 + :flag-assert #x900000008 ) -|# -;; (deftype gs-clamp (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-tex-wrap-mode +(defenum gs-tex-wrap-mode + :type uint8 + (repeat 0) + (clamp 1) + (region-clamp 2) + (region-repeat 3) + ) +;; ---gs:gs-tex-wrap-mode + +(deftype gs-clamp (uint64) + ((wms gs-tex-wrap-mode :offset 0 :size 2) + (wmt gs-tex-wrap-mode :offset 2 :size 2) + (minu uint16 :offset 4 :size 10) + (maxu uint16 :offset 14 :size 10) + (minv uint16 :offset 24 :size 10) + (maxv uint16 :offset 34 :size 10) + ) + :flag-assert #x900000008 + ) -#| (deftype gs-fog (uint64) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((f uint8 :offset 56 :size 8) ) - :method-count-assert 9 - :size-assert #x8 - :flag-assert #x900000008 + :flag-assert #x900000008 ) -|# -#| (deftype gs-fogcol (uint64) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((fcr uint8 :offset 0 :size 8) + (fcg uint8 :offset 8 :size 8) + (fcb uint8 :offset 16 :size 8) ) - :method-count-assert 9 - :size-assert #x8 - :flag-assert #x900000008 + :flag-assert #x900000008 ) -|# -;; (deftype gif-ctrl (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-ctrl (uint32) + ((rst uint8 :offset 0 :size 1) + (pse uint8 :offset 3 :size 1) + ) + :flag-assert #x900000004 + ) -;; (deftype gif-mode (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-mode (uint32) + ((m3r uint8 :offset 0 :size 1) + (imt uint8 :offset 2 :size 1) + ) + :flag-assert #x900000004 + ) -;; (deftype gif-stat (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-stat (uint32) + ((m3r uint8 :offset 0 :size 1) + (m3p uint8 :offset 1 :size 1) + (imt uint8 :offset 2 :size 1) + (pse uint8 :offset 3 :size 1) + (ip3 uint8 :offset 5 :size 1) + (p3q uint8 :offset 6 :size 1) + (p2q uint8 :offset 7 :size 1) + (p1q uint8 :offset 8 :size 1) + (oph uint8 :offset 9 :size 1) + (apath uint8 :offset 10 :size 2) + (dir uint8 :offset 12 :size 1) + (fqc uint8 :offset 24 :size 5) + ) + :flag-assert #x900000004 + ) -;; (deftype gif-cnt (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-cnt (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (regcnt uint8 :offset 16 :size 4) + (vuaddr uint16 :offset 20 :size 10) + ) + :flag-assert #x900000004 + ) -;; (deftype gif-p3cnt (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-p3cnt (uint32) + ((p3cnt uint16 :offset 0 :size 15) + ) + :flag-assert #x900000004 + ) -;; (deftype gif-p3tag (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-p3tag (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + :flag-assert #x900000004 + ) -#| (deftype gif-bank (structure) - ((ctrl gif-ctrl :offset-assert 0) ;; guessed by decompiler - (mode gif-mode :offset-assert 16) ;; guessed by decompiler - (stat gif-stat :offset-assert 32) ;; guessed by decompiler - (tag0 uint32 :offset-assert 64) - (tag1 uint32 :offset-assert 80) - (tag2 uint32 :offset-assert 96) - (tag3 uint32 :offset-assert 112) - (cnt gif-cnt :offset-assert 128) ;; guessed by decompiler - (p3cnt gif-p3cnt :offset-assert 144) ;; guessed by decompiler - (p3tag gif-p3tag :offset-assert 160) ;; guessed by decompiler + ((ctrl gif-ctrl :offset 0) + (mode gif-mode :offset 16) + (stat gif-stat :offset 32) + (tag0 uint32 :offset 64) + (tag1 uint32 :offset 80) + (tag2 uint32 :offset 96) + (tag3 uint32 :offset 112) + (cnt gif-cnt :offset 128) + (p3cnt gif-p3cnt :offset 144) + (p3tag gif-p3tag :offset 160) ) :method-count-assert 9 :size-assert #xa4 :flag-assert #x9000000a4 ) -|# -;; (deftype gif-tag-prim (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +;; +++gs:gif-flag +(defenum gif-flag + :type uint8 + (packed 0) + (reg-list 1) + (image 2) + (disable 3) + ) +;; ---gs:gif-flag -;; (deftype gif-tag-count (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-tag-prim (uint32) + ((id uint16 :offset 0 :size 14) + (pre uint8 :offset 14 :size 1) + (prim gs-prim :offset 15 :size 11) + (flg gif-flag :offset 26 :size 2) + (nreg uint8 :offset 28 :size 4) + ) + :flag-assert #x900000004 + ) -;; (deftype gif-tag64 (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gif-tag-count (uint32) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + :flag-assert #x900000004 + ) + +;; +++gs:gif-reg-id +(defenum gif-reg-id + :type uint8 + (prim 0) + (rgbaq 1) + (st 2) + (uv 3) + (xyzf2 4) + (xyz2 5) + (tex0-1 6) + (tex0-2 7) + (clamp-1 8) + (clamp-2 9) + (fog 10) + (xyzf3 12) + (xyz3 13) + (a+d 14) + (nop 15) + ) +;; ---gs:gif-reg-id + +(deftype gif-tag64 (uint64) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim gs-prim :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + ) + :flag-assert #x900000008 + ) -#| (deftype gif-tag (uint128) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim uint16 :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + (regs0 gif-reg-id :offset 64 :size 4) + (regs1 gif-reg-id :offset 68 :size 4) + (regs2 gif-reg-id :offset 72 :size 4) + (regs3 gif-reg-id :offset 76 :size 4) + (regs4 gif-reg-id :offset 80 :size 4) + (regs5 gif-reg-id :offset 84 :size 4) + (regs6 gif-reg-id :offset 88 :size 4) + (regs7 gif-reg-id :offset 92 :size 4) + (regs8 gif-reg-id :offset 96 :size 4) + (regs9 gif-reg-id :offset 100 :size 4) + (regs10 gif-reg-id :offset 104 :size 4) + (regs11 gif-reg-id :offset 108 :size 4) + (regs12 gif-reg-id :offset 112 :size 4) + (regs13 gif-reg-id :offset 116 :size 4) + (regs14 gif-reg-id :offset 120 :size 4) + (regs15 gif-reg-id :offset 124 :size 4) ) - :method-count-assert 9 - :size-assert #x10 - :flag-assert #x900000010 + :flag-assert #x900000010 ) -|# -#| +;; +++gs:gif-tag-regs +(deftype gif-tag-regs (uint64) + ((regs0 gif-reg-id :offset 0 :size 4) + (regs1 gif-reg-id :offset 4 :size 4) + (regs2 gif-reg-id :offset 8 :size 4) + (regs3 gif-reg-id :offset 12 :size 4) + (regs4 gif-reg-id :offset 16 :size 4) + (regs5 gif-reg-id :offset 20 :size 4) + (regs6 gif-reg-id :offset 24 :size 4) + (regs7 gif-reg-id :offset 28 :size 4) + (regs8 gif-reg-id :offset 32 :size 4) + (regs9 gif-reg-id :offset 36 :size 4) + (regs10 gif-reg-id :offset 40 :size 4) + (regs11 gif-reg-id :offset 44 :size 4) + (regs12 gif-reg-id :offset 48 :size 4) + (regs13 gif-reg-id :offset 52 :size 4) + (regs14 gif-reg-id :offset 56 :size 4) + (regs15 gif-reg-id :offset 60 :size 4) + ) + ) +;; ---gs:gif-tag-regs + +;; +++gs:gif-tag-regs-32 +(deftype gif-tag-regs-32 (uint32) + ((regs0 gif-reg-id :offset 0 :size 4) + (regs1 gif-reg-id :offset 4 :size 4) + (regs2 gif-reg-id :offset 8 :size 4) + (regs3 gif-reg-id :offset 12 :size 4) + (regs4 gif-reg-id :offset 16 :size 4) + (regs5 gif-reg-id :offset 20 :size 4) + (regs6 gif-reg-id :offset 24 :size 4) + (regs7 gif-reg-id :offset 28 :size 4) + ) + ) +;; ---gs:gif-tag-regs-32 + (deftype gs-gif-tag (structure) - ((qword qword :inline :offset-assert 0) ;; uint128 - (dword uint64 2 :offset-assert 0) ;; guessed by decompiler - (word uint32 4 :offset-assert 0) ;; guessed by decompiler - (tag uint64 :offset-assert 0) ;; gif-tag64 - (regs uint64 :offset-assert 8) ;; gif-tag-regs + ((qword uint128 :offset-assert 0 :score -1) ;; is "qword" and inline? in game + + (tag gif-tag64 :offset 0) + (regs gif-tag-regs :offset 8) + + (dword uint64 2 :offset 0) + (word uint32 4 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gif-packet (basic) + "Unused type for building a dynamically sized gif packet." ((reg-count int32 :offset-assert 4) - (gif-tag0 uint128 :offset-assert 16) - (args uint64 1 :offset-assert 32) ;; guessed by decompiler + (gif-tag gs-gif-tag :inline :offset-assert 16) ;; added + (gif-tag0 uint128 :offset 16) + (args uint64 1 :offset-assert 32) ) + (:methods + (new (symbol type int) _type_) ;; 0 + ) :method-count-assert 9 :size-assert #x28 :flag-assert #x900000028 ) -|# -#| (deftype draw-context (basic) - ((orgx int32 :offset-assert 4) - (orgy int32 :offset-assert 8) - (orgz int32 :offset-assert 12) - (width int32 :offset-assert 16) - (height int32 :offset-assert 20) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((orgx int32 :offset-assert 4) + (orgy int32 :offset-assert 8) + (orgz int32 :offset-assert 12) + (width int32 :offset-assert 16) + (height int32 :offset-assert 20) + (color rgba 4 :offset-assert 24) ) + (:methods + (new (symbol type int int int int rgba) _type_) ;; 0 + ) :method-count-assert 9 :size-assert #x28 :flag-assert #x900000028 + ;; Failed to read some fields. ) -|# - -#| (deftype gs-packed-rgba (vector4w) - ((r int32 :offset-assert 0) - (g int32 :offset-assert 4) - (b int32 :offset-assert 8) - (a int32 :offset-assert 12) + ((r int32 :offset 0) + (g int32 :offset 4) + (b int32 :offset 8) + (a int32 :offset 12) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gs-packed-xyzw (vector) - ((ix int32 :offset-assert 0) - (iy int32 :offset-assert 4) - (iz int32 :offset-assert 8) - (iw int32 :offset-assert 12) + ((ix int32 :offset 0 :score 10) + (iy int32 :offset 4 :score 10) + (iz int32 :offset 8 :score 10) + (iw int32 :offset 12 :score 10) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gs-packed-stq (vector) - ((tex-s float :offset-assert 0) - (tex-t float :offset-assert 4) - (tex-q float :offset-assert 8) + ((tex-s float :offset 0) + (tex-t float :offset 4) + (tex-q float :offset 8) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gs-packed-uv (vector) - ((u int16 :offset-assert 0) - (v int16 :offset-assert 4) + ((u int16 :offset 0) + (v int16 :offset 4) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gs-packed-gt (structure) - ((stq gs-packed-stq :inline :offset-assert 0) - (rgba gs-packed-rgba :inline :offset-assert 16) - (xyzw gs-packed-xyzw :inline :offset-assert 32) + ((stq gs-packed-stq :inline :offset 0) + (rgba gs-packed-rgba :inline :offset 16) + (xyzw gs-packed-xyzw :inline :offset 32) ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype gs-packed-gt4 (structure) - ((data gs-packed-gt 4 :offset-assert 0) ;; guessed by decompiler + ((data gs-packed-gt 4 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #xc0 :flag-assert #x9000000c0 ) -|# -;; (define-extern psm-size function) ;; (function gs-psm int) -;; (define-extern psm-page-height function) ;; (function gs-psm int) -;; (define-extern psm->string function) ;; (function gs-psm string) -;; (define-extern *fog-color* object) ;; rgba -;; (define-extern open-gif-packet function) ;; (function gif-packet gif-packet) -;; (define-extern add-reg-gif-packet function) ;; (function gif-packet int int none) -;; (define-extern close-gif-packet function) ;; (function gif-packet int gif-packet) -;; (define-extern draw-context-set-xy function) ;; (function draw-context int int none) +(define-extern psm-size (function gs-psm int)) +(define-extern psm-page-height (function gs-psm int)) +(define-extern psm->string (function gs-psm string)) +(define-extern *fog-color* rgba) +(define-extern open-gif-packet (function gif-packet gif-packet)) +(define-extern add-reg-gif-packet (function gif-packet int int none)) +(define-extern close-gif-packet (function gif-packet int gif-packet)) +(define-extern draw-context-set-xy (function draw-context int int none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; display-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype display-frame (basic) - ((buffer dma-buffer 11 :offset-assert 4) ;; guessed by decompiler - (calc-buf dma-buffer :offset-assert 8) ;; guessed by decompiler - (vu1-buf dma-buffer :offset-assert 8) ;; guessed by decompiler - (debug-buf dma-buffer :offset-assert 36) ;; guessed by decompiler - (global-buf dma-buffer :offset-assert 40) ;; guessed by decompiler - (bucket-group dma-bucket :offset-assert 44) ;; (inline-array dma-bucket) - (profile-array profile-array :inline :offset-assert 48) - (start-time uint64 :offset-assert 56) - (run-time uint64 :offset-assert 64) + ((buffer dma-buffer 11 :offset-assert 4) ;; guessed by decompiler + (calc-buf dma-buffer :offset 8) ;; guessed by decompiler + (vu1-buf dma-buffer :offset 8) ;; guessed by decompiler + (debug-buf dma-buffer :offset 36) ;; guessed by decompiler + (global-buf dma-buffer :offset 40) ;; guessed by decompiler + (bucket-group (inline-array dma-bucket) :offset 44) ;; (inline-array dma-bucket) + (profile-array profile-array :inline :offset 48) + (start-time uint64 :offset 56) ;; int64 + (run-time uint64 :offset 64) ;; int64 ) :method-count-assert 9 :size-assert #x48 :flag-assert #x900000048 + (:methods + (new (symbol type) _type_) ;; 0 + ) ) -|# -#| (deftype display (basic) ((on-screen int32 :offset-assert 4) (last-screen int32 :offset-assert 8) @@ -4087,28 +5815,28 @@ (bgcolor uint64 :offset-assert 24) ;; gs-bgcolor (pmode uint64 :offset-assert 32) ;; gs-pmode (clock clock 22 :offset-assert 40) ;; guessed by decompiler - (session-clock clock :offset-assert 40) ;; guessed by decompiler - (game-clock clock :offset-assert 44) ;; guessed by decompiler - (base-clock clock :offset-assert 48) ;; guessed by decompiler - (real-clock clock :offset-assert 52) ;; guessed by decompiler - (frame-clock clock :offset-assert 56) ;; guessed by decompiler - (real-frame-clock clock :offset-assert 60) ;; guessed by decompiler - (target-clock clock :offset-assert 64) ;; guessed by decompiler - (entity-clock clock :offset-assert 68) ;; guessed by decompiler - (part-clock clock :offset-assert 72) ;; guessed by decompiler - (bg-clock clock :offset-assert 76) ;; guessed by decompiler - (camera-clock clock :offset-assert 80) ;; guessed by decompiler - (total-game-clock clock :offset-assert 84) ;; guessed by decompiler - (user0-clock clock :offset-assert 88) ;; guessed by decompiler - (user1-clock clock :offset-assert 92) ;; guessed by decompiler - (user2-clock clock :offset-assert 96) ;; guessed by decompiler - (user3-clock clock :offset-assert 100) ;; guessed by decompiler - (user4-clock clock :offset-assert 104) ;; guessed by decompiler - (user5-clock clock :offset-assert 108) ;; guessed by decompiler - (user6-clock clock :offset-assert 112) ;; guessed by decompiler - (user7-clock clock :offset-assert 116) ;; guessed by decompiler - (user8-clock clock :offset-assert 120) ;; guessed by decompiler - (user9-clock clock :offset-assert 124) ;; guessed by decompiler + (session-clock clock :offset 40) ;; guessed by decompiler + (game-clock clock :offset 44) ;; guessed by decompiler + (base-clock clock :offset 48) ;; guessed by decompiler + (real-clock clock :offset 52) ;; guessed by decompiler + (frame-clock clock :offset 56) ;; guessed by decompiler + (real-frame-clock clock :offset 60) ;; guessed by decompiler + (target-clock clock :offset 64) ;; guessed by decompiler + (entity-clock clock :offset 68) ;; guessed by decompiler + (part-clock clock :offset 72) ;; guessed by decompiler + (bg-clock clock :offset 76) ;; guessed by decompiler + (camera-clock clock :offset 80) ;; guessed by decompiler + (total-game-clock clock :offset 84) ;; guessed by decompiler + (user0-clock clock :offset 88) ;; guessed by decompiler + (user1-clock clock :offset 92) ;; guessed by decompiler + (user2-clock clock :offset 96) ;; guessed by decompiler + (user3-clock clock :offset 100) ;; guessed by decompiler + (user4-clock clock :offset 104) ;; guessed by decompiler + (user5-clock clock :offset 108) ;; guessed by decompiler + (user6-clock clock :offset 112) ;; guessed by decompiler + (user7-clock clock :offset 116) ;; guessed by decompiler + (user8-clock clock :offset 120) ;; guessed by decompiler + (user9-clock clock :offset 124) ;; guessed by decompiler (time-factor float :offset-assert 128) (dog-ratio float :offset-assert 132) (vblank-start-time int64 2 :offset-assert 136) ;; guessed by decompiler @@ -4127,263 +5855,568 @@ :size-assert #xd0 :flag-assert #xa000000d0 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type int int int int int) _type_) - (display-method-9 () none) ;; 9 ;; (set-time-ratios (_type_ float) float) + (new (symbol type int int int int int) _type_) ;; 0 + (set-time-ratios (_type_ float) float) ;; 9 ) ) -|# -;; (define-extern *pre-draw-hook* object) ;; (function object none) -;; (define-extern *post-draw-hook* object) ;; (function dma-buffer none) +(define-extern *pre-draw-hook* (function object none)) +(define-extern *post-draw-hook* (function dma-buffer none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; geometry ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern vector-flatten! function) ;; (function vector vector vector vector) -;; (define-extern vector-reflect! function) ;; (function vector vector vector vector) -;; (define-extern vector-reflect-flat! function) ;; (function vector vector vector vector) -;; (define-extern vector-reflect-flat-above! function) ;; (function vector vector vector vector) -;; (define-extern vector-reflect-flat-gravity! function) ;; (function vector vector vector vector vector) -;; (define-extern vector-segment-distance-point! function) ;; (function vector vector vector vector float) -;; (define-extern vector-segment-xz-distance-point! function) ;; (function vector vector vector vector float) -;; (define-extern vector-line-distance function) ;; (function vector vector vector float) -;; (define-extern vector-line-distance-point! function) ;; (function vector vector vector vector float) -;; (define-extern vector-line-xz-distance-point! function) ;; (function vector vector vector vector float) -;; (define-extern vector-segment-overlap function) ;; (function vector vector vector float) -;; (define-extern line-sphere-intersection? function) ;; (function vector vector vector symbol) -;; (define-extern nearest-dist2-between-moving-points function) ;; (function vector vector vector vector float float) -;; (define-extern vector-orient-by-quat! function) ;; (function vector vector quaternion vector) -;; (define-extern vector-inv-orient-by-quat! function) ;; (function vector vector quaternion vector) -;; (define-extern vector-cap-rotation! function) -;; (define-extern vector-interp-angle! function) -;; (define-extern forward-down->inv-matrix function) ;; (function matrix vector vector matrix) -;; (define-extern forward-down-nopitch->inv-matrix function) ;; (function matrix vector vector matrix) -;; (define-extern forward-up->inv-matrix function) ;; (function matrix vector vector matrix) -;; (define-extern forward-up-nopitch->inv-matrix function) ;; (function matrix vector vector matrix) -;; (define-extern forward-up-nopitch->quaternion function) ;; (function quaternion vector vector quaternion) -;; (define-extern forward-up->quaternion function) ;; (function quaternion vector vector quaternion) -;; (define-extern quaternion-from-two-vectors! function) ;; (function quaternion vector vector quaternion) -;; (define-extern quaternion-from-two-vectors-partial! function) ;; (function quaternion vector vector float quaternion) -;; (define-extern quaternion-from-two-vectors-max-angle! function) ;; (function quaternion vector vector float quaternion) -;; (define-extern quaternion-from-two-vectors-max-angle-partial! function) ;; (function quaternion vector vector float float quaternion) -;; (define-extern matrix-from-two-vectors! function) ;; (function matrix vector vector matrix) -;; (define-extern matrix-from-two-vectors-max-angle! function) ;; (function matrix vector vector float matrix) -;; (define-extern matrix-from-two-vectors-smooth! function) ;; (function matrix vector vector float int matrix) -;; (define-extern matrix-from-two-vectors-the-long-way-smooth! function) ;; (function matrix vector vector float int matrix) -;; (define-extern quaternion-from-two-vectors-smooth! function) ;; (function quaternion vector vector float int quaternion) -;; (define-extern matrix-from-two-vectors-max-angle-partial! function) ;; (function matrix vector vector float float matrix) -;; (define-extern matrix-from-two-vectors-partial-linear! function) ;; (function matrix vector vector float matrix) -;; (define-extern matrix-remove-z-rot function) ;; (function matrix vector matrix) -;; (define-extern matrix-rot-diff! function) ;; (function quaternion matrix matrix float) -;; (define-extern quaternion-seek function) ;; (function quaternion quaternion quaternion float float quaternion) -;; (define-extern vector-deg-seek function) ;; (function vector vector vector float vector) -;; (define-extern vector-deg-slerp function) ;; (function vector vector vector float vector) -;; (define-extern vector-vector-deg-slerp! function) ;; (function vector vector vector float vector vector) -;; (define-extern normal-of-plane function) ;; (function vector vector vector vector vector) -;; (define-extern vector-3pt-cross! function) ;; (function vector vector vector vector vector) -;; (define-extern closest-pt-in-triangle function) ;; (function vector vector matrix vector none) -;; (define-extern point-in-triangle-cross function) ;; (function vector vector vector vector vector symbol) -;; (define-extern point-in-plane-<-point+normal! function) ;; (function vector vector vector vector) -;; (define-extern circle-circle-xz-intersect function) ;; (function sphere sphere vector vector int) -;; (define-extern circle-test function) ;; (function none) -;; (define-extern vector-circle-tangent-new function) ;; (function vector vector vector vector none) -;; (define-extern vector-circle-tangent function) ;; (function vector vector vector vector none) -;; (define-extern find-knot-span function) ;; (function int int float (inline-array vector) int) -;; (define-extern calculate-basis-functions-vector! function) ;; (function vector int float (pointer float) vector) -;; (define-extern curve-evaluate! function) ;; (function vector float (inline-array vector) int (pointer float) int vector) -;; (define-extern curve-get-pos! function) ;; (function vector float curve vector) -;; (define-extern curve-length function) ;; (function curve float) -;; (define-extern curve-copy! function) ;; (function curve curve curve) -;; (define-extern curve-closest-point function) ;; (function curve vector float float int float float) -;; (define-extern vector-plane-distance function) ;; (function vector plane vector float) -;; (define-extern intersect-ray-plane function) ;; (function vector vector vector vector float) -;; (define-extern line-line-find-intersection-xz function) ;; (function vector vector vector vector vector float) -;; (define-extern segment-segment-find-intersection-xz function) ;; (function vector vector vector vector float) -;; (define-extern generate-rand-vector-on-sphere function) ;; (function vector vector) -;; (define-extern ellipsoid-get-foci function) +(define-extern vector-flatten! + "Get the projection of src onto a plane with the given normal + The normal should have magnitude 1.0." + (function vector vector vector vector)) +(define-extern vector-reflect! "Reflect a vector off of a plane." (function vector vector vector vector)) +(define-extern vector-reflect-flat! + "This is a weird one. It doesn't care about the value of src dot normal + and it effectively replaces the component of src normal to the plane with + the plane's normal. I think this requires src/normal to both be unit vectors + in order to make sense. + NOTE: src should point from positive halfspace to negative otherwise it + doesn't work." + (function vector vector vector vector)) +(define-extern vector-reflect-flat-above! + "Not really a reflect. Same as flatten." + (function vector vector vector vector)) +(define-extern vector-reflect-flat-gravity! (function vector vector vector vector vector)) +(define-extern vector-segment-distance-point! + "Compute the distance from a point to the closest point on the line segment. + arg0 is the point. arg1/arg2 are the endpoints of the line segment. + arg3 is an optional output closest point." + (function vector vector vector vector float)) +(define-extern vector-segment-xz-distance-point! (function vector vector vector vector float)) +(define-extern vector-line-distance + "Weird function: given a point arg1, and an infinite line connecting arg2 and arg1, compute the distance + from arg0 to that line." + (function vector vector vector float)) +(define-extern vector-line-distance-point! + "Same as above function, but returns the point on arg2/arg1 in arg3 (ignored if #f)" + (function vector vector vector vector float)) +(define-extern vector-line-xz-distance-point! (function vector vector vector vector float)) +(define-extern vector-segment-overlap + "Seems to compute (v1 - v0).dot(v2 - v1), but in a weird way." + (function vector vector vector float)) +(define-extern line-sphere-intersection? + "Does [arg1, arg2] intersect sphere arg0?" + (function vector vector vector symbol)) +(define-extern nearest-dist2-between-moving-points (function vector vector vector vector float float)) +(define-extern vector-orient-by-quat! + "Rotate a vector by a quaternion." + (function vector vector quaternion vector)) +(define-extern vector-orient-by-quat! (function vector vector quaternion vector)) +(define-extern vector-inv-orient-by-quat! (function vector vector quaternion vector)) ;; +(define-extern vector-cap-rotation! (function vector vector vector float vector)) +(define-extern vector-interp-angle! (function vector vector vector float vector)) +(define-extern forward-down->inv-matrix + "Create a matrix representing an inverse transform where arg1 is forward (+z) + and arg2 is down (-y). Will have the pitch of forward." + (function matrix vector vector matrix)) +(define-extern forward-down-nopitch->inv-matrix + "Create a matrix representing an inverse transform where arg1 is forward (+z) + and arg2 is down (-y). Will not use the pitch of forward." + (function matrix vector vector matrix)) +(define-extern forward-up->inv-matrix + "Create a matrix representing an inverse transform where arg1 is forward (+z) + and arg2 is up (+y). Will use the pitch of forward." + (function matrix vector vector matrix)) +(define-extern forward-up-nopitch->inv-matrix + "Create a matrix representing an inverse transform where arg1 is forward (+z) + and arg2 is up (+y). Will not use the pitch of forward." + (function matrix vector vector matrix)) +(define-extern forward-up-nopitch->quaternion + "Create a quaternion representing a transform where arg1 is forward (+z) + and arg2 is up (+y). Will not use the pitch of forward." + (function quaternion vector vector quaternion)) +(define-extern forward-up->quaternion + "Create a quaternion representing a transform where arg1 is forward (+z) + and arg2 is up (+y). Will use the pitch of forward." + (function quaternion vector vector quaternion)) +(define-extern quaternion-from-two-vectors! + "Create a quaternion representing the rotation between two vectors." + (function quaternion vector vector quaternion)) +(define-extern quaternion-from-two-vectors-partial! + "Create a quaternion representing the rotation between two vectors, + doing arg3 fraction of the total rotation." + (function quaternion vector vector float quaternion)) +(define-extern quaternion-from-two-vectors-max-angle! + "Create a quaternion representing the rotation between two vectors, + allowing at most a rotation of arg3 degrees." + (function quaternion vector vector float quaternion)) +(define-extern quaternion-from-two-vectors-max-angle-partial! + "Create a quaternion representing the arg4 fraction of the rotation between two vectors, + allowing at most a rotation of arg3 degrees." + (function quaternion vector vector float float quaternion)) +(define-extern matrix-from-two-vectors! + "Create a rotation matrix representing the rotation between two vectors." + (function matrix vector vector matrix)) +(define-extern matrix-from-two-vectors-max-angle! + "Create a rotation matrix representing the rotation between two vectors, + allowing at most a rotation of arg3 degrees." + (function matrix vector vector float matrix)) +(define-extern matrix-from-two-vectors-smooth! + "This function can help smoothly rotate from a current heading vector to a target one. + It returns a rotation to move arg1 closer to arg2, subject to two different speed limits. + arg3 is a rotations-per-frame rate. This limit takes frame rate into account (when lagging, the rotation is larger) + arg4 is a 'slow down when getting close to the end' limit. + This is used in rotate-toward-orientation, which is much improved from jak 1." + (function matrix vector vector float int matrix)) +(define-extern matrix-from-two-vectors-the-long-way-smooth! + "Same as above, but rotates you away from the target. + Note that the 'near the end' smoothing will apply when you're near the target." + (function matrix vector vector float int matrix)) +(define-extern quaternion-from-two-vectors-smooth! + "Same as above, but returns a quaternion." + (function quaternion vector vector float int quaternion)) +(define-extern matrix-from-two-vectors-max-angle-partial! + "Create a rotation matrix representing the given fraction of the rotation between two heading vectors, + rotating by at most the given angle." + (function matrix vector vector float float matrix)) +(define-extern matrix-from-two-vectors-partial-linear! + "Create a rotation matrix representing doing arg3 fraction of the rotation between two vectors." + (function matrix vector vector float matrix)) +(define-extern matrix-remove-z-rot "Remove the z rotation component of a rotation." (function matrix vector matrix)) +(define-extern matrix-rot-diff! + "Get the difference of rotation between two matrices, expressed as a quaternion." + (function quaternion matrix matrix float)) +(define-extern quaternion-seek + "Strange quaternion rotate toward function. arg3 is ignored. arg4 is the max seek amount." + (function quaternion quaternion quaternion float float quaternion)) +(define-extern vector-deg-seek + "Make one vector closer to another, doing at most a rotation by arg3 degrees." + (function vector vector vector float vector)) +(define-extern vector-deg-slerp + "Slerp for vectors. (imagine that they are the z axis of two frames)" + (function vector vector vector float vector)) +(define-extern vector-vector-deg-slerp! "Unused. No clue what this does." (function vector vector vector float vector vector)) +(define-extern normal-of-plane + "Given three points on a plane, compute the plane's normal." + (function vector vector vector vector vector)) +(define-extern vector-3pt-cross! + "Cross product of 2 - 1 and 3 - 1. (will give a normal to the plane, but not of magnitude 1)" + (function vector vector vector vector vector)) +(define-extern closest-pt-in-triangle + "arg2 is the vertices of the triangle, arg3 is the normal, arg1 is the input point, arg0 is the output." + (function vector vector matrix vector none)) +(define-extern point-in-triangle-cross + "Check if point is in the triangle using cross product check (so you have to get the order of points right)." + (function vector vector vector vector vector symbol)) +(define-extern point-in-plane-<-point+normal! + "Very strange function. Takes a plane, in point-normal form, then returns some other point on that plane. + It will move 1m in two of {x, y, z} directions. The direction not moved in is the one which is closest to point-in-triangle-cross + in the same direction of the normal (this prevent moving huge distances for nearly vertical planes for example)." + (function vector vector vector vector)) +(define-extern circle-circle-xz-intersect + "This function is unused and really complicated, so not implementing it for now." + (function sphere sphere vector vector int)) +(define-extern circle-test "Test the circle-circle-xz-intersect function." (function none)) +(define-extern vector-circle-tangent-new "Unused." (function vector vector vector vector none)) +(define-extern vector-circle-tangent "Also unused." (function vector vector vector vector none)) +(define-extern find-knot-span + "Binary serach over knots to find which contains the value float in (arg0 arg1). Unused." + (function int int float (inline-array vector) int)) +(define-extern calculate-basis-functions-vector! + "Calculate polynomial basis for a given control point." + (function vector int float (pointer float) vector)) +(define-extern curve-evaluate! + "Evaluate a curve. + arg0 is the output + arg1 is the input. + arg2 is control vertices. + arg3 is the number of control vertices. + arg4 is the knot points. + arg5 is the number of knots." + (function vector float (inline-array vector) int (pointer float) int vector)) +(define-extern curve-get-pos! + "Get the position on the curve at the given input." + (function vector float curve vector)) +(define-extern curve-length + "Compute the approximate curve length as the sum of distances between knots." + (function curve float)) +(define-extern curve-copy! "Shallow copy a curve." (function curve curve curve)) +(define-extern curve-closest-point + "Get the input value for the point on the curve. Approximate! And is O(n_knots)." + (function curve vector float float int float float)) +(define-extern vector-plane-distance "Unused." (function vector plane vector float)) +(define-extern intersect-ray-plane + "arg1 is ray direction, arg3 is plane normal, others don't really make sense to me." + (function vector vector vector vector float)) +(define-extern line-line-find-intersection-xz (function vector vector vector vector vector float)) +(define-extern segment-segment-find-intersection-xz (function vector vector vector vector float)) +(define-extern generate-rand-vector-on-sphere (function vector vector)) +(define-extern ellipsoid-get-foci (function ellipsoid vector vector float)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; timer ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern timer-count function) ;; (function timer-bank uint) -;; (define-extern disable-irq function) ;; (function none) -;; (define-extern enable-irq function) ;; (function none) -;; (define-extern stopwatch-init function) ;; (function stopwatch int) -;; (define-extern stopwatch-reset function) ;; (function stopwatch int) -;; (define-extern stopwatch-start function) ;; (function stopwatch int) -;; (define-extern stopwatch-stop function) ;; (function stopwatch none) -;; (define-extern stopwatch-begin function) ;; (function stopwatch int) -;; (define-extern stopwatch-end function) ;; (function stopwatch none) -;; (define-extern stopwatch-elapsed-ticks function) ;; (function stopwatch time-frame) -;; (define-extern stopwatch-elapsed-seconds function) ;; (function stopwatch float) +(define-extern timer-count (function timer-bank uint)) +(define-extern disable-irq (function none)) +(define-extern enable-irq (function none)) +(define-extern stopwatch-init (function stopwatch int)) +(define-extern stopwatch-reset (function stopwatch int)) +(define-extern stopwatch-start (function stopwatch int)) +(define-extern stopwatch-stop (function stopwatch none)) +(define-extern stopwatch-begin (function stopwatch int)) +(define-extern stopwatch-end (function stopwatch none)) +(define-extern stopwatch-elapsed-ticks (function stopwatch time-frame)) +(define-extern stopwatch-elapsed-seconds (function stopwatch float)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; vector ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern vector-cross! function) ;; (function vector vector vector vector) -;; (define-extern vector-xz-cross! function) ;; (function vector vector vector vector) -;; (define-extern vector+float! function) ;; (function vector vector float vector) -;; (define-extern vector*! function) ;; (function vector vector vector vector) -;; (define-extern vector+*! function) ;; (function vector vector vector float vector) -;; (define-extern vector-*! function) ;; (function vector vector vector float vector) -;; (define-extern vector/! function) ;; (function vector vector vector vector) -;; (define-extern vector-float*! function) ;; (function vector vector float vector) -;; (define-extern vector-average! function) ;; (function vector vector vector vector) -;; (define-extern vector+float*! function) ;; (function vector vector vector float vector) -;; (define-extern vector--float*! function) ;; (function vector vector vector float vector) -;; (define-extern vector-min! function) ;; (function vector vector vector vector) -;; (define-extern vector-max! function) ;; (function vector vector vector vector) -;; (define-extern vector-float/! function) ;; (function vector vector float vector) -;; (define-extern vector-negate! function) ;; (function vector vector vector) -;; (define-extern vector-negate-in-place! function) ;; (function vector vector) -;; (define-extern vector= function) ;; (function vector vector symbol) -;; (define-extern vector-delta function) ;; (function vector vector float) -;; (define-extern vector-seek! function) ;; (function vector vector float vector) -;; (define-extern vector-smooth-seek! function) ;; (function vector vector float vector) -;; (define-extern vector-seek-2d-xz-smooth! function) ;; (function vector vector float float vector) -;; (define-extern vector-seek-2d-yz-smooth! function) ;; (function vector vector float float vector) -;; (define-extern vector-seek-3d-smooth! function) ;; (function vector vector float float vector) -;; (define-extern seek-with-smooth function) ;; (function float float float float float float) -;; (define-extern vector-identity! function) ;; (function vector vector) -;; (define-extern vector-seconds function) ;; (function vector vector vector) -;; (define-extern vector-seconds! function) ;; (function vector vector) -;; (define-extern vector-v! function) ;; (function vector vector) -;; (define-extern vector-v+! function) ;; (function vector vector vector vector) -;; (define-extern vector-v*float+! function) ;; (function vector vector vector float vector) -;; (define-extern vector-v++! function) ;; (function vector vector vector) -;; (define-extern vector-v*float! function) ;; (function vector vector float vector) -;; (define-extern vector-v*float++! function) ;; (function vector vector float vector) -;; (define-extern vector-to-ups! function) ;; (function vector vector vector) -;; (define-extern vector-from-ups! function) ;; (function vector vector vector) -;; (define-extern vector-length function) ;; (function vector float) -;; (define-extern vector-length-squared function) ;; (function vector float) -;; (define-extern vector-xz-length-squared function) ;; (function vector float) -;; (define-extern vector-xz-length function) ;; (function vector float) -;; (define-extern vector-vector-distance function) ;; (function vector vector float) -;; (define-extern vector-vector-distance-squared function) ;; (function vector vector float) -;; (define-extern vector-vector-xz-distance function) ;; (function vector vector float) -;; (define-extern vector-vector-xy-distance function) ;; (function vector vector float) -;; (define-extern vector-vector-xz-distance-squared function) ;; (function vector vector float) -;; (define-extern vector-vector-planar-distance function) ;; (function vector vector vector float) -;; (define-extern vector-normalize! function) ;; (function vector float vector) -;; (define-extern vector-normalize-ret-len! function) ;; (function vector float float) -;; (define-extern vector-normalize-copy! function) ;; (function vector vector float vector) -;; (define-extern vector-xz-normalize! function) ;; (function vector float vector) -;; (define-extern vector-xz-normalize-copy! function) ;; (function vector vector float vector) -;; (define-extern vector-length-max! function) ;; (function vector float vector) -;; (define-extern vector-xz-length-max! function) ;; (function vector float vector) -;; (define-extern vector-rotate-around-x! function) ;; (function vector vector float vector) -;; (define-extern vector-rotate-around-y! function) ;; (function vector vector float vector) -;; (define-extern vector-rotate90-around-y! function) ;; (function vector vector vector) -;; (define-extern vector-rotate-around-z! function) ;; (function vector vector float vector) -;; (define-extern rotate-y<-vector+vector function) ;; (function vector vector float) -;; (define-extern rotate-x<-vector+vector function) ;; (function vector vector float) -;; (define-extern rotate-z<-vector+vector function) ;; (function vector vector float) -;; (define-extern rotate-vector-to-vector function) ;; (function vector vector vector vector) -;; (define-extern vector-cvt.w.s! function) ;; (function vector vector vector) -;; (define-extern vector-cvt.s.w! function) ;; (function vector vector vector) -;; (define-extern rot-zxy-from-vector! function) ;; (function vector vector vector) -;; (define-extern rot-zyx-from-vector! function) ;; (function vector vector vector) -;; (define-extern vector-world-to-local! function) -;; (define-extern vector-local-to-world! function) -;; (define-extern vector-lerp! function) ;; (function vector vector vector float vector) -;; (define-extern vector-lerp-clamp! function) ;; (function vector vector vector float vector) -;; (define-extern vector4-lerp! function) ;; (function vector vector vector float vector) -;; (define-extern vector4-lerp-clamp! function) ;; (function vector vector vector float vector) -;; (define-extern vector4w-lerp! function) -;; (define-extern vector-degi function) ;; (function vector vector vector) -;; (define-extern vector-degf function) ;; (function vector vector vector) -;; (define-extern vector-degmod function) ;; (function vector vector vector) -;; (define-extern vector-deg-diff function) ;; (function vector vector vector none) -;; (define-extern vector-deg-lerp-clamp! function) ;; (function vector vector vector float vector) -;; (define-extern vector3s-copy! function) ;; (function vector vector vector) -;; (define-extern vector3s+! function) ;; (function vector vector vector vector) -;; (define-extern vector3s*float! function) ;; (function vector vector float vector) -;; (define-extern vector3s-! function) ;; (function vector vector vector vector) -;; (define-extern vector4-add! function) ;; (function vector4 vector4 vector4 none) -;; (define-extern vector4-sub! function) ;; (function vector4 vector4 vector4 none) -;; (define-extern vector4-mul! function) ;; (function vector4 vector4 vector4 none) -;; (define-extern vector4-scale! function) ;; (function vector4 vector4 float none) -;; (define-extern vector4-madd! function) ;; (function vector4 vector4 vector4 float none) -;; (define-extern vector4-msub! function) ;; (function vector4 vector4 vector4 float none) -;; (define-extern vector4-array-add! function) ;; (function (inline-array vector4) (inline-array vector4) (inline-array vector4) int none) -;; (define-extern vector4-array-sub! function) ;; (function (inline-array vector4) (inline-array vector4) (inline-array vector4) int none) -;; (define-extern vector4-array-mul! function) ;; (function (inline-array vector4) (inline-array vector4) (inline-array vector4) int none) -;; (define-extern vector4-array-scale! function) ;; (function (inline-array vector4) (inline-array vector4) float int none) -;; (define-extern vector4-array-madd! function) ;; (function (inline-array vector4) (inline-array vector4) (inline-array vector4) float int none) -;; (define-extern vector4-array-msub! function) ;; (function (inline-array vector4) (inline-array vector4) (inline-array vector4) float int none) -;; (define-extern vector4-array-lerp! function) ;; (function (inline-array vector4) (inline-array vector4) (inline-array vector4) float int symbol) -;; (define-extern spheres-overlap? function) ;; (function sphere sphere symbol) -;; (define-extern sphere<-vector! function) ;; (function sphere vector sphere) -;; (define-extern sphere<-vector+r! function) ;; (function sphere vector float sphere) -;; (define-extern rand-vu-sphere-point! function) ;; (function vector float vector) -;; (define-extern rand-vu-sphere-point-uniform! function) ;; (function vector float vector) -;; (define-extern vector-vector-angle-safe function) ;; (function vector vector float) -;; (define-extern vector-get-unique! function) ;; (function vector vector vector) -;; (define-extern vector-get-closest-perpendicular! function) ;; (function vector vector vector vector) +(define-extern vector-cross! + "Compute the cross product. The w component is set to junk." + (function vector vector vector vector)) +(define-extern vector-xz-cross! + "Compute the cross product of the xz components of inputs." + (function vector vector vector vector)) +(define-extern vector+float! + "Add float to each component of vector. The w component is set to 1" + (function vector vector float vector)) +(define-extern vector*! "Elementwise product. Set w = 1." (function vector vector vector vector)) +(define-extern vector+*! + "set arg0 = arg1 + (arg3 * arg2). The w component will be set to 1." + (function vector vector vector float vector)) +(define-extern vector-*! + "Set arg0 = arg1 - (arg3 * arg2). The w component will be set to 1." + (function vector vector vector float vector)) +(define-extern vector/! + "Set arg0 = arg1 / arg2. The w component will be set to 1. + The implementation is kind of crazy." + (function vector vector vector vector)) +(define-extern vector-float*! + "Multiply all values in a vector by arg2. Set w to 1." + (function vector vector float vector)) +(define-extern vector-average! + "Set arg0 to the average of arg1 and arg2. Set w to 1." + (function vector vector vector vector)) +(define-extern vector+float*! "arg0 = arg1 + arg2 * arg3." (function vector vector vector float vector)) +(define-extern vector--float*! + "Set arg0 = arg1 - (arg2 * arg3). The w component will be set to 1. + Is this different from vector-*!" + (function vector vector vector float vector)) +(define-extern vector-min! (function vector vector vector vector)) +(define-extern vector-max! (function vector vector vector vector)) +(define-extern vector-float/! + "Divide all components by arg2. The w component will be set to 1." + (function vector vector float vector)) +(define-extern vector-negate! "Negate xyz, set w to 1." (function vector vector vector)) +(define-extern vector-negate-in-place! "Negate xyz. Doesn't touch w." (function vector vector)) +(define-extern vector= + "Are the two vectors equal? Does not compare the w component. + The implementation is cool." + (function vector vector symbol)) +(define-extern vector-delta + "Sum of the elementwise absolute value of differences." + (function vector vector float)) +(define-extern vector-seek! + "Seek arg0 toward arg1. The arg0 is both read and written. + arg2 is saturated to (0, 1)" + (function vector vector float vector)) +(define-extern vector-smooth-seek! + "Smoothly seek vec toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a _square_ with side length arg2. + Note that this doesn't project to a circle like the function below..." + (function vector vector float vector)) +(define-extern vector-seek-2d-xz-smooth! + "Smoothly seek vec's x and z components toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a circle of radius max-step. + Doesn't touch y or w." + (function vector vector float float vector)) +(define-extern vector-seek-2d-yz-smooth! + "Smoothly seek vec's y and z components toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a circle of radius max-step. + Doesn't touch x or w." + (function vector vector float float vector)) +(define-extern vector-seek-3d-smooth! + "Smoothly seek vec's x, y, and z components toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a circle of radius max-step. + Doesn't touch w." + (function vector vector float float vector)) +(define-extern seek-with-smooth + "Move value closer to target. + If we are within deadband, just go straight to target. + If not, try to go alpha*err. If that is a larger step than max-step, limit to max-step" + (function float float float float float float)) +(define-extern vector-identity! "Set arg0 to 1, 1, 1, 1." (function vector vector)) +(define-extern vector-seconds + "Convert from actual seconds to the seconds unit." + (function vector vector vector)) +(define-extern vector-seconds! + "Convert from actual seconds to seconds, in place." + (function vector vector)) +(define-extern vector-v! + "Convert a velocity to a displacement per frame. The velocity should be in X/actual_second. + Uses the current process clock." + (function vector vector)) +(define-extern vector-v+! + "Euler forward step, using the current display time settings." + (function vector vector vector vector)) +(define-extern vector-v*float+! + "Euler forward step, scaling velocity by velocity-scale." + (function vector vector vector float vector)) +(define-extern vector-v++! + "Update position in place, using display's current timing." + (function vector vector vector)) +(define-extern vector-v*float! + "Go from velocity to delta-p per frame, scaling by scale." + (function vector vector float vector)) +(define-extern vector-v*float++! + "Update position with given velocity, scaled by scale." + (function vector vector float vector)) +(define-extern vector-to-ups! + "Go from units per frame to units per second?" + (function vector vector vector)) +(define-extern vector-from-ups! + "Go from units per second to units per frame?" + (function vector vector vector)) +(define-extern vector-length + "Get the length of the xyz part." + (function vector float)) +(define-extern vector-length-squared + "Get the squared length of the xyz part." + (function vector float)) +(define-extern vector-xz-length-squared + "Get the length of the xz part, squared." + (function vector float)) +(define-extern vector-xz-length "Get the length of the xz part." (function vector float)) +(define-extern vector-vector-distance + "Subtract the xyz parts and get the norm." + (function vector vector float)) +(define-extern vector-vector-distance-squared + "Squared norm of the difference of the xyz parts." + (function vector vector float)) +(define-extern vector-vector-xz-distance "Distance on the xz plane." (function vector vector float)) +(define-extern vector-vector-xy-distance "distance on the xy plane." (function vector vector float)) +(define-extern vector-vector-xz-distance-squared "Distance on the xz plane squared." (function vector vector float)) +(define-extern vector-vector-planar-distance (function vector vector vector float)) +(define-extern vector-normalize! + "Modify arg0 in place to have length arg1 for its xyz components. The w part is not changed." + (function vector float vector)) +(define-extern vector-normalize-ret-len! + "Modify arg0 in place to have length arg1 for its xyz components. + The w part isn't changed and the _original_ length is returned." + (function vector float float)) +(define-extern vector-normalize-copy! + "Normalize, but not in place. + This implementation is very good compared to the vector-normalize! one. + The w component is set to 1." + (function vector vector float vector)) +(define-extern vector-xz-normalize! "Normalize, xz components only." (function vector float vector)) +(define-extern vector-xz-normalize-copy! "Normalize, xz components only." (function vector vector float vector)) +(define-extern vector-length-max! + "Make vector at most arg1 length (xyz only). + If it is larger, project onto sphere. + Doesn't touch w" + (function vector float vector)) +(define-extern vector-xz-length-max! + "Make vector at most arg1 length (xz only). + It it is larger, project onto circle. + Doesn't touch w or y." + (function vector float vector)) +(define-extern vector-rotate-around-x! "Rotate a vector around the x axis." (function vector vector float vector)) +(define-extern vector-rotate-around-y! "Rotate a vector around the y axis." (function vector vector float vector)) +(define-extern vector-rotate90-around-y! "Rotate a vector 90 degrees around y." (function vector vector vector)) +(define-extern vector-rotate-around-z! "Rotate a vector around the z axis." (function vector vector float vector)) +(define-extern rotate-y<-vector+vector + "Get the y rotation between vectors. These should have the same length." + (function vector vector float)) +(define-extern rotate-x<-vector+vector + "Get the x rotation between vectors. These should have the same length." + (function vector vector float)) +(define-extern rotate-z<-vector+vector + "Get the z rotation between vectors. These should have the same length." + (function vector vector float)) +(define-extern rotate-vector-to-vector (function vector vector vector vector)) +(define-extern vector-cvt.w.s! "Convert float to int32. Truncate." (function vector vector vector)) +(define-extern vector-cvt.s.w! "Convert float to int32." (function vector vector vector)) +(define-extern rot-zxy-from-vector! + "I think this gives you a vector of euler angles to rotate some unit vector + to arg1." + (function vector vector vector)) +(define-extern rot-zyx-from-vector! + "I think this gives you a vector of euler angles to rotate some unit vector + to arg1." + (function vector vector vector)) +(define-extern vector-world-to-local! (function vector vector vector quaternion vector)) +(define-extern vector-local-to-world! (function vector vector vector quaternion vector)) +(define-extern vector-lerp! + "Linearly interpolate between two vectors. Alpha isn't clamped. + w will be set to 1." + (function vector vector vector float vector)) +(define-extern vector-lerp-clamp! + "Linearly interpolate between two vectors, clamping alpha to 0, 1. + w will be set to 1." + (function vector vector vector float vector)) +(define-extern vector4-lerp! + "Interpolate all 4 elements of a vector. Alpha is not clamped." + (function vector vector vector float vector)) +(define-extern vector4-lerp-clamp! + "Interpolate all 4 elements of a vector. Alpha is clamped to [0, 1]." + (function vector vector vector float vector)) +(define-extern vector4w-lerp! (function vector4w vector4w vector4w float vector4w)) +(define-extern vector-degi + "Convert a vector (in _rotations_) to degrees units, stored in an int. + Truncates to the nearest _rotation_. + Neither the input or output is a commonly used form. + Unsurprisingly, this strange function is never used." + (function vector vector vector)) +(define-extern vector-degf + "Convert a vector (in integer degree units) to floating point rotations. + Truncates to the nearest _rotation_. + Like the previous function, this is stupid and unused." + (function vector vector vector)) +(define-extern vector-degmod + "This one is actually right. Wraps degrees units (in floats, like they should be) + to +/- half a rotation." + (function vector vector vector)) +(define-extern vector-deg-diff + "Wrapped difference, degrees units. Will have the usual 16-bit accuracy issue." + (function vector vector vector none)) +(define-extern vector-deg-lerp-clamp! + "Apply deg-lerp-clamp to the xyz components of a vector. Sets w = 1." + (function vector vector vector float vector)) +(define-extern vector3s-copy! (function vector vector vector)) +(define-extern vector3s+! (function vector vector vector vector)) +(define-extern vector3s*float! (function vector vector float vector)) +(define-extern vector3s-! (function vector vector vector vector)) +(define-extern vector4-add! "Add 2 vector4s." (function vector4 vector4 vector4 none)) +(define-extern vector4-sub! "Subtract 2 vector4s." (function vector4 vector4 vector4 none)) +(define-extern vector4-mul! "Multiple 2 vector4s." (function vector4 vector4 vector4 none)) +(define-extern vector4-scale! "arg0 = arg1 * arg2." (function vector4 vector4 float none)) +(define-extern vector4-madd! "arg0 = arg1 + arg2 * arg3." (function vector4 vector4 vector4 float none)) +(define-extern vector4-msub! "arg0 = arg1 - arg2 * arg3." (function vector4 vector4 vector4 float none)) +(define-extern vector4-array-add! "Apply vector4-add! to all arrays." (function (inline-array vector4) (inline-array vector4) (inline-array vector4) int none)) +(define-extern vector4-array-sub! "Apply vector4-sub! to all arrays." (function (inline-array vector4) (inline-array vector4) (inline-array vector4) int none)) +(define-extern vector4-array-mul! "Apply vector4-mul! to all arrays." (function (inline-array vector4) (inline-array vector4) (inline-array vector4) int none)) +(define-extern vector4-array-scale! "Apply vector4-scale! to all arrays." (function (inline-array vector4) (inline-array vector4) float int none)) +(define-extern vector4-array-madd! "Apply vector4-madd! to all arrays." (function (inline-array vector4) (inline-array vector4) (inline-array vector4) float int none)) +(define-extern vector4-array-msub! "Apply vector4-msub! to all arrays." (function (inline-array vector4) (inline-array vector4) (inline-array vector4) float int none)) +(define-extern vector4-array-lerp! "Apply vector4-lerp! to all arrays." (function (inline-array vector4) (inline-array vector4) (inline-array vector4) float int symbol)) +(define-extern spheres-overlap? "Do the spheres overlap?" (function sphere sphere symbol)) +(define-extern sphere<-vector! + "Set the position of the sphere to arg1. Does not change the radius." + (function sphere vector sphere)) +(define-extern sphere<-vector+r! + "Set the position of the sphere from arg1 and the radius from arg2." + (function sphere vector float sphere)) +(define-extern rand-vu-sphere-point! + "Get a random point on the sphere at the origin with radius arg1. + The point is on the surface of the sphere." + (function vector float vector)) +(define-extern rand-vu-sphere-point-uniform! (function vector float vector)) +(define-extern vector-vector-angle-safe + "Get the angle between two vectors, with some 'safety' applied..." + (function vector vector float)) +(define-extern vector-get-unique! (function vector vector vector)) ;; +(define-extern vector-get-closest-perpendicular! (function vector vector vector vector)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; file-io ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++file-io:file-kind +(defenum file-kind + :bitfield #f + (level-bt 0) ;; aka bsp-header. + (art-group 1) + (tpage 2) + (dir-tpage 3) + (level-vs 4) + (tx 5) + (vis 6) + (map 7) + ) +;; ---file-io:file-kind + (deftype file-stream (basic) - () + ((flags uint32 :offset-assert 4) + (mode symbol :offset-assert 8) + (name string :offset-assert 12) + (file uint32 :offset-assert 16) + ) + (:methods + (new (symbol type string symbol) _type_) + ) :method-count-assert 9 :size-assert #x14 :flag-assert #x900000014 - ;; Failed to read fields. ) -|# -#| (deftype file-info (basic) - ((file-type (pointer string) :offset-assert 4) ;; guessed by decompiler - (file-name string :offset-assert 8) ;; guessed by decompiler - (major-version uint32 :offset-assert 12) - (minor-version uint32 :offset-assert 16) - (maya-file-name string :offset-assert 20) ;; guessed by decompiler - (tool-debug string :offset-assert 24) ;; guessed by decompiler - (mdb-file-name string :offset-assert 28) ;; guessed by decompiler + ((file-type (pointer string) :offset-assert 4) ;; guessed by decompiler + (file-name string :offset-assert 8) + (major-version uint32 :offset-assert 12) + (minor-version uint32 :offset-assert 16) + (maya-file-name string :offset-assert 20) + (tool-debug string :offset-assert 24) + (mdb-file-name string :offset-assert 28) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -;; (define-extern file-stream-read-string function) ;; (function file-stream string string) -;; (define-extern *file-temp-string* object) ;; string -;; (define-extern make-file-name function) ;; (function file-kind string int symbol string) -;; (define-extern make-vfile-name function) ;; (function file-kind string string) -;; (define-extern file-info-correct-version? function) ;; (function file-info file-kind int symbol) -;; (define-extern *sqlpipe-file-path-send* object) -;; (define-extern *sqlpipe-file-path-recv* object) -;; (define-extern *sqlpipe-file-buffer* object) -;; (define-extern file-stream-read-complete function) -;; (define-extern sqlpipe-query function) -;; (define-extern old-sql-query object) -;; (define-extern sql-query object) ;; (function string sql-result) +(define-extern file-stream-read-string (function file-stream string string)) +(define-extern *file-temp-string* string) +(define-extern make-file-name (function file-kind string int symbol string)) +(define-extern make-vfile-name (function file-kind string string)) +(define-extern file-info-correct-version? (function file-info file-kind int symbol)) +(define-extern *sqlpipe-file-path-send* symbol) +(define-extern *sqlpipe-file-path-recv* symbol) +(define-extern *sqlpipe-file-buffer* (pointer uint32)) +(define-extern file-stream-read-complete (function file-stream pointer int int)) +(define-extern sqlpipe-query (function string sql-result)) +(define-extern old-sql-query function) +(define-extern sql-query (function string sql-result)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; loader-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype load-dir (basic) -;; () -;; :flag-assert #xb00000010 -;; ) +(declare-type art basic) +(declare-type art-group art) +(define-extern art-group type) -;; (deftype load-dir-art-group (load-dir) -;; () -;; :flag-assert #xb00000010 -;; ) +(deftype load-dir (basic) + ;; copied from jak1. + ((lev level :offset-assert 4) + (string-array (array string) :offset-assert 8) ;; these are the names + (data-array (array basic) :score -50 :offset-assert 12) ;; this is the file data. + ) + :method-count-assert 11 + :size-assert #x10 + :flag-assert #xb00000010 + ;; Failed to read some fields. + (:methods + (new (symbol type int level) _type_) ;; 0 + (load-to-heap-by-name (_type_ string symbol kheap int) art-group) ;; 9 + (set-loaded-art (_type_ art-group) art-group) ;; 10 + ) + ) + +(deftype load-dir-art-group (load-dir) + "Specialization of load-dir for `art-group`s." + ((art-group-array (array art-group) :offset 12) + ) + :flag-assert #xb00000010 + (:methods + (new (symbol type int level) _type_) ;; 0 + ) + ) -#| (deftype external-art-buffer (basic) + "An `external-art-buffer` is a buffer that streamed files use." ((index int32 :offset-assert 4) (other external-art-buffer :offset-assert 8) ;; guessed by decompiler (status symbol :offset-assert 12) ;; guessed by decompiler @@ -4394,54 +6427,54 @@ (heap kheap :inline :offset-assert 32) (pending-load-file string :offset-assert 48) ;; guessed by decompiler (pending-load-file-part int32 :offset-assert 52) - (pending-load-file-owner uint64 :offset-assert 56) ;; handle + (pending-load-file-owner handle :offset-assert 56) ;; handle (pending-load-file-priority float :offset-assert 64) (load-file string :offset-assert 68) ;; guessed by decompiler (load-file-part int32 :offset-assert 72) - (load-file-owner uint64 :offset-assert 80) ;; handle + (load-file-owner handle :offset-assert 80) ;; handle (load-file-priority float :offset-assert 88) (buf pointer :offset-assert 92) ;; guessed by decompiler (len int32 :offset-assert 96) (art-group art-group :offset-assert 100) ;; guessed by decompiler - (art-data uint32 :offset-assert 100) + (art-data uint32 :offset 100) ) :method-count-assert 16 :size-assert #x68 :flag-assert #x1000000068 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type int function symbol) _type_) - (external-art-buffer-method-9 () none) ;; 9 ;; (set-pending-file (_type_ string int handle float) int) - (external-art-buffer-method-10 () none) ;; 10 ;; (update (_type_) int) - (external-art-buffer-method-11 () none) ;; 11 ;; (inactive? (_type_) symbol) - (external-art-buffer-method-12 () none) ;; 12 ;; (file-status (_type_ string int) symbol) - (external-art-buffer-method-13 () none) ;; 13 ;; (link-file (_type_ art-group) art-group) - (external-art-buffer-method-14 () none) ;; 14 ;; (unlink-file (_type_ art-group) int) - (external-art-buffer-method-15 () none) ;; 15 ;; (unlock! (_type_) int) + (new (symbol type int function symbol) _type_) ;; 0 + (set-pending-file (_type_ string int handle float) int) ;; 9 + (update (_type_) int) ;; 10 + (inactive? (_type_) symbol) ;; 11 + (file-status (_type_ string int) symbol) ;; 12 + (link-file (_type_ art-group) art-group) ;; 13 + (unlink-file (_type_ art-group) int) ;; 14 + (unlock! (_type_) int) ;; 15 ) ) -|# -#| (deftype spool-anim (basic) - ((name string :offset-assert 16) ;; guessed by decompiler - (anim-name string :offset-assert 20) ;; guessed by decompiler + "A `spool-anim` is metadata for an animation that will be loaded in chunks + to a pair of external-art-buffers." + ((name string :offset 16) ;; guessed by decompiler + (anim-name string :offset-assert 20) + (buffer external-art-buffer :offset 20 :score -1) ;; added (parts int32 :offset-assert 24) - (hint-id int32 :offset-assert 24) + (hint-id int32 :offset 24) (priority float :offset-assert 28) - (owner uint64 :offset-assert 32) ;; handle + (owner handle :offset-assert 32) ;; handle (command-list pair :offset-assert 40) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype external-art-control (basic) + "The `external-art-control` manages loading chunks from `spool-anim`s to `external-art-buffer`." ((buffer external-art-buffer 2 :offset-assert 4) ;; guessed by decompiler - (rec spool-anim 3 :offset-assert 20) ;; guessed by decompiler - (spool-lock uint64 :offset-assert 160) ;; handle + (rec spool-anim 3 :inline :offset-assert 16) ;; guessed by decompiler + (spool-lock handle :offset-assert 160) ;; handle (reserve-buffer external-art-buffer :offset-assert 168) ;; guessed by decompiler (reserve-buffer-count int16 :offset-assert 172) (dma-reserve-buffer-count int16 :offset-assert 174) @@ -4454,86 +6487,82 @@ :size-assert #xd0 :flag-assert #x10000000d0 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) - (external-art-control-method-9 () none) ;; 9 ;; (update (_type_ symbol) int) - (external-art-control-method-10 () none) ;; 10 ;; (clear-rec (_type_) int) - (external-art-control-method-11 () none) ;; 11 ;; (spool-push (_type_ string int process float) int) - (external-art-control-method-12 () none) ;; 12 ;; (file-status (_type_ string int) symbol) - (external-art-control-method-13 () none) ;; 13 ;; (reserve-alloc (_type_) kheap) - (external-art-control-method-14 () none) ;; 14 ;; (reserve-free (_type_ kheap) int) - (external-art-control-method-15 () none) ;; 15 ;; (none-reserved? (_type_) symbol) + (new (symbol type) _type_) ;; 0 + (update (_type_ symbol) int) ;; 9 + (clear-rec (_type_) int) ;; 10 + (spool-push (_type_ string int process float) int) ;; 11 + (file-status (_type_ string int) symbol) ;; 12 + (reserve-alloc (_type_) kheap) ;; 13 + (reserve-free (_type_ kheap) int) ;; 14 + (none-reserved? (_type_) symbol) ;; 15 ) ) -|# -#| (deftype subtitle-range (basic) ((start-frame float :offset-assert 4) (end-frame float :offset-assert 8) (message basic 12 :offset-assert 12) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. ) :method-count-assert 9 :size-assert #x3c :flag-assert #x90000003c ) -|# -#| (deftype subtitle-image (basic) ((width uint16 :offset-assert 4) (height uint16 :offset-assert 6) - (palette rgba 16 :offset-assert 16) ;; guessed by decompiler + (palette rgba 16 :offset 16) ;; guessed by decompiler (data uint8 :dynamic :offset-assert 80) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; texture-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type texture-page basic) + (deftype texture-id (uint32) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + "Unique identifier for a texture + as the tpage number and index of the texture within the tpage." + ((index uint16 :offset 8 :size 12) + (page uint16 :offset 20 :size 12) ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype texture-pool-segment (structure) + "A chunk of VRAM." ((dest uint32 :offset-assert 0) (size uint32 :offset-assert 4) ) + :allow-misaligned + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype texture-pool (basic) + "The manager for the VRAM." ((top int32 :offset-assert 4) (cur int32 :offset-assert 8) (allocate-func (function texture-pool texture-page kheap int texture-page) :offset-assert 12) ;; guessed by decompiler (font-palette int32 :offset-assert 16) - (segment texture-pool-segment 4 :offset-assert 20) ;; guessed by decompiler - (segment-near texture-pool-segment :inline :offset-assert 20) - (segment-common texture-pool-segment :inline :offset-assert 28) + (segment texture-pool-segment 4 :inline :offset-assert 20) ;; guessed by decompiler + (segment-near texture-pool-segment :inline :offset 20) + (segment-common texture-pool-segment :inline :offset 28) (common-page texture-page 32 :offset-assert 52) ;; guessed by decompiler (common-page-mask int32 :offset-assert 180) (update-sprites-flag symbol :offset-assert 184) ;; guessed by decompiler (update-flag symbol :offset-assert 188) ;; guessed by decompiler - (texture-enable-user uint64 :offset-assert 192) ;; texture-enable-mask - (texture-enable-user-menu uint64 :offset-assert 200) ;; texture-enable-mask + (texture-enable-user texture-enable-mask :offset-assert 192) ;; texture-enable-mask + (texture-enable-user-menu texture-enable-mask :offset-assert 200) ;; texture-enable-mask (ids uint32 128 :offset-assert 208) ;; guessed by decompiler ) :method-count-assert 28 @@ -4562,51 +6591,48 @@ (texture-pool-method-27 () none) ;; 27 ) ) -|# -#| (deftype texture-mask (structure) + "Mask where each bit indicates if some part of a tpage is used, by a texture. + Additionally, the w component holds a minimum distance. The texture is only needed + if the distance to the object is smaller than this." ((mask vector4w :inline :offset-assert 0) - (dist float :offset-assert 12) - (long uint64 2 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + (dist float :offset 12 :score 1) + (long uint64 2 :offset 0) ;; guessed by decompiler + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype texture-masks (structure) - ((data texture-mask 3 :offset-assert 0) ;; guessed by decompiler - (level basic :offset-assert 8) + "Grouping of three masks, corresponding to the 3 segments of the texture. + So mask 0 is needed if segment 0 of the texture is needed, etc..." + ((data texture-mask 3 :inline :offset-assert 0) ;; guessed by decompiler + (level basic :offset 8) ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype texture-masks-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data texture-masks :dynamic :offset-assert 16) ;; guessed by decompiler + "Group of all texture-masks for a given tpage." + ((data texture-masks :dynamic :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype texture (basic) + "Metadata for a texture." ((w int16 :offset-assert 4) (h int16 :offset-assert 6) (num-mips uint8 :offset-assert 8) (tex1-control uint8 :offset-assert 9) - (psm uint8 :offset-assert 10) ;; gs-psm + (psm gs-psm :offset-assert 10) ;; gs-psm (mip-shift uint8 :offset-assert 11) (clutpsm uint16 :offset-assert 12) (dest uint16 7 :offset-assert 14) ;; guessed by decompiler @@ -4622,29 +6648,44 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype texture-page-segment (structure) + "Metadata for a 'segment' of a texture page. + Each texture page has 3 segments - smaller number segments have higher detail mips." ((block-data pointer :offset-assert 0) ;; guessed by decompiler (size uint32 :offset-assert 4) (dest uint32 :offset-assert 8) ) + :allow-misaligned + :pack-me :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -#| +;; +++texture-h:tex-upload-mode +(defenum tex-upload-mode + (none -3) + (seg0-1 -2) + (seg0-1-2 -1) + (seg0 0) + (seg2 2) + ) +;; ---texture-h:tex-upload-mode + (deftype texture-page (basic) + "A collection of textures. There is a tpage per category per level. + These tpages are loaded from the DVD. + e.g.: prison tfrag is its own tpage. + The tpage has multiple textures, and 3 segments. + Lower number segments are larger and have hi-res versions of textures." ((info file-info :offset-assert 4) ;; guessed by decompiler (name string :offset-assert 8) ;; guessed by decompiler (id uint32 :offset-assert 12) (length int32 :offset-assert 16) (mip0-size uint32 :offset-assert 20) (size uint32 :offset-assert 24) - (segment texture-page-segment 3 :offset-assert 28) ;; guessed by decompiler + (segment texture-page-segment 3 :inline :offset-assert 28) ;; guessed by decompiler (dram-size uint32 :offset-assert 64) (vram-size uint32 :offset-assert 68) (pad uint32 14 :offset-assert 72) ;; guessed by decompiler @@ -4662,43 +6703,63 @@ (texture-page-method-14 () none) ;; 14 ) ) -|# -;; (deftype shader-ptr (uint32) -;; () -;; :flag-assert #x900000004 -;; ) - -#| -(deftype texture-link (structure) - ((next shader-ptr :offset-assert 0) ;; guessed by decompiler +;; (declare-type adgif-shader structure) +(deftype shader-ptr (uint32) + "A pointer to an adgif-shader, stored in bits 8-32. This allows them to fit into + an adgif shader easily." + ((first-8 uint8 :offset 0 :size 8) ;; added + (shader uint32 :offset 8 :size 24) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +(deftype texture-link (structure) + "An overlay structure containing a shader-ptr that points to the next adgif-shader + in a linked list." + ((next shader-ptr 1 :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype texture-page-dir-entry (structure) + "An entry for a texture in the texture-page-dir. + The texture-page-dir contains an entry for each tpage. + Each entry contains a reference to the tpage, and a linked list of shaders + using it." ((length int16 :offset-assert 0) (status uint16 :offset-assert 2) (page texture-page :offset-assert 4) ;; guessed by decompiler (link texture-link :offset-assert 8) ;; guessed by decompiler ) + :pack-me + :allow-misaligned :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -;; (deftype texture-page-dir (basic) -;; () -;; :flag-assert #xb00000014 -;; ) +(deftype texture-page-dir (basic) + "The list of all texture pages. + This is static data loaded from the DVD at boot." + ((length int32) + (entries texture-page-dir-entry 1 :inline) + ) + (:methods + (relocate (_type_ kheap (pointer uint8)) none :replace) ;; 7 + (unlink-shaders-in-heap "Iterate through all adgifs, splicing out ones that are in the given heap." (_type_ kheap) int) ;; 9 + (texture-page-dir-method-10 (_type_) none) + ) + :flag-assert #xb00000014 + ) -#| (deftype texture-relocate-later (basic) + "Unused in Jak 2, but metadata for postponing tpage copies until a second frame, + to have a smaller impact on frame times when loading." ((memcpy symbol :offset-assert 4) ;; guessed by decompiler (dest uint32 :offset-assert 8) (source uint32 :offset-assert 12) @@ -4710,47 +6771,59 @@ :size-assert #x1c :flag-assert #x90000001c ) -|# -#| +;; +++texture-h:link-test-flags +(defenum link-test-flags + :type uint32 + :bitfield #t + (needs-log-in 8) + (bit-9 9) + (backup-sprite-tex 10) ;; set when particle-setup-adgif fails texture lookup. + ) +;; ---texture-h:link-test-flags + (deftype adgif-shader (structure) - ((quad qword 5 :offset-assert 0) ;; guessed by decompiler - (prims gs-reg64 10 :offset-assert 0) ;; guessed by decompiler - (reg-0 uint8 :offset-assert 8) ;; gs-reg - (reg-1 uint8 :offset-assert 24) ;; gs-reg - (reg-2 uint8 :offset-assert 40) ;; gs-reg - (reg-3 uint8 :offset-assert 56) ;; gs-reg - (reg-4 uint8 :offset-assert 72) ;; gs-reg - (tex0 uint64 :offset-assert 0) ;; gs-tex0 - (tex1 uint64 :offset-assert 16) ;; gs-tex1 - (miptbp1 uint64 :offset-assert 32) ;; gs-miptbp - (clamp uint64 :offset-assert 48) ;; gs-clamp - (clamp-reg uint64 :offset-assert 56) ;; gs-reg64 - (alpha uint64 :offset-assert 64) ;; gs-miptbp - (link-test link-test-flags :offset-assert 8) ;; guessed by decompiler - (texture-id texture-id :offset-assert 24) ;; guessed by decompiler - (next shader-ptr :offset-assert 40) ;; guessed by decompiler + "GS texturing/blending settings, called adgif-shader. + These are used by many different renderers and partially managed by the texture system. + For example, the texture system will automatically update tbp to point to the location + of the texture." + ((quad qword 5 :inline :offset-assert 0 :score -100) ;; guessed by decompiler + (prims gs-reg64 10 :offset 0 :score -100) ;; guessed by decompiler + (reg-0 gs-reg :offset 8) + (reg-1 gs-reg :offset 24) + (reg-2 gs-reg :offset 40) + (reg-3 gs-reg :offset 56) + (reg-4 gs-reg :offset 72) + (tex0 gs-tex0 :offset 0) ;; + (tex1 gs-tex1 :offset 16) ;; + (miptbp1 gs-miptbp :offset 32) ;; + (clamp gs-clamp :offset 48) ;; gs-clamp + (clamp-reg gs-reg64 :offset 56) ;; + (alpha gs-miptbp :offset 64) ;; + (link-test link-test-flags :offset 8) ;; guessed by decompiler + (texture-id texture-id :offset 24) ;; guessed by decompiler + (next shader-ptr :offset 40) ;; guessed by decompiler + ;(alpha-as-miptb2 gs-miptbp :offset 64) ;; added!! + (alpha-as-miptb2 gs-miptbp :offset 64) + (reg-4-u32 gs-reg32 :offset 72) + ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype adgif-shader-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data adgif-shader :dynamic :offset-assert 16) ;; guessed by decompiler + ((data adgif-shader :inline :dynamic :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype texture-base (structure) + "Metadata about an area of VRAM set aside for fancy dynamic texture effects + (sky, eye, etc)." ((vram-page uint32 :offset-assert 0) (vram-block uint32 :offset-assert 4) (vram-word uint32 :offset-assert 8) @@ -4759,11 +6832,9 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype texture-page-translate-item (structure) - ((bucket int32 :offset-assert 0) ;; bucket-id + ((bucket bucket-id :offset-assert 0) ;; bucket-id (level-index uint32 :offset-assert 4) (level-texture-page tpage-category-u32 :offset-assert 8) ;; guessed by decompiler (texture-user texture-enable-mask-u32 :offset-assert 12) ;; guessed by decompiler @@ -4772,79 +6843,84 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern *texture-masks* object) ;; texture-masks -;; (define-extern *texture-masks-array* object) ;; texture-masks-array -;; (define-extern texture-mip->segment function) ;; (function int int int) -;; (define-extern *texture-relocate-later* object) ;; texture-relocate-later -;; (define-extern *texture-page-dir* object) ;; texture-page-dir -;; (define-extern ct32-24-block-table array) ;; (array int32) -;; (define-extern mz32-24-block-table array) ;; (array int32) -;; (define-extern ct16-block-table array) ;; (array int32) -;; (define-extern ct16s-block-table array) ;; (array int32) -;; (define-extern mz16-block-table array) ;; (array int32) -;; (define-extern mz16s-block-table array) ;; (array int32) -;; (define-extern mt8-block-table array) ;; (array int32) -;; (define-extern mt4-block-table array) ;; (array int32) -;; (define-extern *texture-page-translate* array) ;; (array texture-page-translate-item) +(define-extern *texture-masks* texture-masks) +(define-extern *texture-masks-array* texture-masks-array) +(define-extern texture-mip->segment (function int int int)) +(define-extern *texture-relocate-later* texture-relocate-later) +(define-extern *texture-page-dir* texture-page-dir) +(define-extern ct32-24-block-table (array int32)) +(define-extern mz32-24-block-table (array int32)) +(define-extern ct16-block-table (array int32)) +(define-extern ct16s-block-table (array int32)) +(define-extern mz16-block-table (array int32)) +(define-extern mz16s-block-table (array int32)) +(define-extern mt8-block-table (array int32)) +(define-extern mt4-block-table (array int32)) +(define-extern *texture-page-translate* (array texture-page-translate-item)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; texture-anim-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype texture-anim-layer (structure) - ((extra vector :inline :offset-assert 240) + ((interpolated-color vector :inline) ;; added + (interpolated-scale-offset vector :inline) + (interpolated-st-scale-offset vector :inline) + (interpolated-qs vector :inline) + (interpolated-rot vector :inline) + (extra vector :inline :offset 240) (func (function dma-buffer uint int int texture-anim-layer float int) :offset-assert 256) ;; guessed by decompiler - (func-id symbol :offset-assert 256) ;; guessed by decompiler + (func-id symbol :offset-assert 256 :overlay-at func) ;; guessed by decompiler (init-func (function texture-anim-layer int) :offset-assert 260) ;; guessed by decompiler - (init-func-id symbol :offset-assert 260) ;; guessed by decompiler + (init-func-id symbol :offset-assert 260 :overlay-at init-func) ;; guessed by decompiler (tex texture :offset-assert 264) ;; guessed by decompiler (start-time float :offset-assert 268) (end-time float :offset-assert 272) (tex-name string :offset-assert 276) ;; guessed by decompiler - (test uint64 :offset-assert 280) ;; gs-test - (alpha uint64 :offset-assert 288) ;; gs-alpha - (clamp uint64 :offset-assert 296) ;; gs-clamp - (start-color vector :inline :offset-assert 80) - (start-scale vector2 :inline :offset-assert 96) - (start-offset vector2 :inline :offset-assert 104) - (start-st-scale vector2 :inline :offset-assert 112) - (start-st-offset vector2 :inline :offset-assert 120) - (start-qs vector :inline :offset-assert 128) - (start-rot deg :offset-assert 144) ;; degrees - (start-st-rot deg :offset-assert 148) ;; degrees - (end-color vector :inline :offset-assert 160) - (end-scale vector2 :inline :offset-assert 176) - (end-offset vector2 :inline :offset-assert 184) - (end-st-scale vector2 :inline :offset-assert 192) - (end-st-offset vector2 :inline :offset-assert 200) - (end-qs vector :inline :offset-assert 208) - (end-rot deg :offset-assert 224) ;; degrees - (end-st-rot deg :offset-assert 228) ;; degrees + (test gs-test :offset-assert 280) ;; gs-test + (alpha gs-alpha :offset-assert 288) ;; gs-alpha + (clamp gs-clamp :offset-assert 296) ;; gs-clamp + (start-vectors vector 5 :inline :offset 80 :score -10) ;; added + + (start-color vector :inline :offset 80) + (start-scale vector2 :inline :offset 96) + (start-offset vector2 :inline :offset 104) + (start-st-scale vector2 :inline :offset 112) + (start-st-offset vector2 :inline :offset 120) + (start-qs vector :inline :offset 128) + (start-rot degrees :offset 144) ;; degrees + (start-st-rot degrees :offset 148) ;; degrees + (end-vectors vector 5 :inline :offset 160 :score -10) ;; added + + (end-color vector :inline :offset 160) + (end-scale vector2 :inline :offset 176) + (end-offset vector2 :inline :offset 184) + (end-st-scale vector2 :inline :offset 192) + (end-st-offset vector2 :inline :offset 200) + (end-qs vector :inline :offset 208) + (end-rot degrees :offset 224) ;; degrees + (end-st-rot degrees :offset 228) ;; degrees ) :method-count-assert 11 :size-assert #x130 :flag-assert #xb00000130 (:methods - (texture-anim-layer-method-9 () none) ;; 9 ;; (initialize-texture! (_type_) _type_) - (texture-anim-layer-method-10 () none) ;; 10 ;; (clear-texture! (_type_) _type_) + (initialize-texture! (_type_) _type_) ;; 9 + (clear-texture! (_type_) _type_) ;; 10 ) ) -|# -#| (deftype texture-anim (structure) ((num-layers uint32 :offset-assert 0) (func (function dma-buffer texture-anim int) :offset-assert 4) ;; guessed by decompiler - (func-id symbol :offset-assert 4) ;; guessed by decompiler + (func-id symbol :offset-assert 4 :overlay-at func) ;; guessed by decompiler (init-func (function texture-anim int) :offset-assert 8) ;; guessed by decompiler - (init-func-id symbol :offset-assert 8) ;; guessed by decompiler + (init-func-id symbol :offset-assert 8 :overlay-at init-func) ;; guessed by decompiler (mip-func basic :offset-assert 12) - (mip-func-id basic :offset-assert 12) + (mip-func-id basic :offset-assert 12 :overlay-at mip-func) (time-func basic :offset-assert 16) - (time-func-id basic :offset-assert 16) + (time-func-id basic :offset-assert 16 :overlay-at time-func) (tex texture :offset-assert 20) ;; guessed by decompiler (tex-name string :offset-assert 24) ;; guessed by decompiler (extra vector :inline :offset-assert 32) @@ -4865,26 +6941,19 @@ (texture-anim-method-10 () none) ;; 10 ;; (clear-textures! (_type_) _type_) ) ) -|# -#| (deftype texture-anim-array (array) - ((type type :offset-assert 0) ;; guessed by decompiler - (length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (content-type type :offset-assert 12) ;; guessed by decompiler + ((array-data texture-anim :dynamic :offset-assert 16) ) :method-count-assert 11 :size-assert #x10 :flag-assert #xb00000010 (:methods - (texture-anim-array-method-9 () none) ;; 9 ;; (init! (_type_) _type_) - (texture-anim-array-method-10 () none) ;; 10 ;; (clear! (_type_) _type_) + (init! (_type_) _type_) ;; 9 + (clear! (_type_) _type_) ;; 10 ) ) -|# -#| (deftype texture-anim-work (structure) ((erase-tmpl dma-gif-packet :inline :offset-assert 0) (draw-tmpl dma-gif-packet :inline :offset-assert 32) @@ -4898,7 +6967,7 @@ (corner3 vector :inline :offset-assert 240) (const vector :inline :offset-assert 256) (color vector4w :inline :offset-assert 272) - (random vector4w 8 :offset-assert 288) ;; guessed by decompiler + (random vector4w 8 :inline :offset-assert 288) ;; guessed by decompiler (random-index uint8 :offset-assert 416) (color80808040 vector4w :inline :offset-assert 432) (color80808060 vector4w :inline :offset-assert 448) @@ -4931,9 +7000,7 @@ :size-assert #x350 :flag-assert #x900000350 ) -|# -#| (deftype clut16x16 (structure) ((clut rgba 256 :offset-assert 0) ;; guessed by decompiler ) @@ -4941,9 +7008,7 @@ :size-assert #x400 :flag-assert #x900000400 ) -|# -#| (deftype noise8x8 (structure) ((image uint8 64 :offset-assert 0) ;; guessed by decompiler ) @@ -4951,9 +7016,7 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype noise16x16 (structure) ((image uint8 256 :offset-assert 0) ;; guessed by decompiler ) @@ -4961,9 +7024,7 @@ :size-assert #x100 :flag-assert #x900000100 ) -|# -#| (deftype noise32x32 (structure) ((image uint8 1024 :offset-assert 0) ;; guessed by decompiler ) @@ -4971,9 +7032,7 @@ :size-assert #x400 :flag-assert #x900000400 ) -|# -#| (deftype noise64x64 (structure) ((image uint8 4096 :offset-assert 0) ;; guessed by decompiler ) @@ -4981,9 +7040,7 @@ :size-assert #x1000 :flag-assert #x900001000 ) -|# -#| (deftype noise128x128 (structure) ((image uint8 16384 :offset-assert 0) ;; guessed by decompiler ) @@ -4991,9 +7048,7 @@ :size-assert #x4000 :flag-assert #x900004000 ) -|# -#| (deftype fog8x256 (structure) ((image uint8 256 :offset-assert 0) ;; guessed by decompiler ) @@ -5001,9 +7056,7 @@ :size-assert #x100 :flag-assert #x900000100 ) -|# -#| (deftype fog-texture-work (structure) ((fog-height float :offset-assert 0) (fog-near float :offset-assert 4) @@ -5018,81 +7071,75 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -;; (define-extern *clut-translate* object) ;; (pointer uint8) +(define-extern *clut-translate* (pointer uint8)) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; lights-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype vu-lights (structure) - ((direction vector 3 :offset-assert 0) ;; guessed by decompiler - (color vector 3 :offset-assert 48) ;; guessed by decompiler + ((direction vector 3 :inline :offset-assert 0) ;; guessed by decompiler + (color vector 3 :inline :offset-assert 48) ;; guessed by decompiler (ambient vector :inline :offset-assert 96) + (fade-int uint32 :offset 44) + (fade-flags uint32 :offset 28) ) :method-count-assert 9 :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype light (structure) + "extra: {?, shadow, ?, ?}" ((direction vector :inline :offset-assert 0) (color rgbaf :inline :offset-assert 16) (extra vector :inline :offset-assert 32) - (level float :offset-assert 32) - (luminance float :offset-assert 40) - (priority float :offset-assert 44) - (bytes uint8 4 :offset-assert 36) ;; guessed by decompiler - (mask uint16 :offset-assert 36) - (palette-index int8 :offset-assert 39) + (level float :offset-assert 32 :overlay-at (-> extra x)) + (luminance float :offset-assert 40 :overlay-at (-> extra z)) + (priority float :offset-assert 44 :overlay-at (-> extra w)) + (bytes uint8 4 :offset-assert 36 :overlay-at (-> extra y)) ;; guessed by decompiler + (mask uint16 :offset-assert 36 :overlay-at bytes) + (palette-index int8 :offset-assert 39 :overlay-at (-> bytes 3)) ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -;; (deftype light-shadow-mask (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype light-shadow-mask (uint32) + () + :flag-assert #x900000004 + ) -#| (deftype light-sphere (structure) ((name string :offset-assert 0) ;; guessed by decompiler (bsphere vector :inline :offset-assert 16) (direction vector :inline :offset-assert 32) (color vector :inline :offset-assert 48) - (decay-start float :offset-assert 4) - (ambient-point-ratio float :offset-assert 8) - (brightness float :offset-assert 12) - (bytes uint8 4 :offset-assert 60) ;; guessed by decompiler - (mask uint16 :offset-assert 60) - (palette-index int8 :offset-assert 63) - (shadow uint32 :offset-assert 32) + (decay-start float :offset 4) + (ambient-point-ratio float :offset 8) + (brightness float :offset 12) + (bytes uint8 4 :offset 60) ;; guessed by decompiler + (mask uint16 :offset 60) + (palette-index int8 :offset 63) + (shadow uint32 :offset 32 :score 1) ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype light-hash-bucket (structure) ((index uint16 :offset-assert 0) (count uint16 :offset-assert 2) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype light-hash (basic) ((num-lights uint16 :offset-assert 4) (num-indices uint16 :offset-assert 6) @@ -5109,9 +7156,7 @@ :size-assert #x4c :flag-assert #x90000004c ) -|# -#| (deftype light-hash-work (structure) ((ones vector4w :inline :offset-assert 0) ) @@ -5119,28 +7164,49 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (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) + (lights light 4 :inline :offset 0) ;; added ) :method-count-assert 9 :size-assert #xc0 :flag-assert #x9000000c0 ) -|# -;; (define-extern *light-hash* object) ;; light-hash +(define-extern *light-hash* light-hash) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; trail-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++trail-h:trail-node-flag +(defenum trail-node-flag + :type uint8 + :bitfield #t + (tnf0 0) ;; unused?? + (tnf1 1) + (tnf2 2) + ) +;; ---trail-h:trail-node-flag + +;; +++trail-h:conn-flag +(defenum conn-flag + :type uint8 + :bitfield #t + (cf0 0) + (cf1 1) + (cf2 2) + (cf3 3) + (cf4 4) + (cf5 5) + (cf6 6) + ) +;; ---trail-h:conn-flag + (deftype trail-node (structure) ((next-id int16 :offset-assert 0) (prev-id int16 :offset-assert 2) @@ -5151,21 +7217,20 @@ (first-conn uint16 :offset-assert 12) (cost-from-start uint16 :offset-assert 14) (cost-to-goal uint16 :offset-assert 16) - (flags uint8 :offset-assert 18) ;; trail-node-flag + (flags trail-node-flag :offset-assert 18) (conn-count uint8 :offset-assert 19) ) + :pack-me :method-count-assert 12 :size-assert #x14 :flag-assert #xc00000014 (:methods - (trail-node-method-9 () none) ;; 9 ;; (get-dist-score (_type_ vector) uint) - (trail-node-method-10 () none) ;; 10 ;; (debug-draw (_type_ int) symbol) - (trail-node-method-11 () none) ;; 11 ;; (get-position (_type_ vector) vector) + (get-dist-score (_type_ vector) uint) ;; 9 + (debug-draw (_type_ int) symbol) ;; 10 + (get-position (_type_ vector) vector) ;; 11 ) ) -|# -#| (deftype trail-visgroup (structure) ((first-node uint16 :offset-assert 0) (node-count uint8 :offset-assert 2) @@ -5175,51 +7240,46 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype trail-blocker (structure) ((plane plane :inline :offset-assert 0) (center vector :inline :offset-assert 16) - (radius-squared float :offset-assert 28) + (radius-squared float :offset-assert 28 :overlay-at (-> center w)) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| +(declare-type trail-graph basic) (deftype trail-conn (structure) ((head-id uint16 :offset-assert 0) (tail-id uint16 :offset-assert 2) - (flags uint8 :offset-assert 4) ;; conn-flag + (flags conn-flag :offset-assert 4) (visgroup-id uint8 :offset-assert 5) (cost uint16 :offset-assert 6) ) + :pack-me :method-count-assert 10 :size-assert #x8 :flag-assert #xa00000008 (:methods - (trail-conn-method-9 () none) ;; 9 ;; (debug-draw (_type_ trail-graph int) none) + (debug-draw (_type_ trail-graph int) none) ;; 9 ) ) -|# -#| (deftype trail-conn-hash-cell (structure) ((first-conn uint16 :offset-assert 0) (conn-count uint8 :offset-assert 2) (pov-count uint8 :offset-assert 3) (first-pov uint16 :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x6 :flag-assert #x900000006 ) -|# -#| (deftype trail-conn-search (structure) ((best-conn-id int32 :offset-assert 0) (best-dist float :offset-assert 4) @@ -5228,18 +7288,16 @@ (debug-cells-searched int32 :offset-assert 16) (debug-conns-searched int32 :offset-assert 20) (bounds bounding-box4w :inline :offset-assert 32) - (cell-quads qword 2 :offset-assert 64) ;; guessed by decompiler - (conn-quads qword 7 :offset-assert 96) ;; guessed by decompiler - (cell-bits vector16ub 2 :offset-assert 64) ;; guessed by decompiler - (conn-bits vector16ub 2 :offset-assert 96) ;; guessed by decompiler + (cell-quads qword 2 :inline :offset-assert 64) ;; guessed by decompiler + (conn-quads qword 7 :inline :offset-assert 96) ;; guessed by decompiler + (cell-bits vector16ub 2 :inline :offset-assert 64 :overlay-at cell-quads) ;; guessed by decompiler + (conn-bits vector16ub 2 :inline :offset-assert 96 :overlay-at conn-quads) ) :method-count-assert 9 :size-assert #xd0 :flag-assert #x9000000d0 ) -|# -#| (deftype trail-conn-hash (basic) ((cell-width meters :offset-assert 4) (origin vector :inline :offset-assert 16) @@ -5250,9 +7308,7 @@ :size-assert #x28 :flag-assert #x900000028 ) -|# -#| (deftype trail-cached-search-info (structure) ((goal-conn-id int16 :offset-assert 0) (orig-goal-pos vector :inline :offset-assert 16) @@ -5262,11 +7318,9 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype trail-cached-start-pov (structure) - ((last-updated uint64 :offset-assert 0) ;; time-frame + ((last-updated time-frame :offset-assert 0) (pov-can-see-start uint64 :offset-assert 8) (next-node-id int32 :offset-assert 16) (start-pos vector :inline :offset-assert 32) @@ -5275,9 +7329,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype trail-graph (basic) ((mode uint8 :offset-assert 4) (search-id uint32 :offset-assert 8) @@ -5294,64 +7346,74 @@ (conn-mask uint8 :offset-assert 40) (node (inline-array trail-node) :offset-assert 44) ;; guessed by decompiler (conn (inline-array trail-conn) :offset-assert 48) ;; guessed by decompiler - (blocker (inline-array trail-blocker) :offset-assert 52) ;; guessed by decompiler + (blocker (inline-array trail-blocker) :offset-assert 52) (conn-ids (pointer uint16) :offset-assert 56) ;; guessed by decompiler (visgroup (inline-array trail-conn-hash-cell) :offset-assert 60) ;; guessed by decompiler (visnode-ids (pointer uint16) :offset-assert 64) ;; guessed by decompiler (conn-hash trail-conn-hash :offset-assert 68) ;; guessed by decompiler - (cell-pov-bit-arrays (pointer uint64) :offset-assert 72) ;; guessed by decompiler + (cell-pov-bit-arrays (pointer uint64) :offset-assert 72) (pov-can-see-goal uint64 :offset-assert 80) (cached-start-pov trail-cached-start-pov :inline :offset-assert 96) (orig-start-pos vector :inline :offset-assert 144) (orig-goal-pos vector :inline :offset-assert 160) (conn-start-pos vector :inline :offset-assert 176) (conn-goal-pos vector :inline :offset-assert 192) - (open-quads qword 6 :offset-assert 208) ;; guessed by decompiler - (closed-quads qword 6 :offset-assert 304) ;; guessed by decompiler - (open-bits vector16ub 2 :offset-assert 208) ;; guessed by decompiler - (closed-bits vector16ub 2 :offset-assert 304) ;; guessed by decompiler + (open-quads qword 6 :inline :offset-assert 208) ;; guessed by decompiler + (closed-quads qword 6 :inline :offset-assert 304) ;; guessed by decompiler + (open-bits vector16ub 2 :inline :offset-assert 208 :overlay-at open-quads) + (closed-bits vector16ub 2 :inline :offset-assert 304 :overlay-at closed-quads) ) :method-count-assert 34 :size-assert #x190 :flag-assert #x2200000190 (:methods - (trail-graph-method-9 () none) ;; 9 ;; (trail-graph-method-9 (_type_ int) int) - (trail-graph-method-10 () none) ;; 10 ;; (trail-graph-method-10 (_type_ int) symbol) - (trail-graph-method-11 () none) ;; 11 ;; (trail-graph-method-11 (_type_ int int) trail-node) - (trail-graph-method-12 () none) ;; 12 ;; (trail-graph-method-12 (_type_ trail-node vector) symbol) - (trail-graph-method-13 () none) ;; 13 ;; (trail-graph-method-13 (_type_ vector vector) symbol) - (trail-graph-method-14 () none) ;; 14 ;; (debug-draw (_type_) symbol) - (trail-graph-method-15 () none) ;; 15 ;; (trail-graph-method-15 (_type_ int) symbol) - (trail-graph-method-16 () none) ;; 16 ;; (trail-graph-method-16 (_type_ int (pointer uint16) vector vector rgba float) symbol) - (trail-graph-method-17 () none) ;; 17 ;; (trail-graph-method-17 (_type_ vector vector) int) - (trail-graph-method-18 () none) ;; 18 ;; (trail-graph-method-18 (_type_ vector) int) - (trail-graph-method-19 () none) ;; 19 ;; (trail-graph-method-19 (_type_) none) - (trail-graph-method-20 () none) ;; 20 ;; (trail-graph-method-20 (_type_ uint vector) vector) - (trail-graph-method-21 () none) ;; 21 ;; (trail-graph-method-21 (_type_ (pointer uint16) int (pointer int32) (pointer float)) int) - (trail-graph-method-22 () none) ;; 22 ;; (trail-graph-method-22 (_type_ int int) symbol) - (trail-graph-method-23 () none) ;; 23 ;; (trail-graph-method-23 (_type_) symbol) - (trail-graph-method-24 () none) ;; 24 ;; (trail-graph-method-24 (_type_ uint vector int int) symbol) - (trail-graph-method-25 () none) ;; 25 ;; (trail-graph-method-25 (_type_ int) int) - (trail-graph-method-26 () none) ;; 26 ;; (trail-graph-method-26 (_type_) int) - (trail-graph-method-27 () none) ;; 27 ;; (trail-graph-method-27 (_type_) int) - (trail-graph-method-28 () none) ;; 28 ;; (trail-graph-method-28 (_type_ trail-conn-search int int) symbol) - (trail-graph-method-29 () none) ;; 29 ;; (trail-graph-method-29 (_type_ vector vector trail-cached-search-info) int) - (trail-graph-method-30 () none) ;; 30 ;; (trail-graph-method-30 (_type_) int) - (trail-graph-method-31 () none) ;; 31 ;; (trail-graph-method-31 (_type_ int) none) - (trail-graph-method-32 () none) ;; 32 ;; (trail-graph-method-32 (_type_) uint) - (trail-graph-method-33 () none) ;; 33 ;; (trail-graph-method-33 (_type_ int) symbol) + (trail-graph-method-9 (_type_ int) int) ;; 9 ;; (trail-graph-method-9 (_type_ int) none) + (trail-graph-method-10 (_type_ int) symbol) ;; 10 ;; (trail-graph-method-10 (_type_ int) none) + (trail-graph-method-11 (_type_ int int) trail-node) ;; 11 ;; (trail-graph-method-11 (_type_ int int) trail-node) + (trail-graph-method-12 (_type_ trail-node vector) symbol) ;; 12 + (trail-graph-method-13 (_type_ vector vector) symbol) ;; 13 ;; (debug-draw-cell (_type_ int) none) + (debug-draw (_type_) symbol) ;; 14 ;; (debug-draw-path (_type_ int (pointer uint16) vector vector rgba float) symbol) + (trail-graph-method-15 (_type_ int) symbol) ;; 15 ;; (do-path (_type_ vector vector) int) + (trail-graph-method-16 (_type_ int (pointer uint16) vector vector rgba float) symbol) ;; 16 ;; (trail-graph-method-16 () none) + (trail-graph-method-17 (_type_ vector vector) int) ;; 17 ;; (get-node-location-by-id (_type_ uint vector) vector) + (trail-graph-method-18 (_type_ vector) int) ;; 18 ;; (get-path-to-root (_type_ (pointer uint16) int (pointer int32) (pointer float)) int) + (trail-graph-method-19 (_type_) none) ;; 19 ;; (trail-graph-method-19 (_type_ int int) symbol) + (trail-graph-method-20 (_type_ uint vector) vector) ;; 20 ;; (try-initialize (_type_) symbol) + (trail-graph-method-21 (_type_ (pointer uint16) int (pointer int32) (pointer float)) int) ;; 21 ;; (update-node-flags-for-conn (_type_ int trail-node-flag trail-node-flag) none) + (trail-graph-method-22 (_type_ int int) symbol) ;; 22 ;; (trail-graph-method-22 (_type_ int) none) + (trail-graph-method-23 (_type_) symbol) ;; 23 ;; (reset-search-state (_type_) none) + (trail-graph-method-24 (_type_ uint vector int int) symbol) ;; 24 ;; (get-next-to-explore (_type_) int) + (trail-graph-method-25 (_type_ int) int) ;; 25 ;; (trail-graph-method-25 (_type_ trail-conn-search int int) none) + (trail-graph-method-26 (_type_) int) ;; 26 ;; (do-search! (_type_ vector vector trail-cached-search-info) none) + (trail-graph-method-27 (_type_) int) ;; 27 ;; (do-some-work (_type_) int) + (trail-graph-method-28 (_type_ trail-conn-search int int) symbol) ;; 28 ;; (run-until-done-or-timeout (_type_ int) none) + (trail-graph-method-29 (_type_ vector vector trail-cached-search-info) int) ;; 29 + (trail-graph-method-30 (_type_) int) ;; 30 + (trail-graph-method-31 (_type_ int) none) ;; 31 + (trail-graph-method-32 (_type_) uint) ;; 32 + (trail-graph-method-33 (_type_ int) symbol) ;; 33 ) ) -|# -;; (define-extern *trail-graph* object) ;; trail-graph +(define-extern *trail-graph* trail-graph) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; connect ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype connectable (structure) + "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`." ((next0 connectable :offset-assert 0) (prev0 connectable :offset-assert 4) (next1 connectable :offset-assert 8) @@ -5361,172 +7423,203 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| +(declare-type engine basic) + (deftype connection (connectable) + "This is the actual data for the connection. + It may be used in multiple ways, but the most common is to use `param0` as a function. + It receives `param1`, `param2`, `param3`, and the engine as the arguments. + In some cases, the return value is checked for `'dead`." ((param0 basic :offset-assert 16) (param1 basic :offset-assert 20) (param2 int32 :offset-assert 24) ;; guessed by decompiler (param3 int32 :offset-assert 28) ;; guessed by decompiler - (quad uint128 2 :offset-assert 0) ;; guessed by decompiler + (quad uint128 2 :offset 0) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x20 :flag-assert #xe00000020 ;; field param1 uses ~A with a signed load. field param2 uses ~A with a signed load. field param3 uses ~A with a signed load. (:methods - (connection-method-9 () none) ;; 9 ;; (get-engine (connection) engine) - (connection-method-10 () none) ;; 10 ;; (get-process (connection) process) - (connection-method-11 () none) ;; 11 ;; (belongs-to-engine? (connection engine) symbol) - (connection-method-12 () none) ;; 12 ;; (belongs-to-process? (connection process) symbol) - (connection-method-13 () none) ;; 13 ;; (move-to-dead (connection) connection) + (get-engine + "Get the engine for this connection. This must be used on a live connection." + (connection) engine) ;; 9 + (get-process "Get the process for this connection." (connection) process) ;; 10 + (belongs-to-engine? + "Check to see if this connection is located in the data section of the engine. + This works on dead or alive connections." + (connection engine) symbol) ;; 11 + (belongs-to-process? "Does this connection belong to the given process?" (connection process) symbol) ;; 12 + (move-to-dead "Move this connection from the alive list to the dead list." (connection) connection) ;; 13 ) ) -|# -#| (deftype engine (basic) + "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. + + New for Jak 2: You can use a child class of [[connection]]." ((name symbol :offset-assert 4) ;; guessed by decompiler - (engine-time uint64 :offset-assert 16) ;; time-frame - (allocated-length int16 :offset-assert 10) - (length int16 :offset-assert 8) - (element-type type :offset-assert 12) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (data connection :dynamic :offset-assert 96) ;; guessed by decompiler + (engine-time time-frame :offset 16) ;; time-frame + (allocated-length int16 :offset 10) + (length int16 :offset 8) + (element-type type :offset 12) ;; guessed by decompiler + (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) + (data connection :inline :dynamic :offset-assert 96) ;; guessed by decompiler ) :method-count-assert 26 :size-assert #x60 :flag-assert #x1a00000060 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type symbol int type) _type_) - (engine-method-9 () none) ;; 9 ;; (inspect-all-connections (engine) engine) - (engine-method-10 () none) ;; 10 ;; (apply-to-connections (engine (function connectable none)) int) - (engine-method-11 () none) ;; 11 ;; (apply-to-connections-reverse (engine (function connectable none)) int) - (engine-method-12 () none) ;; 12 ;; (execute-connections (engine object) int) - (engine-method-13 () none) ;; 13 ;; (execute-connections-and-move-to-dead (engine object) int) - (engine-method-14 () none) ;; 14 ;; (execute-connections-if-needed (engine object) int) - (engine-method-15 () none) ;; 15 ;; (add-connection (engine process object object object object) connection) - (engine-method-16 () none) ;; 16 ;; (remove-from-process (engine process) int) - (engine-method-17 () none) ;; 17 ;; (remove-matching (engine (function connection engine symbol)) int) - (engine-method-18 () none) ;; 18 ;; (remove-all (engine) int) - (engine-method-19 () none) ;; 19 ;; (remove-by-param0 (engine object) int) - (engine-method-20 () none) ;; 20 ;; (remove-by-param1 (engine int) int) - (engine-method-21 () none) ;; 21 ;; (remove-by-param2 (engine int) int) - (engine-method-22 () none) ;; 22 ;; (get-first-connectable (engine) connectable) - (engine-method-23 () none) ;; 23 ;; (get-last-connectable (engine) connectable) - (engine-method-24 () none) ;; 24 ;; (get-next-connectable (_type_ connectable) connectable) - (engine-method-25 () none) ;; 25 ;; (get-prev-connectable (_type_ connectable) connectable) + (new (symbol type symbol int type) _type_) ;; 0 + (inspect-all-connections "inspect all of the connections." (engine) engine) ;; 9 + (apply-to-connections + "Apply arg0 to all connections for the engine. + It's okay to have arg0 remove the connection." + (engine (function connectable none)) int) ;; 10 + (apply-to-connections-reverse + "Apply arg0 to all connections, reverse order. + Do not use arg0 to remove yourself from the list." + (engine (function connectable none)) int) ;; 11 + (execute-connections "Run the engine!" (engine object) int) ;; 12 + (execute-connections-and-move-to-dead + "Run the engine! If any objects return `'dead`, remove them." + (engine object) int) ;; 13 + (execute-connections-if-needed + "Execute connections, but only if it hasn't been done on this frame." + (engine object) int) ;; 14 + (add-connection + "Add a connection between this engine and a given process." + (engine process object object object object) connection) ;; 15 + (remove-from-process "Remove all connections from process for this engine." (engine process) int) ;; 16 + (remove-matching + "Call the given function on each connection and the engine. + If it returns truthy, `move-to-dead` that connection." + (engine (function connection engine symbol)) int) ;; 17 + (remove-all "Remove all connections from an engine." (engine) int) ;; 18 + (remove-by-param0 "Remove all connections with param0 matching arg0." (engine object) int) ;; 19 + (remove-by-param1 "Remove all connections with param1 matching arg0." (engine int) int) ;; 20 + (remove-by-param2 "Remove all connections with param2 matching arg0." (engine int) int) ;; 21 + (get-first-connectable (engine) connectable) ;; 22 + (get-last-connectable (engine) connectable) ;; 23 + (get-next-connectable (_type_ connectable) connectable) ;; 24 + (get-prev-connectable (_type_ connectable) connectable) ;; 25 ) ) -|# -#| (deftype connection-pers (structure) + "This is another engine system, very similar to the first, but not specific to a process. + Each connection has a `key`, which is like the process, but unlike normal engine, + the key's don't track which engine-pers they belong to. + + Unlike [[engine]], users can use [[engine-pers]] as a parent class." ((next connection-pers :offset-assert 0) - (key object :offset-assert 4) ;; guessed by decompiler - (update-time uint64 :offset-assert 8) ;; time-frame - (param object 4 :offset-assert 16) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (param-int32 int32 4 :offset-assert 16) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (param-int64 int64 2 :offset-assert 16) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (param-float float 4 :offset-assert 16) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (param-quat uint128 :offset-assert 16) + (key object :offset-assert 4) + (update-time time-frame :offset-assert 8) + (param object 4 :offset-assert 16) + (param-int32 int32 4 :offset 16) + (param-int64 int64 2 :offset 16) + (param-float float 4 :offset 16) + (param-quat uint128 :offset 16) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ;; field key uses ~A with a signed load. ) -|# -#| (deftype engine-pers (basic) - ((name symbol :offset-assert 4) ;; guessed by decompiler - (length int16 :offset-assert 8) - (allocated-length int16 :offset-assert 10) - (element-type type :offset-assert 12) ;; guessed by decompiler - (execute-time uint64 :offset-assert 16) ;; time-frame - (alive-list connection-pers :offset-assert 24) - (dead-list connection-pers :offset-assert 28) - (data connection-pers :dynamic :offset-assert 32) ;; guessed by decompiler + ((name symbol :offset-assert 4) ;; guessed by decompiler + (length int16 :offset-assert 8) + (allocated-length int16 :offset-assert 10) + (element-type type :offset-assert 12) ;; guessed by decompiler + (execute-time time-frame :offset-assert 16) ;; time-frame + (alive-list connection-pers :offset-assert 24) + (dead-list connection-pers :offset-assert 28) + (data connection-pers :inline :dynamic :offset-assert 32) ;; guessed by decompiler ) :method-count-assert 15 :size-assert #x20 :flag-assert #xf00000020 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type symbol int type) _type_) - (engine-pers-method-9 () none) ;; 9 ;; (schedule-callback (_type_ object time-frame) connection-pers) - (engine-pers-method-10 () none) ;; 10 ;; (kill-callback (_type_ connection-pers) none) - (engine-pers-method-11 () none) ;; 11 ;; (kill-by-key (_type_ object) none) - (engine-pers-method-12 () none) ;; 12 ;; (kill-matching (_type_ (function engine-pers connection-pers object object symbol) object object) none) - (engine-pers-method-13 () none) ;; 13 ;; (update-callback (_type_) none) - (engine-pers-method-14 () none) ;; 14 ;; (run-pending-updates! (_type_ time-frame) none) + (new (symbol type symbol int type) _type_) ;; 0 + (schedule-callback + "Get a connection for this key. + If no connection exists, add it. + Schedule an update to happen in arg1 seconds." + (_type_ object time-frame) connection-pers) ;; 9 + (kill-callback "Called when a connection is removed." (_type_ connection-pers) none) ;; 10 + (kill-by-key "Remove connections with this key, calling `kill-callback`." (_type_ object) none) ;; 11 + (kill-matching + "Call the given function on each connection. If it returns truthy, kill that connection." + (_type_ (function engine-pers connection-pers object object symbol) object object) none) ;; 12 + (update-callback + "Called when a connection is run. + Users can override this as needed." + (_type_) none) ;; 13 + (run-pending-updates! + "Run updates if they scheduled. If something is found that has no pending update, kill it. + Note that we won't kill things on this call if they fail to update their `update-time`. + They will survive until the next call to `run-pending-updates`! + (or you can modify their `update-time` before that to prevent them from being killed.)" + (_type_ time-frame) none) ;; 14 ) ) -|# -;; (define-extern connection-process-apply function) ;; (function process (function object none) symbol) -;; (define-extern process-disconnect function) ;; (function process int) +(define-extern connection-process-apply + "Apply a function to all connectables of a process." + (function process (function object none) symbol)) +(define-extern process-disconnect "Disconnect all connections for the given process." (function process int)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; mood-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype mood-channel (structure) ((data float 24 :offset-assert 0) ;; guessed by decompiler - (vecs vector4 6 :offset-assert 0) ;; guessed by decompiler + (vecs vector4 6 :inline :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x60 :flag-assert #x900000060 ) -|# -#| (deftype mood-channel-group (structure) - ((data mood-channel 4 :offset-assert 0) ;; guessed by decompiler + ((data mood-channel 4 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x180 :flag-assert #x900000180 ) -|# -#| (deftype mood-fog (structure) ((fog-color vector :inline :offset-assert 0) (fog-dists vector :inline :offset-assert 16) - (fog-start meters :offset-assert 16) - (fog-end meters :offset-assert 20) - (fog-max float :offset-assert 24) - (fog-min float :offset-assert 28) + (fog-start meters :offset-assert 16 :overlay-at (-> fog-dists x)) + (fog-end meters :offset-assert 20 :overlay-at (-> fog-dists y)) + (fog-max float :offset-assert 24 :overlay-at (-> fog-dists z)) + (fog-min float :offset-assert 28 :overlay-at (-> fog-dists w)) (erase-color vector :inline :offset-assert 32) ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype mood-fog-table (structure) - ((data mood-fog 8 :offset-assert 0) ;; guessed by decompiler + ((data mood-fog 8 :inline :offset-assert 0) ;; guessed by decompiler + (_data uint128 24 :offset 0 :score -1) ) :method-count-assert 9 :size-assert #x180 :flag-assert #x900000180 ) -|# -#| (deftype mood-color (structure) ((lgt-color vector :inline :offset-assert 0) (amb-color vector :inline :offset-assert 16) @@ -5535,39 +7628,32 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype mood-direction-table (structure) - ((data vector 4 :offset-assert 0) ;; guessed by decompiler + ((data vector 4 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype mood-color-table (structure) - ((data mood-color 8 :offset-assert 0) ;; guessed by decompiler + ((data mood-color 8 :inline :offset-assert 0) ;; guessed by decompiler + (_data uint128 16 :offset 0 :score -1) ) :method-count-assert 9 :size-assert #x100 :flag-assert #x900000100 ) -|# -#| (deftype mood-sky-table (structure) - ((data vector 8 :offset-assert 0) ;; guessed by decompiler + ((data vector 8 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype mood-clouds (structure) ((cloud-min float :offset-assert 0) (cloud-max float :offset-assert 4) @@ -5576,58 +7662,52 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype mood-weather (structure) ((data float 2 :offset-assert 0) ;; guessed by decompiler - (cloud float :offset-assert 0) - (fog float :offset-assert 4) + (cloud float :offset 0) + (fog float :offset 4) ) + :pack-me + :allow-misaligned :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype mood-iweather (structure) ((data int32 2 :offset-assert 0) ;; guessed by decompiler - (cloud int32 :offset-assert 0) - (fog int32 :offset-assert 4) + (cloud int32 :offset 0) + (fog int32 :offset 4) ) + :allow-misaligned :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype mood-range (structure) - ((data float 4 :offset-assert 0) ;; guessed by decompiler - (min-cloud float :offset-assert 0) - (max-cloud float :offset-assert 4) - (min-fog float :offset-assert 8) - (max-fog float :offset-assert 12) - (quad uint128 :offset-assert 0) + ((data float 4 :offset-assert 0 :score -1) ;; guessed by decompiler + (min-cloud float :offset 0) + (max-cloud float :offset 4) + (min-fog float :offset 8) + (max-fog float :offset 12) + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype mood-filters-table (structure) - ((data vector 8 :offset-assert 0) ;; guessed by decompiler + ((data vector 8 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ) -|# -#| +(declare-type sky-color-day structure) (deftype mood-table (basic) ((mood-fog-table mood-fog-table :offset-assert 4) (mood-color-table mood-color-table :offset-assert 8) @@ -5640,31 +7720,27 @@ :size-assert #x1c :flag-assert #x90000001c ) -|# -#| (deftype light-state (structure) ((time float :offset-assert 0) (fade float :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype flicker-state (structure) ((flicker-off uint8 :offset-assert 0) (flicker-on uint8 :offset-assert 1) ) + :allow-misaligned :method-count-assert 9 :size-assert #x2 :flag-assert #x900000002 ) -|# -#| (deftype florescent-state (structure) ((value float :offset-assert 0) (delay int8 :offset-assert 4) @@ -5674,33 +7750,29 @@ :size-assert #x6 :flag-assert #x900000006 ) -|# -#| (deftype electricity-state (structure) ((value float :offset-assert 0) (scale float :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype pulse-state (structure) ((pulse float :offset-assert 0) (brightness float :offset-assert 4) (target-brightness float :offset-assert 8) (speed float :offset-assert 12) ) + :pack-me :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype strobe-state (structure) ((time float :offset-assert 0) ) @@ -5708,22 +7780,19 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype flames-state (structure) ((time float :offset-assert 0) (index uint8 :offset-assert 4) (length uint8 :offset-assert 5) (height uint8 :offset-assert 6) ) + :pack-me :method-count-assert 9 :size-assert #x7 :flag-assert #x900000007 ) -|# -#| (deftype mood-context-core (structure) ((current-fog mood-fog :inline :offset-assert 0) (current-sky-color vector :inline :offset-assert 48) @@ -5735,40 +7804,33 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype mood-context-core2 (mood-context-core) - ((light-group light-group 8 :offset-assert 112) ;; guessed by decompiler + ((light-group light-group 8 :inline :offset-assert 112) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x670 :flag-assert #x900000670 ) -|# -#| (deftype mood-context-core3 (mood-context-core2) - ((times vector 8 :offset-assert 1648) ;; guessed by decompiler + ((times vector 8 :inline :offset-assert 1648) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x6f0 :flag-assert #x9000006f0 ) -|# -#| (deftype mood-context (mood-context-core3) - ((itimes vector4w 4 :offset-assert 1776) ;; guessed by decompiler + ((itimes vector4w 4 :inline :offset-assert 1776) ;; guessed by decompiler (state uint32 32 :offset-assert 1840) ;; guessed by decompiler + (data uint128 123 :offset 0 :score -1) ) :method-count-assert 9 :size-assert #x7b0 :flag-assert #x9000007b0 ) -|# -#| (deftype mood-control-work (structure) ((color vector4w :inline :offset-assert 0) (weather mood-weather :inline :offset-assert 16) @@ -5786,9 +7848,7 @@ :size-assert #x5c :flag-assert #x90000005c ) -|# -#| (deftype mood-control (mood-table) ((mood-clouds mood-clouds :offset-assert 28) (current-interp mood-weather :inline :offset-assert 32) @@ -5802,8 +7862,9 @@ (target-special-interp float :offset-assert 108) (rate-special-interp float :offset-assert 112) (display-flag symbol :offset-assert 116) ;; guessed by decompiler - (override-weather-flag basic :offset-assert 120) - (override mood-weather :inline :offset-assert 128) + (overide-weather-flag symbol :offset-assert 120) ;; guessed by decompiler + (pad int32 :offset-assert 124) + (overide mood-weather :inline :offset-assert 128) (lightning-index int32 :offset-assert 136) (lightning-val int32 :offset-assert 140) (lightning-time int32 :offset-assert 144) @@ -5825,32 +7886,119 @@ :size-assert #x118 :flag-assert #x1900000118 (:methods - (mood-control-method-9 () none) ;; 9 ;; (init-weather! (_type_) none) - (mood-control-method-10 () none) ;; 10 ;; (set-cloud-and-fog-interp! (_type_ float float float float) none) - (mood-control-method-11 () none) ;; 11 ;; (update-mood-range! (_type_ float float float float) none) - (mood-control-method-12 () none) ;; 12 ;; (set-time-for-random-weather! (_type_ float float) none) - (mood-control-method-13 () none) ;; 13 ;; (set-special-interps! (_type_ float float symbol) none) - (mood-control-method-14 () none) ;; 14 ;; (weather-event-concluded? (_type_) symbol) - (mood-control-method-15 () none) ;; 15 ;; (set-lightning-time! (_type_ int int float) none) - (mood-control-method-16 () none) ;; 16 ;; (apply-mood-clouds-and-fog (_type_ mood-control-work) none) - (mood-control-method-17 () none) ;; 17 ;; (apply-mood-fog (_type_ mood-control-work mood-color-table mood-color-table mood-color-table float) none) - (mood-control-method-18 () none) ;; 18 ;; (apply-fog-height (_type_ mood-control-work float float float float) none) - (mood-control-method-19 () none) ;; 19 ;; (apply-mood-colors (_type_ mood-control-work) none) - (mood-control-method-20 () none) ;; 20 ;; (mood-control-method-20 (_type_ mood-control-work mood-color-table mood-color-table mood-color-table float) none) - (mood-control-method-21 () none) ;; 21 ;; (apply-mood-channels (_type_ mood-control-work) none) - (mood-control-method-22 () none) ;; 22 ;; (adjust-num-clouds (_type_ mood-control-work) none) - (mood-control-method-23 () none) ;; 23 ;; (gen-lightning-and-thunder! (_type_ int) none) - (mood-control-method-24 () none) ;; 24 ;; (play-or-stop-lightning-sfx! (_type_ sound-spec vector) none) + (init-weather! (_type_) none) ;; 9 + (set-cloud-and-fog-interp! (_type_ float float float float) none) ;; 10 ;; (update-mood-weather! (_type_ float float float float) none) + (update-mood-range! (_type_ float float float float) none) ;; 11 + (set-time-for-random-weather! (_type_ float float) none) ;; 12 + (set-special-interps! + "Sets the `*-special-interp` values with the given values + @param! this The [[mood-control]] + @param target-interp Clamped between 0.0 and 1.0 + @param rate-interp Value to set [[this::rate-special-interp]] + @param set-current-interp? Uses `target-interp` to set [[this::current-special-interp] + @returns [[none]]" + (_type_ float float symbol) none) ;; 13 + (weather-event-concluded? ;; TODO - guess at name + "@returns [[#t]] if [[this::override-weather-flag]] is set, we aren't in a cutscene and [[this::current-special-interp]] is equal to `0.0`" + (_type_) symbol) ;; 14 ;; (apply-mood-color (_type_ mood-control-work) none) + (set-lightning-time! (_type_ int int float) none) ;; 15 ;; (apply-mood-channels (_type_ mood-control-work) none) + (apply-mood-clouds-and-fog (_type_ mood-control-work) none) ;; 16 ;; (adjust-num-clouds! (_type_ mood-control-work) none) + (apply-mood-fog (_type_ mood-control-work mood-color-table mood-color-table mood-color-table float) none) ;; 17 + (apply-fog-height (_type_ mood-control-work float float float float) none) ;; 18 + (apply-mood-colors (_type_ mood-control-work) none) ;; 19 + (mood-control-method-20 (_type_ mood-control-work mood-color-table mood-color-table mood-color-table float) none) ;; 20 + (apply-mood-channels (_type_ mood-control-work) none) ;; 21 + (adjust-num-clouds (_type_ mood-control-work) none) ;; 22 + (gen-lightning-and-thunder! (_type_ int) none) ;; 23 + (play-or-stop-lightning-sfx! (_type_ sound-spec vector) none) ;; 24 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; level-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type bsp-header basic) + +;; +++level-h:vis-info-flag +(defenum vis-info-flag + :type uint32 + :bitfield #t + (dummy0 0) + (dummy1 1) + (dummy2 2) + (dummy3 3) + (dummy4 4) + (dummy5 5) + (dummy6 6) + (dummy7 7) + (dummy8 8) + (dummy9 9) + (dummy10 10) + (dummy11 11) + (dummy12 12) + (dummy13 13) + (dummy14 14) + (dummy15 15) + (dummy16 16) + (dummy17 17) + (dummy18 18) + (dummy19 19) + (dummy20 20) + (dummy21 21) + (dummy22 22) + (dummy23 23) + (dummy24 24) + (dummy25 25) + (dummy26 26) + (dummy27 27) + (dummy28 28) + (in-iop 29) + (loading 30) + (vis-valid 31) + ) +;; ---level-h:vis-info-flag + +;; +++level-h:task-mask +(defenum task-mask + :type uint32 + :bitfield #t + (task0 0) + (task1 1) + (task2 2) + (task3 3) + (task4 4) + (task5 5) + (task6 6) + (task7 7) + (done 8) + (dummy0 9) + (network 10) + (vehicle 11) + (special 12) + (primary0 13) + (ctywide 14) + (never 15) + (movie0 16) + (movie1 17) + (movie2 18) + (tm19 19) + (tm20 20) + (tm21 21) + (tm22 22) + (tm23 23) + (tm24 24) + (tm25 25) + (tm26 26) + (tm27 27) + (tm28 28) + (tm29 29) + (tm30 30) + (tm31 31) +) +;; ---level-h:task-mask + (deftype level-vis-info (basic) ((level level :offset-assert 4) ;; guessed by decompiler (from-level symbol :offset-assert 8) ;; guessed by decompiler @@ -5870,29 +8018,78 @@ :size-assert #x4c :flag-assert #x90000004c ) -|# -#| (deftype level-borrow-info (basic) ((borrow-size uint16 3 :offset-assert 4) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (borrow-info object 3 :offset-assert 12) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. ) :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| +;; +++level-h:level-flags +(defenum level-flags + :type uint32 + :bitfield #t + (lf0 0) + (not-physical 1) + (ctycar 2) + (ctypes 3) + (external 4) + (title 5) + (borrow-load 6) + (end-mode 7) + (flut 8) + (sky 9) + (use-camera-other 10) + (display-wait 11) + (ocean-near-translucent 12) + (ocean-far 13) + (low-res-hfrag 14) + (city-borrow-available 15) + (mech 16) + (allow-unloaded 17) + (check-taskname-for-continue 18) + (city-borrow-high-priority 19) + (ocean-all 20) + (desert 21) + ) +;; ---level-h:level-flags + +;; +++level-h:level-memory-mode +(defenum level-memory-mode + :type uint32 + (micro 0) + (tiny 1) + (tiny-edge 2) + (tiny-center 3) + (small-edge 4) + (small-center 5) + (city-center 6) + (medium 7) + (large 8) + (alias 9) + (borrow 10) + (borrow0 11) + (borrow1 12) + (borrow2 13) + (borrow3 14) + (borrow4 15) + (borrow-city-small 16) + (tiny-center-small 17) + (tiny-center-micro 18) + (city-tiny-edge 19) + ) +;; ---level-h:level-memory-mode + (deftype level-load-info (basic) - ((name-list symbol 4 :offset-assert 4) ;; guessed by decompiler - (name symbol :offset-assert 4) ;; guessed by decompiler - (visname symbol :offset-assert 8) ;; guessed by decompiler - (nickname symbol :offset-assert 12) ;; guessed by decompiler - (dbname symbol :offset-assert 4) ;; guessed by decompiler - (taskname symbol :offset-assert 16) ;; guessed by decompiler + ((name-list symbol 4 :offset-assert 4 :score -1) ;; guessed by decompiler + (name symbol :offset 4) ;; guessed by decompiler + (visname symbol :offset 8) ;; guessed by decompiler + (nickname symbol :offset 12) ;; guessed by decompiler + (dbname symbol :offset 4) ;; guessed by decompiler + (taskname symbol :offset 16) ;; guessed by decompiler (index int16 :offset-assert 20) (task-level uint8 :offset-assert 22) (race-minimap uint8 :offset-assert 23) @@ -5921,9 +8118,9 @@ (level-load-info-method-10 () none) ;; 10 ;; (get-callback-by-slot! (_type_ int) object) ) ) -|# -#| +(declare-type drawable basic) + (deftype login-state (basic) ((state int32 :offset-assert 4) (pos uint32 :offset-assert 8) @@ -5934,9 +8131,12 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| +(declare-type entity-links-array inline-array-class) +(declare-type light-hash basic) +(declare-type engine basic) +(declare-type game-text-info structure) +(declare-type text-id uint32) (deftype level (basic) ((name symbol :offset-assert 4) ;; guessed by decompiler (load-name symbol :offset-assert 8) ;; guessed by decompiler @@ -5944,20 +8144,28 @@ (index int32 :offset-assert 16) (status symbol :offset-assert 20) ;; guessed by decompiler (borrow-level level 3 :offset-assert 24) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (borrow-from-level level :offset-assert 36) ;; guessed by decompiler (heap kheap :inline :offset-assert 48) - (borrow-heap kheap 3 :offset-assert 64) ;; guessed by decompiler + (borrow-heap kheap 3 :inline :offset-assert 64) ;; guessed by decompiler (bsp bsp-header :offset-assert 112) ;; guessed by decompiler (art-group load-dir-art-group :offset-assert 116) ;; guessed by decompiler (info level-load-info :offset-assert 120) ;; guessed by decompiler - (texture-page-dir UNKNOWN 11 :offset-assert 128) + (level-TODO-01 int32 :offset-assert 124) + (texture-page-dir texture-page-segment 11 :inline :offset-assert 128) ;; TODO - a guess, seems to fit though (loaded-texture-page texture-page 16 :offset-assert 260) ;; guessed by decompiler (loaded-texture-page-count int32 :offset-assert 324) (entity entity-links-array :offset-assert 328) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ;; copied from jak3 + (closest-object meters 10 :offset-assert 332) + (tie-min-dist float :offset 376) + (fg-tfrag-min-dist float :offset-assert 380) + (fg-prim-min-dist float :offset-assert 384) + (fg-shrub-min-dist float :offset-assert 388) + (fg-warp-min-dist float :offset 396) + (fg-prim2-min-dist float :offset 404) + ;; end copy (upload-size int32 19 :offset-assert 408) ;; guessed by decompiler - (inside-boxes? basic :offset-assert 484) + (inside-boxes? symbol :offset-assert 484) (display? symbol :offset-assert 488) ;; guessed by decompiler (render? symbol :offset-assert 492) ;; guessed by decompiler (meta-inside? symbol :offset-assert 496) ;; guessed by decompiler @@ -5973,7 +8181,7 @@ (vis-info level-vis-info 8 :offset-assert 540) ;; guessed by decompiler (vis-self-index int32 :offset-assert 572) (vis-adj-index int32 :offset-assert 576) - (vis-buffer uint8 :offset-assert 580) ;; guessed by decompiler + (vis-buffer uint32 :offset-assert 580) ;; guessed by decompiler (mem-usage-block memory-usage-block :offset-assert 584) ;; guessed by decompiler (mem-usage int32 :offset-assert 588) (code-memory-start pointer :offset-assert 592) ;; guessed by decompiler @@ -5985,11 +8193,13 @@ (load-buffer-last dgo-header :offset-assert 628) (load-buffer-mode level-memory-mode :offset-assert 632) ;; guessed by decompiler (display-start-time uint64 :offset-assert 640) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (memory-mask uint32 :offset-assert 648) (task-mask task-mask :offset-assert 652) - (tfrag-gs-test uint64 :offset-assert 656) ;; gs-test - (texture-dirty-masks texture-mask 11 :offset-assert 672) ;; guessed by decompiler - (texture-mask texture-mask 19 :offset-assert 848) ;; guessed by decompiler + (tfrag-gs-test gs-test :offset-assert 656) ;; gs-test + (level-TODO-003 int32 :offset-assert 664) + (level-TODO-004 int32 :offset-assert 668) + (texture-dirty-masks texture-mask 11 :inline :offset-assert 672) ;; guessed by decompiler + (texture-mask texture-mask 19 :inline :offset-assert 848) ;; guessed by decompiler (tfrag-last-calls uint32 6 :offset-assert 1152) ;; guessed by decompiler (texture-anim-array texture-anim-array 11 :offset-assert 1176) ;; guessed by decompiler (light-hash light-hash :offset-assert 1220) ;; guessed by decompiler @@ -5997,15 +8207,14 @@ (draw-index int32 :offset-assert 1228) (part-engine engine :offset-assert 1232) ;; guessed by decompiler (user-object basic 4 :offset-assert 1236) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (loaded-text-info-count int32 :offset-assert 1252) (loaded-text-info game-text-info 16 :offset-assert 1256) ;; guessed by decompiler (level-type type :offset-assert 1320) ;; guessed by decompiler (load-order uint64 :offset-assert 1328) (slot int32 :offset-assert 1336) (filter-num uint32 :offset-assert 1340) - (filter-name UNKNOWN 16 :offset-assert 1344) - (filter-look UNKNOWN 16 :offset-assert 1408) + (filter-name string 16 :offset-assert 1344) + (filter-look uint8 16 :offset-assert 1408) (buffer kheap :offset-assert 1424) ) :method-count-assert 30 @@ -6035,11 +8244,13 @@ (level-method-29 () none) ;; 29 ;; (vis-clear (_type_) none) ) ) -|# -#| (deftype level-group (basic) ((length int32 :offset-assert 4) + ;; copied from jak 3 + (log-in-level-bsp bsp-header) + (loading-level level) + ;; end copy (entity-link entity-links :offset-assert 16) (border? symbol :offset-assert 20) ;; guessed by decompiler (vis? symbol :offset-assert 24) ;; guessed by decompiler @@ -6047,20 +8258,15 @@ (receiving-level basic :offset-assert 32) (load-commands pair :offset-assert 36) ;; guessed by decompiler (play? symbol :offset-assert 40) ;; guessed by decompiler - (prev-target-pos UNKNOWN 2 :offset-assert 48) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (curr-target-pos UNKNOWN 2 :offset-assert 80) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (prev-camera-pos UNKNOWN 2 :offset-assert 112) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (curr-camera-pos UNKNOWN 2 :offset-assert 144) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (prev-target-pos vector 2 :inline :offset-assert 48) + (curr-target-pos vector 2 :inline :offset-assert 80) + (prev-camera-pos vector 2 :inline :offset-assert 112) + (curr-camera-pos vector 2 :inline :offset-assert 144) (heap kheap :inline :offset-assert 176) (car-heap kheap :inline :offset-assert 192) (driver-heap kheap :inline :offset-assert 208) (cars-heap kheap :inline :offset-assert 224) - (sound-bank sound-bank-state 7 :offset-assert 240) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (sound-bank sound-bank-state 7 :inline :offset-assert 240) ;; guessed by decompiler (disk-load-timing? symbol :offset-assert 352) ;; guessed by decompiler (load-level symbol :offset-assert 356) ;; guessed by decompiler (load-size uint32 :offset-assert 360) @@ -6068,34 +8274,36 @@ (load-login-time float :offset-assert 368) (draw-level-count int32 :offset-assert 372) (draw-level level 19 :offset-assert 376) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (draw-index-map uint8 19 :offset-assert 452) ;; guessed by decompiler (shared-ties basic :offset-assert 472) (status-cache-sync uint16 :offset-assert 476) (load-order uint64 :offset-assert 480) - (wide-level UNKNOWN 2 :offset-assert 488) + (wide-level level 2 :offset-assert 488) (tfrag-login-level basic :offset-assert 496) - (level level 19 :offset-assert 548) ;; guessed by decompiler - (data UNKNOWN 19 :offset-assert 548) - (level0 level :inline :offset-assert 548) - (level1 level :inline :offset-assert 1988) - (level2 level :inline :offset-assert 3428) - (level3 level :inline :offset-assert 4868) - (level4 level :inline :offset-assert 6308) - (level5 level :inline :offset-assert 7748) - (car0 level :inline :offset-assert 9188) - (car1 level :inline :offset-assert 10628) - (car2 level :inline :offset-assert 12068) - (car3 level :inline :offset-assert 13508) - (car4 level :inline :offset-assert 14948) - (car5 level :inline :offset-assert 16388) - (driver0 level :inline :offset-assert 17828) - (driver1 level :inline :offset-assert 19268) - (driver2 level :inline :offset-assert 20708) - (driver3 level :inline :offset-assert 22148) - (driver4 level :inline :offset-assert 23588) - (driver5 level :inline :offset-assert 25028) - (level-default level :inline :offset-assert 26468) + (level-group-TODO-001 int32 11 :offset-assert 500) ;; added + (level level 19 :inline :offset 544) ;; offset adjusted + ;; (data UNKNOWN 19 :offset-assert 548) + (level0 level :inline :offset 548 :overlay-at (-> level 0)) + + (level1 level :inline :offset 1988 :overlay-at (-> level 1)) + (level2 level :inline :offset 3428 :overlay-at (-> level 2)) + (level3 level :inline :offset 4868 :overlay-at (-> level 3)) + (level4 level :inline :offset 6308 :overlay-at (-> level 4)) + (level5 level :inline :offset 7748 :overlay-at (-> level 5)) + (car0 level :inline :offset 9188 :overlay-at (-> level 6)) + (car1 level :inline :offset 10628 :overlay-at (-> level 7)) + (car2 level :inline :offset 12068 :overlay-at (-> level 8)) + (car3 level :inline :offset 13508 :overlay-at (-> level 9)) + (car4 level :inline :offset 14948 :overlay-at (-> level 10)) + (car5 level :inline :offset 16388 :overlay-at (-> level 11)) + (driver0 level :inline :offset 17828 :overlay-at (-> level 12)) + (driver1 level :inline :offset 19268 :overlay-at (-> level 13)) + (driver2 level :inline :offset 20708 :overlay-at (-> level 14)) + (driver3 level :inline :offset 22148 :overlay-at (-> level 15)) + (driver4 level :inline :offset 23588 :overlay-at (-> level 16)) + (driver5 level :inline :offset 25028 :overlay-at (-> level 17)) + (level-default level :inline :offset 26468 :overlay-at (-> level 18)) + (pad int32) ;; added ) :method-count-assert 34 :size-assert #x6d04 @@ -6128,44 +8336,78 @@ (level-group-method-33 () none) ;; 33 ) ) -|# -;; (define-extern *level* level-group) ;; level-group -;; (define-extern *draw-index* object) ;; int -;; (define-extern *level-index* object) ;; int -;; (define-extern *city-mode* object) ;; symbol -;; (define-extern *lobby-levels* array) -;; (define-extern *lobby-levels-display* array) -;; (define-extern *lobby-levels-tmp* array) +(define-extern *level* level-group) ;; level-group +(define-extern *draw-index* int) +(define-extern *level-index* int) +(define-extern *city-mode* symbol) +(define-extern *lobby-levels* (array symbol)) +(define-extern *lobby-levels-display* (array symbol)) +(define-extern *lobby-levels-tmp* (array symbol)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; minimap-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++minimap-h:minimap-flag +(defenum minimap-flag + :type uint32 + :bitfield #t + (active 0) + (minimap 1) + (fade-in 2) + (fade-out 3) + (task-graph 4) + (flash 5) + (racer 6) + ) +;; ---minimap-h:minimap-flag + +;; +++minimap-h:minimap-class +(defenum minimap-class + :type uint16 + (none 0) + (racer-0 1) + (racer-1 2) + (racer-2 3) + (racer-3 4) + (racer-4 5) + (racer-5 6) + (racer-6 7) + (raptor 8) + (goal 9) + (red-flag 10) + (blue-flag 11) + (neutral-flag 12) + (success-seeker 13) + (chicken-drone 14) +) +;; ---minimap-h:minimap-class + (deftype minimap-class-node (structure) ((default-position vector :inline :offset-assert 0) (flags minimap-flag :offset-assert 16) - (name string :offset-assert 20) ;; guessed by decompiler + (name string :offset-assert 20) (icon-xy vector2ub :inline :offset-assert 24) - (class uint16 :offset-assert 26) ;; minimap-class + (class minimap-class :offset-assert 26) ;; minimap-class (scale float :offset-assert 28) (color rgba :offset-assert 32) ;; guessed by decompiler ) - :method-count-assert 9 + :method-count-assert 10 :size-assert #x24 - :flag-assert #x900000024 + :flag-assert #xa00000024 + (:methods + (minimap-class-node-method-9 (_type_) symbol) ;; 9 + ) ) -|# -#| (deftype connection-minimap (connection-pers) - ((next connection-minimap :offset-assert 0) - (handle uint64 :offset-assert 8) ;; handle - (position vector :offset-assert 16) - (alpha float :offset-assert 20) - (flags minimap-flag :offset-assert 24) - (class minimap-class-node :offset-assert 28) + ((next connection-minimap :offset-assert 0 :override) + (handle handle :offset-assert 8 :overlay-at update-time :score 1) + (position vector :offset-assert 16 :overlay-at (-> param 0)) ;; object + (alpha float :offset-assert 20 :overlay-at (-> param 1)) + (flags minimap-flag :offset-assert 24 :overlay-at (-> param 2)) + (class minimap-class-node :offset-assert 28 :overlay-at (-> param 3)) (node uint16 :offset-assert 32) (edge-ry int16 :offset-assert 34) (last-world-pos vector :inline :offset-assert 48) @@ -6175,26 +8417,22 @@ :flag-assert #x900000040 ;; field key uses ~A with a signed load. ) -|# -#| (deftype engine-minimap (engine-pers) - ((alive-list connection-minimap :offset-assert 24) - (dead-list connection-minimap :offset-assert 28) + ((alive-list connection-minimap :offset-assert 24 :override) + (dead-list connection-minimap :offset-assert 28 :override) ) :method-count-assert 15 :size-assert #x20 :flag-assert #xf00000020 ) -|# -#| (deftype minimap-draw-work (structure) ((buf dma-buffer :offset-assert 0) ;; guessed by decompiler (global-flags uint32 :offset-assert 4) (draw-pos vector4w :inline :offset-assert 16) (mat matrix :inline :offset-assert 32) - (corner vector 4 :offset-assert 96) ;; guessed by decompiler + (corner vector 4 :inline :offset-assert 96) ;; guessed by decompiler (vec vector :inline :offset-assert 160) (pos vector :inline :offset-assert 176) (mid-val float :offset-assert 192) @@ -6203,9 +8441,7 @@ :size-assert #xc4 :flag-assert #x9000000c4 ) -|# -#| (deftype minimap (structure) ((draw-tmpl dma-gif-packet :inline :offset-assert 0) (sprite-tmpl dma-gif-packet :inline :offset-assert 32) @@ -6238,14 +8474,599 @@ (minimap-method-15 () none) ;; 15 ;; (draw-1 (_type_ dma-buffer vector4w symbol) none) ) ) -|# +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; text-h ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; +++main-h:text-id +(defenum text-id + :type uint32 + (null #x0) + + (text-id-341 341) + (text-id-342 342) + (text-id-343 343) + (text-id-344 344) + + (text-id-522 522) + + (text-id-1579 1579) + (text-id-1580 1580) + (text-id-1581 1581) + (text-id-1588 1588) + (text-id-1624 1624) + (text-id-1625 1625) + (text-id-1633 1633) + (text-id-1655 1655) + (text-id-1656 1656) + (text-id-1659 1659) + (text-id-1694 1694) + (text-id-1695 1695) + (text-id-1838 1838) + (text-id-1839 1839) + + (text-id-1940 1940) + + (text-id-2135 2135) + (text-id-2136 2136) + (text-id-2137 2137) + (text-id-2138 2138) + (text-id-2139 2139) + (text-id-2140 2140) + (text-id-2141 2141) + (text-id-2142 2142) + (text-id-2143 2143) + (text-id-2144 2144) + (text-id-2145 2145) + (text-id-2146 2146) + (text-id-2147 2147) + + (text-id-2149 2149) + + (text-id-2163 2163) + (text-id-2164 2164) + (text-id-2165 2165) + (text-id-2166 2166) + (text-id-2167 2167) + (text-id-2168 2168) + (text-id-2169 2169) + (text-id-2170 2170) + (text-id-2171 2171) + (text-id-2172 2172) + (text-id-2173 2173) + (text-id-2174 2174) + (text-id-2175 2175) + (text-id-2176 2176) + (text-id-2177 2177) + (text-id-2178 2178) + (text-id-2179 2179) + (text-id-2183 2183) + (text-id-2184 2184) + (text-id-2185 2185) + (text-id-2186 2186) + (text-id-2187 2187) + (text-id-2188 2188) + (text-id-2189 2189) + (text-id-2190 2190) + + (text-id-2208 2208) + (text-id-2209 2209) + (text-id-2210 2210) + (text-id-2211 2211) + (text-id-2212 2212) + (text-id-2213 2213) + (text-id-2214 2214) + (text-id-2215 2215) + (text-id-2216 2216) + (text-id-2217 2217) + (text-id-2218 2218) + (text-id-2219 2219) + (text-id-2220 2220) + (text-id-2221 2221) + + (text-id-2278 2278) + (text-id-2279 2279) + (text-id-2280 2280) + (text-id-2281 2281) + (text-id-2282 2282) + (text-id-2283 2283) + (text-id-2284 2284) + (text-id-2285 2285) + (text-id-2286 2286) + (text-id-2287 2287) + (text-id-2288 2288) + (text-id-2289 2289) + (text-id-2290 2290) + (text-id-2291 2291) + (text-id-2292 2292) + (text-id-2293 2293) + (text-id-2294 2294) + (text-id-2295 2295) + (text-id-2296 2296) + (text-id-2297 2297) + (text-id-2298 2298) + (text-id-2299 2299) + (text-id-2300 2300) + (text-id-2301 2301) + (text-id-2302 2302) + (text-id-2303 2303) + (text-id-2304 2304) + (text-id-2305 2305) + (text-id-2306 2306) + (text-id-2307 2307) + (text-id-2308 2308) + (text-id-2309 2309) + (text-id-2310 2310) + (text-id-2311 2311) + (text-id-2312 2312) + + (text-id-2513 2513) + + (text-id-2833 2833) + (text-id-2834 2834) + (text-id-2835 2835) + (text-id-2836 2836) + (text-id-2837 2837) + (text-id-2838 2838) + (text-id-2839 2839) + (text-id-2840 2840) + + (text-id-2842 2842) + (text-id-2843 2843) + (text-id-2844 2844) + (text-id-2845 2845) + (text-id-2846 2846) + (text-id-2847 2847) + (text-id-2848 2848) + (text-id-2849 2849) + (text-id-2850 2850) + (text-id-2851 2851) + (text-id-2852 2852) + (text-id-2853 2853) + (text-id-2854 2854) + (text-id-2855 2855) + (text-id-2856 2856) + (text-id-2857 2857) + (text-id-2858 2858) + (text-id-2859 2859) + (text-id-2860 2860) + (text-id-2861 2861) + (text-id-2862 2862) + (text-id-2863 2863) + (text-id-2864 2864) + (text-id-2865 2865) + (text-id-2866 2866) + (text-id-2867 2867) + (text-id-2868 2868) + (text-id-2869 2869) + (text-id-2870 2870) + (text-id-2871 2871) + (text-id-2872 2872) + (text-id-2873 2873) + (text-id-2874 2874) + (text-id-2875 2875) + (text-id-2876 2876) + (text-id-2877 2877) + (text-id-2878 2878) + (text-id-2879 2879) + (text-id-2880 2880) + (text-id-2881 2881) + (text-id-2882 2882) + (text-id-2883 2883) + (text-id-2884 2884) + (text-id-2885 2885) + + (text-id-2886 2886) + + (text-id-2961 2961) + (text-id-2962 2962) + (text-id-2963 2963) + (text-id-2964 2964) + (text-id-2965 2965) + (text-id-2966 2966) + (text-id-2967 2967) + (text-id-2968 2968) + (text-id-2969 2969) + (text-id-2970 2970) + (text-id-2971 2971) + (text-id-2972 2972) + (text-id-2973 2973) + (text-id-2974 2974) + (text-id-2975 2975) + (text-id-2976 2976) + (text-id-2977 2977) + (text-id-2978 2978) + (text-id-2979 2979) + (text-id-2980 2980) + (text-id-2981 2981) + (text-id-2982 2982) + (text-id-2983 2983) + (text-id-2984 2984) + (text-id-2985 2985) + (text-id-2986 2986) + (text-id-2987 2987) + (text-id-2988 2988) + (text-id-2989 2989) + (text-id-2990 2990) + (text-id-2991 2991) + (text-id-2992 2992) + (text-id-2993 2993) + (text-id-2994 2994) + (text-id-2995 2995) + (text-id-2996 2996) + (text-id-2997 2997) + (text-id-2998 2998) + (text-id-2999 2999) + (text-id-3000 3000) + (text-id-3001 3001) + (text-id-3002 3002) + (text-id-3003 3003) + (text-id-3004 3004) + (text-id-3005 3005) + (text-id-3006 3006) + (text-id-3007 3007) + (text-id-3008 3008) + (text-id-3009 3009) + + (text-id-4370 4370) + (text-id-4371 4371) + (text-id-4372 4372) + (text-id-4373 4373) + (text-id-4374 4374) + (text-id-4375 4375) + (text-id-4376 4376) + (text-id-4377 4377) + (text-id-4378 4378) + (text-id-4379 4379) + (text-id-4380 4380) + (text-id-4381 4381) + (text-id-4382 4382) + + (text-id-4660 4660) + (text-id-4661 4661) + (text-id-4662 4662) + (text-id-4663 4663) + (text-id-4664 4664) + (text-id-4665 4665) + (text-id-4666 4666) + (text-id-4667 4667) + (text-id-4668 4668) + (text-id-4669 4669) + (text-id-4670 4670) + (text-id-4671 4671) + (text-id-4672 4672) + (text-id-4673 4673) + (text-id-4674 4674) + (text-id-4675 4675) + (text-id-4676 4676) + (text-id-4677 4677) + (text-id-4678 4678) + (text-id-4679 4679) + (text-id-4680 4680) + (text-id-4681 4681) + (text-id-4682 4682) + (text-id-4683 4683) + (text-id-4684 4684) + (text-id-4685 4685) + (text-id-4686 4686) + (text-id-4687 4687) + (text-id-4688 4688) + (text-id-4689 4689) + (text-id-4690 4690) + (text-id-4691 4691) + + (text-id-4692 4692) + (text-id-4693 4693) + (text-id-4694 4694) + (text-id-4695 4695) + (text-id-4696 4696) + (text-id-4697 4697) + (text-id-4698 4698) + (text-id-4699 4699) + (text-id-4700 4700) + (text-id-4701 4701) + (text-id-4702 4702) + (text-id-4703 4703) + (text-id-4704 4704) + (text-id-4705 4705) + (text-id-4706 4706) + (text-id-4707 4707) + (text-id-4708 4708) + (text-id-4709 4709) + (text-id-4710 4710) + (text-id-4711 4711) + (text-id-4712 4712) + (text-id-4713 4713) + (text-id-4714 4714) + (text-id-4715 4715) + (text-id-4716 4716) + (text-id-4717 4717) + (text-id-4718 4718) + (text-id-4719 4719) + (text-id-4720 4720) + (text-id-4721 4721) + (text-id-4722 4722) + (text-id-4723 4723) + (text-id-4724 4724) + (text-id-4725 4725) + (text-id-4726 4726) + (text-id-4727 4727) + (text-id-4728 4728) + (text-id-4729 4729) + (text-id-4730 4730) + (text-id-4731 4731) + (text-id-4732 4732) + (text-id-4733 4733) + (text-id-4734 4734) + (text-id-4735 4735) + (text-id-4736 4736) + (text-id-4737 4737) + (text-id-4738 4738) + (text-id-4739 4739) + (text-id-4740 4740) + (text-id-4741 4741) + (text-id-4742 4742) + (text-id-4743 4743) + (text-id-4744 4744) + (text-id-4745 4745) + (text-id-4746 4746) + (text-id-4747 4747) + (text-id-4748 4748) + (text-id-4749 4749) + (text-id-4750 4750) + (text-id-4751 4751) + (text-id-4752 4752) + (text-id-4753 4753) + (text-id-4754 4754) + (text-id-4755 4755) + (text-id-4756 4756) + (text-id-4757 4757) + (text-id-4758 4758) + (text-id-4759 4759) + (text-id-4760 4760) + (text-id-4761 4761) + (text-id-4762 4762) + (text-id-4763 4763) + (text-id-4764 4764) + (text-id-4765 4765) + (text-id-4766 4766) + (text-id-4767 4767) + (text-id-4768 4768) + (text-id-4769 4769) + (text-id-4770 4770) + (text-id-4771 4771) + (text-id-4772 4772) + (text-id-4773 4773) + (text-id-4774 4774) + (text-id-4775 4775) + (text-id-4776 4776) + (text-id-4777 4777) + (text-id-4778 4778) + (text-id-4779 4779) + (text-id-4780 4780) + (text-id-4781 4781) + (text-id-4782 4782) + (text-id-4783 4783) + (text-id-4784 4784) + (text-id-4785 4785) + (text-id-4786 4786) + (text-id-4787 4787) + (text-id-4788 4788) + (text-id-4789 4789) + (text-id-4790 4790) + (text-id-4791 4791) + (text-id-4792 4792) + (text-id-4793 4793) + (text-id-4794 4794) + (text-id-4795 4795) + (text-id-4796 4796) + (text-id-4797 4797) + (text-id-4798 4798) + (text-id-4799 4799) + (text-id-4800 4800) + (text-id-4801 4801) + (text-id-4802 4802) + (text-id-4803 4803) + (text-id-4804 4804) + (text-id-4805 4805) + (text-id-4806 4806) + (text-id-4807 4807) + (text-id-4808 4808) + (text-id-4809 4809) + (text-id-4810 4810) + (text-id-4811 4811) +) + +;; ---main-h:text-id + +(deftype game-text (structure) + ((id text-id :offset-assert 0) ;; guessed by decompiler + (text string :offset-assert 4) ;; guessed by decompiler + ) + :pack-me + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +;; TODO - no more dynamic inline? +(deftype game-text-info (basic) + ((length int32 :offset-assert 4) + (language-id int32 :offset-assert 8) + (group-name string :offset-assert 12) ;; guessed by decompiler + (dic-index uint32 :offset-assert 16) + (dic-data uint32 :offset-assert 20) + (text uint32 :offset-assert 24) + (text-data uint32 :offset-assert 28) + ) + :method-count-assert 13 + :size-assert #x20 + :flag-assert #xd00000020 + (:methods + (game-text-info-method-9 () none) ;; 9 ;; (lookup-text! (_type_ text-id symbol) string) + (game-text-info-method-10 () none) ;; 10 + (game-text-info-method-11 () none) ;; 11 + (game-text-info-method-12 () none) ;; 12 + ) + ) + +(define-extern *text-group-names* (array string)) ;; +(define-extern *common-text-heap* kheap) ;; +(define-extern *common-text* game-text-info) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; main-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type debug-menu-context basic) + +;; +++main-h:collide-spec +(defenum collide-spec + :bitfield #t + :type uint32 + (backgnd 0) + (jak 1) + (bot 2) + (crate 3) + (civilian 4) + (enemy 5) + (obstacle 6) + (vehicle-sphere 7) + (vehicle-debris 8) ; was hit-by-player-list + (hit-by-player-list 9) ; was hit-by-others-list + (hit-by-others-list 10) ; was player-list + (player-list 11) ; was water + (water 12) ; was collectable + (collectable 13) ; was blocking-plane + (blocking-plane 14) ; was projectile + (projectile 15) ; was jak-vulnerable + (jak-vulnerable 16) ; was camera-blocker + (camera-blocker 17) ; was los-blocker + (los-blocker 18) ; was notice-blue-eco-powerup + (nav-mesh 19) ; was tobot + (pusher 20) + (bot-targetable 21) ; was vehicle-mesh + (coliseum-ball 23) ; was jak-vehicle + (special-obstacle 22) ; unchanged semantically + (impenetrable-obj 25) ; was mech-punch + (obstacle-for-jak 24) ; was special-obstacle + (vehicle-sphere-no-probe 27) ; was vehicle-mesh-probeable + (shield 26) ; was obstacle-for-jak + (impenetrable-obj-alt 28) ; original impenetrable-obj (no mapping shown) + (shield-alt 29) ; original shield (no mapping shown) + (vehicle-mesh-no-block-use 30) + (vehicle-sphere-no-probe-alt 31) +) +;; ---main-h:collide-spec + +;; +++main-h:strip-lines-controls +(defenum strip-lines-controls + :type int64 + (none 0) + ; (strippable 1) + ; (convertible 2) + ; (good 3) + ; (edgeable 4) + ; (ordinary 8) + ; (color-mismatch 16) + ; (shader-mismatch 32) + ; (uv-mismatch 64) + ; (too-big 128) + ; (bad 240) + ; (all-edges 255) + ; (strips 256) + ; (frags 512) + ) +;; ---main-h:strip-lines-controls + +;; +++main-h:scene-controls +(defenum scene-controls + :type int64 + :bitfield #t + (channel) + (anim-name) + (dma-size) + (bounds-spheres) + (actors) + (actor-marks) + (special-fma-spheres) + (scene-controls-7) + (scene-controls-8) + (display-controls) + ) +;; ---main-h:scene-controls + +;; +++main-h:bot-marks-controls +(defenum bot-marks-controls + :type int64 + (all-off 0) + (course-spots 1) + (task-spots 2) + (all-on 3) + (bmc04 4) + (bmc05 5) + (bmc06 6) + (bmc07 7) + (bmc08 8) + (bmc09 9) + (bmc10 10) + (bmc11 11) + (bmc12 12) + (bmc13 13) + (bmc14 14) + (bmc15 15) + (bmc16 16) + ) +;; ---main-h:bot-marks-controls + +;; +++main-h:race-marks-controls +(defenum race-marks-controls + :type int64 + (all-off 0) + (path0-red 1) + (path1-green 2) + (path2-blue 4) + (path3-yellow 8) + (path4-cyan 16) + (path5-violet 32) + (path6-orange 64) + (path7-black 128) + (all-paths-on 255) + (rmc2040 2040) + ) +;; ---main-h:race-marks-controls + +;; +++main-h:race-selection +(defenum race-selection + :type int64 + (desertb-race-record 0) + (rs1 1) + (desrally-record 2) + ) +;; ---main-h:race-selection + +;; +++main-h:subdivide-setting +(defenum subdivide-setting + :type int64 + (textured 0) + (outline 1) + (gouraud 2) + (hack 3)) +;; ---main-h:subdivide-setting + +;; +++main-h:ocean-height-hack +(defenum ocean-height-hack + :type int64 + ; (zero 1) + ; (far-below 2) + ; (sewer-start 3) + ; (sewer-hi 4) + ; (sewer-med 5) + ; (sewer-lo 6) + ) +;; ---main-h:ocean-height-hack + (deftype frame-stats (structure) ((field-time time-frame 2 :offset-assert 0) ;; guessed by decompiler (field int32 :offset-assert 16) @@ -6254,20 +9075,18 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype screen-filter (basic) ((draw? symbol :offset-assert 4) ;; guessed by decompiler - (bucket int32 :offset-assert 8) ;; bucket-id + (bucket bucket-id :offset-assert 8) ;; bucket-id (depth int32 :offset-assert 12) (ztest uint64 :offset-assert 16) (color vector :inline :offset-assert 32) (color-src vector :inline :offset-assert 48) (color-dest vector :inline :offset-assert 64) (extra vector :inline :offset-assert 80) - (speed float :offset-assert 80) - (current-interp float :offset-assert 84) + (speed float :offset 80) + (current-interp float :offset 84) (lock-vsync? symbol :offset-assert 96) ;; guessed by decompiler (idx int32 :offset-assert 100) (frames int32 :offset-assert 104) @@ -6281,9 +9100,7 @@ (screen-filter-method-11 () none) ;; 11 ;; (disable (_type_) none) ) ) -|# -#| (deftype col-rend (basic) ((draw? symbol :offset-assert 4) ;; guessed by decompiler (outline? symbol :offset-assert 8) ;; guessed by decompiler @@ -6302,163 +9119,217 @@ :size-assert #x44 :flag-assert #xa00000044 (:methods - (col-rend-method-9 () none) ;; 9 ;; (draw (_type_) none) + (draw (_type_) none) ) ) -|# -;; (define-extern *stats-poly* object) ;; symbol -;; (define-extern *stats-memory* object) ;; symbol -;; (define-extern *stats-memory-short* object) ;; symbol -;; (define-extern *stats-memory-level-index* object) ;; int -;; (define-extern *stats-collide* object) ;; symbol -;; (define-extern *stats-bsp* object) ;; symbol -;; (define-extern *stats-buffer* object) ;; symbol -;; (define-extern *stats-target* object) ;; symbol -;; (define-extern *stats-profile-bars* object) ;; symbol -;; (define-extern *stats-perf* object) ;; symbol -;; (define-extern *stats-sound* object) -;; (define-extern *artist-all-visible* object) ;; symbol -;; (define-extern *artist-flip-visible* object) ;; symbol -;; (define-extern *artist-fix-visible* object) ;; symbol -;; (define-extern *artist-fix-frustum* object) ;; symbol -;; (define-extern *artist-error-spheres* object) ;; symbol -;; (define-extern *artist-use-menu-subdiv* object) ;; symbol -;; (define-extern *display-profile* object) ;; symbol -;; (define-extern *display-sidekick-stats* object) ;; symbol -;; (define-extern *display-quad-stats* object) ;; symbol -;; (define-extern *display-tri-stats* object) ;; symbol -;; (define-extern *display-ground-stats* object) ;; symbol -;; (define-extern *display-collision-marks* object) ;; symbol -;; (define-extern *display-collide-cache* object) ;; symbol -;; (define-extern *display-render-collision* object) ;; symbol -;; (define-extern *display-hipri-collision-marks* object) ;; symbol -;; (define-extern *display-edge-collision-marks* object) ;; symbol -;; (define-extern *display-geo-marks* object) ;; symbol -;; (define-extern *display-target-marks* object) ;; symbol -;; (define-extern *target-rc-board-controls* object) ;; symbol -;; (define-extern *display-collide-history* object) ;; int -;; (define-extern *amy-cam* object) ;; symbol -;; (define-extern *display-xyz-axes* object) ;; symbol -;; (define-extern *display-cam-collide-history* object) ;; symbol -;; (define-extern *record-cam-collide-history* object) ;; symbol -;; (define-extern *display-cam-master-marks* object) ;; symbol -;; (define-extern *display-cam-other* object) ;; symbol -;; (define-extern *display-camera-marks* object) ;; symbol -;; (define-extern *camera-no-mip-correction* object) ;; symbol -;; (define-extern *camera-turbo-free* object) ;; symbol -;; (define-extern *suppress-vehicle-respawn* object) -;; (define-extern *display-cam-los-info* object) ;; symbol -;; (define-extern *display-cam-los-debug* object) ;; symbol -;; (define-extern *display-cam-los-marks* object) ;; symbol -;; (define-extern *display-cam-coll-marks* object) ;; symbol -;; (define-extern *display-camera-info* object) ;; symbol -;; (define-extern *display-camera-old-stats* object) ;; symbol -;; (define-extern *display-camera-last-attacker* object) ;; symbol -;; (define-extern *display-file-info* object) ;; symbol -;; (define-extern *display-actor-marks* object) ;; symbol -;; (define-extern *display-sprite-info* object) ;; symbol -;; (define-extern *display-sprite-marks* object) ;; symbol -;; (define-extern *display-sprite-spheres* object) ;; symbol -;; (define-extern *display-bsp-errors* object) -;; (define-extern *display-entity-errors* object) ;; symbol -;; (define-extern *display-capture-mode* object) ;; symbol -;; (define-extern *display-instance-info* object) ;; symbol -;; (define-extern *display-deci-count* object) ;; symbol -;; (define-extern *sync-dma* object) ;; symbol -;; (define-extern *display-strip-lines* object) ;; strip-lines-controls -;; (define-extern *display-battle-marks* object) ;; symbol -;; (define-extern *display-joint-axes* object) ;; symbol -;; (define-extern *display-nav-marks* object) ;; symbol -;; (define-extern *display-nav-network* object) ;; symbol -;; (define-extern *display-path-marks* object) ;; symbol -;; (define-extern *display-vol-marks* object) ;; symbol -;; (define-extern *display-water-marks* object) ;; symbol -;; (define-extern *display-nav-mesh* object) ;; symbol -;; (define-extern *display-race-mesh* object) ;; symbol -;; (define-extern *display-ai-tuning* object) -;; (define-extern *display-actor-pointer* object) ;; symbol -;; (define-extern *display-actor-vis* object) ;; symbol -;; (define-extern *display-actor-graph* object) ;; symbol -;; (define-extern *display-traffic-height-map* object) ;; symbol -;; (define-extern *display-trail-graph* object) ;; symbol -;; (define-extern *display-color-bars* object) ;; symbol -;; (define-extern *display-bug-report* object) ;; symbol -;; (define-extern *display-level-border* object) ;; symbol -;; (define-extern *display-memcard-info* object) ;; symbol -;; (define-extern *display-split-boxes* object) ;; symbol -;; (define-extern *display-split-box-info* object) ;; symbol -;; (define-extern *display-texture-distances* object) ;; symbol -;; (define-extern *display-texture-download* object) ;; symbol -;; (define-extern *display-art-control* object) ;; symbol -;; (define-extern *display-gui-control* object) ;; symbol -;; (define-extern *display-level-spheres* object) ;; symbol -;; (define-extern *time-of-day-fast* object) ;; symbol -;; (define-extern *display-iop-info* object) ;; symbol -;; (define-extern *slow-frame-rate* object) ;; symbol -;; (define-extern *display-region-marks* object) ;; symbol -;; (define-extern *execute-regions* object) ;; symbol -;; (define-extern *disable-bot* object) -;; (define-extern *debug-reverb* object) -;; (define-extern *debug-whoosh* object) -;; (define-extern *debug-engine-sounds* object) -;; (define-extern *debug-pause* object) ;; symbol -;; (define-extern *debug-view-anims* object) ;; symbol -;; (define-extern *debug-unkillable* object) ;; symbol -;; (define-extern *debug-player-vehicle-unkillable* object) ;; symbol -;; (define-extern *debug-actor* object) ;; process -;; (define-extern *debug-force-highspeed* object) -;; (define-extern *gun-marks* object) ;; symbol -;; (define-extern *debug-split-screen* object) -;; (define-extern *ignore-want-load-display* object) -;; (define-extern *bug-report-output-mode* object) ;; symbol -;; (define-extern *draw-debug-boxes* object) -;; (define-extern *hide-menus* object) -;; (define-extern *list-all-scenes* object) -;; (define-extern *display-scene-control* object) ;; scene-controls -;; (define-extern *display-bot-marks* object) ;; bot-marks-controls -;; (define-extern *display-race-marks* object) ;; race-marks-controls -;; (define-extern *race-record-path* object) ;; symbol -;; (define-extern *select-race* object) ;; race-selection -;; (define-extern *select-race-path* object) ;; int -;; (define-extern *bot-record-path* object) ;; int -;; (define-extern *subdivide-draw-mode* object) ;; subdivide-setting -;; (define-extern *subdivide-scissor-draw-mode* object) ;; subdivide-setting -;; (define-extern *subdivide-foreground-draw-mode* object) ;; subdivide-setting -;; (define-extern *subdivide-ocean-draw-mode* object) ;; subdivide-setting -;; (define-extern *dproc* object) ;; process -;; (define-extern *run* object) ;; symbol -;; (define-extern *teleport* object) ;; symbol -;; (define-extern *teleport-count* object) ;; int -;; (define-extern *draw-hook* object) ;; (function none) -;; (define-extern *debug-hook* object) ;; pair -;; (define-extern *menu-hook* object) ;; (function debug-menu-context) -;; (define-extern *progress-hook* object) ;; (function none) -;; (define-extern *dma-timeout-hook* object) ;; (function none) -;; (define-extern *frame-stats* object) ;; frame-stats -;; (define-extern *col-rend* col-rend) ;; col-rend -;; (define-extern debug-actor? function) ;; (function object symbol) -;; (define-extern *record-fma* object) -;; (define-extern *record-fma-use-path* object) -;; (define-extern *record-fma-path-mode* object) -;; (define-extern *record-fma-path-high-res* object) -;; (define-extern *record-fma-path-dry-run* object) -;; (define-extern *record-fma-real* object) -;; (define-extern *record-fma-low-res* object) -;; (define-extern *record-fma-start* object) -;; (define-extern *record-fma-end* object) -;; (define-extern *record-fma-pal* object) -;; (define-extern *profile-slot* object) -;; (define-extern *game-mode* object) -;; (define-extern *lobby-local-players* object) -;; (define-extern *first-boot* object) ;; symbol -;; (define-extern *cheat-temp* object) ;; (pointer int32) +(define-extern *stats-poly* symbol) +(define-extern *stats-memory* symbol) +(define-extern *stats-memory-short* symbol) +(define-extern *stats-memory-level-index* int) +(define-extern *stats-collide* symbol) +(define-extern *stats-bsp* symbol) +(define-extern *stats-buffer* symbol) +(define-extern *stats-target* symbol) +(define-extern *stats-profile-bars* symbol) ;; +(define-extern *stats-perf* symbol) ;; +(define-extern *stats-sound* symbol) +(define-extern *artist-all-visible* symbol) +(define-extern *artist-flip-visible* symbol) +(define-extern *artist-fix-visible* symbol) +(define-extern *artist-fix-frustum* symbol) +(define-extern *artist-error-spheres* symbol) +(define-extern *artist-use-menu-subdiv* symbol) +(define-extern *display-profile* symbol) ;; +(define-extern *display-sidekick-stats* symbol) ;; +(define-extern *display-quad-stats* symbol) +(define-extern *display-tri-stats* symbol) +(define-extern *display-ground-stats* symbol) +(define-extern *display-collision-marks* symbol) +(define-extern *display-collide-cache* symbol) +(define-extern *display-render-collision* symbol) +(define-extern *display-hipri-collision-marks* symbol) +(define-extern *display-edge-collision-marks* symbol) +(define-extern *display-geo-marks* symbol) +(define-extern *display-target-marks* symbol) +(define-extern *target-rc-board-controls* symbol) +(define-extern *display-collide-history* int) +(define-extern *amy-cam* symbol) +(define-extern *display-xyz-axes* symbol) +(define-extern *display-cam-collide-history* symbol) +(define-extern *record-cam-collide-history* symbol) +(define-extern *display-cam-master-marks* symbol) +(define-extern *display-cam-other* symbol) +(define-extern *display-camera-marks* symbol) +(define-extern *camera-no-mip-correction* symbol) +(define-extern *camera-turbo-free* symbol) +(define-extern *suppress-vehicle-respawn* object) +(define-extern *display-cam-los-info* symbol) +(define-extern *display-cam-los-debug* symbol) +(define-extern *display-cam-los-marks* symbol) +(define-extern *display-cam-coll-marks* symbol) +(define-extern *display-camera-info* symbol) +(define-extern *display-camera-old-stats* symbol) +(define-extern *display-camera-last-attacker* symbol) +(define-extern *display-file-info* symbol) +(define-extern *display-actor-marks* symbol) +(define-extern *display-sprite-info* symbol) +(define-extern *display-sprite-marks* symbol) +(define-extern *display-sprite-spheres* symbol) +(define-extern *display-bsp-errors* symbol) +(define-extern *display-entity-errors* symbol) +(define-extern *display-capture-mode* symbol) +(define-extern *display-instance-info* symbol) +(define-extern *display-deci-count* symbol) +(define-extern *sync-dma* symbol) +(define-extern *display-strip-lines* strip-lines-controls) +(define-extern *display-battle-marks* symbol) +(define-extern *display-joint-axes* symbol) +(define-extern *display-nav-marks* symbol) +(define-extern *display-nav-network* symbol) +(define-extern *display-path-marks* symbol) +(define-extern *display-vol-marks* symbol) +(define-extern *display-water-marks* symbol) +(define-extern *display-nav-mesh* symbol) +(define-extern *display-race-mesh* symbol) +(define-extern *display-ai-tuning* symbol) +(define-extern *display-actor-pointer* symbol) +(define-extern *display-actor-vis* symbol) +(define-extern *display-actor-graph* symbol) +(define-extern *display-traffic-height-map* symbol) +(define-extern *display-trail-graph* symbol) +(define-extern *display-color-bars* symbol) +(define-extern *display-bug-report* symbol) +(define-extern *display-level-border* symbol) +(define-extern *display-memcard-info* symbol) +(define-extern *display-split-boxes* symbol) +(define-extern *display-split-box-info* symbol) +(define-extern *display-texture-distances* symbol) +(define-extern *display-texture-download* symbol) +(define-extern *display-art-control* symbol) +(define-extern *display-gui-control* symbol) +(define-extern *display-level-spheres* symbol) +(define-extern *time-of-day-fast* symbol) +(define-extern *display-iop-info* symbol) +(define-extern *slow-frame-rate* symbol) +(define-extern *display-region-marks* symbol) +(define-extern *execute-regions* symbol) +(define-extern *disable-bot* symbol) +(define-extern *debug-reverb* symbol) +(define-extern *debug-whoosh* symbol) +(define-extern *debug-engine-sounds* symbol) +(define-extern *debug-pause* symbol) +(define-extern *debug-view-anims* symbol) +(define-extern *debug-unkillable* symbol) +(define-extern *debug-player-vehicle-unkillable* symbol) +(define-extern *debug-actor* process) +(define-extern *debug-force-highspeed* symbol) +(define-extern *gun-marks* symbol) ;; +(define-extern *debug-split-screen* symbol) +(define-extern *ignore-want-load-display* symbol) +(define-extern *bug-report-output-mode* symbol) ;; +(define-extern *draw-debug-boxes* symbol) +(define-extern *hide-menus* symbol) +(define-extern *list-all-scenes* symbol) +(define-extern *display-scene-control* scene-controls) +(define-extern *display-bot-marks* bot-marks-controls) +(define-extern *display-race-marks* race-marks-controls) +(define-extern *race-record-path* symbol) +(define-extern *select-race* race-selection) +(define-extern *select-race-path* int) +(define-extern *bot-record-path* int) +(define-extern *subdivide-draw-mode* subdivide-setting) +(define-extern *subdivide-scissor-draw-mode* subdivide-setting) +(define-extern *subdivide-foreground-draw-mode* subdivide-setting) +(define-extern *subdivide-ocean-draw-mode* subdivide-setting) +(define-extern *dproc* process) ;; +(define-extern *run* symbol) +(define-extern *teleport* symbol) +(define-extern *teleport-count* int) +(define-extern *draw-hook* (function none)) +(define-extern *debug-hook* pair) +(define-extern *menu-hook* (function debug-menu-context)) +(define-extern *progress-hook* (function none)) +(define-extern *dma-timeout-hook* (function none)) +(define-extern *frame-stats* frame-stats) +(define-extern *col-rend* col-rend) +(define-extern debug-actor? (function object symbol)) +(define-extern *record-fma* symbol) +(define-extern *record-fma-use-path* symbol) +(define-extern *record-fma-path-mode* symbol) +(define-extern *record-fma-path-high-res* symbol) +(define-extern *record-fma-path-dry-run* symbol) +(define-extern *record-fma-real* symbol) +(define-extern *record-fma-low-res* symbol) +(define-extern *record-fma-start* int) +(define-extern *record-fma-end* int) +(define-extern *record-fma-pal* symbol) +(define-extern *profile-slot* int) +(define-extern *game-mode* symbol) +(define-extern *lobby-local-players* int) +(define-extern *first-boot* symbol) +(define-extern *cheat-temp* (pointer int32)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; traffic-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type nav-mesh basic) +(declare-type nav-branch structure) + +(defenum driver-type + :type uint8 + (d-jak 0) + (d-ashelin 1) + (d-razer 2) + (d-klever 3) + (d-kiera 4) + (d-thug-a 5) + (d-thug-b 6) + (d-thug-c 7) + (d-taryn 8) + (d-torn 9) + (d-sig 10) + (d-ur-86 11) + (d-kaeden 12) + (d-rayn 13) + (d-ratchet 14) + (d-jaka 15) + (d-jakb 16) + (d-jakc 17) + (d-daxter 18) + (d-gtblitz 19) + (d-pecker 20) + (d-ximon 21) + (d-osmo 22) + (none 23) +) + +(defenum traffic-vehicle-type + :type uint8 + (v-mongoose 0) + (v-falcon 1) + (v-wombat 2) + (v-possum 3) + (v-bobcat 4) + (v-cougar 5) + (v-wolf 6) + (v-bear 7) + (v-leopard 8) + (v-panther 9) + (v-tiger 10) + (v-cheetah 11) + (v-gila 12) + (v-snake 13) + (v-daxtermobile 14) + (v-drone 15) + (v-dart 16) + (test-bike 17) + (test-car 18) + (none 19) + (any 20) +) + (deftype vehicle-spawn-params (structure) ((behavior uint64 :offset-assert 0) (nav-mesh basic :offset-assert 8) @@ -6472,7 +9343,7 @@ (flags uint32 :offset-assert 88) (player-id int8 :offset-assert 92) (level-slot int8 :offset-assert 93) - (driver-type uint8 :offset-assert 94) + (driver-type driver-type :offset-assert 94) (driver-slot int8 :offset-assert 95) (impact-callback basic :offset-assert 96) (proc basic :offset-assert 100) @@ -6481,19 +9352,34 @@ :size-assert #x68 :flag-assert #x900000068 ) -|# -;; (define-extern *vehicle-manager* object) ;; vehicle-manager -;; (define-extern vehicle-type->string function) -;; (define-extern driver-type->string function) -;; (define-extern type-from-driver-type function) -;; (define-extern level-from-driver-type function) +(declare-type vehicle-manager process) + +(define-extern *vehicle-manager* vehicle-manager) ;; vehicle-manager +(define-extern vehicle-type->string (function traffic-vehicle-type string)) +(define-extern driver-type->string (function driver-type string)) +(define-extern type-from-driver-type (function driver-type basic)) +(define-extern level-from-driver-type (function driver-type symbol)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; game-task-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++game-task-h:game-task +(defenum game-task + :type uint8 + :bitfield #f + (unknown -1) +) +;; ---game-task-h:game-task + +;; +++game-task-h:game-task-node +(defenum game-task-node + :type uint16 + (none) + ) +;; ---game-task-h:game-task-node + (deftype task-level-info (structure) ((flags uint32 :offset-assert 0) (text-id uint32 :offset-assert 4) @@ -6508,25 +9394,24 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -;; (define-extern *net-play-mode-names* array) -;; (define-extern *net-play-mode-text-ids* object) -;; (define-extern *net-play-mode-icon-string* array) -;; (define-extern *task-level* array) ;; (array symbol) -;; (define-extern *task-level-info* array) -;; (define-extern *driver-list-cup1* array) -;; (define-extern *driver-list-cup1-gp* array) -;; (define-extern *driver-list-cup1-temp* array) -;; (define-extern *driver-list-cup2* array) -;; (define-extern *driver-list-cup2-gp* array) -;; (define-extern *driver-list-cup3* array) -;; (define-extern *driver-list-cup3-capture* array) -;; (define-extern *driver-list-cup3-gp* array) -;; (define-extern *driver-list-cup4-capture* array) -;; (define-extern *driver-list-cup4-gp* array) -;; (define-extern *driver-list-boss* array) -;; (define-extern *driver-list-training* array) +(define-extern *net-play-mode-names* (array symbol)) +(define-extern *net-play-mode-text-ids* (pointer text-id)) +(define-extern *net-play-mode-icon-string* (array string)) +(define-extern *task-level* (array symbol)) ;; +(define-extern *task-level-info* (array task-level-info)) +(define-extern *driver-list-cup1* (array uint8)) +(define-extern *driver-list-cup1-gp* (array uint8)) +(define-extern *driver-list-cup1-temp* (array uint8)) +(define-extern *driver-list-cup2* (array uint8)) +(define-extern *driver-list-cup2-gp* (array uint8)) +(define-extern *driver-list-cup3* (array uint8)) +(define-extern *driver-list-cup3-capture* (array uint8)) +(define-extern *driver-list-cup3-gp* (array uint8)) +(define-extern *driver-list-cup4-capture* (array uint8)) +(define-extern *driver-list-cup4-gp* (array uint8)) +(define-extern *driver-list-boss* (array uint8)) +(define-extern *driver-list-training* (array uint8)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; task-control-h ;; @@ -6546,6 +9431,20 @@ ) |# +;; TODO - not sure if this actually exists in jakx or not +(deftype resetter-spec (structure) + ((continue string :offset-assert 0) + (node game-task-node :offset-assert 4) + (reset-mode symbol :offset-assert 8) + (execute basic :offset-assert 12) + ) + :pack-me + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ;; field execute uses ~A with a signed load. + ) + #| (deftype game-task-node-stats (structure) ((death-count uint8 :offset-assert 0) @@ -6762,43 +9661,39 @@ ;; car-info-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype car-layer-textures (structure) - ((data UNKNOWN 6 :offset-assert 0) - (dest basic :offset-assert 0) - (base basic :offset-assert 4) - (stripe basic :offset-assert 8) - (detail basic :offset-assert 12) - (damage basic :offset-assert 16) - (wheel-dest basic :offset-assert 0) - (wheel-base basic :offset-assert 4) - (wheel-blur basic :offset-assert 8) - (tread-dest basic :offset-assert 12) - (tread-base basic :offset-assert 16) - (tread-blur basic :offset-assert 20) + ((data basic 6 :offset-assert 0) + (dest basic :offset 0) + (base basic :offset 4) + (stripe basic :offset 8) + (detail basic :offset 12) + (damage basic :offset 16) + (wheel-dest basic :offset 0) + (wheel-base basic :offset 4) + (wheel-blur basic :offset 8) + (tread-dest basic :offset 12) + (tread-base basic :offset 16) + (tread-blur basic :offset 20) ) + :pack-me :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype car-textures (structure) - ((data UNKNOWN 14 :offset-assert 0) + ((data car-layer-textures 14 :inline :offset-assert 0) ) :method-count-assert 9 :size-assert #x150 :flag-assert #x900000150 ) -|# -#| (deftype car-rgb-color (vector4w) - ((red int32 :offset-assert 0) - (green int32 :offset-assert 4) - (blue int32 :offset-assert 8) - (alpha int32 :offset-assert 12) + ((red int32 :offset 0) + (green int32 :offset 4) + (blue int32 :offset 8) + (alpha int32 :offset 12) ) :method-count-assert 12 :size-assert #x10 @@ -6809,13 +9704,11 @@ (car-rgb-color-method-11 () none) ;; 11 ) ) -|# -#| (deftype car-hsv-color (vector) - ((hue float :offset-assert 0) - (saturation float :offset-assert 4) - (value float :offset-assert 8) + ((hue float :offset 0) + (saturation float :offset 4) + (value float :offset 8) ) :method-count-assert 10 :size-assert #x10 @@ -6824,9 +9717,7 @@ (car-hsv-color-method-9 () none) ;; 9 ) ) -|# -#| (deftype car-part-info (structure) ((short-name-id uint32 :offset-assert 0) (name-id uint32 :offset-assert 4) @@ -6840,14 +9731,12 @@ :size-assert #xe :flag-assert #x90000000e ) -|# -;; (deftype tuning-info (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype tuning-info (uint32) + () + :flag-assert #x900000004 + ) -#| (deftype upgrade-info (structure) ((cost float :offset-assert 0) (base uint8 :offset-assert 4) @@ -6860,34 +9749,28 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype upgrade-info-array (structure) - ((data UNKNOWN 4 :offset-assert 0) + ((data upgrade-info 4 :inline :offset-assert 0) ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype car-upgrade-info-array (structure) - ((data UNKNOWN 15 :offset-assert 0) + ((data upgrade-info-array 15 :inline :offset-assert 0) ) :method-count-assert 9 :size-assert #x3c0 :flag-assert #x9000003c0 ) -|# -#| (deftype car-info (structure) ((base-color car-rgb-color :inline :offset-assert 0) (stripe-color car-rgb-color :inline :offset-assert 16) (car-type int8 :offset-assert 32) - (current-parts UNKNOWN 11 :offset-assert 33) + (current-parts int8 11 :offset-assert 33) (tuning uint32 :offset-assert 44) (flags uint32 :offset-assert 48) ) @@ -6895,14 +9778,12 @@ :size-assert #x34 :flag-assert #x900000034 ) -|# -#| (deftype car-info-save (structure) ((car-type int8 :offset-assert 0) (base-color uint32 :offset-assert 4) (stripe-color uint32 :offset-assert 8) - (parts UNKNOWN 11 :offset-assert 12) + (parts int8 11 :offset-assert 12) (tuning uint32 :offset-assert 24) (flags uint32 :offset-assert 28) ) @@ -6910,9 +9791,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype car-info-full (car-info) ((level basic :offset-assert 52) (wheel-blur float :offset-assert 56) @@ -6920,7 +9799,7 @@ (textures car-textures :offset-assert 64) (first-tbp uint32 :offset-assert 68) (last-tbp uint32 :offset-assert 72) - (damage UNKNOWN 14 :offset-assert 76) + (damage int8 14 :offset-assert 76) (lights vu-lights :inline :offset-assert 96) (shield-vu-lights vu-lights :inline :offset-assert 208) (shield-light-group light-group :inline :offset-assert 320) @@ -6944,22 +9823,18 @@ (car-info-full-method-21 () none) ;; 21 ) ) -|# -#| (deftype car-info-array (structure) - ((data UNKNOWN 15 :offset-assert 0) + ((data car-info 15 :inline :offset-assert 0) ) :method-count-assert 9 :size-assert #x3c0 :flag-assert #x9000003c0 ) -|# -#| (deftype car-level-array (basic) - ((data UNKNOWN 6 :offset-assert 16) - (textures UNKNOWN 6 :offset-assert 3088) + ((data car-info-full 6 :inline :offset-assert 16) + (textures car-textures 6 :inline :offset-assert 3088) ) :method-count-assert 10 :size-assert #x13f0 @@ -6968,22 +9843,42 @@ (car-level-array-method-9 () none) ;; 9 ) ) -|# -;; (define-extern *car-type-names* array) -;; (define-extern type-from-vehicle-type function) ;; (function vehicle-type type) -;; (define-extern level-name-from-vehicle-type function) -;; (define-extern car-type-from-vehicle-type function) -;; (define-extern vehicle-type-from-car-type function) -;; (define-extern car-type-from-level-name function) -;; (define-extern vehicle-type-from-level-name function) -;; (define-extern vehicle-type-from-name function) -;; (define-extern *car-part-names* array) -;; (define-extern *car-part-translate-array* array) -;; (define-extern *car-part-translate-names* array) -;; (define-extern *car-look-names* array) -;; (define-extern *car-layer-names* array) -;; (define-extern *car-string-name* object) +;; +++car-info-h:vehicle-type +(defenum vehicle-type + :type uint8 + (mongoose 0) + (falcon 1) + (wombat 2) + (possum 3) + (bobcat 4) + (cougar 5) + (wolf 6) + (bear 7) + (leopard 8) + (panther 9) + (tiger 10) + (cheetah 11) + (gila 12) + (snake 13) + (daxtermobile 14) +) +;; ---car-info-h:vehicle-type + +(define-extern *car-type-names* (array string)) +(define-extern type-from-vehicle-type (function vehicle-type traffic-vehicle-type)) +(define-extern level-name-from-vehicle-type function) +(define-extern car-type-from-vehicle-type function) +(define-extern vehicle-type-from-car-type function) +(define-extern car-type-from-level-name (function symbol int)) +(define-extern vehicle-type-from-level-name function) +(define-extern vehicle-type-from-name (function string int)) +(define-extern *car-part-names* (array string)) +(define-extern *car-part-translate-array* (array uint8)) +(define-extern *car-part-translate-names* (array string)) +(define-extern *car-look-names* (array string)) +(define-extern *car-layer-names* (array string)) +(define-extern *car-string-name* string) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; car-tables ;; @@ -7001,56 +9896,52 @@ ;; capture-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype gs-store-image-packet (structure) ((vifcode vif-tag 4 :offset-assert 0) ;; guessed by decompiler - (giftag uint128 :offset-assert 16) ;; gif-tag - (bitbltbuf uint64 :offset-assert 32) ;; gs-bitbltbuf - (bitbltbuf-addr uint64 :offset-assert 40) ;; gs-reg64 - (trxpos uint64 :offset-assert 48) ;; gs-trxpos - (trxpos-addr uint64 :offset-assert 56) ;; gs-reg64 - (trxreg uint64 :offset-assert 64) ;; gs-trxreg - (trxreg-addr uint64 :offset-assert 72) ;; gs-reg64 - (finish uint64 :offset-assert 80) - (finish-addr uint64 :offset-assert 88) ;; gs-reg64 - (trxdir uint64 :offset-assert 96) ;; gs-trxdir - (trxdir-addr uint64 :offset-assert 104) ;; gs-reg64 + (giftag gif-tag :offset-assert 16) ;; gif-tag + (bitbltbuf gs-bitbltbuf :offset-assert 32) ;; gs-bitbltbuf + (bitbltbuf-addr gs-reg64 :offset-assert 40) ;; gs-reg64 + (trxpos gs-trxpos :offset-assert 48) ;; gs-trxpos + (trxpos-addr gs-reg64 :offset-assert 56) ;; gs-reg64 + (trxreg gs-trxreg :offset-assert 64) ;; gs-trxreg + (trxreg-addr gs-reg64 :offset-assert 72) ;; gs-reg64 + (finish uint64 :offset-assert 80) ;; int64 + (finish-addr gs-reg64 :offset-assert 88) ;; gs-reg64 + (trxdir gs-trxdir :offset-assert 96) ;; gs-trxdir + (trxdir-addr gs-reg64 :offset-assert 104) ;; gs-reg64 ) :method-count-assert 9 :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype screen-shot-work (structure) ((count int16 :offset-assert 0) (size int16 :offset-assert 2) (name string :offset-assert 4) ;; guessed by decompiler (highres-enable symbol :offset-assert 8) ;; guessed by decompiler - (highres-objects-enable basic :offset-assert 12) + (highres-objects-enable symbol :offset-assert 12) (hud-enable symbol :offset-assert 16) ;; guessed by decompiler - (letterbox-enable basic :offset-assert 20) - (debug-enable basic :offset-assert 24) + (letterbox-enable symbol :offset-assert 20) + (debug-enable symbol :offset-assert 24) (dir basic :offset-assert 28) - (dir-checked? basic :offset-assert 32) + (dir-checked? symbol :offset-assert 32) ) :method-count-assert 9 :size-assert #x24 :flag-assert #x900000024 ) -|# -;; (define-extern *screen-shot-work* object) ;; screen-shot-work -;; (define-extern *image-name* object) ;; string -;; (define-extern *capture-tga-buffer* object) +(define-extern *screen-shot-work* screen-shot-work) ;; +(define-extern *image-name* string) ;; +(define-extern *capture-tga-buffer* object) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; math-camera-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype vis-gif-tag (structure) + "Unused." ((fog0 uint32 :offset-assert 0) (strip uint32 :offset-assert 4) (regs uint32 :offset-assert 8) @@ -7060,10 +9951,9 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype cull-info (structure) + "Also seems unused." ((x-fact float :offset-assert 0) (y-fact float :offset-assert 4) (z-fact float :offset-assert 8) @@ -7081,17 +9971,16 @@ (yz-dir-bz float :offset-assert 56) (yz-cross-ab float :offset-assert 60) ) + :allow-misaligned :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype math-camera (basic) ((d meters :offset-assert 4) (f meters :offset-assert 8) - (fov deg :offset-assert 12) ;; degrees + (fov degrees :offset-assert 12) ;; degrees (x-ratio float :offset-assert 16) (y-ratio float :offset-assert 20) (x-pix float :offset-assert 24) @@ -7127,15 +10016,15 @@ (hvdf-off vector :inline :offset-assert 816) (guard vector :inline :offset-assert 832) (vis-gifs vis-gif-tag 4 :offset-assert 848) ;; guessed by decompiler - (giftex uint128 :offset-assert 848) - (gifgr uint128 :offset-assert 864) - (giftex-trans uint128 :offset-assert 880) - (gifgr-trans uint128 :offset-assert 896) + (giftex uint128 :offset 848) + (gifgr uint128 :offset 864) + (giftex-trans uint128 :offset 880) + (gifgr-trans uint128 :offset 896) (pfog0 float :offset-assert 912) (pfog1 float :offset-assert 916) (trans vector :inline :offset-assert 928) - (plane plane 4 :offset-assert 944) ;; guessed by decompiler - (guard-plane plane 4 :offset-assert 1008) ;; guessed by decompiler + (plane plane 4 :inline :offset-assert 944) ;; guessed by decompiler + (guard-plane plane 4 :inline :offset-assert 1008) ;; guessed by decompiler (shrub-mat matrix :inline :offset-assert 1072) (quat-other quaternion :inline :offset-assert 1136) (trans-other vector :inline :offset-assert 1152) @@ -7145,30 +10034,27 @@ (camera-rot-other-sky matrix :inline :offset-assert 1360) (camera-rot-other-sprite matrix :inline :offset-assert 1424) (inv-camera-rot-other matrix :inline :offset-assert 1488) - (plane-other plane 4 :offset-assert 1552) ;; guessed by decompiler - (guard-plane-other plane 4 :offset-assert 1616) ;; guessed by decompiler + (plane-other plane 4 :inline :offset-assert 1552) ;; guessed by decompiler + (guard-plane-other plane 4 :inline :offset-assert 1616) ;; guessed by decompiler (mirror-trans vector :inline :offset-assert 1680) (mirror-normal vector :inline :offset-assert 1696) - (fov-correction-factor float :offset-assert 1712) - ) + (fov-correction-factor float :offset-assert 1712)) :method-count-assert 10 :size-assert #x6b4 :flag-assert #xa000006b4 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) + (new (symbol type) _type_) (math-camera-method-9 () none) ;; 9 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; viewport-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype viewport (structure) - ((fog-corner UNKNOWN 4 :offset-assert 0) + ((fog-corner vector 4 :inline :offset-assert 0) (min-fog-corner vector :inline :offset-assert 64) (max-fog-corner vector :inline :offset-assert 80) (prev-inv-camera-rot matrix :inline :offset-assert 96) @@ -7228,7 +10114,8 @@ (screen-cy int32 :offset-assert 592) (ratio-x float :offset-assert 596) (ratio-y float :offset-assert 600) - (prev-inv-camera-rot matrix :inline :offset-assert 96) + ;; TODO - odd... + (pad int32 17 :offset-assert 604) ;; added (minx-on-screen int32 :offset-assert 672) (miny-on-screen int32 :offset-assert 676) (scissor-on-screen uint64 :offset-assert 680) @@ -7246,33 +10133,29 @@ (viewport-method-15 () none) ;; 15 ) ) -|# -#| -(deftype viewport-array (structure) - ((mode uint32 :offset-assert 0) - (num-viewports uint32 :offset-assert 4) - (current-viewport-index uint32 :offset-assert 8) - (data UNKNOWN 3 :offset-assert 16) - (default viewport :inline :offset-assert 1392) - ) - :method-count-assert 12 - :size-assert #x820 - :flag-assert #xc00000820 - (:methods - (viewport-array-method-9 () none) ;; 9 - (viewport-array-method-10 () none) ;; 10 - (viewport-array-method-11 () none) ;; 11 - ) - ) -|# +;; (deftype viewport-array (structure) +;; ((mode uint32 :offset-assert 0) +;; (num-viewports uint32 :offset-assert 4) +;; (current-viewport-index uint32 :offset-assert 8) +;; (data UNKNOWN 3 :offset-assert 16) +;; (default viewport :inline :offset-assert 1392) +;; ) +;; :method-count-assert 12 +;; :size-assert #x820 +;; :flag-assert #xc00000820 +;; (:methods +;; (viewport-array-method-9 () none) ;; 9 +;; (viewport-array-method-10 () none) ;; 10 +;; (viewport-array-method-11 () none) ;; 11 +;; ) +;; ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; blit-displays-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype blit-displays-work (structure) ((adgif-tmpl dma-gif-packet :inline :offset-assert 0) (sprite-tmpl dma-gif-packet :inline :offset-assert 32) @@ -7285,7 +10168,7 @@ (scan-tmpl dma-gif-packet :inline :offset-assert 256) (color vector4w :inline :offset-assert 288) (line-color uint64 :offset-assert 304) ;; gs-rgbaq - (scan-colors vector4w 15 :offset-assert 320) ;; guessed by decompiler + (scan-colors vector4w 15 :inline :offset-assert 320) ;; guessed by decompiler (vu1-enable-user-menu uint64 :offset-assert 560) ;; vu1-renderer-mask (texture-enable-user-menu uint32 :offset-assert 568) (horizontal-flip-flag symbol :offset-assert 572) ;; guessed by decompiler @@ -7309,41 +10192,38 @@ (blit-displays-work-method-16 () none) ;; 16 ;; (draw-zoom-blur (_type_ dma-buffer int) none) (blit-displays-work-method-17 () none) ;; 17 ;; (setup-zoom-blur-2d (_type_ vector int float symbol) none) (blit-displays-work-method-18 () none) ;; 18 ;; (draw-brightness-and-contrast (_type_ dma-buffer float float) none) - (blit-displays-work-method-19 () none) ;; 19 ;; (do-blit-displays (_type_) none) - (blit-displays-work-method-20 () none) ;; 20 ;; (blit-menu-mode (_type_ dma-buffer) none) + (get-horizontal-flip-flag (_type_) symbol) ;; 19 ;; (do-blit-displays (_type_) none) + (set-horizontal-flip-flag (_type_ symbol) symbol) ;; 20 ;; (blit-menu-mode (_type_ dma-buffer) none) (blit-displays-work-method-21 () none) ;; 21 ;; (get-menu-mode (_type_) symbol) (blit-displays-work-method-22 () none) ;; 22 ;; (get-screen-copied (_type_) symbol) - (blit-displays-work-method-23 () none) ;; 23 ;; (get-horizontal-flip-flag (_type_) symbol) + (blit-displays-work-method-23 () none) ;; 23 ;; ( (_type_) symbol) (blit-displays-work-method-24 () none) ;; 24 ;; (set-menu-mode (_type_ symbol) symbol) (blit-displays-work-method-25 () none) ;; 25 ;; (set-screen-copied (_type_ symbol) symbol) - (blit-displays-work-method-26 () none) ;; 26 ;; (set-horizontal-flip-flag (_type_ symbol) symbol) + (blit-displays-work-method-26 () none) ;; 26 ;; ( (_type_ symbol) symbol) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sparks-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype spark (structure) ((pos vector :inline :offset-assert 0) - (age float :offset-assert 12) + (age float :offset 12) (vel vector :inline :offset-assert 16) - (length float :offset-assert 28) + (length float :offset 28) (accel vector :inline :offset-assert 32) - (alpha float :offset-assert 44) + (alpha float :offset 44) ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| + (deftype spark-vport (structure) - ((mat UNKNOWN 4 :offset-assert 0) + ((mat matrix 4 :inline :offset-assert 0) (hvdf-offset vector :inline :offset-assert 256) (hmge-scale vector :inline :offset-assert 272) (frame qword :inline :offset-assert 288) @@ -7355,25 +10235,21 @@ :size-assert #x160 :flag-assert #x900000160 ) -|# -#| (deftype spark-color-group (structure) - ((colors UNKNOWN 4 :offset-assert 0) + ((colors vector 4 :inline :offset-assert 0) (alpha gs-adcmd :inline :offset-assert 64) ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype spark-constants (structure) - ((vport UNKNOWN 2 :offset-assert 0) + ((vport spark-vport 2 :inline :offset-assert 0) (adgif-tag qword :inline :offset-assert 704) - (prim-tags UNKNOWN 3 :offset-assert 720) - (color-groups UNKNOWN 13 :offset-assert 768) + (prim-tags vector 3 :inline :offset-assert 720) + (color-groups spark-color-group 13 :inline :offset-assert 768) (friction float :offset-assert 1808) (scale float :offset-assert 1812) (matrix-count int32 :offset-assert 1816) @@ -7383,9 +10259,7 @@ :size-assert #x720 :flag-assert #x900000720 ) -|# -#| (deftype spark-vert (structure) ((color vector :inline :offset-assert 0) (pos vector :inline :offset-assert 16) @@ -7394,21 +10268,17 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype spark-line-packet (structure) ((tag qword :inline :offset-assert 0) (alpha qword :inline :offset-assert 16) - (verts UNKNOWN 4 :offset-assert 32) + (verts spark-vert 4 :inline :offset-assert 32) ) :method-count-assert 9 :size-assert #xa0 :flag-assert #x9000000a0 ) -|# -#| (deftype spark-viewport-packet (structure) ((tag qword :inline :offset-assert 0) (frame qword :inline :offset-assert 16) @@ -7419,9 +10289,7 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype spark-launch-params (structure) ((pos vector :inline :offset-assert 0) (vel vector :inline :offset-assert 16) @@ -7436,38 +10304,35 @@ :size-assert #x44 :flag-assert #x900000044 ) -|# -#| -(deftype sparks-work (basic) - ((next-free int32 :offset-assert 4) - (constants spark-constants :inline :offset-assert 16) - (start vector :inline :offset-assert 1840) - (vel vector :inline :offset-assert 1856) - (accel vector :inline :offset-assert 1872) - (test basic :offset-assert 1888) - (vecs UNKNOWN 4 :offset-assert 1904) - (y-floor UNKNOWN 512 :offset-assert 1968) - (data UNKNOWN 512 :offset-assert 4016) - ) - :method-count-assert 20 - :size-assert #x6fb0 - :flag-assert #x1400006fb0 - (:methods - (sparks-work-method-9 () none) ;; 9 - (sparks-work-method-10 () none) ;; 10 - (sparks-work-method-11 () none) ;; 11 - (sparks-work-method-12 () none) ;; 12 - (sparks-work-method-13 () none) ;; 13 - (sparks-work-method-14 () none) ;; 14 - (sparks-work-method-15 () none) ;; 15 - (sparks-work-method-16 () none) ;; 16 - (sparks-work-method-17 () none) ;; 17 - (sparks-work-method-18 () none) ;; 18 - (sparks-work-method-19 () none) ;; 19 - ) - ) -|# +;; (deftype sparks-work (basic) +;; ((next-free int32 :offset-assert 4) +;; (constants spark-constants :inline :offset-assert 16) +;; (start vector :inline :offset-assert 1840) +;; (vel vector :inline :offset-assert 1856) +;; (accel vector :inline :offset-assert 1872) +;; (test basic :offset-assert 1888) +;; (vecs vector 4 :inline :offset-assert 1904) +;; (y-floor int32 512 :offset-assert 1968) +;; (data spark-viewport-packet 512 :inline :offset-assert 4016) +;; ) +;; :method-count-assert 20 +;; :size-assert #x6fb0 +;; :flag-assert #x1400006fb0 +;; (:methods +;; (sparks-work-method-9 () none) ;; 9 +;; (sparks-work-method-10 () none) ;; 10 +;; (sparks-work-method-11 () none) ;; 11 +;; (sparks-work-method-12 () none) ;; 12 +;; (sparks-work-method-13 () none) ;; 13 +;; (sparks-work-method-14 () none) ;; 14 +;; (sparks-work-method-15 () none) ;; 15 +;; (sparks-work-method-16 () none) ;; 16 +;; (sparks-work-method-17 () none) ;; 17 +;; (sparks-work-method-18 () none) ;; 18 +;; (sparks-work-method-19 () none) ;; 19 +;; ) +;; ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -7531,7 +10396,6 @@ ;; font-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype font-char-effect (structure) ((scale-x float :offset-assert 0) (scale-y float :offset-assert 4) @@ -7544,9 +10408,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype char-color (structure) ((color rgba 4 :offset-assert 0) ;; guessed by decompiler ) @@ -7554,9 +10416,76 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| +;; +++font-h:font-flags +(defenum font-flags + :type uint16 + :bitfield #t + (shadow 0) + (kerning 1) + (middle 2) + (middle-vert 3) + (right 4) + (large 5) + (pc-hack 6) + (ff7 7) + (ff8 8) + (ff9 9) + ) +;; ---font-h:font-flags + + +;; +++font-h:font-color +(defenum font-color + :type uint8 + (default 0) + (white 1) + (transparent 2) + (red 3) + (orange 4) + (yellow 5) + (green 6) + (blue 7) + (cyan 8) + (pink 9) + (menu-selected 10) + (menu-selected-parent 11) + (menu 12) + (menu-parent 13) + (menu-func-bad 14) + (menu-flag-on 15) + (menu-flag-on-parent 16) + (menu-flag-off 17) + (menu-flag-off-parent 18) + (menu-invalid 19) + (flat-yellow 20) + (font-color-21 21) + (pad-back 22) + (pad-shine 23) + (pad-square 24) + (pad-circle 25) + (pad-triangle 26) + (pad-x 27) + (progress-old-blue 28) + (progress-old-yellow 29) + (progress-old-selected 30) + (progress-old-percent 31) + (font-color-32 32) + (font-color-33 33) + (font-color-34 34) + (font-color-35 35) + (font-color-36 36) + (font-color-37 37) + (font-color-38 38) + (font-color-39 39) + (font-color-40 40) + (font-color-41 41) + (font-color-42 42) + (font-color-43 43) + (font-color-44 44) + ) +;; ---font-h:font-color + (deftype font-context (basic) ((y-spacing float :offset-assert 4) (alpha float :offset-assert 8) @@ -7576,41 +10505,39 @@ (scale float :offset-assert 172) (mat matrix :offset-assert 176) (effect-time float :offset-assert 180) - (color uint8 :offset-assert 184) ;; font-color - (effect uint8 :offset-assert 185) - (effect-color uint8 :offset-assert 186) + (color font-color :offset-assert 184) ;; font-color + (effect uint8 :offset-assert 185) ;; TODO - some enum + (effect-color font-color :offset-assert 186) ) :method-count-assert 30 :size-assert #xbb :flag-assert #x1e000000bb (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type matrix int int float font-color font-flags) _type_) + (new (symbol type matrix int int float font-color font-flags) _type_) (font-context-method-9 () none) ;; 9 ;; (set-mat! (font-context matrix) font-context) (font-context-method-10 () none) ;; 10 ;; (set-origin! (font-context int int) font-context) (font-context-method-11 () none) ;; 11 ;; (set-depth! (font-context int) font-context) (font-context-method-12 () none) ;; 12 ;; (set-w! (font-context float) font-context) - (font-context-method-13 () none) ;; 13 ;; (set-width! (font-context int) font-context) - (font-context-method-14 () none) ;; 14 ;; (set-height! (font-context int) font-context) - (font-context-method-15 () none) ;; 15 ;; (set-projection! (font-context float) font-context) - (font-context-method-16 () none) ;; 16 ;; (set-color! (font-context font-color) font-context) - (font-context-method-17 () none) ;; 17 ;; (set-flags! (font-context font-flags) font-context) - (font-context-method-18 () none) ;; 18 ;; (set-start-line! (font-context uint) font-context) - (font-context-method-19 () none) ;; 19 ;; (set-scale! (font-context float) font-context) - (font-context-method-20 () none) ;; 20 ;; (set-alpha! (font-context float) font-context) - (font-context-method-21 () none) ;; 21 - (font-context-method-22 () none) ;; 22 - (font-context-method-23 () none) ;; 23 - (font-context-method-24 () none) ;; 24 - (font-context-method-25 () none) ;; 25 - (font-context-method-26 () none) ;; 26 - (font-context-method-27 () none) ;; 27 - (font-context-method-28 () none) ;; 28 - (font-context-method-29 () none) ;; 29 + (set-mat! (_type_ matrix) none) ;; 13 ;; (set-width! (font-context int) font-context) + (set-x-y! (_type_ int int) none) ;; 14 ;; (set-height! (font-context int) font-context) + (set-z! (_type_ int) none) ;; 15 ;; (set-projection! (font-context float) font-context) + (set-w! (_type_ float) none) ;; 16 ;; (set-color! (font-context font-color) font-context) + (set-width! (_type_ int) none) ;; 17 ;; (set-flags! (font-context font-flags) font-context) + (set-height! (_type_ int) none) ;; 18 ;; (set-start-line! (font-context uint) font-context) + (set-projection! (_type_ float) none) ;; 19 ;; (set-scale! (font-context float) font-context) + (set-color! (_type_ font-color) none) ;; 20 + (set-flags! (_type_ font-flags) none) ;; 21 + (set-start-line! (_type_ float) none) ;; 22 + (set-scale! (_type_ float) none) ;; 23 + (set-alpha! (_type_ float) none) ;; 24 + (set-y-spacing! (_type_ float) none) ;; 25 + (set-meters-per-texel! (_type_ float) none) ;; 26 + (set-effect! (_type_ uint) none) ;; 27 + (set-effect-color! (_type_ font-color) none) ;; 28 + (set-effect-time! (_type_ float) none) ;; 29 ) ) -|# -#| (deftype char-packet (structure) ((tag dma-gif-packet :inline :offset-assert 0) (font dma-packet :inline :offset-assert 32) @@ -7629,9 +10556,7 @@ :size-assert #xd0 :flag-assert #x9000000d0 ) -|# -#| (deftype char-ad-packet (structure) ((tag dma-gif-packet :inline :offset-assert 0) (font dma-packet :inline :offset-assert 32) @@ -7640,9 +10565,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype char-2d-packet (structure) ((tag dma-gif-packet :inline :offset-assert 0) (font dma-packet :inline :offset-assert 32) @@ -7656,9 +10579,7 @@ :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype char-2d-packet-no-packed (structure) ((tag dma-gif-packet :inline :offset-assert 0) (color0 uint64 :offset-assert 32) @@ -7672,9 +10593,7 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype char-packet-no-packed (structure) ((tag dma-gif-packet :inline :offset-assert 0) (prim uint64 :offset-assert 32) @@ -7692,9 +10611,7 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype char-3d-packet (structure) ((tag dma-gif-packet :inline :offset-assert 0) (font dma-packet :inline :offset-assert 32) @@ -7713,9 +10630,7 @@ :size-assert #xd0 :flag-assert #x9000000d0 ) -|# -#| (deftype font-work (structure) ((char-2d-tmpl dma-gif-packet :inline :offset-assert 0) (char-2d-no-packed-tmpl dma-gif-packet :inline :offset-assert 32) @@ -7746,25 +10661,25 @@ (save-color vector :inline :offset-assert 512) (save-color2 vector :inline :offset-assert 528) (current-color vector4w :inline :offset-assert 544) - (current-colorq uint64 :offset-assert 544) + (current-colorq uint64 :offset 544) (current-color2 vector4w :inline :offset-assert 560) - (current-color2q uint64 :offset-assert 560) - (effect-colors UNKNOWN 2 :offset-assert 576) + (current-color2q uint64 :offset 560) + (effect-colors vector4w 2 :inline :offset-assert 576) (color-shadow vector4w :inline :offset-assert 608) (color-outline vector4w :inline :offset-assert 624) - (justify vector 256 :offset-assert 640) ;; guessed by decompiler + (justify vector 256 :inline :offset-assert 640) ;; guessed by decompiler (hvdf-offset vector :inline :offset-assert 4736) (hvdf-shadow vector :inline :offset-assert 4752) - (hvdf-outline UNKNOWN 4 :offset-assert 4768) - (hvdf-outline0 vector :inline :offset-assert 4768) - (hvdf-outline1 vector :inline :offset-assert 4784) - (hvdf-outline2 vector :inline :offset-assert 4800) - (hvdf-outline3 vector :inline :offset-assert 4816) + (hvdf-outline vector 4 :inline :offset-assert 4768) + (hvdf-outline0 vector :inline :offset 4768) + (hvdf-outline1 vector :inline :offset 4784) + (hvdf-outline2 vector :inline :offset 4800) + (hvdf-outline3 vector :inline :offset 4816) (save-pos0 vector :inline :offset-assert 4832) (save-pos1 vector :inline :offset-assert 4848) (save-pos2 vector :inline :offset-assert 4864) (save-pos3 vector :inline :offset-assert 4880) - (color-table char-color 74 :offset-assert 4896) ;; guessed by decompiler + (color-table char-color 74 :inline :offset-assert 4896) ;; guessed by decompiler (current-font-0-tmpl uint64 2 :offset-assert 6080) ;; guessed by decompiler (current-font-1-tmpl uint64 2 :offset-assert 6096) ;; guessed by decompiler (current-font-2-tmpl uint64 2 :offset-assert 6112) ;; guessed by decompiler @@ -7780,22 +10695,20 @@ :size-assert #x1824 :flag-assert #x900001824 ) -|# -;; (define-extern *font-work* object) ;; font-work -;; (define-extern font-set-tex0 function) ;; (function (pointer gs-tex0) texture int int int none) -;; (define-extern set-font-color function) ;; (function font-color rgba rgba rgba rgba int) -;; (define-extern *font-default-matrix* object) ;; matrix -;; (define-extern *font-default-matrix-3d* object) -;; (define-extern *font-context* object) ;; font-context -;; (define-extern *font-context-3d* object) -;; (define-extern *font-char-effect* object) +(define-extern *font-work* font-work) +(define-extern font-set-tex0 (function (pointer gs-tex0) texture int int int none)) +(define-extern set-font-color (function font-color rgba rgba rgba rgba int)) +(define-extern *font-default-matrix* matrix) +(define-extern *font-default-matrix-3d* matrix) +(define-extern *font-context* font-context) +(define-extern *font-context-3d* font-context) +(define-extern *font-char-effect* font-char-effect) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; decomp-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype decomp-work (structure) ((buffer0 uint8 2048 :offset-assert 0) ;; guessed by decompiler (buffer1 uint8 2048 :offset-assert 2048) ;; guessed by decompiler @@ -7806,15 +10719,14 @@ :size-assert #x3000 :flag-assert #x900003000 ) -|# - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; time-of-day-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype palette-fade-control (structure) + "Unused interface to the time-of-day control. Was used in jak 1 as an interface between level code, + and the code in mood.gc, which set the actual fade values for time-of-day." ((trans vector :inline :offset-assert 0) (fade float :offset-assert 16) (actor-dist float :offset-assert 20) @@ -7823,24 +10735,25 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype palette-fade-controls (basic) - ((control palette-fade-control 8 :offset-assert 16) ;; guessed by decompiler + "Unused interface to the time-of-day control. Was used in jak 1 as an interface between level code, + and the code in mood.gc, which set the actual fade values for time-of-day." + ((control palette-fade-control 8 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 11 :size-assert #x110 :flag-assert #xb00000110 (:methods - (palette-fade-controls-method-9 () none) ;; 9 ;; (reset! (_type_) none) - (palette-fade-controls-method-10 () none) ;; 10 ;; (set-fade! (_type_ int float float vector) object) + (reset! (_type_) none) ;; 9 + (set-fade! (_type_ int float float vector) object) ;; 10 ) ) -|# -#| +(declare-type sparticle-launch-control inline-array-class) + (deftype time-of-day-proc (process) + "Process for running things that change with the time-of-day, like lighting, sun/stars/moon, etc." ((hours int32 :offset-assert 144) (minutes int32 :offset-assert 148) (seconds int32 :offset-assert 152) @@ -7866,19 +10779,12 @@ :method-count-assert 15 :size-assert #x104 :flag-assert #xf00800104 - (:methods - (time-of-day-proc-method-9 () none) ;; 9 - (time-of-day-proc-method-10 () none) ;; 10 - (time-of-day-proc-method-11 () none) ;; 11 - (time-of-day-proc-method-12 () none) ;; 12 - (time-of-day-proc-method-13 () none) ;; 13 - (time-of-day-proc-method-14 () none) ;; 14 - ) ) -|# -#| (deftype time-of-day-palette (basic) + "Pre-baked lighting values used by rendering code. The exact meaning of this data can vary, + but in all cases, the time-of-day system can do linear interpolation of two palettes to + blend between them." ((width int32 :offset-assert 4) (height int32 :offset-assert 8) (pad int32 :offset-assert 12) @@ -7888,19 +10794,37 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| +;; +++mood:time-of-day-palette-id +(defenum time-of-day-palette-id + :type uint32 + :bitfield #t + (unk0 0) ;; 1 + (unk1 1) ;; 2 + (unk2 2) ;; 4 + (unk3 3) ;; 8 + (palette-0 4) ;; 16 + (palette-1 5) ;; 32 + (palette-2 6) ;; 64 + (palette-3 7) ;; 128 + (palette-4 8) ;; 256 + (palette-5 9) ;; 512 + (palette-6 10) ;; 1024 + (palette-7 11) ;; 2048 + ) +;; ---mood:time-of-day-palette-id + (deftype time-of-day-context (basic) + "A mix of inputs/outputs to the time-of-day system." ((interp float 18 :offset-assert 4) ;; guessed by decompiler (current-fog mood-fog :inline :offset-assert 80) (current-sky-color vector :inline :offset-assert 128) (current-env-color vector :inline :offset-assert 144) (current-prt-color vector :inline :offset-assert 160) (current-shadow-color vector :inline :offset-assert 176) - (light-group light-group 8 :offset-assert 192) ;; guessed by decompiler + (light-group light-group 8 :inline :offset-assert 192) ;; guessed by decompiler (current-clouds mood-clouds :inline :offset-assert 1728) - (times vector 8 :offset-assert 1744) ;; guessed by decompiler + (times vector 8 :inline :offset-assert 1744) ;; guessed by decompiler (title-light-group light-group :inline :offset-assert 1872) (rim-light-group light-group :inline :offset-assert 2064) (front-rear-light-group light-group :inline :offset-assert 2256) @@ -7927,10 +10851,9 @@ :size-assert #xa1c :flag-assert #x900000a1c ) -|# -#| (deftype time-of-day-dma (structure) + "Memory layout for the time-of-day interpolation functions." ((outa uint32 256 :offset-assert 0) ;; guessed by decompiler (outb uint32 256 :offset-assert 1024) ;; guessed by decompiler (banka uint32 256 :offset-assert 2048) ;; guessed by decompiler @@ -7940,17 +10863,16 @@ :size-assert #x1000 :flag-assert #x900001000 ) -|# -;; (define-extern *palette-fade-controls* object) ;; palette-fade-controls -;; (define-extern *time-of-day-context* time-of-day-context) ;; time-of-day-context +(define-extern *palette-fade-controls* palette-fade-controls) +(define-extern *time-of-day-context* time-of-day-context) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; profile ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype profile-work (structure) + "DMA templates for profile drawing." ((sprite-tmpl dma-gif-packet :inline :offset-assert 0) (line-tmpl dma-gif-packet :inline :offset-assert 32) (last-index int32 :offset-assert 64) @@ -7959,26 +10881,25 @@ :size-assert #x44 :flag-assert #x900000044 ) -|# -;; (define-extern *profile-spec-array* object) ;; (inline-array profile-spec) -;; (define-extern *profile-translate-array* array) ;; (pointer uint64) -;; (define-extern *profile-work* object) ;; profile-work -;; (define-extern *profile-x* object) ;; int -;; (define-extern *profile-y* object) ;; int -;; (define-extern *profile-w* object) ;; int -;; (define-extern *profile-h* object) ;; int -;; (define-extern *profile-ticks* object) ;; symbol +(define-extern *profile-spec-array* (inline-array profile-spec)) +(define-extern *profile-translate-array* (array uint8)) +(define-extern *profile-work* profile-work) +(define-extern *profile-x* int) +(define-extern *profile-y* int) +(define-extern *profile-w* int) +(define-extern *profile-h* int) +(define-extern *profile-ticks* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; display ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern get-current-time function) ;; (function time-frame) -;; (define-extern get-integral-current-time function) ;; (function time-frame) -;; (define-extern get-real-current-time function) ;; (function time-frame) -;; (define-extern set-display function) ;; (function display display) -;; (define-extern allocate-dma-buffers function) ;; (function display display) +(define-extern get-current-time (function time-frame)) +(define-extern get-integral-current-time (function time-frame)) +(define-extern get-real-current-time (function time-frame)) +(define-extern set-display "Allocate and initialize clocks for the display." (function display display)) +(define-extern allocate-dma-buffers "Allocate the main, debug, and calc dma buffers." (function display display)) ;; (define-extern draw-sprite2d-xy function) ;; (function dma-buffer int int int int rgba int none) ;; (define-extern draw-sprite2d-xy-absolute function) ;; (function dma-buffer int int int int rgba int none) ;; (define-extern draw-quad2d function) ;; (function dma-buffer draw-context none) @@ -7988,75 +10909,31 @@ ;; (define-extern vblank-handler function) ;; (function int) ;; (define-extern set-display-gs-state function) ;; (function dma-buffer int int int int int dma-buffer) ;; (define-extern set-display-gs-state-offset function) ;; (function dma-buffer int int int int int int int dma-buffer) -;; (define-extern reset-display-gs-state function) ;; (function display dma-buffer display) -;; (define-extern *vu0-dma-list* object) ;; dma-buffer -;; (define-extern *display* object) ;; display - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; text-h ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -#| -(deftype game-text (structure) - ((id text-id :offset-assert 0) ;; guessed by decompiler - (index uint32 :offset-assert 4) - ) - :method-count-assert 9 - :size-assert #x8 - :flag-assert #x900000008 - ) -|# - -#| -(deftype game-text-info (basic) - ((length int32 :offset-assert 4) - (language-id int32 :offset-assert 8) - (group-name string :offset-assert 12) ;; guessed by decompiler - (dic-index uint32 :offset-assert 16) - (dic-data uint32 :offset-assert 20) - (text uint32 :offset-assert 24) - (text-data uint32 :offset-assert 28) - ) - :method-count-assert 13 - :size-assert #x20 - :flag-assert #xd00000020 - (:methods - (game-text-info-method-9 () none) ;; 9 ;; (lookup-text! (_type_ text-id symbol) string) - (game-text-info-method-10 () none) ;; 10 - (game-text-info-method-11 () none) ;; 11 - (game-text-info-method-12 () none) ;; 12 - ) - ) -|# - -;; (define-extern *text-group-names* array) ;; (array string) -;; (define-extern *common-text-heap* object) ;; kheap -;; (define-extern *common-text* object) ;; game-text-info +(define-extern reset-display-gs-state (function display dma-buffer display)) ;; +(define-extern *vu0-dma-list* dma-buffer) ;; +(define-extern *display* display) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; camera-defs-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype camera-bank (basic) ((collide-move-rad float :offset-assert 4) (joypad uint32 :offset-assert 8) (min-detectable-velocity float :offset-assert 12) - (attack-timeout uint64 :offset-assert 16) ;; time-frame + (attack-timeout time-frame :offset-assert 16) ;; time-frame (default-string-max-y meters :offset-assert 24) (default-string-min-y meters :offset-assert 28) (default-string-max-z meters :offset-assert 32) (default-string-min-z meters :offset-assert 36) (default-string-push-z meters :offset-assert 40) - (default-tilt-adjust deg :offset-assert 44) ;; degrees + (default-tilt-adjust degrees :offset-assert 44) ;; degrees ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype camera-master-bank (basic) ((onscreen-head-height meters :offset-assert 4) (onscreen-foot-height meters :offset-assert 8) @@ -8071,20 +10948,32 @@ :size-assert #x24 :flag-assert #x900000024 ) -|# -;; (define-extern *CAMERA-bank* camera-bank) ;; camera-bank -;; (define-extern *CAMERA_MASTER-bank* camera-master-bank) ;; camera-master-bank +(define-extern *CAMERA-bank* camera-bank) ;; camera-bank +(define-extern *CAMERA_MASTER-bank* camera-master-bank) ;; camera-master-bank ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; settings-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++settings-h:game-secrets +(defenum game-secrets + :type uint64 + :bitfield #t + (hero-mode 0) + ) +;; ---settings-h:game-secrets + +(declare-type resetter-spec structure) (deftype user-setting-data (structure) ((border-mode symbol :offset-assert 0) ;; guessed by decompiler (process-mask process-mask :offset-assert 4) ;; guessed by decompiler - (language uint8 :offset-assert 12) ;; language-enum + (common-page int32 :offset-assert 8) ;; added + (language language-enum :offset-assert 12) ;; language-enum + (unknown-usd-1 int32 :offset-assert 16) ;; added + (unknown-usd-2 int32 :offset-assert 20) ;; added + (unknown-usd-3 int32 :offset-assert 24) ;; added + (unknown-usd-4 int32 :offset-assert 28) ;; added (movie (pointer process) :offset-assert 32) ;; guessed by decompiler (talking (pointer process) :offset-assert 36) ;; guessed by decompiler (spooling (pointer process) :offset-assert 40) ;; guessed by decompiler @@ -8092,7 +10981,11 @@ (ambient (pointer process) :offset-assert 48) ;; guessed by decompiler (video-mode symbol :offset-assert 52) ;; guessed by decompiler (aspect-ratio symbol :offset-assert 56) ;; guessed by decompiler + (unknown-usd-5 int32 :offset-assert 60) ;; added + (unknown-usd-6 int32 :offset-assert 64) ;; added + (unknown-usd-7 int32 :offset-assert 68) ;; added (auto-save symbol :offset-assert 72) ;; guessed by decompiler + (unknown-usd-8 int32 :offset-assert 76) ;; added (bg-r float :offset-assert 80) (bg-g float :offset-assert 84) (bg-b float :offset-assert 88) @@ -8104,9 +10997,16 @@ (allow-progress symbol :offset-assert 112) ;; guessed by decompiler (allow-in-game-menu basic :offset-assert 116) (allow-pause symbol :offset-assert 120) ;; guessed by decompiler + (unknown-usd-9 int32 :offset-assert 124) ;; added + (unknown-usd-10 int32 :offset-assert 128) ;; added + (unknown-usd-11 int32 :offset-assert 132) ;; added (movie-name symbol :offset-assert 136) ;; guessed by decompiler (weather symbol :offset-assert 140) ;; guessed by decompiler + (unknown-usd-12 int32 :offset-assert 144) ;; added + (unknown-usd-13 int32 :offset-assert 148) ;; added + (unknown-usd-14 int32 :offset-assert 152) ;; added (task-mask task-mask :offset-assert 156) + (unknown-usd-15 int32 :offset-assert 160) ;; added (speed-mult float :offset-assert 164) (features uint64 :offset-assert 168) ;; game-feature (vehicles uint64 :offset-assert 176) ;; game-vehicles @@ -8132,6 +11032,8 @@ (airlock symbol :offset-assert 260) ;; guessed by decompiler (minimap uint32 :offset-assert 264) (allow-continue symbol :offset-assert 268) ;; guessed by decompiler + (unknown-usd-16 int32 :offset-assert 272) ;; added + (unknown-usd-17 int32 :offset-assert 276) ;; added (subtitle symbol :offset-assert 280) ;; guessed by decompiler (doorway symbol :offset-assert 284) ;; guessed by decompiler (gem symbol :offset-assert 288) ;; guessed by decompiler @@ -8159,6 +11061,7 @@ (sound-bank-load symbol :offset-assert 376) ;; guessed by decompiler (allow-error symbol :offset-assert 380) ;; guessed by decompiler (under-water-pitch-mod float :offset-assert 384) + (unknown-usd-18 int32 :offset-assert 388) ;; added (restart-info resetter-spec :offset-assert 392) ;; guessed by decompiler (fail-info resetter-spec :offset-assert 396) ;; guessed by decompiler (death-info resetter-spec :offset-assert 400) ;; guessed by decompiler @@ -8170,12 +11073,29 @@ (exclusive-task-count uint32 :offset-assert 440) (exclusive-task int32 3 :offset-assert 444) ;; guessed by decompiler (level-trans-time int32 :offset-assert 456) + (unknown-usd-19 int32 :offset-assert 460) ;; added + (unknown-usd-20 int32 :offset-assert 464) ;; added + (unknown-usd-21 int32 :offset-assert 468) ;; added + (unknown-usd-22 int32 :offset-assert 472) ;; added + (unknown-usd-23 int32 :offset-assert 476) ;; added (letterbox float :offset-assert 480) (letterbox-speed float :offset-assert 484) + (unknown-usd-24 int32 :offset-assert 488) ;; added + (unknown-usd-25 int32 :offset-assert 492) ;; added + (unknown-usd-26 int32 :offset-assert 496) ;; added + (unknown-usd-27 int32 :offset-assert 500) ;; added + (unknown-usd-28 int32 :offset-assert 504) ;; added + (unknown-usd-29 int32 :offset-assert 508) ;; added + (unknown-usd-30 int32 :offset-assert 512) ;; added + (unknown-usd-31 int32 :offset-assert 516) ;; added + (unknown-usd-32 int32 :offset-assert 520) ;; added (borrow-city-count uint32 :offset-assert 524) (borrow-city pair 3 :offset-assert 528) ;; guessed by decompiler + (unknown-usd-33 int32 28 :offset-assert 540) ;; added (audio-language uint8 :offset-assert 652) ;; language-enum + (unknown-usd-34 int32 11 :offset-assert 656) ;; added (special-volume float :offset-assert 700) + (unknown-usd-35 int32 17 :offset-assert 704) ;; added ) :method-count-assert 11 :size-assert #x304 @@ -8185,15 +11105,63 @@ (user-setting-data-method-10 () none) ;; 10 ;; (user-setting-data-method-10 (_type_ object symbol float uint) user-setting-data) ) ) -|# -#| +;; +++settings-h:cam-slave-options +(defenum cam-slave-options + :type uint64 + :bitfield #t + (BUTT_CAM) + (SAME_SIDE) + (MOVE_SPHERICAL) + (ALLOW_Z_ROT) + (JUMP_PITCHES) + (COLLIDE) + (FIND_HIDDEN_TARGET) + (DRAG) + (PLAYER_MOVING_CAMERA) + (LINE_OF_SIGHT) + (MOVEMENT_BLOCKED) + (SHRINK_MAX_ANGLE) + (GOTO_GOOD_POINT) + (BIKE_MODE) + (NO_ROTATE) + (STICKY_ANGLE) + (BLOCK_RIGHT_STICK) + (ALLOW_SHIFT_BUTTONS) + (GUN_CAM) + (WIDE_FOV) + (RAPID_TRACKING) + (EASE_SPLINE_IDX) + (VERTICAL_FOLLOW_MATCHES_CAMERA) + (HAVE_BUTT_HANDLE) + (BOMBBOT) + (JUMP_LAG) + ) +;; ---settings-h:cam-slave-options + +;; +++settings-h:cam-master-options +(defenum cam-master-options + :type uint64 + :bitfield #t + (HAVE_TARGET) ;; 1 + (SET_COMBINER_AXIS) ;; 2 + (FLIP_COMBINER) ;; 4 + (HAVE_EASE_TO_POS) ;; 8 + (IN_BASE_REGION) ;; 10 + (IGNORE_ANALOG) ;; 20 + (BLOCK_RIGHT_STICK) ;; 40 + (USE_L1_R1) ;; 80 + (READ_BUTTONS) + (IMMEDIATE_STRING_MIN_MAX) + ) +;; ---settings-h:cam-master-options + (deftype cam-setting-data (structure) - ((fov deg :offset-assert 0) ;; degrees - (pov-handle uint64 :offset-assert 16) ;; handle + ((fov degrees :offset-assert 0) ;; degrees + (pov-handle uint64 :offset 16) ;; handle (pov-bone int32 :offset-assert 24) (pov-offset vector :inline :offset-assert 32) - (string-default boolean :offset-assert 48) ;; symbol + (string-default symbol :offset-assert 48) ;; symbol (string-max-length meters :offset-assert 52) (string-min-length meters :offset-assert 56) (string-max-height meters :offset-assert 60) @@ -8205,7 +11173,7 @@ (gun-min-height meters :offset-assert 84) (string-local-down vector :inline :offset-assert 96) (slave-options cam-slave-options :offset-assert 112) - (matrix-blend-max-angle deg :offset-assert 120) ;; degrees + (matrix-blend-max-angle degrees :offset-assert 120) ;; degrees (matrix-blend-max-partial float :offset-assert 124) (string-spline-max-move meters :offset-assert 128) (string-spline-accel meters :offset-assert 132) @@ -8218,10 +11186,10 @@ (target-height meters :offset-assert 196) (foot-offset meters :offset-assert 200) (head-offset meters :offset-assert 204) - (teleport-on-entity-change boolean :offset-assert 208) ;; symbol + (teleport-on-entity-change symbol :offset-assert 208) ;; symbol (entity-name string :offset-assert 212) (cam-slope string :offset-assert 216) - (entity-or-mode-changed boolean :offset-assert 220) ;; symbol + (entity-or-mode-changed symbol :offset-assert 220) ;; symbol (master-options cam-master-options :offset-assert 224) (entity-mask uint32 :offset-assert 232) (mode-name symbol :offset-assert 236) ;; guessed by decompiler @@ -8246,6 +11214,7 @@ (string-min-height-default symbol :offset-assert 368) ;; guessed by decompiler (flip-vertical symbol :offset-assert 372) ;; guessed by decompiler (flip-horizontal symbol :offset-assert 376) ;; guessed by decompiler + (dummy object 1 :offset-assert 380) ;; guessed by decompiler (fov-priority float :offset-assert 384) (ocean-off basic :offset-assert 388) (ocean-override basic :offset-assert 392) @@ -8260,9 +11229,7 @@ (cam-setting-data-method-10 () none) ;; 10 ;; (cam-setting-data-method-10 (_type_ object (pointer process) float int) _type_) ) ) -|# -#| (deftype cam-setting-state (structure) ((current cam-setting-data :inline :offset-assert 0) (target cam-setting-data :inline :offset-assert 400) @@ -8272,9 +11239,7 @@ :size-assert #x4b0 :flag-assert #x9000004b0 ) -|# -#| (deftype engine-group (structure) ((engine basic :offset-assert 0) (engine-pers basic :offset-assert 4) @@ -8284,24 +11249,22 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype setting-control (basic) ((user-current user-setting-data :inline :offset-assert 16) (user-target user-setting-data :inline :offset-assert 800) (user-default user-setting-data :inline :offset-assert 1584) - (cam-settings UNKNOWN 4 :offset-assert 2368) + (cam-settings cam-setting-state 4 :inline :offset-assert 2368) (engine engine :offset-assert 7168) ;; guessed by decompiler (engine-pers engine-pers :offset-assert 7172) ;; guessed by decompiler (engine-hi engine :offset-assert 7176) ;; guessed by decompiler - (cam-engines UNKNOWN 4 :offset-assert 7180) + (cam-engines engine-group 4 :offset-assert 7180) ) :method-count-assert 25 :size-assert #x1c1c :flag-assert #x1900001c1c (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type int) _type_) + (new (symbol type int) _type_) ;; 0 (setting-control-method-9 () none) ;; 9 ;; (add-setting (_type_ process symbol object object object) connection) (setting-control-method-10 () none) ;; 10 ;; (persist-with-delay (_type_ symbol time-frame symbol symbol float int) none) (setting-control-method-11 () none) ;; 11 ;; (set-setting (_type_ process symbol object object object) connection) @@ -8320,18 +11283,16 @@ (setting-control-method-24 () none) ;; 24 ) ) -|# -;; (define-extern *settings-dialog-volume* object) -;; (define-extern *settings-music-volume* object) -;; (define-extern *settings-sfx-volume* object) -;; (define-extern *settings-music-seek-speed* object) +(define-extern *settings-dialog-volume* float) +(define-extern *settings-music-volume* float) +(define-extern *settings-sfx-volume* float) +(define-extern *settings-music-seek-speed* float) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; memory-usage-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype memory-usage-info (structure) ((name string :offset-assert 0) ;; guessed by decompiler (count int32 :offset-assert 4) @@ -8342,34 +11303,30 @@ :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 112 :offset-assert 16) ;; guessed by decompiler + (data memory-usage-info 112 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 12 :size-assert #x710 :flag-assert #xc00000710 (:methods - (memory-usage-block-method-9 () none) ;; 9 ;; (reset! (_type_) _type_) - (memory-usage-block-method-10 () none) ;; 10 ;; (calculate-total (_type_) int) - (memory-usage-block-method-11 () none) ;; 11 ;; (print-mem-usage (_type_ level object) _type_) + (reset! (_type_) _type_) ;; 9 + (calculate-total (_type_) int) ;; 10 + (print-mem-usage (_type_ level object) _type_) ;; 11 ) ) -|# -;; (define-extern *mem-usage* object) ;; memory-usage-block -;; (define-extern *dma-mem-usage* object) ;; memory-usage-block -;; (define-extern *temp-mem-usage* object) ;; memory-usage-block +(define-extern *mem-usage* memory-usage-block) +(define-extern *dma-mem-usage* memory-usage-block) +(define-extern *temp-mem-usage* memory-usage-block) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sky-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype sky-color-hour (structure) ((snapshot1 int32 :offset-assert 0) (snapshot2 int32 :offset-assert 4) @@ -8380,51 +11337,43 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype sky-color-day (structure) - ((hour sky-color-hour 24 :offset-assert 0) ;; guessed by decompiler + ((hour sky-color-hour 24 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x180 :flag-assert #x900000180 ) -|# -#| (deftype sky-sun-data (structure) ((data uint128 4 :offset-assert 0) ;; guessed by decompiler - (pos vector :inline :offset-assert 0) - (r-sun float :offset-assert 16) - (r-halo float :offset-assert 20) - (r-aurora float :offset-assert 24) - (c-sun-start rgba :offset-assert 32) ;; guessed by decompiler - (c-sun-end rgba :offset-assert 48) ;; guessed by decompiler - (c-halo-start rgba :offset-assert 36) ;; guessed by decompiler - (c-halo-end rgba :offset-assert 52) ;; guessed by decompiler - (c-aurora-start rgba :offset-assert 40) ;; guessed by decompiler - (c-aurora-end rgba :offset-assert 56) ;; guessed by decompiler + (pos vector :inline :offset-assert 0 :overlay-at data) + (r-sun float :offset-assert 16 :overlay-at (-> pos 1 x)) + (r-halo float :offset-assert 20 :overlay-at (-> pos 1 y)) + (r-aurora float :offset-assert 24 :overlay-at (-> pos 1 z)) + (c-sun-start rgba :offset-assert 32 :overlay-at (-> pos 2 x)) ;; guessed by decompiler + (c-sun-end rgba :offset-assert 48 :overlay-at (-> pos 3 x)) ;; guessed by decompiler + (c-halo-start rgba :offset-assert 36 :overlay-at (-> pos 2 y)) ;; guessed by decompiler + (c-halo-end rgba :offset-assert 52 :overlay-at (-> pos 3 y)) ;; guessed by decompiler + (c-aurora-start rgba :offset-assert 40 :overlay-at (-> pos 2 z)) ;; guessed by decompiler + (c-aurora-end rgba :offset-assert 56 :overlay-at (-> pos 3 z)) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype sky-moon-data (structure) ((data uint128 2 :offset-assert 0) ;; guessed by decompiler - (pos vector :inline :offset-assert 0) - (scale vector :inline :offset-assert 16) + (pos vector :inline :offset-assert 0 :overlay-at (-> data 0)) + (scale vector :inline :offset-assert 16 :overlay-at (-> data 1)) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype sky-orbit (structure) ((high-noon float :offset-assert 0) (tilt float :offset-assert 4) @@ -8433,37 +11382,32 @@ (min-halo float :offset-assert 16) (max-halo float :offset-assert 20) ) + :allow-misaligned :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype sky-upload-data (structure) ((data uint128 12 :offset-assert 0) ;; guessed by decompiler - (sun sky-sun-data 2 :offset-assert 0) ;; guessed by decompiler - (moon sky-moon-data :inline :offset-assert 128) + (sun sky-sun-data 2 :inline :offset-assert 0 :overlay-at data) ;; guessed by decompiler + (moon sky-moon-data :inline :offset-assert 128 :overlay-at (-> data 8)) ) :method-count-assert 9 :size-assert #xc0 :flag-assert #x9000000c0 ) -|# -#| (deftype sky-vertex (structure) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((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 cloud-vertex (structure) ((pos vector :inline :offset-assert 0) (stq vector :inline :offset-assert 16) @@ -8477,19 +11421,15 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype cloud-vert-array (structure) - ((data cloud-vertex 100 :offset-assert 0) ;; guessed by decompiler + ((data cloud-vertex 100 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x2bc0 :flag-assert #x900002bc0 ) -|# -#| (deftype haze-vertex (structure) ((pos vector :inline :offset-assert 0) (nrm vector :inline :offset-assert 16) @@ -8499,19 +11439,15 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype haze-vert-array (structure) - ((data haze-vertex 36 :offset-assert 0) ;; guessed by decompiler + ((data haze-vertex 36 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x6c0 :flag-assert #x9000006c0 ) -|# -#| (deftype cloud-lights (structure) ((sun0-normal vector :inline :offset-assert 0) (sun1-normal vector :inline :offset-assert 16) @@ -8530,9 +11466,7 @@ :size-assert #x9c :flag-assert #x90000009c ) -|# -#| (deftype haze-lights (structure) ((sun0-normal vector :inline :offset-assert 0) (sun1-normal vector :inline :offset-assert 16) @@ -8549,9 +11483,7 @@ :size-assert #x7c :flag-assert #x90000007c ) -|# -#| (deftype sky-work (structure) ((adgif-tmpl dma-gif-packet :inline :offset-assert 0) (draw-tmpl dma-gif-packet :inline :offset-assert 32) @@ -8560,18 +11492,18 @@ (blend-tmpl dma-gif-packet :inline :offset-assert 128) (sprite-tmpl dma-gif-packet :inline :offset-assert 160) (sprite-tmpl2 dma-gif-packet :inline :offset-assert 192) - (sun-coords vector 2 :offset-assert 224) ;; guessed by decompiler - (green-coords vector 2 :offset-assert 256) ;; guessed by decompiler - (moon0-coords vector 2 :offset-assert 288) ;; guessed by decompiler - (moon1-coords vector 2 :offset-assert 320) ;; guessed by decompiler - (moon2-coords vector 2 :offset-assert 352) ;; guessed by decompiler - (star-coords vector 2 :offset-assert 384) ;; guessed by decompiler - (sun-colors vector4w 2 :offset-assert 416) ;; guessed by decompiler - (green-colors vector4w 2 :offset-assert 448) ;; guessed by decompiler - (moon-colors vector4w 3 :offset-assert 480) ;; guessed by decompiler - (star-colors vector4w 16 :offset-assert 528) ;; guessed by decompiler - (st-coords vector 2 :offset-assert 784) ;; guessed by decompiler - (random vector4w 8 :offset-assert 816) ;; guessed by decompiler + (sun-coords vector 2 :inline :offset-assert 224) ;; guessed by decompiler + (green-coords vector 2 :inline :offset-assert 256) ;; guessed by decompiler + (moon0-coords vector 2 :inline :offset-assert 288) ;; guessed by decompiler + (moon1-coords vector 2 :inline :offset-assert 320) ;; guessed by decompiler + (moon2-coords vector 2 :inline :offset-assert 352) ;; guessed by decompiler + (star-coords vector 2 :inline :offset-assert 384) ;; guessed by decompiler + (sun-colors vector4w 2 :inline :offset-assert 416) ;; guessed by decompiler + (green-colors vector4w 2 :inline :offset-assert 448) ;; guessed by decompiler + (moon-colors vector4w 3 :inline :offset-assert 480) ;; guessed by decompiler + (star-colors vector4w 16 :inline :offset-assert 528) ;; guessed by decompiler + (st-coords vector 2 :inline :offset-assert 784) ;; guessed by decompiler + (random vector4w 8 :inline :offset-assert 816) ;; guessed by decompiler (giftag-base dma-gif :inline :offset-assert 944) (giftag-haze dma-gif :inline :offset-assert 960) (giftag-roof dma-gif :inline :offset-assert 976) @@ -8582,7 +11514,7 @@ (time float :offset-assert 1072) (off-s uint16 :offset-assert 1076) (off-t uint16 :offset-assert 1078) - (orbit sky-orbit 3 :offset-assert 1080) ;; guessed by decompiler + (orbit sky-orbit 3 :inline :offset-assert 1080) ;; guessed by decompiler (upload-data sky-upload-data :inline :offset-assert 1184) (ambi-color vector :inline :offset-assert 1376) (ambi-color-lower vector :inline :offset-assert 1392) @@ -8597,7 +11529,7 @@ (cloud-lights cloud-lights :inline :offset-assert 1632) (haze-lights haze-lights :inline :offset-assert 1792) (buf dma-buffer :offset-assert 1916) ;; guessed by decompiler - (stars vector 512 :offset-assert 1920) ;; guessed by decompiler + (stars vector 512 :inline :offset-assert 1920) ;; guessed by decompiler (disable-day-star basic :offset-assert 10112) ) :method-count-assert 37 @@ -8634,14 +11566,12 @@ (sky-work-method-36 () none) ;; 36 ;; (draw-roof (_type_ dma-buffer) none) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ocean-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype ocean-corner (structure) ((bsphere sphere :inline :offset-assert 0) (start-corner vector :inline :offset-assert 16) @@ -8653,9 +11583,7 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype ocean-wave-info (structure) ((frequency float :offset-assert 0) (amplitude float :offset-assert 4) @@ -8670,9 +11598,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype ocean-vertex (structure) ((pos vector :inline :offset-assert 0) (stq vector :inline :offset-assert 16) @@ -8682,19 +11608,15 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype ocean-spheres (structure) - ((spheres sphere 36 :offset-assert 0) ;; guessed by decompiler + ((spheres sphere 36 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x240 :flag-assert #x900000240 ) -|# -#| (deftype ocean-colors (structure) ((colors rgba 2548 :offset-assert 0) ;; guessed by decompiler ) @@ -8702,30 +11624,25 @@ :size-assert #x27d0 :flag-assert #x9000027d0 ) -|# -#| (deftype ocean-colors-float (structure) - ((colors vector 2548 :offset-assert 0) ;; guessed by decompiler + ((colors vector 2548 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x9f40 :flag-assert #x900009f40 ) -|# -#| (deftype ocean-mid-mask (structure) ((mask uint8 8 :offset-assert 0) ;; guessed by decompiler - (dword uint64 :offset-assert 0) + (dword uint64 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype ocean-mid-indices (basic) ((data uint16 36 :offset-assert 4) ;; guessed by decompiler ) @@ -8733,9 +11650,7 @@ :size-assert #x4c :flag-assert #x90000004c ) -|# -#| (deftype ocean-mid-masks (basic) ((data (inline-array ocean-mid-mask) :offset-assert 4) ;; guessed by decompiler ) @@ -8743,41 +11658,35 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype ocean-trans-mask (structure) ((mask uint8 4 :offset-assert 0) ;; guessed by decompiler - (word int32 :offset-assert 0) + (word int32 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (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 ocean-trans-index 2304 :offset-assert 4) ;; guessed by decompiler + ((data ocean-trans-index 2304 :inline :offset-assert 4) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x2404 :flag-assert #x900002404 ) -|# -#| (deftype ocean-near-index (structure) ((data uint16 16 :offset-assert 0) ;; guessed by decompiler ) @@ -8785,9 +11694,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype ocean-near-indices (basic) ((data (inline-array ocean-near-index) :offset-assert 4) ;; guessed by decompiler ) @@ -8795,9 +11702,7 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype ocean-near-colors (structure) ((color0 vector :inline :offset-assert 0) (color1 vector :inline :offset-assert 16) @@ -8808,9 +11713,7 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype ocean-trans-strip (structure) ((verts uint128 10 :offset-assert 0) ;; guessed by decompiler ) @@ -8818,19 +11721,15 @@ :size-assert #xa0 :flag-assert #x9000000a0 ) -|# -#| (deftype ocean-trans-strip-array (structure) - ((data ocean-trans-strip 4 :offset-assert 0) ;; guessed by decompiler + ((data ocean-trans-strip 4 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x280 :flag-assert #x900000280 ) -|# -#| (deftype ocean-wave-data (structure) ((data uint8 1024 :offset-assert 0) ;; guessed by decompiler ) @@ -8838,20 +11737,16 @@ :size-assert #x400 :flag-assert #x900000400 ) -|# -#| (deftype ocean-wave-frames (structure) - ((frame ocean-wave-data 64 :offset-assert 0) ;; guessed by decompiler + ((frame ocean-wave-data 64 :inline :offset-assert 0) ;; guessed by decompiler ) + ;; overflow 16-bit int size bug :method-count-assert 9 - :size-assert #x0 - :heap-base #x1 - :flag-assert #x900010000 + :size-assert #x10000 + ;:flag-assert #x900010000 ) -|# -#| (deftype ocean-texture-constants (structure) ((giftag qword :inline :offset-assert 0) ;; gs-gif-tag :inline (buffers vector4w :inline :offset-assert 16) @@ -8865,9 +11760,7 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype ocean-mid-vertex (structure) ((stq vector :inline :offset-assert 0) (col vector :inline :offset-assert 16) @@ -8877,9 +11770,7 @@ :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) @@ -8897,7 +11788,7 @@ (env-texture adgif-shader :inline :offset-assert 272) (env-strip qword :inline :offset-assert 352) ;; gs-gif-tag :inline (env-color vector :inline :offset-assert 368) - (index-table vector4w 8 :offset-assert 384) ;; guessed by decompiler + (index-table vector4w 8 :inline :offset-assert 384) ;; guessed by decompiler (pos0 vector :inline :offset-assert 512) (pos1 vector :inline :offset-assert 528) (pos2 vector :inline :offset-assert 544) @@ -8907,9 +11798,7 @@ :size-assert #x240 :flag-assert #x900000240 ) -|# -#| (deftype ocean-mid-upload (structure) ((rot matrix :inline :offset-assert 0) (matrix matrix :inline :offset-assert 64) @@ -8920,9 +11809,7 @@ :size-assert #x760 :flag-assert #x900000760 ) -|# -#| (deftype ocean-mid-upload2 (structure) ((rot matrix :inline :offset-assert 0) (matrix matrix :inline :offset-assert 64) @@ -8941,9 +11828,7 @@ :size-assert #x230 :flag-assert #x900000230 ) -|# -#| (deftype ocean-mid-work (structure) ((env0 vector :inline :offset-assert 0) (env1 vector :inline :offset-assert 16) @@ -8957,9 +11842,7 @@ :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) @@ -8986,15 +11869,13 @@ (drw2-strip qword :inline :offset-assert 480) ;; gs-gif-tag :inline (drw3-adgif qword :inline :offset-assert 496) ;; gs-gif-tag :inline (drw3-frame qword :inline :offset-assert 512) ;; gs-adcmd :inline - (index-table vector4w 4 :offset-assert 528) ;; guessed by decompiler + (index-table vector4w 4 :inline :offset-assert 528) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x250 :flag-assert #x900000250 ) -|# -#| (deftype ocean-near-upload (structure) ((rot matrix :inline :offset-assert 0) (matrix matrix :inline :offset-assert 64) @@ -9007,9 +11888,7 @@ :size-assert #x100 :flag-assert #x900000100 ) -|# -#| (deftype ocean-near-vertex (structure) ((stq vector :inline :offset-assert 0) (clr vector :inline :offset-assert 16) @@ -9019,9 +11898,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype ocean-near-work (structure) ((verts-ptr vector :inline :offset-assert 0) (indices uint128 16 :offset-assert 16) ;; guessed by decompiler @@ -9030,9 +11907,7 @@ :size-assert #x110 :flag-assert #x900000110 ) -|# -#| (deftype ocean-height-array (structure) ((data float 1024 :offset-assert 0) ;; guessed by decompiler ) @@ -9040,9 +11915,7 @@ :size-assert #x1000 :flag-assert #x900001000 ) -|# -#| (deftype ocean-map (structure) ((start-corner vector :inline :offset-assert 0) (far-color vector :inline :offset-assert 16) @@ -9060,9 +11933,7 @@ (ocean-map-method-10 () none) ;; 10 ;; (get-base-height (_type_) float) ) ) -|# -#| (deftype ocean (ocean-map) ((off symbol :offset-assert 52) ;; guessed by decompiler (near-off symbol :offset-assert 56) ;; guessed by decompiler @@ -9171,10 +12042,9 @@ (ocean-method-83 () none) ;; 83 ;; (ocean-method-83 (_type_ dma-buffer sky-upload-data vector4w float) none) ) ) -|# -;; (define-extern *ocean-map* object) ;; ocean-map -;; (define-extern *ocean* object) ;; ocean +(define-extern *ocean-map* ocean-map) +(define-extern *ocean* ocean) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; car-textures ;; @@ -9214,19 +12084,6 @@ ;; texture ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| -(deftype texture-page-dir (basic) - () - :method-count-assert 11 - :size-assert #x14 - :flag-assert #xb00000014 - (:methods - (texture-page-dir-method-9 () none) ;; 9 ;; (unlink-shaders-in-heap (_type_ kheap) int) - (texture-page-dir-method-10 () none) ;; 10 - ) - ) -|# - ;; (define-extern texture-bpp function) ;; (function gs-psm int) ;; (define-extern texture-qwc function) ;; (function int int gs-psm int) ;; (define-extern physical-address function) ;; (function pointer pointer) @@ -9284,8 +12141,9 @@ ;; mspace-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype joint (basic) + "A joint from an animated skeleton. This defines the graph of the skeleton, and also the bind pose + used for the mesh data. The joints are shared between all instances of the same model." ((name basic :offset-assert 4) (number int32 :offset-assert 8) (parent joint :offset-assert 12) ;; guessed by decompiler @@ -9295,10 +12153,9 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype bone-cache (structure) + "Unused type. Existed in Jak 1, but wasn't used there." ((bone-matrix uint32 :offset-assert 0) (parent-matrix uint32 :offset-assert 4) (dummy uint32 :offset-assert 8) @@ -9308,34 +12165,33 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype bone (structure) + "The location and scale of a bone in an animated skeleton. Each instance of a skeleton + has its own copy of the bones. This data is used for collision checking or other gameplay math, + but, despite the name, isn't directly used in rendering." ((transform matrix :inline :offset-assert 0) - (position vector :inline :offset-assert 48) + (position vector :inline :offset 48) (scale vector :inline :offset-assert 64) ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype skeleton (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data UNKNOWN :dynamic :offset-assert 16) + "Skeleton is an array of bones for the entire character. The bones are stored in an inline array so they can be + easily dma'd to the scratchpad later." + ((bones bone :inline :dynamic) ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype cspace (structure) + "A cspace describes how to control a bone. It contains a reference to the joint, bone, and a callback function. + The callback function is used to take the joint transforms out of the joint animation, then update the bone." ((parent cspace :offset-assert 0) (joint joint :offset-assert 4) ;; guessed by decompiler (joint-num int16 :offset-assert 8) @@ -9350,31 +12206,33 @@ :flag-assert #xa00000020 ;; field param1 uses ~A with a signed load. field param2 uses ~A with a signed load. (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type drawable) _type_) - (cspace-method-9 () none) ;; 9 ;; (reset-and-assign-geo! (_type_ drawable) _type_) + (new (symbol type drawable) _type_) ;; 0 + (reset-and-assign-geo! (_type_ drawable) _type_) ;; 9 ) ) -|# -#| (deftype cspace-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data cspace :dynamic :offset-assert 16) ;; guessed by decompiler + ((data cspace :dynamic :inline :offset-assert 16 :score 1) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type region-prim-list structure) + (deftype drawable (basic) + "Base class for `drawable` scene graph system. + This base class is really abused in many ways, and the meaning of the various methods differ depending + on the exact type. Not even the ID and bsphere here are always populated. + This is used for very high level organization of different rendering data types, and also very low-level + culling/rendering optimizations. It supports both array-of-references and inline-array containers with precise + control over memory layout for use with DMA." ((id int16 :offset-assert 4) (bsphere vector :inline :offset-assert 16) ) @@ -9382,147 +12240,168 @@ :size-assert #x20 :flag-assert #x1100000020 (:methods - (drawable-method-9 () none) ;; 9 ;; (login (_type_) _type_) - (drawable-method-10 () none) ;; 10 ;; (draw (_type_) none) - (drawable-method-11 () none) ;; 11 ;; (drawable-method-11 (_type_) none) - (drawable-method-12 () none) ;; 12 ;; (drawable-method-12 (_type_) none) - (drawable-method-13 () none) ;; 13 ;; (collect-stats (_type_) none) - (drawable-method-14 () none) ;; 14 ;; (debug-draw (_type_) none) - (drawable-method-15 () none) ;; 15 ;; (unpack-vis (_type_ (pointer int8) (pointer int8)) (pointer int8)) - (drawable-method-16 () none) ;; 16 ;; (collect-regions (_type_ sphere int region-prim-list) none) + (login "Initialize the object after it is loaded." (_type_) _type_);; 9 + (draw "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." (_type_) none) ;; 10 + (drawable-method-11 (_type_) none) ;; 11 ;; (fill-collide-list-from-box (_type_ int collide-list collide-query) int) + (drawable-method-12 (_type_) none) ;; 12 ;; (fill-collide-list-from-line-sphere (_type_ int collide-list collide-query) int) + (collect-stats "Collect triangle/perf statistics for rendering. + This is only called when viewing stats. + The vis-bits and culling registers are loaded during this time." (_type_) none) ;; 13 + (debug-draw "Debug-draw a drawable and its children. Typically uses the debug-draw functions." (_type_) none) ;; 14 + (unpack-vis (_type_ (pointer int8) (pointer int8)) (pointer int8)) ;; 15 + (collect-regions "Fill the region-prim-list with regions that intersect the sphere." (_type_ sphere int region-prim-list) none) ;; 16 ) ) -|# -#| (deftype drawable-error (drawable) + "A drawable which just represents an error. When drawn, it simply displays a sphere with an error message." ((name string :offset-assert 32) ;; guessed by decompiler ) :method-count-assert 17 :size-assert #x24 :flag-assert #x1100000024 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-group-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype drawable-group (drawable) - ((id int16 :offset-assert 0) - (bsphere vector :inline :offset-assert 12) - (length int16 :offset-assert 2) - (data drawable :dynamic :offset-assert 28) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + "Base class for an array of references to other drawables. + These are typically used for very high-level organization of drawable." + ((length int16 :offset 6) + (data drawable :dynamic :offset-assert 32) ;; guessed by decompiler ) :method-count-assert 17 :size-assert #x20 :flag-assert #x1100000020 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type int) _type_) + (new (symbol type int) _type_) ;; 0 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-inline-array-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype drawable-inline-array (drawable) - ((length int16 :offset-assert 6) + ((length int16 :offset 6) ) :method-count-assert 17 :size-assert #x20 :flag-assert #x1100000020 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; draw-node-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype draw-node (drawable) - ((child-count uint8 :offset-assert 6) - (flags uint8 :offset-assert 7) - (child drawable :offset-assert 8) ;; guessed by decompiler - (distance float :offset-assert 12) + "Node in a bounding volume heirarchy. This is a base class, and there are no children. + The child is a pointer to the start of inline array of drawables (note: not a drawable-inline-array, literally a bunch of plain drawables) + The size of this array is child-count. The type is either more draw-nodes, or, some other drawable like tfragment, depending on the flags. + Different renderers have different restrictions on the tree structure, like max child count, or if all children have the same depth. + Generally, tfrag/collide use a very rigid equal depth, max 8 children rule, but with shrub, anything goes. + This is a very awkward data structure to traverse, but it is designed for fast view frustum culling. + Note that there can be multiple ways to reach drawables in here in some cases - for example you can follow + this tree, or check one of the depth arrays found in tfrag. + " + ((child-count uint8 :offset 6) + (flags uint8 :offset 7) + (child drawable :offset 8) ;; guessed by decompiler + (distance float :offset 12) ) :method-count-assert 17 :size-assert #x20 :flag-assert #x1100000020 ;; field distance is a float printed as hex? ) -|# -;; (deftype drawable-inline-array-node (drawable-inline-array) -;; () -;; :flag-assert #x1100000044 -;; ) +(deftype drawable-inline-array-node (drawable-inline-array) + "Top level container for a BVH made of draw-nodes." + ((data draw-node 1 :inline) + (pad uint32) + ) + :flag-assert #x1100000044 + ) -#| (deftype draw-node-dma (structure) - ((banka draw-node 32 :offset-assert 4) ;; guessed by decompiler - (bankb draw-node 32 :offset-assert 1028) ;; guessed by decompiler + "DMA buffer layout for draw node culling routine, which copies draw-nodes directly to scratchpad in bulk. + This would not work with the memory layout of shrub." + ((banka draw-node 32 :inline :offset-assert 0) ;; guessed by decompiler + (bankb draw-node 32 :inline :offset-assert 1024) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x800 :flag-assert #x900000800 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-tree-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype drawable-tree (drawable-group) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree (drawable-group) + "A drawable tree is a container of drawables of a specific rendering type. + Instead of having a single large tree of mixed types, there will be a tree of tfrags, a tree of ties, etc. + The top-level tfrag tree will have a type that's a child of drawable-tree. + Generally, the object passed to a large renderer is a drawable-tree." + () + :flag-assert #x1100000020 + ) -;; (deftype drawable-tree-array (drawable-group) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-array (drawable-group) + "Collection of drawable trees. This might have a tfrag tree, tie tree, etc." + ((trees drawable-tree :dynamic :offset 32 :score 100)) + :flag-assert #x1100000020 + ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-actor-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + (deftype drawable-actor (drawable) - ((actor entity-actor :offset-assert 8) ;; guessed by decompiler + "Wrapper around an entity-actor to put it in the drawable system. + Note that this is never used to actually draw actors - it is just used as a list of all entity-actors + for the entity/birth system." + ((actor entity-actor :offset 8) ;; guessed by decompiler ) :method-count-assert 17 :size-assert #x20 :flag-assert #x1100000020 ) -|# -;; (deftype drawable-tree-actor (drawable-tree) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-actor (drawable-tree) + "Adapater for putting the actors in the tree-array." + () + :flag-assert #x1100000020 + ) -;; (deftype drawable-inline-array-actor (drawable-inline-array) -;; () -;; :flag-assert #x1100000044 -;; ) +(deftype drawable-inline-array-actor (drawable-inline-array) + "Array of drawable-actors." + ((data drawable-actor 1 :inline) + (pad uint8 4)) + :flag-assert #x1100000044 + ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; region-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type region-prim-area structure) + (deftype region (structure) + "A region is a closed volume that you can, enter, exit, and be inside. + This stores a unique, and script functions for a single region. + These are stored separately from the actual geometry to allow the geometry to be smaller + and fit in scratchpad/cache better." ((id uint32 :offset-assert 0) (on-enter pair :offset-assert 4) ;; guessed by decompiler (on-inside pair :offset-assert 8) ;; guessed by decompiler @@ -9533,118 +12412,105 @@ :flag-assert #xa00000010 ;; field on-enter uses ~A with a signed load. field on-inside uses ~A with a signed load. field on-exit uses ~A with a signed load. (:methods - (region-method-9 () none) ;; 9 ;; (point-in-region-debug! (_type_ vector) symbol) + (point-in-region-debug! "Debug check to see if point is in region. This is not efficient, since it has to find the parent geometry of this region." (_type_ vector) symbol) ;; 9 ) ) -|# -#| (deftype region-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data region :dynamic :offset-assert 16) ;; guessed by decompiler + "Array of region." + ((data region :dynamic :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype drawable-region-prim (drawable) - ((region region :offset-assert 8) + "Base class for a region + geometry. + Note that all child classes of this must be 32-bytes." + ((region region :offset 8) ) :method-count-assert 20 :size-assert #x20 :flag-assert #x1400000020 (:methods - (drawable-region-prim-method-17 () none) ;; 17 ;; (debug-draw-region (_type_ int) none) - (drawable-region-prim-method-18 () none) ;; 18 ;; (track-region (_type_ region-prim-area) symbol) - (drawable-region-prim-method-19 () none) ;; 19 ;; (within-area? (_type_ region-prim-area) symbol) + (debug-draw-region (_type_ int) none) ;; 17 + (track-region (_type_ region-prim-area) symbol) ;; 18 + (within-area? "@returns Whether or not the object overlaps with the provided [[region-prim-area]]'s extent" (_type_ region-prim-area) symbol) ;; 19 ) ) -|# -#| (deftype drawable-tree-region-prim (drawable-tree) - ((id int16 :offset-assert 0) - (bsphere vector :inline :offset-assert 12) - (length int16 :offset-assert 2) - (data drawable :dynamic :offset-assert 28) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (name symbol :offset-assert 4) ;; guessed by decompiler - ) + "Top-level container for all regions of a level." + ((name symbol :offset 8) + (data2 drawable-inline-array :dynamic :offset 32 :score 1)) :method-count-assert 19 :size-assert #x20 :flag-assert #x1300000020 (:methods - (drawable-tree-region-prim-method-17 () none) ;; 17 ;; (drawable-tree-region-prim-method-17 (_type_ vector) symbol) - (drawable-tree-region-prim-method-18 () none) ;; 18 ;; (debug-print (_type_ vector object) none) + (drawable-tree-region-prim-method-17 (_type_ vector) symbol) ;; 17 + (debug-print (_type_ vector object) none) ;; 18 ) ) -|# -;; (deftype drawable-inline-array-region-prim (drawable-inline-array) -;; () -;; :flag-assert #x1100000044 -;; ) +(deftype drawable-inline-array-region-prim (drawable-inline-array) + "Inline array of drawable-region-prim. This actually stores child classes, but they are + exactly the same size as the parent, so it's okay." + ((data drawable-region-prim 1 :inline :offset-assert 32) + (pad uint8 4)) + :flag-assert #x1100000044 + ) -#| (deftype drawable-region-sphere (drawable-region-prim) + "Region where the bsphere of the drawable is the volume." () :method-count-assert 20 :size-assert #x20 :flag-assert #x1400000020 ) -|# -#| (deftype region-face-data (structure) + "Data to store a single planar face, as a normal and list of vertices." ((normal vector :inline :offset-assert 0) - (normal-offset float :offset-assert 12) + (normal-offset float :offset-assert 12 :overlay-at (-> normal w)) (num-points uint32 :offset-assert 16) - (points vector :dynamic :offset-assert 32) ;; guessed by decompiler + (points vector :dynamic :inline :offset-assert 32) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype drawable-region-face (drawable-region-prim) - ((data region-face-data :offset-assert 12) + "A drawable-region which is just a face. Unclear if `on-inside` is used." + ((data region-face-data :offset 12) ) :method-count-assert 20 :size-assert #x20 :flag-assert #x1400000020 ) -|# -#| (deftype region-face-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data drawable-region-face :dynamic :offset-assert 20) ;; guessed by decompiler + "An array of faces that hopefully make a closed volume." + ((data drawable-region-face :dynamic :inline :offset 16) ;; guessed by decompiler + (pad uint32) ) :method-count-assert 14 :size-assert #x14 :flag-assert #xe00000014 ) -|# -#| (deftype drawable-region-volume (drawable-region-prim) - ((faces region-face-array :offset-assert 12) ;; guessed by decompiler + "A drawable-region which is a bunch of faces that represent a closed volume." + ((faces region-face-array :offset 12) ;; guessed by decompiler ) :method-count-assert 20 :size-assert #x20 :flag-assert #x1400000020 ) -|# -#| (deftype region-prim-list (structure) + "A list of drawable-region-prim. This is the return type of queries like `which regions contain this point?`" ((num-items int32 :offset-assert 0) (items drawable-region-prim 320 :offset-assert 4) ;; guessed by decompiler ) @@ -9652,7 +12518,6 @@ :size-assert #x504 :flag-assert #x900000504 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -9664,28 +12529,28 @@ ;; generic-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype gsf-vertex (structure) + "Vertex used by generic. GSF = generic stripped fragment?" ((data uint32 8 :offset-assert 0) ;; guessed by decompiler - (byte uint8 32 :offset-assert 0) ;; guessed by decompiler - (quad uint128 2 :offset-assert 0) ;; guessed by decompiler - (vt qword :inline :offset-assert 0) - (pos vector3s :inline :offset-assert 0) - (tex vector2uh :inline :offset-assert 12) - (nrm vector3s :inline :offset-assert 16) - (nc qword :inline :offset-assert 16) - (clr vector4ub :inline :offset-assert 28) - (dtex vector2uh :inline :offset-assert 16) - (dclr vector4ub :inline :offset-assert 20) + (byte uint8 32 :offset 0) ;; guessed by decompiler + (quad uint128 2 :offset 0) ;; guessed by decompiler + (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) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype gsf-fx-vertex (structure) + "Color/texture data only. Possibly used to share with a gsf-vertex with + the same position/normal." ((clr vector4ub :inline :offset-assert 0) (tex vector2uh :inline :offset-assert 4) ) @@ -9693,10 +12558,9 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype gsf-header (structure) + "Header for generic data." ((num-strips uint8 :offset-assert 0) (num-new-vtxs uint8 :offset-assert 1) (num-dps uint16 :offset-assert 2) @@ -9707,9 +12571,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gsf-ik (structure) ((index uint8 :offset-assert 0) (no-kick uint8 :offset-assert 1) @@ -9718,9 +12580,7 @@ :size-assert #x2 :flag-assert #x900000002 ) -|# -#| (deftype gsf-info (structure) ((ptr-iks uint32 :offset-assert 0) (ptr-verts uint32 :offset-assert 4) @@ -9731,22 +12591,18 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gsf-buffer (structure) ((data uint8 8192 :offset-assert 0) ;; guessed by decompiler - (info gsf-info :inline :offset-assert 0) - (header gsf-header :inline :offset-assert 16) - (work-area uint8 :dynamic :offset-assert 32) ;; guessed by decompiler + (info gsf-info :inline :offset 0) + (header gsf-header :inline :offset 16) + (work-area uint8 :dynamic :offset 32) ;; guessed by decompiler ) :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) @@ -9755,9 +12611,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype generic-strip (structure) ((pos uint16 :offset-assert 0) (len uint16 :offset-assert 2) @@ -9766,9 +12620,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype generic-envmap-saves (structure) ((index-mask vector4w :inline :offset-assert 0) (verts uint128 12 :offset-assert 16) ;; guessed by decompiler @@ -9778,9 +12630,7 @@ :size-assert #x110 :flag-assert #x900000110 ) -|# -#| (deftype generic-interp-job (structure) ((job-type uint16 :offset-assert 0) (num uint16 :offset-assert 2) @@ -9790,13 +12640,12 @@ (morph-z uint16 :offset-assert 12) (morph-w uint16 :offset-assert 14) ) + :pack-me :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) @@ -9829,24 +12678,20 @@ :size-assert #x170 :flag-assert #x900000170 ) -|# -#| (deftype generic-gif-tag (structure) - ((data uint32 4 :offset-assert 0) ;; guessed by decompiler - (qword qword :inline :offset-assert 0) - (fan-prim gif-tag-prim :offset-assert 0) ;; guessed by decompiler - (str-prim gif-tag-prim :offset-assert 4) ;; guessed by decompiler - (regs gif-tag-regs-32 :offset-assert 8) ;; guessed by decompiler - (num-strips uint32 :offset-assert 12) + ((data uint32 4 :offset-assert 0 :score -1) ;; guessed by decompiler + (qword qword :inline :offset 0 :score -1) + (fan-prim gif-tag-prim :offset 0) ;; guessed by decompiler + (str-prim gif-tag-prim :offset 4) ;; guessed by decompiler + (regs gif-tag-regs-32 :offset 8) ;; guessed by decompiler + (num-strips 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) @@ -9857,9 +12702,7 @@ :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) ;; guessed by decompiler @@ -9872,7 +12715,7 @@ (ztest-normal gs-adcmd :inline :offset-assert 176) (ztest-opaque gs-adcmd :inline :offset-assert 192) (adcmd-offsets uint8 16 :offset-assert 208) ;; guessed by decompiler - (adcmds UNKNOWN 4 :offset-assert 144) + ;(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) @@ -9890,9 +12733,7 @@ :size-assert #x1b0 :flag-assert #x9000001b0 ) -|# -#| (deftype generic-storage (structure) ((data uint128 16 :offset-assert 0) ;; guessed by decompiler ) @@ -9900,35 +12741,29 @@ :size-assert #x100 :flag-assert #x900000100 ) -|# -#| -(deftype gsf-vertex-array (UNKNOWN) - ((vtx gsf-vertex :dynamic :offset-assert 0) ;; guessed by decompiler +(deftype gsf-vertex-array (structure) + ((vtx gsf-vertex :dynamic :offset-assert 0) ) - :method-count-assert 0 + :method-count-assert 9 :size-assert #x0 - :flag-assert #x0 + :flag-assert #x900000000 ) -|# -#| -(deftype gsf-fx-vertex-array (UNKNOWN) - ((data gsf-fx-vertex :dynamic :offset-assert 0) ;; guessed by decompiler +(deftype gsf-fx-vertex-array (structure) + ((data gsf-fx-vertex :dynamic :offset-assert 0) ) - :method-count-assert 0 + :method-count-assert 9 :size-assert #x0 - :flag-assert #x0 + :flag-assert #x900000000 ) -|# -;; (define-extern *gsf-buffer* object) ;; object +(define-extern *gsf-buffer* object) ;; gsf-buffer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cloth-art-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype cloth-pt (structure) ((pt vector :inline :offset-assert 0) (u float :offset-assert 16) @@ -9938,9 +12773,7 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype anchor-transform (structure) ((offset vector :inline :offset-assert 0) (joint-name string :offset-assert 16) ;; guessed by decompiler @@ -9951,9 +12784,7 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype sphere-transform (structure) ((offset vector :inline :offset-assert 0) (joint-name string :offset-assert 16) ;; guessed by decompiler @@ -9964,9 +12795,7 @@ :size-assert #x1a :flag-assert #x90000001a ) -|# -#| (deftype disc-transform (structure) ((offset vector :inline :offset-assert 0) (normal vector :inline :offset-assert 16) @@ -9980,66 +12809,78 @@ :size-assert #x2e :flag-assert #x90000002e ) -|# -#| (deftype anchor-transform-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data anchor-transform :dynamic :offset-assert 16) ;; guessed by decompiler + ((data anchor-transform :dynamic :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype sphere-transform-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data sphere-transform :dynamic :offset-assert 16) ;; guessed by decompiler + ((data sphere-transform :dynamic :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype disc-transform-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data disc-transform :dynamic :offset-assert 16) ;; guessed by decompiler + ((data disc-transform :dynamic :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype cloth-thickness-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data uint8 :dynamic :offset-assert 16) ;; guessed by decompiler + ((data uint8 :dynamic :offset-assert 16) ;; ?? ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| +;; +++cloth-art-h:cloth-flag +(defenum cloth-flag + :type uint64 + :bitfield #t + (no-gravity 0) + (use-wind 1) + (need-reset 2) + (double-sided 3) + (suppress-mesh-failure 4) + (active 5) + (check-ground 6) + (flip-normals 7) + (wraps 8) + (inited 9) + (no-draw 10) + (need-setup 11) + (use-global-wind 12) + (autogen-uvs 13) + (use-momentum 14) + (use-parent-momentum 15) + (riding 16) + (hidden 17) + (local-space 18) + (local-space-xyz 19) + (local-space-y 20) + (use-old-resets 21) + (using-alt-tex 22) + ) +;; ---cloth-art-h:cloth-flag + (deftype cloth-params (structure) ((mesh int16 :offset-assert 0) - (gravity-constant float :offset-assert 4) ;; meters + (gravity-constant meters :offset-assert 4) ;; meters (wind-constant float :offset-assert 8) (cloth-width uint16 :offset-assert 12) (num-sphere-constraints uint16 :offset-assert 14) (num-disc-constraints uint16 :offset-assert 16) (num-anchor-points uint16 :offset-assert 18) - (flags uint64 :offset-assert 24) ;; cloth-flag + (flags cloth-flag :offset-assert 24) ;; cloth-flag (tex-name string :offset-assert 32) ;; guessed by decompiler (tex-name2 string :offset-assert 36) ;; guessed by decompiler (tex-name3 string :offset-assert 40) ;; guessed by decompiler @@ -10049,37 +12890,34 @@ (cloth-thickness float :offset-assert 56) (initial-xform int16 :offset-assert 60) (drag float :offset-assert 64) - (ball-collision-radius float :offset-assert 68) ;; meters + (ball-collision-radius meters :offset-assert 68) ;; meters (num-iterations int8 :offset-assert 72) (timestep-frequency int8 :offset-assert 73) - (secret-disable uint64 :offset-assert 80) ;; game-secrets + (secret-disable game-secrets :offset-assert 80) ;; game-secrets ) :method-count-assert 9 :size-assert #x58 :flag-assert #x900000058 ) -|# -#| (deftype cloth-base (basic) () :method-count-assert 11 :size-assert #x4 :flag-assert #xb00000004 (:methods - (cloth-base-method-9 () none) ;; 9 ;; (update! (_type_) int) - (cloth-base-method-10 () none) ;; 10 ;; (setup-from-params! (_type_ cloth-params handle) int) + (update! (_type_) int) ;; 9 + (setup-from-params! (_type_ cloth-params handle) int) ;; 10 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; art-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype joint-anim (basic) + "Base class for all joint animations. These are animations that store joint transforms." ((name string :offset-assert 4) ;; guessed by decompiler (number int16 :offset-assert 8) (length int16 :offset-assert 10) @@ -10088,50 +12926,49 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -;; (deftype joint-anim-matrix (joint-anim) -;; () -;; :flag-assert #x900000010 -;; ) +(deftype joint-anim-matrix (joint-anim) + "Joint animation which stores matrices directly. Not used." + ((data matrix :inline :dynamic :offset 16)) + :flag-assert #x900000010 + ) -#| (deftype joint-anim-transformq (joint-anim) - ((name string :offset-assert 0) ;; guessed by decompiler - (number int16 :offset-assert 4) - (length int16 :offset-assert 6) - (data transformq :dynamic :offset-assert 12) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + "Joint animation which stores transformq's directly. Not used." + ((data transformq :dynamic :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype joint-anim-drawable (joint-anim) + "Mysterious unused joint animation type." ((data drawable :dynamic :offset-assert 12) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype joint-anim-frame (structure) - ((matrices matrix 2 :offset-assert 0) ;; guessed by decompiler - (data transformq :dynamic :offset-assert 128) ;; guessed by decompiler + "Frame containing all joint transforms. Note that there are two special frames: align and prejoint. + The 'align' frame is used for the complicated animation alignment system, which allows the animation to move + a character, among other things. The prejoint is just the root of the skeleton. + The remaining transformq's are the joint transforms you'd expect." + ((matrices matrix 2 :inline :offset-assert 0) ;; guessed by decompiler + (data transformq :dynamic :inline :offset-assert 128) ;; guessed by decompiler ) + (:methods + (new (symbol type int) _type_) + ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype joint-anim-compressed-hdr (structure) + "Header for the compressed joint animation format." ((control-bits uint32 14 :offset-assert 0) ;; guessed by decompiler (num-joints uint32 :offset-assert 56) (matrix-bits uint32 :offset-assert 60) @@ -10140,38 +12977,32 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype joint-anim-compressed-fixed (structure) ((hdr joint-anim-compressed-hdr :inline :offset-assert 0) (offset-64 uint32 :offset-assert 64) (offset-32 uint32 :offset-assert 68) (offset-16 uint32 :offset-assert 72) (reserved uint32 :offset-assert 76) - (data vector 133 :offset-assert 80) ;; guessed by decompiler + (data vector 133 :inline :offset-assert 80) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x8a0 :flag-assert #x9000008a0 ) -|# -#| (deftype joint-anim-compressed-frame (structure) ((offset-64 uint32 :offset-assert 0) (offset-32 uint32 :offset-assert 4) (offset-16 uint32 :offset-assert 8) (reserved uint32 :offset-assert 12) - (data vector 133 :offset-assert 16) ;; guessed by decompiler + (data vector 133 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x860 :flag-assert #x900000860 ) -|# -#| (deftype joint-anim-compressed-control (structure) ((num-frames uint16 :offset-assert 0) (flags uint16 :offset-assert 2) @@ -10184,11 +13015,11 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype art (basic) - ((name string :offset-assert 8) ;; guessed by decompiler + "Base class for anything considered `art`. This is typically foreground model data. + This can be either an art container containing more arts, or an actual art thing (art-element)." + ((name string :offset 8) ;; guessed by decompiler (length int32 :offset-assert 12) (extra res-lump :offset-assert 16) ;; guessed by decompiler ) @@ -10196,37 +13027,33 @@ :size-assert #x14 :flag-assert #xe00000014 (:methods - (art-method-9 () none) ;; 9 ;; (login (_type_) _type_) - (art-method-10 () none) ;; 10 ;; (art-method-10 (_type_) _type_) - (art-method-11 () none) ;; 11 ;; (get-art-by-name-method (_type_ string type) basic) - (art-method-12 () none) ;; 12 ;; (get-art-idx-by-name-method (_type_ string type) int) - (art-method-13 () none) ;; 13 ;; (contains-art-for-other-group? (_type_) symbol) + (login (_type_) _type_) ;; 9 + (art-method-10 (_type_) _type_) ;; 10 + (get-art-by-name-method "Look inside this art for an art with the given name and type. Return #f if not found" (_type_ string type) basic) ;; 11 + (get-art-idx-by-name-method "Look inside this art for an art with the given name and type and return the index of the art. Return #f if not found." (_type_ string type) int) ;; 12 + (contains-art-for-other-group? "Some art groups have placeholder #f's for some art that will be loaded separately as needed. + Does this art group contain art that needs to be added to another group?" (_type_) symbol) ;; 13 ) ) -|# -#| (deftype art-element (art) - ((master-art-group-name string :offset-assert 20) ;; guessed by decompiler - (master-art-group-index int32 :offset-assert 24) + "Base class Art which is not a container of more art." + ((master-art-group-name string :offset-assert 20) + (master-art-group-index int32 :offset-assert 24) + (pad uint8 20) ) :method-count-assert 14 :size-assert #x30 :flag-assert #xe00000030 ) -|# -;; (deftype art-mesh-anim (art-element) -;; () -;; :flag-assert #xe00000030 -;; ) - -#| +(declare-type merc-eye-anim-block structure) (deftype art-joint-anim (art-element) - ((eye-anim merc-eye-anim-block :offset-assert 28) - (blend-shape-anim (pointer int8) :offset-assert 32) ;; guessed by decompiler - (frames joint-anim-compressed-control :offset-assert 36) - (speed float :offset-assert 48) + "Art for a joint animation. Also contains the eye animation." + ((eye-anim merc-eye-anim-block :offset 28) + (blend-shape-anim (pointer int8) :offset 32) ;; guessed by decompiler + (frames joint-anim-compressed-control :offset 36) + (speed float :offset 48) (artist-base float :offset-assert 52) (artist-step float :offset-assert 56) ) @@ -10235,104 +13062,167 @@ :flag-assert #xe0000003c ;; field blend-shape-anim uses ~A with a signed load. ) -|# -;; (deftype art-group (art) -;; () -;; :flag-assert #x1000000020 -;; ) +(deftype art-group (art) + "Art which is a list of more art. The -ag files are an art group with all the art needed for a + actor, like the mesh, animations, shadow mesh, skeleton, etc." + ((info file-info :offset 4) + (data art-element :score -1 :dynamic :offset 32) ;; might just be art? + ) + :flag-assert #x1000000020 + (:methods + (relocate (_type_ kheap (pointer uint8)) none :replace) ;; 7 + (link-art-to-master (_type_) art-group) + (unlink-art-to-master (_type_) int) + ) + ) -;; (deftype art-mesh-geo (art-element) -;; () -;; :flag-assert #xe00000030 -;; ) +(deftype art-mesh-geo (art-element) + "Unused art format for a mesh. This might have been for the renderer that came before merc." + ((data basic :dynamic :offset-assert 48) + ) + :flag-assert #xe00000030 + ) -;; (deftype art-joint-geo (art-element) -;; () -;; :flag-assert #xe00000030 -;; ) +(deftype art-joint-geo (art-element) + "Collection of joints for an actor." + ((data joint :dynamic :offset-assert 48) + ) + :flag-assert #xe00000030 + ) -#| (deftype art-cloth-geo (art-element) - ((anchor-transforms anchor-transform-array :offset-assert 48) ;; guessed by decompiler - (sphere-transforms sphere-transform-array :offset-assert 52) ;; guessed by decompiler - (disc-transforms disc-transform-array :offset-assert 56) ;; guessed by decompiler - (cloth-thickness cloth-thickness-array :offset-assert 60) ;; guessed by decompiler - (thickness-scalar float :offset-assert 64) - (num-points int32 :offset-assert 12) - (mesh cloth-pt :dynamic :offset-assert 80) ;; guessed by decompiler + ((anchor-transforms anchor-transform-array :offset-assert 48) + (sphere-transforms sphere-transform-array :offset-assert 52) + (disc-transforms disc-transform-array :offset-assert 56) + (cloth-thickness cloth-thickness-array :offset-assert 60) + (thickness-scalar float :offset-assert 64) + (num-points int32 :offset 12) + (mesh cloth-pt :dynamic :inline :offset 80) ;; todo ) :method-count-assert 14 :size-assert #x50 :flag-assert #xe00000050 ) -|# -#| (deftype skeleton-group (art-group) - ((name string :offset-assert 8) ;; guessed by decompiler - (length int32 :offset-assert 12) - (extra res-lump :offset-assert 16) ;; guessed by decompiler - (info file-info :offset-assert 4) ;; guessed by decompiler - (data art-element :dynamic :offset-assert 32) ;; guessed by decompiler - (art-group-name string :offset-assert 32) ;; guessed by decompiler - (jgeo int16 :offset-assert 36) - (janim int16 :offset-assert 38) - (bounds vector :inline :offset-assert 48) - (radius meters :offset-assert 60) - (mgeo int16 6 :offset-assert 64) ;; guessed by decompiler - (max-lod int32 :offset-assert 76) - (lod-dist float 6 :offset-assert 80) ;; guessed by decompiler - (longest-edge meters :offset-assert 104) - (texture-level int8 :offset-assert 108) - (version int8 :offset-assert 109) - (shadow int16 :offset-assert 110) - (shadow-joint-index int8 :offset-assert 112) - (origin-joint-index int8 :offset-assert 113) - (sort int8 :offset-assert 114) - (light-index uint8 :offset-assert 115) - (clothing (array cloth-params) :offset-assert 116) ;; guessed by decompiler - (global-effects uint8 :offset-assert 120) + "Unlike other art types, the skeleton-groups are defined in GOAL code. + This stores settings like the name of the art-group, shadow/level-of-detail settings, etc." + ((art-group-name string :offset-assert 32) ;; guessed by decompiler + (jgeo int16 :offset-assert 36) ;; int32 + (janim int16 :offset-assert 38) ;; int32 + (bounds vector :inline :offset-assert 48) + (radius meters :offset-assert 60 :overlay-at (-> bounds w)) + (mgeo int16 6 :offset-assert 64) ;; guessed by decompiler + (max-lod int32 :offset-assert 76) + (lod-dist float 6 :offset-assert 80) ;; guessed by decompiler + (longest-edge meters :offset-assert 104) + (texture-level int8 :offset-assert 108) + (version int8 :offset-assert 109) + (shadow int16 :offset-assert 110) ;; int8 + (shadow-joint-index int8 :offset-assert 112) + (origin-joint-index int8 :offset-assert 113) + (sort int8 :offset-assert 114) + (light-index uint8 :offset-assert 115) + (clothing (array cloth-params) :offset-assert 116) + (global-effects uint8 :offset-assert 120) ) :method-count-assert 17 :size-assert #x79 :flag-assert #x1100000079 (:methods - (skeleton-group-method-16 () none) ;; 16 ;; (add-to-loading-level (_type_) skeleton-group) + (add-to-loading-level (_type_) skeleton-group) ;; 16 ) ) -|# -#| +(declare-type merc-ctrl structure) (deftype lod-group (structure) + "A single level of detail mesh." ((geo merc-ctrl :offset-assert 0) ;; guessed by decompiler (dist meters :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype lod-set (structure) - ((lod lod-group 6 :offset-assert 0) ;; guessed by decompiler + "All the different level-of-detail meshes for an actor." + ((lod lod-group 6 :inline :offset-assert 0) ;; guessed by decompiler (max-lod int8 :offset-assert 48) ) + :allow-misaligned :method-count-assert 10 :size-assert #x31 :flag-assert #xa00000031 (:methods - (lod-set-method-9 () none) ;; 9 ;; (setup-lods! (_type_ skeleton-group art-group entity) _type_) + (setup-lods! (_type_ skeleton-group art-group entity) _type_) ;; 9 ) ) -|# -#| +(declare-type process-nettable process) +(declare-type process-drawable process-nettable) + +;; +++art-h:draw-control-status +(defenum draw-control-status + :type uint32 + :bitfield #t + (close-to-screen 0) + (no-draw 1) + (no-draw-temp) + (on-screen) + (uninited) + (no-draw-bounds) + (no-closest-distance) + (math-skel) + (force-vu1) + (no-draw-bounds2) + (force-fade) + (warp-cross-fade) + (lod-set) + (disable-fog) + (hud) + (no-bounds-check) + ) +;; ---art-h:draw-control-status + +;; +++art-h:draw-control-data-format +(defenum draw-control-data-format + :type uint8 + :bitfield #f + (pris 0) + (merc 1) + ) +;; ---art-h:draw-control-data-format + +;; +++art-h:draw-control-global-effect +(defenum draw-control-global-effect + :type uint8 + :bitfield #t + (bit-0) + (bit-1) + (title-light) + (disable-envmap) + (rim-lights) + (rim-lights2) + (rim-lights3) + (no-textures) + ) +;; ---art-h:draw-control-global-effect + +(declare-type ripple-control basic) +(declare-type shadow-geo structure) +(declare-type shadow-control structure) +(declare-type cloth-base basic) +(declare-type verlet-particle-system cloth-base) +(declare-type cloth-system verlet-particle-system) +(declare-type joint-control basic) + (deftype draw-control (basic) ((process process-drawable :offset-assert 4) ;; guessed by decompiler (status draw-control-status :offset-assert 8) - (data-format uint8 :offset-assert 12) ;; draw-control-data-format + (data-format draw-control-data-format :offset-assert 12) ;; draw-control-data-format (global-effect draw-control-global-effect :offset-assert 13) (art-group art-group :offset-assert 16) ;; guessed by decompiler (jgeo art-joint-geo :offset-assert 20) ;; guessed by decompiler @@ -10340,17 +13230,18 @@ (dma-add-func (function process-drawable draw-control symbol object none) :offset-assert 28) ;; guessed by decompiler (skeleton skeleton :offset-assert 32) ;; guessed by decompiler (lod-set lod-set :inline :offset-assert 36) - (lod UNKNOWN 6 :offset-assert 36) - (max-lod int8 :offset-assert 84) + ;; (lod UNKNOWN 6 :offset-assert 36) + (max-lod int8 :offset 84) (force-lod int8 :offset-assert 85) (cur-lod int8 :offset-assert 86) - (cur-lods UNKNOWN 2 :offset-assert 87) - (effect-masks UNKNOWN 2 :offset-assert 96) + ;; (cur-lods UNKNOWN 2 :offset-assert 87) + (dummy-add int32 2 :offset-assert 88) + (effect-masks uint64 2 :offset-assert 96) (prev-seg-mask uint64 :offset-assert 112) (want-lod int8 :offset-assert 120) (ripple ripple-control :offset-assert 124) ;; guessed by decompiler (longest-edge meters :offset-assert 128) - (longest-edge? uint32 :offset-assert 128) + (longest-edge? uint32 :offset 128) (light-index uint8 :offset-assert 132) (shadow-mask uint8 :offset-assert 133) (level-index uint8 :offset-assert 134) @@ -10364,7 +13255,7 @@ (distance meters :offset-assert 152) (origin vector :inline :offset-assert 160) (bounds vector :inline :offset-assert 176) - (radius meters :offset-assert 188) + (radius meters :offset 188) (color-mult rgbaf :inline :offset-assert 192) (color-emissive rgbaf :inline :offset-assert 208) (effect-mask uint64 :offset-assert 224) @@ -10393,28 +13284,27 @@ (draw-control-method-15 () none) ;; 15 ;; (do-joint-math (_type_ cspace-array joint-control) none) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-vu1-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype pris-mtx (structure) + "Matrix for merc rendering. Named after the earlier 'pris' renderer. + Contains a transformation matrix for vertices, one for normals, and a scale. + This matrix is likely not used by generic VU1, but is used by the merc -> generic converter." ((data float 32 :offset-assert 0) ;; guessed by decompiler - (vector vector 8 :offset-assert 0) ;; guessed by decompiler - (t-mtx matrix :inline :offset-assert 0) - (n-mtx matrix3 :inline :offset-assert 64) - (scale vector :inline :offset-assert 112) + (vector vector 8 :offset 0) ;; guessed by decompiler + (t-mtx matrix :inline :offset 0) + (n-mtx matrix3 :inline :offset 64) + (scale vector :inline :offset 112) ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype generic-pris-mtx-save (structure) ((loc-mtx pris-mtx :inline :offset-assert 0) (par-mtx pris-mtx :inline :offset-assert 128) @@ -10424,12 +13314,11 @@ :size-assert #x180 :flag-assert #x900000180 ) -|# -#| (deftype generic-constants (structure) + "Constant data sent to VU1 for generic rendering." ((fog vector :inline :offset-assert 0) - (adgif qword :inline :offset-assert 16) ;; gs-gif-tag :inline + (adgif gs-gif-tag :inline :offset-assert 16) ;; :inline (hvdf-offset vector :inline :offset-assert 32) (hmge-scale vector :inline :offset-assert 48) (invh-scale vector :inline :offset-assert 64) @@ -10441,9 +13330,7 @@ :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype generic-shrub-constants (structure) ((shrub-giftag generic-gif-tag :inline :offset-assert 0) (shrub-adnop qword :inline :offset-assert 16) @@ -10452,38 +13339,32 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype gcf-shader (structure) ((adgif uint128 5 :offset-assert 0) ;; guessed by decompiler - (shader adgif-shader :inline :offset-assert 0) - (pos uint32 :offset-assert 12) - (num uint32 :offset-assert 28) + (shader adgif-shader :inline :offset 0) + (pos uint32 :offset 12) + (num uint32 :offset 28) ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype gcf-control (structure) ((matrix matrix :inline :offset-assert 0) (giftag generic-gif-tag :inline :offset-assert 64) - (adnops gs-adcmd 2 :offset-assert 80) ;; guessed by decompiler - (num-strips uint32 :offset-assert 76) - (num-dps uint32 :offset-assert 92) - (kick-offset uint32 :offset-assert 108) - (shader gcf-shader :dynamic :offset-assert 112) ;; guessed by decompiler + (adnops gs-adcmd 2 :inline :offset-assert 80) ;; guessed by decompiler + (num-strips uint32 :offset 76) + (num-dps uint32 :offset 92) + (kick-offset uint32 :offset 108) + (shader gcf-shader :inline :dynamic :offset-assert 112) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype gcf-vertex (structure) ((tex vector4w :inline :offset-assert 0) (clr gs-packed-rgba :inline :offset-assert 16) @@ -10493,31 +13374,27 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; merc-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype ripple-merc-query (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (start-vertex int32 :offset-assert 16) - (vertex-skip int32 :offset-assert 20) - (vertex-count int32 :offset-assert 24) - (current-loc int32 :offset-assert 28) - (data vector :dynamic :offset-assert 32) ;; guessed by decompiler + "Information about which merc vertices to apply the 'ripple' effect to." + ((start-vertex int32 :offset-assert 16) + (vertex-skip int32 :offset-assert 20) + (vertex-count int32 :offset-assert 24) + (current-loc int32 :offset-assert 28) + (data vector :inline :dynamic :offset-assert 32) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x20 :flag-assert #xe00000020 ) -|# -#| (deftype merc-byte-header (structure) + "Header for a single [[merc-fragment]] uploaded to the VU." ((srcdest-off uint8 :offset-assert 0) (rgba-off uint8 :offset-assert 1) (lump-off uint8 :offset-assert 2) @@ -10537,10 +13414,9 @@ :size-assert #x17 :flag-assert #x900000017 ) -|# -#| (deftype merc-fragment (structure) + "A single merc fragment that fits into VU memory." ((header merc-byte-header :inline :offset-assert 0) (rest uint8 1 :offset-assert 23) ;; guessed by decompiler ) @@ -10548,13 +13424,12 @@ :size-assert #x18 :flag-assert #xa00000018 (:methods - (merc-fragment-method-9 () none) ;; 9 ;; (login-adgifs (_type_) merc-fragment) + (login-adgifs (_type_) merc-fragment) ;; 9 ) ) -|# -#| (deftype merc-vtx (structure) + "A packed merc vertex." ((mat-0 uint8 :offset-assert 0) (mat-1 uint8 :offset-assert 1) (nrm-x uint8 :offset-assert 2) @@ -10572,10 +13447,9 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype merc-fp-header (structure) + "Merc header for a [[merc-fragment]]'s floating point data." ((x-add float :offset-assert 0) (y-add float :offset-assert 4) (z-add float :offset-assert 8) @@ -10588,35 +13462,33 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype merc-mat-dest (structure) + "Metadata for a merc matrix upload." ((matrix-number uint8 :offset-assert 0) (matrix-dest uint8 :offset-assert 1) ) + :pack-me :method-count-assert 9 :size-assert #x2 :flag-assert #x900000002 ) -|# -#| (deftype merc-fragment-control (structure) + "Data about a [[merc-fragment]] needed for merc DMA generation." ((unsigned-four-count uint8 :offset-assert 0) (lump-four-count uint8 :offset-assert 1) (fp-qwc uint8 :offset-assert 2) (mat-xfer-count uint8 :offset-assert 3) - (mat-dest-data merc-mat-dest :dynamic :offset-assert 4) ;; guessed by decompiler + (mat-dest-data merc-mat-dest :dynamic :inline :offset-assert 4) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype merc-blend-ctrl (structure) + "Information about the vertices of a model modified by BLERC." ((blend-vtx-count uint8 :offset-assert 0) (nonzero-index-count uint8 :offset-assert 1) (bt-index uint8 :dynamic :offset-assert 2) ;; guessed by decompiler @@ -10625,10 +13497,9 @@ :size-assert #x2 :flag-assert #x900000002 ) -|# -#| (deftype mei-envmap-tint (structure) + "Data for the extra 'envmap tint' effect." ((fade0 float :offset-assert 0) (fade1 float :offset-assert 4) (tint rgba :offset-assert 8) ;; guessed by decompiler @@ -10638,10 +13509,9 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype mei-texture-scroll (structure) + "Data for the extra 'texscroll' effect." ((max-dist float :offset-assert 0) (st-int-scale uint8 :offset-assert 4) (time-factor uint8 :offset-assert 5) @@ -10654,10 +13524,9 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype mei-ripple (structure) + "Data for the extra 'ripple' effect." ((x-base float :offset-assert 0) (z-base float :offset-assert 4) (grid-size float :offset-assert 8) @@ -10667,10 +13536,9 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype merc-extra-info (structure) + "Info for merc extra effects." ((envmap-tint-offset uint8 :offset-assert 0) (shader-offset uint8 :offset-assert 1) (texture-scroll-offset uint8 :offset-assert 2) @@ -10681,16 +13549,37 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| +;; +++merc-h:effect-bits +(defenum effect-bits + :type uint8 + :bitfield #t + (texscroll 0) + (no-fade-out 1) ;; translucent. + (ripple 2) + (emerc 3) ;; envmap?? + (ignore-tod-for-envmap-tint 4) ;; color thing + (force-mercneric 5) ;; some mercneric-only effect + (cross-fade 6) ;; WARP? + (ignore-alpha 7) + ) +;; ---merc-h:effect-bits + +;; moved from end of merc-h definitions +(deftype merc-blend-data (structure) ;; was unknown! + "Packed BLERC data." + ((int8-data int8 :dynamic :offset-assert 0) + ) + ) + (deftype merc-effect (structure) + "A collection of [[merc-fragment]]s with data for any extra effects." ((frag-geo merc-fragment :offset-assert 0) (frag-ctrl merc-fragment-control :offset-assert 4) (blend-data merc-blend-data :offset-assert 8) (blend-ctrl merc-blend-ctrl :offset-assert 12) (merc-effect-version uint8 :offset-assert 16) - (effect-bits uint8 :offset-assert 17) ;; effect-bits + (effect-bits effect-bits :offset-assert 17) (frag-count uint16 :offset-assert 18) (blend-frag-count uint16 :offset-assert 20) (tri-count uint16 :offset-assert 22) @@ -10703,70 +13592,66 @@ :size-assert #x20 :flag-assert #xa00000020 (:methods - (merc-effect-method-9 () none) ;; 9 ;; (login-adgifs (_type_) none) + (login-adgifs (_type_) none) ;; 9 ) ) -|# -#| (deftype merc-eye-ctrl (structure) - ((eye-slot int8 :offset-assert 0) - (shader-offset int8 :offset-assert 1) - (shader-count int8 :offset-assert 2) - (eye-ctrl-index int8 :offset-assert 3) - (shader adgif-shader 6 :offset-assert 16) ;; guessed by decompiler - (left-iris-shader adgif-shader :inline :offset-assert 16) - (left-pupil-shader adgif-shader :inline :offset-assert 96) - (left-lid-shader adgif-shader :inline :offset-assert 176) - (right-iris-shader adgif-shader :inline :offset-assert 256) - (right-pupil-shader adgif-shader :inline :offset-assert 336) - (right-lid-shader adgif-shader :inline :offset-assert 416) + "Eye info for both eyes of a merc model." + ((eye-slot int8 :offset-assert 0) + (shader-offset int8 :offset-assert 1) + (shader-count int8 :offset-assert 2) + (eye-ctrl-index int8 :offset-assert 3) + (shader adgif-shader 6 :inline :offset-assert 16) ;; guessed by decompiler + (left-iris-shader adgif-shader :inline :offset 16) + (left-pupil-shader adgif-shader :inline :offset 96) + (left-lid-shader adgif-shader :inline :offset 176) + (right-iris-shader adgif-shader :inline :offset 256) + (right-pupil-shader adgif-shader :inline :offset 336) + (right-lid-shader adgif-shader :inline :offset 416) ) :method-count-assert 9 :size-assert #x1f0 :flag-assert #x9000001f0 ) -|# -#| (deftype merc-eye-anim-frame (structure) + "A single frame of a merc eye animation." ((pupil-trans-x int8 :offset-assert 0) (pupil-trans-y int8 :offset-assert 1) (blink int8 :offset-assert 2) - (iris-scale int8 :offset-assert 4) - (pupil-scale int8 :offset-assert 5) - (lid-scale int8 :offset-assert 6) - (dword uint64 :offset-assert 0) + (iris-scale int8 :offset 4) + (pupil-scale int8 :offset 5) + (lid-scale int8 :offset 6) + (dword uint64 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype merc-eye-anim-block (structure) - ((max-frame int16 :offset-assert 0) - (data merc-eye-anim-frame :dynamic :offset-assert 8) ;; guessed by decompiler + "A list of eye animation frames." + ((max-frame int16 :offset-assert 0) + (data merc-eye-anim-frame :inline :dynamic :offset-assert 8) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype texture-usage-group (structure) - ((data texture-masks 7 :offset-assert 0) ;; guessed by decompiler + ((data texture-masks 7 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x150 :flag-assert #x900000150 ) -|# -#| (deftype merc-ctrl-header (structure) + "The header for a [[merc-ctrl]], + containing metadata about the model used for drawing." ((xyz-scale float :offset-assert 0) (st-magic uint32 :offset-assert 4) (st-out-a uint32 :offset-assert 8) @@ -10796,49 +13681,47 @@ (eye-ctrl merc-eye-ctrl :offset-assert 64) (pad uint32 3 :offset-assert 68) ;; guessed by decompiler (masks-padding texture-masks :inline :offset-assert 80) - (texture-usage-group texture-usage-group :offset-assert 80) - (dummy-bytes uint8 :dynamic :offset-assert 32) ;; guessed by decompiler - (envmap-tint uint32 :offset-assert 32) - (query basic :offset-assert 36) - (needs-clip uint8 :offset-assert 40) - (use-isometric uint8 :offset-assert 41) - (use-attached-shader uint8 :offset-assert 42) - (display-triangles uint8 :offset-assert 43) - (death-vertex-skip uint16 :offset-assert 44) - (death-start-vertex uint16 :offset-assert 46) - (death-effect uint32 :offset-assert 48) - (use-translucent uint8 :offset-assert 52) - (display-this-fragment uint8 :offset-assert 53) - (use-warp uint8 :offset-assert 54) - (ignore-alpha uint8 :offset-assert 55) - (force-fade uint8 :offset-assert 56) - (disable-fog uint8 :offset-assert 57) - (disable-envmap uint8 :offset-assert 58) + (texture-usage-group texture-usage-group :offset 80) + (dummy-bytes uint8 :dynamic :offset 32) ;; guessed by decompiler + (envmap-tint uint32 :offset 32) + (query basic :offset 36) + (needs-clip uint8 :offset 40) + (use-isometric uint8 :offset 41) + (use-attached-shader uint8 :offset 42) + (display-triangles uint8 :offset 43) + (death-vertex-skip uint16 :offset 44) + (death-start-vertex uint16 :offset 46) + (death-effect uint32 :offset 48) + (use-translucent uint8 :offset 52) + (display-this-fragment uint8 :offset 53) + (use-warp uint8 :offset 54) + (ignore-alpha uint8 :offset 55) + (force-fade uint8 :offset 56) + (disable-fog uint8 :offset 57) + (disable-envmap uint8 :offset 58) ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ;; field xyz-scale is a float printed as hex? ) -|# -#| (deftype merc-ctrl (art-element) - ((num-joints int32 :offset-assert 12) - (seg-table (array uint64) :offset-assert 28) ;; guessed by decompiler + "The merc data for a single model as it's stored in an art group. + Consists of a header and a list of [[merc-effect]]s." + ((num-joints int32 :offset 12) + (seg-table (array uint64) :offset 28) ;; guessed by decompiler (header merc-ctrl-header :inline :offset-assert 48) - (effect merc-effect :dynamic :offset-assert 176) ;; guessed by decompiler + (effect merc-effect :dynamic :inline :offset-assert 176) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #xb0 :flag-assert #xe000000b0 ) -|# -#| (deftype merc-vu1-low-mem (structure) - ((tri-strip-gif qword :inline :offset-assert 0) ;; gs-gif-tag :inline - (ad-gif qword :inline :offset-assert 16) ;; gs-gif-tag :inline + ((tri-strip-gif gs-gif-tag :inline :offset-assert 0) ;; gs-gif-tag :inline + (ad-gif gs-gif-tag :inline :offset-assert 16) ;; gs-gif-tag :inline (hvdf-offset vector :inline :offset-assert 32) (perspective uint128 4 :offset-assert 48) ;; guessed by decompiler (fog vector :inline :offset-assert 112) @@ -10847,24 +13730,20 @@ :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype emerc-vu1-low-mem (structure) - ((tri-strip-gif qword :inline :offset-assert 0) ;; gs-gif-tag :inline - (ad-gif qword :inline :offset-assert 16) ;; gs-gif-tag :inline - (hvdf-offset vector :inline :offset-assert 32) - (perspective vector 4 :offset-assert 48) ;; guessed by decompiler - (fog vector :inline :offset-assert 112) - (unperspect vector :inline :offset-assert 128) + ((tri-strip-gif gs-gif-tag :inline :offset-assert 0) ;; gs-gif-tag :inline + (ad-gif gs-gif-tag :inline :offset-assert 16) ;; gs-gif-tag :inline + (hvdf-offset vector :inline :offset-assert 32) + (perspective vector 4 :inline :offset-assert 48) ;; guessed by decompiler + (fog vector :inline :offset-assert 112) + (unperspect vector :inline :offset-assert 128) ) :method-count-assert 9 :size-assert #x90 :flag-assert #x900000090 ) -|# -#| (deftype texture-login-data (structure) ((default-texture-index int32 :offset-assert 0) (current-texture-index int32 :offset-assert 4) @@ -10876,9 +13755,7 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype ripple-wave (structure) ((scale float :offset-assert 0) (offs float :offset-assert 4) @@ -10889,27 +13766,24 @@ (zmul float :offset-assert 20) (delta float :offset-assert 24) ) + :pack-me :method-count-assert 9 :size-assert #x1c :flag-assert #x90000001c ) -|# -#| (deftype ripple-wave-set (basic) ((count int32 :offset-assert 4) (converted basic :offset-assert 8) (normal-scale float :offset-assert 12) - (wave ripple-wave 4 :offset-assert 16) ;; guessed by decompiler + (wave ripple-wave 4 :inline :offset-assert 16) ;; guessed by decompiler (frame-save uint64 :offset-assert 128) ) :method-count-assert 9 :size-assert #x88 :flag-assert #x900000088 ) -|# -#| (deftype ripple-control (basic) ((global-scale float :offset-assert 4) (last-frame-scale float :offset-assert 8) @@ -10924,10 +13798,11 @@ :method-count-assert 9 :size-assert #x28 :flag-assert #x900000028 + (:methods + (new (symbol type) _type_) ;; 0 + ) ) -|# -#| (deftype death-info (basic) ((vertex-skip uint16 :offset-assert 4) (timer uint8 :offset-assert 6) @@ -10939,48 +13814,34 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| -(deftype merc-blend-data (UNKNOWN) - ((int8-data int8 :dynamic :offset-assert 0) ;; guessed by decompiler - ) - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 - ) -|# - -;; (define-extern merc-fragment-fp-data function) ;; (function merc-fragment merc-fp-header) +(define-extern merc-fragment-fp-data + "Get the floating point data of a [[merc-fragment]]." + (function merc-fragment merc-fp-header)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-merc-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype merc-matrix (structure) ((quad uint128 8 :offset-assert 0) ;; guessed by decompiler - (vector vector 8 :offset-assert 0) ;; guessed by decompiler - (tag uint64 :offset-assert 0) + (vector vector 8 :inline :offset 0 :score 1) ;; guessed by decompiler + (tag uint64 :offset 0) ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype generic-merc-tag (dma-packet) - ((next-ptr uint32 :offset-assert 12) - (size uint32 :offset-assert 8) + ((next-ptr uint32 :offset 12) + (size uint32 :offset 8) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype generic-merc-ctrl (structure) ((tag generic-merc-tag :inline :offset-assert 0) (lights vu-lights :inline :offset-assert 16) @@ -10991,9 +13852,7 @@ :size-assert #x120 :flag-assert #x900000120 ) -|# -#| (deftype generic-merc-ctrl-with-sfx (generic-merc-ctrl) ((sfx-data uint128 11 :offset-assert 288) ;; guessed by decompiler ) @@ -11001,14 +13860,12 @@ :size-assert #x1d0 :flag-assert #x9000001d0 ) -|# -#| (deftype generic-merc-input (structure) ((geo-tag generic-merc-tag :inline :offset-assert 0) (geo-block uint8 1296 :offset-assert 16) ;; guessed by decompiler - (byte-header merc-byte-header :inline :offset-assert 16) - (matrix merc-matrix 9 :offset-assert 1312) ;; guessed by decompiler + (byte-header merc-byte-header :inline :offset 16) + (matrix merc-matrix 9 :inline :offset-assert 1312) ;; guessed by decompiler (control generic-merc-ctrl-with-sfx :inline :offset-assert 2464) (end-tag generic-merc-tag :inline :offset-assert 2928) (shader adgif-shader :inline :offset-assert 2944) @@ -11017,24 +13874,20 @@ :size-assert #xbd0 :flag-assert #x900000bd0 ) -|# -#| (deftype generic-merc-output (structure) ((info gsf-info :inline :offset-assert 0) (header gsf-header :inline :offset-assert 16) (index-kick-table uint16 80 :offset-assert 32) ;; guessed by decompiler - (index-table uint8 160 :offset-assert 32) ;; guessed by decompiler + (index-table uint8 160 :offset 32) ;; guessed by decompiler (inverse-table uint8 256 :offset-assert 192) ;; guessed by decompiler - (vertex-table gsf-vertex 72 :offset-assert 448) ;; guessed by decompiler + (vertex-table gsf-vertex 72 :inline :offset-assert 448) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #xac0 :flag-assert #x900000ac0 ) -|# -#| (deftype generic-merc-dcache (structure) ((output-a generic-merc-output :inline :offset-assert 0) (output-b generic-merc-output :inline :offset-assert 2752) @@ -11047,9 +13900,7 @@ :size-assert #x2000 :flag-assert #x900002000 ) -|# -#| (deftype gm-shadow (structure) ((perspective matrix :inline :offset-assert 0) (isometric matrix :inline :offset-assert 64) @@ -11084,9 +13935,7 @@ :size-assert #x1a0 :flag-assert #x9000001a0 ) -|# -#| (deftype generic-merc-work (structure) ((input-a generic-merc-input :inline :offset-assert 0) (input-b generic-merc-input :inline :offset-assert 3024) @@ -11098,17 +13947,15 @@ :size-assert #x1c10 :flag-assert #x900001c10 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-tie-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype generic-tie-instance (structure) ((matrix-tag dma-packet :inline :offset-assert 0) - (matrix-data vector 6 :offset-assert 16) ;; guessed by decompiler + (matrix-data vector 6 :inline :offset-assert 16) ;; guessed by decompiler (index-tag dma-packet :inline :offset-assert 112) (indices uint8 224 :offset-assert 128) ;; guessed by decompiler (end-tag dma-packet :inline :offset-assert 352) @@ -11117,16 +13964,14 @@ :size-assert #x170 :flag-assert #x900000170 ) -|# -#| (deftype generic-tie-input (structure) ((palette-tag dma-packet :inline :offset-assert 0) (palette rgba 128 :offset-assert 16) ;; guessed by decompiler (model-tag dma-packet :inline :offset-assert 528) - (model vector 146 :offset-assert 544) ;; guessed by decompiler + (model vector 146 :inline :offset-assert 544) ;; guessed by decompiler (matrix-tag dma-packet :inline :offset-assert 2880) - (matrix-data vector 6 :offset-assert 2896) ;; guessed by decompiler + (matrix-data vector 6 :inline :offset-assert 2896) ;; guessed by decompiler (index-tag dma-packet :inline :offset-assert 2992) (indices uint8 224 :offset-assert 3008) ;; guessed by decompiler (end-tag dma-packet :inline :offset-assert 3232) @@ -11135,9 +13980,7 @@ :size-assert #xcb0 :flag-assert #x900000cb0 ) -|# -#| (deftype generic-tie-run-control (structure) ((skip-bp2 uint8 :offset-assert 0) (skip-ips uint8 :offset-assert 1) @@ -11156,76 +13999,67 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype generic-tie-base-point (structure) ((data uint16 8 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) - (x int16 :offset-assert 0) - (y int16 :offset-assert 2) - (z int16 :offset-assert 4) - (d0 int16 :offset-assert 6) - (vtx uint64 :offset-assert 0) - (u int16 :offset-assert 8) - (v int16 :offset-assert 10) - (tex uint32 :offset-assert 8) - (w int16 :offset-assert 12) - (d1 int16 :offset-assert 14) + (quad uint128 :offset 0) + (x int16 :offset 0) + (y int16 :offset 2) + (z int16 :offset 4) + (d0 int16 :offset 6) + (vtx uint64 :offset 0) + (u int16 :offset 8) + (v int16 :offset 10) + (tex uint32 :offset 8) + (w int16 :offset 12) + (d1 int16 :offset 14) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype generic-tie-bps (structure) - ((bp generic-tie-base-point 4 :offset-assert 0) ;; guessed by decompiler + ((bp generic-tie-base-point 4 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype generic-tie-interp-point (structure) ((data uint16 12 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) - (x int16 :offset-assert 0) - (y int16 :offset-assert 2) - (z int16 :offset-assert 4) - (d0 int16 :offset-assert 6) - (vtx0 uint64 :offset-assert 0) - (dx int16 :offset-assert 8) - (dy int16 :offset-assert 10) - (dz int16 :offset-assert 12) - (unused int16 :offset-assert 14) - (vtx1 uint64 :offset-assert 8) - (u int16 :offset-assert 16) - (v int16 :offset-assert 18) - (tex uint32 :offset-assert 16) - (w int16 :offset-assert 20) - (d1 int16 :offset-assert 22) + ;(quad uint128 :offset 0) ;; misaligned? + (x int16 :offset 0) + (y int16 :offset 2) + (z int16 :offset 4) + (d0 int16 :offset 6) + (vtx0 uint64 :offset 0) + (dx int16 :offset 8) + (dy int16 :offset 10) + (dz int16 :offset 12) + (unused int16 :offset 14) + (vtx1 uint64 :offset 8) + (u int16 :offset 16) + (v int16 :offset 18) + (tex uint32 :offset 16) + (w int16 :offset 20) + (d1 int16 :offset 22) ) + :pack-me :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype generic-tie-ips (structure) - ((ip generic-tie-interp-point 2 :offset-assert 0) ;; guessed by decompiler + ((ip generic-tie-interp-point 2 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype generic-tie-header (structure) ((effect uint8 :offset-assert 0) (interp-table-size uint8 :offset-assert 1) @@ -11242,9 +14076,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype generic-tie-matrix (structure) ((matrix matrix :inline :offset-assert 0) (morph vector :inline :offset-assert 64) @@ -11254,9 +14086,7 @@ :size-assert #x60 :flag-assert #x900000060 ) -|# -#| (deftype generic-tie-normal (structure) ((x int8 :offset-assert 0) (y int8 :offset-assert 1) @@ -11267,9 +14097,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype generic-tie-control (structure) ((ptr-palette uint32 :offset-assert 0) (ptr-shaders uint32 :offset-assert 4) @@ -11291,9 +14119,7 @@ :size-assert #x3c :flag-assert #x90000003c ) -|# -#| (deftype generic-tie-stats (structure) ((num-bps uint32 :offset-assert 0) (num-ips uint32 :offset-assert 4) @@ -11309,22 +14135,19 @@ :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype generic-tie-calls (structure) ((generic-prepare-dma-double basic :offset-assert 0) (generic-envmap-dproc basic :offset-assert 4) (generic-interp-dproc basic :offset-assert 8) (generic-no-light-dproc basic :offset-assert 12) ) + :pack-me :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype generic-tie-shadow (structure) ((out-buf gsf-buffer :offset-assert 0) (cur-buf uint32 :offset-assert 4) @@ -11336,13 +14159,12 @@ (write-limit uint32 :offset-assert 28) (calls generic-tie-calls :inline :offset-assert 32) ) + :pack-me :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype generic-tie-work (structure) ((control generic-tie-control :inline :offset-assert 0) (interp-job generic-interp-job :inline :offset-assert 60) @@ -11356,26 +14178,22 @@ :size-assert #x1d50 :flag-assert #x900001d50 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-work-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype generic-input-buffer (structure) ((data uint128 473 :offset-assert 0) ;; guessed by decompiler - (merc generic-merc-work :inline :offset-assert 0) - (tie generic-tie-work :inline :offset-assert 0) + (merc generic-merc-work :inline :offset 0) + (tie generic-tie-work :inline :offset 0) ) :method-count-assert 9 :size-assert #x1d90 :flag-assert #x900001d90 ) -|# -#| (deftype generic-debug (structure) ((locks uint32 4 :offset-assert 0) ;; guessed by decompiler (timer uint32 32 :offset-assert 16) ;; guessed by decompiler @@ -11389,26 +14207,22 @@ :size-assert #x19c :flag-assert #x90000019c ) -|# -#| (deftype generic-vu1-header (structure) ((matrix matrix :inline :offset-assert 0) (strgif generic-gif-tag :inline :offset-assert 64) - (adcmds gs-adcmd 2 :offset-assert 80) ;; guessed by decompiler - (adnop1 gs-adcmd :inline :offset-assert 80) - (adnop2 gs-adcmd :inline :offset-assert 96) - (dps uint16 :offset-assert 92) - (kickoff uint16 :offset-assert 108) - (strips uint16 :offset-assert 76) + (adcmds gs-adcmd 2 :inline :offset-assert 80) ;; guessed by decompiler + (adnop1 gs-adcmd :inline :offset 80) + (adnop2 gs-adcmd :inline :offset 96) + (dps uint16 :offset 92) + (kickoff uint16 :offset 108) + (strips uint16 :offset 76) ) :method-count-assert 9 :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype generic-vu1-texbuf (structure) ((header generic-vu1-header :inline :offset-assert 0) (shader uint32 :dynamic :offset-assert 112) ;; guessed by decompiler @@ -11417,9 +14231,7 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype generic-texbuf (structure) ((tag dma-packet :inline :offset-assert 0) (header generic-vu1-header :inline :offset-assert 16) @@ -11429,9 +14241,7 @@ :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype generic-effect-work (structure) ((consts generic-consts :inline :offset-assert 0) (storage generic-storage :inline :offset-assert 432) @@ -11442,9 +14252,7 @@ :size-assert #x420 :flag-assert #x900000420 ) -|# -#| (deftype generic-effect-buffer (structure) ((outbuf-0 uint8 3552 :offset-assert 0) ;; guessed by decompiler (work generic-effect-work :inline :offset-assert 3552) @@ -11454,9 +14262,7 @@ :size-assert #x1fe0 :flag-assert #x900001fe0 ) -|# -#| (deftype generic-work (structure) ((saves generic-saves :inline :offset-assert 0) (storage generic-storage :inline :offset-assert 368) @@ -11467,34 +14273,48 @@ :size-assert #x3fe0 :flag-assert #x900003fe0 ) -|# -;; (define-extern *generic-debug* object) ;; generic-debug +(define-extern *generic-debug* generic-debug) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; shadow-cpu-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++shadow-cpu-h:shadow-flags +(defenum shadow-flags + :bitfield #t + :type int32 + (shdf00) ;; unused + (disable-fade) + (shdf02) ;; only set, never used. + (shdf03) + (shdf04) ;; unused + (disable-draw) + (shdf06) + (shdf07) + (shdf08) + ) +;; ---shadow-cpu-h:shadow-flags + (deftype shadow-settings (structure) - ((center vector :inline :offset-assert 0) - (flags int32 :offset-assert 12) ;; shadow-flags + "Settings used to draw a shadow." + ((center vector :inline :offset-assert 0 :score -1) + (flags shadow-flags :offset 12) (shadow-dir vector :inline :offset-assert 16) - (dist-to-locus float :offset-assert 28) + (dist-to-locus float :offset 28) (bot-plane plane :inline :offset-assert 32) (top-plane plane :inline :offset-assert 48) - (fade-dist float :offset-assert 64) - (fade-start float :offset-assert 68) - (dummy-2 int32 :offset-assert 72) - (shadow-type int32 :offset-assert 76) + (fade-vec vector :inline :offset 64 :score -1) ;; added + (fade-dist float :offset 64) + (fade-start float :offset 68) + (dummy-2 int32 :offset 72) + (shadow-type int32 :offset 76 :score 1) ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype shadow-control (basic) ((settings shadow-settings :inline :offset-assert 16) ) @@ -11502,21 +14322,20 @@ :size-assert #x60 :flag-assert #xf00000060 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type float float float vector shadow-flags float) _type_) - (shadow-control-method-9 () none) ;; 9 ;; (enable-draw (shadow-control) int) - (shadow-control-method-10 () none) ;; 10 ;; (disable-draw (shadow-control) int) - (shadow-control-method-11 () none) ;; 11 ;; (set-top-plane-offset (shadow-control float) int) - (shadow-control-method-12 () none) ;; 12 ;; (set-bottom-plane-offset (shadow-control float) int) - (shadow-control-method-13 () none) ;; 13 ;; (probe-line-for-shadow (_type_ vector float float float) none) - (shadow-control-method-14 () none) ;; 14 ;; (shadow-control-method-14 (_type_ vector vector float float float) none) + (new (symbol type float float float vector shadow-flags float) _type_) ;; 0 + (enable-draw (shadow-control) int) ;; 9 + (disable-draw (shadow-control) int) ;; 10 + (set-top-plane-offset (shadow-control float) int) ;; 11 + (set-bottom-plane-offset (shadow-control float) int) ;; 12 + (probe-line-for-shadow (_type_ vector float float float) none) ;; 13 + (shadow-control-method-14 (_type_ vector vector float float float) none) ;; 14 ) ) -|# -#| (deftype shadow-data (structure) + "DMA data for the shadow renderer." ((dma-unpack-template dma-packet :inline :offset-assert 0) - (dma-cnt uint64 :offset-assert 16) ;; dma-tag + (dma-cnt dma-tag :offset-assert 16) ;; dma-tag (vif-nop vif-tag :offset-assert 24) ;; guessed by decompiler (vif-unpack-v4-8 vif-tag :offset-assert 28) ;; guessed by decompiler (pdc basic :offset-assert 32) @@ -11528,9 +14347,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype shadow-work (structure) ((shadow-data shadow-data :inline :offset-assert 0) (inbuf uint128 600 :offset-assert 48) ;; guessed by decompiler @@ -11539,45 +14356,41 @@ :size-assert #x25b0 :flag-assert #x9000025b0 ) -|# -#| +(declare-type shadow-vu1-constants structure) + (deftype shadow-bucket (structure) ((first pointer :offset-assert 0) ;; guessed by decompiler (next pointer :offset-assert 4) ;; guessed by decompiler - (bucket-id int32 :offset-assert 8) ;; bucket-id + (bucket-id bucket-id :offset-assert 8) (shadow-color rgba :offset-assert 12) ;; guessed by decompiler (constants shadow-vu1-constants :offset-assert 16) ;; guessed by decompiler ) + :allow-misaligned :method-count-assert 9 :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype shadow-bucket-views (structure) - ((data UNKNOWN 2 :offset-assert 0) + ((data shadow-bucket 2 :inline :offset-assert 0) ) + :allow-misaligned :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype shadow-globals (structure) ((num-buckets uint32 :offset-assert 0) (cur-bucket uint32 :offset-assert 4) - (data UNKNOWN 3 :offset-assert 8) + (data shadow-bucket-views 3 :inline :offset-assert 8) ) :method-count-assert 9 :size-assert #xc8 :flag-assert #x9000000c8 ) -|# -#| (deftype shadow-vertex (structure) ((x float :offset-assert 0) (y float :offset-assert 4) @@ -11588,9 +14401,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype shadow-matrix-ref (structure) ((joint-0 uint8 :offset-assert 0) (joint-1 uint8 :offset-assert 1) @@ -11599,9 +14410,7 @@ :size-assert #x2 :flag-assert #x900000002 ) -|# -#| (deftype shadow-edge (structure) ((ind-0 uint8 :offset-assert 0) (ind-1 uint8 :offset-assert 1) @@ -11612,9 +14421,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype shadow-tri (structure) ((ind-0 uint8 :offset-assert 0) (ind-1 uint8 :offset-assert 1) @@ -11625,9 +14432,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype shadow-frag-header (structure) ((qwc-data uint32 :offset-assert 0) (num-joints uint32 :offset-assert 4) @@ -11648,38 +14453,35 @@ :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype shadow-frag-ref (structure) ((header shadow-frag-header :offset-assert 0) (qwc uint32 :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype shadow-geo (art-element) - ((version uint32 :offset-assert 28) - (total-size uint32 :offset-assert 32) + "The low poly model used for drawing the shadow." + ((version uint32 :offset 28) + (total-size uint32 :offset 32) (total-qwc uint32 :offset-assert 48) (num-joints uint32 :offset-assert 52) (num-fragments uint32 :offset-assert 56) - (frags shadow-frag-ref :dynamic :offset-assert 60) ;; guessed by decompiler + (frags shadow-frag-ref :inline :dynamic :offset-assert 60) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x3c :flag-assert #xe0000003c ) -|# -;; (define-extern *shadow-globals* object) ;; shadow-globals -;; (define-extern *shadow* object) ;; symbol -;; (define-extern *shadow-object* object) ;; symbol -;; (define-extern *shadow-debug* object) ;; symbol +(define-extern *shadow-globals* shadow-globals) +(define-extern *shadow* symbol) +(define-extern *shadow-object* symbol) +(define-extern *shadow-debug* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; shadow-vu1-h ;; @@ -11690,56 +14492,69 @@ ;; prim-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(define-extern process-drawable-art-error (state string process-drawable)) + (deftype prim-vertex (structure) + "Vertex for the prim renderer. These vertices are generated by + some special effect code, then sent to the prim renderer to be drawn." ((stq vector :inline :offset-assert 0) - (nokick uint32 :offset-assert 8) - (col rgba :offset-assert 12) ;; guessed by decompiler + (nokick uint32 :offset-assert 8 :overlay-at (-> stq z)) + (col rgba :offset-assert 12 :overlay-at (-> stq w) :score 1) (pos vector :inline :offset-assert 16) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype prim-base (basic) + "Base class for prim-strip." () :method-count-assert 10 :size-assert #x4 :flag-assert #xa00000004 (:methods - (prim-base-method-9 () none) ;; 9 ;; (generate-dma! (_type_ matrix) none) + (generate-dma! "Generate DMA for prim rendering." (_type_ matrix) none) ;; 9 ) ) -|# -#| (deftype prim-client (basic) () :method-count-assert 10 :size-assert #x4 :flag-assert #xa00000004 (:methods - (prim-client-method-9 () none) ;; 9 + (prim-client-method-9 (_type_) none) ;; 9 ) ) -|# -#| +;; +++prim-h:prim-flags +(defenum prim-flags + :type uint32 + :bitfield #t + (alpha-blend-enable 0) ;; set by default + (texture-enable 1) ;; set by default + (fog-enable 2) + (pf3 3) ;; auto-clear vertices? + (pf4 4) ;; has new verts to draw? + (no-texture-name 5) ;; only has the ID. + ) +;; ---prim-h:prim-flags + (deftype prim-strip (prim-base) + "A collection of vertices, all with the same texture and draw settings. + These are owned by the thing submitting to prim, not the prim renderer itself." ((flags prim-flags :offset-assert 4) ;; guessed by decompiler (tex-name basic :offset-assert 8) (tex basic :offset-assert 12) (tex-id texture-id :offset-assert 16) ;; guessed by decompiler - (adnops gs-adcmd 2 :offset-assert 32) ;; guessed by decompiler - (data0 uint64 :offset-assert 32) ;; gs-test - (reg0 uint64 :offset-assert 40) ;; gs-reg64 - (data1 uint64 :offset-assert 48) ;; gs-test - (reg1 uint64 :offset-assert 56) ;; gs-reg64 - (clamp uint64 :offset-assert 64) ;; gs-clamp - (alpha uint64 :offset-assert 72) ;; gs-alpha + (adnops gs-adcmd 2 :inline :offset-assert 32) ;; guessed by decompiler + (data0 gs-test :offset 32) ;; gs-test + (reg0 gs-reg64 :offset 40) ;; gs-reg64 + (data1 gs-test :offset 48) ;; gs-test + (reg1 gs-reg64 :offset 56) ;; gs-reg64 + (clamp gs-clamp :offset-assert 64) ;; gs-clamp + (alpha gs-alpha :offset-assert 72) ;; gs-alpha (level level :offset-assert 80) ;; guessed by decompiler (texture-index int8 :offset-assert 84) ;; uint32 (num-verts uint16 :offset-assert 86) @@ -11751,27 +14566,25 @@ :size-assert #x60 :flag-assert #xb00000060 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type int texture-id string) _type_) - (prim-strip-method-10 () none) ;; 10 ;; (setup-dma-and-tex (_type_ draw-control) none) + (new "Allocate a new prim-strip and room for vertices. The texture can be specified by name or ID." + (symbol type int texture-id string) _type_) + (setup-dma-and-tex "Set up the bucket, prim sink, and texture." (_type_ draw-control) none) ;; 10 ) ) -|# -#| (deftype prim-sink (structure) ((vertex-count uint8 :offset-assert 0) (control-count uint8 :offset-assert 1) ) + :allow-misaligned :method-count-assert 9 :size-assert #x2 :flag-assert #x900000002 ) -|# -#| (deftype prim-work (structure) - ((vertex-tmpl dma-packet 3 :offset-assert 0) ;; guessed by decompiler - (control-tmpl dma-packet 2 :offset-assert 48) ;; guessed by decompiler + ((vertex-tmpl dma-packet 3 :inline :offset-assert 0) ;; guessed by decompiler + (control-tmpl dma-packet 2 :inline :offset-assert 48) ;; guessed by decompiler (giftag generic-gif-tag :inline :offset-assert 80) (call-scissor dma-packet :inline :offset-assert 96) (call-noclip dma-packet :inline :offset-assert 112) @@ -11779,8 +14592,8 @@ (mask vector4w :inline :offset-assert 208) (in-verts int32 :offset-assert 224) (num-verts int32 :offset-assert 228) - (vert-ptr prim-vertex :offset-assert 232) ;; (inline-array prim-vertex) - (sinks prim-sink 114 :offset-assert 236) ;; guessed by decompiler + (vert-ptr (inline-array prim-vertex) :offset-assert 232) ;; + (sinks prim-sink 114 :inline :offset-assert 236) ;; guessed by decompiler ) :method-count-assert 10 :size-assert #x80c @@ -11789,69 +14602,67 @@ (prim-work-method-9 () none) ;; 9 ;; (reset! (_type_) none) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; memcard-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype mc-handle (int32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype mc-handle (int32) + () + :flag-assert #x900000004 + ) -#| (deftype mc-file-info (structure) + "Data stored in a save file." ((present int32 :offset-assert 0) (blind-data float 24 :offset-assert 4) ;; guessed by decompiler - (blind-data-int8 int8 96 :offset-assert 4) ;; guessed by decompiler - (level-index int32 :offset-assert 4) - (gem-count float :offset-assert 8) - (skill-count float :offset-assert 12) - (completion-percentage float :offset-assert 16) - (minute uint8 :offset-assert 24) - (hour uint8 :offset-assert 25) - (week uint8 :offset-assert 26) - (day uint8 :offset-assert 27) - (month uint8 :offset-assert 28) - (year uint8 :offset-assert 29) - (language uint8 :offset-assert 30) - (game-time0 uint32 :offset-assert 36) - (game-time1 uint32 :offset-assert 40) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (name UNKNOWN 16 :offset-assert 68) + (blind-data-int8 int8 96 :offset 4) ;; guessed by decompiler + (level-index int32 :offset 4) + (gem-count float :offset 8) + (skill-count float :offset 12) + (completion-percentage float :offset 16) + (minute uint8 :offset 24) + (hour uint8 :offset 25) + (week uint8 :offset 26) + (day uint8 :offset 27) + (month uint8 :offset 28) + (year uint8 :offset 29) + (language uint8 :offset 30) + (game-time0 uint32 :offset 36) + (game-time1 uint32 :offset 40) + (purchase-secrets uint32 :offset 44) + (secrets uint32 :offset 52) + (features uint32 :offset 60) + (name uint8 16 :offset 68) ) + :pack-me :method-count-assert 9 :size-assert #x64 :flag-assert #x900000064 ) -|# -#| (deftype mc-slot-info (structure) - ((handle int32 :offset-assert 0) ;; mc-handle + "Data about a memory card slot." + ((handle mc-handle :offset-assert 0) ;; (known int32 :offset-assert 4) (formatted int32 :offset-assert 8) (inited int32 :offset-assert 12) (last-file int32 :offset-assert 16) (mem-required int32 :offset-assert 20) (mem-actual int32 :offset-assert 24) - (file mc-file-info 4 :offset-assert 28) ;; guessed by decompiler + (file mc-file-info 4 :inline :offset-assert 28) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x1ac :flag-assert #x9000001ac ) -|# -#| (deftype stored-network-account (structure) - ((name UNKNOWN 64 :offset-assert 0) - (password UNKNOWN 64 :offset-assert 64) + ((name uint8 64 :offset-assert 0) + (password uint8 64 :offset-assert 64) ) + :pack-me :method-count-assert 11 :size-assert #x80 :flag-assert #xb00000080 @@ -11860,14 +14671,13 @@ (stored-network-account-method-10 () none) ;; 10 ) ) -|# -#| (deftype stored-network-accounts (structure) - ((accounts UNKNOWN 4 :offset-assert 0) + ((accounts stored-network-account 4 :inline :offset-assert 0) (default-idx int8 :offset-assert 512) (ct int8 :offset-assert 513) ) + :allow-misaligned :method-count-assert 10 :size-assert #x202 :flag-assert #xa00000202 @@ -11875,47 +14685,126 @@ (stored-network-accounts-method-9 () none) ;; 9 ) ) -|# -#| (deftype mc-common-data (structure) ((magic uint32 :offset-assert 0) (crc uint32 :offset-assert 4) (version uint32 :offset-assert 8) - (data UNKNOWN 1012 :offset-assert 12) - (net-accounts stored-network-accounts :inline :offset-assert 12) + (data uint8 1012 :offset-assert 12) + (net-accounts stored-network-accounts :inline :offset 12) ) :method-count-assert 9 :size-assert #x400 :flag-assert #x900000400 ) -|# -#| (deftype mc-patch-data (structure) ((magic uint32 :offset-assert 0) (crc uint32 :offset-assert 4) (version uint32 :offset-assert 8) (size uint32 :offset-assert 12) - (data UNKNOWN 524272 :offset-assert 16) + (data uint8 524272 :offset-assert 16) ) :method-count-assert 9 - :size-assert #x0 - :heap-base #x8 - :flag-assert #x900080000 + :size-assert #x80000 + :flag-assert #x900000000 ) -|# -;; (define-extern mc-sync function) ;; (function int) -;; (define-extern show-mc-info function) ;; (function dma-buffer none) -;; (define-extern *mc-common-data* object) -;; (define-extern *mc-patch-data* object) -;; (define-extern *mc-last-result* object) +;; +++memcard-h:mc-status-code +(defenum mc-status-code + :type uint32 + (busy 0) + (ok 1) + (bad-handle 2) + (format-failed 3) + (internal-error 4) + (write-error 5) + (read-error 6) + (new-game 7) + (no-memory 8) + (no-card 9) + (no-last 10) + (no-format 11) + (no-file 12) + (no-save 13) + (no-space 14) + (bad-version 15) + (no-process 16) + (no-auto-save 17) + ) +;; ---memcard-h:mc-status-code + +;; from kernel +(define-extern mc-get-slot-info (function int mc-slot-info none)) + +;; original funcs +(define-extern mc-sync (function int)) +(define-extern show-mc-info (function dma-buffer none)) +(define-extern *mc-common-data* mc-common-data) +(define-extern *mc-patch-data* mc-patch-data) +(define-extern *mc-last-result* mc-status-code) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; game-info-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +++game-info-h:pickup-type +(defenum pickup-type + :type int32 + (none 0) + (eco-yellow 1) + (eco-red 2) + (eco-blue 3) + (eco-dark 4) + (eco-green 5) + (eco-pill-green 6) + (eco-pill-dark 7) + (eco-pill-light 8) + (eco-pill-random 9) + (money 10) + (fuel-cell 11) + (buzzer 12) + (darkjak 13) + (lightjak 14) + (ammo-yellow 15) + (ammo-red 16) + (ammo-blue 17) + (ammo-dark 18) + (shield 19) + (health 20) + (trick-point 21) + (trick-judge 22) + (gem 23) + (skill 24) + (karma 25) + (gun-red-1 26) + (gun-red-2 27) + (gun-red-3 28) + (gun-yellow-1 29) + (gun-yellow-2 30) + (gun-yellow-3 31) + (gun-blue-1 32) + (gun-blue-2 33) + (gun-blue-3 34) + (gun-dark-1 35) + (gun-dark-2 36) + (gun-dark-3 37) + (board 38) + (pass-red 39) + (pass-green 40) + (pass-yellow 41) + (pass-blue 42) + (ammo-random 43) + (health-max 44) + (light-eco-crystal 45) + (dark-eco-crystal 46) + (pass-slumb-genb 47) + (ammo-light-random 48) + (ammo-dark-light-random 49) + (light-random 50) + ) +;; ---game-info-h:pickup-type + #| (deftype game-bank (basic) ((life-max-default float :offset-assert 4) @@ -11930,22 +14819,34 @@ ) |# -;; (deftype actor-id (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype actor-id (uint32) + () + :flag-assert #x900000004 + ) + +;; +++game-info-h:highscore-flags +(defenum highscore-flags + :bitfield #t + :type uint8 + (time) + (hf1 1) + (hf2 2) + (hf3 3) + (hf4 4) + (hf5 5) + (hf6 6) + (hf7 7) + ) +;; ---game-info-h:highscore-flags -#| (deftype highscore-info (structure) - ((flags uint8 :offset-assert 0) ;; highscore-flags + ((flags highscore-flags :offset-assert 0) ;; highscore-flags ) :method-count-assert 9 :size-assert #x1 :flag-assert #x900000001 ) -|# -#| (deftype level-buffer-state (structure) ((name symbol :offset-assert 0) ;; guessed by decompiler (display? symbol :offset-assert 4) ;; guessed by decompiler @@ -11954,13 +14855,12 @@ (slot int32 :offset-assert 16) (force-reload basic :offset-assert 20) ) + :allow-misaligned :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype level-buffer-state-small (structure) ((name symbol :offset-assert 0) ;; guessed by decompiler (display? symbol :offset-assert 4) ;; guessed by decompiler @@ -11969,33 +14869,24 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype level-buffer-state-split (structure) ((name basic :offset-assert 0) - (display? UNKNOWN 2 :offset-assert 4) + (display? symbol 2 :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype load-state (basic) - ((want level-buffer-state 18 :offset-assert 4) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (want-exp level-buffer-state 18 :offset-assert 580) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (want-split UNKNOWN 18 :offset-assert 1156) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (target level-buffer-state 18 :offset-assert 1372) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (want-sound sound-bank-state 7 :offset-assert 1948) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (target-sound sound-bank-state 7 :offset-assert 2060) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((want level-buffer-state 18 :inline :offset-assert 4) ;; guessed by decompiler + (want-exp level-buffer-state 18 :inline :offset-assert 580) ;; guessed by decompiler + (want-split level-buffer-state-split 18 :inline :offset-assert 1156) + (target level-buffer-state 18 :inline :offset-assert 1372) ;; guessed by decompiler + (want-sound sound-bank-state 7 :inline :offset-assert 1948) ;; guessed by decompiler + (target-sound sound-bank-state 7 :inline :offset-assert 2060) ;; guessed by decompiler (vis-nick symbol :offset-assert 2172) ;; guessed by decompiler (command-list pair :offset-assert 2176) ;; guessed by decompiler (object-name string 256 :offset-assert 2180) ;; guessed by decompiler @@ -12027,9 +14918,46 @@ (load-state-method-26 () none) ;; 26 ) ) -|# -#| +;; +++game-info-h:continue-flags +(defenum continue-flags + :type uint32 + :bitfield #t + ;(continue-flag-0 0) + (scene-wait 1) + (change-continue 2) + (no-auto 3) + (no-blackout 4) + (game-start 5) + (grab) + (warp-gate 7) + (demo 8) + (intro 9) + (hero-mode 10) + (darkjak) + (title 12) + (title-movie 13) + (continue-flag-14 14) + (copy-entity-pos 15) + (test) + (nothing-apparently 17) + (race 18) + (credits) + (indax) + (mech) + (continue-flag-22 22) + (flut 23) + (flut-racer 24) + (vehicle 25) + (vehicle-movie 26) + (indax-hang 27) + (flut-fight 28) + (htorpedo 29) + (vehicle-scorpion 30) + (lightjak 31) + ) +;; ---game-info-h:continue-flags + (deftype continue-point (basic) ((name string :offset-assert 4) ;; guessed by decompiler (level symbol :offset-assert 8) ;; guessed by decompiler @@ -12044,9 +14972,7 @@ (vehicle-type uint8 :offset-assert 100) (want-count int8 :offset-assert 101) (want (inline-array level-buffer-state-small) :offset-assert 104) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (want-sound symbol 1 :offset-assert 108) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. ) :method-count-assert 12 :size-assert #x70 @@ -12058,133 +14984,128 @@ (continue-point-method-11 () none) ;; 11 ;; (move-camera! (_type_) none) ) ) -|# -#| (deftype game-info-player (structure) - ((current-continue basic :offset-assert 0) - (last-continue basic :offset-assert 4) + ((current-continue continue-point :offset-assert 0) + (last-continue continue-point :offset-assert 4) (vehicle uint64 :offset-assert 8) (cash float :offset-assert 16) - (camera-inside-view basic :offset-assert 20) + (camera-inside-view symbol :offset-assert 20) (last-selected-vehicle uint8 :offset-assert 24) ) :method-count-assert 9 :size-assert #x19 :flag-assert #x900000019 ) -|# -#| -(deftype game-info (basic) - ((mode symbol :offset-assert 4) ;; guessed by decompiler - (save-name string :offset-assert 8) ;; guessed by decompiler - (player-info UNKNOWN 2 :offset-assert 16) - (car-info car-info-array :inline :offset-assert 80) - (features uint64 :offset-assert 1040) ;; game-feature - (debug-features uint64 :offset-assert 1048) ;; game-feature - (old-features uint64 :offset-assert 1056) ;; game-feature - (items uint64 :offset-assert 1064) ;; game-items - (debug-items uint64 :offset-assert 1072) ;; game-items - (old-items uint64 :offset-assert 1080) ;; game-items - (secrets uint64 :offset-assert 1088) ;; game-secrets - (purchase-secrets uint64 :offset-assert 1096) ;; game-secrets - (vehicles uint64 :offset-assert 1104) ;; game-vehicles - (debug-vehicles uint64 :offset-assert 1112) ;; game-vehicles - (old-vehicles uint64 :offset-assert 1120) ;; game-vehicles - (health-bar float :offset-assert 1128) - (health-bar-owner uint64 :offset-assert 1136) ;; handle - (attack-id uint32 :offset-assert 1144) - (perm-list entity-perm-array :offset-assert 1148) ;; guessed by decompiler - (task-node-commands (array game-task-node-command) :offset-assert 1164) ;; guessed by decompiler - (task-counter uint32 :offset-assert 1168) - (level-opened uint8 32 :offset-assert 1176) ;; guessed by decompiler - (total-deaths int32 :offset-assert 1208) - (continue-deaths int32 :offset-assert 1212) - (task-deaths int32 :offset-assert 1216) - (total-trys int32 :offset-assert 1220) - (game-start-time uint64 :offset-assert 1224) ;; time-frame - (continue-time uint64 :offset-assert 1232) ;; time-frame - (death-time uint64 :offset-assert 1240) ;; time-frame - (hit-time uint64 :offset-assert 1248) ;; time-frame - (task-pickup-time uint64 :offset-assert 1256) ;; time-frame - (stop-watch-start uint64 :offset-assert 1264) ;; time-frame - (stop-watch-stop uint64 :offset-assert 1272) ;; time-frame - (blackout-time uint64 :offset-assert 1280) ;; time-frame - (letterbox-time uint64 :offset-assert 1288) ;; time-frame - (hint-play-time uint64 :offset-assert 1296) ;; time-frame - (display-text-time uint64 :offset-assert 1304) ;; time-frame - (display-text-handle uint64 :offset-assert 1312) ;; handle - (death-movie-tick int32 :offset-assert 1320) - (want-auto-save symbol :offset-assert 1324) ;; guessed by decompiler - (auto-save-proc uint64 :offset-assert 1328) ;; handle - (auto-save-status mc-status-code :offset-assert 1336) ;; guessed by decompiler - (auto-save-card int32 :offset-assert 1340) - (auto-save-which int32 :offset-assert 1344) - (auto-save-count int32 :offset-assert 1348) - (pov-camera-handle uint64 :offset-assert 1352) ;; handle - (other-camera-handle uint64 :offset-assert 1360) ;; handle - (controller handle 2 :offset-assert 1368) ;; guessed by decompiler - (bot-health float 3 :offset-assert 1384) ;; guessed by decompiler - (demo-state uint32 :offset-assert 1396) - (distance float :offset-assert 1400) - (kiosk-timeout uint64 :offset-assert 1408) ;; time-frame - (pause-start-time uint64 :offset-assert 1416) ;; time-frame - (game-score (array float) :offset-assert 1424) ;; guessed by decompiler - (goal float :offset-assert 1428) - (miss float :offset-assert 1432) - (miss-max float :offset-assert 1436) - (health-bar-vehicle float :offset-assert 1440) - (pause-menu uint64 :offset-assert 1448) - (current-vehicle uint8 :offset-assert 1456) ;; vehicle-type-u8 - (collision-damage-multiplier float :offset-assert 1460) - (traction-multiplier float :offset-assert 1464) - (turbo-factor float :offset-assert 1468) - (turbo-disabled int8 :offset-assert 1472) - (turbo-last-disabled int32 :offset-assert 1476) - (fragile-vehicle basic :offset-assert 1480) - (music-data UNKNOWN 4 :offset-assert 1484) - (music-info uint32 :offset-assert 1484) - (playing-grand-prix? grand-prix :offset-assert 1496) - (grand-prix-index uint32 :offset-assert 1500) - (collision-vs-rbody-damage-multiplier float :offset-assert 1504) - (global-speed-factor float :offset-assert 1508) - (this-race-grand-prix-score UNKNOWN 23 :offset-assert 1512) - (cumulative-grand-prix-score UNKNOWN 23 :offset-assert 1604) - (driver-info uint64 :offset-assert 1696) - (driver-info2 UNKNOWN 2 :offset-assert 1696) - (driver-unlock uint32 :offset-assert 1696) - (driver-award uint32 :offset-assert 1700) - ) - :method-count-assert 31 - :size-assert #x6a8 - :flag-assert #x1f000006a8 - (:methods - (game-info-method-9 () none) ;; 9 ;; (initialize! (_type_ symbol game-save string resetter-spec) _type_) - (game-info-method-10 () none) ;; 10 ;; (give (_type_ symbol float handle) float) - (game-info-method-11 () none) ;; 11 ;; (task-complete? (_type_ game-task) symbol) - (game-info-method-12 () none) ;; 12 ;; (subtask-index-by-name (_type_ string) int) - (game-info-method-13 () none) ;; 13 ;; (actor-perm (_type_ actor-id) entity-perm) - (game-info-method-14 () none) ;; 14 ;; (task-perm-by-index (_type_ int) entity-perm) - (game-info-method-15 () none) ;; 15 ;; (copy-perms-from-level! (_type_ level) int) - (game-info-method-16 () none) ;; 16 ;; (copy-perms-to-level! (_type_ level) int) - (game-info-method-17 () none) ;; 17 ;; (debug-inspect (_type_ symbol) _type_) - (game-info-method-18 () none) ;; 18 ;; (get-current-continue-forced (_type_) continue-point) - (game-info-method-19 () none) ;; 19 ;; (get-continue-by-name (_type_ string) continue-point) - (game-info-method-20 () none) ;; 20 ;; (set-continue! (_type_ basic symbol) continue-point) - (game-info-method-21 () none) ;; 21 ;; (game-info-method-21 (_type_) none) - (game-info-method-22 () none) ;; 22 ;; (save-game (_type_ game-save string) game-save) - (game-info-method-23 () none) ;; 23 ;; (load-game (_type_ game-save) game-save) - (game-info-method-24 () none) ;; 24 ;; (you-suck-stage (_type_ symbol int) int) - (game-info-method-25 () none) ;; 25 ;; (you-suck-scale (_type_ symbol int) float) - (game-info-method-26 () none) ;; 26 ;; (get-next-attack-id! (_type_) uint) - (game-info-method-27 () none) ;; 27 ;; (game-info-method-27 (_type_ game-score float) int) - (game-info-method-28 () none) ;; 28 ;; (get-game-score-ref (_type_ int) (pointer float)) - (game-info-method-29 () none) ;; 29 ;; (game-info-method-29 (_type_ int) int) - (game-info-method-30 () none) ;; 30 ;; (get-highscore-rank (_type_ int float) int) - ) - ) -|# +;; (deftype game-info (basic) +;; ((mode symbol :offset-assert 4) ;; guessed by decompiler +;; (save-name string :offset-assert 8) ;; guessed by decompiler +;; (player-info game-info-player 2 :inline :offset-assert 16) +;; (car-info car-info-array :inline :offset-assert 80) +;; (features uint64 :offset-assert 1040) ;; game-feature +;; (debug-features uint64 :offset-assert 1048) ;; game-feature +;; (old-features uint64 :offset-assert 1056) ;; game-feature +;; (items uint64 :offset-assert 1064) ;; game-items +;; (debug-items uint64 :offset-assert 1072) ;; game-items +;; (old-items uint64 :offset-assert 1080) ;; game-items +;; (secrets uint64 :offset-assert 1088) ;; game-secrets +;; (purchase-secrets uint64 :offset-assert 1096) ;; game-secrets +;; (vehicles uint64 :offset-assert 1104) ;; game-vehicles +;; (debug-vehicles uint64 :offset-assert 1112) ;; game-vehicles +;; (old-vehicles uint64 :offset-assert 1120) ;; game-vehicles +;; (health-bar float :offset-assert 1128) +;; (health-bar-owner uint64 :offset-assert 1136) ;; handle +;; (attack-id uint32 :offset-assert 1144) +;; (perm-list entity-perm-array :offset-assert 1148) ;; guessed by decompiler +;; (task-node-commands (array game-task-node-command) :offset-assert 1164) ;; guessed by decompiler +;; (task-counter uint32 :offset-assert 1168) +;; (level-opened uint8 32 :offset-assert 1176) ;; guessed by decompiler +;; (total-deaths int32 :offset-assert 1208) +;; (continue-deaths int32 :offset-assert 1212) +;; (task-deaths int32 :offset-assert 1216) +;; (total-trys int32 :offset-assert 1220) +;; (game-start-time uint64 :offset-assert 1224) ;; time-frame +;; (continue-time uint64 :offset-assert 1232) ;; time-frame +;; (death-time uint64 :offset-assert 1240) ;; time-frame +;; (hit-time uint64 :offset-assert 1248) ;; time-frame +;; (task-pickup-time uint64 :offset-assert 1256) ;; time-frame +;; (stop-watch-start uint64 :offset-assert 1264) ;; time-frame +;; (stop-watch-stop uint64 :offset-assert 1272) ;; time-frame +;; (blackout-time uint64 :offset-assert 1280) ;; time-frame +;; (letterbox-time uint64 :offset-assert 1288) ;; time-frame +;; (hint-play-time uint64 :offset-assert 1296) ;; time-frame +;; (display-text-time uint64 :offset-assert 1304) ;; time-frame +;; (display-text-handle uint64 :offset-assert 1312) ;; handle +;; (death-movie-tick int32 :offset-assert 1320) +;; (want-auto-save symbol :offset-assert 1324) ;; guessed by decompiler +;; (auto-save-proc uint64 :offset-assert 1328) ;; handle +;; (auto-save-status mc-status-code :offset-assert 1336) ;; guessed by decompiler +;; (auto-save-card int32 :offset-assert 1340) +;; (auto-save-which int32 :offset-assert 1344) +;; (auto-save-count int32 :offset-assert 1348) +;; (pov-camera-handle uint64 :offset-assert 1352) ;; handle +;; (other-camera-handle uint64 :offset-assert 1360) ;; handle +;; (controller handle 2 :offset-assert 1368) ;; guessed by decompiler +;; (bot-health float 3 :offset-assert 1384) ;; guessed by decompiler +;; (demo-state uint32 :offset-assert 1396) +;; (distance float :offset-assert 1400) +;; (kiosk-timeout uint64 :offset-assert 1408) ;; time-frame +;; (pause-start-time uint64 :offset-assert 1416) ;; time-frame +;; (game-score (array float) :offset-assert 1424) ;; guessed by decompiler +;; (goal float :offset-assert 1428) +;; (miss float :offset-assert 1432) +;; (miss-max float :offset-assert 1436) +;; (health-bar-vehicle float :offset-assert 1440) +;; (pause-menu uint64 :offset-assert 1448) +;; (current-vehicle uint8 :offset-assert 1456) ;; vehicle-type-u8 +;; (collision-damage-multiplier float :offset-assert 1460) +;; (traction-multiplier float :offset-assert 1464) +;; (turbo-factor float :offset-assert 1468) +;; (turbo-disabled int8 :offset-assert 1472) +;; (turbo-last-disabled int32 :offset-assert 1476) +;; (fragile-vehicle basic :offset-assert 1480) +;; (music-data uint32 4 :offset-assert 1484) +;; (music-info uint32 :offset 1484) +;; (playing-grand-prix? grand-prix :offset-assert 1496) +;; (grand-prix-index uint32 :offset-assert 1500) +;; (collision-vs-rbody-damage-multiplier float :offset-assert 1504) +;; (global-speed-factor float :offset-assert 1508) +;; (this-race-grand-prix-score uint32 23 :offset-assert 1512) +;; (cumulative-grand-prix-score uint32 23 :offset-assert 1604) +;; (driver-info uint64 :offset-assert 1696) +;; (driver-info2 uint64 2 :offset 1696) +;; (driver-unlock uint32 :offset 1696) +;; (driver-award uint32 :offset 1700) +;; ) +;; :method-count-assert 31 +;; :size-assert #x6a8 +;; :flag-assert #x1f000006a8 +;; (:methods +;; (game-info-method-9 () none) ;; 9 ;; (initialize! (_type_ symbol game-save string resetter-spec) _type_) +;; (game-info-method-10 () none) ;; 10 ;; (give (_type_ symbol float handle) float) +;; (game-info-method-11 () none) ;; 11 ;; (task-complete? (_type_ game-task) symbol) +;; (game-info-method-12 () none) ;; 12 ;; (subtask-index-by-name (_type_ string) int) +;; (game-info-method-13 () none) ;; 13 ;; (actor-perm (_type_ actor-id) entity-perm) +;; (game-info-method-14 () none) ;; 14 ;; (task-perm-by-index (_type_ int) entity-perm) +;; (game-info-method-15 () none) ;; 15 ;; (copy-perms-from-level! (_type_ level) int) +;; (game-info-method-16 () none) ;; 16 ;; (copy-perms-to-level! (_type_ level) int) +;; (game-info-method-17 () none) ;; 17 ;; (debug-inspect (_type_ symbol) _type_) +;; (game-info-method-18 () none) ;; 18 ;; (get-current-continue-forced (_type_) continue-point) +;; (game-info-method-19 () none) ;; 19 ;; (get-continue-by-name (_type_ string) continue-point) +;; (game-info-method-20 () none) ;; 20 ;; (set-continue! (_type_ basic symbol) continue-point) +;; (game-info-method-21 () none) ;; 21 ;; (game-info-method-21 (_type_) none) +;; (game-info-method-22 () none) ;; 22 ;; (save-game (_type_ game-save string) game-save) +;; (game-info-method-23 () none) ;; 23 ;; (load-game (_type_ game-save) game-save) +;; (game-info-method-24 () none) ;; 24 ;; (you-suck-stage (_type_ symbol int) int) +;; (game-info-method-25 () none) ;; 25 ;; (you-suck-scale (_type_ symbol int) float) +;; (game-info-method-26 () none) ;; 26 ;; (get-next-attack-id! (_type_) uint) +;; (game-info-method-27 () none) ;; 27 ;; (game-info-method-27 (_type_ game-score float) int) +;; (game-info-method-28 () none) ;; 28 ;; (get-game-score-ref (_type_ int) (pointer float)) +;; (game-info-method-29 () none) ;; 29 ;; (game-info-method-29 (_type_ int) int) +;; (game-info-method-30 () none) ;; 30 ;; (get-highscore-rank (_type_ int float) int) +;; ) +;; ) ;; (define-extern *GAME-bank* game-bank) ;; game-bank ;; (define-extern *static-continues* array) @@ -12203,31 +15124,140 @@ ;; gui-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++gui-h:gui-action +(defenum gui-action + :type uint8 + :bitfield #f + (none 0) + (queue 1) + (play 2) + (playing 3) + (stop 4) + (stopping 5) + (abort 6) + (hide 7) + (hidden 8) + (fade 9) + ) +;; ---gui-h:gui-action + +;; +++gui-h:gui-status +(defenum gui-status + :type uint8 ;; not sure + :bitfield #f + (unknown 0) + (pending 1) + (ready 2) + (active 3) + (hide 4) + (stop 5) + ) +;; ---gui-h:gui-status + +;; +++gui-h:gui-channel +(defenum gui-channel + :type uint8 + :bitfield #f + (none 0) + (art-load 16) + (art-load-next 17) + (background 18) + (jak 19) + (daxter 20) + (sig 21) + (ashelin 22) + (beast 23) + (jak-effect-1 24) + (pecker 25) + (jak-effect-2 26) + (gun 27) + (hal 28) + (speech 29) + (guard 30) + (jak-mode 31) + (alert 32) + (citizen 33) + (bbush 34) + (rider 35) + (task 36) + (voice 47) + (movie 64) + (blackout 65) + (query 66) + (message 67) + (notice 68) + (subtitle 69) + (supertitle 70) + (notice-low 71) + (resetter 72) + (progress 73) + (freeze 74) + (subtitle-pc 78) ;; custom + (screen 79) + (hud-upper-right 80) + (hud-upper-left 81) + (hud-lower-right 82) + (hud-lower-left 83) + (hud-lower-left-1 84) + (hud-lower-left-2 85) + (hud-center-right 86) + (hud-center-left 87) + (hud-middle-right 88) + (hud-middle-left 89) + (hud-upper-center 90) + (hud-upper-center-2 91) + (hud-lower-center 92) + (hud-auto-save 93) + (hud-auto-save-message 94) + (hud 95) + (hud-mp-vehicle-main-0 96) + (hud-mp-vehicle-main-1 97) + (hud-mp-player-indicators-0 98) + (hud-mp-player-indicators-1 99) + (hud-mp-race-0 100) + (hud-mp-race-1 101) + (hud-mp-race-2 102) + (hud-mp-race-3 103) + (max 112) + ) +;; ---gui-h:gui-channel + +;; +++gui-h:gui-connection-flags +(defenum gui-connection-flags + :type uint8 + :bitfield #t + (gcf0 0) + (gcf1 1) + (fo-curve 2) + (fo-min 3) + (fo-max 4) + (volume 5) + ) +;; ---gui-h:gui-connection-flags + (deftype gui-connection (connection) - ((priority float :offset-assert 16) - (action uint8 :offset-assert 20) ;; gui-action - (channel uint8 :offset-assert 21) ;; gui-channel - (anim-part uint8 :offset-assert 22) - (flags uint8 :offset-assert 23) ;; gui-connection-flags - (name string :offset-assert 24) ;; guessed by decompiler - (id sound-id :offset-assert 28) ;; guessed by decompiler - (handle uint64 :offset-assert 0) ;; handle - (time-stamp uint64 :offset-assert 8) ;; time-frame - (hold-time uint64 :offset-assert 32) ;; time-frame + ((priority float :offset 16 :score 1) + (action gui-action :offset 20) ;; gui-action + (channel gui-channel :offset 21) ;; gui-channel + (anim-part uint8 :offset 22) + (flags gui-connection-flags :offset 23) ;; gui-connection-flags + (name string :offset 24) ;; guessed by decompiler + (id sound-id :offset 28) ;; guessed by decompiler + (handle handle :offset 0) ;; handle + (time-stamp time-frame :offset 8) ;; time-frame + (hold-time time-frame :offset-assert 32) ;; time-frame (fo-min float :offset-assert 40) ;; int16 (fo-max float :offset-assert 44) ;; int16 (fo-power float :offset-assert 48) (fade uint8 :offset-assert 52) (volume float :offset-assert 56) ;; int16 - (qw-pad UNKNOWN 4 :offset-assert 60) + (qw-pad int8 4 :offset-assert 60) ) :method-count-assert 14 :size-assert #x40 :flag-assert #xe00000040 ;; field param1 uses ~A with a signed load. field param2 uses ~A with a signed load. field param3 uses ~A with a signed load. ) -|# ;; (deftype gui-control (basic) ;; () @@ -12239,43 +15269,63 @@ ;; ambient-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++ambient-h:talker-flags +(defenum talker-flags + :type uint16 + :bitfield #t + (play-only-once 0) + (reduce-volume 1) + (auto-save-on-each-start 2) + (auto-save-once-on-exit 3) + (only-play-in-region 4) + (fade-in 5) + (slide-in 6) + (bigger-font 7) + (long-timeout 8) + ) +;; ---ambient-h:talker-flags + (deftype talker-speech-class (structure) - ((name string :offset-assert 0) ;; guessed by decompiler - (channel uint8 :offset-assert 4) ;; gui-channel - (flags uint16 :offset-assert 6) ;; talker-flags - (speech uint16 :offset-assert 8) - (text-duration uint16 :offset-assert 10) - (delay uint16 :offset-assert 12) - (pos uint16 :offset-assert 14) - (neg uint16 :offset-assert 16) - (text-message text-id :offset-assert 20) ;; guessed by decompiler - (on-close pair :offset-assert 24) ;; guessed by decompiler - (camera string :offset-assert 28) ;; guessed by decompiler + "Contains metadata about a voice line or hint text being played/displayed. + In the talker state, there's a pos-state and neg-state. + Calling yes-play! adjusts the pos-state and no-play! adjusts the neg-state. + Playback is only allowed if the pos-state is less than or equal to pos + and neg-state is greater than or equal to neg. + " + ((name string :offset-assert 0) + (channel gui-channel :offset-assert 4) + (flags talker-flags :offset-assert 6) + (speech uint16 :offset-assert 8) + (text-duration uint16 :offset-assert 10 :decomp-as time-frame) + (delay uint16 :offset-assert 12 :decomp-as time-frame) + (pos uint16 :offset-assert 14) + (neg uint16 :offset-assert 16) + (text-message text-id :offset-assert 20) + (on-close pair :offset-assert 24) + (camera string :offset-assert 28) ) + :pack-me :method-count-assert 14 :size-assert #x20 :flag-assert #xe00000020 ;; field on-close uses ~A with a signed load. (:methods - (talker-speech-class-method-9 () none) ;; 9 ;; (should-play? (_type_) symbol) - (talker-speech-class-method-10 () none) ;; 10 ;; (mark-played! (_type_) none) - (talker-speech-class-method-11 () none) ;; 11 ;; (reset-state! (_type_) none) - (talker-speech-class-method-12 () none) ;; 12 ;; (yes-play! (_type_ int) none) - (talker-speech-class-method-13 () none) ;; 13 ;; (no-play! (_type_ int) none) + (should-play? "Return if the talker is in a state where it should play." (_type_) symbol) ;; 9 + (mark-played! "Mark something as played by making its state UINT16_MAX" (_type_) none) ;; 10 + (reset-state! "Reset the state of this talker to 0 (the initial value)" (_type_) none) ;; 11 + (yes-play! (_type_ int) none) ;; 12 + (no-play! (_type_ int) none) ;; 13 ) ) -|# -#| (deftype talker (process) ((trans vector :inline :offset-assert 144) (message talker-speech-class :offset-assert 160) - (total-time uint64 :offset-assert 168) ;; time-frame - (total-off-time uint64 :offset-assert 176) ;; time-frame - (start-time uint64 :offset-assert 184) ;; time-frame - (state-time uint64 :offset-assert 192) ;; time-frame - (voicebox uint64 :offset-assert 200) ;; handle + (total-time time-frame :offset-assert 168) ;; time-frame + (total-off-time time-frame :offset-assert 176) ;; time-frame + (start-time time-frame :offset-assert 184) ;; time-frame + (state-time time-frame :offset-assert 192) ;; time-frame + (voicebox handle :offset-assert 200) ;; handle (voice-id sound-id :offset-assert 208) ;; guessed by decompiler (message-id sound-id :offset-assert 212) ;; guessed by decompiler (region region :offset-assert 216) @@ -12286,42 +15336,51 @@ :method-count-assert 19 :size-assert #xe8 :flag-assert #x13006000e8 + (:state-methods + idle ;; 14 + active ;; 15 + exit ;; 16 + ) (:methods - (talker-method-9 () none) ;; 9 - (talker-method-10 () none) ;; 10 - (talker-method-11 () none) ;; 11 - (talker-method-12 () none) ;; 12 - (talker-method-13 () none) ;; 13 - (talker-method-14 () none) ;; 14 ;; (idle () _type_ :state) - (talker-method-15 () none) ;; 15 ;; (active () _type_ :state) - (talker-method-16 () none) ;; 16 ;; (exit () _type_ :state) - (talker-method-17 () none) ;; 17 ;; (draw-text (_type_) none) - (talker-method-18 () none) ;; 18 + (draw-text (_type_) none) ;; 17 ) ) -|# -;; (define-extern *talker-speech* object) ;; (inline-array talker-speech-class) +(define-extern *talker-speech* (inline-array talker-speech-class)) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; speech-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++speech-h:speech-info-flag +(defenum speech-info-flag + :type uint64 + :bitfield #t + (si0 0) + (si1 1) + (si2 2) + (si3 3) + (si4 4) + (si5 5) + (si6 6) + (si7 7) + (si8 8) + ) +;; ---speech-h:speech-info-flag + (deftype speech-info-item (structure) ((name basic :offset-assert 0) - (flags uint64 :offset-assert 8) + (flags speech-info-flag :offset-assert 8) ) + :pack-me :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype speech-info (structure) ((list basic :offset-assert 0) - (flags uint64 :offset-assert 8) ;; speech-info-flag + (flags speech-info-flag :offset-assert 8) ;; speech-info-flag ) :method-count-assert 13 :size-assert #x10 @@ -12333,15 +15392,80 @@ (speech-info-method-12 () none) ;; 12 ) ) -|# -#| +;; +++speech-h:speech-type +(defenum speech-type + :type uint8 + (none 0) + (guard-generic-battle 1) + (guard-generic-battle-b 2) + (guard-battle-victory 3) + (guard-battle-victory-b 4) + (guard-change-targets 5) + (guard-change-targets-b 6) + (guard-go-hostile 7) + (guard-go-hostile-b 8) + (guard-hit 9) + (guard-hit-b 10) + (guard-witness-death 11) + (guard-witness-death-b 12) + (guard-chatter 13) + (guard-chatter-b 14) + (guard-chatter-jak 15) + (guard-chatter-jak-b 16) + (guard-bumped-by-jak 17) + (guard-bumped-by-jak-b 18) + (civ-m-ambient 19) + (civ-m-alert 20) + (civ-m-cower 21) + (civ-m-touched-by-player 22) + (civ-m-shot-by-player 23) + (civ-m-avoiding-player-vehicle 24) + (civ-m-hit-by-player-vehicle 25) + (civ-m-player-stealing-vehicle 26) + (civ-f-ambient 27) + (civ-f-alert 28) + (civ-f-cower 29) + (civ-f-touched-by-player 30) + (civ-f-shot-by-player 31) + (civ-f-avoiding-player-vehicle 32) + (civ-f-hit-by-player-vehicle 33) + (race-jak-start 34) + (race-jak-lap 35) + (race-jak-last-lap 36) + (race-jak-hit 37) + (race-jak-got-hit 38) + (race-jak-ambient 39) + (race-jak-pass 40) + (race-jak-jump 41) + (race-jak-win 42) + (race-daxter-start 43) + (race-daxter-lap 44) + (race-daxter-last-lap 45) + (race-daxter-hit 46) + (race-daxter-got-hit 47) + (race-daxter-ambient 48) + (race-daxter-pass 49) + (race-daxter-jump 50) + (race-daxter-win 51) + (race-errol-start 52) + (race-errol-last-lap 53) + (race-errrol-hit 54) + (race-errol-got-hit 55) + (race-errol-ambient 56) + (race-errol-pass 57) + (race-errol-got-passed 58) + (race-errol-win 59) + (race-errol-lose 60) + ) +;; ---speech-h:speech-type + (deftype speech-request (structure) - ((handle uint64 :offset-assert 0) ;; handle - (req-time uint64 :offset-assert 8) - (start-time uint64 :offset-assert 16) + ((handle handle :offset-assert 0) ;; handle + (req-time time-frame :offset-assert 8) + (start-time time-frame :offset-assert 16) (name basic :offset-assert 24) - (speech-type uint8 :offset-assert 28) ;; speech-type + (speech-type speech-type :offset-assert 28) ;; speech-type (flags uint8 :offset-assert 29) (max-delay uint64 :offset-assert 32) ) @@ -12349,18 +15473,24 @@ :size-assert #x28 :flag-assert #x900000028 ) -|# -#| +;; +++speech-h:speech-channel-flag +(defenum speech-channel-flag + :type uint8 + :bitfield #t + (disable 0) + ) +;; ---speech-h:speech-channel-flag + (deftype speech-channel (structure) ((flags speech-channel-flag :offset-assert 0) - (gui-channel uint8 :offset-assert 1) ;; gui-channel + (gui-channel gui-channel :offset-assert 1) ;; gui-channel (delay uint16 :offset-assert 2) (id sound-id :offset-assert 4) ;; guessed by decompiler (time uint64 :offset-assert 8) (current-request speech-request :offset-assert 16) (requests basic :offset-assert 20) - (speeches UNKNOWN 31 :offset-assert 24) + (speeches speech-info-item 31 :offset-assert 24) ) :method-count-assert 17 :size-assert #x94 @@ -12377,11 +15507,9 @@ (speech-channel-method-16 () none) ;; 16 ) ) -|# -#| (deftype speech-control (structure) - ((channels UNKNOWN 22 :offset-assert 0) + ((channels speech-channel 22 :inline :offset-assert 0) ) :method-count-assert 17 :size-assert #xdc0 @@ -12397,31 +15525,27 @@ (speech-control-method-16 () none) ;; 16 ;; (speech-control-method-16 (_type_) none) ) ) -|# -;; (define-extern *music-volume-during-speech* object) -;; (define-extern *sfx-volume-during-speech* object) -;; (define-extern pecker-can-speak? function) +(define-extern *music-volume-during-speech* float) +(define-extern *sfx-volume-during-speech* float) +(define-extern pecker-can-speak? (function symbol)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; wind-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype wind-vector (structure) ((wind-pos vector4w :inline :offset-assert 0) (wind-vel vector4w :inline :offset-assert 16) - (stiffness float :offset-assert 28) + (stiffness float :offset 28) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype wind-work (basic) - ((wind-array vector 64 :offset-assert 16) ;; guessed by decompiler + ((wind-array vector 64 :inline :offset-assert 16) ;; guessed by decompiler (wind-normal vector :inline :offset-assert 1040) (wind-temp vector :inline :offset-assert 1056) (wind-force float 64 :offset-assert 1072) ;; guessed by decompiler @@ -12446,80 +15570,84 @@ :size-assert #x584 :flag-assert #x900000584 ) -|# -#| (deftype wind-dma (structure) - ((buffer0 wind-vector 128 :offset-assert 0) ;; guessed by decompiler - (buffer1 wind-vector 128 :offset-assert 4096) ;; guessed by decompiler - (buffer2 wind-vector 128 :offset-assert 8192) ;; guessed by decompiler + ((buffer0 wind-vector 128 :inline :offset-assert 0) ;; guessed by decompiler + (buffer1 wind-vector 128 :inline :offset-assert 4096) ;; guessed by decompiler + (buffer2 wind-vector 128 :inline :offset-assert 8192) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x3000 :flag-assert #x900003000 ) -|# -;; (define-extern *wind-scales* array) ;; (array uint8) +(define-extern *wind-scales* (array uint8)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; prototype-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++prototype-h:prototype-flags +(defenum prototype-flags + :bitfield #t + :type uint16 + (disable 0) ;; set from debug menu, for debugging + (tpage-alpha 2) + (vanish 3) + (visible 5) ;; set by prototypes-game-visible-set! to hide things on purpose + (no-collide 6) + (tpage-water 7) + ) +;; ---prototype-h:prototype-flags + (deftype prototype-bucket (basic) ((name string :offset-assert 4) ;; guessed by decompiler - (flags uint16 :offset-assert 8) ;; prototype-flags + (flags prototype-flags :offset-assert 8) ;; prototype-flags (texture-masks-index uint16 :offset-assert 10) (in-level uint16 :offset-assert 12) (utextures uint16 :offset-assert 14) - (wide-level-index uint16 :offset-assert 14) (geometry drawable 4 :offset-assert 16) ;; guessed by decompiler (dists vector :inline :offset-assert 32) (rdists vector :inline :offset-assert 48) - (near-plane meters :offset-assert 32) - (near-stiff meters :offset-assert 36) - (mid-plane meters :offset-assert 40) - (far-plane meters :offset-assert 44) - (rlength-near float :offset-assert 48) - (rlength-stiff float :offset-assert 52) - (rlength-mid float :offset-assert 56) - (stiffness float :offset-assert 60) + (near-plane meters :offset 32) + (near-stiff meters :offset 36) + (mid-plane meters :offset 40) + (far-plane meters :offset 44) + (rlength-near float :offset 48) + (rlength-stiff float :offset 52) + (rlength-mid float :offset 56) + (stiffness float :offset 60) ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype prototype-bucket-shrub (prototype-bucket) ((next uint32 4 :offset-assert 64) ;; guessed by decompiler (count uint16 4 :offset-assert 80) ;; guessed by decompiler - (mod-count uint16 4 :offset-assert 88) ;; guessed by decompiler + (count-quad uint128 :offset 80) + (mod-count uint16 4 :offset 88) ;; guessed by decompiler (last dma-packet 4 :offset-assert 96) ;; guessed by decompiler - (next-clear uint128 :offset-assert 64) - (count-clear uint64 :offset-assert 80) - (last-clear uint128 :offset-assert 96) + (next-clear uint128 :offset 64) + (count-clear uint64 :offset 80) + (last-clear uint128 :offset 96) ) :method-count-assert 9 :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype prototype-inline-array-shrub (drawable) - ((length int16 :offset-assert 6) - (data prototype-bucket-shrub 1 :offset-assert 36) ;; guessed by decompiler + ((length int16 :offset 6) + (data prototype-bucket-shrub 1 :inline :offset 32) ;; guessed by decompiler + (pad uint32) ) :method-count-assert 17 :size-assert #x94 :flag-assert #x1100000094 ) -|# -#| (deftype prototype-array-shrub-info (basic) ((prototype-inline-array-shrub prototype-inline-array-shrub :offset-assert 4) ;; guessed by decompiler (wind-vectors uint32 :offset-assert 8) @@ -12529,9 +15657,10 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| +(declare-type prototype-tie drawable) +(declare-type collide-hash-fragment-array basic) + (deftype prototype-bucket-tie (prototype-bucket) ((next uint32 12 :offset-assert 64) ;; guessed by decompiler (count uint16 12 :offset-assert 112) ;; guessed by decompiler @@ -12548,94 +15677,89 @@ (tie-colors time-of-day-palette :offset-assert 180) ;; guessed by decompiler (data uint32 :dynamic :offset-assert 184) ;; guessed by decompiler (color-index-qwc uint32 :dynamic :offset-assert 184) ;; guessed by decompiler - (scissor-frag-count uint8 :offset-assert 136) - (near-frag-count uint8 :offset-assert 137) - (mid-frag-count uint8 :offset-assert 138) - (far-frag-count uint8 :offset-assert 139) - (scissor-index-start uint8 :offset-assert 140) - (near-index-start uint8 :offset-assert 141) - (mid-index-start uint8 :offset-assert 142) - (far-index-start uint8 :offset-assert 143) - (scissor-base-qw uint16 :offset-assert 144) - (near-base-qw uint16 :offset-assert 146) - (mid-base-qw uint16 :offset-assert 148) - (far-base-qw uint16 :offset-assert 150) - (tie-next uint32 4 :offset-assert 64) ;; guessed by decompiler - (tie-scissor-next uint32 :offset-assert 64) - (tie-near-next uint32 :offset-assert 68) - (tie-mid-next uint32 :offset-assert 72) - (tie-far-next uint32 :offset-assert 76) - (trans-next uint32 4 :offset-assert 64) ;; guessed by decompiler - (trans-scissor-next uint32 4 :offset-assert 64) ;; guessed by decompiler - (trans-near-next uint32 :offset-assert 68) - (trans-mid-next uint32 :offset-assert 72) - (trans-far-next uint32 :offset-assert 76) - (water-next uint32 4 :offset-assert 64) ;; guessed by decompiler - (water-scissor-next uint32 4 :offset-assert 64) ;; guessed by decompiler - (water-near-next uint32 :offset-assert 68) - (water-mid-next uint32 :offset-assert 72) - (water-far-next uint32 :offset-assert 76) - (envmap-next uint32 4 :offset-assert 80) ;; guessed by decompiler - (envmap-scissor-next uint32 4 :offset-assert 80) ;; guessed by decompiler - (envmap-near-next uint32 :offset-assert 84) - (envmap-mid-next uint32 :offset-assert 88) - (envmap-far-next uint32 :offset-assert 92) - (generic-next uint32 3 :offset-assert 96) ;; guessed by decompiler - (generic-near-next uint32 :offset-assert 96) - (generic-mid-next uint32 :offset-assert 100) - (generic-far-next uint32 :offset-assert 104) - (vanish-next uint32 :offset-assert 108) - (tie-count uint16 4 :offset-assert 112) ;; guessed by decompiler - (tie-scissor-count uint16 :offset-assert 112) - (tie-near-count uint16 :offset-assert 114) - (tie-mid-count uint16 :offset-assert 116) - (tie-far-count uint16 :offset-assert 118) - (trans-count uint16 4 :offset-assert 112) ;; guessed by decompiler - (trans-scissor-count uint16 :offset-assert 112) - (trans-near-count uint16 :offset-assert 114) - (trans-mid-count uint16 :offset-assert 116) - (trans-far-count uint16 :offset-assert 118) - (water-count uint16 4 :offset-assert 112) ;; guessed by decompiler - (water-scissor-count uint16 :offset-assert 112) - (water-near-count uint16 :offset-assert 114) - (water-mid-count uint16 :offset-assert 116) - (water-far-count uint16 :offset-assert 118) - (envmap-count uint16 4 :offset-assert 120) ;; guessed by decompiler - (envmap-scissor-count uint16 :offset-assert 120) - (envmap-near-count uint16 :offset-assert 122) - (envmap-mid-count uint16 :offset-assert 124) - (envmap-far-count uint16 :offset-assert 126) - (generic-count uint16 3 :offset-assert 128) ;; guessed by decompiler - (generic-near-count uint16 :offset-assert 128) - (generic-mid-count uint16 :offset-assert 130) - (generic-far-count uint16 :offset-assert 132) - (vanish-count uint16 :offset-assert 134) - (next-clear uint128 3 :offset-assert 64) ;; guessed by decompiler - (count-clear uint64 3 :offset-assert 112) ;; guessed by decompiler + (scissor-frag-count uint8 :offset 136) + (near-frag-count uint8 :offset 137) + (mid-frag-count uint8 :offset 138) + (far-frag-count uint8 :offset 139) + (scissor-index-start uint8 :offset 140) + (near-index-start uint8 :offset 141) + (mid-index-start uint8 :offset 142) + (far-index-start uint8 :offset 143) + (scissor-base-qw uint16 :offset 144) + (near-base-qw uint16 :offset 146) + (mid-base-qw uint16 :offset 148) + (far-base-qw uint16 :offset 150) + (tie-next uint32 4 :offset 64) ;; guessed by decompiler + (tie-scissor-next uint32 :offset 64) + (tie-near-next uint32 :offset 68) + (tie-mid-next uint32 :offset 72) + (tie-far-next uint32 :offset 76) + (trans-next uint32 4 :offset 64) ;; guessed by decompiler + (trans-scissor-next uint32 4 :offset 64) ;; guessed by decompiler + (trans-near-next uint32 :offset 68) + (trans-mid-next uint32 :offset 72) + (trans-far-next uint32 :offset 76) + (water-next uint32 4 :offset 64) ;; guessed by decompiler + (water-scissor-next uint32 4 :offset 64) ;; guessed by decompiler + (water-near-next uint32 :offset 68) + (water-mid-next uint32 :offset 72) + (water-far-next uint32 :offset 76) + (envmap-next uint32 4 :offset 80) ;; guessed by decompiler + (envmap-scissor-next uint32 4 :offset 80) ;; guessed by decompiler + (envmap-near-next uint32 :offset 84) + (envmap-mid-next uint32 :offset 88) + (envmap-far-next uint32 :offset 92) + (generic-next uint32 3 :offset 96) ;; guessed by decompiler + (generic-near-next uint32 :offset 96) + (generic-mid-next uint32 :offset 100) + (generic-far-next uint32 :offset 104) + (vanish-next uint32 :offset 108) + (tie-count uint16 4 :offset 112) ;; guessed by decompiler + (tie-scissor-count uint16 :offset 112) + (tie-near-count uint16 :offset 114) + (tie-mid-count uint16 :offset 116) + (tie-far-count uint16 :offset 118) + (trans-count uint16 4 :offset 112) ;; guessed by decompiler + (trans-scissor-count uint16 :offset 112) + (trans-near-count uint16 :offset 114) + (trans-mid-count uint16 :offset 116) + (trans-far-count uint16 :offset 118) + (water-count uint16 4 :offset 112) ;; guessed by decompiler + (water-scissor-count uint16 :offset 112) + (water-near-count uint16 :offset 114) + (water-mid-count uint16 :offset 116) + (water-far-count uint16 :offset 118) + (envmap-count uint16 4 :offset 120) ;; guessed by decompiler + (envmap-scissor-count uint16 :offset 120) + (envmap-near-count uint16 :offset 122) + (envmap-mid-count uint16 :offset 124) + (envmap-far-count uint16 :offset 126) + (generic-count uint16 3 :offset 128) ;; guessed by decompiler + (generic-near-count uint16 :offset 128) + (generic-mid-count uint16 :offset 130) + (generic-far-count uint16 :offset 132) + (vanish-count uint16 :offset 134) + (next-clear uint128 3 :offset 64) ;; guessed by decompiler + (count-clear uint64 3 :offset 112) ;; guessed by decompiler + ;; added + (tie-geom prototype-tie 4 :offset 16 :score 1) ) :method-count-assert 9 :size-assert #xb8 :flag-assert #x9000000b8 ) -|# -#| (deftype prototype-array-tie (array) - ((type type :offset-assert 0) ;; guessed by decompiler - (length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (content-type type :offset-assert 12) ;; guessed by decompiler + ((array-data prototype-bucket-tie :dynamic :offset 16) ;; NOTE - field added, not 100% positive on the type ) :method-count-assert 10 :size-assert #x10 :flag-assert #xa00000010 (:methods - (prototype-array-tie-method-9 () none) ;; 9 ;; (prototype-array-tie-method-9 () none) + (prototype-array-tie-method-9 () none) ;; 9 ;; (login (_type_) none) ) ) -|# -#| (deftype proxy-prototype-array-tie (basic) ((prototype-array-tie prototype-array-tie :offset-assert 4) ;; guessed by decompiler (wind-vectors uint32 :offset-assert 8) @@ -12646,9 +15770,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype prototype-node (structure) ((prototype basic :offset-assert 0) (level basic :offset-assert 4) @@ -12661,14 +15783,12 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype prototype-node-group (basic) ((next-prototype int16 :offset-assert 4) (next-free int16 :offset-assert 6) - (next-child-prototype UNKNOWN 19 :offset-assert 8) - (data UNKNOWN 512 :offset-assert 48) + (next-child-prototype int16 19 :offset-assert 8) + (data prototype-node 512 :inline :offset-assert 48) ) :method-count-assert 15 :size-assert #x2030 @@ -12682,39 +15802,79 @@ (prototype-node-group-method-14 () none) ;; 14 ) ) -|# -#| +;; +++prototype-h:instance-flags +(defenum instance-flags + :type uint16 + :bitfield #t + (no-collide 0) + ) +;; ---prototype-h:instance-flags + (deftype instance (drawable) - ((bucket-index uint16 :offset-assert 6) + ((bucket-index uint16 :offset 6) (origin matrix4h :inline :offset-assert 32) - (flags uint16 :offset-assert 46) ;; instance-flags - (wind-index uint16 :offset-assert 62) + (flags instance-flags :offset 46) ;; instance-flags + (wind-index uint16 :offset 62) ) :method-count-assert 17 :size-assert #x40 :flag-assert #x1100000040 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; joint-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++joint-h:joint-control-command +(defenum joint-control-command + :type uint64 + (push 1) + (blend 2) + (four 4) + (eight 8) + (push1 19) + (jcc32 32) + (stack 36) + (float 42) + (stack1 52) + ) +;; ---joint-h:joint-control-command + +;; +++joint-h:joint-control-status +(defenum joint-control-status + :type uint16 + :bitfield #t + + (sync-math 0) ;; 1 + (spooling 1) ;; 2 + (spooling-not-last-block 2) ;; 4 + (blend-shape 3) ;; 8 + (math-when-off-screen 4) ;; 16 + (valid-spooled-frame 5) ;; 32 + (blend-shape-valid 6) ;; 64 + (eye-anim-valid 7) ;; 128 + (eye-anim 8) ;; 256 + (force-math 9) + (no-joint-callbacks 10) + ) +;; ---joint-h:joint-control-status + +(declare-type effect-control basic) + (deftype joint-control-channel (structure) + "A single animation channel that controls a number of joints. + Multiple channels are used to blend animations together." ((parent joint-control :offset-assert 0) ;; guessed by decompiler (frame-group art-joint-anim :offset-assert 4) ;; guessed by decompiler (frame-num float :offset-assert 8) (dist meters :offset-assert 12) (num-func (function joint-control-channel float float float float) :offset-assert 16) ;; guessed by decompiler (param float 3 :offset-assert 20) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (frame-interp float 2 :offset-assert 32) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (inspector-amount uint8 :offset-assert 40) - (command uint64 :offset-assert 48) ;; joint-control-command + (command joint-control-command :offset-assert 48) ;; joint-control-command (group-sub-index int8 :offset-assert 56) (group-size int8 :offset-assert 57) (eval-time uint32 :offset-assert 60) @@ -12723,9 +15883,7 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype top-anim-joint-control (basic) ((process (pointer process-drawable) :offset-assert 4) ;; guessed by decompiler (interp-select uint64 2 :offset-assert 8) ;; guessed by decompiler @@ -12743,29 +15901,28 @@ (frame-start float :offset-assert 68) (frame-post-blend float :offset-assert 72) (frame-post-end float :offset-assert 76) - (frame-push-time uint64 :offset-assert 80) ;; time-frame + (frame-push-time time-frame :offset-assert 80) ;; (frame-post-put-away basic :offset-assert 88) - (update-time uint64 :offset-assert 96) ;; time-frame + (update-time time-frame :offset-assert 96) ;; time-frame ) :method-count-assert 13 :size-assert #x68 :flag-assert #xd00000068 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable) _type_) - (top-anim-joint-control-method-9 () none) ;; 9 ;; (reset (_type_) none) - (top-anim-joint-control-method-10 () none) ;; 10 ;; (update (_type_) none) - (top-anim-joint-control-method-11 () none) ;; 11 ;; (get-channel (_type_ int) joint-control-channel) - (top-anim-joint-control-method-12 () none) ;; 12 ;; (push-anim-to-targ (_type_ art-joint-anim float int int float float symbol) none) + (new (symbol type process-drawable) _type_) ;; 0 + (reset (_type_) none) ;; 9 + (update (_type_) none) ;; 10 + (get-channel (_type_ int) joint-control-channel) ;; 11 + (push-anim-to-targ (_type_ art-joint-anim float int int float float symbol) none) ;; 12 ) ) -|# -#| (deftype joint-control (basic) + "Every [[process-drawable]] has a [[joint-control]] that handles all the animation channels." ((status joint-control-status :offset-assert 4) (allocated-length uint8 :offset-assert 6) (active-channels uint8 :offset-assert 7) - (root-channel (inline-array joint-control-channel) :offset-assert 16) ;; guessed by decompiler + (root-channel (inline-array joint-control-channel) :offset 16) ;; guessed by decompiler (blend-index uint8 :offset-assert 20) (active-frame-interp uint8 :offset-assert 21) (float-channels uint8 :offset-assert 22) @@ -12774,39 +15931,36 @@ (postbind-function (function draw-control cspace-array joint-control none) :offset-assert 32) ;; guessed by decompiler (effect effect-control :offset-assert 36) ;; guessed by decompiler (interp-select int64 2 :offset-assert 40) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ;(UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (top-anim top-anim-joint-control :offset-assert 56) ;; guessed by decompiler (override (array float) :offset-assert 60) ;; guessed by decompiler - (channel joint-control-channel :dynamic :offset-assert 64) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (channel joint-control-channel :dynamic :inline :offset-assert 64) ;; guessed by decompiler + ;(UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. ) :method-count-assert 13 :size-assert #x40 :flag-assert #xd00000040 ;; field joint-control-status is likely a value type. (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type int) _type_) - (joint-control-method-9 () none) ;; 9 ;; (current-cycle-distance (_type_) float) - (joint-control-method-10 () none) ;; 10 ;; (update-anim-data (_type_) none) - (joint-control-method-11 () none) ;; 11 ;; (debug-print-channels (_type_ symbol) int) - (joint-control-method-12 () none) ;; 12 ;; (joint-control-method-12 (_type_ int) joint-control-channel) + (new (symbol type int) _type_) ;; 0 + (current-cycle-distance (_type_) float) ;; 9 + (update-anim-data (_type_) none) ;; 10 + (debug-print-channels "Print the list of joint animations playing in the flattened blend tree." (_type_ symbol) int) ;; 11 + (joint-control-method-12 (_type_ int) joint-control-channel) ;; 12 ) ) -|# -#| (deftype matrix-stack (structure) ((top matrix :offset-assert 0) - (data matrix 24 :offset-assert 16) ;; guessed by decompiler + (data matrix 24 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x610 :flag-assert #x900000610 ) -|# -#| (deftype channel-upload-info (structure) + "Information about an upload of animation data to a single joint channel." ((fixed joint-anim-compressed-fixed :offset-assert 0) (fixed-qwc int32 :offset-assert 4) (frame joint-anim-compressed-frame :offset-assert 8) @@ -12814,69 +15968,71 @@ (amount float :offset-assert 16) (interp float :offset-assert 20) ) + :pack-me :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype joint-work (structure) ((temp-mtx matrix :inline :offset-assert 0) (joint-stack matrix-stack :inline :offset-assert 64) (fix-jmp-table (function none) 16 :offset-assert 1616) ;; guessed by decompiler (frm-jmp-table (function none) 16 :offset-assert 1680) ;; guessed by decompiler (pair-jmp-table (function none) 16 :offset-assert 1744) ;; guessed by decompiler - (uploads channel-upload-info 24 :offset-assert 1808) ;; guessed by decompiler + (uploads channel-upload-info 24 :inline :offset-assert 1808) ;; guessed by decompiler (num-uploads int32 :offset-assert 2384) - (mtx-acc matrix 2 :offset-assert 2400) ;; guessed by decompiler - (tq-acc transformq 100 :offset-assert 2528) ;; guessed by decompiler + (mtx-acc matrix 2 :inline :offset-assert 2400) ;; guessed by decompiler + (tq-acc transformq 100 :inline :offset-assert 2528) ;; guessed by decompiler (jacp-hdr joint-anim-compressed-hdr :inline :offset-assert 7328) (fixed-data joint-anim-compressed-fixed :inline :offset-assert 7392) - (frame-data joint-anim-compressed-frame 2 :offset-assert 9600) ;; guessed by decompiler - (flatten-array float 576 :offset-assert 2400) ;; guessed by decompiler - (flattened vector 24 :offset-assert 2400) ;; guessed by decompiler + (frame-data joint-anim-compressed-frame 2 :inline :offset-assert 9600) ;; guessed by decompiler + (flatten-array float 576 :offset 2400) ;; guessed by decompiler + (flattened vector 24 :inline :offset 2400) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x3640 :flag-assert #x900003640 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; bones-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++bones-h:bone-calc-flags +(defenum bone-calc-flags + :type uint16 + :bitfield #t + (write-ripple-data 0) + (no-cam-rot 1) + ) +;; ---bones-h:bone-calc-flags + (deftype bone-buffer (structure) - ((joint matrix 16 :offset-assert 0) ;; guessed by decompiler - (bone bone 16 :offset-assert 1024) ;; guessed by decompiler - (output pris-mtx 16 :offset-assert 2304) ;; guessed by decompiler + ((joint matrix 16 :inline :offset-assert 0) ;; guessed by decompiler + (bone bone 16 :inline :offset-assert 1024) ;; guessed by decompiler + (output pris-mtx 16 :inline :offset-assert 2304) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x1100 :flag-assert #x900001100 ) -|# -#| (deftype bone-layout (structure) ((data uint16 8 :offset-assert 0) ;; guessed by decompiler - (joint (inline-array matrix) 2 :offset-assert 0) ;; guessed by decompiler - (bone (inline-array bone) 2 :offset-assert 8) ;; guessed by decompiler - (output (inline-array pris-mtx) 2 :offset-assert 16) ;; guessed by decompiler - (unused uint32 2 :offset-assert 24) ;; guessed by decompiler + (joint (inline-array matrix) 2 :offset 0) ;; guessed by decompiler + (bone (inline-array bone) 2 :offset 8) ;; guessed by decompiler + (output (inline-array pris-mtx) 2 :offset 16) ;; guessed by decompiler + (unused uint32 2 :offset 24) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype bone-regs (structure) - ((dma-buf dma-buffer :offset-assert 0) ;; guessed by decompiler + ((dma-buf dma-buffer :offset-assert 0) (wait-count uint32 :offset-assert 4) (in-count uint32 :offset-assert 8) (sp-size uint32 :offset-assert 12) @@ -12890,9 +16046,7 @@ :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype bone-work (structure) ((layout bone-layout :inline :offset-assert 0) (regs bone-regs :inline :offset-assert 32) @@ -12901,9 +16055,7 @@ :size-assert #x44 :flag-assert #x900000044 ) -|# -#| (deftype bone-debug (structure) ((time-ctr uint32 :offset-assert 0) (timing uint32 360 :offset-assert 4) ;; guessed by decompiler @@ -12912,22 +16064,18 @@ :size-assert #x5a4 :flag-assert #x9000005a4 ) -|# -#| (deftype bone-memory (structure) ((work bone-work :inline :offset-assert 0) - (buffer bone-buffer 2 :offset-assert 80) ;; guessed by decompiler + (buffer bone-buffer 2 :inline :offset-assert 80) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x2250 :flag-assert #x900002250 ) -|# -#| (deftype bone-calculation (structure) - ((flags uint16 :offset-assert 0) ;; bone-calc-flags + ((flags bone-calc-flags :offset-assert 0) ;; bone-calc-flags (num-bones uint16 :offset-assert 2) (matrix-area (inline-array pris-mtx) :offset-assert 4) ;; guessed by decompiler (joints (inline-array joint) :offset-assert 8) ;; guessed by decompiler @@ -12936,6 +16084,7 @@ (ripple-y-scale float :offset-assert 20) (ripple-normal-scale float :offset-assert 24) (ripple-area (inline-array vector) :offset-assert 28) ;; guessed by decompiler + (ripple-vec vector :inline :offset 16) ;; added (next bone-calculation :offset-assert 32) (dummy-1 uint32 :offset-assert 36) (dummy-2 uint32 :offset-assert 40) @@ -12945,9 +16094,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype bone-calculation-list (structure) ((first bone-calculation :offset-assert 0) (next bone-calculation :offset-assert 4) @@ -12956,40 +16103,43 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; foreground-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type merc-effect structure) + (deftype mercneric-chain (structure) + "A DMA chain for drawing with mercneric, and metadata needed to append. + This chain is assumed to run with a specific tpage from a specific level available." ((first uint32 :offset-assert 0) (next uint32 :offset-assert 4) (state generic-bucket-state :inline :offset-assert 8) - (vu1-bucket int32 :offset-assert 16) ;; bucket-id + (vu1-bucket bucket-id :offset-assert 16) ) + :pack-me :method-count-assert 9 :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype merc-chain (structure) + "A DMA chain for drawing with merc. + This chain is assumed to run with a specific tpage from a specific level available." ((first dma-packet :offset-assert 0) (patch dma-packet :offset-assert 4) - (vu1-bucket int32 :offset-assert 8) ;; bucket-id + (vu1-bucket bucket-id :offset-assert 8) ) + :pack-me :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype foreground-bucket (structure) + "A foreground bucket is merc, emerc, and mercneric chain for a given texture mode." ((merc merc-chain :inline :offset-assert 0) (emerc merc-chain :inline :offset-assert 12) (mercneric mercneric-chain :inline :offset-assert 24) @@ -12998,31 +16148,31 @@ :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype foreground-level-buckets (structure) - ((data foreground-bucket 10 :offset-assert 0) ;; guessed by decompiler + "Collection of buckets for a single level. + Each bucket has a different texture. The order is: + tfrag, pris, shrub, alpha, water, pris, pris2" + ((data foreground-bucket 10 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x1e0 :flag-assert #x9000001e0 ) -|# -#| (deftype foreground-bucket-grid (structure) - ((level-buckets foreground-level-buckets 19 :offset-assert 0) ;; guessed by decompiler + "Array of buckets for each level, plus the single warp chain shared between everybody." + ((level-buckets foreground-level-buckets 19 :inline :offset-assert 0) ;; guessed by decompiler (warp-chain mercneric-chain :inline :offset-assert 9120) ) :method-count-assert 9 :size-assert #x23b4 :flag-assert #x9000023b4 ) -|# -#| (deftype foreground-regs (structure) + "Frequently accessed foreground values. These are in scratchpad for fast access + during foreground processing." ((dist float :offset-assert 0) (merc-used uint32 :offset-assert 4) (emerc-used uint32 :offset-assert 8) @@ -13042,12 +16192,13 @@ :size-assert #x38 :flag-assert #x900000038 ) -|# -#| (deftype foreground-work (structure) + "Memory map for scratchpad during foreground processing. + This is not used by the renderers, bone matrix, or joint code - just the code + that assigns stuff to buckets and prepares DMA for merc (or requests for generic merc)." ((regs foreground-regs :inline :offset-assert 0) - (draw-index-map uint8 19 :offset-assert 64) ;; guessed by decompiler + (draw-index-map uint8 19 :offset 64) ;; guessed by decompiler (grid foreground-bucket-grid :inline :offset-assert 96) (bounds sphere :inline :offset-assert 9248) (lights vu-lights :inline :offset-assert 9264) @@ -13058,10 +16209,9 @@ :size-assert #x24c0 :flag-assert #x9000024c0 ) -|# -#| (deftype texscroll-globals (structure) + "List of all merc-effects that need texscroll applied." ((requests int32 :offset-assert 0) (effects merc-effect 32 :offset-assert 4) ;; guessed by decompiler ) @@ -13069,38 +16219,38 @@ :size-assert #x84 :flag-assert #x900000084 ) -|# -#| (deftype merc-effect-bucket-info (structure) + "Scratch info computed per-merc-effect by the foreground code, then later read by merc + DMA generation. This is only for the currently-processing merc model's effects." ((color-fade rgba :offset-assert 0) ;; guessed by decompiler + (alpha uint8 :offset 3) (merc-path uint8 :offset-assert 4) (ignore-alpha uint8 :offset-assert 5) (disable-draw uint8 :offset-assert 6) (disable-envmap uint8 :offset-assert 7) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype merc-bucket-info (structure) + "Scratch info for the current merc-ctrl. Written by the foreground code, read by merc DMA generation." ((light vu-lights :inline :offset-assert 0) (needs-clip int32 :offset-assert 112) (need-mercprime-if-merc int32 :offset-assert 116) (must-use-mercneric-for-clip int32 :offset-assert 120) - (effect merc-effect-bucket-info 64 :offset-assert 124) ;; guessed by decompiler + (effect merc-effect-bucket-info 64 :inline :offset-assert 124) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x27c :flag-assert #x90000027c ) -|# -#| (deftype foreground-globals (structure) + "The foreground renderer state: all DMA chains, settings for the current merc-ctrl, texscroll list." ((foreground-grid foreground-bucket-grid :inline :offset-assert 0) (merc-bucket-info merc-bucket-info :inline :offset-assert 9152) (texscroll texscroll-globals :inline :offset-assert 9792) @@ -13109,10 +16259,9 @@ :size-assert #x26c4 :flag-assert #x9000026c4 ) -|# -#| (deftype shadow-dma-packet (structure) + "DMA tag for submitting shadow data." ((tag generic-merc-tag :inline :offset-assert 0) (settings shadow-settings :inline :offset-assert 16) (geo-ref dma-packet :inline :offset-assert 96) @@ -13123,55 +16272,96 @@ :size-assert #x90 :flag-assert #x900000090 ) -|# -;; (define-extern invalidate-cache-line function) ;; (function pointer int) -;; (define-extern *bucket-map* object) ;; (pointer bucket-id-16) -;; (define-extern vu1-bucket-map function) ;; (function int int merc-mode bucket-id) +;; +++foreground-h:merc-mode +(defenum merc-mode + :type int32 + (merc 0) + (emerc 1) + (mercneric 2) + (texture 3) + (mercneric2 4) + (mm5 5) + ) +;; ---foreground-h:merc-mode + +(define-extern invalidate-cache-line (function pointer int)) +(define-extern *bucket-map* (pointer bucket-id-16)) +(define-extern vu1-bucket-map (function int int int merc-mode bucket-id-16)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; engines ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++engines:part-local-space-flags +(defenum part-local-space-flags + :type uint32 + :bitfield #t + (pls0 0) + (pls1 1) + (pls2 2) + ) +;; ---engines:part-local-space-flags + (deftype particle-local-space-info (connection) - ((params basic 3 :offset-assert 20) ;; guessed by decompiler - (mat-prev matrix :inline :offset-assert 32) - (mat-new matrix :inline :offset-assert 96) - (hand uint64 :offset-assert 160) ;; handle - (flags part-local-space-flags :offset-assert 168) ;; guessed by decompiler - (pad uint32 1 :offset-assert 172) ;; guessed by decompiler + ((params basic 3 :offset 20 :score 1) + (mat-prev matrix :inline :offset-assert 32) + (mat-new matrix :inline :offset-assert 96) + (hand handle :offset-assert 160) + (flags part-local-space-flags :offset-assert 168) + (pad uint32 1 :offset-assert 172) ) :method-count-assert 14 :size-assert #xb0 :flag-assert #xe000000b0 ;; field param1 uses ~A with a signed load. field param2 uses ~A with a signed load. field param3 uses ~A with a signed load. ) -|# -;; (define-extern *background-draw-engine* object) ;; engine -;; (define-extern *matrix-engine* object) ;; (array handle) -;; (define-extern *cloth-engine* object) ;; (array handle) -;; (define-extern *part-engine* object) ;; engine -;; (define-extern *cam-post-hook-engine* object) ;; engine -;; (define-extern *part-local-space-engine* object) ;; engine -;; (define-extern *camera-engine* object) ;; engine -;; (define-extern *debug-engine* object) ;; engine -;; (define-extern *pad-engine* object) ;; engine -;; (define-extern *lightning-engine* object) ;; engine -;; (define-extern *hud-engine* object) ;; engine -;; (define-extern *prim-client-engine* object) -;; (define-extern *prim-engine* object) ;; engine -;; (define-extern *task-manager-engine* object) ;; engine +(define-extern *background-draw-engine* engine) +(define-extern *matrix-engine* (array handle)) +(define-extern *cloth-engine* (array handle)) +(define-extern *part-engine* engine) +(define-extern *cam-post-hook-engine* engine) +(define-extern *part-local-space-engine* engine) +(define-extern *camera-engine* engine) +(define-extern *debug-engine* engine) +(define-extern *pad-engine* engine) +(define-extern *lightning-engine* engine) +(define-extern *hud-engine* engine) +(define-extern *prim-client-engine* engine) +(define-extern *prim-engine* engine) +(define-extern *task-manager-engine* engine) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; lightning-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++lightning-h:lightning-spec-flags +(defenum lightning-spec-flags + :type uint16 + :bitfield #t + (lsf0 0) + (lsf1 1) + (lsf2 2) + (lsf3 3) + (lsf4 4) + (lsf5 5) + (lsf6 6) + (lsf7 7) + (lsf8 8) + (lsf9 9) + (lsf10 10) + (lsf11 11) + (lsf12 12) + (lsf13 13) + (lsf14 14) + (lsf15 15) + ) +;; ---lightning-h:lightning-spec-flags + (deftype lightning-spec (basic) ((name string :offset-assert 4) ;; guessed by decompiler - (flags uint16 :offset-assert 8) ;; lightning-spec-flags + (flags lightning-spec-flags :offset-assert 8) (rand-func uint8 :offset-assert 10) (adjust-distance uint8 :offset-assert 11) (start-color rgba :offset-assert 12) ;; guessed by decompiler @@ -13196,11 +16386,9 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype lightning-state (structure) - ((mode uint8 :offset-assert 0) + ((mode uint8 :offset-assert 0) ;; lightning-mode (counter float :offset-assert 4) (points-to-draw int32 :offset-assert 8) (box-size float :offset-assert 12) @@ -13215,9 +16403,18 @@ :size-assert #x94 :flag-assert #x900000094 ) -|# -#| +;; +++lightning-h:lightning-mode +(defenum lightning-mode + :type uint8 + (lm-1 -1) + (lm0 0) + (lm1 1) + (lm2 2) + (lm3 3) + ) +;; ---lightning-h:lightning-mode + (deftype lightning-control (basic) ((spec lightning-spec :offset-assert 4) ;; guessed by decompiler (process (pointer process) :offset-assert 8) ;; guessed by decompiler @@ -13227,72 +16424,66 @@ :size-assert #xa4 :flag-assert #xe000000a4 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type lightning-spec process float) _type_) - (lightning-control-method-9 () none) ;; 9 ;; (change-mode (_type_ lightning-mode) lightning-mode) - (lightning-control-method-10 () none) ;; 10 ;; (get-mode (_type_) lightning-mode) - (lightning-control-method-11 () none) ;; 11 ;; (set-point! (_type_ int vector) none) - (lightning-control-method-12 () none) ;; 12 ;; (set-first-meet-point (_type_ vector) none) - (lightning-control-method-13 () none) ;; 13 ;; (set-last-meet-point (_type_ vector) none) + (new (symbol type lightning-spec process float) _type_) ;; 0 + (change-mode (_type_ lightning-mode) lightning-mode) ;; 9 + (get-mode (_type_) lightning-mode) ;; 10 + (set-point! (_type_ int vector) none) ;; 11 + (set-first-meet-point (_type_ vector) none) ;; 12 + (set-last-meet-point (_type_ vector) none) ;; 13 ) ) -|# -#| (deftype lightning-probe-vars (basic) - ((src-joint-index uint32 :offset-assert 4) - (next-spawn-time uint64 :offset-assert 8) ;; time-frame - (last-valid-time uint64 :offset-assert 16) ;; time-frame - (point vector 2 :offset-assert 32) ;; guessed by decompiler - (start-pos vector :inline :offset-assert 32) - (end-pos vector :inline :offset-assert 48) - (probe-dirs (inline-array vector) :offset-assert 64) ;; guessed by decompiler + ((src-joint-index uint32 :offset-assert 4) + (next-spawn-time time-frame :offset-assert 8) ;; time-frame + (last-valid-time time-frame :offset-assert 16) ;; time-frame + (point vector 2 :inline :offset-assert 32) ;; guessed by decompiler + (start-pos vector :inline :offset 32) + (end-pos vector :inline :offset 48) + (probe-dirs (inline-array vector) :offset-assert 64) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x44 :flag-assert #x900000044 ) -|# -;; (define-extern lookup-lightning-spec-by-name function) ;; (function string lightning-spec) -;; (define-extern *lightning-probe-vars* lightning-probe-vars) ;; lightning-probe-vars +(define-extern lookup-lightning-spec-by-name (function string lightning-spec)) +(define-extern *lightning-probe-vars* lightning-probe-vars) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; res ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; res-lump is already defined! - -;; (define-extern *res-static-buf* object) ;; pointer +(define-extern *res-static-buf* pointer) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; lights ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *light-hash-work* object) ;; light-hash-work -;; (define-extern light-slerp function) ;; (function light light light float light) -;; (define-extern light-group-slerp function) ;; (function light-group light-group light-group float light-group) -;; (define-extern light-group-process! function) ;; (function vu-lights light-group vector vector none) -;; (define-extern *default-lights* object) ;; vu-lights -;; (define-extern vu-lights-default! function) ;; (function vu-lights vu-lights) -;; (define-extern init-light-hash function) ;; (function none) -;; (define-extern light-hash-count-items function) ;; (function light-hash light-sphere none) -;; (define-extern light-hash-add-items function) ;; (function light-hash light-sphere integer object) -;; (define-extern reset-light-hash function) ;; (function light-hash none) -;; (define-extern update-light-hash function) ;; (function light-hash none) -;; (define-extern lookup-light-sphere-by-name function) ;; (function string light-hash light-sphere) -;; (define-extern light-hash-get-bucket-index function) ;; (function light-hash vector int) -;; (define-extern add-light-sphere-to-light-group function) ;; (function object object object object object) -;; (define-extern light-merge! function) ;; (function light-group light-group none) -;; (define-extern light-group-scale! function) ;; (function light-group (pointer light-group) float none) -;; (define-extern light-group-madd! function) ;; (function light-group (pointer light-group) light-group float none) -;; (define-extern light-group-lerp! function) ;; (function light-group (pointer light-group) light-group float none) -;; (define-extern shadow-info-copy! function) ;; (function light-group light-group none) +(define-extern *light-hash-work* light-hash-work) +(define-extern light-slerp (function light light light float light)) +(define-extern light-group-slerp (function light-group light-group light-group float light-group)) +(define-extern light-group-process! (function vu-lights light-group vector vector none)) +(define-extern *default-lights* vu-lights) +(define-extern vu-lights-default! (function vu-lights vu-lights)) +(define-extern init-light-hash (function none)) +(define-extern light-hash-count-items (function light-hash light-sphere none)) +(define-extern light-hash-add-items (function light-hash light-sphere integer object)) +(define-extern reset-light-hash (function light-hash none)) +(define-extern update-light-hash (function light-hash none)) +(define-extern lookup-light-sphere-by-name (function string light-hash light-sphere)) +(define-extern light-hash-get-bucket-index (function light-hash vector int)) +(define-extern add-light-sphere-to-light-group (function object object object object object)) +(define-extern light-merge! (function light-group light-group none)) +(define-extern light-group-scale! (function light-group (pointer light-group) float none)) +(define-extern light-group-madd! (function light-group (pointer light-group) light-group float none)) +(define-extern light-group-lerp! (function light-group (pointer light-group) light-group float none)) +(define-extern shadow-info-copy! (function light-group light-group none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; dynamics-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype dynamics (basic) ((name symbol :offset-assert 4) ;; guessed by decompiler (gravity-max meters :offset-assert 8) @@ -13306,48 +16497,124 @@ :size-assert #x38 :flag-assert #xa00000038 (:methods - (dynamics-method-9 () none) ;; 9 ;; (set-gravity-length (_type_ float) none) + (set-gravity-length (_type_ float) none) ;; 9 ) ) -|# -;; (define-extern time-to-apex function) ;; (function float float int) -;; (define-extern time-to-ground function) ;; (function float float float int) -;; (define-extern *standard-dynamics* dynamics) ;; dynamics +(define-extern time-to-apex (function float float int)) +(define-extern time-to-ground (function float float float int)) +(define-extern *standard-dynamics* dynamics) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; pat-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++pat-h:pat-mode +(defenum pat-mode + :type uint8 + (ground 0) + (wall 1) + (obstacle 2) + (halfpipe 3) + ) +;; ---pat-h:pat-mode + +;; +++pat-h:pat-material +(defenum pat-material + :type uint8 + (unknown 0) + (ice 1) + (quicksand 2) + (waterbottom 3) + (tar 4) + (sand 5) + (wood 6) + (grass 7) + (pcmetal 8) + (snow 9) + (deepsnow 10) + (hotcoals 11) + (lava 12) + (crwood 13) + (gravel 14) + (dirt 15) + (metal 16) + (straw 17) + (tube 18) + (swamp 19) + (stopproj 20) + (rotate 21) + (neutral 22) + (stone 23) + (crmetal 24) + (carpet 25) + (grmetal 26) + (shmetal 27) + (hdwood 28) + (squish 29) + (invisible 30) ;; mhshroom + (forest 31) + (forcefield 32) ;; mhswamp + (dmaker 33) +) +;; ---pat-h:pat-material + +;; +++pat-h:pat-event +(defenum pat-event + :type uint8 + (none 0) + (deadly 1) + (nodamage 2) ;; endlessfall + (e01 3) ;; burn + (e02 4) ;; deadlyup + (e03 5) ;; burnup + (e04 6) ;; melt + (e05 7) ;; slide + (e06 8) ;; lip + (e07 9) ;; lipramp + (e08 10) ;; shock + (e09 11) ;; shockup + (e10 12) ;; hide + (e11 13) ;; rail + (slippery 14) + (e13 15) ;; drag + (e14 16) ;; waterfloor + (e15 17) ;; hang + (e16 18) ;; fry + (e17 19) ;; slime +) +;; ---pat-h:pat-event + (deftype pat-surface (uint32) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((skip uint8 :offset 0 :size 7 :do-not-decompile) + (mode pat-mode :offset 7 :size 3) + (material pat-material :offset 10 :size 6) + (camera uint8 :offset 16 :size 1 :do-not-decompile) ;; sz = 2?? + (event pat-event :offset 18 :size 6) + (skip2 uint8 :offset 24 :size 5 :do-not-decompile) + + (noentity uint8 :offset 0 :size 1) + (nocamera uint8 :offset 1 :size 1) + (noedge uint8 :offset 2 :size 1) + (nogrind uint8 :offset 3 :size 1) + (nojak uint8 :offset 4 :size 1) + (noboard uint8 :offset 5 :size 1) + (nopilot uint8 :offset 6 :size 1) + + (probe uint8 :offset 24 :size 1) + (nomech uint8 :offset 25 :size 1) + (noproj uint8 :offset 26 :size 1) + (noendlessfall uint8 :offset 27 :size 1) + (noprobe uint8 :offset 28 :size 1) + + (nolineofsight uint8 :offset 16 :size 1) + (board uint8 :offset 4 :size 1) ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype pat-mode-info (structure) ((name string :offset-assert 0) ;; guessed by decompiler (wall-angle float :offset-assert 4) @@ -13358,18 +16625,16 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern pat-material->string function) ;; (function pat-surface string) -;; (define-extern pat-mode->string function) ;; (function pat-surface string) -;; (define-extern pat-event->string function) ;; (function pat-surface string) -;; (define-extern *pat-mode-info* object) ;; (inline-array pat-mode-info) +(define-extern pat-material->string (function pat-surface string)) +(define-extern pat-mode->string (function pat-surface string)) +(define-extern pat-event->string (function pat-surface string)) +(define-extern *pat-mode-info* (inline-array pat-mode-info)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; fact-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype fact-bank (basic) ((eco-level-max float :offset-assert 4) (eco-single-inc float :offset-assert 8) @@ -13412,80 +16677,136 @@ :size-assert #xa4 :flag-assert #x9000000a4 ) -|# -#| +;; +++fact-h:actor-option +(defenum actor-option + :bitfield #t + :type uint64 + (blocked 0) ;; 1 + (spawns-fuel-cell 1) ;; 2 + (draw-blocker 2) ;; 4 + (loop 3) ;; 8 + (reflect 4) ;; 16 + (wait-for-cue 5) ;; 32 + (auto-pickup 6) ;; 64 + (fuel-cell-no-jump 7) ;; 128 + (suck-in 8) ;; 256 + (fade-out 9) ;; 512 + (big-collision 10) ;; 1024 + (racer-only 11) ;; 2048 + (no-reaction 12) ;; 4096 + (no-shadow 13) ;; 8192 + (wait-for-task-complete 14) ;; 16384 + (respawn-delay 15) ;; 32768 + + (no-amb-sound 16) ;; hi 1 + (user17 17) ;; hi 2 + (user18 18) ;; hi 4 + (user19 19) ;; hi 8 + (user20 20) ;; hi 16 + (cond-hide 21) ;; hi 32 + (cond-respawn 22) ;; hi 64 + (fall 23) ;; hi 128 + (mirror 24) ;; hi 256 + (cond-low-ammo 25) ;; hi 512 + (no-distance-check-fadeout 26) ;; 1024 + (no-track 27) ;; hi 2048 + (dont-override-fact 28) + ) +;; ---fact-h:actor-option + +(define-extern process-drawable-art-error (state string process-drawable)) (deftype fact-info (basic) ((process process :offset-assert 4) ;; guessed by decompiler + (pickup-type pickup-type :offset-assert 8) (pickup-amount float :offset-assert 12) (pickup-spawn-amount float :offset-assert 16) (options actor-option :offset-assert 24) - (fade-time uint64 :offset-assert 32) ;; time-frame + (fade-time time-frame :offset-assert 32) ;; time-frame ) :method-count-assert 12 :size-assert #x28 :flag-assert #xc00000028 ;; field actor-option is likely a value type. (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type process pickup-type float) _type_) - (fact-info-method-9 () none) ;; 9 ;; (drop-pickup (_type_ symbol process-tree fact-info int symbol) (pointer process)) - (fact-info-method-10 () none) ;; 10 ;; (reset! (_type_ symbol) none) - (fact-info-method-11 () none) ;; 11 ;; (pickup-collectable! (_type_ pickup-type float handle) float) + (new (symbol type process pickup-type float) _type_) ;; 0 + (drop-pickup (_type_ symbol process-tree fact-info int symbol) (pointer process)) ;; 9 + (reset! (_type_ symbol) none) ;; 10 + (pickup-collectable! (_type_ pickup-type float handle) float) ;; 11 ) ) -|# -#| +;; +++fact-h:enemy-option +(defenum enemy-option + :bitfield #t + :type uint32 + (user0 0) ;; 1 + (user1 1) ;; 2 + (user2 2) ;; 4 + (user3 3) ;; 8 + (user4 4) ;; 16 + (user5 5) ;; 32 + (user6 6) ;; 64 + (user7 7) ;; 128 + (user8 8) ;; 256 + (user9 9) ;; 512 + (user10 10) ;; 1024 + (user11 11) ;; 2048 + (user12 12) ;; 4096 + (user13 13) ;; 8192 + (user14 14) ;; 16k + (user15 15) + + (dormant 16) ;; hi 1 + (dormant-aware 17) ;; hi 2 + (ambush 18) ;; hi 4 + (spawner 19) ;; hi 8 + (prespawned 20) ;; hi 16 + (multi-focus 21) ;; hi 32 + (has-trigger 22) + (idle-til-trigger 23) ;; hi 128 + (knocked-into-water 24) ;; hi 256 + (water 25) ;; hi 512 + ) +;; ---fact-h:enemy-option + +(declare-type actor-group inline-array-class) (deftype fact-info-enemy (fact-info) - ((process process :offset-assert 0) ;; guessed by decompiler - (pickup-amount float :offset-assert 8) - (pickup-spawn-amount float :offset-assert 12) - (options actor-option :offset-assert 20) - (fade-time uint64 :offset-assert 28) ;; time-frame - (speed float :offset-assert 36) - (idle-distance meters :offset-assert 40) - (notice-top meters :offset-assert 44) - (notice-bottom meters :offset-assert 48) - (cam-horz meters :offset-assert 52) - (cam-vert meters :offset-assert 56) - (cam-notice-dist meters :offset-assert 60) - (enemy-options enemy-option :offset-assert 64) - (trig-dist meters :offset-assert 68) - (trig-actor-group (pointer actor-group) :offset-assert 72) ;; guessed by decompiler - (trig-mask-count int8 :offset-assert 76) - (trig-mask uint8 2 :offset-assert 77) ;; guessed by decompiler + ((speed float :offset-assert 40) + (idle-distance meters :offset-assert 44) + (notice-top meters :offset-assert 48) + (notice-bottom meters :offset-assert 52) + (cam-horz meters :offset-assert 56) + (cam-vert meters :offset-assert 60) + (cam-notice-dist meters :offset-assert 64) + (enemy-options enemy-option :offset-assert 68) + (trig-dist meters :offset-assert 72) + (trig-actor-group (pointer actor-group) :offset-assert 76) ;; guessed by decompiler + (trig-mask-count int8 :offset-assert 80) + (trig-mask uint8 2 :offset-assert 81) ;; guessed by decompiler ) :method-count-assert 13 :size-assert #x53 :flag-assert #xd00000053 ;; field actor-option is likely a value type. (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type process (pointer float)) _type_) - (fact-info-enemy-method-12 () none) ;; 12 ;; (clear-mask-bits (_type_ int) none) + (new (symbol type process (pointer float)) _type_) ;; 0 + (clear-mask-bits (_type_ int) none) ;; 12 ) ) -|# -#| (deftype fact-info-crate (fact-info) - ((process process :offset-assert 0) ;; guessed by decompiler - (pickup-amount float :offset-assert 8) - (pickup-spawn-amount float :offset-assert 12) - (options actor-option :offset-assert 20) - (fade-time uint64 :offset-assert 28) ;; time-frame - (suck-count int32 :offset-assert 36) + ((suck-count int32 :offset-assert 40) ) :method-count-assert 12 :size-assert #x2c :flag-assert #xc0000002c ;; field actor-option is likely a value type. (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type process pickup-type float) _type_) + (new (symbol type process pickup-type float) _type_) ;; 0 ) ) -|# -#| (deftype fact-info-enemy-defaults (basic) ((idle-distance meters :offset-assert 4) (pickup-type int32 :offset-assert 8) @@ -13495,20 +16816,105 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern *FACT-bank* fact-bank) ;; fact-bank -;; (define-extern pickup-type->string function) ;; (function pickup-type string) -;; (define-extern *fact-info-enemy-defaults* fact-info-enemy-defaults) ;; fact-info-enemy-defaults +(define-extern *FACT-bank* fact-bank) +(define-extern pickup-type->string (function pickup-type string)) +(define-extern *fact-info-enemy-defaults* fact-info-enemy-defaults) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; penetrate-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern penetrate->string function) ;; (function penetrate string) -;; (define-extern penetrate-using->damage function) ;; (function penetrate float) -;; (define-extern penetrated-by-all&hit-points->penetrated-by function) ;; (function penetrate int penetrate) -;; (define-extern pu->knocked-type function) ;; (function penetrate knocked-type) +;; +++penetrate-h:knocked-type +(defenum knocked-type + :type uint8 + (none 0) + (mech-punch 1) + (explode-or-darkjak 2) + (dark-shot 3) + (yellow-shot 4) + (red-shot 5) + (blue-shot 6) + (vehicle 7) + (knocked-off 8) + ) +;; ---penetrate-h:knocked-type + +;; +++penetrate-h:penetrate +(defenum penetrate + :type uint64 + :bitfield #t + (touch 0) + (generic-attack 1) + (lunge 2) + (flop 3) + (punch 4) + (spin 5) + (roll 6) + (uppercut 7) + (bonk 8) + (tube 9) + (vehicle 10) + (flut-attack 11) + (board 12) + (mech 13) + (mech-punch 14) + (mech-bonk 15) + (dark-skin 16) + (dark-punch 17) + (dark-bomb 18) + (dark-smack 19) + (flut 20) + (shield 21) + (explode 22) + (jak-yellow-shot 23) + (jak-red-shot 24) + (jak-blue-shot 25) + (jak-dark-shot 26) + (enemy-yellow-shot 27) + (enemy-dark-shot 28) + (eco-yellow 29) + (eco-red 30) + (eco-blue 31) + (eco-green 32) + (knocked 33) + (jak-red-shockwave 34) + (jak-dark-nuke 35) + (jak-dark-blackhole 36) + (emp-blast 37) + (penetrate38 38) + (penetrate39 39) + (penetrate40 40) + (penetrate41 41) + (penetrate42 42) + (penetrate43 43) + (penetrate44 44) + (penetrate45 45) + (penetrate46 46) + (penetrate47 47) + (penetrate48 48) + (penetrate49 49) + (penetrate50 50) + (penetrate51 51) + (penetrate52 52) + (penetrate53 53) + (penetrate54 54) + (penetrate55 55) + (penetrate56 56) + (penetrate57 57) + (penetrate58 58) + (penetrate59 59) + (penetrate60 60) + (penetrate61 61) + (penetrate64 62) + (penetrate63 63) + ) +;; ---penetrate-h:penetrate + +(define-extern penetrate->string (function penetrate string)) +(define-extern penetrate-using->damage (function penetrate float)) +(define-extern penetrated-by-all&hit-points->penetrated-by (function penetrate int penetrate)) +(define-extern pu->knocked-type (function penetrate knocked-type)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; scert-1-h ;; @@ -13742,17 +17148,15 @@ ) |# -#| (deftype rsa-key (structure) - ((key UNKNOWN 16 :offset-assert 0) + ((key uint32 16 :offset-assert 0) ) + :pack-me :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype rsa-keypair (structure) ((public-key rsa-key :inline :offset-assert 0) (private-key rsa-key :inline :offset-assert 64) @@ -13761,7 +17165,6 @@ :size-assert #x80 :flag-assert #x900000080 ) -|# #| (deftype net-type-connect-callback-data (structure) @@ -14026,42 +17429,39 @@ ) |# -#| (deftype net-address (structure) ((address-type int32 :offset-assert 0) - (address UNKNOWN 16 :offset-assert 4) + (address int8 16 :offset-assert 4) (port uint32 :offset-assert 20) ) + :pack-me :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype net-address-list (structure) - ((a-address-list UNKNOWN 2 :offset-assert 0) + ((a-address-list net-address 2 :inline :offset-assert 0) ) + :pack-me :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype net-connection-info (structure) ((e-type int32 :offset-assert 0) (address-list net-address-list :inline :offset-assert 4) (world-id int32 :offset-assert 52) (server-key rsa-key :inline :offset-assert 56) - (a-session-key UNKNOWN 17 :offset-assert 120) - (a-access-key UNKNOWN 17 :offset-assert 137) + (a-session-key uint8 17 :offset-assert 120) + (a-access-key uint8 17 :offset-assert 137) ) + :pack-me :method-count-assert 9 :size-assert #x9a :flag-assert #x90000009a ) -|# #| (deftype net-connect-in-params (structure) @@ -19000,7 +22400,6 @@ ;; mem-buffer-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype mem-buffer (structure) ((base uint32 :offset-assert 0) (ptr uint32 :offset-assert 4) @@ -19056,9 +22455,7 @@ (mem-buffer-method-51 () none) ;; 51 ) ) -|# -#| (deftype level-bounding-box (structure) ((bmin vector :inline :offset-assert 0) (bsz vector :inline :offset-assert 16) @@ -19072,10 +22469,9 @@ (level-bounding-box-method-11 () none) ;; 11 ) ) -|# -;; (define-extern *level-bounding-box* object) -;; (define-extern *msg-buffers* object) +(define-extern *level-bounding-box* level-bounding-box) +(define-extern *msg-buffers* (pointer uint32)) ;; (define-extern alloc-msg-buffer function) ;; (define-extern free-msg-buffer function) @@ -19083,7 +22479,6 @@ ;; net-mgr-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype net-aux-msg-handler (structure) ((handler-func basic :offset-assert 0) ) @@ -19091,9 +22486,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype net-mgr-game-state (structure) ((connect-handle basic :offset-assert 0) (local-machine-idx int32 :offset-assert 4) @@ -19106,14 +22499,13 @@ (kicked basic :offset-assert 32) (sm-eligible basic :offset-assert 36) ) + :pack-me :method-count-assert 9 :size-assert #x28 :flag-assert #x900000028 ;; field connect-handle uses ~A with a signed load. ) -|# -#| (deftype net-mgr-lobby-state (structure) ((connect-handle basic :offset-assert 0) (connect-handle-mgcl basic :offset-assert 4) @@ -19137,14 +22529,13 @@ (game-on-me uint64 :offset-assert 80) (game-on-me-error-delay int32 :offset-assert 88) ) + :pack-me :method-count-assert 9 :size-assert #x5c :flag-assert #x90000005c ;; field connect-handle uses ~A with a signed load. field connect-handle-mgcl uses ~A with a signed load. field connect-handle-muis uses ~A with a signed load. field callback-userdata uses ~A with a signed load. ) -|# -#| (deftype net-mgr (process) ((game-type uint8 :offset-assert 144) (last-game-type uint8 :offset-assert 145) @@ -19159,12 +22550,6 @@ :size-assert #x128 :flag-assert #x3c00a00128 (:methods - (net-mgr-method-9 () none) ;; 9 - (net-mgr-method-10 () none) ;; 10 - (net-mgr-method-11 () none) ;; 11 - (net-mgr-method-12 () none) ;; 12 - (net-mgr-method-13 () none) ;; 13 - (net-mgr-method-14 () none) ;; 14 (net-mgr-method-15 () none) ;; 15 (net-mgr-method-16 () none) ;; 16 (net-mgr-method-17 () none) ;; 17 @@ -19212,11 +22597,9 @@ (net-mgr-method-59 () none) ;; 59 ) ) -|# -#| (deftype net-available-game-info (structure) - ((game-name UNKNOWN 64 :offset-assert 0) + ((game-name uint8 64 :offset-assert 0) (player-count uint8 :offset-assert 64) (min-players uint8 :offset-assert 65) (max-players uint8 :offset-assert 66) @@ -19227,9 +22610,9 @@ (generic-1 int32 :offset-assert 76) (generic-2 int32 :offset-assert 80) (generic-3 int32 :offset-assert 84) - (burn-version uint32 :offset-assert 76) - (lobby-world int32 :offset-assert 80) - (class-type int32 :offset-assert 84) + (burn-version uint32 :offset 76) + (lobby-world int32 :offset 80) + (class-type int32 :offset 84) (clan-1 int32 :offset-assert 88) (clan-2 int32 :offset-assert 92) (skill-level int32 :offset-assert 96) @@ -19239,14 +22622,12 @@ :size-assert #x68 :flag-assert #x900000068 ) -|# -#| (deftype net-available-game (structure) ((info net-available-game-info :inline :offset-assert 0) (connect-info net-connection-info :inline :offset-assert 104) (medius-world-id int32 :offset-assert 260) - (format-game-name UNKNOWN 64 :offset-assert 264) + (format-game-name uint8 64 :offset-assert 264) ) :method-count-assert 15 :size-assert #x148 @@ -19260,40 +22641,37 @@ (net-available-game-method-14 () none) ;; 14 ) ) -|# -;; (define-extern *net-aux-msg-handlers* object) -;; (define-extern *net-mgr-startup-status* object) -;; (define-extern *net-mgr* object) -;; (define-extern *net-error* object) -;; (define-extern *medius-world-status* object) -;; (define-extern *dme-initted* object) -;; (define-extern *medius-initted* object) -;; (define-extern *mgcl-initted* object) +(define-extern *net-aux-msg-handlers* (pointer uint32)) +(define-extern *net-mgr-startup-status* symbol) +(define-extern *net-mgr* symbol) +(define-extern *net-error* int) +(define-extern *medius-world-status* int) +(define-extern *dme-initted* symbol) +(define-extern *medius-initted* symbol) +(define-extern *mgcl-initted* symbol) ;; (define-extern encode-net-available-game-info function) ;; (define-extern decode-net-available-game-info function) -;; (define-extern *net-mgr-scratch* object) -;; (define-extern *net-available-game-ct* object) -;; (define-extern *net-available-games* object) -;; (define-extern *net-active-game* object) +(define-extern *net-mgr-scratch* (pointer uint32)) +(define-extern *net-available-game-ct* int) +(define-extern *net-available-games* (pointer uint32)) +(define-extern *net-active-game* (pointer uint32)) ;; (define-extern net-mgr-notify-connect function) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; obj-list ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype list-link (structure) ((prev list-link :offset-assert 0) (next list-link :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype linked-list (structure) ((head list-link :offset-assert 0) (tail list-link :offset-assert 4) @@ -19307,7 +22685,6 @@ (linked-list-method-11 () none) ;; 11 ) ) -|# ;; (define-extern fixup-relocated-link function) @@ -19315,7 +22692,6 @@ ;; process-nettable-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype net-process-class-info (structure) ((msg-map basic :offset-assert 0) (msg-count int32 :offset-assert 4) @@ -19329,14 +22705,12 @@ :size-assert #x1c :flag-assert #x90000001c ) -|# -;; (deftype net-process-id (uint16) -;; () -;; :flag-assert #x900000002 -;; ) +(deftype net-process-id (uint16) + () + :flag-assert #x900000002 + ) -#| (deftype proximity-ownership-params (basic) ((ownable-radius float :offset-assert 4) (force-local basic :offset-assert 8) @@ -19351,9 +22725,7 @@ (proximity-ownership-params-method-9 () none) ;; 9 ) ) -|# -#| (deftype process-nettable (process) ((owner-idx int8 :offset-assert 144) (net-flags uint64 :offset-assert 152) @@ -19368,12 +22740,6 @@ :size-assert #xbc :flag-assert #x2a003000bc (:methods - (process-nettable-method-9 () none) ;; 9 - (process-nettable-method-10 () none) ;; 10 - (process-nettable-method-11 () none) ;; 11 - (process-nettable-method-12 () none) ;; 12 - (process-nettable-method-13 () none) ;; 13 - (process-nettable-method-14 () none) ;; 14 (process-nettable-method-15 () none) ;; 15 (process-nettable-method-16 () none) ;; 16 (process-nettable-method-17 () none) ;; 17 @@ -19403,19 +22769,65 @@ (process-nettable-method-41 () none) ;; 41 ) ) -|# -;; (define-extern *net-process-class-count* object) -;; (define-extern *net-process-class-array* array) -;; (define-extern *net-process-class-names* object) -;; (define-extern net-process-class-register function) -;; (define-extern write-msg-map-rec function) +(define-extern *net-process-class-count* int) +(define-extern *net-process-class-array* (array net-process-class-info)) +(define-extern *net-process-class-names* (pointer uint32)) +(define-extern net-process-class-register (function net-process-class-info none)) +(define-extern write-msg-map-rec (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; game-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type nav-control structure) +(declare-type path-control basic) +(declare-type vol-control basic) +(declare-type fact-info basic) +(declare-type actor-link-info basic) +(declare-type water-control basic) +(declare-type carry-info basic) +(declare-type rigid-body-control basic) + +;; +++game-h:state-flags +(defenum state-flags + :bitfield #t + :type uint32 + (sf0 0) + (sf1 1) + (sf2 2) + (sf3 3) + (sf4 4) + (sf5 5) + (sf6 6) + (sf7 7) + (sf8 8) + (sf9 9) + (sf10 10) + (sf11 11) + (sf12 12) + (sf13 13) + (sf14 14) + (sf15 15) + (sf16 16) + (sf17 17) + (sf18 18) + (sf19 19) + (sf20 20) + (sf21 21) + (sf22 22) + (sf23 23) + (sf24 24) + (sf25 25) + (hang 26) + (sf27 27) + (invisible 28) + (sf29 29) + (sf30 30) + (sf31 31) + ) +;; ---game-h:state-flags + (deftype process-drawable (process-nettable) ((root trsqv :offset-assert 188) ;; guessed by decompiler (node-list cspace-array :offset-assert 192) ;; guessed by decompiler @@ -19430,7 +22842,7 @@ (sound ambient-sound :offset-assert 228) ;; guessed by decompiler (rbody rigid-body-control :offset-assert 232) ;; guessed by decompiler (state-flags state-flags :offset-assert 236) ;; guessed by decompiler - (state-time uint64 :offset-assert 240) ;; time-frame + (state-time time-frame :offset-assert 240) ;; time-frame ) :method-count-assert 50 :size-assert #xf8 @@ -19446,14 +22858,15 @@ (process-drawable-method-49 () none) ;; 49 ) (:states - process-drawable-art-error ;; associated process guessed by decompiler, old: (state string process-drawable) process-drawable-idle ;; associated process guessed by decompiler, old: (state process-drawable) + (process-drawable-art-error string) ;; associated process guessed by decompiler, old: (state string process-drawable) ) ) -|# -#| (deftype process-drawable-reserved (process-drawable) + "A process drawable with a lot of unused method slots. + GOAL cannot increase the number of methods at runtime, so, for interactive development, it is useful + to have a type with a large number of slots which can be turned into real methods without needed to reboot the PS2." () :method-count-assert 248 :size-assert #xf8 @@ -19659,10 +23072,9 @@ (process-drawable-reserved-method-247 () none) ;; 247 ) ) -|# -#| (deftype attack-dir-info (structure) + "Information about the position/direction of an attack." ((dir vector :inline :offset-assert 0) (xz-dir vector :inline :offset-assert 16) (attacker-velocity vector :inline :offset-assert 32) @@ -19672,18 +23084,50 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| +;; +++game-h:attack-mask +(defenum attack-mask + :bitfield #t + :type uint32 + (trans 0) ;; 1 + (vector 1) ;; 2 + (intersection 2) ;; 4 + (attacker 3) ;; 8 + (attack-time 4) ;; 16 + (invinc-time 5) ;; 32 + (mode 6) ;; 64 + (shove-back 7) ;; 128 + (shove-up 8) ;; 256 + (speed 9) ;; 512 + (dist 10) ;; 1024 + (control 11) ;; 2048 + (angle 12) ;; 4096 + (rotate-to 13) ;; 8192 + (prev-state 14) ;; 16384 + (id 15) ;; 32768 + (count 16) ;; hi 1 + (penetrate-using 17) ;; hi 2 + (attacker-velocity 18);; hi 4 + (damage 19) ;; hi 8 + (shield-damage 20) ;; hi16 + (vehicle-damage-factor 21) ;; hi 32 + (vehicle-impulse-factor 22) ;; hi 64 + (knock 23) + (test 24) + (wpn-type 25) + ) +;; ---game-h:attack-mask + (deftype attack-info (structure) + "Information about an incoming attack." ((trans vector :inline :offset-assert 0) (vector vector :inline :offset-assert 16) (attacker-velocity vector :inline :offset-assert 32) (intersection vector :inline :offset-assert 48) (attacker handle :offset-assert 64) - (attack-time uint64 :offset-assert 72) ;; time-frame - (invinc-time uint64 :offset-assert 80) ;; time-frame - (mask attack-info-mask :offset-assert 88) ;; attack-mask + (attack-time time-frame :offset-assert 72) ;; time-frame + (invinc-time time-frame :offset-assert 80) ;; time-frame + (mask attack-mask :offset-assert 88) ;; attack-mask (mode symbol :offset-assert 92) ;; guessed by decompiler (shove-back meters :offset-assert 96) (shove-up meters :offset-assert 100) @@ -19691,16 +23135,16 @@ (dist meters :offset-assert 108) (control float :offset-assert 112) (angle symbol :offset-assert 116) ;; guessed by decompiler - (rotate-to deg :offset-assert 120) ;; degrees + (rotate-to degrees :offset-assert 120) ;; degrees (prev-state state :offset-assert 124) ;; guessed by decompiler (id uint32 :offset-assert 128) - (wpn-type uint8 :offset-assert 132) - (penetrate-using uint64 :offset-assert 136) ;; penetrate + (count uint8 :offset-assert 132) + (penetrate-using penetrate :offset-assert 136) ;; penetrate (damage float :offset-assert 144) (shield-damage float :offset-assert 148) (vehicle-damage-factor float :offset-assert 152) (vehicle-impulse-factor float :offset-assert 156) - (knock uint8 :offset-assert 160) ;; knocked-type + (knock knocked-type :offset-assert 160) ;; knocked-type (test symbol :offset-assert 164) ;; guessed by decompiler ) :method-count-assert 10 @@ -19711,19 +23155,22 @@ (attack-info-method-9 () none) ;; 9 ;; (attack-info-method-9 (_type_ attack-info process-drawable process-drawable) none) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; script-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type script-context structure) +(declare-type load-state structure) +(define-extern *load-state* load-state) + (deftype script-form (structure) ((name symbol :offset-assert 0) ;; guessed by decompiler (spec pair :offset-assert 4) ;; guessed by decompiler (func (function script-context object) :offset-assert 8) ;; guessed by decompiler ) + :pack-me :method-count-assert 10 :size-assert #xc :flag-assert #xa0000000c @@ -19731,9 +23178,7 @@ (script-form-method-9 () none) ;; 9 ;; (script-form-method-9 () none) ) ) -|# -#| (deftype script-context (structure) ((load-state load-state :offset-assert 0) ;; guessed by decompiler (key object :offset-assert 4) ;; guessed by decompiler @@ -19744,22 +23189,21 @@ (expr pair :offset-assert 24) ;; guessed by decompiler (param-count int32 :offset-assert 28) (param object 16 :offset-assert 32) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ;(UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (param-type object 16 :offset-assert 96) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ;(UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. ) :method-count-assert 12 :size-assert #xa0 :flag-assert #xc000000a0 ;; field key uses ~A with a signed load. field expr uses ~A with a signed load. (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type object process vector) _type_) - (script-context-method-9 () none) ;; 9 ;; (eval! (_type_ pair) object) - (script-context-method-10 () none) ;; 10 ;; (script-context-method-10 (_type_ object pair) object) - (script-context-method-11 () none) ;; 11 ;; (script-context-method-11 (_type_ pair pair symbol) symbol) + (new (symbol type object process vector) _type_) ;; 0 + (eval! (_type_ pair) object) ;; 9 + (script-context-method-10 (_type_ object pair) object) ;; 10 + (script-context-method-11 (_type_ pair pair symbol) symbol) ;; 11 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -19896,11 +23340,21 @@ ;; pov-camera-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++pov-camera-h:pov-camera-flag +(defenum pov-camera-flag + :bitfield #t + :type int32 + (notify-of-abort 0) + (allow-abort 1) + (inherit-orientation 2) + (pcf3 3) + ) +;; ---pov-camera-h:pov-camera-flag + (deftype pov-camera (process-drawable) - ((flags int32 :offset-assert 248) ;; pov-camera-flag - (debounce-start-time uint64 :offset-assert 256) ;; time-frame - (notify-handle uint64 :offset-assert 264) ;; handle + ((flags pov-camera-flag :offset-assert 248) ;; + (debounce-start-time time-frame :offset-assert 256) ;; time-frame + (notify-handle handle :offset-assert 264) ;; handle (anim-name string :offset-assert 272) ;; guessed by decompiler (command-list pair :offset-assert 276) ;; guessed by decompiler (mask-to-clear process-mask :offset-assert 280) ;; guessed by decompiler @@ -19923,43 +23377,40 @@ (pov-camera-method-59 () none) ;; 59 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; smush-control-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype smush-control (structure) - ((start-time uint64 :offset-assert 0) ;; time-frame - (period float :offset-assert 8) - (duration float :offset-assert 12) - (amp float :offset-assert 16) - (damp-amp float :offset-assert 20) - (damp-period float :offset-assert 24) - (ticks float :offset-assert 28) + "This holds information about the current state of an object's smush." + ((start-time time-frame :offset-assert 0) + (period float :offset-assert 8) + (duration float :offset-assert 12) + (amp float :offset-assert 16) + (damp-amp float :offset-assert 20) + (damp-period float :offset-assert 24) + (ticks float :offset-assert 28) ) :method-count-assert 15 :size-assert #x20 :flag-assert #xf00000020 (:methods - (smush-control-method-9 () none) ;; 9 ;; (set-zero! (_type_) _type_) - (smush-control-method-10 () none) ;; 10 ;; (update! (_type_) float) - (smush-control-method-11 () none) ;; 11 ;; (get-no-update (_type_) float) - (smush-control-method-12 () none) ;; 12 ;; (activate! (_type_ float int int float float clock) _type_) - (smush-control-method-13 () none) ;; 13 ;; (nonzero-amplitude? (_type_) symbol) - (smush-control-method-14 () none) ;; 14 ;; (die-on-next-update! (_type_) _type_) + (set-zero! "Reset this [[smush-control]]." (_type_) _type_) ;; 9 + (update! "Calculate the next smush amplitude and update the smush state." (_type_) float) ;; 10 + (get-no-update "Get the next amplitude, but do not update the smush state." (_type_) float) ;; 11 + (activate! "Start the smush with the given parameters." (_type_ float int int float float clock) _type_) ;; 12 + (nonzero-amplitude? "Is the smush currently active?" (_type_) symbol) ;; 13 + (die-on-next-update! "Set the dampening period so the smush stops on the next update." (_type_) _type_) ;; 14 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; debug-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype pos-history (structure) ((points (inline-array vector) :offset-assert 0) ;; guessed by decompiler (num-points int32 :offset-assert 4) @@ -19970,9 +23421,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype debug-vertex (structure) ((trans vector4w :inline :offset-assert 0) (normal vector3h :inline :offset-assert 16) @@ -19983,21 +23432,17 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype debug-vertex-stats (basic) ((length int32 :offset-assert 4) (pos-count int32 :offset-assert 8) - (vertex debug-vertex 600 :offset-assert 16) ;; guessed by decompiler + (vertex debug-vertex 600 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x4b10 :flag-assert #x900004b10 ) -|# -#| (deftype stack-debug (structure) ((r29 uint128 :offset-assert 0) (r31 uint128 :offset-assert 16) @@ -20010,73 +23455,117 @@ :flag-assert #x90000002c ;; field obj uses ~A with a signed load. ) -|# -;; (define-extern *color-black* object) ;; rgba -;; (define-extern *color-white* object) ;; rgba -;; (define-extern *color-gray* object) ;; rgba -;; (define-extern *color-red* object) ;; rgba -;; (define-extern *color-green* object) ;; rgba -;; (define-extern *color-blue* object) ;; rgba -;; (define-extern *color-cyan* object) ;; rgba -;; (define-extern *color-magenta* object) ;; rgba -;; (define-extern *color-yellow* object) ;; rgba -;; (define-extern *color-purple* object) -;; (define-extern *color-light-gray* object) -;; (define-extern *color-light-red* object) ;; rgba -;; (define-extern *color-light-green* object) ;; rgba -;; (define-extern *color-light-blue* object) ;; rgba -;; (define-extern *color-light-cyan* object) ;; rgba -;; (define-extern *color-light-magenta* object) ;; rgba -;; (define-extern *color-light-yellow* object) ;; rgba -;; (define-extern *color-dark-red* object) ;; rgba -;; (define-extern *color-dark-green* object) ;; rgba -;; (define-extern *color-dark-blue* object) ;; rgba -;; (define-extern *color-dark-cyan* object) ;; rgba -;; (define-extern *color-dark-magenta* object) ;; rgba -;; (define-extern *color-dark-yellow* object) ;; rgba -;; (define-extern *color-orange* object) ;; rgba -;; (define-extern draw-debug-text-3d function) -;; (define-extern draw-debug-x function) -;; (define-extern draw-debug-line function) -;; (define-extern draw-debug-vector function) -;; (define-extern draw-debug-flat-triangle function) -;; (define-extern draw-debug-sphere function) -;; (define-extern draw-debug-matrix function) -;; (define-extern draw-debug-box-with-transform function) -;; (define-extern draw-debug-line-sphere function) +(define-extern *color-black* rgba) +(define-extern *color-white* rgba) +(define-extern *color-gray* rgba) +(define-extern *color-red* rgba) +(define-extern *color-green* rgba) +(define-extern *color-blue* rgba) +(define-extern *color-cyan* rgba) +(define-extern *color-magenta* rgba) +(define-extern *color-yellow* rgba) +(define-extern *color-purple* rgba) +(define-extern *color-light-gray* rgba) +(define-extern *color-light-red* rgba) +(define-extern *color-light-green* rgba) +(define-extern *color-light-blue* rgba) +(define-extern *color-light-cyan* rgba) +(define-extern *color-light-magenta* rgba) +(define-extern *color-light-yellow* rgba) +(define-extern *color-dark-red* rgba) +(define-extern *color-dark-green* rgba) +(define-extern *color-dark-blue* rgba) +(define-extern *color-dark-cyan* rgba) +(define-extern *color-dark-magenta* rgba) +(define-extern *color-dark-yellow* rgba) +(define-extern *color-orange* rgba) +(define-extern draw-debug-text-3d (function string vector bucket-id font-color vector2h rgba none)) +(define-extern draw-debug-x (function vector bucket-id rgba none)) +(define-extern draw-debug-line (function vector vector bucket-id rgba symbol rgba none)) +(define-extern draw-debug-vector (function vector vector bucket-id rgba meters none)) +(define-extern draw-debug-flat-triangle (function vector vector vector bucket-id rgba none)) +(define-extern draw-debug-sphere (function vector bucket-id float rgba none)) +(define-extern draw-debug-matrix (function matrix bucket-id float none)) +(define-extern draw-debug-box-with-transform (function bounding-box matrix bucket-id rgba none)) +(define-extern draw-debug-line-sphere (function vector vector bucket-id float rgba none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; joint-mod-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++joint-mod-h:joint-mod-mode +(defenum joint-mod-mode + :bitfield #t + :type uint32 + (flex-blend) + (look-at) + (world-look-at) + (rotate) + (joint-set) + (joint-set*) + (rotate2) ;; ?? + (reset) + (polar-look-at) + (joint-set*-world) + (gun-look-at) + (foot-rot) + (joint-set-world) + ) +;; ---joint-mod-h:joint-mod-mode + +;; +++joint-mod-h:track-mode +(defenum track-mode + :bitfield #t + :type uint16 + (track-on 0) ;; 1 + (track-x 1) ;; 2 + (track-y 2) ;; 4 + (lock-on 3) ;; 8 + (no-trans 4) ;; 16 + (no-rotate 5) ;; 32 + (no-scale 6) ;; 64 + ) +;; ---joint-mod-h:track-mode + +;; +++joint-mod-h:joint-mod-ik-flags +(defenum joint-mod-ik-flags + :bitfield #t + :type uint8 + (enable) + (elbow-trans-neg) + (elbow-rot-neg) + ) +;; ---joint-mod-h:joint-mod-ik-flags + (deftype joint-mod (basic) + "Utility to modify a joint transform from code, rather than just getting it from animation. + This is used to make jak look toward an enemy, for example." ((mode joint-mod-mode :offset-assert 4) ;; guessed by decompiler (process process-drawable :offset-assert 8) ;; guessed by decompiler (joint cspace :offset-assert 12) (target vector :inline :offset-assert 16) (twist vector :inline :offset-assert 32) (twist-max vector :inline :offset-assert 48) - (extra-twist deg :offset-assert 40) ;; degrees - (track-mode track-mode :offset-assert 44) - (look-at-count uint16 :offset-assert 46) - (twist-range-x meters :offset-assert 56) - (twist-range-y meters :offset-assert 60) + (extra-twist degrees :offset-assert 40 :overlay-at (-> twist z)) ;; degrees + (track-mode track-mode :offset-assert 44 :overlay-at (-> twist w)) + (look-at-count uint16 :offset 46) + (twist-range-x meters :offset 56) + (twist-range-y meters :offset 60) (twist-speed-x float :offset-assert 64) (twist-speed-y float :offset-assert 68) (trans vector :inline :offset-assert 80) - (smushy-old float :offset-assert 80) - (smushy-off float :offset-assert 84) - (smushyv float :offset-assert 88) + (smushy-old float :offset 80) + (smushy-off float :offset 84) + (smushyv float :offset 88) (quat quaternion :inline :offset-assert 96) (scale vector :inline :offset-assert 112) - (notice-time uint64 :offset-assert 128) ;; time-frame + (notice-time time-frame :offset-assert 128) ;; time-frame (flex-blend float :offset-assert 136) (blend float :offset-assert 140) (old-blend float :offset-assert 144) (max-dist meters :offset-assert 148) - (ignore-angle deg :offset-assert 152) ;; degrees + (ignore-angle degrees :offset-assert 152) ;; degrees (up uint8 :offset-assert 156) (nose uint8 :offset-assert 157) (ear uint8 :offset-assert 158) @@ -20090,21 +23579,19 @@ :flag-assert #x10000000ac ;; field track-mode is likely a value type. (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type joint-mod-mode process-drawable int) _type_) - (joint-mod-method-9 () none) ;; 9 ;; (mode-set! (_type_ joint-mod-mode) none) - (joint-mod-method-10 () none) ;; 10 ;; (target-set! (_type_ vector) none) - (joint-mod-method-11 () none) ;; 11 ;; (look-at! (_type_ vector symbol process) none) - (joint-mod-method-12 () none) ;; 12 ;; (reset-blend! (_type_) _type_) - (joint-mod-method-13 () none) ;; 13 ;; (twist-set! (_type_ float float float) vector) - (joint-mod-method-14 () none) ;; 14 ;; (trs-set! (_type_ vector quaternion vector) none) - (joint-mod-method-15 () none) ;; 15 ;; (shut-down (_type_) none) + (new (symbol type joint-mod-mode process-drawable int) _type_) ;; 0 + (mode-set! "Set the type of joint-mod and install the right callback." (_type_ joint-mod-mode) none) ;; 9 + (target-set! "Set the target position for look-at mode." (_type_ vector) none) ;; 10 + (look-at! "Activate joint mod to look at the process." (_type_ vector symbol process) none) ;; 11 + (reset-blend! "Set the blend to 0." (_type_) _type_) ;; 12 + (twist-set! "Set twist x,y,z. A value of #f will skip the set." (_type_ float float float) vector) ;; 13 + (trs-set! "Set translation, quaternion, scale. A value of #f will skip the set." (_type_ vector quaternion vector) none) ;; 14 + (shut-down "Disable the joint mod, possibly blending out depending on the type" (_type_) none) ;; 15 ) ) -|# -#| (deftype try-to-look-at-info (basic) - ((who uint64 :offset-assert 8) ;; handle + ((who handle :offset-assert 8) (horz float :offset-assert 16) (vert float :offset-assert 20) ) @@ -20112,10 +23599,9 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype joint-mod-spinner (basic) + "Control a joint by just spinning it around an axis." ((spin-axis vector :inline :offset-assert 16) (angle float :offset-assert 32) (spin-rate float :offset-assert 36) @@ -20124,28 +23610,39 @@ :method-count-assert 9 :size-assert #x2c :flag-assert #x90000002c + (:methods + (new "Create and attach a joint-mod-spinner to a joint." (symbol type process-drawable int vector float) _type_) ;; 0 + ) ) -|# -#| +;; +++joint-mod-h:joint-mod-base-flags +(defenum joint-mod-base-flags + :bitfield #t + :type uint16 + (attached 0) + (trans 1) + (quat 2) + (scale 3) + ) +;; ---joint-mod-h:joint-mod-base-flags + (deftype joint-mod-base (structure) - ((flags uint16 :offset-assert 0) ;; joint-mod-base-flags - (node-index int16 :offset-assert 2) - (proc (pointer process-drawable) :offset-assert 4) ;; guessed by decompiler - (callback (function cspace transformq none) :offset-assert 8) ;; guessed by decompiler + "Base type for most joint-mods" + ((flags joint-mod-base-flags :offset-assert 0) + (node-index int16 :offset-assert 2) + (proc (pointer process-drawable) :offset-assert 4) + (callback (function cspace transformq none) :offset-assert 8) ) :method-count-assert 12 :size-assert #xc :flag-assert #xc0000000c (:methods - (joint-mod-base-method-9 () none) ;; 9 ;; (init (_type_ process-drawable uint joint-mod-base-flags) none) - (joint-mod-base-method-10 () none) ;; 10 ;; (attach-callback (_type_) none) - (joint-mod-base-method-11 () none) ;; 11 ;; (remove-callback (_type_) none) + (init "Set up this joint-mod to modify the given joint of the given process. Will attach automatically if attached flag is set." (_type_ process-drawable uint joint-mod-base-flags) none) ;; 9 + (attach-callback "Take control of the specified joint by modifying the cspace callback." (_type_) none) ;; 10 + (remove-callback "Remove this callback and set param0 to #f to use the default (animated joint)" (_type_) none) ;; 11 ) ) -|# -#| (deftype joint-mod-rotate-local (joint-mod-base) ((rotation quaternion :inline :offset-assert 16) ) @@ -20153,12 +23650,11 @@ :size-assert #x20 :flag-assert #xc00000020 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) + (new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable int symbol) _type_) ) ) -|# -#| + (deftype joint-mod-trans-rot-local (joint-mod-base) ((trans vector :inline :offset-assert 16) (rot quaternion :inline :offset-assert 32) @@ -20167,69 +23663,67 @@ :size-assert #x30 :flag-assert #xc00000030 ) -|# -#| (deftype joint-mod-rotate-world (joint-mod-base) + "Add an additional rotation to a joint (right multiply)" ((rotation quaternion :inline :offset-assert 16) ) :method-count-assert 12 :size-assert #x20 :flag-assert #xc00000020 ) -|# -#| (deftype joint-mod-set-local (joint-mod-base) + "Override the trans, quat, and scale of the joint transform. The component to override is selected by the flag." ((transform transformq :inline :offset-assert 16) ) :method-count-assert 12 :size-assert #x40 :flag-assert #xc00000040 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) + (new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable int symbol symbol symbol) _type_) ) ) -|# -#| (deftype joint-mod-add-local (joint-mod-base) + "Add to the trans, rotate the quat, and multiply the scale of the joint transform. The components can be selected by the flag. + Unlike jak 2, this actually multiplies the scale, instead of adding." ((transform transformq :inline :offset-assert 16) ) :method-count-assert 12 :size-assert #x40 :flag-assert #xc00000040 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) + (new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable int symbol symbol symbol) _type_) ) ) -|# -#| (deftype joint-mod-set-world (joint-mod-base) + "Directly overwrite the _bone_ transform (ignoring the parent entirely). + This does not pay attention to the flags." ((transform transformq :inline :offset-assert 16) ) :method-count-assert 12 :size-assert #x40 :flag-assert #xc00000040 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) + (new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable int symbol) _type_) ) ) -|# -#| (deftype joint-mod-set-world-no-trans (joint-mod-base) + "Set the rotation and scale of the _bone_ directly to the values from this transform. + The translation is kept from the result of the normal parented value." ((transform transformq :inline :offset-assert 16) ) :method-count-assert 12 :size-assert #x40 :flag-assert #xc00000040 ) -|# -#| (deftype joint-mod-blend-local (joint-mod-base) + "Blend the _joint_ transform between this transform and the animated one. + Then, apply the normal parented transform." ((transform transformq :inline :offset-assert 16) (blend-transform transformq :inline :offset-assert 64) (blend float :offset-assert 112) @@ -20238,13 +23732,20 @@ :size-assert #x74 :flag-assert #xc00000074 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) + (new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable int symbol) _type_) ) ) -|# -#| +;; added - I really have no idea what is going on here +(deftype joint-mod-blend-world-work (structure) + ((mat1 matrix :inline) + (mat2 matrix :inline) + (quat quaternion :inline) + (vec vector :inline)) + ) + (deftype joint-mod-blend-world (joint-mod-base) + "Blend the _bone_ transform between this one and the animated one." ((transform transformq :inline :offset-assert 16) (blend-transform transformq :inline :offset-assert 64) (blend float :offset-assert 112) @@ -20253,14 +23754,12 @@ :size-assert #x74 :flag-assert #xc00000074 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) + (new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable int symbol float) _type_) ) ) -|# -#| (deftype joint-mod-ik (basic) - ((flags uint8 :offset-assert 4) ;; joint-mod-ik-flags + ((flags joint-mod-ik-flags :offset-assert 4) ;; joint-mod-ik-flags (elbow-pole-vector-axis int8 :offset-assert 5) ;; uint32 (elbow-rotation-axis int8 :offset-assert 6) ;; uint32 (elbow-node int8 :offset-assert 7) @@ -20279,9 +23778,7 @@ (joint-mod-ik-method-10 () none) ;; 10 ;; (enable-set! (_type_ symbol) none) ) ) -|# -#| (deftype ik-limb-setup (structure) ((elbow-index int32 :offset-assert 0) (hand-dist float :offset-assert 4) @@ -20290,54 +23787,63 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| +;; +++joint-mod-h:joint-mod-polar-flags +(defenum joint-mod-polar-flags + :type uint32 + :bitfield #t + (no-z-rot 0) + (blending-to-zero 1) + (negate-nose 2) + (negate-ear 3) + (negate-up 4) + ) +;; ---joint-mod-h:joint-mod-polar-flags + (deftype joint-mod-polar-look-at (basic) - ((flags joint-mod-polar-flags :offset-assert 4) ;; guessed by decompiler - (ear int8 :offset-assert 8) - (up int8 :offset-assert 9) - (nose int8 :offset-assert 10) - (polar-internal-tilt-max float :offset-assert 12) - (polar-internal-radius float :offset-assert 16) - (polar-external-tilt-max float :offset-assert 20) - (polar-external-radius float :offset-assert 24) - (upward-tilt float :offset-assert 28) - (downward-tilt float :offset-assert 32) - (forward-twist float :offset-assert 36) - (backward-twist float :offset-assert 40) - (target vector :inline :offset-assert 48) - (blend-duration uint64 :offset-assert 64) ;; time-frame - (blend-start-time uint64 :offset-assert 72) ;; time-frame - (blend-start-value float :offset-assert 80) - (blend-max float :offset-assert 84) + ((flags joint-mod-polar-flags :offset-assert 4) + (ear int8 :offset-assert 8) + (up int8 :offset-assert 9) + (nose int8 :offset-assert 10) + (polar-internal-tilt-max float :offset-assert 12) + (polar-internal-radius float :offset-assert 16) + (polar-external-tilt-max float :offset-assert 20) + (polar-external-radius float :offset-assert 24) + (upward-tilt float :offset-assert 28) + (downward-tilt float :offset-assert 32) + (forward-twist float :offset-assert 36) + (backward-twist float :offset-assert 40) + (target vector :inline :offset-assert 48) + (blend-duration time-frame :offset-assert 64) + (blend-start-time time-frame :offset-assert 72) + (blend-start-value float :offset-assert 80) + (blend-max float :offset-assert 84) ) :method-count-assert 15 :size-assert #x58 :flag-assert #xf00000058 (:methods - (joint-mod-polar-look-at-method-9 () none) ;; 9 ;; (initialize (_type_ process-drawable int) none) - (joint-mod-polar-look-at-method-10 () none) ;; 10 ;; (set-target! (_type_ vector) none) - (joint-mod-polar-look-at-method-11 () none) ;; 11 ;; (set-both-targets! (_type_ joint-mod-polar-look-at vector) none) - (joint-mod-polar-look-at-method-12 () none) ;; 12 ;; (blend-on! (_type_ time-frame float symbol) none) - (joint-mod-polar-look-at-method-13 () none) ;; 13 ;; (blend-to-off! (_type_ time-frame symbol) none) - (joint-mod-polar-look-at-method-14 () none) ;; 14 ;; (get-start-blend! (_type_) float) + (initialize "Attach joint-mod to process and set defaults." (_type_ process-drawable int) none) ;; 9 + (set-target! "Update the target position." (_type_ vector) none) ;; 10 + (set-both-targets! "Update the target position of this mod, and a second one." (_type_ joint-mod-polar-look-at vector) none) ;; 11 + (blend-on! "Start blending this joint mod on." (_type_ time-frame float symbol) none) ;; 12 + (blend-to-off! "Start blending to disable this joint mod." (_type_ time-frame symbol) none) ;; 13 + (get-start-blend! "Determine what blend to use when starting a new one." (_type_) float) ;; 14 ) ) -|# -;; (define-extern joint-mod-debug-draw function) ;; (function joint-mod none) -;; (define-extern joint-mod-spinner-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-rotate-local-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-trans-rot-local-callback function) -;; (define-extern vector<-cspace2! function) ;; (function vector cspace vector) -;; (define-extern joint-mod-rotate-world-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-set-local-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-add-local-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-set-world-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-set-world-no-trans-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-blend-local-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-blend-world-callback function) ;; (function cspace transformq none) +(define-extern joint-mod-debug-draw (function joint-mod none)) +(define-extern joint-mod-spinner-callback (function cspace transformq none)) +(define-extern joint-mod-rotate-local-callback (function cspace transformq none)) +(define-extern joint-mod-trans-rot-local-callback (function cspace transformq none)) +(define-extern vector<-cspace2! (function vector cspace vector)) +(define-extern joint-mod-rotate-world-callback (function cspace transformq none)) +(define-extern joint-mod-set-local-callback (function cspace transformq none)) +(define-extern joint-mod-add-local-callback (function cspace transformq none)) +(define-extern joint-mod-set-world-callback (function cspace transformq none)) +(define-extern joint-mod-set-world-no-trans-callback (function cspace transformq none)) +(define-extern joint-mod-blend-local-callback (function cspace transformq none)) +(define-extern joint-mod-blend-world-callback (function cspace transformq none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-func-h ;; @@ -20348,9 +23854,9 @@ ;; collide-mesh-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype collide-tri-result (structure) - ((vertex vector 3 :offset-assert 0) ;; guessed by decompiler + "A triangle result of a collision." + ((vertex vector 3 :inline :offset-assert 0) ;; guessed by decompiler (intersect vector :inline :offset-assert 48) (normal vector :inline :offset-assert 64) (pat pat-surface :offset-assert 80) ;; guessed by decompiler @@ -20360,68 +23866,68 @@ :size-assert #x58 :flag-assert #x900000058 ) -|# -#| (deftype collide-mesh-tri (structure) + "A triangle for foreground collision meshes." ((vertex-index uint8 3 :offset-assert 0) ;; guessed by decompiler (unused uint8 :offset-assert 3) (pat pat-surface :offset-assert 4) ;; guessed by decompiler ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| +(declare-type collide-mesh-cache-tri structure) (deftype collide-mesh (basic) + "A collision mesh for foreground objects, + bound to the joint specified by `joint-id`." ((joint-id int32 :offset-assert 4) (num-tris uint32 :offset-assert 8) (num-verts uint32 :offset-assert 12) (vertex-data (inline-array vector) :offset-assert 16) ;; guessed by decompiler - (tris collide-mesh-tri 1 :offset-assert 32) ;; guessed by decompiler + (tris collide-mesh-tri 1 :inline :offset 32) ;; guessed by decompiler ) - :method-count-assert 15 + :method-count-assert 16 :size-assert #x28 - :flag-assert #xf00000028 + :flag-assert #x1000000028 (:methods - (collide-mesh-method-9 () none) ;; 9 ;; (debug-draw-tris (_type_ process-drawable int) none) - (collide-mesh-method-10 () none) ;; 10 ;; (overlap-test (_type_ collide-mesh-cache-tri vector) symbol) - (collide-mesh-method-11 () none) ;; 11 ;; (should-push-away-test (_type_ collide-mesh-cache-tri collide-tri-result vector float) float) - (collide-mesh-method-12 () none) ;; 12 ;; (sphere-on-platform-test (_type_ collide-mesh-cache-tri collide-tri-result vector float) float) - (collide-mesh-method-13 () none) ;; 13 ;; (unpack-mesh-to-cache! (_type_ (inline-array collide-mesh-cache-tri) matrix) none) - (collide-mesh-method-14 () none) ;; 14 ;; (collide-mesh-math-1 (_type_ object object) none) + (debug-draw-tris (_type_ process-drawable int) none) ;; 9 + (overlap-test (_type_ collide-mesh-cache-tri vector) symbol) ;; 10 + (should-push-away-test (_type_ collide-mesh-cache-tri collide-tri-result vector float) float) ;; 11 + (sphere-on-platform-test (_type_ collide-mesh-cache-tri collide-tri-result vector float) float) ;; 12 + (unpack-mesh-to-cache! (_type_ (inline-array collide-mesh-cache-tri) matrix) none) ;; 13 + (collide-mesh-math-1 (_type_ object object) none) ;; 14 + (collide-mesh-math-2 (_type_ object object object) none) ;; 15 ) ) -|# -#| (deftype collide-mesh-cache-tri (structure) - ((vertex vector 3 :offset-assert 0) ;; guessed by decompiler + "A triangle stored in the foreground mesh collide cache." + ((vertex vector 3 :inline :offset-assert 0) ;; guessed by decompiler (normal vector :inline :offset-assert 48) (bbox4w bounding-box4w :inline :offset-assert 64) - (pat pat-surface :offset-assert 60) ;; guessed by decompiler + (pat pat-surface :offset 60 :score 1) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x60 :flag-assert #x900000060 ) -|# -#| (deftype collide-mesh-cache-entry (structure) + "A foreground mesh collide cache entry." ((mat matrix :inline :offset-assert 0) - (tris collide-mesh-cache-tri :dynamic :offset-assert 64) ;; guessed by decompiler + (tris collide-mesh-cache-tri :dynamic :inline :offset-assert 64) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| +(declare-type collide-shape-prim-mesh basic) (deftype collide-mesh-cache (basic) + "A collide cache for foreground meshes." ((used-size uint32 :offset-assert 4) (max-size uint32 :offset-assert 8) (id uint32 :offset-assert 12) @@ -20431,23 +23937,27 @@ :size-assert #xbb90 :flag-assert #xd0000bb90 (:methods - (collide-mesh-cache-method-9 () none) ;; 9 ;; (populate-for-prim-mesh (_type_ collide-shape-prim-mesh) collide-mesh-cache-entry) - (collide-mesh-cache-method-10 () none) ;; 10 ;; (is-id? (_type_ int) symbol) - (collide-mesh-cache-method-11 () none) ;; 11 ;; (next-id! (_type_) uint) - (collide-mesh-cache-method-12 () none) ;; 12 ;; (allocate! (_type_ int) collide-mesh-cache-entry) + (populate-for-prim-mesh (_type_ collide-shape-prim-mesh) collide-mesh-cache-entry) ;; 9 + (is-id? "Does this cache have the given ID?" (_type_ int) symbol) ;; 10 + (next-id! + "Reset all used entries in the cache and increment the ID. + If the id is zero, set it to 1." + (_type_) uint) ;; 11 + (allocate! (_type_ int) collide-mesh-cache-entry) ;; 12 ) ) -|# -;; (define-extern *collide-mesh-cache* object) ;; collide-mesh-cache +(define-extern *collide-mesh-cache* collide-mesh-cache) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-shape-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type collide-shape-prim basic) + (deftype collide-rider (structure) - ((rider-handle uint64 :offset-assert 0) ;; handle + "Something that rides a moving object." + ((rider-handle handle :offset-assert 0) ;; handle (sticky-prim collide-shape-prim :offset-assert 8) ;; guessed by decompiler (prim-ry float :offset-assert 12) (rider-local-pos vector :inline :offset-assert 16) @@ -20456,24 +23966,24 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype collide-rider-pool (basic) + "A pool containing all the riders of an object." ((alloc-count int32 :offset-assert 4) - (riders collide-rider 20 :offset-assert 16) ;; guessed by decompiler + (riders collide-rider 20 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 11 :size-assert #x290 :flag-assert #xb00000290 (:methods - (collide-rider-pool-method-9 () none) ;; 9 ;; (add-rider (_type_ handle) collide-rider) - (collide-rider-pool-method-10 () none) ;; 10 ;; (prepare (_type_) none) + (add-rider (_type_ handle) collide-rider) ;; 9 + (prepare (_type_) none) ;; 10 ) ) -|# -#| +(declare-type collide-shape trsqv) +(declare-type collide-shape-moving collide-shape) + (deftype pull-rider-info (structure) ((rider collide-rider :offset-assert 0) (rider-cshape collide-shape-moving :offset-assert 4) ;; guessed by decompiler @@ -20484,9 +23994,45 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| +;; +++collide-shape-h:overlaps-others-options +(defenum overlaps-others-options + :type uint32 + :bitfield #t + (oo0) + (oo1) + (oo2) + (oo3) + (oo4) + ) +;; ---collide-shape-h:overlaps-others-options + +;; +++collide-shape-h:collide-action +(defenum collide-action + :bitfield #t + :type uint32 + (solid 0) ;; 1 + (semi-solid 1) ;; 2 + (rideable 2) ;; 4 + (can-ride 3) ;; 8 + (dont-push-away 4) ;; 16 + (pull-rider-can-collide 5) ;; 32 + (deadly 6) ;; 64 + (persistent-attack 7) ;; 128 + (no-smack 8) ;; 256 + (no-standon 9) ;; 512 + (block-turn-around 10) ;; 1024 + (check-edge 11) ;; 2048 + (check-stuck 12) ;; 4096 + (stuck-wall-escape 13) ;; 8192 + (no-normal-reset 14) ;; 163884 + (edge-grabbed 15) ;; 32768 + (nav-sphere 16) ;; hi 1 + ) +;; ---collide-shape-h:collide-action + +(declare-type touching-list structure) + (deftype overlaps-others-params (structure) ((options overlaps-others-options :offset-assert 0) ;; guessed by decompiler (collide-with-filter collide-spec :offset-assert 4) ;; guessed by decompiler @@ -20499,9 +24045,7 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype move-above-ground-params (structure) ((gnd-collide-with collide-spec :offset-assert 0) ;; guessed by decompiler (popup float :offset-assert 4) @@ -20519,161 +24063,147 @@ :size-assert #x6c :flag-assert #x90000006c ) -|# -#| (deftype collide-prim-core (structure) + "Collide primitives use this to store their world sphere and their collision flags." ((world-sphere vector :inline :offset-assert 0) (collide-as collide-spec :offset-assert 16) ;; guessed by decompiler (collide-with collide-spec :offset-assert 20) ;; guessed by decompiler (action collide-action :offset-assert 24) ;; guessed by decompiler - (prim-type int8 :offset-assert 28) + (prim-type int8 :offset-assert 28) ;; prim-type (unused1 uint8 3 :offset-assert 29) ;; guessed by decompiler - (quad uint128 2 :offset-assert 0) ;; guessed by decompiler + (quad uint128 2 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| +(declare-type collide-shape trsqv) +(declare-type collide-query structure) +(declare-type collide-cache basic) +(declare-type collide-cache-prim structure) +(declare-type collide-shape-prim-group basic) (deftype collide-shape-prim (basic) + "Base class for collide primitives." ((cshape collide-shape :offset-assert 4) ;; guessed by decompiler (prim-id uint32 :offset-assert 8) (transform-index int8 :offset-assert 12) (unused2 int8 3 :offset-assert 13) ;; guessed by decompiler - (prim-core collide-prim-core :inline :offset-assert 16) - (local-sphere vector :inline :offset-assert 48) - (specific uint8 16 :offset-assert 64) ;; guessed by decompiler - (world-sphere vector :inline :offset-assert 16) - (collide-as collide-spec :offset-assert 32) - (collide-with collide-spec :offset-assert 36) - (action collide-action :offset-assert 40) - (prim-type int8 :offset-assert 44) - (radius meters :offset-assert 60) + (prim-core collide-prim-core :inline :offset 16) + (local-sphere vector :inline :offset 48) + (specific uint8 16 :offset 64 :score -1) ;; guessed by decompiler + (world-sphere vector :inline :offset 16) + (collide-as collide-spec :offset 32) + (collide-with collide-spec :offset 36) + (action collide-action :offset 40) + (prim-type int8 :offset 44) + (radius meters :offset 60) ;; float ) :method-count-assert 20 :size-assert #x50 :flag-assert #x1400000050 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type collide-shape uint int) _type_) - (collide-shape-prim-method-9 () none) ;; 9 ;; (debug-draw (_type_) none) - (collide-shape-prim-method-10 () none) ;; 10 ;; (add-fg-prim-using-box (_type_ collide-cache) none) - (collide-shape-prim-method-11 () none) ;; 11 ;; (add-fg-prim-using-line-sphere (_type_ collide-cache object) none) - (collide-shape-prim-method-12 () none) ;; 12 ;; (overlaps-others-test (_type_ overlaps-others-params collide-shape-prim) symbol) - (collide-shape-prim-method-13 () none) ;; 13 ;; (overlaps-others-group (_type_ overlaps-others-params collide-shape-prim-group) symbol) + (new (symbol type collide-shape uint int) _type_) ;; 0 + (debug-draw (_type_) none) ;; 9 + (add-fg-prim-using-box (_type_ collide-cache) none) ;; 10 + (add-fg-prim-using-line-sphere (_type_ collide-cache object) none) ;; 11 + (overlaps-others-test (_type_ overlaps-others-params collide-shape-prim) symbol) ;; 12 + (overlaps-others-group (_type_ overlaps-others-params collide-shape-prim-group) symbol) ;; 13 (collide-shape-prim-method-14 () none) ;; 14 ;; (collide-shape-prim-method-14 () none) - (collide-shape-prim-method-15 () none) ;; 15 ;; (collide-with-collide-cache-prim-mesh (_type_ collide-query collide-cache-prim) none) - (collide-shape-prim-method-16 () none) ;; 16 ;; (collide-with-collide-cache-prim-sphere (_type_ collide-query collide-cache-prim) none) - (collide-shape-prim-method-17 () none) ;; 17 ;; (on-platform-test (_type_ collide-shape-prim collide-query float) none) - (collide-shape-prim-method-18 () none) ;; 18 ;; (should-push-away-test (_type_ collide-shape-prim collide-query) none) - (collide-shape-prim-method-19 () none) ;; 19 ;; (should-push-away-a-group-test (_type_ collide-shape-prim-group collide-query) none) + (collide-with-collide-cache-prim-mesh (_type_ collide-query collide-cache-prim) none) ;; 15 + (collide-with-collide-cache-prim-sphere (_type_ collide-query collide-cache-prim) none) ;; 16 + (on-platform-test (_type_ collide-shape-prim collide-query float) none) ;; 17 + (should-push-away-test (_type_ collide-shape-prim collide-query) none) ;; 18 + (should-push-away-a-group-test (_type_ collide-shape-prim-group collide-query) none) ;; 19 ) ) -|# -#| (deftype collide-shape-prim-sphere (collide-shape-prim) - ((cshape collide-shape :offset-assert 0) ;; guessed by decompiler - (prim-id uint32 :offset-assert 4) - (transform-index int8 :offset-assert 8) - (unused2 int8 3 :offset-assert 9) ;; guessed by decompiler - (prim-core collide-prim-core :inline :offset-assert 12) - (local-sphere vector :inline :offset-assert 44) - (specific uint8 16 :offset-assert 60) ;; guessed by decompiler - (world-sphere vector :inline :offset-assert 12) - (collide-as collide-spec :offset-assert 28) - (collide-with collide-spec :offset-assert 32) - (action collide-action :offset-assert 36) - (prim-type int8 :offset-assert 40) - (radius meters :offset-assert 56) - (pat pat-surface :offset-assert 60) ;; guessed by decompiler - (nav-radius float :offset-assert 64) - (line-sphere-count int8 :offset-assert 68) - (line-sphere-prim-id int8 :offset-assert 69) + "A sphere primitive for collide shapes." + ((pat pat-surface :offset 64) ;; guessed by decompiler + (nav-radius float :offset 68) + (line-sphere-count int8 :offset 72) + (line-sphere-prim-id int8 :offset 73) ) :method-count-assert 20 :size-assert #x50 :flag-assert #x1400000050 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type collide-shape uint) _type_) + (new (symbol type collide-shape uint) _type_) ;; 0 ) ) -|# -#| (deftype collide-shape-prim-mesh (collide-shape-prim) - ((cshape collide-shape :offset-assert 0) ;; guessed by decompiler - (prim-id uint32 :offset-assert 4) - (transform-index int8 :offset-assert 8) - (unused2 int8 3 :offset-assert 9) ;; guessed by decompiler - (prim-core collide-prim-core :inline :offset-assert 12) - (local-sphere vector :inline :offset-assert 44) - (specific uint8 16 :offset-assert 60) ;; guessed by decompiler - (world-sphere vector :inline :offset-assert 12) - (collide-as collide-spec :offset-assert 28) - (collide-with collide-spec :offset-assert 32) - (action collide-action :offset-assert 36) - (prim-type int8 :offset-assert 40) - (radius meters :offset-assert 56) - (mesh collide-mesh :offset-assert 60) ;; guessed by decompiler - (mesh-id int32 :offset-assert 64) - (mesh-cache-id uint32 :offset-assert 68) - (mesh-cache-entry collide-mesh-cache-entry :offset-assert 72) + "A mesh primitive for collide shapes." + ((mesh collide-mesh :offset 64) ;; guessed by decompiler + (mesh-id int32 :offset 68) + (mesh-cache-id uint32 :offset 72) + (mesh-cache-entry collide-mesh-cache-entry :offset 76) ) :method-count-assert 20 :size-assert #x50 :flag-assert #x1400000050 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type collide-shape uint uint) _type_) + (new (symbol type collide-shape uint uint) _type_) ;; 0 ) ) -|# -#| (deftype collide-shape-prim-group (collide-shape-prim) - ((cshape collide-shape :offset-assert 0) ;; guessed by decompiler - (prim-id uint32 :offset-assert 4) - (transform-index int8 :offset-assert 8) - (unused2 int8 3 :offset-assert 9) ;; guessed by decompiler - (prim-core collide-prim-core :inline :offset-assert 12) - (local-sphere vector :inline :offset-assert 44) - (specific uint8 16 :offset-assert 60) ;; guessed by decompiler - (world-sphere vector :inline :offset-assert 12) - (collide-as collide-spec :offset-assert 28) - (collide-with collide-spec :offset-assert 32) - (action collide-action :offset-assert 36) - (prim-type int8 :offset-assert 40) - (radius meters :offset-assert 56) - (num-children uint8 :offset-assert 60) - (num-alloc-children uint8 :offset-assert 61) - (child (inline-array collide-shape-prim) :offset-assert 64) ;; guessed by decompiler + "A group of collide primitives." + ((num-children uint8 :offset 64) + (num-alloc-children uint8 :offset 65) + (child (inline-array collide-shape-prim) :offset 68) ;; guessed by decompiler ) :method-count-assert 20 :size-assert #x50 :flag-assert #x1400000050 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type collide-shape uint int) _type_) + (new (symbol type collide-shape uint int) _type_) ;; 0 ) ) -|# -#| +;; +++collide-shape-h:collide-list-enum +(defenum collide-list-enum + (hit-by-player) + (usually-hit-by-player) + (hit-by-others) + (player) + ) +;; ---collide-shape-h:collide-list-enum + +;; +++collide-shape-h:nav-flags +(defenum nav-flags + :type uint8 + :bitfield #t + (has-root-sphere 0) + (has-extra-sphere 1) + (has-child-spheres 2) + ) +;; ---collide-shape-h:nav-flags + +(declare-type collide-query structure) +(declare-type water-info structure) +(declare-type touching-shapes-entry structure) (deftype collide-shape (trsqv) - ((actor-hash-index int16 :offset-assert 12) + "The parent of all of an object's collide primitives. + Most [[process-drawable]]s have a [[collide-shape]] that represents their root transform." + ((actor-hash-index int16 :offset 12) (process process-drawable :offset-assert 140) ;; guessed by decompiler (max-iteration-count uint8 :offset-assert 144) - (nav-flags uint8 :offset-assert 145) ;; nav-flags + (nav-flags nav-flags :offset-assert 145) ;; nav-flags (total-prims uint8 :offset-assert 146) (num-riders uint8 :offset-assert 147) - (event-self symbol :offset-assert 152) ;; guessed by decompiler + (pat-ignore-mask pat-surface :offset-assert 148) ;; somehow is missing from inspect?? + (event-self symbol :offset 152) ;; guessed by decompiler (event-other symbol :offset-assert 156) ;; guessed by decompiler (root-prim collide-shape-prim :offset-assert 160) ;; guessed by decompiler (riders (inline-array collide-rider) :offset-assert 164) ;; guessed by decompiler (penetrate-using penetrate :offset-assert 168) (penetrated-by penetrate :offset-assert 176) - (event-priority uint8 :offset-assert 192) + (backup-collide-as collide-spec :offset-assert 184) ;; added (enter process-drawable-art-error) + (backup-collide-with collide-spec :offset-assert 188) ;; added (enter process-drawable-art-error) + (event-priority uint8 :offset 192) (rider-max-momentum float :offset-assert 196) ) :method-count-assert 55 @@ -20681,48 +24211,72 @@ :flag-assert #x37000000c8 ;; field penetrate is likely a value type. field penetrate is likely a value type. (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable collide-list-enum) _type_) - (collide-shape-method-28 () none) ;; 28 ;; (move-by-vector! (_type_ vector) none) - (collide-shape-method-29 () none) ;; 29 ;; (move-to-point! (_type_ vector) none) - (collide-shape-method-30 () none) ;; 30 ;; (debug-draw (_type_) none) - (collide-shape-method-31 () none) ;; 31 ;; (fill-cache-for-shape (_type_ float collide-query) none) - (collide-shape-method-32 () none) ;; 32 ;; (fill-cache-integrate-and-collide (_type_ vector collide-query meters) none) - (collide-shape-method-33 () none) ;; 33 ;; (find-prim-by-id (_type_ uint) collide-shape-prim) - (collide-shape-method-34 () none) ;; 34 ;; (find-prim-by-id-logtest (_type_ uint) collide-shape-prim) - (collide-shape-method-35 () none) ;; 35 ;; (detect-riders! (_type_) symbol) - (collide-shape-method-36 () none) ;; 36 ;; (build-bounding-box-for-shape (_type_ bounding-box float collide-spec) symbol) - (collide-shape-method-37 () none) ;; 37 ;; (integrate-and-collide! (_type_ vector) none) - (collide-shape-method-38 () none) ;; 38 ;; (find-collision-meshes (_type_) none) - (collide-shape-method-39 () none) ;; 39 ;; (on-platform (_type_ collide-shape collide-query) symbol) - (collide-shape-method-40 () none) ;; 40 ;; (find-overlapping-shapes (_type_ overlaps-others-params) symbol) - (collide-shape-method-41 () none) ;; 41 ;; (shove-to-closest-point-on-path (_type_ attack-info float) vector) - (collide-shape-method-42 () none) ;; 42 ;; (should-push-away (_type_ collide-shape collide-query) symbol) - (collide-shape-method-43 () none) ;; 43 ;; (pull-rider! (_type_ pull-rider-info) none) - (collide-shape-method-44 () none) ;; 44 ;; (pull-riders! (_type_) symbol) - (collide-shape-method-45 () none) ;; 45 ;; (do-push-aways (_type_) collide-spec) - (collide-shape-method-46 () none) ;; 46 ;; (update-transforms (_type_) none) - (collide-shape-method-47 () none) ;; 47 ;; (set-collide-with! (_type_ collide-spec) none) - (collide-shape-method-48 () none) ;; 48 ;; (set-collide-as! (_type_ collide-spec) none) - (collide-shape-method-49 () none) ;; 49 ;; (modify-collide-as! (_type_ int collide-spec collide-spec) none) - (collide-shape-method-50 () none) ;; 50 ;; (send-shoves (_type_ process touching-shapes-entry float float float) symbol) - (collide-shape-method-51 () none) ;; 51 ;; (above-ground? (_type_ collide-query vector collide-spec float float float) symbol) - (collide-shape-method-52 () none) ;; 52 ;; (water-info-init! (_type_ water-info collide-action) water-info) - (collide-shape-method-53 () none) ;; 53 ;; (iterate-prims (_type_ (function collide-shape-prim none)) none) - (collide-shape-method-54 () none) ;; 54 ;; (pusher-init (_type_) none) + (new (symbol type process-drawable collide-list-enum) _type_) ;; 0 + (move-by-vector! (_type_ vector) none) ;; 28 + (move-to-point! (_type_ vector) none) ;; 29 + (debug-draw (_type_) none) ;; 30 + (fill-cache-for-shape (_type_ float collide-query) none) ;; 31 + (fill-cache-integrate-and-collide (_type_ vector collide-query meters) none) ;; 32 + (find-prim-by-id (_type_ uint) collide-shape-prim) ;; 33 + (find-prim-by-id-logtest (_type_ uint) collide-shape-prim) ;; 34 + (detect-riders! (_type_) symbol) ;; 35 + (build-bounding-box-for-shape (_type_ bounding-box float collide-spec) symbol) ;; 36 + (integrate-and-collide! (_type_ vector) none) ;; 37 + (find-collision-meshes (_type_) none) ;; 38 + (on-platform (_type_ collide-shape collide-query) symbol) ;; 39 + (find-overlapping-shapes (_type_ overlaps-others-params) symbol) ;; 40 + (shove-to-closest-point-on-path (_type_ attack-info float) vector) ;; 41 + (should-push-away (_type_ collide-shape collide-query) symbol) ;; 42 + (pull-rider! (_type_ pull-rider-info) none) ;; 43 + (pull-riders! (_type_) symbol) ;; 44 + (do-push-aways (_type_) collide-spec) ;; 45 + (update-transforms (_type_) none) ;; 46 + (set-collide-with! (_type_ collide-spec) none) ;; 47 + (set-collide-as! (_type_ collide-spec) none) ;; 48 + (modify-collide-as! (_type_ int collide-spec collide-spec) none) ;; 49 + (send-shoves (_type_ process touching-shapes-entry float float float) symbol) ;; 50 + (above-ground? (_type_ collide-query vector collide-spec float float float) symbol) ;; 51 + (water-info-init! (_type_ water-info collide-action) water-info) ;; 52 + (iterate-prims (_type_ (function collide-shape-prim none)) none) ;; 53 + (pusher-init (_type_) none) ;; 54 ) ) -|# -#| +;; +++collide-shape-h:collide-status +(defenum collide-status + :bitfield #t + :type uint64 + (on-surface 0) + (on-ground 1) + (touch-surface 2) + (touch-wall 3) + (touch-ceiling 4) + (touch-actor 5) + (on-special-surface 6) + (touch-edge 7) + (no-touch 8) + (blocked 9) + (on-water 10) + (impact-surface 11) + (touch-background 12) + (stuck 13) + (touch-ceiling-sticky 14) + (glance 15) + (probe-hit 16) + ) +;; ---collide-shape-h:collide-status + +(declare-type control-info collide-shape-moving) (deftype collide-shape-moving (collide-shape) + "A [[collide-shape]] for moving objects." ((rider-time uint64 :offset-assert 200) ;; time-frame (rider-last-move vector :inline :offset-assert 208) (trans-old vector :inline :offset-assert 224) - (poly-pat pat-surface :offset-assert 272) ;; guessed by decompiler + (poly-pat pat-surface :offset 272) ;; guessed by decompiler (cur-pat pat-surface :offset-assert 276) ;; guessed by decompiler (ground-pat pat-surface :offset-assert 280) ;; guessed by decompiler (status uint64 :offset-assert 288) ;; collide-status - (reaction (function control-info collide-query vector vector collide-status) :offset-assert 316) ;; guessed by decompiler + (reaction (function control-info collide-query vector vector collide-status) :offset 316) ;; guessed by decompiler (no-reaction (function collide-shape-moving collide-query vector vector object) :offset-assert 320) ;; guessed by decompiler (local-normal vector :inline :offset-assert 336) (surface-normal vector :inline :offset-assert 352) @@ -20743,7 +24297,7 @@ :flag-assert #x43000001d8 ;; field penetrate is likely a value type. field penetrate is likely a value type. (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable collide-list-enum) _type_) + (new (symbol type process-drawable collide-list-enum) _type_) ;; 0 (collide-shape-moving-method-55 () none) ;; 55 ;; (find-ground (_type_ collide-query collide-spec float float float process) symbol) (collide-shape-moving-method-56 () none) ;; 56 ;; (react-to-pat! (_type_ pat-surface) cshape-reaction-flags) (collide-shape-moving-method-57 () none) ;; 57 ;; (integrate-no-collide! (_type_ vector) none) @@ -20758,21 +24312,31 @@ (collide-shape-moving-method-66 () none) ;; 66 ;; (step-collision! (_type_ vector vector float int) float) ) ) -|# -;; (define-extern *collide-hit-by-player-list* object) ;; engine -;; (define-extern *collide-hit-by-others-list* object) ;; engine -;; (define-extern *collide-player-list* object) ;; engine -;; (define-extern *collide-shape-prim-backgnd* collide-shape-prim-mesh) ;; collide-shape-prim-mesh -;; (define-extern *collide-shape-prim-water* collide-shape-prim-mesh) ;; collide-shape-prim-mesh -;; (define-extern *collide-shape-prim-nav-mesh* collide-shape-prim-mesh) -;; (define-extern *collide-rider-pool* object) ;; collide-rider-pool +(define-extern *collide-hit-by-player-list* engine) +(define-extern *collide-hit-by-others-list* engine) +(define-extern *collide-player-list* engine) +(define-extern *collide-shape-prim-backgnd* collide-shape-prim-mesh) +(define-extern *collide-shape-prim-water* collide-shape-prim-mesh) +(define-extern *collide-shape-prim-nav-mesh* collide-shape-prim-mesh) +(define-extern *collide-rider-pool* collide-rider-pool) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-obs-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++generic-obs-h:manipy-options +(defenum manipy-options + :bitfield #t + :type uint32 + (mo0 0) + (mo1 1) + (mo2 2) + (mo3 3) + (mo4 4) + ) +;; ---generic-obs-h:manipy-options + (deftype manipy (process-drawable) ((new-trans-hook (function none) :offset-assert 248) ;; guessed by decompiler (cur-trans-hook (function none) :offset-assert 252) ;; guessed by decompiler @@ -20805,10 +24369,9 @@ (manipy-method-50 () none) ;; 50 ) ) -|# -#| (deftype part-spawner (process) + "A process that spawns a specified particle group." ((root trsqv :offset-assert 144) ;; guessed by decompiler (part sparticle-launch-control :offset-assert 148) ;; guessed by decompiler (path path-control :offset-assert 152) ;; guessed by decompiler @@ -20826,19 +24389,11 @@ :size-assert #xf0 :flag-assert #x11006000f0 (:methods - (part-spawner-method-9 () none) ;; 9 - (part-spawner-method-10 () none) ;; 10 - (part-spawner-method-11 () none) ;; 11 - (part-spawner-method-12 () none) ;; 12 - (part-spawner-method-13 () none) ;; 13 - (part-spawner-method-14 () none) ;; 14 ;; (active () _type_ :state) - (part-spawner-method-15 () none) ;; 15 ;; (is-in-view? (_type_) symbol) - (part-spawner-method-16 () none) ;; 16 + (part-spawner-method-15 () none) ;; 14 ;; (active () _type_ :state) + (part-spawner-method-16 () none) ;; 15 ;; (is-in-view? (_type_) symbol) ) ) -|# -#| (deftype part-tracker (process) ((root trsqv :offset-assert 144) ;; guessed by decompiler (mat matrix :inline :offset-assert 160) @@ -20847,7 +24402,7 @@ (userdata uint64 :offset-assert 256) (user-time time-frame 2 :offset-assert 264) ;; guessed by decompiler (user-vector vector :inline :offset-assert 288) - (user-handle uint32 2 :offset-assert 320) ;; guessed by decompiler + (user-handle uint32 2 :offset 320) ;; guessed by decompiler (part sparticle-launch-control :offset-assert 328) ;; guessed by decompiler (callback (function part-tracker vector) :offset-assert 332) ;; guessed by decompiler (linger-callback (function part-tracker vector) :offset-assert 336) ;; guessed by decompiler @@ -20862,26 +24417,18 @@ :flag-assert #x1300f0017c ;; field userdata uses ~A with a 64-bit load. (:methods - (part-tracker-method-9 () none) ;; 9 - (part-tracker-method-10 () none) ;; 10 - (part-tracker-method-11 () none) ;; 11 - (part-tracker-method-12 () none) ;; 12 - (part-tracker-method-13 () none) ;; 13 - (part-tracker-method-14 () none) ;; 14 ;; (active () _type_ :state) - (part-tracker-method-15 () none) ;; 15 ;; (linger () _type_ :state) + (part-tracker-method-15 () none) ;; 14 ;; (active () _type_ :state) 15 ;; (linger () _type_ :state) (part-tracker-method-16 () none) ;; 16 ;; (die () _type_ :state) (part-tracker-method-17 () none) ;; 17 ;; (notify-parent-of-death (_type_) none) (part-tracker-method-18 () none) ;; 18 ) ) -|# -#| (deftype part-tracker-init-params (structure) ((local-offset vector :inline :offset-assert 0) (userdata uint64 :offset-assert 16) - (duration time-frame :offset-assert 24) ;; guessed by decompiler - (local-space-param int32 :offset-assert 28) + (duration uint32 :offset-assert 24) ;; guessed by decompiler + (local-space-param int32 :offset 28) (group sparticle-launch-group :offset-assert 32) ;; guessed by decompiler (callback (function part-tracker vector) :offset-assert 36) ;; guessed by decompiler (local-space-callback basic :offset-assert 40) @@ -20894,9 +24441,9 @@ :flag-assert #x900000038 ;; field userdata uses ~A with a 64-bit load. field mat-joint uses ~A with a signed load. ) -|# -#| +(declare-type sparticle-subsampler basic) + (deftype part-tracker-subsampler (part-tracker) ((subsampler sparticle-subsampler :offset-assert 380) ;; guessed by decompiler ) @@ -20904,9 +24451,7 @@ :size-assert #x180 :flag-assert #x1300f00180 ) -|# -#| (deftype lightning-tracker (process) ((root trsqv :offset-assert 144) ;; guessed by decompiler (lightning lightning-control :offset-assert 148) ;; guessed by decompiler @@ -20923,27 +24468,19 @@ (userdata uint64 :offset-assert 240) (user-time time-frame 2 :offset-assert 248) ;; guessed by decompiler (user-vector vector :inline :offset-assert 272) - (user-handle handle 2 :offset-assert 304) ;; guessed by decompiler + (user-handle handle 2 :offset 304) ;; guessed by decompiler ) :method-count-assert 18 :size-assert #x140 :flag-assert #x1200b00140 ;; field userdata uses ~A with a 64-bit load. (:methods - (lightning-tracker-method-9 () none) ;; 9 - (lightning-tracker-method-10 () none) ;; 10 - (lightning-tracker-method-11 () none) ;; 11 - (lightning-tracker-method-12 () none) ;; 12 - (lightning-tracker-method-13 () none) ;; 13 - (lightning-tracker-method-14 () none) ;; 14 ;; (active () _type_ :state) - (lightning-tracker-method-15 () none) ;; 15 ;; (notify-parent-of-death (_type_) none) + (lightning-tracker-method-15 () none) ;; 14 ;; (active () _type_ :state) 15 ;; (notify-parent-of-death (_type_) none) (lightning-tracker-method-16 () none) ;; 16 ;; (update (_type_) none) (lightning-tracker-method-17 () none) ;; 17 ) ) -|# -#| (deftype touch-tracker (process-drawable) ((duration uint64 :offset-assert 248) ;; time-frame (target uint64 :offset-assert 256) ;; handle @@ -20959,9 +24496,7 @@ (touch-tracker-method-50 () none) ;; 50 ) ) -|# -#| (deftype gui-query (structure) ((x-position int32 :offset-assert 0) (y-position int32 :offset-assert 4) @@ -20979,9 +24514,7 @@ (gui-query-method-10 () none) ;; 10 ;; (gui-query-method-10 () none) ) ) -|# -#| (deftype othercam (process) ((hand uint64 :offset-assert 144) ;; handle (old-global-mask process-mask :offset-assert 152) ;; guessed by decompiler @@ -20999,21 +24532,11 @@ :method-count-assert 15 :size-assert #xe8 :flag-assert #xf006000e8 - (:methods - (othercam-method-9 () none) ;; 9 - (othercam-method-10 () none) ;; 10 - (othercam-method-11 () none) ;; 11 - (othercam-method-12 () none) ;; 12 - (othercam-method-13 () none) ;; 13 - (othercam-method-14 () none) ;; 14 - ) (:states othercam-running ;; associated process guessed by decompiler, old: (state othercam) ) ) -|# -#| (deftype explosion-init-params (structure) ((spawn-point vector :inline :offset-assert 0) (spawn-quat quaternion :inline :offset-assert 16) @@ -21036,9 +24559,7 @@ :size-assert #x71 :flag-assert #x900000071 ) -|# -#| (deftype explosion (process-drawable) ((start-time uint64 :offset-assert 248) ;; time-frame (duration uint32 :offset-assert 256) @@ -21059,59 +24580,17 @@ (explosion-method-52 () none) ;; 52 ) ) -|# -#| (deftype process-hidden (process) - ((name string :offset-assert 0) ;; guessed by decompiler - (mask process-mask :offset-assert 4) - (clock clock :offset-assert 8) ;; guessed by decompiler - (view basic :offset-assert 12) - (parent (pointer process-tree) :offset-assert 16) ;; guessed by decompiler - (brother (pointer process-tree) :offset-assert 20) ;; guessed by decompiler - (child (pointer process-tree) :offset-assert 24) ;; guessed by decompiler - (ppointer (pointer process) :offset-assert 28) ;; guessed by decompiler - (self process :offset-assert 32) ;; guessed by decompiler - (profile-ticks uint32 :offset-assert 36) - (pool dead-pool :offset-assert 40) ;; guessed by decompiler - (status symbol :offset-assert 44) ;; guessed by decompiler - (pid int32 :offset-assert 48) - (main-thread cpu-thread :offset-assert 52) ;; guessed by decompiler - (top-thread cpu-thread :offset-assert 56) ;; guessed by decompiler - (entity entity-actor :offset-assert 60) ;; guessed by decompiler - (level level :offset-assert 64) ;; guessed by decompiler - (state state :offset-assert 68) ;; guessed by decompiler - (prev-state state :offset-assert 72) ;; guessed by decompiler - (next-state state :offset-assert 76) ;; guessed by decompiler - (state-stack (array state) :offset-assert 80) ;; guessed by decompiler - (trans-hook function :offset-assert 84) ;; guessed by decompiler - (post-hook function :offset-assert 88) ;; guessed by decompiler - (event-hook (function process int symbol event-message-block object) :offset-assert 92) ;; guessed by decompiler - (allocated-length int32 :offset-assert 96) - (heap-base pointer :offset-assert 108) ;; guessed by decompiler - (heap-top pointer :offset-assert 112) ;; guessed by decompiler - (heap-cur pointer :offset-assert 116) ;; guessed by decompiler - (stack-frame-top stack-frame :offset-assert 120) ;; guessed by decompiler - (heap kheap :inline :offset-assert 108) - (connection-list connectable :inline :offset-assert 124) - (stack uint8 :dynamic :offset-assert 140) ;; guessed by decompiler - ) + () :method-count-assert 16 :size-assert #x90 :flag-assert #x1000000090 - (:methods - (process-hidden-method-9 () none) ;; 9 - (process-hidden-method-10 () none) ;; 10 - (process-hidden-method-11 () none) ;; 11 - (process-hidden-method-12 () none) ;; 12 - (process-hidden-method-13 () none) ;; 13 - (process-hidden-method-14 () none) ;; 14 ;; (die () _type_ :state) - (process-hidden-method-15 () none) ;; 15 + (:state-methods + die ) ) -|# -#| (deftype simple-prim (process-drawable) ((strip prim-strip :offset-assert 248) ;; guessed by decompiler ) @@ -21127,9 +24606,23 @@ (simple-prim-method-55 () none) ;; 55 ) ) -|# -#| +;; +++generic-obs-h:task-arrow-flags +(defenum task-arrow-flags + :type uint32 + :bitfield #t + (taf0 0) + (taf1 1) + (taf2 2) + (taf3 3) + (taf4 4) + (taf5 5) + (taf6 6) + (taf7 7) + (taf8 8) + ) +;; ---generic-obs-h:task-arrow-flags + (deftype task-arrow-params (structure) ((flags task-arrow-flags :offset-assert 0) ;; guessed by decompiler (map-icon uint16 :offset-assert 4) @@ -21141,9 +24634,7 @@ :size-assert #x34 :flag-assert #x900000034 ) -|# -#| (deftype external-camera-controller (process) ((pause-time uint64 :offset-assert 144) ;; time-frame (blur symbol :offset-assert 152) ;; guessed by decompiler @@ -21151,27 +24642,19 @@ :method-count-assert 16 :size-assert #x9c :flag-assert #x100010009c - (:methods - (external-camera-controller-method-9 () none) ;; 9 - (external-camera-controller-method-10 () none) ;; 10 - (external-camera-controller-method-11 () none) ;; 11 - (external-camera-controller-method-12 () none) ;; 12 - (external-camera-controller-method-13 () none) ;; 13 - (external-camera-controller-method-14 () none) ;; 14 ;; (active () _type_ :state) - (external-camera-controller-method-15 () none) ;; 15 + (:state-methods + active ) ) -|# -;; (define-extern *simple-prim-additive* object) ;; gs-alpha -;; (define-extern *simple-prim-alpha-blend* object) ;; gs-alpha -;; (define-extern *simple-prim-subtractive* object) ;; gs-alpha +(define-extern *simple-prim-additive* gs-alpha) +(define-extern *simple-prim-alpha-blend* gs-alpha) +(define-extern *simple-prim-subtractive* gs-alpha) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; trajectory-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype trajectory (structure) ((initial-position vector :inline :offset-assert 0) (initial-velocity vector :inline :offset-assert 16) @@ -21182,75 +24665,66 @@ :size-assert #x28 :flag-assert #x1200000028 (:methods - (trajectory-method-9 () none) ;; 9 ;; (compute-trans-at-time (_type_ float vector) vector) - (trajectory-method-10 () none) ;; 10 ;; (compute-transv-at-time (_type_ float vector) vector) - (trajectory-method-11 () none) ;; 11 ;; (compute-time-until-apex (_type_) float) - (trajectory-method-12 () none) ;; 12 ;; (setup-from-to-duration! (_type_ vector vector float float) none) - (trajectory-method-13 () none) ;; 13 ;; (setup-from-to-xz-vel! (_type_ vector vector float float) none) - (trajectory-method-14 () none) ;; 14 ;; (setup-from-to-y-vel! (_type_ vector vector float float) none) - (trajectory-method-15 () none) ;; 15 ;; (setup-from-to-height! (_type_ vector vector float float) none) - (trajectory-method-16 () none) ;; 16 ;; (setup-from-to-duration-and-height! (_type_ vector vector float float) none) - (trajectory-method-17 () none) ;; 17 ;; (debug-draw (_type_) none) + (compute-trans-at-time (_type_ float vector) vector) ;; 9 + (compute-transv-at-time (_type_ float vector) vector) ;; 10 + (compute-time-until-apex (_type_) float) ;; 11 + (setup-from-to-duration! (_type_ vector vector float float) none) ;; 12 + (setup-from-to-xz-vel! (_type_ vector vector float float) none) ;; 13 + (setup-from-to-y-vel! (_type_ vector vector float float) none) ;; 14 + (setup-from-to-height! (_type_ vector vector float float) none) ;; 15 + (setup-from-to-duration-and-height! (_type_ vector vector float float) none) ;; 16 + (debug-draw (_type_) none) ;; 17 ) ) -|# -#| (deftype impact-control (structure) ((process (pointer process-drawable) :offset-assert 0) ;; guessed by decompiler - (radius meters :offset-assert 4) + (radius meters :offset-assert 4) ;; float (joint int32 :offset-assert 8) (collide-with collide-spec :offset-assert 12) ;; guessed by decompiler - (start-time uint64 :offset-assert 16) - (trans vector 2 :offset-assert 32) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (start-time uint64 :offset-assert 16) ;; time-frame + (trans vector 2 :inline :offset-assert 32) ;; guessed by decompiler (dir vector :inline :offset-assert 64) ) :method-count-assert 12 :size-assert #x50 :flag-assert #xc00000050 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable int float collide-spec) _type_) - (impact-control-method-9 () none) ;; 9 ;; (initialize (_type_ process-drawable int float collide-spec) impact-control) - (impact-control-method-10 () none) ;; 10 ;; (update-from-cspace (_type_) none) - (impact-control-method-11 () none) ;; 11 ;; (impact-control-method-11 (_type_ collide-query process pat-surface) float) + (new (symbol type process-drawable int float collide-spec) _type_) ;; 0 + (initialize (_type_ process-drawable int float collide-spec) impact-control) ;; 9 + (update-from-cspace (_type_) none) ;; 10 + (impact-control-method-11 (_type_ collide-query process pat-surface) float) ;; 11 ) ) -|# -#| (deftype point-tracker (structure) - ((trans vector 2 :offset-assert 0) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((trans vector 2 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 12 :size-assert #x20 :flag-assert #xc00000020 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type vector vector) _type_) - (point-tracker-method-9 () none) ;; 9 ;; (initialize (_type_ vector vector) point-tracker) - (point-tracker-method-10 () none) ;; 10 ;; (point-tracker-method-10 (_type_ vector vector vector float) vector) - (point-tracker-method-11 () none) ;; 11 ;; (point-tracker-method-11 (_type_ vector vector vector float) vector) + (new (symbol type vector vector) _type_) ;; 0 + (initialize (_type_ vector vector) point-tracker) ;; 9 + (point-tracker-method-10 (_type_ vector vector vector float) vector) ;; 10 + (point-tracker-method-11 (_type_ vector vector vector float) vector) ;; 11 ) ) -|# -#| +(declare-type process-focusable process-drawable) (deftype combo-tracker (point-tracker) - ((target uint64 :offset-assert 32) ;; handle - (move-start-time uint64 :offset-assert 40) ;; time-frame + ((target handle :offset-assert 32) ;; handle + (move-start-time time-frame :offset-assert 40) ;; time-frame ) :method-count-assert 14 :size-assert #x30 :flag-assert #xe00000030 (:methods - (combo-tracker-method-12 () none) ;; 12 ;; (combo-tracker-method-12 (_type_ vector vector process time-frame) combo-tracker) - (combo-tracker-method-13 () none) ;; 13 ;; (combo-tracker-method-13 (_type_ handle vector float vector float) process-focusable) + (combo-tracker-method-12 (_type_ vector vector process time-frame) combo-tracker) ;; 12 + (combo-tracker-method-13 (_type_ handle vector float vector float) process-focusable) ;; 13 ) ) -|# -#| (deftype traj2d-params (structure) ((x float :offset-assert 0) (y float :offset-assert 4) @@ -21263,9 +24737,7 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype traj3d-params (structure) ((gravity float :offset-assert 0) (initial-tilt float :offset-assert 4) @@ -21280,32 +24752,31 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype cubic-curve (structure) ((mat matrix :inline :offset-assert 0) + (vec vector 4 :inline :offset 0 :score 1) ;; added ) :method-count-assert 14 :size-assert #x40 :flag-assert #xe00000040 (:methods - (cubic-curve-method-9 () none) ;; 9 ;; (cubic-curve-method-9 (_type_ vector vector vector vector) none) - (cubic-curve-method-10 () none) ;; 10 ;; (cubic-curve-method-10 (_type_ vector float) vector) - (cubic-curve-method-11 () none) ;; 11 ;; (cubic-curve-method-11 (_type_ vector float) vector) - (cubic-curve-method-12 () none) ;; 12 ;; (cubic-curve-method-12 (_type_ vector float) vector) - (cubic-curve-method-13 () none) ;; 13 ;; (debug-draw-curve (_type_) none) + (cubic-curve-method-9 (_type_ vector vector vector vector) none) ;; 9 + (cubic-curve-method-10 (_type_ vector float) vector) ;; 10 + (cubic-curve-method-11 (_type_ vector float) vector) ;; 11 + (cubic-curve-method-12 (_type_ vector float) vector) ;; 12 + (debug-draw-curve (_type_) none) ;; 13 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-touch-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype touching-prim (structure) + "A collide primitive that's touching another. + Potentially also stores the triangle that is involved." ((cprim collide-shape-prim :offset-assert 0) ;; guessed by decompiler (has-tri? symbol :offset-assert 4) ;; guessed by decompiler (tri collide-tri-result :inline :offset-assert 16) @@ -21314,10 +24785,9 @@ :size-assert #x68 :flag-assert #x900000068 ) -|# -#| (deftype touching-prims-entry (structure) + "A record of two primitives touching." ((next touching-prims-entry :offset-assert 0) (prev touching-prims-entry :offset-assert 4) (allocated? symbol :offset-assert 8) ;; guessed by decompiler @@ -21329,105 +24799,147 @@ :size-assert #xe8 :flag-assert #xd000000e8 (:methods - (touching-prims-entry-method-9 () none) ;; 9 ;; (touching-prims-entry-method-9 (_type_ vector) vector) - (touching-prims-entry-method-10 () none) ;; 10 ;; (get-middle-of-bsphere-overlap (_type_ vector) vector) - (touching-prims-entry-method-11 () none) ;; 11 ;; (get-touched-prim (_type_ collide-shape touching-shapes-entry) collide-shape-prim) - (touching-prims-entry-method-12 () none) ;; 12 ;; (get-touched-tri (_type_ collide-shape touching-shapes-entry) collide-tri-result) + (touching-prims-entry-method-9 (_type_ vector) vector) ;; 9 + (get-middle-of-bsphere-overlap (_type_ vector) vector) ;; 10 + (get-touched-prim (_type_ collide-shape touching-shapes-entry) collide-shape-prim) ;; 11 + (get-touched-tri (_type_ collide-shape touching-shapes-entry) collide-tri-result) ;; 12 ) ) -|# -#| (deftype touching-prims-entry-pool (structure) + "A pool of up to 64 touching prim records." ((head touching-prims-entry :offset-assert 0) - (nodes touching-prims-entry 64 :offset-assert 16) ;; guessed by decompiler + (nodes touching-prims-entry 64 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 13 :size-assert #x3c10 :flag-assert #xd00003c10 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) - (touching-prims-entry-pool-method-9 () none) ;; 9 ;; (alloc-node (_type_) touching-prims-entry) - (touching-prims-entry-pool-method-10 () none) ;; 10 ;; (get-free-node-count (_type_) int) - (touching-prims-entry-pool-method-11 () none) ;; 11 ;; (init-list! (_type_) none) - (touching-prims-entry-pool-method-12 () none) ;; 12 ;; (free-node (_type_ touching-prims-entry) touching-prims-entry) + (new (symbol type) _type_) ;; 0 + (alloc-node (_type_) touching-prims-entry) ;; 9 + (get-free-node-count (_type_) int) ;; 10 + (init-list! (_type_) none) ;; 11 + (free-node (_type_ touching-prims-entry) touching-prims-entry) ;; 12 ) ) -|# -#| (deftype touching-shapes-entry (structure) + "A record of two collide shapes touching, + storing a record of the primitives involved." ((cshape1 collide-shape :offset-assert 0) ;; guessed by decompiler (cshape2 collide-shape :offset-assert 4) ;; guessed by decompiler (resolve-u int8 :offset-assert 8) (head touching-prims-entry :offset-assert 12) - (handle1 uint64 :offset-assert 16) ;; handle - (handle2 uint64 :offset-assert 24) ;; handle + (handle1 handle :offset-assert 16) ;; handle + (handle2 handle :offset-assert 24) ;; handle ) + :pack-me :method-count-assert 15 :size-assert #x20 :flag-assert #xf00000020 (:methods - (touching-shapes-entry-method-9 () none) ;; 9 ;; (get-head (_type_) touching-prims-entry) - (touching-shapes-entry-method-10 () none) ;; 10 ;; (get-next (_type_ touching-shapes-entry) touching-prims-entry) - (touching-shapes-entry-method-11 () none) ;; 11 ;; (get-touched-shape (_type_ collide-shape) collide-shape) - (touching-shapes-entry-method-12 () none) ;; 12 ;; (prims-touching? (_type_ collide-shape uint) touching-prims-entry) - (touching-shapes-entry-method-13 () none) ;; 13 ;; (prims-touching-action? (_type_ collide-shape collide-action collide-action) basic) - (touching-shapes-entry-method-14 () none) ;; 14 ;; (free-touching-prims-list (_type_) none) + (get-head (_type_) touching-prims-entry) ;; 9 + (get-next (_type_ touching-shapes-entry) touching-prims-entry) ;; 10 + (get-touched-shape (_type_ collide-shape) collide-shape) ;; 11 + (prims-touching? (_type_ collide-shape uint) touching-prims-entry) ;; 12 + (prims-touching-action? (_type_ collide-shape collide-action collide-action) basic) ;; 13 + (free-touching-prims-list (_type_) none) ;; 14 ) ) -|# -#| (deftype touching-list (structure) + "Contains a record of touching collide shape pairs." ((num-touching-shapes int32 :offset-assert 0) (resolve-u int8 :offset-assert 4) - (touching-shapes touching-shapes-entry 32 :offset-assert 8) ;; guessed by decompiler + (touching-shapes touching-shapes-entry 32 :inline :offset-assert 8) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x408 :flag-assert #xe00000408 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) - (touching-list-method-9 () none) ;; 9 ;; (add-touching-prims (_type_ collide-shape-prim collide-shape-prim float collide-tri-result collide-tri-result) none) - (touching-list-method-10 () none) ;; 10 ;; (free-nodes (_type_) none) - (touching-list-method-11 () none) ;; 11 ;; (update-from-step-size (_type_ float) none) - (touching-list-method-12 () none) ;; 12 ;; (send-events-for-touching-shapes (_type_) none) - (touching-list-method-13 () none) ;; 13 ;; (get-shapes-entry (_type_ collide-shape collide-shape) touching-shapes-entry) + (new (symbol type) _type_) ;; 0 + (add-touching-prims (_type_ collide-shape-prim collide-shape-prim float collide-tri-result collide-tri-result) none) ;; 9 + (free-nodes (_type_) none) ;; 10 + (update-from-step-size (_type_ float) none) ;; 11 + (send-events-for-touching-shapes (_type_) none) ;; 12 + (get-shapes-entry (_type_ collide-shape collide-shape) touching-shapes-entry) ;; 13 ) ) -|# -;; (define-extern *touching-prims-entry-pool* object) ;; touching-prims-entry-pool -;; (define-extern *touching-list* object) ;; touching-list +(define-extern *touching-prims-entry-pool* touching-prims-entry-pool) +(define-extern *touching-list* touching-list) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; process-drawable-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern cspace-by-name-no-fail function) ;; (function process-drawable string cspace) -;; (define-extern cspace-index-by-name-no-fail function) ;; (function process-drawable string int) -;; (define-extern num-func-none function) ;; (function joint-control-channel float float float float :behavior process) -;; (define-extern num-func-+! function) ;; (function joint-control-channel float float float float :behavior process) -;; (define-extern num-func--! function) ;; (function joint-control-channel float float float float :behavior process) -;; (define-extern num-func-loop! function) ;; (function joint-control-channel float float float float :behavior process) -;; (define-extern num-func-loop-speedless! function) ;; (function joint-control-channel float float float float :behavior process) -;; (define-extern num-func-loop-set! function) ;; (function joint-control-channel float float float float :behavior process) -;; (define-extern num-func-seek! function) ;; (function joint-control-channel float float float float :behavior process) -;; (define-extern num-func-blend-in! function) ;; (function joint-control-channel float float float float :behavior process) -;; (define-extern joint-channel-float-delete! function) ;; (function joint-control-channel none) -;; (define-extern num-func-interp-play! function) ;; (function joint-control-channel float float float float :behavior process) -;; (define-extern num-func-interp1-play! function) ;; (function joint-control-channel float float float float :behavior process) -;; (define-extern num-func-chan function) ;; (function joint-control-channel float float float float :behavior process) -;; (define-extern num-func-identity function) ;; (function joint-control-channel float float float float :behavior process) +(define-extern cspace-by-name-no-fail (function process-drawable string cspace)) +(define-extern cspace-index-by-name-no-fail (function process-drawable string int)) +(define-extern num-func-none (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-+! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func--! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-loop! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-loop-speedless! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-loop-set! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-seek! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-blend-in! (function joint-control-channel float float float float :behavior process)) +(define-extern joint-channel-float-delete! (function joint-control-channel none)) +(define-extern num-func-interp-play! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-interp1-play! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-chan (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-identity (function joint-control-channel float float float float :behavior process)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; process-focusable ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++process-focusable:focus-status +(defenum focus-status + :type uint64 + :bitfield #t + (disable 0) ;; if set, all collide checks fail + (dead 1) ;; if set, all collide checks fail + (ignore 2) + (inactive 3) + (dangerous 4) + (in-air 5) + (hit 6) + (grabbed 7) + (in-head 8) + (touch-water 9) + (on-water 10) + (under-water 11) + (edge-grab 12) + (pole 13) + (pilot-riding 14) + (flut 15) + (tube 16) + (light 17) + (board 18) + (gun 19) + (pilot 20) ;; also racer? + (mech 21) + (dark 22) + (rail 23) + (halfpipe 24) + (carry 25) + (super 26) + (shooting 27) + (indax 28) + (arrestable 29) + (teleporting 30) + (invulnerable 31) + (turret 32) + (no-gravity 33) + (gun-no-target 34) + ) +;; ---process-focusable:focus-status + (deftype process-focusable (process-drawable) - ((focus-status uint64 :offset-assert 248) ;; focus-status + ((self process-focusable :override) + (ppointer (pointer process-focusable) :override) + (root collide-shape :override) + (focus-status focus-status :offset-assert 248) ;; focus-status ) :method-count-assert 59 :size-assert #x100 @@ -21444,37 +24956,61 @@ (process-focusable-method-58 () none) ;; 58 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; focus ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype focus (structure) - ((handle uint64 :offset-assert 0) ;; handle + "A structure that keeps a handle to a [[process-focusable]]." + ((handle handle :offset-assert 0) ;; handle (collide-with collide-spec :offset-assert 8) ;; guessed by decompiler ) :method-count-assert 13 :size-assert #xc :flag-assert #xd0000000c (:methods - (focus-method-9 () none) ;; 9 ;; (clear-focused (_type_) none) - (focus-method-10 () none) ;; 10 ;; (collide-spec-match? (_type_ process-focusable) object) - (focus-method-11 () none) ;; 11 ;; (reset-to-collide-spec (_type_ collide-spec) none) - (focus-method-12 () none) ;; 12 ;; (focus-on! (_type_ process-focusable) symbol) + (clear-focused "Reset the focus' handle." (_type_) none) ;; 9 + (collide-spec-match? + "If the focused process is not dead, + check that the [[collide-spec]] of the focus and the process match." + (_type_ process-focusable) object) ;; 10 + (reset-to-collide-spec "Reset this focus with the given [[collide-spec]]." (_type_ collide-spec) none) ;; 11 + (focus-on! "Set the `handle` of this focus to the given process. Return if the handle changed." (_type_ process-focusable) symbol) ;; 12 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; effect-control-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++effect-control-h:effect-control-flag +(defenum effect-control-flag + :type uint32 + :bitfield #t + (ecf0 0) + (ecf1 1) + (ecf2 2) + (ecf3 3) + (ecf4 4) + (ecf5 5) + (ecf6 6) + (ecf7 7) + (ecf8 8) + (ecf9 9) + (ecf10 10) + (ecf11 11) + (ecf12 12) + (ecf13 13) + (ecf14 14) + (ecf15 15) + ) +;; ---effect-control-h:effect-control-flag + (deftype effect-control (basic) + "An effect such as a particle with sound effects that plays during an animation." ((process process-drawable :offset-assert 4) ;; guessed by decompiler (flags effect-control-flag :offset-assert 8) ;; guessed by decompiler (last-frame-group art-joint-anim :offset-assert 12) ;; guessed by decompiler @@ -21488,95 +25024,92 @@ :size-assert #x24 :flag-assert #xf00000024 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable) _type_) - (effect-control-method-9 () none) ;; 9 ;; (effect-control-method-9 (_type_) none) - (effect-control-method-10 () none) ;; 10 ;; (do-effect (_type_ string float int) none) - (effect-control-method-11 () none) ;; 11 ;; (do-effect-for-surface (_type_ symbol float int basic pat-surface) none) - (effect-control-method-12 () none) ;; 12 ;; (play-effect-sound (_type_ symbol float int basic sound-name) int) - (effect-control-method-13 () none) ;; 13 ;; (set-channel-offset! (_type_ int) none) - (effect-control-method-14 () none) ;; 14 ;; (play-effects-from-res-lump (_type_ float float float) none) + (new (symbol type process-drawable) _type_) ;; 0 + (effect-control-method-9 (_type_) none) ;; 9 + (do-effect (_type_ string float int) none) ;; 10 + (do-effect-for-surface (_type_ symbol float int basic pat-surface) none) ;; 11 + (play-effect-sound (_type_ symbol float int basic sound-name) int) ;; 12 + (set-channel-offset! (_type_ int) none) ;; 13 + (play-effects-from-res-lump (_type_ float float float) none) ;; 14 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-frag-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype collide-frag-vertex (vector) () :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype collide-frag-mesh (basic) + "Unused Jak 1 background collision mesh fragment." ((packed-data uint32 :offset-assert 4) (pat-array uint32 :offset-assert 8) (strip-data-len uint16 :offset-assert 12) (poly-count uint16 :offset-assert 14) (base-trans vector4w :inline :offset-assert 16) - (vertex-count uint8 :offset-assert 28) - (vertex-data-qwc uint8 :offset-assert 29) - (total-qwc uint8 :offset-assert 30) - (unused uint8 :offset-assert 31) + (vertex-count uint8 :offset 28) + (vertex-data-qwc uint8 :offset 29) + (total-qwc uint8 :offset 30) + (unused uint8 :offset 31) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype collide-fragment (drawable) - ((mesh collide-frag-mesh :offset-assert 8) ;; guessed by decompiler - (collide-new basic :offset-assert 12) + "Unused Jak 1 background collision drawable tree node." + ((mesh collide-frag-mesh :offset 8) ;; guessed by decompiler + (collide-new basic :offset 12) ) :method-count-assert 17 :size-assert #x20 :flag-assert #x1100000020 ) -|# -#| (deftype drawable-inline-array-collide-fragment (drawable-inline-array) - ((data collide-fragment 1 :offset-assert 36) ;; guessed by decompiler + "Unused Jak 1 background collision drawable tree inline-array class." + ((data collide-fragment 1 :inline :offset-assert 32) ;; guessed by decompiler + (pad uint32) ) :method-count-assert 17 :size-assert #x44 :flag-assert #x1100000044 ) -|# -;; (deftype drawable-tree-collide-fragment (drawable-tree) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-collide-fragment (drawable-tree) + "Unused jak 1 background collision data." + () + :flag-assert #x1100000020 + ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-hash-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype collide-hash-scratch (structure) + "Scratchpad memory layout for collide-hash. Bitmask of things that have already been checked" ((collidable-bits uint128 128 :offset-assert 0) ;; guessed by decompiler - (poly-bits uint64 2 :offset-assert 0) ;; guessed by decompiler - (id-bits uint32 512 :offset-assert 0) ;; guessed by decompiler + (poly-bits uint64 2 :offset 0) ;; guessed by decompiler + (id-bits uint32 512 :offset 0) ;; guessed by decompiler (tris uint32 :offset-assert 2048) ) :method-count-assert 9 :size-assert #x804 :flag-assert #x900000804 ) -|# -#| (deftype collide-hash-bucket (structure) + "A bucket is a reference to a list of items that intersect a grid cell. + For the broadphase, the items are collide-hash-item (wrapper of collide-hash-fragment). + For the narrowphase, the items are entries in the index list, which contains poly indices." ((index int16 :offset-assert 0) (count int16 :offset-assert 2) ) @@ -21584,125 +25117,155 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype collide-hash-item (structure) + "Items that are 'hashed' in the broadphase. Contains unique ID for checking against already-visited-bitmask + and a pointer to the actual collide-hash-fragment, or possibly a TIE." ((id uint32 :offset-assert 0) (collidable basic :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype collide-hash-poly (structure) + "A polygon in the narrow-phase data. This is just indices into the vertex and PAT tables." ((data uint8 4 :offset-assert 0) ;; guessed by decompiler - (vert-index0 uint8 :offset-assert 0) - (vert-index1 uint8 :offset-assert 1) - (vert-index2 uint8 :offset-assert 2) - (pat-index uint8 :offset-assert 3) - (word uint32 :offset-assert 0) + (vert-index0 uint8 :offset 0) + (vert-index1 uint8 :offset 1) + (vert-index2 uint8 :offset 2) + (pat-index uint8 :offset 3) + (word uint32 :offset 0) ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype collide-hash-fragment-stats (structure) ((num-verts uint16 :offset-assert 0) (num-polys uint8 :offset-assert 2) (poly-count uint8 :offset-assert 3) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype collide-hash-fragment (drawable) - ((num-buckets uint16 :offset-assert 4) - (num-indices uint16 :offset-assert 6) - (pat-array uint32 :offset-assert 8) - (bucket-array uint32 :offset-assert 12) + "A mesh fragment for the Jak2/Jak3 collision system. This is a 'hash' of triangles into a grid + where the 'hash' function is just identity." + ((num-buckets uint16 :offset 4) + (num-indices uint16 :offset 6) + (pat-array uint32 :offset 8) + (bucket-array uint32 :offset 12) (grid-step vector :inline :offset-assert 32) (bbox bounding-box :inline :offset-assert 48) (bbox4w bounding-box4w :inline :offset-assert 80) - (axis-scale vector :inline :offset-assert 64) - (avg-extents vector :inline :offset-assert 80) - (dimension-array uint32 4 :offset-assert 44) ;; guessed by decompiler - (stats collide-hash-fragment-stats :inline :offset-assert 60) - (num-verts uint16 :offset-assert 60) - (num-polys uint8 :offset-assert 62) - (poly-count uint8 :offset-assert 63) - (poly-array uint32 :offset-assert 76) - (vert-array uint32 :offset-assert 92) - (index-array uint32 :offset-assert 108) + (axis-scale vector :inline :offset 64) + (avg-extents vector :inline :offset 80) + (dimension-array uint32 4 :offset 44) ;; guessed by decompiler + (stats collide-hash-fragment-stats :inline :offset 60) + (num-verts uint16 :offset 60) + (num-polys uint8 :offset 62) + (poly-count uint8 :offset 63) + (poly-array uint32 :offset 76) + (vert-array uint32 :offset 92) + (index-array uint32 :offset 108) ) :method-count-assert 17 :size-assert #x70 :flag-assert #x1100000070 ) -|# -#| (deftype collide-hash-fragment-array (array) - ((type type :offset-assert 0) ;; guessed by decompiler - (length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (content-type type :offset-assert 12) ;; guessed by decompiler - ) + "A collection of collide-hash-fragments. These are used by the instanced collision if a single instance + needs more than 1 collide-hash-fragment worth of triangles." + ((fragments collide-hash-fragment :dynamic :offset 16)) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype collide-hash (drawable) - ((num-ids uint16 :offset-assert 4) - (id-count uint16 :offset-assert 6) - (num-buckets uint32 :offset-assert 8) - (qwc-id-bits uint32 :offset-assert 12) - (grid-step vector :inline :offset-assert 16) - (bbox bounding-box :inline :offset-assert 32) - (bbox4w bounding-box4w :inline :offset-assert 64) - (axis-scale vector :inline :offset-assert 48) - (avg-extents vector :inline :offset-assert 64) - (bucket-array uint32 :offset-assert 44) - (item-array (inline-array collide-hash-item) :offset-assert 60) ;; guessed by decompiler - (dimension-array uint32 3 :offset-assert 76) ;; guessed by decompiler - (num-items uint32 :offset-assert 92) + ((num-ids uint16 :offset 4) + (id-count uint16 :offset 6) + (num-buckets uint32 :offset 8) + (qwc-id-bits uint32 :offset 12) + (grid-step vector :inline :offset 16) + (bbox bounding-box :inline :offset 32) + (bbox4w bounding-box4w :inline :offset 64) + (axis-scale vector :inline :offset 48) + (avg-extents vector :inline :offset 64) + (bucket-array uint32 :offset 44) + (item-array (inline-array collide-hash-item) :offset 60 :score 1) ;; guessed by decompiler + (dimension-array uint32 3 :offset 76) ;; guessed by decompiler + (num-items uint32 :offset 92) ) :method-count-assert 17 :size-assert #x60 :flag-assert #x1100000060 ) -|# -;; (define-extern *collide-list-boxes* object) ;; symbol -;; (define-extern *collide-hash-fragments* object) ;; int -;; (define-extern *collide-hash-fragments-tfrag* object) ;; int -;; (define-extern *collide-hash-fragments-instance* object) ;; int -;; (define-extern *already-printed-exeeded-max-cache-tris* object) ;; symbol +(define-extern *collide-list-boxes* symbol) ;; object +(define-extern *collide-hash-fragments* int) ;; object +(define-extern *collide-hash-fragments-tfrag* int) ;; object +(define-extern *collide-hash-fragments-instance* int) ;; object +(define-extern *already-printed-exeeded-max-cache-tris* symbol) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; water-info-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++water-info-h:water-flag +(defenum water-flag + :type uint32 + :bitfield #t + (active 0) + (can-wade 1) + (can-swim 2) + (swim-ground 3) + (can-ground 4) + (use-ocean 5) + (tar 6) + (mud 7) + (deadly 8) + (use-water-anim 9) + (no-grab-sound 10) + (dark-eco 11) + (lava 12) + (swamp 13) + (flow 14) + (under-water 15) + (head-under-water 16) + (bouncing 17) + (wading 18) + (swimming 19) + (touch-water 20) + (jump-out 21) + (break-surface 22) + (spawn-drip 23) + (part-splash 24) + (part-drip 25) + (part-rings 26) + (part-water 27) + (event 28) + (over-water 29) + (find-water 30) + (touch-water-good 31) + ) +;; ---water-info-h:water-flag + (deftype water-info (structure) ((trans vector :inline :offset-assert 0) (normal vector :inline :offset-assert 16) (base-height meters :offset-assert 32) (depth meters :offset-assert 36) - (handle uint64 :offset-assert 40) ;; handle - (flags water-flag :offset-assert 48) + (handle handle :offset-assert 40) ;; handle + (flags water-flag :offset-assert 48) ;; water-flags (prim drawable-region-prim :offset-assert 52) ;; guessed by decompiler (extra-flags uint32 :offset-assert 56) ) @@ -21710,9 +25273,7 @@ :size-assert #x3c :flag-assert #x90000003c ) -|# -#| (deftype water-sphere (structure) ((sphere sphere :inline :offset-assert 0) (flags water-flag :offset-assert 16) @@ -21722,48 +25283,48 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ragdoll-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type ragdoll basic) +(declare-type ragdoll-joint structure) +(declare-type ragdoll-proc process) + (deftype ragdoll-edit-info (structure) - ((editing symbol :offset-assert 0) ;; guessed by decompiler - (current-func uint64 :offset-assert 8) - (analog-func uint64 :offset-assert 16) - (affect uint64 :offset-assert 24) - (single-step uint64 :offset-assert 32) - (collision symbol :offset-assert 40) ;; guessed by decompiler - (gravity symbol :offset-assert 44) ;; guessed by decompiler - (skel-visible uint64 :offset-assert 48) - (current-joint int8 :offset-assert 56) - (auto-setup-now basic :offset-assert 60) - (child-stack ragdoll-joint 60 :offset-assert 64) ;; guessed by decompiler - (child-stack-num int8 :offset-assert 304) - (last-frame uint64 :offset-assert 312) ;; time-frame - (last-frame-dur uint64 :offset-assert 320) ;; time-frame + ((editing symbol :offset-assert 0) + (current-func uint64 :offset-assert 8) + (analog-func uint64 :offset-assert 16) + (affect uint64 :offset-assert 24) + (single-step uint64 :offset-assert 32) + (collision symbol :offset-assert 40) + (gravity symbol :offset-assert 44) + (skel-visible uint64 :offset-assert 48) + (current-joint int8 :offset-assert 56) + (auto-setup-now basic :offset-assert 60) + (child-stack ragdoll-joint 60 :offset-assert 64) + (child-stack-num int8 :offset-assert 304) + (last-frame time-frame :offset-assert 312) + (last-frame-dur time-frame :offset-assert 320) ) :method-count-assert 18 :size-assert #x148 :flag-assert #x1200000148 (:methods - (ragdoll-edit-info-method-9 () none) ;; 9 ;; (has-joint? (_type_ ragdoll-joint) symbol) - (ragdoll-edit-info-method-10 () none) ;; 10 ;; (ragdoll-edit-info-method-10 (_type_ object ragdoll-joint) symbol) - (ragdoll-edit-info-method-11 () none) ;; 11 ;; (fill-child-stack! (_type_ ragdoll) none) - (ragdoll-edit-info-method-12 () none) ;; 12 ;; (ragdoll-edit-info-method-12 (_type_) none) - (ragdoll-edit-info-method-13 () none) ;; 13 ;; (cycle-joints! (_type_ ragdoll) none) - (ragdoll-edit-info-method-14 () none) ;; 14 ;; (ragdoll-edit-info-method-14 (_type_ matrix vector (inline-array ragdoll-joint) ragdoll process-drawable) vector) - (ragdoll-edit-info-method-15 () none) ;; 15 ;; (ragdoll-edit-info-method-15 (_type_) none) - (ragdoll-edit-info-method-16 () none) ;; 16 ;; (ragdoll-edit-info-method-16 (_type_ ragdoll process-drawable) none) - (ragdoll-edit-info-method-17 () none) ;; 17 ;; (ragdoll-edit-info-method-17 (_type_ ragdoll process-drawable) none) + (has-joint? (_type_ ragdoll-joint) symbol) ;; 9 + (ragdoll-edit-info-method-10 (_type_ object ragdoll-joint) symbol) ;; 10 + (fill-child-stack! "Fill the `child-stack` with the joints of the given ragdoll." (_type_ ragdoll) none) ;; 11 + (ragdoll-edit-info-method-12 (_type_) none) ;; 12 + (cycle-joints! "Cycle through joints based on controller input." (_type_ ragdoll) none) ;; 13 + (ragdoll-edit-info-method-14 (_type_ matrix vector (inline-array ragdoll-joint) ragdoll process-drawable) vector) ;; 14 + (ragdoll-edit-info-method-15 (_type_) none) ;; 15 + (ragdoll-edit-info-method-16 (_type_ ragdoll process-drawable) none) ;; 16 + (ragdoll-edit-info-method-17 (_type_ ragdoll process-drawable) none) ;; 17 ) ) -|# -#| (deftype ragdoll-joint-setup (structure) ((joint-index int32 :offset-assert 0) (parent-joint int32 :offset-assert 4) @@ -21779,9 +25340,7 @@ :size-assert #x3e :flag-assert #x90000003e ) -|# -#| (deftype ragdoll-setup (structure) ((orient-tform vector :inline :offset-assert 0) (scale vector :inline :offset-assert 16) @@ -21792,95 +25351,135 @@ :size-assert #x28 :flag-assert #x900000028 ) -|# -#| +;; +++ragdoll-h:ragdoll-joint-flag +(defenum ragdoll-joint-flag + :type uint32 + :bitfield #t + (rjf0 0) + (rjf1 1) + (rjf2 2) + (rjf3 3) + (rjf4 4) + (rjf5 5) + (rjf6 6) + (rjf7 7) + (rjf8 8) + (rjf9 9) + (rjf10 10) + (rjf11 11) + (rjf12 12) + (rjf13 13) + (rjf14 14) + (rjf15 15) + ) +;; ---ragdoll-h:ragdoll-joint-flag + (deftype ragdoll-joint (structure) - ((quat quaternion :inline :offset-assert 0) - (position vector :inline :offset-assert 16) - (velocity vector :inline :offset-assert 32) - (bounce vector :inline :offset-assert 48) - (old-x vector :inline :offset-assert 64) - (pre-tform vector :inline :offset-assert 80) - (geo-tform vector :inline :offset-assert 96) - (axial-slop float :offset-assert 112) - (max-angle float :offset-assert 116) ;; degrees - (joint-length float :offset-assert 120) - (coll-rad float :offset-assert 124) - (ragdoll-joint-flags ragdoll-joint-flag :offset-assert 128) ;; guessed by decompiler - (joint-type uint64 :offset-assert 136) - (joint-index int8 :offset-assert 144) - (parent-joint int8 :offset-assert 145) - (parent-index int8 :offset-assert 146) - (num-children int8 :offset-assert 147) - (old-param0 basic :offset-assert 148) - (hit-sound uint128 :offset-assert 160) ;; sound-name - (ground-pat pat-surface :offset-assert 176) ;; guessed by decompiler - (user0 int32 :offset-assert 180) - (original-speed float :offset-assert 184) + ((quat quaternion :inline :offset-assert 0) + (position vector :inline :offset-assert 16) + (velocity vector :inline :offset-assert 32) + (bounce vector :inline :offset-assert 48) + (old-x vector :inline :offset-assert 64) + (pre-tform vector :inline :offset-assert 80) + (geo-tform vector :inline :offset-assert 96) + (axial-slop float :offset-assert 112) + (max-angle degrees :offset-assert 116) + (joint-length float :offset-assert 120) + (coll-rad float :offset-assert 124) + (ragdoll-joint-flags ragdoll-joint-flag :offset-assert 128) + (joint-type uint64 :offset-assert 136) + (joint-index int8 :offset-assert 144) + (parent-joint int8 :offset-assert 145) + (parent-index int8 :offset-assert 146) + (num-children int8 :offset-assert 147) + (old-param0 basic :offset-assert 148) + (hit-sound sound-name :offset-assert 160) + (ground-pat pat-surface :offset-assert 176) + (user0 int32 :offset-assert 180) + (original-speed float :offset-assert 184) ) :method-count-assert 9 :size-assert #xbc :flag-assert #x9000000bc ) -|# -#| +;; +++ragdoll-h:ragdoll-flag +(defenum ragdoll-flag + :type uint32 + :bitfield #t + (rf0 0) + (rf1 1) + (rf2 2) + (rf3 3) + (rf4 4) + (rf5 5) + (rf6 6) + (rf7 7) + (mirror 8) + (rf9 9) + (rf10 10) + (rf11 11) + (rf12 12) + (rf13 13) + (rf14 14) + (rf15 15) + ) +;; ---ragdoll-h:ragdoll-flag + (deftype ragdoll (basic) - ((ragdoll-joints ragdoll-joint 60 :offset-assert 16) ;; guessed by decompiler - (num-joints uint8 :offset-assert 11536) - (mirror matrix :inline :offset-assert 11552) - (gravity vector :inline :offset-assert 11616) - (gravity-target vector :inline :offset-assert 11632) - (orient-tform vector :inline :offset-assert 11648) - (scale vector :inline :offset-assert 11664) - (stretch-vel float :offset-assert 11680) - (stretch-vel-parallel float :offset-assert 11684) - (compress-vel float :offset-assert 11688) - (compress-vel-parallel float :offset-assert 11692) - (momentum float :offset-assert 11696) - (maximum-stretch float :offset-assert 11700) - (turn-off-start uint64 :offset-assert 11704) ;; time-frame - (turn-off-duration uint64 :offset-assert 11712) ;; time-frame - (copy-velocity-start uint64 :offset-assert 11720) ;; time-frame - (root-offset vector :inline :offset-assert 11728) - (rotate-vel quaternion :inline :offset-assert 11744) - (rotate-adj quaternion :inline :offset-assert 11760) - (rotate-adj-count int8 :offset-assert 11776) - (ragdoll-flags ragdoll-flag :offset-assert 11780) ;; guessed by decompiler - (flex-blend float :offset-assert 11784) - (stable-joints int8 :offset-assert 11788) - (ragdoll-joint-remap uint8 100 :offset-assert 11789) ;; guessed by decompiler - (allow-destabilize uint64 :offset-assert 11896) - (bg-collide-with uint32 :offset-assert 11904) - (water-info water-info :inline :offset-assert 11920) + ((ragdoll-joints ragdoll-joint 60 :inline :offset-assert 16) + (num-joints uint8 :offset-assert 11536) + (mirror matrix :inline :offset-assert 11552) + (gravity vector :inline :offset-assert 11616) + (gravity-target vector :inline :offset-assert 11632) + (orient-tform vector :inline :offset-assert 11648) + (scale vector :inline :offset-assert 11664) + (stretch-vel float :offset-assert 11680) + (stretch-vel-parallel float :offset-assert 11684) + (compress-vel float :offset-assert 11688) + (compress-vel-parallel float :offset-assert 11692) + (momentum float :offset-assert 11696) + (maximum-stretch float :offset-assert 11700) + (turn-off-start time-frame :offset-assert 11704) + (turn-off-duration time-frame :offset-assert 11712) + (copy-velocity-start time-frame :offset-assert 11720) + (root-offset vector :inline :offset-assert 11728) + (rotate-vel quaternion :inline :offset-assert 11744) + (rotate-adj quaternion :inline :offset-assert 11760) + (rotate-adj-count int8 :offset-assert 11776) + (ragdoll-flags ragdoll-flag :offset-assert 11780) + (flex-blend float :offset-assert 11784) + (stable-joints int8 :offset-assert 11788) + (ragdoll-joint-remap uint8 100 :offset-assert 11789) + (allow-destabilize uint64 :offset-assert 11896) + (bg-collide-with uint32 :offset-assert 11904) + (water-info water-info :inline :offset-assert 11920) ) :method-count-assert 26 :size-assert #x2ecc :flag-assert #x1a00002ecc (:methods - (ragdoll-method-9 () none) ;; 9 ;; (ragdoll-method-9 (_type_ matrix process-drawable) none) - (ragdoll-method-10 () none) ;; 10 ;; (ragdoll-method-10 (_type_ process-drawable symbol vector symbol) none) - (ragdoll-method-11 () none) ;; 11 ;; (turn-off-for-duration! (_type_ time-frame) none) - (ragdoll-method-12 () none) ;; 12 ;; (get-parent-joint (_type_ (inline-array ragdoll-joint)) ragdoll-joint) - (ragdoll-method-13 () none) ;; 13 ;; (ragdoll-method-13 (_type_ ragdoll-edit-info ragdoll-joint matrix matrix) none) - (ragdoll-method-14 () none) ;; 14 ;; (ragdoll-method-14 (_type_ process-drawable ragdoll-joint object matrix) none) - (ragdoll-method-15 () none) ;; 15 ;; (ragdoll-method-15 (_type_ process-drawable ragdoll-edit-info) none) - (ragdoll-method-16 () none) ;; 16 ;; (ragdoll-setup! (_type_ process-drawable ragdoll-setup) none) - (ragdoll-method-17 () none) ;; 17 ;; (ragdoll-method-17 (_type_ process-drawable) none) - (ragdoll-method-18 () none) ;; 18 ;; (ragdoll-method-18 (_type_) none) - (ragdoll-method-19 () none) ;; 19 ;; (ragdoll-method-19 (_type_ vector int object matrix) none) - (ragdoll-method-20 () none) ;; 20 ;; (reset-vec! (_type_ vector) none) - (ragdoll-method-21 () none) ;; 21 ;; (ragdoll-method-21 (_type_ vector vector float) vector) - (ragdoll-method-22 () none) ;; 22 ;; (get-max-angle-for-joint-idx (_type_ int) degrees) - (ragdoll-method-23 () none) ;; 23 ;; (ragdoll-method-23 (_type_ vector vector float symbol) none) - (ragdoll-method-24 () none) ;; 24 ;; (ragdoll-method-24 (_type_ vector int) none) - (ragdoll-method-25 () none) ;; 25 ;; (enable-ragdoll! (_type_ process-drawable) none) + (ragdoll-method-9 (_type_ matrix process-drawable) none) ;; 9 + (ragdoll-method-10 (_type_ process-drawable symbol vector symbol) none) ;; 10 + (turn-off-for-duration! (_type_ time-frame) none) ;; 11 + (get-parent-joint (_type_ (inline-array ragdoll-joint)) ragdoll-joint) ;; 12 + (ragdoll-method-13 (_type_ ragdoll-edit-info ragdoll-joint matrix matrix) none) ;; 13 + (ragdoll-method-14 (_type_ process-drawable ragdoll-joint object matrix) none) ;; 14 + (ragdoll-method-15 (_type_ process-drawable ragdoll-edit-info) none) ;; 15 + (ragdoll-setup! "Set up this ragdoll with the given [[ragdoll-setup]]." (_type_ process-drawable ragdoll-setup) none) ;; 16 + (ragdoll-method-17 (_type_ process-drawable) none) ;; 17 + (ragdoll-method-18 (_type_) none) ;; 18 + (ragdoll-method-19 (_type_ vector int object matrix) none) ;; 19 + (reset-vec! (_type_ vector) none) ;; 20 + (ragdoll-method-21 (_type_ vector vector float) vector) ;; 21 + (get-max-angle-for-joint-idx (_type_ int) degrees) ;; 22 + (ragdoll-method-23 (_type_ vector vector float symbol) none) ;; 23 + (ragdoll-method-24 (_type_ vector int) none) ;; 24 + (enable-ragdoll! (_type_ process-drawable) none) ;; 25 ) ) -|# -#| (deftype ragdoll-proc (process) ((ragdoll ragdoll :offset-assert 144) ;; guessed by decompiler (last-attack-id uint32 :offset-assert 148) @@ -21889,13 +25488,7 @@ :size-assert #x98 :flag-assert #x1500100098 (:methods - (ragdoll-proc-method-9 () none) ;; 9 - (ragdoll-proc-method-10 () none) ;; 10 - (ragdoll-proc-method-11 () none) ;; 11 - (ragdoll-proc-method-12 () none) ;; 12 - (ragdoll-proc-method-13 () none) ;; 13 - (ragdoll-proc-method-14 () none) ;; 14 ;; (idle () _type_ :state) - (ragdoll-proc-method-15 () none) ;; 15 ;; (ragdoll-proc-method-15 (_type_ symbol vector symbol) none) + (ragdoll-proc-method-15 () none) ;; 14 ;; (idle () _type_ :state) 15 ;; (ragdoll-proc-method-15 (_type_ symbol vector symbol) none) (ragdoll-proc-method-16 () none) ;; 16 ;; (disable-for-duration (_type_ time-frame) none) (ragdoll-proc-method-17 () none) ;; 17 ;; (ragdoll-proc-method-17 (_type_ ragdoll-edit-info) none) (ragdoll-proc-method-18 () none) ;; 18 ;; (ragdoll-proc-method-18 (_type_ ragdoll-edit-info) none) @@ -21903,28 +25496,65 @@ (ragdoll-proc-method-20 () none) ;; 20 ) ) -|# -;; (define-extern *ragdoll-edit-info* object) ;; ragdoll-edit-info +(define-extern *ragdoll-edit-info* ragdoll-edit-info) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; projectile-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++projectile-h:projectile-options +(defenum projectile-options + :bitfield #t + :type uint64 + (po0 0) + (po1 1) + (po2 2) + (po3 3) + (po4 4) + (po5 5) + (po6 6) + (po7 7) + (po8 8) + (po9 9) + (po10 10) + (po11 11) + (po12 12) + (po13 13) + (po14 14) + (po15 15) + (po16 16) + (po17 17) + (po18 18) + (po19 19) + (po20 20) + (po21 21) + (po22 22) + (po23 23) + (po24 24) + (po25 25) + (po26 26) + (po27 27) + (po28 28) + (po29 29) + (po30 30) + (po31 31) + ) +;; ---projectile-h:projectile-options + (deftype projectile (process-drawable) ((starting-pos vector :inline :offset-assert 256) (starting-dir vector :inline :offset-assert 272) (target-pos vector :inline :offset-assert 288) (base-target-pos vector :inline :offset-assert 304) (pre-move-transv vector :inline :offset-assert 320) - (timeout uint64 :offset-assert 336) ;; time-frame - (spawn-time uint64 :offset-assert 344) ;; time-frame - (options uint64 :offset-assert 352) ;; projectile-options - (last-target uint64 :offset-assert 360) ;; handle - (notify-handle uint64 :offset-assert 368) ;; handle - (owner-handle uint64 :offset-assert 376) ;; handle - (ignore-handle uint64 :offset-assert 384) ;; handle + (timeout time-frame :offset-assert 336) ;; time-frame + (spawn-time time-frame :offset-assert 344) ;; time-frame + (options projectile-options :offset-assert 352) ;; projectile-options + (last-target handle :offset-assert 360) ;; handle + (notify-handle handle :offset-assert 368) ;; handle + (owner-handle handle :offset-assert 376) ;; handle + (ignore-handle handle :offset-assert 384) ;; handle (update-velocity (function projectile none) :offset-assert 392) ;; guessed by decompiler (move (function projectile none) :offset-assert 396) ;; guessed by decompiler (pick-target (function projectile none) :offset-assert 400) ;; guessed by decompiler @@ -21942,8 +25572,8 @@ (charge-level float :offset-assert 508) (sound-id sound-id :offset-assert 512) ;; guessed by decompiler (stop-speed meters :offset-assert 516) - (invinc-time uint64 :offset-assert 520) ;; time-frame - (desired-target uint64 :offset-assert 528) ;; handle + (invinc-time time-frame :offset-assert 520) ;; time-frame + (desired-target handle :offset-assert 528) ;; handle (desired-target-pos vector :inline :offset-assert 544) (wpn-type uint8 :offset-assert 560) ) @@ -21975,22 +25605,20 @@ (projectile-method-71 () none) ;; 71 ) ) -|# -#| (deftype projectile-init-by-other-params (structure) ((pos vector :inline :offset-assert 0) (vel vector :inline :offset-assert 16) (target-pos vector :inline :offset-assert 32) - (target-handle uint64 :offset-assert 48) ;; handle + (target-handle handle :offset-assert 48) (ent entity :offset-assert 56) ;; guessed by decompiler (charge float :offset-assert 60) (attack-id uint32 :offset-assert 64) - (options uint64 :offset-assert 72) ;; projectile-options - (notify-handle uint64 :offset-assert 80) ;; handle - (owner-handle uint64 :offset-assert 88) ;; handle - (ignore-handle uint64 :offset-assert 96) ;; handle - (timeout uint64 :offset-assert 104) ;; time-frame + (options projectile-options :offset-assert 72) ;; projectile-options + (notify-handle handle :offset-assert 80) ;; handle + (owner-handle handle :offset-assert 88) ;; handle + (ignore-handle handle :offset-assert 96) ;; handle + (timeout time-frame :offset-assert 104) ;; time-frame (damage float :offset-assert 112) (vehicle-damage-factor float :offset-assert 116) (vehicle-impulse-factor float :offset-assert 120) @@ -22000,11 +25628,9 @@ :size-assert #x7d :flag-assert #x90000007d ) -|# -#| (deftype projectile-bounce (projectile) - ((played-bounce-time uint64 :offset-assert 568) ;; time-frame + ((played-bounce-time time-frame :offset-assert 568) ;; time-frame (tumble-quat quaternion :inline :offset-assert 576) (gravity float :offset-assert 592) ) @@ -22017,15 +25643,13 @@ (projectile-bounce-method-74 () none) ;; 74 ) ) -|# -;; (define-extern spawn-projectile function) ;; (function type projectile-init-by-other-params process-tree dead-pool (pointer process)) +(define-extern spawn-projectile (function type projectile-init-by-other-params process-tree dead-pool (pointer process))) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; find-nearest-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype find-sorted-targets-params (structure) ((near-point vector :inline :offset-assert 0) (in-dir vector :inline :offset-assert 16) @@ -22048,86 +25672,122 @@ :flag-assert #x900000068 ;; field validator-params uses ~A with a signed load. ) -|# -;; (define-extern *HACK-find-nearest-focusable-ignore* object) +(define-extern *HACK-find-nearest-focusable-ignore* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; target-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| -(deftype target (process-focusable) - ((vehicle uint64 :offset-assert 256) - (target-flags target-flags :offset-assert 236) ;; guessed by decompiler - (game game-info :offset-assert 264) ;; guessed by decompiler - (init-time uint64 :offset-assert 272) ;; time-frame - (teleport-time uint64 :offset-assert 280) ;; time-frame - (state-hook-time uint64 :offset-assert 288) ;; time-frame - (state-hook (function none :behavior target) :offset-assert 296) ;; guessed by decompiler - (cam-user-mode symbol :offset-assert 300) ;; guessed by decompiler - (anim-seed uint64 :offset-assert 304) - (alt-cam-pos vector :inline :offset-assert 320) - (current-level level :offset-assert 336) ;; guessed by decompiler - (saved-pos transformq :inline :offset-assert 352) - (saved-owner uint64 :offset-assert 400) ;; handle - (excitement float :offset-assert 408) - (shock-effect-time uint64 :offset-assert 416) ;; time-frame - (fp-hud uint64 :offset-assert 424) ;; handle - (no-load-wait uint64 :offset-assert 432) ;; time-frame - (no-look-around-wait uint64 :offset-assert 440) ;; time-frame - (burn-proc uint64 :offset-assert 448) ;; handle - (pre-joint-hook (function none :behavior target) :offset-assert 456) ;; guessed by decompiler - (notify uint64 :offset-assert 464) ;; handle - (mode-cache symbol :offset-assert 472) ;; guessed by decompiler - (mode-param1 uint64 :offset-assert 480) ;; handle - (mode-param2 uint64 :offset-assert 488) - (mode-param3 uint64 :offset-assert 496) - (major-mode-exit-hook (function none :behavior target) :offset-assert 504) ;; guessed by decompiler - (major-mode-event-hook (function process int symbol event-message-block object :behavior target) :offset-assert 508) ;; guessed by decompiler - (sub-mode-exit-hook (function none :behavior target) :offset-assert 512) ;; guessed by decompiler - (target-effect uint64 :offset-assert 520) ;; target-effect - (color-effect symbol :offset-assert 528) ;; guessed by decompiler - (color-effect-start-time uint64 :offset-assert 536) ;; time-frame - (color-effect-duration uint64 :offset-assert 544) ;; time-frame - (yes-state basic :offset-assert 552) - (no-state basic :offset-assert 556) - (state-object UNKNOWN 4 :offset-assert 560) - (state-uint32 UNKNOWN 4 :offset-assert 560) - (state-float UNKNOWN 4 :offset-assert 560) - (state-button UNKNOWN 4 :offset-assert 576) - (state-vector UNKNOWN 4 :offset-assert 592) - (state-time time-frame 4 :offset-assert 240) ;; guessed by decompiler - (state-smush smush-control :inline :offset-assert 688) - (state-sound UNKNOWN 4 :offset-assert 720) - (state-handle UNKNOWN 4 :offset-assert 736) - (state-impact UNKNOWN 1 :offset-assert 768) - ) - :method-count-assert 60 - :size-assert #x350 - :flag-assert #x3c02c00350 - ;; field mode-param2 uses ~A with a 64-bit load. field mode-param3 uses ~A with a 64-bit load. - (:methods - (target-method-59 () none) ;; 59 - ) - (:states - target-continue ;; associated process guessed by decompiler, old: (state continue-point target) - target-float ;; associated process guessed by decompiler, old: (state target) - target-introb - target-intro - target-title ;; associated process guessed by decompiler, old: (state symbol target) - target-pilot-start ;; associated process guessed by decompiler, old: (state handle symbol symbol target) - ) +;; +++target-h:target-flags +(defenum target-flags + :type uint32 + :bitfield #t + (tf0 0) + (tf1 1) + (tf2 2) + (tinvuln1 3) + (tf4 4) + (tf5 5) + (tf6 6) + (prevent-jump 7) + (prevent-attack 8) + (prevent-duck 9) + (tf10 10) + (tf11 11) + (tf12 12) + (tf13 13) + (tf14 14) + (tf15 15) + (tf16 16) + (prevent-board 17) + (prevent-gun 18) + (lleg-still 19) + (rleg-still 20) + (lleg-no-ik 21) + (rleg-no-ik 22) + (prevent-double-jump 23) + (disable-attacks 24) + (tinvuln2 25) + (tf26 26) + (tf27 27) + (invisible 28) + (tf29 29) + (tf30 30) + (tf31 31) ) -|# +;; ---target-h:target-flags + +;; (deftype target (process-focusable) +;; ((vehicle uint64 :offset-assert 256) +;; (target-flags target-flags :offset 236) ;; guessed by decompiler +;; (game game-info :offset-assert 264) ;; guessed by decompiler +;; (init-time uint64 :offset-assert 272) ;; time-frame +;; (teleport-time uint64 :offset-assert 280) ;; time-frame +;; (state-hook-time uint64 :offset-assert 288) ;; time-frame +;; (state-hook (function none :behavior target) :offset-assert 296) ;; guessed by decompiler +;; (cam-user-mode symbol :offset-assert 300) ;; guessed by decompiler +;; (anim-seed uint64 :offset-assert 304) +;; (alt-cam-pos vector :inline :offset-assert 320) +;; (current-level level :offset-assert 336) ;; guessed by decompiler +;; (saved-pos transformq :inline :offset-assert 352) +;; (saved-owner uint64 :offset-assert 400) ;; handle +;; (excitement float :offset-assert 408) +;; (shock-effect-time uint64 :offset-assert 416) ;; time-frame +;; (fp-hud uint64 :offset-assert 424) ;; handle +;; (no-load-wait uint64 :offset-assert 432) ;; time-frame +;; (no-look-around-wait uint64 :offset-assert 440) ;; time-frame +;; (burn-proc uint64 :offset-assert 448) ;; handle +;; (pre-joint-hook (function none :behavior target) :offset-assert 456) ;; guessed by decompiler +;; (notify uint64 :offset-assert 464) ;; handle +;; (mode-cache symbol :offset-assert 472) ;; guessed by decompiler +;; (mode-param1 uint64 :offset-assert 480) ;; handle +;; (mode-param2 uint64 :offset-assert 488) +;; (mode-param3 uint64 :offset-assert 496) +;; (major-mode-exit-hook (function none :behavior target) :offset-assert 504) ;; guessed by decompiler +;; (major-mode-event-hook (function process int symbol event-message-block object :behavior target) :offset-assert 508) ;; guessed by decompiler +;; (sub-mode-exit-hook (function none :behavior target) :offset-assert 512) ;; guessed by decompiler +;; (target-effect uint64 :offset-assert 520) ;; target-effect +;; (color-effect symbol :offset-assert 528) ;; guessed by decompiler +;; (color-effect-start-time uint64 :offset-assert 536) ;; time-frame +;; (color-effect-duration uint64 :offset-assert 544) ;; time-frame +;; (yes-state basic :offset-assert 552) +;; (no-state basic :offset-assert 556) +;; (state-object object 4 :offset-assert 560) +;; (state-uint32 uint32 4 :offset-assert 560) +;; (state-float float 4 :offset-assert 560) +;; (state-button UNKNOWN 4 :offset-assert 576) +;; (state-vector vector 4 :offset-assert 592) +;; (state-time time-frame 4 :offset-assert 240) ;; guessed by decompiler +;; (state-smush smush-control :inline :offset-assert 688) +;; (state-sound UNKNOWN 4 :offset-assert 720) +;; (state-handle handle 4 :offset-assert 736) +;; (state-impact UNKNOWN 1 :offset-assert 768) +;; ) +;; :method-count-assert 60 +;; :size-assert #x350 +;; :flag-assert #x3c02c00350 +;; ;; field mode-param2 uses ~A with a 64-bit load. field mode-param3 uses ~A with a 64-bit load. +;; (:methods +;; (target-method-59 () none) ;; 59 +;; ) +;; (:states +;; target-continue ;; associated process guessed by decompiler, old: (state continue-point target) +;; target-float ;; associated process guessed by decompiler, old: (state target) +;; target-introb +;; target-intro +;; target-title ;; associated process guessed by decompiler, old: (state symbol target) +;; target-pilot-start ;; associated process guessed by decompiler, old: (state handle symbol symbol target) +;; ) +;; ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; stats-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype tr-stat (structure) + "triangle stats for a renderer. This can apply to a lot of different renderer types." ((groups uint16 :offset-assert 0) (fragments uint16 :offset-assert 2) (tris uint32 :offset-assert 4) @@ -22139,10 +25799,9 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype merc-global-stats (structure) + "Triangle stats for all merc renderers." ((merc tr-stat :inline :offset-assert 0) (emerc tr-stat :inline :offset-assert 16) (mercneric tr-stat :inline :offset-assert 32) @@ -22151,10 +25810,11 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| + (deftype perf-stat (structure) + "Performance statistics for a single 'bucket' or category. Unlike the more general profile-bars, + this records statistics like cache hits/instruction counts." ((frame-number uint32 :offset-assert 0) (count uint32 :offset-assert 4) (cycles uint32 :offset-assert 8) @@ -22169,38 +25829,104 @@ (to-spr-waits uint32 :offset-assert 44) (from-spr-waits uint32 :offset-assert 48) ) + :pack-me :method-count-assert 14 :size-assert #x34 :flag-assert #xe00000034 (:methods (perf-stat-method-9 () none) ;; 9 ;; (perf-stat-method-9 () none) - (perf-stat-method-10 () none) ;; 10 ;; (print-to-stream (_type_ string basic) none) - (perf-stat-method-11 () none) ;; 11 ;; (start-profiling! (_type_) none) - (perf-stat-method-12 () none) ;; 12 ;; (stop-profiling! (_type_) none) - (perf-stat-method-13 () none) ;; 13 ;; (update-wait-stats (_type_ uint uint uint) none) + (print-to-stream (_type_ string basic) none) ;; 10 + (start-profiling! (_type_) none) ;; 11 + (stop-profiling! (_type_) none) ;; 12 + (update-wait-stats (_type_ uint uint uint) none) ;; 13 ) ) -|# -#| (deftype perf-stat-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data perf-stat :dynamic :offset-assert 16) ;; guessed by decompiler + "Array of all stats for all buckets." + ((data perf-stat :dynamic :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -;; (define-extern perf-stat-bucket->string function) ;; (function perf-stat-bucket string) +;; +++stats-h:perf-stat-bucket +(defenum perf-stat-bucket + :type uint32 + (all-code) + (spatial-hash-build) + (spatial-hash-search) + (collide) + (collide-list) + (collide-fill) + (actor-hash) + (nav) + (nav-dma-all) + (nav-dma-read) + (nav-dma-write) ;; 10 + (nav-dma-work) + (nav-part1) + (nav-part2) + (nav-part3) + (nav-part4) + (nav-part5) + (nav-part6) + (nav-part7) + (nav-part8) + (nav-part9) ;; 20 + (nav-part10) + + ;; renamed + (rb-all) ;; add-to-translation + (rb-fc) ;; update-current-poly + (rb-physics) ;; clamp-vector-to-mesh + (rb-callback) ;; ray-step + (rb-move) ;; update-spheres + (rb-probe) ;; travel-around-spheres + (vqp-all) ;; avoid-spheres + (vqp-sound) ;; check-vector-collision-with-nav-spheres + (vqp-parts) ;; find-nearest-poly + (vqp-ja-post) ;; find-containing-poly ;; 30 + + (vqp-sections) ;; generate-velocity + (vqp-post) ;; apply-rotation + (vqp-common) ;; apply-velocity + (find-nearest-poly) ;; travel-post + (find-containing-poly) ;; common-post + (misc) + (mercneric) + (tie-generic) + (background) ;; 40 + (drawable) + (tfrag) + (tfrag-scissor) + (inst-shrub) + (proto-shrub) + (inst-tie) + (proto-tie) + (bones) + (camera) + (foreground) ;; 50 + ;; hover / vehicle / hud renames + (vehicle-ai) ;; hover-path + (vehicle-ai-calculate-vector) ;; hover-spheres + (update-los) ;; hover-update + (race-line) ;; hover-move + (hud) ;; hover-find-closest + (hud-format) ;; update-los + ;; explicit HUD buckets + (hud-draw-string) ;; perf-stat-bucket-57 + (hud-draw-sprite) ;; perf-stat-bucket-58 +) +;; ---stats-h:perf-stat-bucket + +(define-extern perf-stat-bucket->string (function perf-stat-bucket string)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; bsp-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype bsp-node (structure) ((front int16 :offset-assert 0) (back int16 :offset-assert 2) @@ -22213,25 +25939,90 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| -(deftype bsp-header (drawable) - ((all-visible-list (pointer uint8) :offset-assert 28) ;; guessed by decompiler - (visible-list-length int16 :offset-assert 32) - (drawable-trees drawable-tree-array :offset-assert 36) ;; guessed by decompiler - (pat pointer :offset-assert 40) ;; guessed by decompiler - (pat-length int32 :offset-assert 44) - ) - :method-count-assert 19 - :size-assert #x190 - :flag-assert #x1300000190 - (:methods - (bsp-header-method-17 () none) ;; 17 ;; (birth (_type_) none) - (bsp-header-method-18 () none) ;; 18 ;; (deactivate-entities (_type_) none) - ) - ) -|# +;; TODO - just copied from jak 3, size and such does match +;; (deftype bsp-header (drawable) +;; "The bsp-header is really an entire level. +;; This probably started as a very simple structure, but now it is extremely complicated." +;; ((info file-info :offset 4) +;; (all-visible-list (pointer uint8) :offset-assert 32) ;; guessed by decompiler +;; (visible-list-length int16 :offset-assert 36) +;; (extra-vis-list-length int16 :offset-assert 38) +;; (drawable-trees drawable-tree-array :offset-assert 40) ;; guessed by decompiler +;; (pat pointer :offset-assert 44) ;; guessed by decompiler +;; (pat-length int32 :offset-assert 48) +;; ;; jak2: unlikely to match jak 3 exactly!! +;; (texture-remap-table (pointer uint64) :offset-assert 52) +;; (texture-remap-table-len int32 :offset-assert 56) +;; (texture-ids (pointer texture-id) :offset-assert 60) +;; (texture-page-count int32 :offset-assert 64) +;; (unknown-basic basic :offset-assert 68) ;; seems to be 0 everywhere. +;; (name symbol :offset-assert 72) +;; (nickname symbol :offset-assert 76) +;; (vis-info level-vis-info 8 :offset-assert 80) +;; (actors drawable-inline-array-actor :offset-assert 112) +;; (cameras (array entity-camera) :offset-assert 116) +;; (nodes (inline-array bsp-node) :offset-assert 120) + +;; ;; jak2: unlikely to match jak 3 exactly!! +;; (level level :offset-assert 124) +;; (current-leaf-idx uint16 :offset-assert 128) +;; (texture-flags texture-page-flag 10 :offset-assert 130) +;; (cam-outside-bsp uint8 :offset 152) +;; (cam-using-back uint8 :offset-assert 153) +;; (cam-box-idx uint16 :offset-assert 154) +;; (ambients symbol :offset-assert 156) ;; now just #t? +;; (subdivide-close float :offset 160) +;; (subdivide-far float :offset-assert 164) +;; (race-meshes (array entity-race-mesh) :offset-assert 168) +;; (actor-birth-order (pointer uint32) :offset 172) +;; (light-hash light-hash :offset-assert 176) +;; (nav-meshes (array entity-nav-mesh) :offset-assert 180) +;; (actor-groups (array actor-group) :offset-assert 184) +;; (region-trees (array drawable-tree-region-prim) :offset 188) +;; (region-array region-array :offset-assert 192) +;; (collide-hash collide-hash :offset 196) +;; ; ;; 200 is some array +;; (wind-array uint32 :offset 200) +;; ; ;; 204 is maybe that array's length +;; (wind-array-length int32 :offset 204) +;; (city-level-info city-level-info :offset 208) +;; (vis-spheres vector-array :offset 216) +;; (vis-spheres-length uint32 :offset 248) +;; (region-tree drawable-tree-region-prim :offset 252) + +;; (tfrag-masks texture-masks-array :offset 256) +;; (tfrag-closest (pointer float) :offset-assert 260) +;; (tfrag-mask-count uint32 :offset 260) + +;; (shrub-masks texture-masks-array :offset-assert 264) +;; (shrub-closest (pointer float) :offset-assert 268) +;; (shrub-mask-count uint32 :offset 268) + +;; (alpha-masks texture-masks-array :offset-assert 272) +;; (alpha-closest (pointer float) :offset-assert 276) +;; (alpha-mask-count uint32 :offset 276) + +;; (water-masks texture-masks-array :offset-assert 280) +;; (water-closest (pointer float) :offset-assert 284) +;; (water-mask-count uint32 :offset 284) + +;; (bsp-scale vector :inline :offset 288) +;; (bsp-offset vector :inline :offset-assert 304) + +;; (hfrag-drawable drawable :offset 320) + + +;; (end uint8 :offset #x18f) +;; ) +;; :method-count-assert 19 +;; :size-assert #x190 +;; :flag-assert #x1300000190 +;; (:methods +;; (birth (_type_) none) ;; 17 +;; (deactivate-entities (_type_) none) ;; 18 +;; ) +;; ) #| (deftype game-level (basic) @@ -22260,23 +26051,24 @@ ) |# -#| (deftype collide-stats (structure) + "Very strange collide stats type. It has been somewhat broken in all versions of the game. + The final stopwatch is cut off. For jak 3, I just fixed it." ((calls uint32 :offset-assert 0) (spheres uint32 :offset-assert 4) (nodes uint32 :offset-assert 8) (frags uint32 :offset-assert 12) (tris uint32 :offset-assert 16) (output uint32 :offset-assert 20) - (total-target stopwatch :inline :offset-assert 28) - (target-cache-fill stopwatch :inline :offset-assert 60) - (target-ray-poly stopwatch :inline :offset-assert 92) + (junk (pointer uint32) 24) + ; (total-target stopwatch :inline :offset-assert 28) ;; uint32 8 + ; (target-cache-fill stopwatch :inline :offset-assert 60) ;; uint32 8 + ; (target-ray-poly stopwatch :inline :offset-assert 92) ;; uint32 6 ) :method-count-assert 9 :size-assert #x78 :flag-assert #x900000078 ) -|# ;; (define-extern inspect-bsp-tree function) ;; (function bsp-header bsp-node none) ;; (define-extern map-bsp-tree function) ;; (function (function bsp-node none) bsp-header bsp-node none) @@ -22285,8 +26077,13 @@ ;; collide-cache-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type collide-cache-prim structure) +(declare-type collide-using-spheres-params structure) +(declare-type instance-tie structure) + (deftype collide-puss-sphere (structure) + "A query sphere from the user for the porbe-using-spheres query. + This is used internally by the collide-cache implementation." ((bsphere sphere :inline :offset-assert 0) (bbox4w bounding-box4w :inline :offset-assert 16) ) @@ -22294,68 +26091,84 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype collide-puss-work (structure) + "Scratchpad memory map for probe-using-spheres query." ((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 :offset-assert 96) ;; guessed by decompiler + (spheres collide-puss-sphere 64 :inline :offset-assert 96) ;; guessed by decompiler ) :method-count-assert 11 :size-assert #xc60 :flag-assert #xb00000c60 (:methods - (collide-puss-work-method-9 () none) ;; 9 ;; (check-mesh-prim-against-spheres (_type_ collide-cache-prim collide-using-spheres-params) symbol) - (collide-puss-work-method-10 () none) ;; 10 ;; (check-sphere-prim-against-spheres (_type_ collide-cache-prim collide-using-spheres-params) symbol) + (check-mesh-prim-against-spheres "Check a single mesh prim against the spheres in this type." (_type_ collide-cache-prim collide-using-spheres-params) symbol) ;; 9 + (check-sphere-prim-against-spheres "Check a single sphere prim against the spheres in this type." (_type_ collide-cache-prim collide-using-spheres-params) symbol) ;; 10 ) ) -|# -#| (deftype collide-cache-tri (structure) - ((vertex vector 3 :offset-assert 0) ;; guessed by decompiler + "A single triangle inside the collision cache. + Contains a reference back to the source object (like a collide-shape or water-control), and the prim itself." + ((vertex vector 3 :inline :offset-assert 0) ;; guessed by decompiler (extra-quad uint8 16 :offset-assert 48) ;; guessed by decompiler - (pat pat-surface :offset-assert 48) ;; guessed by decompiler - (collide-ptr basic :offset-assert 52) - (prim-index uint16 :offset-assert 56) - (user16 uint16 :offset-assert 58) - (user32 uint32 :offset-assert 60) + (pat pat-surface :offset 48) ;; guessed by decompiler + (collide-ptr basic :offset 52) + (prim-index uint16 :offset 56) + (user16 uint16 :offset 58) + (user32 uint32 :offset 60) + (clear-flags uint128 :offset 48) ;; added ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| +;; +++collide-cache-h:prim-type +(defenum prim-type + :type int8 + (prim -2) + (sphere -1) + (group 0) + (mesh 1) + (fake-prim 2) + ) +;; ---collide-cache-h:prim-type + +(declare-type collide-list structure) (deftype collide-cache-prim (structure) + "A primitive inside the collide-cache. + This can represent a sphere, a triangle mesh, or a group of other primitives within a bounding sphere." ((prim-core collide-prim-core :inline :offset-assert 0) (extra-quad uint8 16 :offset-assert 32) ;; guessed by decompiler - (ccache collide-cache :offset-assert 32) ;; guessed by decompiler - (prim collide-shape-prim :offset-assert 36) ;; guessed by decompiler - (first-tri uint16 :offset-assert 40) - (num-tris uint16 :offset-assert 42) - (extra basic :offset-assert 44) - (world-sphere vector :inline :offset-assert 0) - (collide-as collide-spec :offset-assert 16) ;; guessed by decompiler - (action collide-action :offset-assert 24) ;; guessed by decompiler - (prim-type int8 :offset-assert 28) ;; prim-type + (ccache collide-cache :offset 32) ;; guessed by decompiler + (prim collide-shape-prim :offset 36) ;; guessed by decompiler + (first-tri uint16 :offset 40) + (num-tris uint16 :offset 42) + (extra basic :offset 44) + (world-sphere vector :inline :offset 0) + (collide-as collide-spec :offset 16) ;; guessed by decompiler + (action collide-action :offset 24) ;; guessed by decompiler + (prim-type prim-type :offset 28) ;; prim-type ) :method-count-assert 11 :size-assert #x30 :flag-assert #xb00000030 (:methods - (collide-cache-prim-method-9 () none) ;; 9 ;; (resolve-moving-sphere-tri (_type_ collide-query sphere vector float collide-action) float) - (collide-cache-prim-method-10 () none) ;; 10 ;; (resolve-moving-sphere-sphere (_type_ collide-query sphere vector float collide-action) float) + (resolve-moving-sphere-tri (_type_ collide-query sphere vector float collide-action) float) ;; 9 + (resolve-moving-sphere-sphere (_type_ collide-query sphere vector float collide-action) float) ;; 10 ) ) -|# -#| (deftype collide-cache (basic) + "The collide-cache is a structure to accelerate collision queries. + In particular, it helps with queries where you don't know what you might hit. + It can detect collision with the background geometry, foreground dynamic collision shapes (spheres and meshes), and water. + To use it, it must first be 'filled' with geometry. Then you can manually inspect the geometry, or use one of the queries. + The supported queries are 'line-sphere' (raycast) and 'spheres' (check if intersecting anything). + It is not useful for ollision queries against a specific foreground object, like 'am I on top of platform X right now?'." ((num-tris int32 :offset-assert 4) (max-tris int32 :offset-assert 8) (num-prims int32 :offset-assert 12) @@ -22365,14 +26178,16 @@ (collide-box bounding-box :inline :offset-assert 32) (collide-box4w bounding-box4w :inline :offset-assert 64) (collide-with collide-spec :offset-assert 96) ;; guessed by decompiler - (unused uint32 :offset-assert 100) - (prims collide-cache-prim :offset-assert 112) ;; guessed by decompiler + ;; TODO - substantially changed, not sure about this yet + (unused uint32 3 :offset-assert 100) + (prims collide-cache-prim 4 :offset-assert 112) ;; guessed by decompiler (tris collide-cache-tri :offset-assert 128) ;; guessed by decompiler ) :method-count-assert 28 :size-assert #x84 :flag-assert #x1c00000084 (:methods + (new (symbol type int int) _type_) (collide-cache-method-9 () none) ;; 9 ;; (debug-draw (_type_) none) (collide-cache-method-10 () none) ;; 10 ;; (fill-and-probe-using-line-sphere (_type_ collide-query) float) (collide-cache-method-11 () none) ;; 11 ;; (fill-and-probe-using-spheres (_type_ collide-query) symbol) @@ -22394,68 +26209,67 @@ (collide-cache-method-27 () none) ;; 27 ) ) -|# -#| (deftype collide-list-item (structure) + "Entry on the broad-phase collision list. + Can represent instanced collision, as a TIE instance, or a single non-instanced mesh fragment." ((mesh instance-tie :offset-assert 0) ;; guessed by decompiler (inst basic :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype collide-list (structure) + "List of items returned by the broad-phase collision query." ((num-items int32 :offset-assert 0) - (items collide-list-item 256 :offset-assert 16) ;; guessed by decompiler + (items collide-list-item 256 :inline :offset 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x810 :flag-assert #x900000810 ) -|# -;; (define-extern *collide-cache* object) ;; collide-cache -;; (define-extern *collide-list* object) ;; collide-list +(define-extern *collide-cache* collide-cache) +(define-extern *collide-list* collide-list) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype collide-query (structure) + "Very general collision-query structure. The meaning is different depending on where it used. + This has both inputs from the user, and collision results." ((best-other-tri collide-tri-result :inline :offset-assert 0) - (best-my-tri collide-tri-result :inline :offset-assert 0) + (best-my-tri collide-tri-result :inline :offset 0) (ignore-processes process-tree 2 :offset-assert 88) ;; guessed by decompiler - (ignore-process0 process-tree :offset-assert 88) ;; guessed by decompiler - (ignore-process1 process-tree :offset-assert 92) ;; guessed by decompiler + (ignore-process0 process-tree :offset 88) ;; guessed by decompiler + (ignore-process1 process-tree :offset 92) ;; guessed by decompiler (ignore-pat pat-surface :offset-assert 96) ;; guessed by decompiler + (ignore-pat-s32 int32 :offset 96) (collide-with collide-spec :offset-assert 100) ;; guessed by decompiler - (overlay-params uint32 3 :offset-assert 112) ;; guessed by decompiler + (collide-with-s32 int32 :offset 100) + (overlay-params uint32 3 :offset 112) ;; guessed by decompiler (bbox bounding-box :inline :offset-assert 128) (bbox4w bounding-box4w :inline :offset-assert 160) (bsphere sphere :inline :offset-assert 192) (start-pos vector :inline :offset-assert 208) (move-dist vector :inline :offset-assert 224) (rlength vector :inline :offset-assert 240) - (exit-planes plane 2 :offset-assert 256) ;; guessed by decompiler - (radius float :offset-assert 268) - (inv-mat matrix :inline :offset-assert 288) - (final-pos vector :inline :offset-assert 240) - (spheres (inline-array sphere) :offset-assert 112) ;; guessed by decompiler - (num-spheres uint32 :offset-assert 116) - (solid-only symbol :offset-assert 120) ;; guessed by decompiler - (best-dist float :offset-assert 112) - (best-other-prim collide-shape-prim :offset-assert 116) ;; guessed by decompiler - (best-my-prim collide-shape-prim :offset-assert 120) ;; guessed by decompiler - (move-vec vector :inline :offset-assert 224) - (best-u float :offset-assert 112) - (action-mask collide-action :offset-assert 352) ;; guessed by decompiler - (nav-mesh basic :offset-assert 116) - (best-ccache-prim collide-cache-prim :offset-assert 116) + (exit-planes plane 2 :inline :offset-assert 256) ;; guessed by decompiler + (radius float :offset 268) + (inv-mat matrix :inline :offset 288) + (spheres (inline-array sphere) :offset 112 :score 1) ;; guessed by decompiler + (num-spheres uint32 :offset 116) + (solid-only symbol :offset 120) ;; guessed by decompiler + (best-dist float :offset 112 :score 2) + (best-other-prim collide-shape-prim :offset 116 :score 1) ;; guessed by decompiler + (best-my-prim collide-shape-prim :offset 120 :score 1) ;; guessed by decompiler + (move-vec vector :inline :offset 224) + (best-u float :offset 112 :score -1) + (action-mask collide-action :offset 352) ;; guessed by decompiler (local-box4w bounding-box4w :inline :offset-assert 368) (search-box bounding-box4w :inline :offset-assert 400) (search-vector vector4w :inline :offset-assert 432) @@ -22472,122 +26286,130 @@ :size-assert #x21c :flag-assert #x90000021c ) -|# -;; (define-extern *collide-test-flag* object) ;; symbol +(define-extern *collide-test-flag* symbol) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; shrubbery-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype billboard (drawable) + "A billboard for shrubbery in the distance. This is simple a quad that faces the camera. + The only data needed is the texture/mode. The location is determined by bsphere." ((flat adgif-shader :inline :offset-assert 32) ) :method-count-assert 17 :size-assert #x70 :flag-assert #x1100000070 ) -|# -#| (deftype shrub-view-data (structure) + "Camera and general settings for shrubbery VU1 program." ((data uint128 3 :offset-assert 0) ;; guessed by decompiler - (texture-giftag qword :inline :offset-assert 0) ;; gs-gif-tag :inline - (consts vector :inline :offset-assert 16) - (fog-clamp vector :inline :offset-assert 32) - (tex-start-ptr int32 :offset-assert 16) - (gifbufsum float :offset-assert 16) - (mtx-buf-ptr int32 :offset-assert 20) - (exp23 float :offset-assert 20) - (fog-0 float :offset-assert 24) - (fog-1 float :offset-assert 28) - (fog-min float :offset-assert 32) - (fog-max float :offset-assert 36) + (texture-giftag gs-gif-tag :inline :offset 0) ;; :inline + (consts vector :inline :offset 16) + (fog-clamp vector :inline :offset 32) + (tex-start-ptr int32 :offset 16) + (gifbufsum float :offset 16) + (mtx-buf-ptr int32 :offset 20) + (exp23 float :offset 20) + (fog-0 float :offset 24) + (fog-1 float :offset 28) + (fog-min float :offset 32) + (fog-max float :offset 36) ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype shrubbery (drawable) - ((textures (inline-array adgif-shader) :offset-assert 4) ;; guessed by decompiler - (header qword :offset-assert 8) - (obj-qwc uint8 :offset-assert 12) - (vtx-qwc uint8 :offset-assert 13) - (col-qwc uint8 :offset-assert 14) - (stq-qwc uint8 :offset-assert 15) - (obj uint32 :offset-assert 16) - (vtx uint32 :offset-assert 20) - (col uint32 :offset-assert 24) - (stq uint32 :offset-assert 28) + "Prototype (mesh/geometry) for a shrub. not _really_ a drawable in any way, as it + overwrites all the normal drawable fields." + ((textures (inline-array adgif-shader) :offset 4) ;; guessed by decompiler + (header qword :offset 8) + (obj-qwc uint8 :offset 12) + (vtx-qwc uint8 :offset 13) + (col-qwc uint8 :offset 14) + (stq-qwc uint8 :offset 15) + (obj uint32 :offset 16) + (vtx uint32 :offset 20) + (col uint32 :offset 24) + (stq uint32 :offset 28) ) :method-count-assert 17 :size-assert #x20 :flag-assert #x1100000020 ) -|# -#| (deftype instance-shrubbery (instance) + "Instance of a shrub." ((flat-normal vector :inline :offset-assert 64) - (flat-hwidth float :offset-assert 76) - (color uint32 :offset-assert 8) + (flat-hwidth float :offset 76) + (color uint32 :offset 8) ) :method-count-assert 17 :size-assert #x50 :flag-assert #x1100000050 ) -|# -;; (deftype drawable-inline-array-instance-shrub (drawable-inline-array) -;; () -;; :flag-assert #x1100000074 -;; ) +(deftype drawable-inline-array-instance-shrub (drawable-inline-array) + "Array of shrub instances stored in the level data." + ((data instance-shrubbery 1 :inline :offset-assert 32) + (pad uint32) + ) + :flag-assert #x1100000074 + ) -;; (deftype drawable-tree-instance-shrub (drawable-tree) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-instance-shrub (drawable-tree) + "Drawable-tree for the shrubs." + ((info prototype-array-shrub-info :offset 8) + (colors-added time-of-day-palette :offset 12) ;; added + ) + :flag-assert #x1100000020 + ) -#| (deftype generic-shrub-fragment (drawable) - ((textures (inline-array adgif-shader) :offset-assert 4) ;; guessed by decompiler - (vtx-cnt uint32 :offset-assert 8) - (cnt-qwc uint8 :offset-assert 12) - (vtx-qwc uint8 :offset-assert 13) - (col-qwc uint8 :offset-assert 14) - (stq-qwc uint8 :offset-assert 15) - (cnt uint32 :offset-assert 16) - (vtx uint32 :offset-assert 20) - (col uint32 :offset-assert 24) - (stq uint32 :offset-assert 28) + "Shrub data, converted into the format for generic. + The shrub renderer doesn't support clipping, so it falls back to generic. + This requires storing the data for all shrubs prototype twice!" + ((textures (inline-array adgif-shader) :offset 4) ;; guessed by decompiler + (vtx-cnt uint32 :offset 8) + (cnt-qwc uint8 :offset 12) + (vtx-qwc uint8 :offset 13) + (col-qwc uint8 :offset 14) + (stq-qwc uint8 :offset 15) + (cnt uint32 :offset 16) + (vtx uint32 :offset 20) + (col uint32 :offset 24) + (stq uint32 :offset 28) ) :method-count-assert 17 :size-assert #x20 :flag-assert #x1100000020 ) -|# -;; (deftype prototype-shrubbery (drawable-inline-array) -;; () -;; :flag-assert #x1100000044 -;; ) +(deftype prototype-shrubbery (drawable-inline-array) + "Array of shrub prototypes." + ((data shrubbery 1 :inline :offset-assert 32) + (pad uint32) + ) + :flag-assert #x1100000044 + ) -;; (deftype prototype-trans-shrubbery (prototype-shrubbery) -;; () -;; :flag-assert #x1100000044 -;; ) +(deftype prototype-trans-shrubbery (prototype-shrubbery) + "Array of transparent shrub prototypes." + () + :flag-assert #x1100000044 + ) -;; (deftype prototype-generic-shrub (drawable-group) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype prototype-generic-shrub (drawable-group) + () + :flag-assert #x1100000020 + ) -#| (deftype shrubbery-matrix (structure) + "Instance matrix for a shrub, contains interpolated color." ((mat matrix :inline :offset-assert 0) (color qword :inline :offset-assert 64) ) @@ -22595,10 +26417,9 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype shrub-near-packet (structure) + "DMA templates for generic rendering of shrubs." ((matrix-tmpl dma-packet :inline :offset-assert 0) (header-tmpl dma-packet :inline :offset-assert 16) (stq-tmpl dma-packet :inline :offset-assert 32) @@ -22606,28 +26427,27 @@ (vertex-tmpl dma-packet :inline :offset-assert 64) (mscal-tmpl dma-packet :inline :offset-assert 80) (init-tmpl dma-packet :inline :offset-assert 96) - (init-data qword 8 :offset-assert 112) ;; guessed by decompiler + (init-data qword 2 :inline :offset-assert 112) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x90 :flag-assert #x900000090 ) -|# -#| (deftype instance-shrub-work (structure) - ((dummy qword 3 :offset-assert 0) ;; guessed by decompiler - (chaina qword 8 :offset-assert 48) ;; guessed by decompiler - (chainb qword 8 :offset-assert 176) ;; guessed by decompiler + "Scratchpad layout for generating shrub DMA." + ((dummy qword 3 :inline :offset-assert 0) ;; guessed by decompiler + (chaina qword 8 :inline :offset-assert 48) ;; guessed by decompiler + (chainb qword 8 :inline :offset-assert 176) ;; guessed by decompiler (colors rgba 1024 :offset-assert 304) ;; guessed by decompiler - (matrix-tmpl qword 20 :offset-assert 4400) ;; guessed by decompiler - (count-tmpl vector4w 20 :offset-assert 4720) ;; guessed by decompiler + (matrix-tmpl qword 20 :inline :offset-assert 4400) ;; guessed by decompiler + (count-tmpl vector4w 20 :inline :offset-assert 4720) ;; guessed by decompiler (mscalf-tmpl dma-packet :inline :offset-assert 5040) (mscalf-ret-tmpl dma-packet :inline :offset-assert 5056) (adgif-tmpl dma-gif-packet :inline :offset-assert 5072) (billboard-tmpl dma-gif-packet :inline :offset-assert 5104) (billboard-const vector :inline :offset-assert 5136) - (shrub-near-packets shrub-near-packet 6 :offset-assert 5152) ;; guessed by decompiler + (shrub-near-packets shrub-near-packet 6 :inline :offset-assert 5152) ;; guessed by decompiler (dma-ref dma-packet :inline :offset-assert 6016) (dma-end dma-packet :inline :offset-assert 6032) (wind-const vector :inline :offset-assert 6048) @@ -22640,8 +26460,8 @@ (bb-color vector :inline :offset-assert 6160) (min-dist vector :inline :offset-assert 6176) (temp-vec vector :inline :offset-assert 6192) - (guard-plane plane 4 :offset-assert 6208) ;; guessed by decompiler - (plane plane 4 :offset-assert 6272) ;; guessed by decompiler + (guard-plane plane 4 :inline :offset-assert 6208) ;; guessed by decompiler + (plane plane 4 :inline :offset-assert 6272) ;; guessed by decompiler (last uint32 4 :offset-assert 6336) ;; guessed by decompiler (next uint32 4 :offset-assert 6352) ;; guessed by decompiler (count uint16 4 :offset-assert 6368) ;; guessed by decompiler @@ -22656,19 +26476,19 @@ (to-spr uint32 :offset-assert 6412) (from-spr uint32 :offset-assert 6416) (shrub-count uint32 :offset-assert 6420) - (stack-ptr uint32 :offset-assert 6400) - (node uint32 6 :offset-assert 6428) ;; guessed by decompiler + (stack-ptr2 uint32 :offset 6400) + (node uint32 6 :offset 6428) ;; guessed by decompiler (length uint32 6 :offset-assert 6452) ;; guessed by decompiler (prototypes uint32 :offset-assert 6476) - (bucket-ptr uint32 :offset-assert 6404) - (start-bank uint8 20 :offset-assert 6484) ;; guessed by decompiler + (bucket-ptr2 uint32 :offset 6404) + (start-bank uint8 20 :offset 6484) ;; guessed by decompiler (buffer-index uint32 :offset-assert 6504) (current-spr uint32 :offset-assert 6508) (current-mem uint32 :offset-assert 6512) (current-shrub-near-packet uint32 :offset-assert 6516) (current-shrub-near-trans-packet uint32 :offset-assert 6520) - (to-spr uint32 :offset-assert 6412) - (dma-buffer basic :offset-assert 6528) + (to-spr2 uint32 :offset 6412) + (dma-buffer basic :offset 6528) (near-last uint32 :offset-assert 6532) (near-next uint32 :offset-assert 6536) (near-count uint32 :offset-assert 6540) @@ -22688,9 +26508,7 @@ :size-assert #x19bc :flag-assert #x9000019bc ) -|# -#| (deftype instance-shrub-dma (structure) ((instancea uint128 325 :offset-assert 0) ;; guessed by decompiler (instanceb uint128 325 :offset-assert 5200) ;; guessed by decompiler @@ -22701,17 +26519,16 @@ :size-assert #x38a0 :flag-assert #x9000038a0 ) -|# -;; (define-extern shrubbery-login-post-texture function) ;; (function shrubbery none) -;; (define-extern *shrub-state* object) ;; int +(define-extern shrubbery-login-post-texture "Do some weird fix-up to the shrubbery textures. this is likely to present normal-looking adgifs to the texture system, but then we scramble them up for easier consumption by VU1." (function shrubbery none)) +(define-extern *shrub-state* int) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; tie-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype tie-fragment-debug (structure) + "Optional debug information about a tie-fragment." ((num-tris uint16 :offset-assert 0) (num-dverts uint16 :offset-assert 2) (debug-lines (array vector-array) :offset-assert 4) ;; guessed by decompiler @@ -22720,17 +26537,16 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype tie-fragment (drawable) - ((gif-ref (inline-array adgif-shader) :offset-assert 4) ;; guessed by decompiler - (point-ref uint32 :offset-assert 8) - (color-index uint16 :offset-assert 12) - (base-colors uint8 :offset-assert 14) - (tex-count uint16 :offset-assert 32) - (gif-count uint16 :offset-assert 34) - (vertex-count uint16 :offset-assert 36) + "A mesh fragment of a TIE. This is a chunk of mesh that is rendered by VU1, stored as DMA chains." + ((gif-ref (inline-array adgif-shader) :offset 4) ;; guessed by decompiler + (point-ref uint32 :offset 8) + (color-index uint16 :offset 12) + (base-colors uint8 :offset 14) + (tex-count uint16 :offset 32) + (gif-count uint16 :offset 34) + (vertex-count uint16 :offset 36) (color-count uint16 :offset-assert 38) (dp-ref uint32 :offset-assert 40) (dp-qwc uint32 :offset-assert 44) @@ -22744,65 +26560,62 @@ :size-assert #x40 :flag-assert #x1100000040 ) -|# -#| (deftype instance-tie (instance) - ((color-indices uint32 :offset-assert 8) - (bucket-ptr prototype-bucket-tie :offset-assert 12) ;; guessed by decompiler - (max-scale uint16 :offset-assert 38) - (rmin-scale uint16 :offset-assert 54) + "A TIE model instance." + ((color-indices uint32 :offset 8) + (bucket-ptr prototype-bucket-tie :offset 12) ;; guessed by decompiler + (max-scale uint16 :offset 38) + (rmin-scale uint16 :offset 54) ) :method-count-assert 17 :size-assert #x40 :flag-assert #x1100000040 ) -|# -;; (deftype drawable-inline-array-instance-tie (drawable-inline-array) -;; () -;; :flag-assert #x1100000064 -;; ) +(deftype drawable-inline-array-instance-tie (drawable-inline-array) + "Array of tie instances stored in the level." + ((data instance-tie 1 :inline :offset-assert 32) ;; not sure on type here + (pad uint32) + ) + :flag-assert #x1100000064 + ) -#| (deftype drawable-tree-instance-tie (drawable-tree) - ((id int16 :offset-assert 0) - (bsphere vector :inline :offset-assert 12) - (length int16 :offset-assert 2) - (data drawable :dynamic :offset-assert 28) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (prototypes proxy-prototype-array-tie :offset-assert 4) ;; guessed by decompiler + "Top-level drawable-tree for TIEs" + ((prototypes proxy-prototype-array-tie :offset 8) ;; guessed by decompiler ) :method-count-assert 17 :size-assert #x20 :flag-assert #x1100000020 ) -|# -;; (deftype prototype-tie (drawable-inline-array) -;; () -;; :flag-assert #x1100000064 -;; ) +(deftype prototype-tie (drawable-inline-array) + "Prototype for a TIE: just an array of fragments." + ((data tie-fragment 1 :inline :offset-assert 32) + (pad uint32) + ) + :flag-assert #x1100000064 + ) -#| (deftype tie-matrix (structure) + "Per-instance matrix for TIE VU1 rendering." ((mat matrix :inline :offset-assert 0) (morph qword :inline :offset-assert 64) (fog qword :inline :offset-assert 80) - (envmap-flag uint32 :offset-assert 80) - (guard-flag uint32 :offset-assert 84) - (vertex-alpha float :offset-assert 88) - (fog-value float :offset-assert 92) - (fixed-alpha float :offset-assert 68) + (envmap-flag uint32 :offset 80) + (guard-flag uint32 :offset 84) + (vertex-alpha float :offset 88) + (fog-value float :offset 92) + (fixed-alpha float :offset 68) ) :method-count-assert 9 :size-assert #x60 :flag-assert #x900000060 ) -|# -#| (deftype instance-tie-work (structure) + "workspace for TIE instance DMA generation" ((wind-const vector :inline :offset-assert 0) (hmge-d vector :inline :offset-assert 16) (hvdf-offset vector :inline :offset-assert 32) @@ -22811,7 +26624,7 @@ (far-morph vector :inline :offset-assert 80) (dist-test vector :inline :offset-assert 96) (min-dist vector :inline :offset-assert 112) - (guard-plane plane 4 :offset-assert 128) ;; guessed by decompiler + (guard-plane plane 4 :inline :offset-assert 128) ;; guessed by decompiler (upload-color-0 dma-packet :inline :offset-assert 192) (upload-color-1 dma-packet :inline :offset-assert 208) (upload-color-2 dma-packet :inline :offset-assert 224) @@ -22854,24 +26667,23 @@ :size-assert #x22c :flag-assert #x90000022c ) -|# -#| (deftype instance-tie-dma (structure) - ((banka instance-tie 32 :offset-assert 4) ;; guessed by decompiler - (bankb instance-tie 32 :offset-assert 2052) ;; guessed by decompiler + "Scratchpad memory layout for TIE instance DMA generation." + ((banka instance-tie 32 :inline :offset-assert 0) ;; guessed by decompiler + (bankb instance-tie 32 :inline :offset-assert 2048) ;; guessed by decompiler (outa uint128 256 :offset-assert 4096) ;; guessed by decompiler (outb uint128 256 :offset-assert 8192) ;; guessed by decompiler - (work instance-tie-work :offset-assert 12288) + ;; this is outside the type???? + (work instance-tie-work :dynamic :offset-assert 12288) ) :method-count-assert 9 :size-assert #x3000 :flag-assert #x900003000 ) -|# -#| (deftype prototype-tie-work (structure) + "workspace for TIE protype DMA generation." ((upload-flushe dma-packet :inline :offset-assert 0) (upload-palette dma-packet :inline :offset-assert 16) (upload-model-0 dma-packet :inline :offset-assert 32) @@ -22902,65 +26714,64 @@ (wait-to-spr uint32 :offset-assert 400) (mood mood-context :offset-assert 404) (wide-level-index uint32 :offset-assert 408) + (prototype-tie-work-todo-01 uint32 :offset-assert 412) (last uint32 16 :offset-assert 416) ;; guessed by decompiler (next uint32 16 :offset-assert 480) ;; guessed by decompiler (count uint16 16 :offset-assert 544) ;; guessed by decompiler - (tie-last uint32 :offset-assert 416) - (tie-next uint32 :offset-assert 480) - (tie-count uint16 :offset-assert 544) - (trans-last uint32 :offset-assert 420) - (trans-next uint32 :offset-assert 484) - (trans-count uint16 :offset-assert 546) - (water-last uint32 :offset-assert 424) - (water-next uint32 :offset-assert 488) - (water-count uint16 :offset-assert 548) - (scissor-last uint32 :offset-assert 428) - (scissor-next uint32 :offset-assert 492) - (scissor-count uint16 :offset-assert 550) - (scissor-trans-last uint32 :offset-assert 432) - (scissor-trans-next uint32 :offset-assert 496) - (scissor-trans-count uint16 :offset-assert 552) - (scissor-water-last uint32 :offset-assert 436) - (scissor-water-next uint32 :offset-assert 500) - (scissor-water-count uint16 :offset-assert 554) - (envmap-last uint32 :offset-assert 440) - (envmap-next uint32 :offset-assert 504) - (envmap-count uint16 :offset-assert 556) - (envmap-trans-last uint32 :offset-assert 444) - (envmap-trans-next uint32 :offset-assert 508) - (envmap-trans-count uint16 :offset-assert 558) - (envmap-water-last uint32 :offset-assert 448) - (envmap-water-next uint32 :offset-assert 512) - (envmap-water-count uint16 :offset-assert 560) - (envmap-scissor-last uint32 :offset-assert 452) - (envmap-scissor-next uint32 :offset-assert 516) - (envmap-scissor-count uint16 :offset-assert 562) - (envmap-scissor-trans-last uint32 :offset-assert 456) - (envmap-scissor-trans-next uint32 :offset-assert 520) - (envmap-scissor-trans-count uint16 :offset-assert 564) - (envmap-scissor-water-last uint32 :offset-assert 460) - (envmap-scissor-water-next uint32 :offset-assert 524) - (envmap-scissor-water-count uint16 :offset-assert 566) - (generic-last uint32 :offset-assert 464) - (generic-next uint32 :offset-assert 528) - (generic-count uint16 :offset-assert 568) - (generic-trans-last uint32 :offset-assert 468) - (generic-trans-next uint32 :offset-assert 532) - (generic-trans-count uint16 :offset-assert 570) - (generic-water-last uint32 :offset-assert 472) - (generic-water-next uint32 :offset-assert 536) - (generic-water-count uint16 :offset-assert 572) - (vanish-last uint32 :offset-assert 476) - (vanish-next uint32 :offset-assert 540) - (vanish-count uint16 :offset-assert 574) + (tie-last uint32 :offset 416) + (tie-next uint32 :offset 480) + (tie-count uint16 :offset 544) + (trans-last uint32 :offset 420) + (trans-next uint32 :offset 484) + (trans-count uint16 :offset 546) + (water-last uint32 :offset 424) + (water-next uint32 :offset 488) + (water-count uint16 :offset 548) + (scissor-last uint32 :offset 428) + (scissor-next uint32 :offset 492) + (scissor-count uint16 :offset 550) + (scissor-trans-last uint32 :offset 432) + (scissor-trans-next uint32 :offset 496) + (scissor-trans-count uint16 :offset 552) + (scissor-water-last uint32 :offset 436) + (scissor-water-next uint32 :offset 500) + (scissor-water-count uint16 :offset 554) + (envmap-last uint32 :offset 440) + (envmap-next uint32 :offset 504) + (envmap-count uint16 :offset 556) + (envmap-trans-last uint32 :offset 444) + (envmap-trans-next uint32 :offset 508) + (envmap-trans-count uint16 :offset 558) + (envmap-water-last uint32 :offset 448) + (envmap-water-next uint32 :offset 512) + (envmap-water-count uint16 :offset 560) + (envmap-scissor-last uint32 :offset 452) + (envmap-scissor-next uint32 :offset 516) + (envmap-scissor-count uint16 :offset 562) + (envmap-scissor-trans-last uint32 :offset 456) + (envmap-scissor-trans-next uint32 :offset 520) + (envmap-scissor-trans-count uint16 :offset 564) + (envmap-scissor-water-last uint32 :offset 460) + (envmap-scissor-water-next uint32 :offset 524) + (envmap-scissor-water-count uint16 :offset 566) + (generic-last uint32 :offset 464) + (generic-next uint32 :offset 528) + (generic-count uint16 :offset 568) + (generic-trans-last uint32 :offset 468) + (generic-trans-next uint32 :offset 532) + (generic-trans-count uint16 :offset 570) + (generic-water-last uint32 :offset 472) + (generic-water-next uint32 :offset 536) + (generic-water-count uint16 :offset 572) + (vanish-last uint32 :offset 476) + (vanish-next uint32 :offset 540) + (vanish-count uint16 :offset 574) ) :method-count-assert 9 :size-assert #x240 :flag-assert #x900000240 ) -|# -#| (deftype prototype-tie-dma (structure) ((colora rgba 256 :offset-assert 0) ;; guessed by decompiler (colorb rgba 256 :offset-assert 1024) ;; guessed by decompiler @@ -22970,8 +26781,8 @@ (next uint32 12 :offset-assert 10256) ;; guessed by decompiler (count uint16 12 :offset-assert 10304) ;; guessed by decompiler (counts uint32 4 :offset-assert 10328) ;; guessed by decompiler - (palette-ptr uint32 :offset-assert 10336) - (model-ptr uint32 :offset-assert 10340) + (palette-ptr uint32 :offset 10336) + (model-ptr uint32 :offset 10340) (ret-ptr uint32 :offset-assert 10344) (length uint32 :offset-assert 10348) (flags uint32 :offset-assert 10352) @@ -22982,76 +26793,75 @@ (to-spr uint32 :offset-assert 10372) (spr-out uint32 :offset-assert 10376) (this-count uint32 :offset-assert 10380) - (scissor-geometry uint32 :offset-assert 10240) - (near-geometry uint32 :offset-assert 10244) - (mid-geometry uint32 :offset-assert 10248) - (far-geometry uint32 :offset-assert 10252) - (scissor-frag-count uint8 :offset-assert 10364) - (near-frag-count uint8 :offset-assert 10365) - (mid-frag-count uint8 :offset-assert 10366) - (far-frag-count uint8 :offset-assert 10367) - (tie-scissor-next uint32 :offset-assert 10256) - (tie-near-next uint32 :offset-assert 10260) - (tie-mid-next uint32 :offset-assert 10264) - (tie-far-next uint32 :offset-assert 10268) - (trans-scissor-next uint32 4 :offset-assert 10256) ;; guessed by decompiler - (trans-near-next uint32 :offset-assert 10260) - (trans-mid-next uint32 :offset-assert 10264) - (trans-far-next uint32 :offset-assert 10268) - (water-scissor-next uint32 4 :offset-assert 10256) ;; guessed by decompiler - (water-near-next uint32 :offset-assert 10260) - (water-mid-next uint32 :offset-assert 10264) - (water-far-next uint32 :offset-assert 10268) - (envmap-scissor-next uint32 4 :offset-assert 10272) ;; guessed by decompiler - (envmap-near-next uint32 :offset-assert 10276) - (envmap-mid-next uint32 :offset-assert 10280) - (envmap-far-next uint32 :offset-assert 10284) - (generic-near-next uint32 :offset-assert 10288) - (generic-mid-next uint32 :offset-assert 10292) - (generic-far-next uint32 :offset-assert 10296) - (vanish-next uint32 :offset-assert 10300) - (tie-count uint16 :offset-assert 10304) - (tie-scissor-count uint16 :offset-assert 10304) - (tie-near-count uint16 :offset-assert 10306) - (tie-mid-count uint16 :offset-assert 10308) - (tie-far-count uint16 :offset-assert 10310) - (trans-count uint16 :offset-assert 10304) - (trans-scissor-count uint16 :offset-assert 10304) - (trans-near-count uint16 :offset-assert 10306) - (trans-mid-count uint16 :offset-assert 10308) - (trans-far-count uint16 :offset-assert 10310) - (water-count uint16 :offset-assert 10304) - (water-scissor-count uint16 :offset-assert 10304) - (water-near-count uint16 :offset-assert 10306) - (water-mid-count uint16 :offset-assert 10308) - (water-far-count uint16 :offset-assert 10310) - (envmap-count uint16 :offset-assert 10312) - (envmap-scissor-count uint16 :offset-assert 10312) - (envmap-near-count uint16 :offset-assert 10314) - (envmap-mid-count uint16 :offset-assert 10316) - (envmap-far-count uint16 :offset-assert 10318) - (generic-count uint16 :offset-assert 10320) - (generic-near-count uint16 :offset-assert 10320) - (generic-mid-count uint16 :offset-assert 10322) - (generic-far-count uint16 :offset-assert 10324) - (vanish-count uint16 :offset-assert 10326) - (next-clear uint32 3 :offset-assert 10256) ;; guessed by decompiler - (count-clear uint16 3 :offset-assert 10304) ;; guessed by decompiler + (scissor-geometry uint32 :offset 10240) + (near-geometry uint32 :offset 10244) + (mid-geometry uint32 :offset 10248) + (far-geometry uint32 :offset 10252) + (scissor-frag-count uint8 :offset 10364) + (near-frag-count uint8 :offset 10365) + (mid-frag-count uint8 :offset 10366) + (far-frag-count uint8 :offset 10367) + (tie-scissor-next uint32 :offset 10256) + (tie-near-next uint32 :offset 10260) + (tie-mid-next uint32 :offset 10264) + (tie-far-next uint32 :offset 10268) + (trans-scissor-next uint32 4 :offset 10256) ;; guessed by decompiler + (trans-near-next uint32 :offset 10260) + (trans-mid-next uint32 :offset 10264) + (trans-far-next uint32 :offset 10268) + (water-scissor-next uint32 4 :offset 10256) ;; guessed by decompiler + (water-near-next uint32 :offset 10260) + (water-mid-next uint32 :offset 10264) + (water-far-next uint32 :offset 10268) + (envmap-scissor-next uint32 4 :offset 10272) ;; guessed by decompiler + (envmap-near-next uint32 :offset 10276) + (envmap-mid-next uint32 :offset 10280) + (envmap-far-next uint32 :offset 10284) + (generic-near-next uint32 :offset 10288) + (generic-mid-next uint32 :offset 10292) + (generic-far-next uint32 :offset 10296) + (vanish-next uint32 :offset 10300) + (tie-count uint16 :offset 10304) + (tie-scissor-count uint16 :offset 10304) + (tie-near-count uint16 :offset 10306) + (tie-mid-count uint16 :offset 10308) + (tie-far-count uint16 :offset 10310) + (trans-count uint16 :offset 10304) + (trans-scissor-count uint16 :offset 10304) + (trans-near-count uint16 :offset 10306) + (trans-mid-count uint16 :offset 10308) + (trans-far-count uint16 :offset 10310) + (water-count uint16 :offset 10304) + (water-scissor-count uint16 :offset 10304) + (water-near-count uint16 :offset 10306) + (water-mid-count uint16 :offset 10308) + (water-far-count uint16 :offset 10310) + (envmap-count uint16 :offset 10312) + (envmap-scissor-count uint16 :offset 10312) + (envmap-near-count uint16 :offset 10314) + (envmap-mid-count uint16 :offset 10316) + (envmap-far-count uint16 :offset 10318) + (generic-count uint16 :offset 10320) + (generic-near-count uint16 :offset 10320) + (generic-mid-count uint16 :offset 10322) + (generic-far-count uint16 :offset 10324) + (vanish-count uint16 :offset 10326) + (next-clear uint32 3 :offset 10256) ;; guessed by decompiler + (count-clear uint16 3 :offset 10304) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x2890 :flag-assert #x900002890 ) -|# -;; (define-extern *instance-tie-work-copy* object) ;; instance-tie-work +(define-extern *instance-tie-work-copy* instance-tie-work) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; tfrag-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype tfragment-stats (structure) + "Triangle and vertex stats for a single tfragment." ((num-tris uint16 4 :offset-assert 0) ;; guessed by decompiler (num-dverts uint16 4 :offset-assert 8) ;; guessed by decompiler ) @@ -23059,10 +26869,9 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype tfragment-debug-data (structure) + "Optional debug information (stats, lines) for a tfragment." ((stats tfragment-stats :inline :offset-assert 0) (debug-lines (array vector-array) :offset-assert 16) ;; guessed by decompiler ) @@ -23070,130 +26879,136 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype generic-tfragment (structure) + "Unused. Could have been a way to render tfrag's through generic." ((dummy int32 :offset-assert 0) ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype tfragment (drawable) - ((color-index uint16 :offset-assert 6) - (debug-data tfragment-debug-data :offset-assert 8) - (color-indices uint32 :offset-assert 12) - (colors uint32 :offset-assert 12) - (dma-chain uint32 3 :offset-assert 32) ;; guessed by decompiler - (dma-common uint32 :offset-assert 32) - (dma-level-0 uint32 :offset-assert 32) - (dma-base uint32 :offset-assert 36) - (dma-level-1 uint32 :offset-assert 40) - (dma-qwc uint8 4 :offset-assert 44) ;; guessed by decompiler - (shader (inline-array adgif-shader) :offset-assert 48) ;; guessed by decompiler - (num-shaders uint8 :offset-assert 52) - (num-base-colors uint8 :offset-assert 53) - (num-level0-colors uint8 :offset-assert 54) - (num-level1-colors uint8 :offset-assert 55) - (color-offset uint8 :offset-assert 56) - (color-count uint8 :offset-assert 57) - (texture-masks-index uint16 :offset-assert 58) - (generic generic-tfragment :offset-assert 60) + "A tfrag mesh fragment. This is just references to DMA data, plus some metadata." + ((color-index uint16 :offset 6) + (debug-data tfragment-debug-data :offset 8) + (color-indices uint32 :offset 12) + (colors uint32 :offset 12) + (dma-chain uint32 3 :offset 32) ;; guessed by decompiler + (dma-common uint32 :offset 32) + (dma-level-0 uint32 :offset 32) + (dma-base uint32 :offset 36) + (dma-level-1 uint32 :offset 40) + (dma-qwc uint8 4 :offset 44) ;; guessed by decompiler + (dma-qwc-word uint32 :overlay-at dma-qwc) + (shader (inline-array adgif-shader) :offset 48) ;; guessed by decompiler + (num-shaders uint8 :offset 52) + (num-base-colors uint8 :offset 53) + (num-level0-colors uint8 :offset 54) + (num-level1-colors uint8 :offset 55) + (color-offset uint8 :offset 56) + (color-count uint8 :offset 57) + (texture-masks-index uint16 :offset 58) + (generic generic-tfragment :offset 60) + (generic-u32 uint32 :offset 60) ;; added ) :method-count-assert 17 :size-assert #x40 :flag-assert #x1100000040 ) -|# -;; (deftype drawable-inline-array-tfrag (drawable-inline-array) -;; () -;; :flag-assert #x1100000064 -;; ) +(deftype drawable-inline-array-tfrag (drawable-inline-array) + "Array of tfragments" + ((data tfragment 1 :inline :offset-assert 32) + (pad uint32)) + :flag-assert #x1100000064 + ) -;; (deftype drawable-inline-array-tfrag-trans (drawable-inline-array-tfrag) -;; () -;; :flag-assert #x11000000b4 -;; ) +(deftype drawable-inline-array-tfrag-trans (drawable-inline-array-tfrag) + ;; note: this is probably a bug in the type layout, copied from jak 1. + ;; this data2 is not used. + ((data2 tfragment 1 :inline :offset-assert 112) + (pad2 uint32)) + :flag-assert #x11000000b4 + ) -;; (deftype drawable-inline-array-tfrag-water (drawable-inline-array-tfrag) -;; () -;; :flag-assert #x11000000b4 -;; ) +(deftype drawable-inline-array-tfrag-water (drawable-inline-array-tfrag) + ((data2 tfragment 1 :inline :offset-assert 112) + (pad2 uint32)) + :flag-assert #x11000000b4 + ) -;; (deftype drawable-tree-tfrag (drawable-tree) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-tfrag (drawable-tree) + "top level tfrag tree." + ((time-of-day-pal time-of-day-palette :offset 12) + (arrays drawable-inline-array :dynamic :offset 32 :score 100) ;; either drawable-inline-array-node or drawable-inline-array-tfrag + ) + :flag-assert #x1100000020 + ) -;; (deftype drawable-tree-tfrag-trans (drawable-tree-tfrag) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-tfrag-trans (drawable-tree-tfrag) + () + :flag-assert #x1100000020 + ) -;; (deftype drawable-tree-tfrag-water (drawable-tree-tfrag) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-tfrag-water (drawable-tree-tfrag-trans) + () + :flag-assert #x1100000020 + ) -;; (deftype drawable-tree-tfrag-shared (drawable-tree-tfrag) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-tfrag-shared (drawable-tree-tfrag) + () + :flag-assert #x1100000020 + ) -;; (deftype drawable-tree-tfrag-trans-shared (drawable-tree-tfrag-shared) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-tfrag-trans-shared (drawable-tree-tfrag-shared) + () + :flag-assert #x1100000020 + ) -;; (deftype drawable-tree-tfrag-water-shared (drawable-tree-tfrag-shared) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-tfrag-water-shared (drawable-tree-tfrag-shared) + () + :flag-assert #x1100000020 + ) -#| (deftype tfrag-dists (structure) + "Distances for mesh level-of-detail blending for use on VU1." ((data uint32 16 :offset-assert 0) ;; guessed by decompiler - (vector vector 4 :offset-assert 0) ;; guessed by decompiler - (k0s vector 2 :offset-assert 0) ;; guessed by decompiler - (k1s vector 2 :offset-assert 32) ;; guessed by decompiler + (vector vector 4 :offset 0) ;; guessed by decompiler + (k0s vector 2 :offset 0) ;; guessed by decompiler + (k1s vector 2 :offset 32) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype tfrag-data (structure) + "Constants for VU1 data memory for tfrag rendering." ((data uint32 56 :offset-assert 0) ;; guessed by decompiler - (vector vector 14 :offset-assert 0) ;; guessed by decompiler - (fog vector :inline :offset-assert 0) - (val vector :inline :offset-assert 16) - (strgif qword :inline :offset-assert 32) ;; gs-gif-tag :inline - (fangif qword :inline :offset-assert 48) ;; gs-gif-tag :inline - (adgif qword :inline :offset-assert 64) ;; gs-gif-tag :inline - (hvdf-offset vector :inline :offset-assert 80) - (hmge-scale vector :inline :offset-assert 96) - (invh-scale vector :inline :offset-assert 112) - (ambient vector :inline :offset-assert 128) - (guard vector :inline :offset-assert 144) - (dists tfrag-dists :inline :offset-assert 160) - (k0s uint128 2 :offset-assert 160) ;; guessed by decompiler - (k1s uint128 2 :offset-assert 192) ;; guessed by decompiler + (vector vector 14 :offset 0) ;; guessed by decompiler + (fog vector :inline :offset 0) + (val vector :inline :offset 16) + (strgif gs-gif-tag :inline :offset 32) ;; gs-gif-tag :inline + (fangif gs-gif-tag :inline :offset 48) ;; gs-gif-tag :inline + (adgif gs-gif-tag :inline :offset 64) ;; gs-gif-tag :inline + (hvdf-offset vector :inline :offset 80) + (hmge-scale vector :inline :offset 96) + (invh-scale vector :inline :offset 112) + (ambient vector :inline :offset 128) + (guard vector :inline :offset 144) + (dists tfrag-dists :inline :offset 160) + (k0s uint128 2 :offset 160) ;; guessed by decompiler + (k1s uint128 2 :offset 192) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #xe0 :flag-assert #x9000000e0 ) -|# -#| (deftype tfrag-control (structure) + "VU1 'control' data containing address and counters." ((num-base-points uint32 :offset-assert 0) (num-shared-base-points uint32 :offset-assert 4) (num-level0-points uint32 :offset-assert 8) @@ -23219,10 +27034,9 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype tfrag-stats (structure) + "TFRAG statistics computed on EE." ((from int32 :offset-assert 0) (to int32 :offset-assert 4) (cnt int32 :offset-assert 8) @@ -23244,9 +27058,7 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype tfrag-packet (structure) ((tag uint128 2 :offset-assert 0) ;; guessed by decompiler ) @@ -23254,10 +27066,9 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype tfrag-work (structure) + "Scratch space for generating TFRAG DMA." ((base-tmpl dma-packet :inline :offset-assert 0) (level-0-tmpl dma-packet :inline :offset-assert 16) (common-tmpl dma-packet :inline :offset-assert 32) @@ -23288,29 +27099,28 @@ :size-assert #xc0 :flag-assert #x9000000c0 ) -|# -#| (deftype tfrag-dma (structure) - ((banka tfragment 16 :offset-assert 4) ;; guessed by decompiler - (bankb tfragment 16 :offset-assert 1028) ;; guessed by decompiler + "Memory layout for to/from scratchpad for tfrag." + ((banka tfragment 16 :inline :offset-assert 0) ;; guessed by decompiler + (bankb tfragment 16 :inline :offset-assert 1024) ;; guessed by decompiler (outa uint128 128 :offset-assert 2048) ;; guessed by decompiler (outb uint128 128 :offset-assert 4096) ;; guessed by decompiler - (colors rgba 2048 :offset-assert 6144) ;; guessed by decompiler + ;; another weird bug with size here... + (colors rgba 2047 :offset-assert 6144) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x37fc :flag-assert #x9000037fc ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; background-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype background-work (basic) + "List of all things for the background renderer to draw." ((tfrag-tree-count int32 :offset-assert 4) (tfrag-trees drawable-tree-tfrag 19 :offset-assert 8) ;; guessed by decompiler (tfrag-levels level 19 :offset-assert 84) ;; guessed by decompiler @@ -23321,14 +27131,14 @@ (tfrag-water-trees drawable-tree-tfrag-water 19 :offset-assert 320) ;; guessed by decompiler (tfrag-water-levels level 19 :offset-assert 396) ;; guessed by decompiler (tfrag-shared-tree-count int32 :offset-assert 472) - (tfrag-shared-trees UNKNOWN 19 :offset-assert 476) - (tfrag-shared-levels UNKNOWN 19 :offset-assert 552) + (tfrag-shared-trees drawable-tree-tfrag-shared 19 :offset-assert 476) + (tfrag-shared-levels level 19 :offset-assert 552) (tfrag-trans-shared-tree-count int32 :offset-assert 628) - (tfrag-trans-shared-trees UNKNOWN 19 :offset-assert 632) - (tfrag-trans-shared-levels UNKNOWN 19 :offset-assert 708) + (tfrag-trans-shared-trees drawable-tree-tfrag-trans-shared 19 :offset-assert 632) + (tfrag-trans-shared-levels level 19 :offset-assert 708) (tfrag-water-shared-tree-count int32 :offset-assert 784) - (tfrag-water-shared-trees UNKNOWN 19 :offset-assert 788) - (tfrag-water-shared-levels UNKNOWN 19 :offset-assert 864) + (tfrag-water-shared-trees drawable-tree-tfrag-water-shared 19 :offset-assert 788) + (tfrag-water-shared-levels level 19 :offset-assert 864) (shrub-tree-count int32 :offset-assert 940) (shrub-trees drawable-tree-instance-shrub 19 :offset-assert 944) ;; guessed by decompiler (shrub-levels level 19 :offset-assert 1020) ;; guessed by decompiler @@ -23341,41 +27151,42 @@ :size-assert #x4e8 :flag-assert #x9000004e8 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; subdivide-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype subdivide-settings (basic) + "Input settings for distances for switching mesh level of details. + These are set by the level code and read by rendering code." ((dist float 5 :offset-assert 4) ;; guessed by decompiler (meters float 5 :offset-assert 24) ;; guessed by decompiler (close float 20 :offset-assert 44) ;; guessed by decompiler (far float 20 :offset-assert 124) ;; guessed by decompiler ) + (:methods + (new (symbol type float float) _type_) + ) :method-count-assert 9 :size-assert #xcc :flag-assert #x9000000cc ) -|# -#| (deftype subdivide-dists (structure) - ((data uint32 32 :offset-assert 0) ;; guessed by decompiler - (vector vector 8 :offset-assert 0) ;; guessed by decompiler - (k0s uint128 4 :offset-assert 0) ;; guessed by decompiler - (k1s uint128 4 :offset-assert 64) ;; guessed by decompiler + "Unused subdivide distances. Internally, tfrag/tie figure these out instead." + ((data uint32 32 :offset 0) ;; guessed by decompiler + (vector vector 8 :offset 0) ;; guessed by decompiler + (k0s uint128 4 :offset 0) ;; guessed by decompiler + (k1s uint128 4 :offset 64) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype terrain-stats (structure) + "Desptie the name `terrain-stats`, these are more general triangle stats for all renderers." ((pris tr-stat :inline :offset-assert 0) (tie-generic tr-stat :inline :offset-assert 16) (tie-vanish tr-stat :inline :offset-assert 32) @@ -23411,38 +27222,39 @@ :size-assert #x1e0 :flag-assert #x9000001e0 ) -|# -#| (deftype background-area (structure) + "Scratchpad memory layout for most background rendering + This uses the full scratchpad so it should only be used when the stack isn't on the scratchpad (rendering code). + Interestingly, dma-area went from a union of all the -dma types to a plain array of bytes in jak 3." ((dma-area uint8 14336 :offset-assert 0) ;; guessed by decompiler - (vis-list uint8 2048 :offset-assert 14336) ;; guessed by decompiler + (vis-list uint8 2048 :offset-assert 14336) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x4000 :flag-assert #x900004000 ) -|# -#| (deftype foreground-area (structure) - ((generic-work generic-work :inline :offset-assert 0) - (foreground-work foreground-work :inline :offset-assert 0) - (joint-work joint-work :inline :offset-assert 0) - (bone-mem bone-memory :inline :offset-assert 0) - (shadow-work shadow-work :inline :offset-assert 0) + "Scratchpad memory layout for most foreground rendering." + ((generic-work generic-work :inline :offset 0) + (foreground-work foreground-work :inline :offset 0) + (joint-work joint-work :inline :offset 0) + (bone-mem bone-memory :inline :offset 0) + (shadow-work shadow-work :inline :offset 0) ) :method-count-assert 9 :size-assert #x3fe0 :flag-assert #x900003fe0 ) -|# -#| (deftype region-prim-area (structure) + "Scratchpad memory layout for regions." ((region-prim-list region-prim-list :inline :offset-assert 0) (pos vector :inline :offset-assert 1296) + (exit-pos vector :inline :offset-assert 1312) ;; added (ray vector :inline :offset-assert 1328) + (exit-ray vector :inline :offset-assert 1344) ;; added (region-enter-count int32 :offset-assert 1360) (region-enter-list region 320 :offset-assert 1364) ;; guessed by decompiler (region-enter-prim-list drawable-region-sphere 320 :offset-assert 2644) ;; guessed by decompiler @@ -23460,83 +27272,101 @@ :size-assert #x2d60 :flag-assert #xd00002d60 (:methods - (region-prim-area-method-9 () none) ;; 9 ;; (track-entered-region! (_type_ drawable-region-sphere) int) - (region-prim-area-method-10 () none) ;; 10 ;; (track-exited-region! (_type_ drawable-region-sphere) int) - (region-prim-area-method-11 () none) ;; 11 ;; (track-inside-region! (_type_ drawable-region-sphere) int) - (region-prim-area-method-12 () none) ;; 12 ;; (track-start-region! (_type_ drawable-region-sphere) int) + (track-entered-region! (_type_ drawable-region-sphere) int) ;; 9 + (track-exited-region! (_type_ drawable-region-sphere) int) ;; 10 + (track-inside-region! (_type_ drawable-region-sphere) int) ;; 11 + (track-start-region! (_type_ drawable-region-sphere) int) ;; 12 ) ) -|# -#| (deftype sprite-area (structure) - ((clock-data vector 22 :offset-assert 0) ;; guessed by decompiler + "Scratchpad memory layout for sprites." + ((clock-data vector 22 :inline :offset-assert 0) ;; guessed by decompiler (buffer uint8 :dynamic :offset-assert 352) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x160 :flag-assert #x900000160 ) -|# -#| (deftype work-area (structure) - ((background background-area :inline :offset-assert 0) - (foreground foreground-area :inline :offset-assert 0) - (region-prim region-prim-area :inline :offset-assert 0) - (sprite sprite-area :inline :offset-assert 0) + "All scratchpad memory layouts." + ((background background-area :inline :offset 0) + (foreground foreground-area :inline :offset 0) + (region-prim region-prim-area :inline :offset 0) + (sprite sprite-area :inline :offset 0) ) :method-count-assert 9 :size-assert #x4000 :flag-assert #x900004000 ) -|# -#| (deftype terrain-context (structure) + "Useless wrapper around work-area. (this added some stuff in jak 1)" ((work work-area :inline :offset-assert 0) ) :method-count-assert 9 :size-assert #x4000 :flag-assert #x900004000 ) -|# -;; (define-extern *terrain-stats* object) ;; terrain-stats -;; (define-extern *collide-stats* object) ;; collide-stats +(define-extern *terrain-stats* terrain-stats) +(define-extern *collide-stats* collide-stats) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; entity-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++entity-h:entity-perm-status +(defenum entity-perm-status + :bitfield #t + :type uint16 + (bit-0 0) ;; blocks birth + (error 1) + (dead 2) + (no-kill 3) + (bit-4 4) + (bit-5 5) + (subtask-complete 6) + (special 7) + (complete 8) + (bit-9 9) + (bit-10 10) + (save 11) + (bit-12 12) + (bit-13 13) + (bit-14 14) + (bit-15 15) + ) +;; ---entity-h:entity-perm-status + (deftype entity-perm (structure) + "Entity information that gets persisted in the save file." ((user-object object 2 :offset-assert 0) ;; guessed by decompiler - (user-uint64 uint64 :offset-assert 0) - (user-float float 2 :offset-assert 0) ;; guessed by decompiler - (user-int32 int32 2 :offset-assert 0) ;; guessed by decompiler - (user-uint32 uint32 2 :offset-assert 0) ;; guessed by decompiler - (user-int16 int16 4 :offset-assert 0) ;; guessed by decompiler - (user-uint16 uint16 4 :offset-assert 0) ;; guessed by decompiler - (user-int8 int8 8 :offset-assert 0) ;; guessed by decompiler - (user-uint8 uint8 8 :offset-assert 0) ;; guessed by decompiler - (status uint16 :offset-assert 8) ;; entity-perm-status + (user-uint64 uint64 :offset 0) + (user-float float 2 :offset 0) ;; guessed by decompiler + (user-int32 int32 2 :offset 0) ;; guessed by decompiler + (user-uint32 uint32 2 :offset 0) ;; guessed by decompiler + (user-int16 int16 4 :offset 0) ;; guessed by decompiler + (user-uint16 uint16 4 :offset 0) ;; guessed by decompiler + (user-int8 int8 8 :offset 0) ;; guessed by decompiler + (user-uint8 uint8 8 :offset 0) ;; guessed by decompiler + (status entity-perm-status :offset-assert 8) ;; entity-perm-status (dummy uint8 1 :offset-assert 10) ;; guessed by decompiler - (task uint8 :offset-assert 11) ;; game-task + (task game-task :offset-assert 11) ;; game-task (aid actor-id :offset-assert 12) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + (quad uint128 :offset 0) ) :method-count-assert 10 :size-assert #x10 :flag-assert #xa00000010 (:methods - (entity-perm-method-9 () none) ;; 9 ;; (update (_type_ symbol entity-perm-status) _type_) + (update (_type_ symbol entity-perm-status) _type_) ;; 9 ) ) -|# -#| (deftype entity-links (structure) + "A linked list of entities with some extra data about their current status." ((prev-link entity-links :offset-assert 0) (next-link entity-links :offset-assert 4) (entity entity :offset-assert 8) ;; guessed by decompiler @@ -23547,47 +27377,57 @@ (vis-dist meters :offset-assert 28) (trans vector :inline :offset-assert 32) (perm entity-perm :inline :offset-assert 48) - (status uint16 :offset-assert 56) ;; entity-perm-status - (aid uint32 :offset-assert 60) - (task uint8 :offset-assert 59) ;; game-task + (status entity-perm-status :offset 56) + (aid uint32 :offset 60) + (task game-task :offset 59) ) :method-count-assert 10 :size-assert #x40 :flag-assert #xa00000040 (:methods - (entity-links-method-9 () none) ;; 9 ;; (birth? (_type_ vector) symbol) + (birth? (_type_ vector) symbol) ;; 9 ) ) -|# -#| (deftype entity-perm-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data entity-perm :dynamic :offset-assert 16) ;; guessed by decompiler + ((data entity-perm :dynamic :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype entity-links-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data entity-links :dynamic :offset-assert 16) ;; guessed by decompiler + "An array of [[entity-links]]. + Levels store a reference to this which holds all the entities in the level." + ((data entity-links :dynamic :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -;; (deftype entity (res-lump) -;; () -;; :flag-assert #x1b00000038 -;; ) +(deftype entity (res-lump) + "Entities are mainly used to place objects in a level. + + As a child of [[res-lump]], they store various types of metadata + in [[res-tag]]s (such as name, curve data, volume data, etc.) + that gets accessed by the accompanying process." + ((trans vector :inline :offset-assert 32) + (aid uint32 :offset-assert 48) + (unknown uint32 :offset-assert 52) + ) + :method-count-assert 27 + :size-assert #x38 + :flag-assert #x1b00000038 + (:methods + (birth! (_type_) _type_) ;; 22 + (kill! (_type_) _type_) ;; 23 + (entity-method-24 (_type_) _type_) ;; 23 (add-to-level! (_type_ level-group level actor-id) none) ;; 24 + (entity-method-25 (_type_) _type_) ;; (remove-from-level! (_type_ level-group) _type_) ;; 25 + (get-level (_type_) level) ;; 26 + ) + ) ;; (deftype entity-camera (entity) ;; () @@ -23604,35 +27444,47 @@ ;; :flag-assert #x1d0000003c ;; ) -;; (deftype entity-actor (entity) -;; () -;; :flag-assert #x2100000060 -;; ) - -#| -(deftype actor-reference (structure) - ((actor entity-actor :offset-assert 0) ;; guessed by decompiler - (id uint32 :offset-assert 4) +(define-extern entity-actor type) +(declare-type nav-poly structure) +(deftype entity-actor (entity) + "Child class of [[entity]] used to spawn [[process-drawable]] actors." + ((etype type :offset 56) + (task game-task :offset-assert 60) + (kill-mask task-mask :offset 52) + (vis-id int16 :offset-assert 62) + (quat quaternion :inline :offset-assert 64) ) + :method-count-assert 33 + :size-assert #x50 + :flag-assert #x2100000050 + ;; Failed to read fields. + (:methods + (next-actor (_type_) entity-actor) ;; 27 + (prev-actor (_type_) entity-actor) ;; 28 + (debug-print (_type_ symbol type) none) ;; 29 + (toggle-status (_type_ entity-perm-status symbol) none) ;; 30 + (get-simple-travel-vector (_type_ vector vector vector object float) nav-mesh) ;; 31 + (project-point-to-nav-mesh (_type_ vector vector nav-poly float) nav-poly) ;; 32 + ) + ) +(deftype actor-reference (structure) + ((actor entity-actor :offset-assert 0) ;; guessed by decompiler + (id uint32 :offset-assert 4) + ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype actor-group (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data actor-reference :dynamic :offset-assert 16) ;; guessed by decompiler + ((data actor-reference :dynamic :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype entity-info (basic) ((ptype object :offset-assert 4) ;; guessed by decompiler (pool symbol :offset-assert 8) ;; guessed by decompiler @@ -23642,9 +27494,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype actor-bank (basic) ((pause-dist float :offset-assert 4) (birth-dist float :offset-assert 8) @@ -23654,12 +27504,11 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern *generate-actor-vis* object) ;; symbol -;; (define-extern *generate-actor-vis-start* object) ;; symbol -;; (define-extern *generate-actor-vis-output* object) ;; symbol -;; (define-extern *ACTOR-bank* actor-bank) ;; actor-bank +(define-extern *generate-actor-vis* symbol) +(define-extern *generate-actor-vis-start* symbol) +(define-extern *generate-actor-vis-output* symbol) +(define-extern *ACTOR-bank* actor-bank) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; entity-more-perm ;; @@ -23714,37 +27563,36 @@ ;; sprite-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype sprite-vec-data-2d (structure) + "Per-particle data needed for rendering. This is sent to VU1." ((x-y-z-sx vector :inline :offset-assert 0) (flag-rot-sy vector :inline :offset-assert 16) (r-g-b-a vector :inline :offset-assert 32) - (x float :offset-assert 0) - (y float :offset-assert 4) - (z float :offset-assert 8) - (sx float :offset-assert 12) - (sy float :offset-assert 28) - (rot float :offset-assert 24) - (flag int32 :offset-assert 16) - (matrix int32 :offset-assert 20) - (warp-turns int32 :offset-assert 16) - (r float :offset-assert 32) - (g float :offset-assert 36) - (b float :offset-assert 40) - (a float :offset-assert 44) - (trans vector3s :inline :offset-assert 0) - (color rgbaf :inline :offset-assert 32) - (data uint128 1 :offset-assert 0) ;; guessed by decompiler - (data64 uint64 6 :offset-assert 0) ;; guessed by decompiler + (x float :offset 0) + (y float :offset 4) + (z float :offset 8) + (sx float :offset 12) + (sy float :offset 28) + (rot float :offset 24) + (flag int32 :offset 16 :score 1) + (matrix int32 :offset 20) + (warp-turns int32 :offset 16) + (r float :offset 32) + (g float :offset 36) + (b float :offset 40) + (a float :offset 44) + (trans vector3s :inline :offset 0) + (color rgbaf :inline :offset 32) + (data uint128 1 :offset 0) ;; guessed by decompiler + (data64 uint64 6 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype sprite-array-2d (basic) + "Array of sprite data for all 2D sprites. There are two groups: normal and HUD." ((num-sprites int32 2 :offset-assert 4) ;; guessed by decompiler (num-valid int32 2 :offset-assert 12) ;; guessed by decompiler (vec-data pointer :offset-assert 20) ;; guessed by decompiler @@ -23752,64 +27600,66 @@ (pad uint128 4 :offset-assert 32) ;; guessed by decompiler (data uint128 1 :offset-assert 96) ;; guessed by decompiler ) + (:methods + (new (symbol type int int) _type_) ;; 0 + ) :method-count-assert 9 :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype sprite-vec-data-3d (structure) + "Per-particle data needed for rendering. This is sent to VU1." ((x-y-z-sx vector :inline :offset-assert 0) (qx-qy-qz-sy vector :inline :offset-assert 16) (r-g-b-a vector :inline :offset-assert 32) - (x float :offset-assert 0) - (y float :offset-assert 4) - (z float :offset-assert 8) - (sx float :offset-assert 12) - (sy float :offset-assert 28) - (qx float :offset-assert 16) - (qy float :offset-assert 20) - (qz float :offset-assert 24) - (r float :offset-assert 32) - (g float :offset-assert 36) - (b float :offset-assert 40) - (a float :offset-assert 44) - (trans vector3s :inline :offset-assert 0) - (rot vector3s :inline :offset-assert 16) - (color rgbaf :inline :offset-assert 32) - (data uint128 1 :offset-assert 0) ;; guessed by decompiler + (x float :offset 0) + (y float :offset 4) + (z float :offset 8) + (sx float :offset 12) + (sy float :offset 28) + (qx float :offset 16) + (qy float :offset 20) + (qz float :offset 24) + (r float :offset 32) + (g float :offset 36) + (b float :offset 40) + (a float :offset 44) + (trans vector3s :inline :offset 0) + (rot vector3s :inline :offset 16) + (color rgbaf :inline :offset 32) + (data uint128 1 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype sprite-array-3d (basic) + "Array of sprite data for all 3D sprites. There are two groups, but only the first is used." ((num-sprites int32 2 :offset-assert 4) ;; guessed by decompiler (num-valid int32 2 :offset-assert 12) ;; guessed by decompiler (vec-data pointer :offset-assert 20) ;; guessed by decompiler (adgif-data (inline-array adgif-shader) :offset-assert 24) ;; guessed by decompiler (data uint128 1 :offset-assert 32) ;; guessed by decompiler ) + (:methods + (new (symbol type int int) _type_) ;; 0 + ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; simple-sprite-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype sprite-glow-data (structure) ((position vector :inline :offset-assert 0) - (size-x float :offset-assert 12) - (size-probe float :offset-assert 16) + (size-x float :offset 12) + (size-probe float :offset 16) (z-offset float :offset-assert 20) (rot-angle float :offset-assert 24) (size-y float :offset-assert 28) @@ -23818,17 +27668,16 @@ (fade-b float :offset-assert 52) (tex-id texture-id :offset-assert 56) ;; guessed by decompiler (dummy uint32 :offset-assert 60) + (quads vector 4 :inline :offset 0) ) :method-count-assert 10 :size-assert #x40 :flag-assert #xa00000040 (:methods - (sprite-glow-data-method-9 () none) ;; 9 ;; (set-trans (_type_ vector) none) + (set-trans (_type_ vector) none) ;; 9 ) ) -|# -#| (deftype simple-sprite-system (structure) ((count int16 :offset-assert 0) (max-count int16 :offset-assert 2) @@ -23838,28 +27687,27 @@ :size-assert #x8 :flag-assert #xc00000008 (:methods - (simple-sprite-system-method-9 () none) ;; 9 ;; (add! (_type_ sprite-glow-data) none) - (simple-sprite-system-method-10 () none) ;; 10 ;; (draw-all-sprites! (_type_ dma-buffer) none) - (simple-sprite-system-method-11 () none) ;; 11 ;; (clear! (_type_) none) + (add! "Add a sprite to the list, to be drawn later." (_type_ sprite-glow-data) none) ;; 9 + (draw-all-sprites! "Submit all sprites to the sprite-glow renderer" (_type_ dma-buffer) none) ;; 10 + (clear! "Reset the list." (_type_) none) ;; 11 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; eye-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype eye (structure) - ((data vector 2 :offset-assert 0) ;; guessed by decompiler - (x float :offset-assert 0) - (y float :offset-assert 4) - (lid float :offset-assert 8) - (iris-scale float :offset-assert 16) - (pupil-scale float :offset-assert 20) - (lid-scale float :offset-assert 24) - (tbp int32 :offset-assert 32) + "Data for a single eye." + ((data vector 2 :inline :offset-assert 0 :score -1) ;; guessed by decompiler + (x float :offset 0) + (y float :offset 4) + (lid float :offset 8) + (iris-scale float :offset 16) + (pupil-scale float :offset 20) + (lid-scale float :offset 24) + (tbp int32 :offset-assert 32) ;; new (shader-count uint32 :offset-assert 36) (shader adgif-shader 8 :offset-assert 40) ;; guessed by decompiler ) @@ -23867,41 +27715,37 @@ :size-assert #x48 :flag-assert #x900000048 ) -|# -#| (deftype eye-control (structure) ((process uint64 :offset-assert 0) ;; handle (random-time uint16 :offset-assert 8) (bucket uint16 :offset-assert 10) (blink float :offset-assert 12) (shaders (inline-array adgif-shader) :offset-assert 16) ;; guessed by decompiler - (eyes eye 2 :offset-assert 32) ;; guessed by decompiler - (left eye :inline :offset-assert 32) - (right eye :inline :offset-assert 112) + (eyes eye 2 :inline :offset-assert 32) ;; guessed by decompiler + (left eye :inline :offset 32) + (right eye :inline :offset 112) (level-index int16 :offset-assert 192) (high-res? symbol :offset-assert 196) ;; guessed by decompiler (level-texture-page uint32 :offset-assert 200) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (art-group-name uint8 67 :offset 201) ;; field could not be read. ) :method-count-assert 9 :size-assert #x10c :flag-assert #x90000010c ) -|# -#| (deftype eye-control-array (basic) - ((data eye-control 32 :offset-assert 16) ;; guessed by decompiler + "An array of [[eye-control]]s." + ((data eye-control 32 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x2210 :flag-assert #x900002210 ) -|# -#| (deftype eye-work (structure) + "Eye renderer DMA data." ((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) @@ -23911,30 +27755,45 @@ :size-assert #x88 :flag-assert #x900000088 ) -|# -;; (define-extern *eye-control-array* eye-control-array) ;; eye-control-array +(define-extern *eye-control-array* eye-control-array) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; camera-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++camera-h:cam-index-options +(defenum cam-index-options + :type uint32 + :bitfield #t + (SPHERICAL) + (RADIAL) + ) +;; ---camera-h:cam-index-options + +;; +++camera-h:slave-los-state +(defenum slave-los-state + :type uint32 + (none 0) + (cw 1) + (ccw 2) + (between 3) + ) +;; ---camera-h:slave-los-state + (deftype cam-index (structure) - ((flags cam-index-options :offset-assert 0) ;; guessed by decompiler - (vec vector 2 :offset-assert 16) ;; guessed by decompiler + ((flags cam-index-options :offset-assert 0) ;; guessed by decompiler + (vec vector 2 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 11 :size-assert #x30 :flag-assert #xb00000030 (:methods - (cam-index-method-9 () none) ;; 9 ;; (cam-index-method-9 (_type_ symbol entity vector curve) symbol) - (cam-index-method-10 () none) ;; 10 ;; (cam-index-method-10 (_type_ vector) float) + (cam-index-method-9 (_type_ symbol entity vector curve) symbol) ;; 9 + (cam-index-method-10 (_type_ vector) float) ;; 10 ) ) -|# -#| (deftype tracking-point (structure) ((position vector :inline :offset-assert 0) (direction vector :inline :offset-assert 16) @@ -23946,9 +27805,7 @@ :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype tracking-spline-sampler (structure) ((cur-pt int32 :offset-assert 0) (partial-pt float :offset-assert 4) @@ -23957,11 +27814,9 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype tracking-spline (structure) - ((point tracking-point 32 :offset-assert 0) ;; guessed by decompiler + ((point tracking-point 32 :inline :offset-assert 0) ;; guessed by decompiler (summed-len float :offset-assert 1536) (free-point int32 :offset-assert 1540) (used-point int32 :offset-assert 1544) @@ -23980,26 +27835,24 @@ :size-assert #x664 :flag-assert #x1800000664 (:methods - (tracking-spline-method-9 () none) ;; 9 ;; (tracking-spline-method-9 (_type_) none) - (tracking-spline-method-10 () none) ;; 10 ;; (tracking-spline-method-10 (_type_ vector) none) - (tracking-spline-method-11 () none) ;; 11 ;; (debug-point-info (_type_ int) none) - (tracking-spline-method-12 () none) ;; 12 ;; (debug-all-points (_type_) none) - (tracking-spline-method-13 () none) ;; 13 ;; (tracking-spline-method-13 (_type_ int) none) - (tracking-spline-method-14 () none) ;; 14 ;; (tracking-spline-method-14 (_type_ tracking-spline-sampler) none) - (tracking-spline-method-15 () none) ;; 15 ;; (tracking-spline-method-15 (_type_) none) - (tracking-spline-method-16 () none) ;; 16 ;; (tracking-spline-method-16 (_type_ float) none) - (tracking-spline-method-17 () none) ;; 17 ;; (tracking-spline-method-17 (_type_ vector float float symbol) int) - (tracking-spline-method-18 () none) ;; 18 ;; (tracking-spline-method-18 (_type_ float vector vector tracking-spline-sampler) vector) - (tracking-spline-method-19 () none) ;; 19 ;; (tracking-spline-method-19 (_type_ float vector vector tracking-spline-sampler) vector) - (tracking-spline-method-20 () none) ;; 20 ;; (tracking-spline-method-20 (_type_ vector int) none) - (tracking-spline-method-21 () none) ;; 21 ;; (tracking-spline-method-21 (_type_ vector float float float float vector) vector) - (tracking-spline-method-22 () none) ;; 22 ;; (tracking-spline-method-22 (_type_ float) symbol) - (tracking-spline-method-23 () none) ;; 23 ;; (debug-draw-spline (_type_) none) + (tracking-spline-method-9 (_type_) none) ;; 9 + (tracking-spline-method-10 (_type_ vector) none) ;; 10 + (debug-point-info (_type_ int) none) ;; 11 + (debug-all-points (_type_) none) ;; 12 + (tracking-spline-method-13 (_type_ int) none) ;; 13 + (tracking-spline-method-14 (_type_ tracking-spline-sampler) none) ;; 14 + (tracking-spline-method-15 (_type_) none) ;; 15 + (tracking-spline-method-16 (_type_ float) none) ;; 16 + (tracking-spline-method-17 (_type_ vector float float symbol) int) ;; 17 + (tracking-spline-method-18 (_type_ float vector vector tracking-spline-sampler) vector) ;; 18 + (tracking-spline-method-19 (_type_ float vector vector tracking-spline-sampler) vector) ;; 19 + (tracking-spline-method-20 (_type_ vector int) none) ;; 20 + (tracking-spline-method-21 (_type_ vector float float float float vector) vector) ;; 21 + (tracking-spline-method-22 (_type_ float) symbol) ;; 22 + (debug-draw-spline (_type_) none) ;; 23 ) ) -|# -#| (deftype cam-float-seeker (structure) ((target float :offset-assert 0) (value float :offset-assert 4) @@ -24008,19 +27861,18 @@ (max-vel float :offset-assert 16) (max-partial float :offset-assert 20) ) + :pack-me :method-count-assert 13 :size-assert #x18 :flag-assert #xd00000018 (:methods - (cam-float-seeker-method-9 () none) ;; 9 ;; (init (_type_ float float float float) none) - (cam-float-seeker-method-10 () none) ;; 10 ;; (copy-to (_type_ _type_) none) - (cam-float-seeker-method-11 () none) ;; 11 ;; (update! (_type_ float) none) - (cam-float-seeker-method-12 () none) ;; 12 ;; (jump-to-target! (_type_ float) float) + (init (_type_ float float float float) none) ;; 9 + (copy-to (_type_ _type_) none) ;; 10 + (update! (_type_ float) none) ;; 11 + (jump-to-target! (_type_ float) float) ;; 12 ) ) -|# -#| (deftype cam-vector-seeker (structure) ((target vector :inline :offset-assert 0) (value vector :inline :offset-assert 16) @@ -24033,13 +27885,11 @@ :size-assert #x3c :flag-assert #xb0000003c (:methods - (cam-vector-seeker-method-9 () none) ;; 9 ;; (init (_type_ vector float float float) none) - (cam-vector-seeker-method-10 () none) ;; 10 ;; (update! (_type_ vector) none) + (init (_type_ vector float float float) none) ;; 9 + (update! (_type_ vector) none) ;; 10 ) ) -|# -#| (deftype cam-rotation-tracker (structure) ((inv-mat matrix :inline :offset-assert 0) (no-follow basic :offset-assert 64) @@ -24058,9 +27908,7 @@ :size-assert #x108 :flag-assert #x900000108 ) -|# -#| (deftype camera-combiner (process) ((trans vector :inline :offset-assert 144) (inv-camera-rot matrix :inline :offset-assert 160) @@ -24079,18 +27927,45 @@ :method-count-assert 15 :size-assert #x23c :flag-assert #xf01b0023c - (:methods - (camera-combiner-method-9 () none) ;; 9 - (camera-combiner-method-10 () none) ;; 10 - (camera-combiner-method-11 () none) ;; 11 - (camera-combiner-method-12 () none) ;; 12 - (camera-combiner-method-13 () none) ;; 13 - (camera-combiner-method-14 () none) ;; 14 + (:states + cam-combiner-active ) ) -|# -#| +;; +++camera-h:camera-blend-to-type +(defenum camera-blend-to-type + :type uint64 + (unknown-0 0) + (unknown-1 1) + (unknown-2 2) + ) +;; ---camera-h:camera-blend-to-type + +;; +++camera-h:camera-blend-from-type +(defenum camera-blend-from-type + :type uint64 + (unknown-0 0) + (unknown-1 1) + (unknown-2 2) + ) +;; ---camera-h:camera-blend-from-type + +;; +++camera-h:cam-slave-options-u32 +(defenum cam-slave-options-u32 + :type uint32 + :bitfield #t + :copy-entries cam-slave-options + ) +;; ---camera-h:cam-slave-options-u32 + +;; +++camera-h:cam-master-options-u32 +(defenum cam-master-options-u32 + :type uint32 + :bitfield #t + :copy-entries cam-master-options + ) +;; ---camera-h:cam-master-options-u32 + (deftype camera-slave (process) ((trans vector :inline :offset-assert 144) (fov float :offset-assert 160) @@ -24113,7 +27988,7 @@ (max-angle-curr float :offset-assert 2292) (options cam-slave-options-u32 :offset-assert 2296) ;; guessed by decompiler (cam-entity entity :offset-assert 2300) ;; guessed by decompiler - (butt-timer uint64 :offset-assert 2304) ;; time-frame + (butt-timer time-frame :offset-assert 2304) ;; time-frame (butt-seek basic :offset-assert 2312) (butt-vector vector :inline :offset-assert 2320) (velocity vector :inline :offset-assert 2336) @@ -24137,8 +28012,8 @@ (spline-tt float :offset-assert 2608) (spline-follow-dist float :offset-assert 2612) (enter-has-run symbol :offset-assert 2616) ;; guessed by decompiler - (blend-from-type uint64 :offset-assert 2624) ;; camera-blend-from-type - (blend-to-type uint64 :offset-assert 2632) ;; camera-blend-to-type + (blend-from-type camera-blend-from-type :offset-assert 2624) ;; camera-blend-from-type + (blend-to-type camera-blend-to-type :offset-assert 2632) ;; camera-blend-to-type (have-phony-joystick basic :offset-assert 2640) (phony-joystick-x float :offset-assert 2644) (phony-joystick-y float :offset-assert 2648) @@ -24157,18 +28032,8 @@ :method-count-assert 15 :size-assert #xafc :flag-assert #xf0a700afc - (:methods - (camera-slave-method-9 () none) ;; 9 - (camera-slave-method-10 () none) ;; 10 - (camera-slave-method-11 () none) ;; 11 - (camera-slave-method-12 () none) ;; 12 - (camera-slave-method-13 () none) ;; 13 - (camera-slave-method-14 () none) ;; 14 - ) ) -|# -#| (deftype camera-master (process) ((master-options cam-master-options-u32 :offset-assert 144) ;; guessed by decompiler (settings cam-setting-data :offset-assert 148) @@ -24215,92 +28080,247 @@ :size-assert #x938 :flag-assert #x1208b00938 (:methods - (camera-master-method-9 () none) ;; 9 - (camera-master-method-10 () none) ;; 10 - (camera-master-method-11 () none) ;; 11 - (camera-master-method-12 () none) ;; 12 - (camera-master-method-13 () none) ;; 13 - (camera-master-method-14 () none) ;; 14 ;; (camera-master-method-14 (_type_ vector) vector) - (camera-master-method-15 () none) ;; 15 ;; (camera-master-method-15 (_type_ vector) vector) + (camera-master-method-15 () none) ;; 14 ;; (camera-master-method-14 (_type_ vector) vector)15 ;; (camera-master-method-15 (_type_ vector) vector) (camera-master-method-16 () none) ;; 16 ;; (camera-master-method-16 (_type_ symbol) int) (camera-master-method-17 () none) ;; 17 ) + (:states + cam-master-active + ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-interface-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *camera-init-mat* object) ;; matrix +(define-extern *camera-init-mat* matrix) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sparticle-launcher-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type sprite-vec-data-3d structure) +(declare-type sparticle-cpuinfo structure) +(declare-type sparticle-system structure) + +;; +++sparticle-launcher-h:sp-field-id +(defenum sp-field-id + :type uint16 + ;; todo copied from jak 2 + (misc-fields-start 0) + (spt-texture 1) + (spt-anim 2) + (spt-anim-speed 3) + (spt-birth-func 4) + (spt-joint/refpoint 5) + (spt-num 6) + (spt-sound 7) + (misc-fields-end 8) + + (sprite-fields-start 9) + (spt-x 10) + (spt-y 11) + (spt-z 12) + (spt-scale-x 13) + (spt-rot-x 14) + (spt-rot-y 15) + (spt-rot-z 16) + (spt-scale-y 17) + (spt-r 18) + (spt-g 19) + (spt-b 20) + (spt-a 21) + (sprite-fields-end 22) + + (cpu-fields-start 23) + (spt-omega 24) + (spt-vel-x 25) + (spt-vel-y 26) + (spt-vel-z 27) + (spt-scalevel-x 28) + (spt-rotvel-x 29) + (spt-rotvel-y 30) + (spt-rotvel-z 31) + (spt-scalevel-y 32) + (spt-fade-r 33) + (spt-fade-g 34) + (spt-fade-b 35) + (spt-fade-a 36) + (spt-accel-x 37) + (spt-accel-y 38) + (spt-accel-z 39) + (spt-dummy 40) + (spt-quat-x 41) + (spt-quat-y 42) + (spt-quat-z 43) + (spt-quad-w 44) + (spt-friction 45) + (spt-timer 46) + (spt-flags 47) + (spt-userdata 48) + (spt-func 49) + (spt-next-time 50) + (spt-next-launcher 51) + (cpu-fields-end 52) + + (launch-fields-start 53) + (spt-launchrot-x 54) + (spt-launchrot-y 55) + (spt-launchrot-z 56) + (spt-launchrot-w 57) + (spt-conerot-x 58) + (spt-conerot-y 59) + (spt-conerot-z 60) + (spt-conerot-w 61) + (spt-rotate-x 62) + (spt-rotate-y 63) + (spt-rotate-z 64) + + (spt-conerot-radius 65) + (spt-mat-scale-x 66) + (spt-mat-scale-y 67) + (spt-mat-scale-z 68) + (launch-fields-end 69) + + (spt-scale 70) + (spt-scalevel 71) + (spt-end 72) + ) +;; ---sparticle-launcher-h:sp-field-id + +;; +++sparticle-launcher-h:sp-flag +(defenum sp-flag + :type uint16 + ;; todo copied from jak 2 + (int 0) ;; int + (float 1) ;; float + (float-int-rand 2) ;; float with int rand + (copy-from-other 3) ;; copy + (object 4) ;; label + (symbol 5) ;; symbol + (launcher 6) ;; launcher from id + (float-store 7) ;; float and store result in *sp-temp* + ) +;; ---sparticle-launcher-h:sp-flag + +;; +++sparticle-launcher-h:sp-group-item-flag +(defenum sp-group-item-flag + :bitfield #t + :type uint16 + (is-3d) + (sp1) + (sp2) + (sp3) + (sp4) + (sp5) + (sp6) + (sp7) + (sp8) + (sp9) + (sp10) + (sp11) + (sp12) + (sp13) + (sp14) + (sp15) + ) +;; ---sparticle-launcher-h:sp-group-item-flag + +;; +++sparticle-launcher-h:sp-launch-state-flags +(defenum sp-launch-state-flags + :bitfield #t + :type uint16 + (sp0) + (sp1) + (sp2) + ) +;; ---sparticle-launcher-h:sp-launch-state-flags + +;; +++sparticle-launcher-h:sp-group-flag +(defenum sp-group-flag + :bitfield #t + :type uint16 + (sp0) + (sp1) + (sp2) + (sp3) + (sp4) + (sp5) + (sp6) + (sp7) + (sp8) + (sp9) + (sp10) + (sp11) + (sp12) + (sp13) + (sp14) + (sp15) + ) +;; ---sparticle-launcher-h:sp-group-flag + (deftype sparticle-birthinfo (structure) + "Used internally by the sparticle code." ((sprite uint32 :offset-assert 0) (anim int32 :offset-assert 4) (anim-speed float :offset-assert 8) (birth-func basic :offset-assert 12) (joint-ppoint int32 :offset-assert 16) (num-to-birth float :offset-assert 20) - (dataf float 1 :offset-assert 0) ;; guessed by decompiler - (data uint32 1 :offset-assert 0) ;; guessed by decompiler + (dataf float 1 :offset 0) ;; guessed by decompiler + (data uint32 1 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype sp-field-init-spec (structure) - ((field uint16 :offset-assert 0) ;; sp-field-id - (flags uint16 :offset-assert 2) ;; sp-flag + "Part of a particle definition - how to initialize a field of a particle." + ((field sp-field-id :offset-assert 0) ;; + (flags sp-flag :offset-assert 2) ;; (initial-valuef float :offset-assert 4) (random-rangef float :offset-assert 8) (random-multf float :offset-assert 12) - (initial-value int32 :offset-assert 4) - (random-range int32 :offset-assert 8) - (random-mult int32 :offset-assert 12) - (func symbol :offset-assert 4) ;; guessed by decompiler - (tex texture-id :offset-assert 4) ;; guessed by decompiler - (pntr pointer :offset-assert 4) ;; guessed by decompiler - (object basic :offset-assert 4) - (sym symbol :offset-assert 4) ;; guessed by decompiler + (initial-value int32 :offset 4) + (random-range int32 :offset 8) + (random-mult int32 :offset 12) + (func symbol :offset 4) ;; guessed by decompiler + (tex texture-id :offset 4) ;; guessed by decompiler + (pntr pointer :offset 4) ;; guessed by decompiler + (object basic :offset 4) + (sym symbol :offset 4) ;; guessed by decompiler + ;; (sound sound-spec :offset 4) ;; guessed by decompiler ) + :allow-misaligned :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ;; field object uses ~A with a signed load. ) -|# -#| (deftype sparticle-launcher (basic) + "A definition of a single particle, as a list of init specs." ((birthaccum float :offset-assert 4) - (init-specs (inline-array sp-field-init-spec) :offset-assert 8) ;; guessed by decompiler - (level-flag int32 :offset-assert 12) + (soundaccum float :offset-assert 8) + (init-specs (inline-array sp-field-init-spec) :offset-assert 12) ;; guessed by decompiler ) :method-count-assert 11 :size-assert #x10 :flag-assert #xb00000010 (:methods - (sparticle-launcher-method-9 () none) ;; 9 ;; (get-field-spec-by-id (_type_ sp-field-id) sp-field-init-spec) - (sparticle-launcher-method-10 () none) ;; 10 ;; (setup-special-textures (_type_ string) none) + (get-field-spec-by-id "Look up a field's init spec by ID number." (_type_ sp-field-id) sp-field-init-spec) ;; 9 + (setup-special-textures "Set the particle's texture to the texture with the given name, and convert userdata strings to textures." (_type_ string) none) ;; 10 ) ) -|# -#| (deftype sparticle-group-item (structure) + "A reference to a single sparticle-launcher (by ID) and some parameters for using it." ((launcher uint32 :offset-assert 0) (fade-after meters :offset-assert 4) (falloff-to meters :offset-assert 8) - (flags uint16 :offset-assert 12) ;; sp-group-item-flag + (flags sp-group-item-flag :offset-assert 12) ;; sp-group-item-flag (period uint16 :offset-assert 14) (length uint16 :offset-assert 16) (offset int16 :offset-assert 18) @@ -24311,12 +28331,11 @@ :size-assert #x1c :flag-assert #x90000001c ) -|# -#| (deftype sparticle-launch-state (structure) + "The state associated with a launcher of a given sparticle." ((group-item sparticle-group-item :offset-assert 0) - (flags uint16 :offset-assert 4) ;; sp-launch-state-flags + (flags sp-launch-state-flags :offset-assert 4) ;; (randomize uint16 :offset-assert 6) (center vector :offset-assert 8) (sprite3d sprite-vec-data-3d :offset-assert 12) @@ -24325,27 +28344,28 @@ (accum float :offset-assert 24) (spawn-time uint32 :offset-assert 28) (control sparticle-launch-control :offset-assert 32) ;; guessed by decompiler - (swarm basic :offset-assert 20) - (seed uint32 :offset-assert 24) - (time uint32 :offset-assert 28) + (swarm basic :offset 20) + (seed uint32 :offset 24) + (time uint32 :offset 28) + (spec basic :offset 16) + (id uint32 :offset 12) ) :method-count-assert 9 :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype sparticle-launch-group (basic) + "Definition of multiple a particle-group, which is a collection of particle effects." ((length int16 :offset-assert 4) (duration uint16 :offset-assert 6) (linger-duration uint16 :offset-assert 8) - (flags uint16 :offset-assert 10) ;; sp-group-flag + (flags sp-group-flag :offset-assert 10) ;; (name string :offset-assert 12) ;; guessed by decompiler (launcher (inline-array sparticle-group-item) :offset-assert 16) ;; guessed by decompiler - (rotate-x deg :offset-assert 20) ;; degrees - (rotate-y deg :offset-assert 24) ;; degrees - (rotate-z deg :offset-assert 28) ;; degrees + (rotate-x degrees :offset-assert 20) ;; degrees + (rotate-y degrees :offset-assert 24) ;; degrees + (rotate-z degrees :offset-assert 28) ;; degrees (scale-x float :offset-assert 32) (scale-y float :offset-assert 36) (scale-z float :offset-assert 40) @@ -24355,26 +28375,26 @@ :size-assert #x40 :flag-assert #xa00000040 (:methods - (sparticle-launch-group-method-9 () none) ;; 9 ;; (create-launch-control (_type_ process) sparticle-launch-control) + (create-launch-control (_type_ process) sparticle-launch-control) ;; 9 ) ) -|# -#| (deftype sparticle-launch-control (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (group sparticle-launch-group :offset-assert 16) ;; guessed by decompiler + "Top-level type containing all the state needed to launch a particle group. + These are typically owned by a process, and allocated on the process heap. + These refer to static particle definitions, and then spawn particles that are tracked by the + particle system itself. This type just holds the launching-related state." + ((group sparticle-launch-group :offset-assert 16) ;; guessed by decompiler (proc process-drawable :offset-assert 20) ;; guessed by decompiler (local-clock int32 :offset-assert 24) - (local-space-binding particle-local-space-info :offset-assert 28) + (local-space-binding particle-local-space-info :offset 28 :score 18) (matrix int8 :offset-assert 32) (pointer-control uint32 :offset-assert 36) (last-spawn-frame int32 :offset-assert 40) (last-spawn-time int32 :offset-assert 44) (origin matrix :inline :offset-assert 48) - (center vector :inline :offset-assert 96) - (data sparticle-launch-state :dynamic :offset-assert 112) ;; guessed by decompiler + (center vector :inline :offset 96) + (data sparticle-launch-state :dynamic :inline :offset-assert 112) ;; guessed by decompiler ) :method-count-assert 22 :size-assert #x70 @@ -24390,9 +28410,9 @@ (sparticle-launch-control-method-21 () none) ;; 21 ) ) -|# -#| +(declare-type sparticle-system structure) + (deftype sparticle-subsampler (basic) ((min-emit float :offset-assert 4) (accum float :offset-assert 8) @@ -24401,27 +28421,25 @@ (part-id uint32 :offset-assert 20) (spawn-mat matrix :inline :offset-assert 32) (inited? symbol :offset-assert 96) ;; guessed by decompiler - (per-meter-method? basic :offset-assert 100) + (per-meter-method? symbol :offset-assert 100) ) :method-count-assert 11 :size-assert #x68 :flag-assert #xb00000068 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type sparticle-system sparticle-launcher float) _type_) + (new (symbol type sparticle-system uint float symbol float) _type_) (sparticle-subsampler-method-9 () none) ;; 9 ;; (init-with-vec! (_type_ vector) vector) (sparticle-subsampler-method-10 () none) ;; 10 ;; (init-with-mat! (_type_ matrix) matrix) ) ) -|# -#| (deftype particle-birth-work (structure) ((quat quaternion :inline :offset-assert 0) - (vel-range UNKNOWN 2 :offset-assert 16) - (vel vector :inline :offset-assert 16) - (pos-range UNKNOWN 2 :offset-assert 48) - (pos vector :inline :offset-assert 48) - (d-pos vector :inline :offset-assert 64) + (vel-range vector 2 :inline :offset-assert 16) + (vel vector :inline :offset 16) + (pos-range vector 2 :inline :offset-assert 48) + (pos vector :inline :offset 48) + (d-pos vector :inline :offset 64) (mat matrix :inline :offset-assert 80) (tt float :offset-assert 144) (t-step float :offset-assert 148) @@ -24430,17 +28448,56 @@ :size-assert #x98 :flag-assert #x900000098 ) -|# -;; (define-extern *launch-matrix* object) ;; matrix -;; (define-extern compute-rot-in-screenspace function) ;; (function vector float) +(define-extern *launch-matrix* matrix) ;; +(define-extern compute-rot-in-screenspace (function vector float)) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sparticle-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type sprite-vec-data-2d structure) + +;; +++sparticle-h:sp-cpuinfo-flag +(defenum sp-cpuinfo-flag + :bitfield #t + :type uint32 + ;; todo copied from jak 2 + (sp-cpuinfo-flag-0 0) + (sp-cpuinfo-flag-1 1) + (sp-cpuinfo-flag-2 2) ;; cleared after an aux has its func set to add-to-sprite-aux-lst + (sp-cpuinfo-flag-3 3) + (sp-cpuinfo-flag-4 4) + (sp-cpuinfo-flag-5 5) + (ready-to-launch 6) ;; maybe just just death? + (distort 7) ;; distort sprite + (aux-list 8) ;; prevents relaunch, adds to aux + (sp-cpuinfo-flag-9 9) + (level0 10) + (level1 11) + (sp-cpuinfo-flag-12 12) ;; required to relaunch + (sp-cpuinfo-flag-13 13) + (sp-cpuinfo-flag-14 14) + (glow 15) ;; glow sprite + (use-global-acc 16) + (launch-along-z 17) + (left-multiply-quat 18) + (right-multiply-quat 19) + (set-conerot 20) + (sp-cpuinfo-flag-21 21) + ) +;; ---sparticle-h:sp-cpuinfo-flag + +;; +++sparticle-h:sp-cpuinfo-flag-s32 +(defenum sp-cpuinfo-flag-s32 + :bitfield #t + :type int32 + :copy-entries sp-cpuinfo-flag + ) +;; ---sparticle-h:sp-cpuinfo-flag-s32 + (deftype sparticle-cpuinfo (structure) + "The per-particle information. This stays on the CPU, and isn't uploaded to the VU." ((sprite sprite-vec-data-2d :offset-assert 0) (adgif adgif-shader :offset-assert 4) (radius float :offset-assert 8) @@ -24450,19 +28507,20 @@ (fade rgbaf :inline :offset-assert 48) (acc vector :inline :offset-assert 64) (rotvel3d quaternion :inline :offset-assert 80) - (vel vector3s :inline :offset-assert 16) - (accel vector3s :inline :offset-assert 64) - (scalevelx float :offset-assert 28) - (scalevely float :offset-assert 44) + (vel vector3s :inline :offset 16) ;; vector :inline + (accel vector3s :inline :offset 64) ;; vector :inline + (scalevelx float :offset 28) + (scalevely float :offset 44) (friction float :offset-assert 96) (timer int32 :offset-assert 100) (flags sp-cpuinfo-flag :offset-assert 104) ;; guessed by decompiler + (flags-s32 sp-cpuinfo-flag-s32 :offset 104) ;; added (user-int32 int32 :offset-assert 108) - (user-uint32 uint32 :offset-assert 108) - (user-float float :offset-assert 108) - (user-pntr uint32 :offset-assert 108) - (user-object basic :offset-assert 108) - (user-sprite sprite-vec-data-2d :offset-assert 108) + (user-uint32 uint32 :offset 108) + (user-float float :offset 108 :score 1) + (user-pntr uint32 :offset 108) + (user-object basic :offset 108) + (user-sprite sprite-vec-data-2d :offset 108) (sp-func (function sparticle-system sparticle-cpuinfo sprite-vec-data-3d uint none) :offset-assert 112) ;; guessed by decompiler (next-time uint32 :offset-assert 116) (next-launcher basic :offset-assert 120) @@ -24470,43 +28528,43 @@ (valid uint8 :offset-assert 128) (clock-index uint8 :offset-assert 129) (user1-int16 uint16 :offset-assert 130) - (control basic :offset-assert 132) - (binding int32 :offset-assert 136) ;; sparticle-launch-state - (data uint32 1 :offset-assert 12) ;; guessed by decompiler - (datab int8 4 :offset-assert 12) ;; guessed by decompiler - (dataf float 1 :offset-assert 12) ;; guessed by decompiler + (key sparticle-launch-control :offset-assert 132) ;; guessed by decompiler + (binding sparticle-launch-state :offset-assert 136) + (data uint32 1 :offset 12) ;; guessed by decompiler + (datab int8 4 :offset 12) ;; guessed by decompiler + (dataf float 1 :offset 12) ;; guessed by decompiler + (datac uint8 1 :offset 12) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x8c :flag-assert #x90000008c - ;; field user-object uses ~A with a signed load. field control uses ~A with a signed load. + ;; field user-object uses ~A with a signed load. field key uses ~A with a signed load. ) -|# -#| (deftype sparticle-launchinfo (structure) + "Settings for launching a particle. These are a temporary thing consumed by the assembly particle code, and modified by particle callbacks." ((launchrot vector :inline :offset-assert 0) (conerot vector :inline :offset-assert 16) (rotate-x float :offset-assert 32) (rotate-y float :offset-assert 36) (rotate-z float :offset-assert 40) (coneradius float :offset-assert 44) - (rotate vector :inline :offset-assert 32) + (rotate vector :inline :offset 32) (scale-x float :offset-assert 48) (scale-y float :offset-assert 52) (scale-z float :offset-assert 56) (dummy float :offset-assert 60) - (scale vector :inline :offset-assert 48) - (data uint8 1 :offset-assert 0) ;; guessed by decompiler + (scale vector :inline :offset 48) + (data uint8 1 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype sparticle-system (basic) + "An entire particle 'system', which is a pipeline for spawning, updating, and generating sprite-renderer DMA data. + There are separate systems for different modes of sprite rendering: 2D/billboard, full 3D, and screen-space (HUD)" ((blocks int32 2 :offset-assert 4) ;; guessed by decompiler (length int32 2 :offset-assert 12) ;; guessed by decompiler (num-alloc int32 2 :offset-assert 20) ;; guessed by decompiler @@ -24520,17 +28578,23 @@ :method-count-assert 9 :size-assert #x34 :flag-assert #x900000034 + (:methods + (new (symbol type int int symbol pointer (inline-array adgif-shader)) _type_) ;; 0 + ) ) -|# -;; (define-extern *sp-60-hz* object) ;; symbol +(define-extern *sp-60-hz* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; actor-link-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype actor-link-info (basic) + "A linked list of actors. + + Actors allocate this on their process heap if they have a + `next-actor` or `prev-actor` defined in their lump + and use it for entity lookups." ((process process :offset-assert 4) ;; guessed by decompiler (next entity-actor :offset-assert 8) ;; guessed by decompiler (prev entity-actor :offset-assert 12) ;; guessed by decompiler @@ -24559,9 +28623,8 @@ (actor-link-info-method-25 () none) ;; 25 ;; (actor-count (_type_) int) ) ) -|# -;; (define-extern entity-actor-lookup function) ;; (function res-lump symbol int entity-actor) +(define-extern entity-actor-lookup (function res-lump symbol int entity-actor)) ;; ;; (define-extern entity-actor-count function) ;; (function res-lump symbol int) ;; (define-extern actor-link-subtask-complete-hook function) ;; (function entity-actor (pointer symbol) symbol) ;; (define-extern actor-link-subtask-incomplete-count-hook function) ;; (function entity-actor (pointer uint64) symbol) @@ -24572,60 +28635,66 @@ ;; cam-debug-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *redline-table* object) ;; (pointer float) -;; (define-extern *redline-index* object) ;; int -;; (define-extern float-save-redline function) ;; (function float none) -;; (define-extern float-lookup-redline function) ;; (function float float) -;; (define-extern *blueline-table* object) ;; (pointer float) -;; (define-extern *blueline-index* object) ;; int -;; (define-extern float-save-blueline function) ;; (function float none) -;; (define-extern float-lookup-blueline function) ;; (function float float) -;; (define-extern *greenline-table* object) ;; (pointer float) -;; (define-extern *greenline-index* object) ;; int -;; (define-extern float-save-greenline function) ;; (function float none) -;; (define-extern float-lookup-greenline function) ;; (function float float) -;; (define-extern *yellowline-table* object) ;; (pointer float) -;; (define-extern *yellowline-index* object) ;; int -;; (define-extern float-save-yellowline function) ;; (function float none) -;; (define-extern float-lookup-yellowline function) ;; (function float float) -;; (define-extern *timeplot-table* object) ;; (pointer float) -;; (define-extern *timeplot-index* object) ;; int -;; (define-extern float-save-timeplot function) ;; (function float none) -;; (define-extern float-lookup-timeplot function) ;; (function float float) -;; (define-extern *cam-layout* object) ;; symbol +(define-extern *redline-table* (pointer float)) +(define-extern *redline-index* int) +(define-extern float-save-redline (function float none)) +(define-extern float-lookup-redline (function float float)) +(define-extern *blueline-table* (pointer float)) +(define-extern *blueline-index* int) +(define-extern float-save-blueline (function float none)) +(define-extern float-lookup-blueline (function float float)) +(define-extern *greenline-table* (pointer float)) +(define-extern *greenline-index* int) +(define-extern float-save-greenline (function float none)) +(define-extern float-lookup-greenline (function float float)) +(define-extern *yellowline-table* (pointer float)) +(define-extern *yellowline-index* int) +(define-extern float-save-yellowline (function float none)) +(define-extern float-lookup-yellowline (function float float)) +(define-extern *timeplot-table* (pointer float)) +(define-extern *timeplot-index* int) +(define-extern float-save-timeplot (function float none)) +(define-extern float-lookup-timeplot (function float float)) +(define-extern *cam-layout* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-update-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *external-cam-options* object) ;; external-cam-option -;; (define-extern *external-cam-mode* object) ;; symbol -;; (define-extern *camera-look-through-other* object) ;; int -;; (define-extern *camera-other-fov* bfloat) ;; bfloat -;; (define-extern *camera-other-trans* object) ;; vector -;; (define-extern *camera-other-matrix* object) ;; matrix -;; (define-extern *camera-smush-control* object) ;; smush-control -;; (define-extern *camera-smush-control-horizontal* object) ;; smush-control -;; (define-extern *camera-smush-control-into* object) ;; smush-control -;; (define-extern *camera-smush-control-2* object) -;; (define-extern *camera-smush-control-horizontal-2* object) -;; (define-extern *camera-smush-control-into-2* object) -;; (define-extern *camera-other-root* object) ;; vector -;; (define-extern *fix-visible-level-mask* object) ;; int -;; (define-extern *manual-sample-point* object) ;; symbol +;; +++cam-update-h:external-cam-option +(defenum external-cam-option + :bitfield #t + (allow-z 0) + ) +;; ---cam-update-h:external-cam-option + +(define-extern *external-cam-options* external-cam-option) +(define-extern *external-cam-mode* symbol) +(define-extern *camera-look-through-other* int) +(define-extern *camera-other-fov* bfloat) +(define-extern *camera-other-trans* vector) +(define-extern *camera-other-matrix* matrix) +(define-extern *camera-smush-control* smush-control) +(define-extern *camera-smush-control-horizontal* smush-control) +(define-extern *camera-smush-control-into* smush-control) +(define-extern *camera-smush-control-2* smush-control) +(define-extern *camera-smush-control-horizontal-2* smush-control) +(define-extern *camera-smush-control-into-2* smush-control) +(define-extern *camera-other-root* vector) +(define-extern *fix-visible-level-mask* int) +(define-extern *manual-sample-point* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; hud-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype hud-string (structure) ((text string :offset-assert 0) ;; guessed by decompiler (scale float :offset-assert 4) (width float :offset-assert 8) (height float :offset-assert 12) - (color uint8 :offset-assert 16) ;; font-color - (flags uint16 :offset-assert 18) ;; font-flags + (color font-color :offset-assert 16) ;; font-color + (flags font-flags :offset-assert 18) ;; font-flags (pos vector4w :inline :offset-assert 32) (alpha float :offset-assert 48) (time float :offset-assert 52) @@ -24640,11 +28709,9 @@ (hud-string-method-9 () none) ;; 9 ) ) -|# -#| (deftype hud-corners (structure) - ((data UNKNOWN 4 :offset-assert 0) + ((data uint64 4 :offset-assert 0) ) :method-count-assert 10 :size-assert #x20 @@ -24653,22 +28720,43 @@ (hud-corners-method-9 () none) ;; 9 ) ) -|# -#| +;; +++hud-h:hud-sprite-flags +(defenum hud-sprite-flags + :type uint16 + :bitfield #t + (hsf0 0) + (hsf1 1) + (hsf2 2) + (hsf3 3) + (hsf4 4) + (hsf5 5) + (hsf6 6) + (hsf7 7) + (hsf8 8) + (hsf9 9) + (hsf10 10) + (hsf11 11) + (hsf12 12) + (hsf13 13) + (hsf14 14) + (hsf15 15) + ) +;; ---hud-h:hud-sprite-flags + (deftype hud-sprite (structure) ((pos vector4w :inline :offset-assert 0) - (offset-x float :offset-assert 0) - (offset-y float :offset-assert 4) + (offset-x float :offset 0) + (offset-y float :offset 4) (color vector4w :inline :offset-assert 16) - (flags uint16 :offset-assert 32) ;; hud-sprite-flags + (flags hud-sprite-flags :offset-assert 32) ;; (scale-x float :offset-assert 36) - (width float :offset-assert 36) + (width float :offset 36) (scale-y float :offset-assert 40) - (height float :offset-assert 40) + (height float :offset 40) (angle float :offset-assert 44) (tex texture :offset-assert 48) ;; guessed by decompiler - (tid texture-id :offset-assert 48) ;; guessed by decompiler + (tid texture-id :offset 48) ;; guessed by decompiler ) :method-count-assert 11 :size-assert #x34 @@ -24678,13 +28766,11 @@ (hud-sprite-method-10 () none) ;; 10 ;; (hud-sprite-method-10 (_type_ dma-buffer level int int int int) object) ) ) -|# -#| (deftype hud-box (structure) ((box bounding-box2 :inline :offset-assert 0) - (min vector2 :inline :offset-assert 0) - (max vector2 :inline :offset-assert 8) + (min vector2 :inline :offset 0) + (max vector2 :inline :offset 8) (color vector4w :inline :offset-assert 16) ) :method-count-assert 13 @@ -24697,9 +28783,7 @@ (hud-box-method-12 () none) ;; 12 ;; (draw-box-alpha-3 (_type_ dma-buffer) none) ) ) -|# -#| (deftype hud-icon (structure) ((icon (pointer manipy) :offset-assert 0) ;; guessed by decompiler (pos vector4w :inline :offset-assert 16) @@ -24710,17 +28794,25 @@ :size-assert #x28 :flag-assert #x900000028 ) -|# -#| +;; +++hud-h:hud-flags +(defenum hud-flags + :type uint32 + :bitfield #t + (disable 0) + (should-die 1) + (show 2) + ) +;; ---hud-h:hud-flags + (deftype hud (process) ((trigger-time uint64 :offset-assert 144) ;; time-frame (last-hide-time uint64 :offset-assert 152) ;; time-frame (offset float :offset-assert 160) (flags hud-flags :offset-assert 164) ;; guessed by decompiler - (strings hud-string 45 :offset-assert 176) ;; guessed by decompiler - (sprites hud-sprite 50 :offset-assert 3056) ;; guessed by decompiler - (icons hud-icon 2 :offset-assert 6256) ;; guessed by decompiler + (strings hud-string 45 :inline :offset-assert 176) ;; guessed by decompiler + (sprites hud-sprite 50 :inline :offset-assert 3056) ;; guessed by decompiler + (icons hud-icon 2 :inline :offset-assert 6256) ;; guessed by decompiler (num-strings int32 :offset-assert 6352) (num-sprites int32 :offset-assert 6356) (gui-id sound-id :offset-assert 6360) ;; guessed by decompiler @@ -24729,13 +28821,7 @@ :size-assert #x18dc :flag-assert #x1e185018dc (:methods - (hud-method-9 () none) ;; 9 - (hud-method-10 () none) ;; 10 - (hud-method-11 () none) ;; 11 - (hud-method-12 () none) ;; 12 - (hud-method-13 () none) ;; 13 - (hud-method-14 () none) ;; 14 ;; (hidden? (_type_) object) - (hud-method-15 () none) ;; 15 ;; (draw (_type_) none) + (hud-method-15 () none) ;; 14 ;; (hidden? (_type_) object) 15 ;; (draw (_type_) none) (hud-method-16 () none) ;; 16 ;; (update-values! (_type_) none) (hud-method-17 () none) ;; 17 ;; (init-callback (_type_) none) (hud-method-18 () none) ;; 18 ;; (event-callback (_type_ process int symbol event-message-block) object) @@ -24752,9 +28838,7 @@ (hud-method-29 () none) ;; 29 ) ) -|# -#| (deftype hud-map (hud) ((x float :offset-assert 6364) (y float :offset-assert 6368) @@ -24763,7 +28847,6 @@ :size-assert #x18e4 :flag-assert #x1e186018e4 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -24775,23 +28858,29 @@ ;; rpc-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(define-extern rpc-busy? (function int uint)) +(define-extern rpc-call (function int uint uint uint int uint int uint)) + (deftype rpc-buffer (basic) + "Buffer for storing input/output data for a remote procedure call to the overlord driver on the IOP." ((elt-size uint32 :offset-assert 4) (elt-count uint32 :offset-assert 8) (elt-used uint32 :offset-assert 12) - (busy symbol :offset-assert 16) ;; guessed by decompiler + (busy symbol :offset-assert 16) (base pointer :offset-assert 20) ;; guessed by decompiler - (data uint8 :dynamic :offset-assert 32) ;; guessed by decompiler + (data uint8 :dynamic :offset 32) ;; guessed by decompiler ) + (:methods + (new (symbol type uint uint) _type_) ;; 0 + ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype rpc-buffer-pair (basic) + "A double buffer of RPC buffers. This is used to let the game queue up data in one buffer while + the other is being read/written by overlord." ((buffer rpc-buffer 2 :offset-assert 4) ;; guessed by decompiler (current rpc-buffer :offset-assert 12) ;; guessed by decompiler (last-recv-buffer pointer :offset-assert 16) ;; guessed by decompiler @@ -24801,31 +28890,46 @@ :size-assert #x18 :flag-assert #xf00000018 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type uint uint int) rpc-buffer-pair) - (rpc-buffer-pair-method-9 () none) ;; 9 ;; (call (rpc-buffer-pair uint pointer uint) int) - (rpc-buffer-pair-method-10 () none) ;; 10 ;; (add-element (rpc-buffer-pair) pointer) - (rpc-buffer-pair-method-11 () none) ;; 11 ;; (decrement-elt-used (rpc-buffer-pair) int) - (rpc-buffer-pair-method-12 () none) ;; 12 ;; (sync (rpc-buffer-pair symbol) int) - (rpc-buffer-pair-method-13 () none) ;; 13 ;; (check-busy (rpc-buffer-pair) symbol) - (rpc-buffer-pair-method-14 () none) ;; 14 ;; (pop-last-received (rpc-buffer-pair) pointer) + (new (symbol type uint uint int) rpc-buffer-pair) ;; 0 + (call "Start an async RPC call. If there is already one in progress, stall and wait for it to finish." (rpc-buffer-pair uint pointer uint) int) ;; 9 + (add-element "Add an element. If the buffer is full, flush it!" (rpc-buffer-pair) pointer) ;; 10 + (decrement-elt-used "Remove the most recently queued element." (rpc-buffer-pair) int) ;; 11 + (sync "Wait for an in-progress rpc to finish." (rpc-buffer-pair symbol) int) ;; 12 + (check-busy "Check to see if an rpc is in progress." (rpc-buffer-pair) symbol) ;; 13 + (pop-last-received "Pop the response from the most recently completed rpc call." (rpc-buffer-pair) pointer) ;; 14 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; path-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++path-h:path-control-flag +(defenum path-control-flag + :bitfield #t + :type uint32 + (display 0) + (draw-line 1) ;; TODO - only seen it used to control debug drawing so far + (draw-point 2) ;; TODO - only seen it used to control debug drawing so far + (draw-text 3) ;; TODO - only seen it used to control debug drawing so far + (not-found 4) + ) +;; ---path-h:path-control-flag + (deftype path-control (basic) + "The path-control is a reference a path data, which is just a list of points. + Although it contains a `curve`, the knot part is not populated, so it's just treated as + a bunch of line segments from the control points. + The child class curve-control does fill out the knot data and is a proper b-spline. + These path-controls are typically allocated on a process heap." ((flags path-control-flag :offset-assert 4) ;; guessed by decompiler (name symbol :offset-assert 8) ;; guessed by decompiler (process process-drawable :offset-assert 12) ;; guessed by decompiler (distmap uint32 :offset-assert 16) (curve curve :inline :offset-assert 20) - (num-cverts int32 :offset-assert 24) - (cverts uint32 :offset-assert 20) + (num-cverts int32 :offset 24) + (cverts uint32 :offset 20) ) :method-count-assert 33 :size-assert #x28 @@ -24858,31 +28962,41 @@ (path-control-method-32 () none) ;; 32 ) ) -|# -#| (deftype curve-control (path-control) + "A curve-control is like a path control, but it has both control points and knot points." () :method-count-assert 35 :size-assert #x28 :flag-assert #x2300000028 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type process symbol float) _type_) + (new (symbol type process symbol res-lump symbol float) _type_) ;; 0 (curve-control-method-33 () none) ;; 33 (curve-control-method-34 () none) ;; 34 ) ) -|# -;; (define-extern get-knot-name function) -;; (define-extern get-distmap-name function) +(define-extern get-knot-name (function symbol symbol)) +(define-extern get-distmap-name (function symbol symbol)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; nav-mesh-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type grid-hash structure) +(declare-type sphere-hash structure) + +;; +++nav-mesh-h:nav-mesh-flag +(defenum nav-mesh-flag + :type uint8 + :bitfield #t + (water 0) + (dummy 1) + ) +;; ---nav-mesh-h:nav-mesh-flag + (deftype nav-mesh-work-debug (structure) + "Debug outputs for the nav-mesh assembly functions" ((debug-vec1 vector :inline :offset-assert 0) (debug-vec2 vector :inline :offset-assert 16) (debug-vec3 vector :inline :offset-assert 32) @@ -24895,16 +29009,17 @@ (debug-vec10 vector :inline :offset-assert 144) (debug-vec11 vector :inline :offset-assert 160) (debug-vec12 vector :inline :offset-assert 176) - (sphere-array sphere 16 :offset-assert 192) ;; guessed by decompiler + (sphere-array sphere 16 :inline :offset-assert 192) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x1c0 :flag-assert #x9000001c0 ) -|# -#| +(declare-type nav-poly structure) + (deftype nav-mesh-work (structure) + "Workspace for nav-mesh processing functions." ((vert0-table int8 4 :offset-assert 0) ;; guessed by decompiler (vert1-table int8 4 :offset-assert 4) ;; guessed by decompiler (edge-mask-table uint8 3 :offset-assert 8) ;; guessed by decompiler @@ -24913,7 +29028,7 @@ (rad-to-deg float :offset-assert 20) (nav-poly-min-dist float :offset-assert 24) (nav-poly-epsilon float :offset-assert 28) - (sphere-array sphere 16 :offset-assert 32) ;; guessed by decompiler + (sphere-array sphere 16 :inline :offset-assert 32) ;; guessed by decompiler (debug nav-mesh-work-debug :offset-assert 288) (work-struct-in-scratch int8 :offset-assert 292) (mesh-struct-in-scratch int8 :offset-assert 293) @@ -24928,10 +29043,9 @@ :size-assert #x13c :flag-assert #x90000013c ) -|# -#| (deftype nav-mesh-link (structure) + "Link between two different meshes" ((id uint32 :offset-assert 0) (dest-mesh-id uint32 :offset-assert 4) (src-link-poly-id uint8 :offset-assert 8) @@ -24944,9 +29058,17 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| + +;; +++nav-mesh-h:nav-mesh-link-search-node-status +(defenum nav-mesh-link-search-node-status + :type uint8 + :bitfield #t + (open 0) + (closed 1) + ) +;; ---nav-mesh-h:nav-mesh-link-search-node-status + (deftype nav-mesh-link-search-node (structure) ((pprev uint32 :offset-assert 0) (next nav-mesh-link-search-node :offset-assert 4) @@ -24954,51 +29076,47 @@ (link nav-mesh-link :offset-assert 12) (cost-to-start float :offset-assert 16) (cost-to-end float :offset-assert 20) - (status nav-mesh-link-search-node-status :offset-assert 24) + (status nav-mesh-link-search-node-status :offset-assert 24) ) :method-count-assert 9 :size-assert #x19 :flag-assert #x900000019 ;; field nav-mesh-link-search-node-status is likely a value type. ) -|# -#| (deftype nav-poly (structure) - ((data uint8 64 :offset-assert 0) ;; guessed by decompiler - (vertex vector 4 :offset-assert 0) ;; guessed by decompiler - (vertex0 vector :inline :offset-assert 0) - (vertex1 vector :inline :offset-assert 16) - (vertex2 vector :inline :offset-assert 32) - (vertex3 vector :inline :offset-assert 48) - (id uint8 :offset-assert 12) - (pat uint8 :offset-assert 13) - (vertex-count uint8 :offset-assert 14) - (link uint8 :offset-assert 15) - (adj-poly uint8 4 :offset-assert 28) ;; guessed by decompiler - (adj-poly0 uint8 :offset-assert 28) - (adj-poly1 uint8 :offset-assert 29) - (adj-poly2 uint8 :offset-assert 30) - (adj-poly3 uint8 :offset-assert 31) - (min-y float :offset-assert 44) - (max-y float :offset-assert 60) + "Polygon within a nav-mesh. Can be a tri or quad. + Based on the implementation of point-poly-intersection?, these should likely be convex." + ((data uint8 64 :offset 0 :score -1) ;; guessed by decompiler + (vertex vector 4 :inline :offset 0) ;; guessed by decompiler + (vertex0 vector :inline :offset 0) + (vertex1 vector :inline :offset 16) + (vertex2 vector :inline :offset 32) + (vertex3 vector :inline :offset 48) + (id uint8 :offset 12) + (pat uint8 :offset 13) + (vertex-count uint8 :offset 14) + (link uint8 :offset 15) + (adj-poly uint8 4 :offset 28) ;; guessed by decompiler + (adj-poly0 uint8 :offset 28) + (adj-poly1 uint8 :offset 29) + (adj-poly2 uint8 :offset 30) + (adj-poly3 uint8 :offset 31) + (min-y float :offset 44) + (max-y float :offset 60) ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype nav-vertex (vector) () :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype nav-sphere (structure) ((trans sphere :inline :offset-assert 0) ) @@ -25006,16 +29124,16 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| +(declare-type nav-mesh basic) + (deftype nav-ray (structure) ((current-pos vector :inline :offset-assert 0) (dir vector :inline :offset-assert 16) (dest-pos vector :inline :offset-assert 32) - (current-mesh basic :offset-assert 48) + (current-mesh nav-mesh :offset-assert 48) (current-poly nav-poly :offset-assert 52) - (next-mesh basic :offset-assert 56) + (next-mesh nav-mesh :offset-assert 56) (next-poly nav-poly :offset-assert 60) (len meters :offset-assert 64) (last-edge int8 :offset-assert 68) @@ -25024,7 +29142,7 @@ (reached-dest symbol :offset-assert 76) ;; guessed by decompiler (hit-boundary symbol :offset-assert 80) ;; guessed by decompiler (hit-gap symbol :offset-assert 84) ;; guessed by decompiler - (cross-meshes basic :offset-assert 88) + (cross-meshes nav-mesh-link :offset-assert 88) ) :method-count-assert 13 :size-assert #x5c @@ -25032,15 +29150,13 @@ (:methods (nav-ray-method-9 () none) ;; 9 (nav-ray-method-10 () none) ;; 10 - (nav-ray-method-11 () none) ;; 11 - (nav-ray-method-12 () none) ;; 12 + (nav-ray-method-11 (_type_) none) ;; 11 + (nav-ray-method-12 (_type_) none) ;; 12 ) ) -|# -#| (deftype nav-route-portal (structure) - ((vertex nav-vertex 2 :offset-assert 0) ;; guessed by decompiler + ((vertex nav-vertex 2 :inline :offset-assert 0) ;; guessed by decompiler (next-poly nav-poly :offset-assert 32) (edge-index int8 :offset-assert 36) ) @@ -25048,9 +29164,7 @@ :size-assert #x25 :flag-assert #x900000025 ) -|# -#| (deftype nav-find-poly-parms (structure) ((point vector :inline :offset-assert 0) (y-threshold float :offset-assert 16) @@ -25063,9 +29177,7 @@ :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype clamp-travel-vector-to-mesh-return-info (structure) ((found-boundary symbol :offset-assert 0) ;; guessed by decompiler (intersection vector :inline :offset-assert 16) @@ -25090,26 +29202,23 @@ (clamp-travel-vector-to-mesh-return-info-method-10 () none) ;; 10 ) ) -|# -#| (deftype nav-find-corner-portal-params (structure) ((start-poly nav-poly :offset-assert 0) (target-poly nav-poly :offset-assert 4) (corner-poly nav-poly :offset-assert 8) (start-pos vector :inline :offset-assert 16) (target-pos vector :inline :offset-assert 32) - (corner-verts UNKNOWN 2 :offset-assert 48) + (corner-verts vector 2 :inline :offset-assert 48) (vert-select int8 :offset-assert 80) ) :method-count-assert 9 :size-assert #x51 :flag-assert #x900000051 ) -|# -#| (deftype nav-mesh (basic) + "Mesh used for creature/enemy navigation." ((work nav-mesh-work :offset-assert 4) (poly-array (inline-array nav-poly) :offset-assert 8) ;; guessed by decompiler (static-sphere-count uint8 :offset-assert 12) @@ -25122,10 +29231,10 @@ (sphere-hash sphere-hash :offset-assert 28) ;; guessed by decompiler (static-sphere (inline-array sphere) :offset-assert 32) ;; guessed by decompiler (user-list engine :offset-assert 36) ;; guessed by decompiler - (next-nav-mesh surface :offset-assert 40) ;; guessed by decompiler - (prev-nav-mesh surface :offset-assert 44) ;; guessed by decompiler + (next-nav-mesh basic :offset-assert 40) ;; guessed by decompiler + (prev-nav-mesh basic :offset-assert 44) ;; guessed by decompiler (bounds sphere :inline :offset-assert 48) - (origin vector :inline :offset-assert 48) + (origin vector :inline :offset 48) (entity entity :offset-assert 64) ;; guessed by decompiler (link-array (inline-array nav-mesh-link) :offset-assert 68) ;; guessed by decompiler (link-count uint8 :offset-assert 72) @@ -25181,24 +29290,21 @@ (nav-mesh-method-46 () none) ;; 46 ;; (nav-mesh-method-46 (_type_ nav-poly) nav-poly) ) ) -|# -#| (deftype nav-location (structure) - ((nav-mesh basic :offset-assert 0) + ((nav-mesh nav-mesh :offset-assert 0) (nav-poly nav-poly :offset-assert 4) ) :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -;; (define-extern vector-normalize-unity! function) ;; (function vector vector) -;; (define-extern vector-normalize-unity-copy! function) ;; (function vector vector vector) -;; (define-extern debug-validate-current-poly function) ;; (function symbol) -;; (define-extern point-poly-intersection? function) ;; (function nav-mesh vector int (inline-array vector) symbol) -;; (define-extern nav-sphere-from-cam function) ;; (function none) +(define-extern vector-normalize-unity! (function vector vector)) +(define-extern vector-normalize-unity-copy! (function vector vector vector)) +(define-extern debug-validate-current-poly (function symbol)) +(define-extern point-poly-intersection? (function nav-mesh vector int (inline-array vector) symbol)) +(define-extern nav-sphere-from-cam (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; nav-control-h ;; @@ -25414,23 +29520,24 @@ ;; spatial-hash-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype grid-hash-word (uint8) -;; () -;; :flag-assert #x900000001 -;; ) +(declare-type grid-hash-work structure) + +(deftype grid-hash-word (uint8) + () + :flag-assert #x900000001 + ) -#| (deftype grid-hash-box (structure) + "Integer coordinate box for the spatial hash grid." ((min int8 3 :offset-assert 0) ;; guessed by decompiler (max int8 3 :offset-assert 3) ;; guessed by decompiler ) + :pack-me :method-count-assert 9 :size-assert #x6 :flag-assert #x900000006 ) -|# -#| (deftype grid-hash (basic) ((work grid-hash-work :offset-assert 4) ;; guessed by decompiler (search-box grid-hash-box :inline :offset-assert 8) @@ -25475,9 +29582,7 @@ (grid-hash-method-26 () none) ;; 26 ) ) -|# -#| (deftype find-nav-sphere-ids-params (structure) ((bsphere sphere :inline :offset-assert 0) (y-threshold float :offset-assert 16) @@ -25490,10 +29595,9 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype sphere-hash (grid-hash) + "An extension of grid hash that holds spheres inside of the grid." ((sphere-array (inline-array sphere) :offset-assert 88) ;; guessed by decompiler (max-object-count int16 :offset-assert 92) (pad int16 :offset-assert 94) @@ -25516,9 +29620,7 @@ (sphere-hash-method-35 () none) ;; 35 ) ) -|# -#| (deftype hash-object-info (structure) ((object basic :offset-assert 0) ) @@ -25526,10 +29628,9 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype spatial-hash (sphere-hash) + "An extension of sphere-hash that associates an object with each sphere." ((object-array (inline-array hash-object-info) :offset-assert 104) ;; guessed by decompiler (mem-object-array (inline-array hash-object-info) :offset-assert 108) ;; guessed by decompiler (spr-object-array (inline-array hash-object-info) :offset-assert 112) ;; guessed by decompiler @@ -25547,23 +29648,21 @@ (spatial-hash-method-41 () none) ;; 41 ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; actor-hash-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *actor-list* object) ;; (pointer collide-shape) -;; (define-extern *actor-list-length* object) ;; int +(define-extern *actor-list* (pointer collide-shape)) +(define-extern *actor-list-length* int) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; fmv-player-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype m2v-caption (structure) - ((text-id uint32 :offset-assert 0) + ((text-id text-id :offset-assert 0) (start int32 :offset-assert 4) (end int32 :offset-assert 8) ) @@ -25571,9 +29670,7 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype m2v-info (structure) ((name basic :offset-assert 0) (sound basic :offset-assert 4) @@ -25590,9 +29687,7 @@ :size-assert #x1c :flag-assert #x90000001c ) -|# -#| (deftype fmv-player (process) ((texture-base-page uint32 :offset-assert 144) (texture-width uint32 :offset-assert 148) @@ -25605,12 +29700,6 @@ :size-assert #xb1 :flag-assert #x14003000b1 (:methods - (fmv-player-method-9 () none) ;; 9 - (fmv-player-method-10 () none) ;; 10 - (fmv-player-method-11 () none) ;; 11 - (fmv-player-method-12 () none) ;; 12 - (fmv-player-method-13 () none) ;; 13 - (fmv-player-method-14 () none) ;; 14 (fmv-player-method-15 () none) ;; 15 (fmv-player-method-16 () none) ;; 16 (fmv-player-method-17 () none) ;; 17 @@ -25618,9 +29707,7 @@ (fmv-player-method-19 () none) ;; 19 ) ) -|# -#| (deftype fmv-display-params (structure) ((display-mode int32 :offset-assert 0) (texture-base-page uint32 :offset-assert 4) @@ -25639,9 +29726,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype fmv-player-params (structure) ((display-mode fmv-display-params :inline :offset-assert 0) (file-init basic :offset-assert 48) @@ -25661,10 +29746,9 @@ (fmv-player-params-method-9 () none) ;; 9 ) ) -|# -;; (define-extern *fmv-player* object) -;; (define-extern *m2v-info* array) +(define-extern *fmv-player* fmv-player) +(define-extern *m2v-info* (array m2v-info)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; load-dgo ;; @@ -25818,7 +29902,7 @@ ;; (define-extern current-str-status function) ;; (function sound-id stream-status) ;; (define-extern *dnas-is-running* object) ;; (define-extern is-cd-in? function) ;; (function symbol) -;; (define-extern new-sound-id function) ;; (function sound-id) +(define-extern new-sound-id (function sound-id)) ;; ;; (define-extern check-irx-version function) ;; (function int) ;; (define-extern sound-bank-load function) ;; (function sound-name int int sound-id) ;; (define-extern sound-bank-unload function) ;; (function sound-name int) @@ -25832,7 +29916,7 @@ ;; (define-extern *debug-sound-info-item* object) ;; (define-extern sound-instance-play function) ;; (define-extern sound-instance-update function) -;; (define-extern sound-info-by-name function) +(define-extern sound-info-by-name (function string sound-info)) ;; (define-extern *sound-handles* array) ;; (define-extern find-sound-handle function) ;; (define-extern release-sound-handle function) @@ -25862,7 +29946,7 @@ ;; (define-extern free-last-sound-buffer-entry function) ;; (function none) ;; (define-extern sound-basic-cb function) ;; (function int (pointer int32) none) ;; (define-extern sound-trans-copy function) -;; (define-extern string->sound-name function) ;; (function string sound-name) +(define-extern string->sound-name (function string sound-name)) ;; ;; (define-extern sound-name->string function) ;; (function sound-name string) ;; (define-extern sound-set-volume function) ;; (function sound-group float int) ;; (define-extern sound-set-reverb function) ;; (function int float float uint int) @@ -25891,13 +29975,13 @@ ;; transformq ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern transformq-copy! function) ;; (function transformq transformq transformq) -;; (define-extern matrix<-transformq! function) ;; (function matrix transformq matrix) -;; (define-extern matrix<-no-trans-transformq! function) ;; (function matrix transformq matrix) -;; (define-extern matrix<-transformq+trans! function) ;; (function matrix transformq vector matrix) -;; (define-extern matrix<-transformq+world-trans! function) ;; (function matrix transformq vector matrix) -;; (define-extern matrix<-parented-transformq! function) ;; (function matrix transformq vector matrix) -;; (define-extern matrix<-transformq+rot-offset! function) ;; (function matrix transformq vector matrix) +(define-extern transformq-copy! (function transformq transformq transformq)) +(define-extern matrix<-transformq! (function matrix transformq matrix)) +(define-extern matrix<-no-trans-transformq! (function matrix transformq matrix)) +(define-extern matrix<-transformq+trans! (function matrix transformq vector matrix)) +(define-extern matrix<-transformq+world-trans! (function matrix transformq vector matrix)) +(define-extern matrix<-parented-transformq! (function matrix transformq vector matrix)) +(define-extern matrix<-transformq+rot-offset! (function matrix transformq vector matrix)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-func ;; @@ -25955,7 +30039,7 @@ ;; (define-extern cspace<-cspace! function) ;; (function cspace cspace matrix) ;; (define-extern cspace<-cspace-normalized! function) ;; (function cspace cspace matrix) ;; (define-extern cspace<-parent-joint! function) ;; (function cspace (pointer process-drawable) int matrix) -;; (define-extern cspace<-transformq! function) ;; (function cspace transformq matrix) +(define-extern cspace<-transformq! (function cspace transformq matrix)) ;; (define-extern cspace<-transformq+trans! function) ;; (function cspace transformq vector matrix) ;; (define-extern cspace<-transformq+world-trans! function) ;; (function cspace transformq vector matrix) ;; (define-extern cspace<-transformq+rot-offset! function) ;; (function cspace transformq vector matrix) @@ -25966,7 +30050,7 @@ ;; (define-extern cspace<-parented-matrix-mirror! function) ;; (function cspace matrix matrix) ;; (define-extern cspace<-parented-matrix-joint-flip-z! function) ;; (function cspace matrix matrix) ;; (define-extern cspace<-matrix-joint-flip-z! function) ;; (function cspace matrix none) -;; (define-extern cspace<-parented-transformq-joint! function) ;; (function cspace transformq none) +(define-extern cspace<-parented-transformq-joint! (function cspace transformq none)) ;; (define-extern cspace<-parented-transformq-joint-flip-z! function) ;; (function cspace transformq none) ;; (define-extern clear-frame-accumulator function) ;; (define-extern normalize-frame-quaternions function) @@ -26405,34 +30489,34 @@ ;; (define-extern *debug-text-3d-trk* object) ;; debug-tracking-thang ;; (define-extern *debug-prims* object) ;; (define-extern debug-reset-prim-buffer function) -;; (define-extern add-debug-flat-triangle function) ;; (function symbol bucket-id vector vector vector rgba symbol) +(define-extern add-debug-flat-triangle (function symbol bucket-id vector vector vector rgba symbol)) ;; (define-extern get-debug-line function) ;; (function debug-line) ;; (define-extern get-debug-text-3d function) ;; (function debug-text-3d) ;; (define-extern debug-reset-buffers function) ;; (function symbol) ;; (define-extern debug-draw-buffers function) ;; (function symbol) -;; (define-extern add-debug-line function) ;; (function symbol bucket-id vector vector rgba symbol rgba symbol) -;; (define-extern add-debug-line2d function) ;; (function symbol bucket-id vector4w vector4w vector4w symbol) -;; (define-extern add-debug-box function) ;; (function symbol bucket-id vector vector rgba symbol) -;; (define-extern add-debug-box-with-transform function) ;; (function symbol bucket-id bounding-box matrix rgba symbol) -;; (define-extern add-debug-x function) ;; (function symbol bucket-id vector rgba symbol) -;; (define-extern add-debug-cross function) ;; (function symbol bucket-id vector float symbol) -;; (define-extern add-debug-text-3d function) ;; (function symbol bucket-id string vector font-color vector2h symbol) -;; (define-extern add-debug-sphere-with-transform function) ;; (function symbol bucket-id vector meters matrix rgba symbol) -;; (define-extern add-debug-sphere function) ;; (function symbol bucket-id vector meters rgba symbol) -;; (define-extern add-debug-text-sphere function) ;; (function symbol bucket-id vector meters string rgba symbol) -;; (define-extern add-debug-spheres function) ;; (function symbol bucket-id (inline-array vector) int rgba symbol) -;; (define-extern add-debug-line-sphere function) ;; (function symbol bucket-id vector vector float rgba none) -;; (define-extern add-debug-circle function) ;; (function symbol bucket-id vector float rgba matrix symbol) -;; (define-extern add-debug-vector function) ;; (function symbol bucket-id vector vector meters rgba symbol) -;; (define-extern add-debug-matrix function) ;; (function symbol bucket-id matrix meters matrix) -;; (define-extern add-debug-rot-matrix function) ;; (function symbol bucket-id matrix vector matrix) -;; (define-extern add-debug-quaternion function) ;; (function symbol bucket-id vector quaternion none) -;; (define-extern add-debug-cspace function) ;; (function symbol bucket-id cspace cspace) -;; (define-extern add-debug-yrot-vector function) ;; (function symbol bucket-id vector float float rgba symbol) -;; (define-extern add-debug-arc function) ;; (function symbol bucket-id vector float float float rgba matrix symbol) -;; (define-extern add-debug-curve function) ;; (function symbol bucket-id (inline-array vector) int (pointer float) int rgba symbol) -;; (define-extern add-debug-curve2 function) ;; (function symbol bucket-id curve rgba symbol symbol) -;; (define-extern add-debug-points function) ;; (function symbol bucket-id (inline-array vector) int rgba float int symbol) +(define-extern add-debug-line (function symbol bucket-id vector vector rgba symbol rgba symbol)) +(define-extern add-debug-line2d (function symbol bucket-id vector4w vector4w vector4w symbol)) +(define-extern add-debug-box (function symbol bucket-id vector vector rgba symbol)) +(define-extern add-debug-box-with-transform (function symbol bucket-id bounding-box matrix rgba symbol)) +(define-extern add-debug-x (function symbol bucket-id vector rgba symbol)) +(define-extern add-debug-cross (function symbol bucket-id vector float symbol)) +(define-extern add-debug-text-3d (function symbol bucket-id string vector font-color vector2h symbol)) +(define-extern add-debug-sphere-with-transform (function symbol bucket-id vector meters matrix rgba symbol)) +(define-extern add-debug-sphere (function symbol bucket-id vector meters rgba symbol)) +(define-extern add-debug-text-sphere (function symbol bucket-id vector meters string rgba symbol)) +(define-extern add-debug-spheres (function symbol bucket-id (inline-array vector) int rgba symbol)) +(define-extern add-debug-line-sphere (function symbol bucket-id vector vector float rgba none)) +(define-extern add-debug-circle (function symbol bucket-id vector float rgba matrix symbol)) +(define-extern add-debug-vector (function symbol bucket-id vector vector meters rgba symbol)) +(define-extern add-debug-matrix (function symbol bucket-id matrix meters matrix)) +(define-extern add-debug-rot-matrix (function symbol bucket-id matrix vector matrix)) +(define-extern add-debug-quaternion (function symbol bucket-id vector quaternion none)) +(define-extern add-debug-cspace (function symbol bucket-id cspace cspace)) +(define-extern add-debug-yrot-vector (function symbol bucket-id vector float float rgba symbol)) +(define-extern add-debug-arc (function symbol bucket-id vector float float float rgba matrix symbol)) +(define-extern add-debug-curve (function symbol bucket-id (inline-array vector) int (pointer float) int rgba symbol)) +(define-extern add-debug-curve2 (function symbol bucket-id curve rgba symbol symbol)) +(define-extern add-debug-points (function symbol bucket-id (inline-array vector) int rgba float int symbol)) ;; (define-extern debug-percent-bar function) ;; (function symbol bucket-id int int float rgba int int symbol) ;; (define-extern debug-pad-display function) ;; (function cpad-info symbol) ;; (define-extern add-debug-light function) ;; (function symbol bucket-id light vector string symbol) @@ -26538,6 +30622,85 @@ ;; (define-extern emerc-vu1-block object) ;; vu-function +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; merc-blend-shape ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +#| +(deftype blerc-block-header (structure) + ((tag generic-merc-tag :inline :offset-assert 0) + (vtx-count uint32 :offset-assert 16) + (overlap uint32 :offset-assert 20) + (lump-dest uint32 :offset-assert 24) + (lump-qwc uint32 :offset-assert 28) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) +|# + +#| +(deftype blerc-block (structure) + ((output uint8 848 :offset-assert 0) ;; guessed by decompiler + (header blerc-block-header :inline :offset-assert 848) + ) + :method-count-assert 9 + :size-assert #x370 + :flag-assert #x900000370 + ) +|# + +#| +(deftype blerc-dcache (structure) + ((repl-mult vector 40 :offset-assert 0) ;; guessed by decompiler + ) + :method-count-assert 9 + :size-assert #x280 + :flag-assert #x900000280 + ) +|# + +#| +(deftype blerc-globals (structure) + ((first uint32 :offset-assert 0) + (next uint32 :offset-assert 4) + (min-val int16 :offset-assert 8) + (max-val int16 :offset-assert 10) + (fragment-count int32 :offset-assert 12) + (vtx-count int32 :offset-assert 16) + (target-vtx-count int32 :offset-assert 20) + ) + :method-count-assert 9 + :size-assert #x18 + :flag-assert #x900000018 + ) +|# + +#| +(deftype blerc-context (structure) + ((block-a blerc-block :inline :offset-assert 0) + (dummy uint8 7312 :offset-assert 880) ;; guessed by decompiler + (block-b blerc-block :inline :offset-assert 8192) + ) + :method-count-assert 9 + :size-assert #x2370 + :flag-assert #x900002370 + ) +|# + +;; (define-extern *stats-blerc* object) ;; symbol +;; (define-extern *blerc-globals* object) ;; blerc-globals +;; (define-extern blerc-stats-init function) ;; (function none) +;; (define-extern blerc-init function) ;; (function none) +;; (define-extern blerc-a-fragment function) ;; function +;; (define-extern dma-from-spr function) ;; function +;; (define-extern merc-dma-chain-to-spr function) ;; function +;; (define-extern blerc-execute function) ;; (function none) +;; (define-extern merc-blend-shape function) ;; (function process-drawable object) +;; (define-extern setup-blerc-chains-for-one-fragment function) ;; (function object object object object object object object) +;; (define-extern setup-blerc-chains function) ;; (function merc-ctrl (pointer int16) dma-buffer none) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; merc ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -26630,6 +30793,33 @@ ;; (define-extern debug-merc-fade-runtime function) ;; (define-extern foreground-check-longest-edge function) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; foreground ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; (define-extern foreground-vu0-block object) ;; vu-function +;; (define-extern generic-bucket-state-init function) ;; (function generic-bucket-state none) +;; (define-extern mercneric-chain-init function) ;; (function mercneric-chain bucket-id none) +;; (define-extern foreground-init function) ;; (function none) +;; (define-extern texscroll-make-request function) ;; (function merc-effect none) +;; (define-extern texscroll-execute function) ;; (function none) +;; (define-extern vu-lights<-light-group! function) ;; (function vu-lights light-group none) +;; (define-extern foreground-add-mtx-calc function) ;; (function bone-calculation (inline-array pris-mtx) bone-calc-flags bone-calculation) +;; (define-extern foreground-wrapup function) ;; (function none) +;; (define-extern *default-shadow-settings* object) ;; shadow-settings +;; (define-extern foreground-shadow function) ;; (function draw-control (inline-array pris-mtx) pointer pointer) +;; (define-extern foreground-generic-merc-death function) ;; (function draw-control generic-merc-ctrl none) +;; (define-extern foreground-generic-merc-add-fragments function) ;; (function merc-effect pointer mercneric-chain pointer) +;; (define-extern foreground-generic-merc function) ;; (function draw-control pointer int pointer) +;; (define-extern foreground-merc function) ;; (function draw-control (inline-array pris-mtx) pointer int int object pointer) +;; (define-extern foreground-emerc function) ;; (function draw-control (inline-array pris-mtx) pointer object int int pointer) +;; (define-extern foreground-check-longest-edge-asm function) ;; (function draw-control float symbol) +;; (define-extern foreground-ripple function) ;; (function draw-control merc-ctrl pointer int pointer) +;; (define-extern foreground-draw function) ;; (function draw-control dma-buffer float none) +;; (define-extern foreground-draw-hud function) ;; (function draw-control dma-buffer float none) +;; (define-extern *foreground* object) ;; foreground-globals +;; (define-extern *foreground-draw-engine* object) ;; engine + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-vu0 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -26650,6 +30840,44 @@ ;; (define-extern generic-vu1-init-buf-special function) ;; (function bucket-id gs-zbuf none) ;; (define-extern generic-vu1-init-buffers function) ;; (function none) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; generic-effect ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; (define-extern *target-lock* object) ;; object +;; (define-extern *generic-consts* object) ;; generic-consts +;; (define-extern generic-work-init function) ;; (function generic-bucket-state none) +;; (define-extern generic-upload-vu0 function) ;; (function none) +;; (define-extern upload-vu0-program function) ;; (function vu-function pointer none) +;; (define-extern generic-initialize-without-sync function) ;; (function matrix vu-lights none) +;; (define-extern generic-initialize function) ;; (function generic-bucket-state matrix vu-lights none) +;; (define-extern generic-wrapup function) ;; (function generic-bucket-state none) +;; (define-extern generic-dma-from-spr function) +;; (define-extern generic-light-proc function) +;; (define-extern generic-envmap-proc function) +;; (define-extern generic-prepare-dma-double function) +;; (define-extern generic-prepare-dma-single function) +;; (define-extern generic-envmap-dproc function) +;; (define-extern generic-interp-dproc function) +;; (define-extern generic-no-light-proc function) +;; (define-extern generic-no-light-dproc-only function) +;; (define-extern generic-no-light-dproc function) +;; (define-extern generic-no-light+envmap function) +;; (define-extern generic-no-light function) +;; (define-extern generic-envmap-only-proc function) +;; (define-extern generic-light function) +;; (define-extern generic-copy-vtx-dclr-dtex function) +;; (define-extern generic-none function) +;; (define-extern generic-none-dma-wait function) +;; (define-extern *warp-data* object) ;; object +;; (define-extern generic-warp-source-proc function) ;; (function none) +;; (define-extern generic-warp-source function) ;; (function gsf-buffer none) +;; (define-extern generic-warp-dest-proc function) +;; (define-extern generic-warp-dest function) +;; (define-extern generic-warp-envmap-dest function) +;; (define-extern generic-debug-light-proc function) +;; (define-extern generic-post-debug function) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-merc ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -26698,6 +30926,81 @@ ;; (define-extern generic-tie-debug function) ;; (define-extern generic-tie-execute function) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; shadow-cpu ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +#| +(deftype shadow-stats (structure) + ((num-single-tris uint32 :offset-assert 0) + (num-double-tris uint32 :offset-assert 4) + (num-single-edges uint32 :offset-assert 8) + (num-double-edges uint32 :offset-assert 12) + (num-fragments uint16 :offset-assert 16) + (num-objects uint16 :offset-assert 18) + ) + :method-count-assert 9 + :size-assert #x14 + :flag-assert #x900000014 + ) +|# + +#| +(deftype shadow-dcache (structure) + ((vtx-table uint32 :offset-assert 0) + (single-edge-table uint32 :offset-assert 4) + (double-edge-table uint32 :offset-assert 8) + (double-tri-table uint32 :offset-assert 12) + (dcache-top uint32 :offset-assert 16) + (num-facing-single-tris uint32 :offset-assert 20) + (num-single-edges uint32 :offset-assert 24) + (num-double-edges uint32 :offset-assert 28) + (single-tri-list uint32 :offset-assert 32) + (single-edge-list uint32 :offset-assert 36) + (double-edge-list uint32 :offset-assert 40) + (ptr-dual-verts uint32 :offset-assert 44) + (stats shadow-stats :inline :offset-assert 48) + (frag-qwc uint32 :offset-assert 68) + (center vector :inline :offset-assert 80) + (plane vector :inline :offset-assert 96) + (top-plane vector :inline :offset-assert 112) + (near-plane vector :inline :offset-assert 128) + (light-dir vector :inline :offset-assert 144) + (vtx-min vector :inline :offset-assert 160) + (data uint8 :dynamic :offset-assert 176) ;; guessed by decompiler + ) + :method-count-assert 9 + :size-assert #xb0 + :flag-assert #x9000000b0 + ) +|# + +;; (define-extern *shadow-data* object) ;; shadow-data +;; (define-extern shadow-invert-z-buf function) ;; (function dma-buffer none) +;; (define-extern shadow-make-invert-buf function) ;; (function none) +;; (define-extern shadow-dma-init function) ;; (function dma-buffer none) +;; (define-extern shadow-dma-end function) ;; (function dma-buffer gs-rgbaq symbol int none) +;; (define-extern shadow-vu0-block object) ;; vu-function +;; (define-extern shadow-xform-verts function) ;; function +;; (define-extern shadow-calc-dual-verts function) ;; function +;; (define-extern shadow-scissor-edges function) ;; function +;; (define-extern shadow-scissor-top function) ;; function +;; (define-extern shadow-init-vars function) ;; function +;; (define-extern shadow-find-facing-single-tris function) ;; function +;; (define-extern shadow-find-single-edges function) ;; function +;; (define-extern shadow-find-facing-double-tris function) ;; function +;; (define-extern shadow-find-double-edges function) ;; function +;; (define-extern shadow-add-verts function) ;; function +;; (define-extern shadow-add-facing-single-tris function) ;; function +;; (define-extern shadow-add-single-edges function) ;; function +;; (define-extern shadow-add-single-tris function) ;; function +;; (define-extern shadow-add-double-tris function) ;; function +;; (define-extern shadow-add-double-edges function) ;; function +;; (define-extern debug-draw-settings function) ;; (function shadow-settings symbol) +;; (define-extern shadow-execute function) ;; (function shadow-dma-packet pointer pointer) +;; (define-extern shadow-vu0-upload function) ;; (function none) +;; (define-extern shadow-execute-all function) ;; (function dma-buffer none) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; shadow-vu1 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -27451,7 +31754,7 @@ ;; (define-extern count-launch-controls-in-table function) ;; (define-extern lookup-part-group-by-name function) ;; (function string sparticle-launch-group) ;; (define-extern lookup-part-group-pointer-by-name function) ;; (function string (pointer object)) -;; (define-extern part-group-pointer? function) ;; (function pointer symbol) +(define-extern part-group-pointer? (function pointer symbol)) ;; ;; (define-extern unlink-part-group-by-heap function) ;; (function kheap int) ;; (define-extern sp-init-fields! function) ;; (function (pointer float) (inline-array sp-field-init-spec) sp-field-id sp-field-id symbol (inline-array sp-field-init-spec)) ;; (define-extern *sp-launcher-lock* object) ;; symbol @@ -27662,7 +31965,7 @@ ;; (define-extern drawable-load function) ;; (function drawable kheap drawable) ;; (define-extern art-load function) ;; (function string kheap art) ;; (define-extern art-group-load-check function) ;; (function string kheap int art-group) -;; (define-extern external-art-buffer-init function) ;; (function external-art-buffer int) +(define-extern external-art-buffer-init (function external-art-buffer int)) ;; (define-extern *preload-spool-anims* object) ;; symbol ;; (define-extern ja-play-spooled-anim function) ;; (function spool-anim art-joint-anim art-joint-anim (function process-drawable symbol) spooler-flags int :behavior process-drawable) ;; (define-extern ja-play-spooled-no-sync-anim function) @@ -28616,12 +32919,50 @@ ;; collide-frag ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; collide-mesh ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +#| +(deftype sopt-work (structure) + ((intersect vector :inline :offset-assert 0) + (sphere-bbox4w bounding-box4w :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) +|# + +#| +(deftype spat-work (structure) + ((intersect vector :inline :offset-assert 0) + (sphere-bbox4w bounding-box4w :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) +|# + +#| +(deftype oot-work (structure) + ((intersect vector :inline :offset-assert 0) + (sphere-bbox4w bounding-box4w :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) +|# + +;; (define-extern should-push-away-test-mesh function) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-touch ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype add-prims-touching-work (structure) ((tri1 collide-tri-result :offset-assert 0) (tri2 collide-tri-result :offset-assert 4) @@ -28630,10 +32971,24 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# ;; (define-extern get-intersect-point function) ;; (function vector touching-prims-entry collide-shape touching-shapes-entry vector) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; collide-shape ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; (define-extern find-ground-point function) ;; (function control-info vector float float vector) +;; (define-extern collide-shape-moving-angle-set! function) ;; (function collide-shape-moving vector vector none) +;; (define-extern cshape-reaction-update-state function) ;; (function control-info collide-query vector none) +;; (define-extern cshape-reaction-default function) ;; (function control-info collide-query vector vector collide-status) +;; (define-extern cshape-reaction-just-move function) ;; (function control-info collide-query vector collide-status) +;; (define-extern collide-shape-draw-debug-marks function) ;; (function none) +;; (define-extern *col-timer* object) ;; stopwatch +;; (define-extern *frame-timer* object) ;; stopwatch +;; (define-extern *col-timer-enable* object) ;; symbol +;; (define-extern debug-report-col-stats function) ;; (function int) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-shape-rider ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -28870,7 +33225,7 @@ ;; (define-extern matrix-world->local function) ;; (function symbol object matrix) ;; (define-extern *camera-dummy-vector* object) ;; vector ;; (define-extern *camera-dummy-velocity* object) -;; (define-extern camera-pos function) ;; (function vector) +(define-extern camera-pos (function vector)) ;; ;; (define-extern camera-vel function) ;; (define-extern math-camera-pos function) ;; (function vector) ;; (define-extern math-camera-nearest-dist-sq function) @@ -28878,7 +33233,7 @@ ;; (define-extern math-camera-nearest-matrix function) ;; (define-extern math-camera-nearest-dist function) ;; (define-extern camera-matrix function) ;; (function matrix) -;; (define-extern math-camera-matrix function) ;; (function matrix) +(define-extern math-camera-matrix (function matrix)) ;; ;; (define-extern camera-angle function) ;; (function float) ;; (define-extern camera-teleport-to-entity function) ;; (function entity-actor symbol :behavior process) ;; (define-extern camera-teleport-to-entity-named function) ;; (function string none) @@ -29647,63 +34002,63 @@ ;; process-drawable ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern cspace-by-name function) ;; (function process-drawable string cspace) -;; (define-extern cspace-index-by-name function) ;; (function process-drawable string int) -;; (define-extern vector<-cspace! function) ;; (function vector cspace vector) -;; (define-extern vector<-matrix! function) ;; (function vector matrix vector) -;; (define-extern vector<-cspace+vector! function) ;; (function vector cspace vector vector) -;; (define-extern cspace-children function) ;; (function process-drawable int pair) -;; (define-extern cspace-inspect-tree function) ;; (function process-drawable cspace int int object process-drawable) -;; (define-extern execute-math-engine function) ;; (function int) -;; (define-extern execute-cloth-engine function) ;; (function int) -;; (define-extern draw-joint-axes function) ;; (function process-drawable none) -;; (define-extern draw-root function) ;; (function process-drawable none) -;; (define-extern empty-state state) ;; (state process) -;; (define-extern process-drawable-error-print function) ;; (function process-drawable string none) -;; (define-extern skeleton-group->draw-control function) ;; (function process-drawable skeleton-group (pointer cspace-array) draw-control) -;; (define-extern ja-group-in-array? function) ;; (function (array int32) art-joint-anim :behavior process-drawable) -;; (define-extern ja-done? function) ;; (function int symbol :behavior process-drawable) -;; (define-extern ja-min? function) ;; (function int symbol :behavior process-drawable) -;; (define-extern ja-max? function) ;; (function int symbol :behavior process-drawable) -;; (define-extern ja-num-frames function) ;; (function int int :behavior process-drawable) -;; (define-extern ja-frame-num function) ;; (function int float :behavior process-drawable) -;; (define-extern ja-aframe-num function) ;; (function int float :behavior process-drawable) -;; (define-extern ja-aframe function) ;; (function float int float :behavior process-drawable) -;; (define-extern ja-speed function) ;; (function int float :behavior process-drawable) -;; (define-extern ja-step function) ;; (function int float :behavior process-drawable) -;; (define-extern ja-rate function) ;; (function int float :behavior process-drawable) -;; (define-extern ja-linear-vel function) ;; (function int vector :behavior process-drawable) +(define-extern cspace-by-name (function process-drawable string cspace)) +(define-extern cspace-index-by-name (function process-drawable string int)) +(define-extern vector<-cspace! (function vector cspace vector)) +(define-extern vector<-matrix! (function vector matrix vector)) +(define-extern vector<-cspace+vector! (function vector cspace vector vector)) +(define-extern cspace-children (function process-drawable int pair)) +(define-extern cspace-inspect-tree (function process-drawable cspace int int object process-drawable)) +(define-extern execute-math-engine (function int)) +(define-extern execute-cloth-engine (function int)) +(define-extern draw-joint-axes (function process-drawable none)) +(define-extern draw-root (function process-drawable none)) +(define-extern empty-state (state process)) +(define-extern process-drawable-error-print (function process-drawable string none)) +(define-extern skeleton-group->draw-control (function process-drawable skeleton-group (pointer cspace-array) draw-control)) +(define-extern ja-group-in-array? (function (array int32) art-joint-anim :behavior process-drawable)) +(define-extern ja-done? (function int symbol :behavior process-drawable)) +(define-extern ja-min? (function int symbol :behavior process-drawable)) +(define-extern ja-max? (function int symbol :behavior process-drawable)) +(define-extern ja-num-frames (function int int :behavior process-drawable)) +(define-extern ja-frame-num (function int float :behavior process-drawable)) +(define-extern ja-aframe-num (function int float :behavior process-drawable)) +(define-extern ja-aframe (function float int float :behavior process-drawable)) +(define-extern ja-speed (function int float :behavior process-drawable)) +(define-extern ja-step (function int float :behavior process-drawable)) +(define-extern ja-rate (function int float :behavior process-drawable)) +(define-extern ja-linear-vel (function int vector :behavior process-drawable)) ;; (define-extern ja-linear-dist function) ;; (define-extern ja-distance-covered function) -;; (define-extern ja-channel-set! function) ;; (function int int :behavior process-drawable) -;; (define-extern ja-channel-push! function) ;; (function int time-frame int :behavior process-drawable) -;; (define-extern ja-channel-float! function) ;; (function art-joint-anim float float float joint-control-channel :behavior process-drawable) -;; (define-extern joint-control-reset! function) ;; (function joint-control joint-control-channel none :behavior process-drawable) -;; (define-extern ja-group-size function) ;; (function int :behavior process-drawable) -;; (define-extern ja-eval function) ;; (function int :behavior process-drawable) -;; (define-extern ja-blend-eval function) ;; (function int :behavior process-drawable) -;; (define-extern cloth-post function) ;; (function none :behavior process-drawable) -;; (define-extern ja-post function) ;; (function none :behavior process-drawable) -;; (define-extern sleep-code function) ;; (function symbol :behavior process) -;; (define-extern transform-and-sleep function) ;; (function none :behavior process-drawable) -;; (define-extern transform-and-sleep-code function) ;; (function none :behavior process-drawable) -;; (define-extern transform-post function) ;; (function int :behavior process-drawable) -;; (define-extern rider-trans function) ;; (function none :behavior process-drawable) -;; (define-extern rider-post function) ;; (function none :behavior process-drawable) -;; (define-extern pusher-post function) ;; (function int :behavior process-drawable) -;; (define-extern process-drawable-delay-player function) ;; (function time-frame int :behavior process-drawable) -;; (define-extern process-drawable-fuel-cell-handler function) ;; (function process int symbol event-message-block none :behavior process-drawable) -;; (define-extern process-drawable-birth-fuel-cell function) ;; (function entity vector symbol none :behavior process-drawable) -;; (define-extern find-offending-process-focusable function) ;; (function process-tree attack-info process-focusable :behavior process-drawable) -;; (define-extern *valid-con* object) ;; string -;; (define-extern process-drawable-valid? function) ;; (function process-drawable symbol) -;; (define-extern process-drawable-reset-all-cloth function) ;; (function process-drawable none) -;; (define-extern process-drawable-set-riding function) ;; (function process-drawable symbol none) -;; (define-extern process-drawable-set-cloth-ground-height function) ;; (function process-drawable float none) -;; (define-extern process-drawable-set-wind-strength function) ;; (function process-drawable float none) -;; (define-extern process-drawable-show-all-cloth function) ;; (function process-drawable symbol none) -;; (define-extern process-drawable-slow-mo-cloth function) ;; (function process-drawable symbol none) -;; (define-extern process-drawable-cloth-command function) ;; (function process-drawable pair none) +(define-extern ja-channel-set! (function int int :behavior process-drawable)) +(define-extern ja-channel-push! (function int time-frame int :behavior process-drawable)) +(define-extern ja-channel-float! (function art-joint-anim float float float joint-control-channel :behavior process-drawable)) +(define-extern joint-control-reset! (function joint-control joint-control-channel none :behavior process-drawable)) +(define-extern ja-group-size (function int :behavior process-drawable)) +(define-extern ja-eval (function int :behavior process-drawable)) +(define-extern ja-blend-eval (function int :behavior process-drawable)) +(define-extern cloth-post (function none :behavior process-drawable)) +(define-extern ja-post (function none :behavior process-drawable)) +(define-extern sleep-code (function symbol :behavior process)) +(define-extern transform-and-sleep (function none :behavior process-drawable)) +(define-extern transform-and-sleep-code (function none :behavior process-drawable)) +(define-extern transform-post (function int :behavior process-drawable)) +(define-extern rider-trans (function none :behavior process-drawable)) +(define-extern rider-post (function none :behavior process-drawable)) +(define-extern pusher-post (function int :behavior process-drawable)) +(define-extern process-drawable-delay-player (function time-frame int :behavior process-drawable)) +(define-extern process-drawable-fuel-cell-handler (function process int symbol event-message-block none :behavior process-drawable)) +(define-extern process-drawable-birth-fuel-cell (function entity vector symbol none :behavior process-drawable)) +;; (define-extern find-offending-process-focusable (function process-tree attack-info process-focusable :behavior process-drawable)) +(define-extern *valid-con* string) +(define-extern process-drawable-valid? (function process-drawable symbol)) +(define-extern process-drawable-reset-all-cloth (function process-drawable none)) +(define-extern process-drawable-set-riding (function process-drawable symbol none)) +(define-extern process-drawable-set-cloth-ground-height (function process-drawable float none)) +(define-extern process-drawable-set-wind-strength (function process-drawable float none)) +(define-extern process-drawable-show-all-cloth (function process-drawable symbol none)) +(define-extern process-drawable-slow-mo-cloth (function process-drawable symbol none)) +(define-extern process-drawable-cloth-command (function process-drawable pair none)) ;; (define-extern process-drawable-local-transq-for-joint! function) ;; (define-extern process-drawable-local-trans-for-joint! function) @@ -30060,7 +34415,7 @@ ) |# -;; (define-extern *lightning-spec-id-table* object) ;; (array lightning-spec) +(define-extern *lightning-spec-id-table* (array lightning-spec)) ;; ;; (define-extern *lightning-gcf* object) ;; gcf-control ;; (define-extern lightning-fractal-gen function) ;; (function (inline-array vector) int int float lightning-spec none) ;; (define-extern lightning-uniform-gen function) ;; (function (inline-array vector) int int float lightning-spec none) @@ -30652,7 +35007,7 @@ ;; (define-extern projectile-update-velocity-add-gravity function) ;; (function projectile none) ;; (define-extern projectile-update-velocity-space-wars function) ;; (function projectile none) ;; (define-extern projectile-base-code function) -;; (define-extern projectile-init-by-other function) ;; (function projectile-init-by-other-params object :behavior projectile) +(define-extern projectile-init-by-other (function projectile-init-by-other-params object :behavior projectile)) ;; (define-extern projectile-bounce-update-velocity function) ;; (function projectile-bounce none :behavior projectile) ;; (define-extern projectile-bounce-falling-post function) ;; (function none :behavior projectile-bounce) ;; (define-extern projectile-bounce-move function) ;; (function projectile-bounce none) @@ -31310,7 +35665,7 @@ ;; (define-extern get-aspect-ratio function) ;; (function symbol) ;; (define-extern set-progressive-scan function) ;; (function symbol none) ;; (define-extern get-progressive-scan function) ;; (function symbol) -;; (define-extern set-graphics-mode function) ;; (function none) +(define-extern set-graphics-mode (function none)) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; main ;; @@ -31333,7 +35688,7 @@ ;; (define-extern blackout function) ;; (function bucket-id none) ;; (define-extern add-blackout function) ;; (function time-frame int int int int int) ;; (define-extern paused? function) ;; (function symbol) -;; (define-extern movie? function) ;; (function symbol) +(define-extern movie? (function symbol)) ;; ;; (define-extern scene-select? function) ;; (function symbol) ;; (define-extern demo? function) ;; (function symbol) ;; (define-extern kiosk? function) ;; (function symbol) @@ -31357,6 +35712,37 @@ ;; (define-extern on function) ;; (function symbol process) ;; (define-extern off function) ;; (function none) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; collide-cache ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +#| +(deftype collide-puls-work (structure) + ((ignore-pat pat-surface :offset-assert 0) ;; guessed by decompiler + (bsphere sphere :inline :offset-assert 16) + (move-dist vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) +|# + +#| +(deftype lsmi-work (structure) + ((best-u float :offset-assert 0) + (orig-best-u float :offset-assert 4) + (action uint32 :offset-assert 8) + (cquery collide-query :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x22c + :flag-assert #x90000022c + ) +|# + +;; (define-extern test-closest-pt-in-triangle function) ;; (function collide-cache symbol) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-debug ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -31387,6 +35773,130 @@ ;; (define-extern mem-size function) ;; (function basic symbol int int) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; entity ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +#| +(deftype debug-actor-info (basic) + ((name string :offset-assert 4) ;; guessed by decompiler + (handle uint64 :offset-assert 8) ;; handle + (process process :offset-assert 16) ;; guessed by decompiler + (pid int32 :offset-assert 20) + ) + :method-count-assert 9 + :size-assert #x18 + :flag-assert #x900000018 + ) +|# + +;; actor-group is already defined! + +#| +(deftype entity (res-lump) + ((trans vector :inline :offset-assert 28) + (aid uint32 :offset-assert 44) + ) + :method-count-assert 27 + :size-assert #x38 + :flag-assert #x1b00000038 + (:methods + (entity-method-22 () none) ;; 22 ;; (birth! (_type_) _type_) + (entity-method-23 () none) ;; 23 ;; (kill! (_type_) _type_) + (entity-method-24 () none) ;; 24 ;; (add-to-level! (_type_ level-group level actor-id) none) + (entity-method-25 () none) ;; 25 ;; (remove-from-level! (_type_ level-group) _type_) + (entity-method-26 () none) ;; 26 ;; (get-level (_type_) level) + ) + ) +|# + +#| +(deftype entity-nav-mesh (entity) + ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ) + :method-count-assert 29 + :size-assert #x3c + :flag-assert #x1d0000003c + (:methods + (entity-nav-mesh-method-27 () none) ;; 27 ;; (initialize-nav-mesh! (_type_) none) + (entity-nav-mesh-method-28 () none) ;; 28 ;; (debug-draw (_type_) none) + ) + ) +|# + +#| +(deftype entity-actor (entity) + ((etype type :offset-assert 56) ;; guessed by decompiler + (task uint8 :offset-assert 60) ;; game-task + (kill-mask task-mask :offset-assert 52) ;; guessed by decompiler + (vis-id int16 :offset-assert 62) + (quat vector :inline :offset-assert 76) ;; quaternion :inline + ) + :method-count-assert 33 + :size-assert #x60 + :flag-assert #x2100000060 + (:methods + (entity-actor-method-27 () none) ;; 27 ;; (next-actor (_type_) entity-actor) + (entity-actor-method-28 () none) ;; 28 ;; (prev-actor (_type_) entity-actor) + (entity-actor-method-29 () none) ;; 29 ;; (debug-print (_type_ symbol type) none) + (entity-actor-method-30 () none) ;; 30 ;; (toggle-status (_type_ entity-perm-status symbol) none) + (entity-actor-method-31 () none) ;; 31 ;; (get-simple-travel-vector (_type_ vector vector vector object float) nav-mesh) + (entity-actor-method-32 () none) ;; 32 ;; (project-point-to-nav-mesh (_type_ vector vector nav-poly float) nav-poly) + ) + ) +|# + +;; (define-extern *spawn-actors* object) ;; symbol +;; (define-extern *compact-actors* object) ;; symbol +;; (define-extern *vis-actors* object) ;; symbol +;; (define-extern *additional-spawner-count* object) +;; (define-extern *additional-spawners* object) +;; (define-extern register-additional-spawner function) +;; (define-extern unregister-spawner-at-index function) +;; (define-extern *camera-pos-0* object) +;; (define-extern *camera-pos-1* object) +;; (define-extern vis-cull-all? function) +;; (define-extern vis-dist-additional-ok? function) +;; (define-extern vis-dist-ok? function) +;; (define-extern entity-by-name function) ;; (function string entity) +;; (define-extern entity-by-type function) ;; (function type entity-actor) +;; (define-extern entity-by-aid function) ;; (function uint entity) +;; (define-extern entity-actor-from-level-name function) ;; (function symbol entity-actor) +;; (define-extern entity-nav-mesh-by-aid function) ;; (function actor-id entity-nav-mesh) +;; (define-extern nav-mesh-from-res-tag function) ;; (function entity symbol int nav-mesh) +;; (define-extern entity-by-meters function) ;; (function float float float entity-actor) +;; (define-extern process-by-ename function) ;; (function string process) +;; (define-extern entity-process-count function) ;; (function symbol int) +;; (define-extern entity-count function) ;; (function int) +;; (define-extern entity-remap-names function) ;; (function pair none) +;; (define-extern process-status-bits function) ;; (function process symbol none) +;; (define-extern process-entity-set! function) ;; (function process entity entity) +(define-extern process-task-mask (function process task-mask)) ;; +;; (define-extern update-actor-vis-box function) ;; (function process-drawable vector vector none) +;; (define-extern expand-bounding-box function) ;; (function vector vector vector vector none) +;; (define-extern expand-bounding-box-from-nav-meshes function) ;; (function entity vector vector object) +;; (define-extern expand-vis-box-with-point function) ;; (function entity vector none) +;; (define-extern *debug-actor-info* debug-actor-info) ;; debug-actor-info +;; (define-extern *pid-string* object) ;; string +;; (define-extern debug-actor function) ;; (function string none) +;; (define-extern debug-actor-process function) ;; (function process none) +;; (define-extern draw-actor-marks function) ;; (function process none) +;; (define-extern init-entity function) ;; (function process entity-actor type none) +;; (define-extern entity-deactivate-handler function) ;; (function process entity-actor none) +;; (define-extern check-for-rougue-process function) ;; (function process int int level none) +;; (define-extern process-drawable-scale-from-entity! function) ;; (function process-drawable entity none) +;; (define-extern process-drawable-from-entity! function) ;; (function process-drawable entity-actor none) +;; (define-extern reset-actors-by-game-type function) +;; (define-extern reset-actors function) ;; (function symbol none) +;; (define-extern reset-cameras function) ;; (function none) +;; (define-extern entity-birth-no-kill function) ;; (function entity process) +;; (define-extern entity-task-complete-on function) ;; (function entity none) +;; (define-extern entity-task-complete-off function) ;; (function entity none) +;; (define-extern process-entity-status! function) ;; (function process entity-perm-status symbol entity-perm-status) +;; (define-extern find-nearest-entity function) ;; (function vector type entity) +;; (define-extern entity-speed-test function) ;; (function string entity) +;; (define-extern dump-entity-remap function) ;; (function object object none) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; path ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -31519,7 +36029,7 @@ ;; (define-extern connection-validate function) ;; (function connection none) ;; (define-extern connection-list-validate function) ;; (function (inline-array connection) symbol) ;; (define-extern nav-control-validate function) ;; (function process-drawable none) -;; (define-extern debug-validate-nav-poly function) ;; (function nav-mesh-link nav-poly none) +(define-extern debug-validate-nav-poly (function nav-mesh-link nav-poly none)) ;; ;; (define-extern vu-point-triangle-intersection? function) ;; (function vector vector vector vector symbol) ;; (define-extern poly-in-height-range? function) ;; (function nav-poly float float symbol) ;; (define-extern nav-ray-test function) ;; (function nav-mesh nav-poly vector vector meters) @@ -31615,7 +36125,7 @@ ;; (define-extern *footstep-surface* object) ;; pat-surface ;; (define-extern *debug-effect-control* object) ;; symbol ;; (define-extern sound-name-with-material function) ;; (function string pat-surface string sound-name) -;; (define-extern effect-param->sound-spec function) ;; (function sound-spec (pointer float) int process-focusable sound-spec) +(define-extern effect-param->sound-spec (function sound-spec (pointer float) int process-focusable sound-spec)) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; water-part ;; @@ -31732,6 +36242,61 @@ ;; (define-extern ray-plane-equation-intersect function) ;; (function vector vector vector vector float) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; task-control ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +#| +(deftype scene-stage (process-hidden) + () + :method-count-assert 16 + :size-assert #x90 + :flag-assert #x1000000090 + ) +|# + +;; (define-extern game-task-node->string function) ;; (function game-task-node string) +;; (define-extern reset-city-squad-control function) ;; (function symbol none) +;; (define-extern city-task-faction-commands function) ;; (function object) +;; (define-extern evaluate-faction-commands function) ;; (function pair object) +;; (define-extern update-task-masks function) ;; (function symbol int) +;; (define-extern play-clean function) ;; (function symbol int) +;; (define-extern play-task function) ;; (function game-task symbol symbol string) +;; (define-extern task-node-by-name function) ;; (function string game-task-node-info) +;; (define-extern task-node-index-by-name function) ;; (function string int) +;; (define-extern task-resolution-close! function) ;; (function game-task symbol) +;; (define-extern task-close! function) ;; (function string symbol) +;; (define-extern task-closed? function) ;; (function string symbol) +;; (define-extern open-task-nodes function) ;; (function (array game-task-node-info) (array game-task-node-info)) +;; (define-extern task-node-closed? function) ;; (function game-task-node symbol) +;; (define-extern task-node-close! function) ;; (function game-task-node symbol int) +;; (define-extern task-open? function) ;; (function string symbol) +;; (define-extern task-node-open? function) ;; (function game-task-node symbol) +;; (define-extern task-node-open! function) ;; (function game-task-node symbol int) +;; (define-extern task-node-close-upwards function) ;; (function (array game-task-node-info) int none) +;; (define-extern task-node-reset function) ;; (function symbol int) +;; (define-extern cheat-add-gold function) +;; (define-extern *cache-open-node* object) +;; (define-extern get-open-task-node-info function) +;; (define-extern get-task-total-score function) +(define-extern get-task-cup-score (function int int)) +;; (define-extern stats-weapon-used function) +;; (define-extern stats-player-died function) +;; (define-extern stats-player-medal function) +;; (define-extern stats-player-ranking function) +;; (define-extern stats-player-score function) +;; (define-extern stats-player-end-mode function) +;; (define-extern stats-player-time function) +;; (define-extern stats-player-duration function) +;; (define-extern stats-player-vehicle function) +;; (define-extern stats-player-cash function) +;; (define-extern get-medal-reward-ignore-medal function) +;; (define-extern get-medal-reward function) +;; (define-extern update-high-scores function) +;; (define-extern *last-medal* object) +;; (define-extern report-score function) +;; (define-extern task-node-dump function) ;; (function symbol symbol) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; scene ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -37911,6 +42476,12 @@ ;; (define-extern muis-news-callback function) ;; (define-extern muis-info-callback function) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; net-mgr-medius-cache ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; (define-extern medius-cache-tick function) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; net-mgr-medius-players ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -39100,6 +43671,59 @@ ) |# +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; water-anim ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +#| +(deftype water-anim (process-drawable) + ((water-height meters :offset-assert 248) + (wade-height meters :offset-assert 252) + (swim-height meters :offset-assert 256) + (bottom-height meters :offset-assert 260) + (attack-event symbol :offset-assert 264) ;; guessed by decompiler + (attack-id uint32 :offset-assert 268) + (flow flow-control :offset-assert 272) ;; guessed by decompiler + (target uint64 :offset-assert 280) ;; handle + (flags water-flag :offset-assert 288) ;; guessed by decompiler + (look int32 :offset-assert 292) ;; wanim-look + (play-ambient-sound? symbol :offset-assert 296) ;; guessed by decompiler + (visible symbol :offset-assert 300) ;; guessed by decompiler + ) + :method-count-assert 59 + :size-assert #x130 + :flag-assert #x3b00a00130 + (:methods + (water-anim-method-50 () none) ;; 50 + (water-anim-method-52 () none) ;; 52 + (water-anim-method-53 () none) ;; 53 + (water-anim-method-54 () none) ;; 54 + (water-anim-method-55 () none) ;; 55 + (water-anim-method-56 () none) ;; 56 + (water-anim-method-57 () none) ;; 57 + (water-anim-method-58 () none) ;; 58 + ) + (:state-methods + idle ;; 51 + ) + ) +|# + +#| +(deftype water-anim-look (structure) + ((skel-group string :offset-assert 0) ;; guessed by decompiler + (anim int32 :offset-assert 4) + (ambient-sound-spec sound-spec :offset-assert 8) + ) + :method-count-assert 9 + :size-assert #xc + :flag-assert #x90000000c + ) +|# + +;; (define-extern *water-anim-look* array) ;; (array water-anim-look) +;; (define-extern water-anim-event-handler function) ;; (function process int symbol event-message-block object :behavior water-anim) +;; (define-extern water-anim-init-by-other function) ;; (function entity-actor object :behavior water-anim) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; rigid-body-debug ;; @@ -39439,7 +44063,7 @@ (target vector :inline :offset-assert 12) (twist vector :inline :offset-assert 28) (twist-max vector :inline :offset-assert 44) - (extra-twist deg :offset-assert 36) + (extra-twist degrees :offset-assert 36) (track-mode track-mode :offset-assert 40) (look-at-count uint16 :offset-assert 42) (twist-range-x meters :offset-assert 52) @@ -39457,7 +44081,7 @@ (blend float :offset-assert 136) (old-blend float :offset-assert 140) (max-dist meters :offset-assert 144) - (ignore-angle deg :offset-assert 148) + (ignore-angle degrees :offset-assert 148) (up uint8 :offset-assert 152) (nose uint8 :offset-assert 153) (ear uint8 :offset-assert 154) @@ -40050,7 +44674,7 @@ #| (deftype cam-point-watch-bank (basic) ((speed float :offset-assert 4) - (rot-speed deg :offset-assert 8) ;; degrees + (rot-speed degrees :offset-assert 8) ;; degrees ) :method-count-assert 9 :size-assert #xc @@ -40061,7 +44685,7 @@ #| (deftype cam-free-bank (basic) ((speed float :offset-assert 4) - (rot-speed deg :offset-assert 8) ;; degrees + (rot-speed degrees :offset-assert 8) ;; degrees ) :method-count-assert 9 :size-assert #xc @@ -40223,67 +44847,27 @@ ;; vehicle-manager ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype vehicle-manager (process) - ((name string :offset-assert 0) ;; guessed by decompiler - (mask process-mask :offset-assert 4) - (clock clock :offset-assert 8) ;; guessed by decompiler - (view basic :offset-assert 12) - (parent (pointer process-tree) :offset-assert 16) ;; guessed by decompiler - (brother (pointer process-tree) :offset-assert 20) ;; guessed by decompiler - (child (pointer process-tree) :offset-assert 24) ;; guessed by decompiler - (ppointer (pointer process) :offset-assert 28) ;; guessed by decompiler - (self process :offset-assert 32) ;; guessed by decompiler - (profile-ticks uint32 :offset-assert 36) - (pool dead-pool :offset-assert 40) ;; guessed by decompiler - (status symbol :offset-assert 44) ;; guessed by decompiler - (pid int32 :offset-assert 48) - (main-thread cpu-thread :offset-assert 52) ;; guessed by decompiler - (top-thread cpu-thread :offset-assert 56) ;; guessed by decompiler - (entity entity-actor :offset-assert 60) ;; guessed by decompiler - (level level :offset-assert 64) ;; guessed by decompiler - (state state :offset-assert 68) ;; guessed by decompiler - (prev-state state :offset-assert 72) ;; guessed by decompiler - (next-state state :offset-assert 76) ;; guessed by decompiler - (state-stack (array state) :offset-assert 80) ;; guessed by decompiler - (trans-hook function :offset-assert 84) ;; guessed by decompiler - (post-hook function :offset-assert 88) ;; guessed by decompiler - (event-hook (function process int symbol event-message-block object) :offset-assert 92) ;; guessed by decompiler - (allocated-length int32 :offset-assert 96) - (heap-base pointer :offset-assert 108) ;; guessed by decompiler - (heap-top pointer :offset-assert 112) ;; guessed by decompiler - (heap-cur pointer :offset-assert 116) ;; guessed by decompiler - (stack-frame-top stack-frame :offset-assert 120) ;; guessed by decompiler - (heap kheap :inline :offset-assert 108) - (connection-list connectable :inline :offset-assert 124) - (stack uint8 :dynamic :offset-assert 140) ;; guessed by decompiler - ) + () :method-count-assert 19 :size-assert #x90 :flag-assert #x1300000090 - (:methods - (vehicle-manager-method-9 () none) ;; 9 - (vehicle-manager-method-10 () none) ;; 10 - (vehicle-manager-method-11 () none) ;; 11 - (vehicle-manager-method-12 () none) ;; 12 - (vehicle-manager-method-13 () none) ;; 13 - (vehicle-manager-method-14 () none) ;; 14 ;; (idle () _type_ :state) - (vehicle-manager-method-17 () none) ;; 17 ;; (vehicle-manager-method-17 (_type_) none) - (vehicle-manager-method-18 () none) ;; 18 - ) (:state-methods - idle ;; 15, old: (active () _type_ :state) - active ;; 16, old: (vehicle-manager-method-16 (_type_) none) + idle ;; 14 + active ;; 15 + ) + (:methods + (vehicle-manager-method-16 (_type_) none) ;; 16 + (vehicle-manager-method-17 (_type_) none) ;; 17 ) ) -|# ;; (define-extern vehicle-manager-event-handler function) ;; (function process int symbol event-message-block object :behavior vehicle-manager) ;; (define-extern vehicle-manager-init-by-other function) ;; (function object :behavior vehicle-manager) ;; (define-extern vehicle-manager-start function) ;; (function process none) ;; (define-extern vehicle-manager-kill function) ;; (function none) -;; (define-extern *car-appearance-hack* object) -;; (define-extern *car-info-default* object) +(define-extern *car-appearance-hack* int) +(define-extern *car-info-default* (pointer uint32)) ;; (define-extern vehicle-init-by-other function) ;; (function int traffic-object-spawn-params object :behavior vehicle) ;; (define-extern vehicle-idx-from-level-name function) ;; (define-extern vehicle-in-level? function) @@ -41068,6 +45652,17 @@ ;; (define-extern *editable-work* object) ;; editable-work ;; (define-extern *editable* object) ;; (pointer editable-player) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; editable ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; (define-extern common-owner function) ;; (function editable editable object) +;; (define-extern update-light-sphere-from-editable-light function) ;; (function editable-light object) +;; (define-extern load-editable-lights function) ;; (function editable-array symbol) +;; (define-extern *editable-sample-region* object) ;; editable-region +;; (define-extern *editable-light-region* object) ;; editable-region +;; (define-extern *editable-entity-region* object) ;; editable-region + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; editable-player ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -42574,21 +47169,18 @@ ;; net-enemy-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype net-enemy-transition (structure) ((timestamp int32 :offset-assert 0) (name basic :offset-assert 4) (preempt basic :offset-assert 8) (data-len int32 :offset-assert 12) - (buf-data UNKNOWN 64 :offset-assert 16) + (buf-data uint8 64 :offset-assert 16) ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype net-enemy-anim-info (structure) ((name basic :offset-assert 0) (anim-idx int32 :offset-assert 4) @@ -42598,9 +47190,7 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype net-enemy-info (structure) ((flags uint64 :offset-assert 0) (inverse-mass float :offset-assert 8) @@ -42626,70 +47216,67 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| -(deftype net-enemy (process-focusable) - ((flags uint64 :offset-assert 256) - (info net-enemy-info :offset-assert 264) - (ragdoll-proc uint64 :offset-assert 272) - (health float :offset-assert 280) - (local-damage float :offset-assert 284) - (killed-by int8 :offset-assert 288) - (last-health-send-time int32 :offset-assert 292) - (net-anim net-anim-control :inline :offset-assert 304) - (minimap connection-minimap :offset-assert 444) - (transitions UNKNOWN 3 :offset-assert 448) - (transition-ct int32 :offset-assert 688) - (last-attack-time int32 :offset-assert 692) - (vehicle-penetrate-time int32 :offset-assert 696) - (paths basic :offset-assert 700) - (pending-impulse-valid basic :offset-assert 704) - (pending-impulse rigid-body-impact :inline :offset-assert 720) - (last-transition-time int32 :offset-assert 788) - (last-attack-id int32 :offset-assert 792) - (vel-for-ragdoll vector :inline :offset-assert 800) - (nav-poly nav-poly :offset-assert 816) - (snap-flags uint64 :offset-assert 824) - (prev-pos vector :inline :offset-assert 832) - (forward-path-vector vector :inline :offset-assert 848) - (enemy-link list-link :inline :offset-assert 864) - ) - :method-count-assert 87 - :size-assert #x368 - :flag-assert #x5702e00368 - (:methods - (net-enemy-method-59 () none) ;; 59 - (net-enemy-method-60 () none) ;; 60 - (net-enemy-method-61 () none) ;; 61 - (net-enemy-method-62 () none) ;; 62 - (net-enemy-method-63 () none) ;; 63 - (net-enemy-method-64 () none) ;; 64 - (net-enemy-method-65 () none) ;; 65 - (net-enemy-method-66 () none) ;; 66 - (net-enemy-method-67 () none) ;; 67 - (net-enemy-method-68 () none) ;; 68 - (net-enemy-method-69 () none) ;; 69 - (net-enemy-method-70 () none) ;; 70 - (net-enemy-method-71 () none) ;; 71 - (net-enemy-method-72 () none) ;; 72 - (net-enemy-method-73 () none) ;; 73 - (net-enemy-method-74 () none) ;; 74 - (net-enemy-method-75 () none) ;; 75 - (net-enemy-method-76 () none) ;; 76 - (net-enemy-method-77 () none) ;; 77 - (net-enemy-method-78 () none) ;; 78 - (net-enemy-method-79 () none) ;; 79 - (net-enemy-method-80 () none) ;; 80 - (net-enemy-method-81 () none) ;; 81 - (net-enemy-method-82 () none) ;; 82 - (net-enemy-method-83 () none) ;; 83 - (net-enemy-method-84 () none) ;; 84 - (net-enemy-method-85 () none) ;; 85 - (net-enemy-method-86 () none) ;; 86 - ) - ) -|# +;; (deftype net-enemy (process-focusable) +;; ((flags uint64 :offset-assert 256) +;; (info net-enemy-info :offset-assert 264) +;; (ragdoll-proc uint64 :offset-assert 272) +;; (health float :offset-assert 280) +;; (local-damage float :offset-assert 284) +;; (killed-by int8 :offset-assert 288) +;; (last-health-send-time int32 :offset-assert 292) +;; (net-anim net-anim-control :inline :offset-assert 304) +;; (minimap connection-minimap :offset-assert 444) +;; (transitions net-enemy-transition 3 :inline :offset-assert 448) +;; (transition-ct int32 :offset-assert 688) +;; (last-attack-time int32 :offset-assert 692) +;; (vehicle-penetrate-time int32 :offset-assert 696) +;; (paths basic :offset-assert 700) +;; (pending-impulse-valid basic :offset-assert 704) +;; (pending-impulse rigid-body-impact :inline :offset-assert 720) +;; (last-transition-time int32 :offset-assert 788) +;; (last-attack-id int32 :offset-assert 792) +;; (vel-for-ragdoll vector :inline :offset-assert 800) +;; (nav-poly nav-poly :offset-assert 816) +;; (snap-flags uint64 :offset-assert 824) +;; (prev-pos vector :inline :offset-assert 832) +;; (forward-path-vector vector :inline :offset-assert 848) +;; (enemy-link list-link :inline :offset-assert 864) +;; ) +;; :method-count-assert 87 +;; :size-assert #x368 +;; :flag-assert #x5702e00368 +;; (:methods +;; (net-enemy-method-59 () none) ;; 59 +;; (net-enemy-method-60 () none) ;; 60 +;; (net-enemy-method-61 () none) ;; 61 +;; (net-enemy-method-62 () none) ;; 62 +;; (net-enemy-method-63 () none) ;; 63 +;; (net-enemy-method-64 () none) ;; 64 +;; (net-enemy-method-65 () none) ;; 65 +;; (net-enemy-method-66 () none) ;; 66 +;; (net-enemy-method-67 () none) ;; 67 +;; (net-enemy-method-68 () none) ;; 68 +;; (net-enemy-method-69 () none) ;; 69 +;; (net-enemy-method-70 () none) ;; 70 +;; (net-enemy-method-71 () none) ;; 71 +;; (net-enemy-method-72 () none) ;; 72 +;; (net-enemy-method-73 () none) ;; 73 +;; (net-enemy-method-74 () none) ;; 74 +;; (net-enemy-method-75 () none) ;; 75 +;; (net-enemy-method-76 () none) ;; 76 +;; (net-enemy-method-77 () none) ;; 77 +;; (net-enemy-method-78 () none) ;; 78 +;; (net-enemy-method-79 () none) ;; 79 +;; (net-enemy-method-80 () none) ;; 80 +;; (net-enemy-method-81 () none) ;; 81 +;; (net-enemy-method-82 () none) ;; 82 +;; (net-enemy-method-83 () none) ;; 83 +;; (net-enemy-method-84 () none) ;; 84 +;; (net-enemy-method-85 () none) ;; 85 +;; (net-enemy-method-86 () none) ;; 86 +;; ) +;; ) ;; (define-extern *tmp-construct-transition* object) ;; (define-extern net-enemy-init-remote function) @@ -47536,6 +52123,24 @@ ;; race-mesh ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; race-line ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +#| +(deftype race-line-get-points (structure) + ((points UNKNOWN 4 :offset-assert 0) + (index int32 :offset-assert 64) + ) + :method-count-assert 9 + :size-assert #x44 + :flag-assert #x900000044 + ) +|# + +;; (define-extern test-find-line-info function) +;; (define-extern test-find-closest-point function) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; race-ai-tuning ;; diff --git a/decompiler/config/jakx/jakx_config.jsonc b/decompiler/config/jakx/jakx_config.jsonc index 160bfe5c35..449a771141 100644 --- a/decompiler/config/jakx/jakx_config.jsonc +++ b/decompiler/config/jakx/jakx_config.jsonc @@ -9,25 +9,7 @@ // it will make the decompiler much faster. "allowed_objects": [], - // TODO - these objects currently cause various errors in the decompiler that need to be fixed - // thankfully no header files so hopefully the impact on all-types is minimal - "banned_objects": [ - "dma", - "race-line", - "merc-blend-shape", - "foreground", - "generic-effect", - "shadow-cpu", - "collide-mesh", - "collide-shape", - "collide-cache", - "entity", - "task-control", - "net-mgr-medius-cache", - "water-anim", - "editable", - "gstring" - ], + "banned_objects": [], //////////////////////////// // CODE ANALYSIS OPTIONS @@ -64,17 +46,15 @@ // write goal imports for the part group table "process_part_group_table": false, // write out a json file containing the art info mapping, run this with all objects allowed - // TODO - rerun this once all objects can be allowed "dump_art_group_info": false, // write out a json file containing the joint node mapping, run this with all objects allowed - // TODO - rerun this once all objects can be allowed - "dump_joint_geo_info": false, + // TODO - not done yet + "dump_joint_geo_info": true, // write out a json file containing tpage and texture mappings, run with all objects allowed - // TODO - rerun this once all objects can be allowed "dump_tex_info": false, // write out a json file containing the part group table, run with all objects allowed - // TODO - re-run this once particle code has been decomped and once all objects can be allowed - "dump_part_group_table": false, + // TODO - not done yet + "dump_part_group_table": true, // set to false to skip adding .STR files to the decompiler database "read_spools": false, diff --git a/decompiler/config/jakx/ntsc_v1/anonymous_function_types.jsonc b/decompiler/config/jakx/ntsc_v1/anonymous_function_types.jsonc index 2c63c08510..f1470fe92d 100644 --- a/decompiler/config/jakx/ntsc_v1/anonymous_function_types.jsonc +++ b/decompiler/config/jakx/ntsc_v1/anonymous_function_types.jsonc @@ -1,2 +1,3 @@ { + "profile": [[3, "(function profile-segment-array profile-collapse none)"]] } diff --git a/decompiler/config/jakx/ntsc_v1/art_info.jsonc b/decompiler/config/jakx/ntsc_v1/art_info.jsonc index bdff3fea61..f649e0ae03 100644 --- a/decompiler/config/jakx/ntsc_v1/art_info.jsonc +++ b/decompiler/config/jakx/ntsc_v1/art_info.jsonc @@ -8,15 +8,12 @@ // so you only need to specify it when that's not the case. // remap names for states and behaviors of these types - "type_remap": { - }, + "type_remap": {}, // remap names for types in an entire file (higher priority) - "file_override": { - }, + "file_override": {}, // some art groups (like robotboss-ag) have a name for their model that differs // from the usual ag-name + "-lod0". you can add those exceptions here. - "joint_node_hacks": { - } + "joint_node_hacks": {} } diff --git a/decompiler/config/jakx/ntsc_v1/hacks.jsonc b/decompiler/config/jakx/ntsc_v1/hacks.jsonc index 83bfbcf8ee..675d6a8fcf 100644 --- a/decompiler/config/jakx/ntsc_v1/hacks.jsonc +++ b/decompiler/config/jakx/ntsc_v1/hacks.jsonc @@ -2,63 +2,131 @@ //////////////////////////// // HACKS and ASM FUNCTIONS //////////////////////////// - - "types_with_bad_inspect_methods": [ - ], - + "types_with_bad_inspect_methods": ["game-task-event", "game-task-control"], "no_type_analysis_functions_by_name": [], - // this limits the number of cases in a cond. The first argument is the name of the function. // the second argument is the name of the first condition in the cond. Use print_cfg to find it out. // The third argument is the number of cases. If you set it too small it may fail to build the CFG. - "cond_with_else_max_lengths": [ - ], - + "cond_with_else_max_lengths": [], // if a cond with an else case is being used a value in a place where it looks wrong // you can add the function name to this list and it will more aggressively reject this rewrite. - "aggressively_reject_cond_to_value_rewrite": [ - ], - + "aggressively_reject_cond_to_value_rewrite": [], // this provides a hint to the decompiler that these functions will have a lot of inline assembly. // currently it just leaves pcpyld as an asm op. "hint_inline_assembly_functions": [], - "asm_functions_by_name": [ + // checking boxed type is different now - these make the cfg stuff sad + "name=", + // disabled to get decomp to work + "water-anim-event-handler", + "(anon-function 55 task-control)", + "(method 22 level)", + "(method 11 medius-cache)", + "(method 13 race-line)", + "(method 11 collide-mesh)", + // dma + "symlink2", + // actual asm + "quad-copy!", + "sin-rad", + "cos-rad", + "atan-series-rad", + "sign-float", + "(method 9 matrix)", + "quaternion->matrix-2", + "vector-rotate-y-fast!", + "(method 11 collide-mesh-cache)", + "generic-light-proc", + "dma-count-until-done" ], - // these functions use pairs and the decompiler // will be less picky about types related to pairs. "pair_functions_by_name": [ + "ref", + "ref&", + "(method 4 pair)", + "last", + "member", + "nmember", + "assoc", + "assoce", + "nassoc", + "nassoce", + "append!", + "delete!", + "delete-car!", + "insert-cons!", + "sort" ], - // If format is used with the wrong number of arguments, // it will often mess up the decompilation, as the decompiler assumes // that they used the correct number. This will override the decompiler's // automatic detection. "bad_format_strings": { + "~170h~5d~220h~5d~280h~5,,2f": 3, + "~338h~5d~388h~5d~448h~5,,2f": 3 }, - "blocks_ending_in_asm_branch": { + "sqlpipe-query": [21], + "(method 9 editable-region)": [63], + "find-nearest-entity": [7, 9], + // collide-shape + "(method 42 collide-shape)": [0, 1, 2, 3, 4, 7], + "(method 18 collide-shape-prim-mesh)": [2, 3, 4, 5, 6, 7], + "(method 12 collide-shape-prim-sphere)": [ + 1, 2, 3, 4, 5, 8, 10, 11, 13, 14, 15 + ], + "(method 12 collide-shape-prim-mesh)": [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16 + ], + // collide-mesh + "(method 11 collide-mesh)": [2, 4], + "(method 12 collide-mesh-cache)": [0, 1, 2, 3, 4, 5], + "(method 10 collide-mesh)": [2] }, - // Sometimes the game might use format strings that are fetched dynamically, // for example using the game text lookup method // Add information about those format instructions here. // e.g. "function-name":[[op, argc], [op, argc], ...] // where "op" is the op number for the call to format. - "dynamic_format_arg_counts": { - }, - + "dynamic_format_arg_counts": {}, "mips2c_functions_by_name": [ + // collide-cache + "(method 9 collide-cache-prim)", + "(method 10 collide-cache-prim)", + "(method 17 collide-cache)", + // collide-mesh + "(method 12 collide-mesh)", + "(method 14 collide-mesh)", + "(method 15 collide-mesh)", + // shadow + "shadow-execute", + "shadow-add-double-edges", + "shadow-add-single-edges", + "shadow-add-facing-single-tris", + "shadow-add-double-tris", + "shadow-xform-verts", + "shadow-calc-dual-verts", + "shadow-scissor-edges", + "shadow-scissor-top", + "shadow-init-vars", + "shadow-find-facing-single-tris", + "shadow-find-single-edges", + "shadow-find-facing-double-tris", + "shadow-find-double-edges", + "shadow-add-verts", + "shadow-add-single-tris", + // foreground + "foreground-check-longest-edge-asm", + "foreground-merc", + // merc-blend-shape + "blerc-a-fragment", + "blerc-execute" ], - "mips2c_jump_table_functions": {}, - // there are some missing textures. I don't know what the game actually does here. // the format for entries is [level, tpage, index] - "missing_textures": [ - ], - + "missing_textures": [], // some object files have garbage pad data at the end which makes the decompiler // assume they must be different files, such as the art group for orb-cache-top. // this just suppresses a message. diff --git a/decompiler/config/jakx/ntsc_v1/inputs.jsonc b/decompiler/config/jakx/ntsc_v1/inputs.jsonc index 8998f1fb65..6d532bd776 100644 --- a/decompiler/config/jakx/ntsc_v1/inputs.jsonc +++ b/decompiler/config/jakx/ntsc_v1/inputs.jsonc @@ -13,373 +13,373 @@ // "CGO/COMMON.CGO", // "CGO/ENGINE.CGO", "CGO/KERNEL.CGO", - "CGO/GAME.CGO" - // "DGO/ASHCRED.DGO", - // "DGO/ASHLEV.DGO", - // "DGO/ASHVL.DGO", - // "DGO/ASHVL2.DGO", - // "DGO/ASHVL3.DGO", - // "DGO/ATL.DGO", - // "DGO/ATOLLART.DGO", - // "DGO/ATOLLCTF.DGO", - // "DGO/ATOLLS.DGO", - // "DGO/ATOPLOW.DGO", - // "DGO/ATX.DGO", - // "DGO/BEARL.DGO", - // "DGO/BOBCL.DGO", - // "DGO/BRDROOM.DGO", - // "DGO/BRDROOMF.DGO", - // "DGO/CANFOOT.DGO", - // "DGO/CANSPARS.DGO", - // "DGO/CANSPARW.DGO", - // "DGO/CANTBOX.DGO", - // "DGO/CANYONS.DGO", - // "DGO/CANYONTT.DGO", - // "DGO/CANYONW.DGO", - // "DGO/CARS.DGO", - // "DGO/CHEEL.DGO", - // "DGO/CLF.DGO", - // "DGO/CLFX.DGO", - // "DGO/CLIFCTF.DGO", - // "DGO/CLIFFART.DGO", - // "DGO/CLIFFSS.DGO", - // "DGO/CLIFHUNT.DGO", - // "DGO/CLIFTRN.DGO", - // "DGO/CNSPFOOT.DGO", - // "DGO/CNSPTBOX.DGO", - // "DGO/CNSPTT.DGO", - // "DGO/COL.DGO", - // "DGO/COLART.DGO", - // "DGO/COLICLCT.DGO", - // "DGO/COLICTF.DGO", - // "DGO/COLIREV.DGO", - // "DGO/COLISEUS.DGO", - // "DGO/COLX.DGO", - // "DGO/COUGL.DGO", - // "DGO/CREDITS.DGO", - // "DGO/CSX.DGO", - // "DGO/CSY.DGO", - // "DGO/CYA.DGO", - // "DGO/CYB.DGO", - // "DGO/CYC.DGO", - // "DGO/CYD.DGO", - // "DGO/CYE.DGO", - // "DGO/CYX.DGO", - // "DGO/CYY.DGO", - // "DGO/DAXCRED.DGO", - // "DGO/DAXLEV.DGO", - // "DGO/DAXTL.DGO", - // "DGO/DESACTF.DGO", - // "DGO/DESARENS.DGO", - // "DGO/DESART.DGO", - // "DGO/DESCLCT.DGO", - // "DGO/DESHUNT.DGO", - // "DGO/DESHUNT2.DGO", - // "DGO/DESISLES.DGO", - // "DGO/DESRAPT.DGO", - // "DGO/DESREV.DGO", - // "DGO/DETHRACE.DGO", - // "DGO/DISLEART.DGO", - // "DGO/DISLECTF.DGO", - // "DGO/DKA.DGO", - // "DGO/DKB.DGO", - // "DGO/DKC.DGO", - // "DGO/DKD.DGO", - // "DGO/DKE.DGO", - // "DGO/DKKRFOOT.DGO", - // "DGO/DKKRTBOX.DGO", - // "DGO/DKKRTT.DGO", - // "DGO/DKKX.DGO", - // "DGO/DKKY.DGO", - // "DGO/DKX.DGO", - // "DGO/DOCKFOOT.DGO", - // "DGO/DOCKKRAS.DGO", - // "DGO/DOCKKRAW.DGO", - // "DGO/DOCKSS.DGO", - // "DGO/DOCKSTT.DGO", - // "DGO/DOCKSW.DGO", - // "DGO/DOCKTBOX.DGO", - // "DGO/DRA.DGO", - // "DGO/DRB.DGO", - // "DGO/DRC.DGO", - // "DGO/DRD.DGO", - // "DGO/DRDKFOOT.DGO", - // "DGO/DRDKTBOX.DGO", - // "DGO/DRDKTT.DGO", - // "DGO/DRDX.DGO", - // "DGO/DRDY.DGO", - // "DGO/DROMDOCS.DGO", - // "DGO/DROMDOCW.DGO", - // "DGO/DROMES.DGO", - // "DGO/DROMETT.DGO", - // "DGO/DROMEW.DGO", - // "DGO/DROMEX.DGO", - // "DGO/DROMFOOT.DGO", - // "DGO/DROMTBOX.DGO", - // "DGO/DRONE.DGO", - // "DGO/DRX.DGO", - // "DGO/DRY.DGO", - // "DGO/DSI.DGO", - // "DGO/DSR.DGO", - // "DGO/DSRX.DGO", - // "DGO/DSX.DGO", - // "DGO/EIGHT.DGO", - // "DGO/EIGHTB.DGO", - // "DGO/FALCL.DGO", - // "DGO/FMVLEV.DGO", - // "DGO/FOXL.DGO", - // "DGO/GARAGE.DGO", - // "DGO/GARAGEB.DGO", - // "DGO/GILAL.DGO", - // "DGO/GTBCRED.DGO", - // "DGO/GTBLEV.DGO", - // "DGO/GTBVL.DGO", - // "DGO/HAVENS.DGO", - // "DGO/HAVENW.DGO", - // "DGO/HAVJUNGS.DGO", - // "DGO/HAVJUNGW.DGO", - // "DGO/HAVNFOOT.DGO", - // "DGO/HAVNTBOX.DGO", - // "DGO/HAVSEWS.DGO", - // "DGO/HAVSEWW.DGO", - // "DGO/HAVTFOOT.DGO", - // "DGO/HAVTOURS.DGO", - // "DGO/HAVTOURW.DGO", - // "DGO/HAVTT.DGO", - // "DGO/HAVTTBOX.DGO", - // "DGO/HJNGFOOT.DGO", - // "DGO/HJX.DGO", - // "DGO/HJY.DGO", - // "DGO/HSX.DGO", - // "DGO/HSY.DGO", - // "DGO/HVA.DGO", - // "DGO/HVB.DGO", - // "DGO/HVC.DGO", - // "DGO/HVD.DGO", - // "DGO/HVE.DGO", - // "DGO/HVJGTBOX.DGO", - // "DGO/HVJGTT.DGO", - // "DGO/HVSWFOOT.DGO", - // "DGO/HVSWTBOX.DGO", - // "DGO/HVSWTT.DGO", - // "DGO/HVTRTT.DGO", - // "DGO/HVX.DGO", - // "DGO/HVY.DGO", - // "DGO/IBX.DGO", - // "DGO/IBY.DGO", - // "DGO/ICA.DGO", - // "DGO/ICB.DGO", - // "DGO/ICBGTT.DGO", - // "DGO/ICC.DGO", - // "DGO/ICD.DGO", - // "DGO/ICEBERGS.DGO", - // "DGO/ICEBERGW.DGO", - // "DGO/ICEBFOOT.DGO", - // "DGO/ICEBTBOX.DGO", - // "DGO/ICEFOOT.DGO", - // "DGO/ICEPASSS.DGO", - // "DGO/ICEPASSW.DGO", - // "DGO/ICEPFOOT.DGO", - // "DGO/ICEPTBOX.DGO", - // "DGO/ICES.DGO", - // "DGO/ICETBOX.DGO", - // "DGO/ICETFOOT.DGO", - // "DGO/ICETOURS.DGO", - // "DGO/ICETOURW.DGO", - // "DGO/ICETRN.DGO", - // "DGO/ICETT.DGO", - // "DGO/ICETTBOX.DGO", - // "DGO/ICEW.DGO", - // "DGO/ICPSTT.DGO", - // "DGO/ICTRTT.DGO", - // "DGO/ICX.DGO", - // "DGO/ICY.DGO", - // "DGO/IPX.DGO", - // "DGO/IPY.DGO", - // "DGO/JAKCRED.DGO", - // "DGO/JAKLEV.DGO", - // "DGO/JAKVL.DGO", - // "DGO/JGA.DGO", - // "DGO/JGB.DGO", - // "DGO/JGC.DGO", - // "DGO/JGD.DGO", - // "DGO/JGE.DGO", - // "DGO/JGF.DGO", - // "DGO/JGG.DGO", - // "DGO/JGX.DGO", - // "DGO/JGY.DGO", - // "DGO/JKALEV.DGO", - // "DGO/JKBLEV.DGO", - // "DGO/JKCLEV.DGO", - // "DGO/JUNGFOOT.DGO", - // "DGO/JUNGLES.DGO", - // "DGO/JUNGLETT.DGO", - // "DGO/JUNGLEW.DGO", - // "DGO/JUNGTBOX.DGO", - // "DGO/JUNGTRN.DGO", - // "DGO/KAELEV.DGO", - // "DGO/KCR.DGO", - // "DGO/KCROSART.DGO", - // "DGO/KCROSCTF.DGO", - // "DGO/KCROSSS.DGO", - // "DGO/KCRSCLCT.DGO", - // "DGO/KCRSPLOW.DGO", - // "DGO/KCRX.DGO", - // "DGO/KEICRED.DGO", - // "DGO/KIELEV.DGO", - // "DGO/KIEVL.DGO", - // "DGO/KLECRED.DGO", - // "DGO/KLELEV.DGO", - // "DGO/KLEVL.DGO", - // "DGO/KLEVL2.DGO", - // "DGO/KRA.DGO", - // "DGO/KRASFOOT.DGO", - // "DGO/KRASS.DGO", - // "DGO/KRASTBOX.DGO", - // "DGO/KRASTRN.DGO", - // "DGO/KRASTT.DGO", - // "DGO/KRASW.DGO", - // "DGO/KRATFOOT.DGO", - // "DGO/KRATOURS.DGO", - // "DGO/KRATOURW.DGO", - // "DGO/KRATTBOX.DGO", - // "DGO/KRB.DGO", - // "DGO/KRC.DGO", - // "DGO/KRTRTT.DGO", - // "DGO/KRX.DGO", - // "DGO/KRY.DGO", - // "DGO/LEOPL.DGO", - // "DGO/MENU2.DGO", - // "DGO/MENUMAP.DGO", - // "DGO/MONGL.DGO", - // "DGO/OSMLEV.DGO", - // "DGO/PANTL.DGO", - // "DGO/PEAKFOOT.DGO", - // "DGO/PEAKS.DGO", - // "DGO/PEAKTBOX.DGO", - // "DGO/PEAKTT.DGO", - // "DGO/PEAKW.DGO", - // "DGO/PECCRED.DGO", - // "DGO/PECLEV.DGO", - // "DGO/PECVL.DGO", - // "DGO/PKA.DGO", - // "DGO/PKB.DGO", - // "DGO/PKC.DGO", - // "DGO/PKD.DGO", - // "DGO/PKE.DGO", - // "DGO/PKX.DGO", - // "DGO/POSSL.DGO", - // "DGO/RACEWEAP.DGO", - // "DGO/RATLEV.DGO", - // "DGO/RAYCRED.DGO", - // "DGO/RAYLEV.DGO", - // "DGO/RAYVL.DGO", - // "DGO/RAYVL2.DGO", - // "DGO/RAZCRED.DGO", - // "DGO/RAZLEV.DGO", - // "DGO/RAZVL.DGO", - // "DGO/RTH.DGO", - // "DGO/RUSTYH.DGO", - // "DGO/S2A.DGO", - // "DGO/S3A.DGO", - // "DGO/SBWLCTF.DGO", - // "DGO/SEWERS.DGO", - // "DGO/SEWERTT.DGO", - // "DGO/SEWERW.DGO", - // "DGO/SEWFOOT.DGO", - // "DGO/SEWTBOX.DGO", - // "DGO/SIGCRED.DGO", - // "DGO/SIGLEV.DGO", - // "DGO/SIGVL.DGO", - // "DGO/SIGVL2.DGO", - // "DGO/SIGVL3.DGO", - // "DGO/SNAKL.DGO", - // "DGO/SNO.DGO", - // "DGO/SNOBART.DGO", - // "DGO/SNOBOWLS.DGO", - // "DGO/SNOWFOOT.DGO", - // "DGO/SNOWS.DGO", - // "DGO/SNOWTBOX.DGO", - // "DGO/SNOWTRN2.DGO", - // "DGO/SNOWTT.DGO", - // "DGO/SNOX.DGO", - // "DGO/SNW.DGO", - // "DGO/SNWX.DGO", - // "DGO/SPA.DGO", - // "DGO/SPARFOOT.DGO", - // "DGO/SPARGUSS.DGO", - // "DGO/SPARGUSW.DGO", - // "DGO/SPARTEMS.DGO", - // "DGO/SPARTEMW.DGO", - // "DGO/SPARTT.DGO", - // "DGO/SPATFOOT.DGO", - // "DGO/SPATOURS.DGO", - // "DGO/SPATOURW.DGO", - // "DGO/SPATTBOX.DGO", - // "DGO/SPB.DGO", - // "DGO/SPC.DGO", - // "DGO/SPD.DGO", - // "DGO/SPE.DGO", - // "DGO/SPRGSTBX.DGO", - // "DGO/SPTMFOOT.DGO", - // "DGO/SPTMTBOX.DGO", - // "DGO/SPTMTT.DGO", - // "DGO/SPTRTT.DGO", - // "DGO/SPX.DGO", - // "DGO/SPY.DGO", - // "DGO/STX.DGO", - // "DGO/STY.DGO", - // "DGO/SWA.DGO", - // "DGO/SWB.DGO", - // "DGO/SWC.DGO", - // "DGO/SWD.DGO", - // "DGO/SWE.DGO", - // "DGO/SWF.DGO", - // "DGO/SWX.DGO", - // "DGO/TARLEV.DGO", - // "DGO/TEMPFOOT.DGO", - // "DGO/TEMPLES.DGO", - // "DGO/TEMPLETT.DGO", - // "DGO/TEMPLEW.DGO", - // "DGO/TEMPTBOX.DGO", - // "DGO/THACRED.DGO", - // "DGO/THALEV.DGO", - // "DGO/THAVL.DGO", - // "DGO/THAVL2.DGO", - // "DGO/THAVL3.DGO", - // "DGO/THBCRED.DGO", - // "DGO/THBLEV.DGO", - // "DGO/THBVL.DGO", - // "DGO/THBVL2.DGO", - // "DGO/THBVL3.DGO", - // "DGO/THCCRED.DGO", - // "DGO/THCLEV.DGO", - // "DGO/THCVL.DGO", - // "DGO/THCVL2.DGO", - // "DGO/THCVL3.DGO", - // "DGO/TIGEL.DGO", - // "DGO/TOADL.DGO", - // "DGO/TORCRED.DGO", - // "DGO/TORLEV.DGO", - // "DGO/TORVL.DGO", - // "DGO/TORVL2.DGO", - // "DGO/TORVL3.DGO", - // "DGO/TPA.DGO", - // "DGO/TPB.DGO", - // "DGO/TPC.DGO", - // "DGO/TPD.DGO", - // "DGO/TPE.DGO", - // "DGO/TPX.DGO", - // "DGO/TPY.DGO", - // "DGO/TURTL.DGO", - // "DGO/UR8CRED.DGO", - // "DGO/UR8LEV.DGO", - // "DGO/UR8VL.DGO", - // "DGO/UR8VL2.DGO", - // "DGO/UR8VL3.DGO", - // "DGO/WOLFL.DGO", - // "DGO/WOMBL.DGO", - // "DGO/XIMLEV.DGO" + "CGO/GAME.CGO", + "DGO/ASHCRED.DGO", + "DGO/ASHLEV.DGO", + "DGO/ASHVL.DGO", + "DGO/ASHVL2.DGO", + "DGO/ASHVL3.DGO", + "DGO/ATL.DGO", + "DGO/ATOLLART.DGO", + "DGO/ATOLLCTF.DGO", + "DGO/ATOLLS.DGO", + "DGO/ATOPLOW.DGO", + "DGO/ATX.DGO", + "DGO/BEARL.DGO", + "DGO/BOBCL.DGO", + "DGO/BRDROOM.DGO", + "DGO/BRDROOMF.DGO", + "DGO/CANFOOT.DGO", + "DGO/CANSPARS.DGO", + "DGO/CANSPARW.DGO", + "DGO/CANTBOX.DGO", + "DGO/CANYONS.DGO", + "DGO/CANYONTT.DGO", + "DGO/CANYONW.DGO", + "DGO/CARS.DGO", + "DGO/CHEEL.DGO", + "DGO/CLF.DGO", + "DGO/CLFX.DGO", + "DGO/CLIFCTF.DGO", + "DGO/CLIFFART.DGO", + "DGO/CLIFFSS.DGO", + "DGO/CLIFHUNT.DGO", + "DGO/CLIFTRN.DGO", + "DGO/CNSPFOOT.DGO", + "DGO/CNSPTBOX.DGO", + "DGO/CNSPTT.DGO", + "DGO/COL.DGO", + "DGO/COLART.DGO", + "DGO/COLICLCT.DGO", + "DGO/COLICTF.DGO", + "DGO/COLIREV.DGO", + "DGO/COLISEUS.DGO", + "DGO/COLX.DGO", + "DGO/COUGL.DGO", + "DGO/CREDITS.DGO", + "DGO/CSX.DGO", + "DGO/CSY.DGO", + "DGO/CYA.DGO", + "DGO/CYB.DGO", + "DGO/CYC.DGO", + "DGO/CYD.DGO", + "DGO/CYE.DGO", + "DGO/CYX.DGO", + "DGO/CYY.DGO", + "DGO/DAXCRED.DGO", + "DGO/DAXLEV.DGO", + "DGO/DAXTL.DGO", + "DGO/DESACTF.DGO", + "DGO/DESARENS.DGO", + "DGO/DESART.DGO", + "DGO/DESCLCT.DGO", + "DGO/DESHUNT.DGO", + "DGO/DESHUNT2.DGO", + "DGO/DESISLES.DGO", + "DGO/DESRAPT.DGO", + "DGO/DESREV.DGO", + "DGO/DETHRACE.DGO", + "DGO/DISLEART.DGO", + "DGO/DISLECTF.DGO", + "DGO/DKA.DGO", + "DGO/DKB.DGO", + "DGO/DKC.DGO", + "DGO/DKD.DGO", + "DGO/DKE.DGO", + "DGO/DKKRFOOT.DGO", + "DGO/DKKRTBOX.DGO", + "DGO/DKKRTT.DGO", + "DGO/DKKX.DGO", + "DGO/DKKY.DGO", + "DGO/DKX.DGO", + "DGO/DOCKFOOT.DGO", + "DGO/DOCKKRAS.DGO", + "DGO/DOCKKRAW.DGO", + "DGO/DOCKSS.DGO", + "DGO/DOCKSTT.DGO", + "DGO/DOCKSW.DGO", + "DGO/DOCKTBOX.DGO", + "DGO/DRA.DGO", + "DGO/DRB.DGO", + "DGO/DRC.DGO", + "DGO/DRD.DGO", + "DGO/DRDKFOOT.DGO", + "DGO/DRDKTBOX.DGO", + "DGO/DRDKTT.DGO", + "DGO/DRDX.DGO", + "DGO/DRDY.DGO", + "DGO/DROMDOCS.DGO", + "DGO/DROMDOCW.DGO", + "DGO/DROMES.DGO", + "DGO/DROMETT.DGO", + "DGO/DROMEW.DGO", + "DGO/DROMEX.DGO", + "DGO/DROMFOOT.DGO", + "DGO/DROMTBOX.DGO", + "DGO/DRONE.DGO", + "DGO/DRX.DGO", + "DGO/DRY.DGO", + "DGO/DSI.DGO", + "DGO/DSR.DGO", + "DGO/DSRX.DGO", + "DGO/DSX.DGO", + "DGO/EIGHT.DGO", + "DGO/EIGHTB.DGO", + "DGO/FALCL.DGO", + "DGO/FMVLEV.DGO", + "DGO/FOXL.DGO", + "DGO/GARAGE.DGO", + "DGO/GARAGEB.DGO", + "DGO/GILAL.DGO", + "DGO/GTBCRED.DGO", + "DGO/GTBLEV.DGO", + "DGO/GTBVL.DGO", + "DGO/HAVENS.DGO", + "DGO/HAVENW.DGO", + "DGO/HAVJUNGS.DGO", + "DGO/HAVJUNGW.DGO", + "DGO/HAVNFOOT.DGO", + "DGO/HAVNTBOX.DGO", + "DGO/HAVSEWS.DGO", + "DGO/HAVSEWW.DGO", + "DGO/HAVTFOOT.DGO", + "DGO/HAVTOURS.DGO", + "DGO/HAVTOURW.DGO", + "DGO/HAVTT.DGO", + "DGO/HAVTTBOX.DGO", + "DGO/HJNGFOOT.DGO", + "DGO/HJX.DGO", + "DGO/HJY.DGO", + "DGO/HSX.DGO", + "DGO/HSY.DGO", + "DGO/HVA.DGO", + "DGO/HVB.DGO", + "DGO/HVC.DGO", + "DGO/HVD.DGO", + "DGO/HVE.DGO", + "DGO/HVJGTBOX.DGO", + "DGO/HVJGTT.DGO", + "DGO/HVSWFOOT.DGO", + "DGO/HVSWTBOX.DGO", + "DGO/HVSWTT.DGO", + "DGO/HVTRTT.DGO", + "DGO/HVX.DGO", + "DGO/HVY.DGO", + "DGO/IBX.DGO", + "DGO/IBY.DGO", + "DGO/ICA.DGO", + "DGO/ICB.DGO", + "DGO/ICBGTT.DGO", + "DGO/ICC.DGO", + "DGO/ICD.DGO", + "DGO/ICEBERGS.DGO", + "DGO/ICEBERGW.DGO", + "DGO/ICEBFOOT.DGO", + "DGO/ICEBTBOX.DGO", + "DGO/ICEFOOT.DGO", + "DGO/ICEPASSS.DGO", + "DGO/ICEPASSW.DGO", + "DGO/ICEPFOOT.DGO", + "DGO/ICEPTBOX.DGO", + "DGO/ICES.DGO", + "DGO/ICETBOX.DGO", + "DGO/ICETFOOT.DGO", + "DGO/ICETOURS.DGO", + "DGO/ICETOURW.DGO", + "DGO/ICETRN.DGO", + "DGO/ICETT.DGO", + "DGO/ICETTBOX.DGO", + "DGO/ICEW.DGO", + "DGO/ICPSTT.DGO", + "DGO/ICTRTT.DGO", + "DGO/ICX.DGO", + "DGO/ICY.DGO", + "DGO/IPX.DGO", + "DGO/IPY.DGO", + "DGO/JAKCRED.DGO", + "DGO/JAKLEV.DGO", + "DGO/JAKVL.DGO", + "DGO/JGA.DGO", + "DGO/JGB.DGO", + "DGO/JGC.DGO", + "DGO/JGD.DGO", + "DGO/JGE.DGO", + "DGO/JGF.DGO", + "DGO/JGG.DGO", + "DGO/JGX.DGO", + "DGO/JGY.DGO", + "DGO/JKALEV.DGO", + "DGO/JKBLEV.DGO", + "DGO/JKCLEV.DGO", + "DGO/JUNGFOOT.DGO", + "DGO/JUNGLES.DGO", + "DGO/JUNGLETT.DGO", + "DGO/JUNGLEW.DGO", + "DGO/JUNGTBOX.DGO", + "DGO/JUNGTRN.DGO", + "DGO/KAELEV.DGO", + "DGO/KCR.DGO", + "DGO/KCROSART.DGO", + "DGO/KCROSCTF.DGO", + "DGO/KCROSSS.DGO", + "DGO/KCRSCLCT.DGO", + "DGO/KCRSPLOW.DGO", + "DGO/KCRX.DGO", + "DGO/KEICRED.DGO", + "DGO/KIELEV.DGO", + "DGO/KIEVL.DGO", + "DGO/KLECRED.DGO", + "DGO/KLELEV.DGO", + "DGO/KLEVL.DGO", + "DGO/KLEVL2.DGO", + "DGO/KRA.DGO", + "DGO/KRASFOOT.DGO", + "DGO/KRASS.DGO", + "DGO/KRASTBOX.DGO", + "DGO/KRASTRN.DGO", + "DGO/KRASTT.DGO", + "DGO/KRASW.DGO", + "DGO/KRATFOOT.DGO", + "DGO/KRATOURS.DGO", + "DGO/KRATOURW.DGO", + "DGO/KRATTBOX.DGO", + "DGO/KRB.DGO", + "DGO/KRC.DGO", + "DGO/KRTRTT.DGO", + "DGO/KRX.DGO", + "DGO/KRY.DGO", + "DGO/LEOPL.DGO", + "DGO/MENU2.DGO", + "DGO/MENUMAP.DGO", + "DGO/MONGL.DGO", + "DGO/OSMLEV.DGO", + "DGO/PANTL.DGO", + "DGO/PEAKFOOT.DGO", + "DGO/PEAKS.DGO", + "DGO/PEAKTBOX.DGO", + "DGO/PEAKTT.DGO", + "DGO/PEAKW.DGO", + "DGO/PECCRED.DGO", + "DGO/PECLEV.DGO", + "DGO/PECVL.DGO", + "DGO/PKA.DGO", + "DGO/PKB.DGO", + "DGO/PKC.DGO", + "DGO/PKD.DGO", + "DGO/PKE.DGO", + "DGO/PKX.DGO", + "DGO/POSSL.DGO", + "DGO/RACEWEAP.DGO", + "DGO/RATLEV.DGO", + "DGO/RAYCRED.DGO", + "DGO/RAYLEV.DGO", + "DGO/RAYVL.DGO", + "DGO/RAYVL2.DGO", + "DGO/RAZCRED.DGO", + "DGO/RAZLEV.DGO", + "DGO/RAZVL.DGO", + "DGO/RTH.DGO", + "DGO/RUSTYH.DGO", + "DGO/S2A.DGO", + "DGO/S3A.DGO", + "DGO/SBWLCTF.DGO", + "DGO/SEWERS.DGO", + "DGO/SEWERTT.DGO", + "DGO/SEWERW.DGO", + "DGO/SEWFOOT.DGO", + "DGO/SEWTBOX.DGO", + "DGO/SIGCRED.DGO", + "DGO/SIGLEV.DGO", + "DGO/SIGVL.DGO", + "DGO/SIGVL2.DGO", + "DGO/SIGVL3.DGO", + "DGO/SNAKL.DGO", + "DGO/SNO.DGO", + "DGO/SNOBART.DGO", + "DGO/SNOBOWLS.DGO", + "DGO/SNOWFOOT.DGO", + "DGO/SNOWS.DGO", + "DGO/SNOWTBOX.DGO", + "DGO/SNOWTRN2.DGO", + "DGO/SNOWTT.DGO", + "DGO/SNOX.DGO", + "DGO/SNW.DGO", + "DGO/SNWX.DGO", + "DGO/SPA.DGO", + "DGO/SPARFOOT.DGO", + "DGO/SPARGUSS.DGO", + "DGO/SPARGUSW.DGO", + "DGO/SPARTEMS.DGO", + "DGO/SPARTEMW.DGO", + "DGO/SPARTT.DGO", + "DGO/SPATFOOT.DGO", + "DGO/SPATOURS.DGO", + "DGO/SPATOURW.DGO", + "DGO/SPATTBOX.DGO", + "DGO/SPB.DGO", + "DGO/SPC.DGO", + "DGO/SPD.DGO", + "DGO/SPE.DGO", + "DGO/SPRGSTBX.DGO", + "DGO/SPTMFOOT.DGO", + "DGO/SPTMTBOX.DGO", + "DGO/SPTMTT.DGO", + "DGO/SPTRTT.DGO", + "DGO/SPX.DGO", + "DGO/SPY.DGO", + "DGO/STX.DGO", + "DGO/STY.DGO", + "DGO/SWA.DGO", + "DGO/SWB.DGO", + "DGO/SWC.DGO", + "DGO/SWD.DGO", + "DGO/SWE.DGO", + "DGO/SWF.DGO", + "DGO/SWX.DGO", + "DGO/TARLEV.DGO", + "DGO/TEMPFOOT.DGO", + "DGO/TEMPLES.DGO", + "DGO/TEMPLETT.DGO", + "DGO/TEMPLEW.DGO", + "DGO/TEMPTBOX.DGO", + "DGO/THACRED.DGO", + "DGO/THALEV.DGO", + "DGO/THAVL.DGO", + "DGO/THAVL2.DGO", + "DGO/THAVL3.DGO", + "DGO/THBCRED.DGO", + "DGO/THBLEV.DGO", + "DGO/THBVL.DGO", + "DGO/THBVL2.DGO", + "DGO/THBVL3.DGO", + "DGO/THCCRED.DGO", + "DGO/THCLEV.DGO", + "DGO/THCVL.DGO", + "DGO/THCVL2.DGO", + "DGO/THCVL3.DGO", + "DGO/TIGEL.DGO", + "DGO/TOADL.DGO", + "DGO/TORCRED.DGO", + "DGO/TORLEV.DGO", + "DGO/TORVL.DGO", + "DGO/TORVL2.DGO", + "DGO/TORVL3.DGO", + "DGO/TPA.DGO", + "DGO/TPB.DGO", + "DGO/TPC.DGO", + "DGO/TPD.DGO", + "DGO/TPE.DGO", + "DGO/TPX.DGO", + "DGO/TPY.DGO", + "DGO/TURTL.DGO", + "DGO/UR8CRED.DGO", + "DGO/UR8LEV.DGO", + "DGO/UR8VL.DGO", + "DGO/UR8VL2.DGO", + "DGO/UR8VL3.DGO", + "DGO/WOLFL.DGO", + "DGO/WOMBL.DGO", + "DGO/XIMLEV.DGO" ], "levels_to_extract": [], diff --git a/decompiler/config/jakx/ntsc_v1/label_types.jsonc b/decompiler/config/jakx/ntsc_v1/label_types.jsonc index 2c63c08510..2a9b04d7d9 100644 --- a/decompiler/config/jakx/ntsc_v1/label_types.jsonc +++ b/decompiler/config/jakx/ntsc_v1/label_types.jsonc @@ -1,2 +1,14 @@ { + "ambient-h": [["L1", "(inline-array talker-speech-class)", 233]], + "pat-h": [["L1", "(inline-array pat-mode-info)", 4]], + "foreground-h": [["L4", "(pointer bucket-id-16)", 462]], + "texture-anim-h": [["L1", "(pointer uint8)", 256]], + "process-nettable-h": [["L13", "(pointer uint32)", 95]], + "math": [ + ["L109", "(pointer float)", 32], + ["L108", "(pointer float)", 32] + ], + "timer-h": [["L15", "(pointer uint32)", 12]], + "game-task-h": [["L178", "(pointer text-id)", 24]], + "profile": [["L3", "(inline-array profile-spec)", 13]] } diff --git a/decompiler/config/jakx/ntsc_v1/process_stack_size_overrides.jsonc b/decompiler/config/jakx/ntsc_v1/process_stack_size_overrides.jsonc index ba77e08ed9..4745ef76c5 100644 --- a/decompiler/config/jakx/ntsc_v1/process_stack_size_overrides.jsonc +++ b/decompiler/config/jakx/ntsc_v1/process_stack_size_overrides.jsonc @@ -1,3 +1,2 @@ // This overrides the stack size for calls to stack-size-set! in given functions. -{ -} +{} diff --git a/decompiler/config/jakx/ntsc_v1/stack_structures.jsonc b/decompiler/config/jakx/ntsc_v1/stack_structures.jsonc index 2c63c08510..7b55c1f361 100644 --- a/decompiler/config/jakx/ntsc_v1/stack_structures.jsonc +++ b/decompiler/config/jakx/ntsc_v1/stack_structures.jsonc @@ -1,2 +1,77 @@ { + "quaternion-smooth-seek!": [[16, ["inline-array", "quaternion", 2]]], + "rotate-vector-to-vector": [[16, "quaternion"]], + "nearest-dist2-between-moving-points": [[16, ["inline-array", "vector", 2]]], + "vector-segment-xz-distance-point!": [[16, "matrix"]], + "vector-interp-angle!": [[16, "quaternion"]], + "vector-cap-rotation!": [[16, "quaternion"]], + "vector-line-xz-distance-point!": [[16, "matrix"]], + "vector-circle-tangent-new": [ + [32, "vector"], + [48, "vector"] + ], + "v-slrp2!": [ + [32, "vector"], + [64, "matrix"] + ], + "v-slrp3!": [[32, "vector"]], + "collide-list-fill-bg-using-box": [ + [32, "matrix"], + [96, "collide-query"] + ], + "collide-list-fill-bg-using-line-sphere": [ + [32, "matrix"], + [96, "collide-query"] + ], + "(method 9 touching-list)": [[16, "add-prims-touching-work"]], + "(method 9 curve-color-fast)": [[16, "rgbaf"]], + "(method 9 curve2d-fast)": [ + [16, "vector"], + [32, "vector"] + ], + "evaluate-color-curve-fast": [[16, "vector"]], + "evaluate-curve-fast": [ + [16, "vector"], + [32, "vector"] + ], + "add-debug-box-with-transform": [ + [16, ["inline-array", "vector", 8]], + [144, ["inline-array", "vector", 2]], + [176, "vector"] + ], + "add-debug-curve": [ + [16, "vector"], + [32, "vector"] + ], + "add-debug-sphere-from-table": [ + [16, "vector"], + [48, "vector"], + [64, "vector"] + ], + "make-debug-sphere-table": [ + [16, "vector"], + [32, "vector"], + [48, "vector"], + [64, "vector"], + [80, "vector"], + [96, "vector"], + [112, "vector"] + ], + "eul->matrix": [[16, "vector"]], + "joint-mod-joint-set-world-handler": [ + [32, "vector"], + [48, "vector"] + ], + "joint-mod-blend-world-callback": [[16, "joint-mod-blend-world-work"]], + "(method 20 lightning-bolt)": [[16, "vector"]], + "update-light-hash": [ + [16, "bounding-box"], + [48, "vector"], + [64, "vector"] + ], + "(method 10 simple-sprite-system)": [[16, ["array", "texture-id", 128]]], + "(method 10 cubic-curve)": [[16, "trajectory"]], + "(method 11 cubic-curve)": [[16, "trajectory"]], + "(method 12 cubic-curve)": [[16, "trajectory"]], + "matrix<-parented-transformq!": [[16, "vector"]] } diff --git a/decompiler/config/jakx/ntsc_v1/type_casts.jsonc b/decompiler/config/jakx/ntsc_v1/type_casts.jsonc index 2c63c08510..cc89d79900 100644 --- a/decompiler/config/jakx/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jakx/ntsc_v1/type_casts.jsonc @@ -1,2 +1,467 @@ { + "entity-actor-count": [["_stack_", 16, "res-tag"]], + "entity-actor-lookup": [["_stack_", 16, "res-tag"]], + "build-masks": [ + [[18, 22], "a1", "drawable-tree-tfrag"], + [24, "a2", "drawable-inline-array-tfrag"], + [[27, 31], "a2", "(inline-array tfragment)"], + [[38, 42], "a1", "drawable-tree-tfrag-trans"], + [44, "a2", "drawable-inline-array-tfrag"], + [[47, 51], "a2", "(inline-array tfragment)"], + [[58, 62], "a1", "drawable-tree-tfrag-water"], + [64, "a2", "drawable-inline-array-tfrag"], + [[67, 71], "a2", "(inline-array tfragment)"], + [[78, 79], "a1", "drawable-tree-instance-tie"], + [123, "a1", "drawable-tree-instance-shrub"], + [[129, 133], "a2", "(inline-array prototype-bucket-shrub)"] + ], + "cam-layout-function-call": [ + [15, "gp", "(function string int basic object)"] + ], + "cam-layout-save-cam-rot": [[13, "v0", "vector"]], + "cam-layout-save-campointsoffset": [[12, "v0", "vector"]], + "cam-layout-save-splineoffset": [ + [37, "v0", "vector"], + [25, "v0", "vector"] + ], + "clmf-save-all": [[18, "v1", "connection"]], + "execute-cam-post-hook-engine": [ + [8, "s5", "connection"], + [[14, 17], "s5", "connection"], + [18, "t9", "(function object object object object object)"], + [9, "s5", "connection"] + ], + "collide-list-fill-bg-using-box": [ + [223, "a0", "collide-hash-scratch"], + [255, "a0", "collide-hash-scratch"], + [208, "v1", "collide-hash-scratch"], + [210, "v1", "collide-hash-scratch"], + [212, "v1", "collide-hash-scratch"], + [241, "v1", "collide-hash-scratch"], + [243, "v1", "collide-hash-scratch"], + [246, "v1", "collide-hash-scratch"] + ], + "collide-list-fill-bg-using-line-sphere": [ + [287, "a0", "collide-hash-scratch"], + [[272, 280], "v1", "collide-hash-scratch"], + [[239, 246], "v1", "collide-hash-scratch"], + [255, "a0", "collide-hash-scratch"], + [102, "v1", "float"] + ], + "(method 0 collide-shape-prim-group)": [ + [[6, 12], "v0", "collide-shape-prim-group"] + ], + "(method 0 collide-shape-prim-mesh)": [ + [[6, 11], "v0", "collide-shape-prim-mesh"] + ], + "(method 0 collide-shape-prim-sphere)": [ + [[5, 8], "v0", "collide-shape-prim-sphere"] + ], + "(method 10 touching-list)": [[[5, 11], "s5", "touching-shapes-entry"]], + "(method 11 touching-list)": [ + [8, "s5", "touching-shapes-entry"], + [11, "s5", "touching-shapes-entry"], + [13, "s5", "touching-shapes-entry"], + [48, "s5", "touching-shapes-entry"], + [52, "s5", "touching-shapes-entry"], + [10, "s5", "touching-shapes-entry"], + [33, "s5", "touching-shapes-entry"], + [50, "s5", "touching-shapes-entry"] + ], + "(method 0 touching-list)": [[[6, 8], "v0", "touching-list"]], + "(method 11 touching-prims-entry-pool)": [ + [[0, 8], "v1", "touching-prims-entry"], + [8, "v1", "pointer"], + [[9, 11], "v1", "touching-prims-entry"], + [[1, 20], "a1", "touching-prims-entry"] + ], + "(method 0 engine)": [ + [44, "v1", "pointer"], + [47, "v1", "pointer"], + [53, "v1", "connectable"], + [65, "v1", "connectable"] + ], + "(method 0 engine-pers)": [ + [32, "v1", "pointer"], + [23, "v1", "pointer"], + [26, "v1", "pointer"], + [24, "v1", "(pointer pointer)"] + ], + "(method 11 connection)": [[5, "a1", "pointer"]], + "(method 12 engine)": [ + [[0, 25], "s4", "connection"], + [13, "t9", "(function object object object object object)"] + ], + "(method 13 engine)": [ + [[0, 25], "s4", "connection"], + [13, "t9", "(function object object object object object)"] + ], + "(method 19 engine)": [[8, "a0", "connection"]], + "(method 20 engine)": [[8, "a0", "connection"]], + "(method 21 engine)": [[8, "a0", "connection"]], + "(method 3 connection-pers)": [[97, "f0", "float"]], + "(method 9 connection)": [[8, "a0", "pointer"]], + "drawable-frag-count": [[[14, 20], "s5", "drawable-group"]], + "add-debug-sphere-from-table": [ + [[38, 41], "v1", "vector"], + [[55, 59], "s0", "(inline-array vector)"] + ], + "unpack-comp-huf": [[[21, 23], "t3", "(pointer uint16)"]], + "unpack-comp-rle": [[[10, 26], "a0", "(pointer int8)"]], + "dma-bucket-insert-tag": [ + [[2, 6], "v1", "dma-bucket"], + [3, "a0", "dma-bucket"] + ], + "dma-buffer-add-buckets": [ + [[1, 4], "v1", "dma-bucket"], + [5, "v1", "pointer"], + [[9, 11], "v1", "dma-bucket"], + [11, "v1", "pointer"] + ], + "dma-buffer-patch-buckets": [ + [[3, 34], "a0", "dma-bucket"], + [[34, 38], "a0", "dma-packet"] + ], + "disasm-dma-list": [ + [43, "v1", "dma-packet"], + [266, "v1", "(pointer uint64)"], + [272, "v1", "(pointer uint64)"], + [133, "v1", "(pointer uint64)"], + [152, "v1", "(pointer uint64)"], + [167, "v1", "(pointer uint64)"], + [176, "v1", "(pointer uint64)"], + [198, "v1", "(pointer uint64)"], + [207, "v1", "(pointer uint64)"], + [238, "v1", "(pointer uint64)"], + [247, "v1", "(pointer uint64)"], + [282, "v1", "(pointer uint64)"], + [291, "v1", "(pointer uint64)"], + [324, "v1", "(pointer uint64)"], + [334, "v1", "(pointer uint64)"], + [141, "v1", "int"], + [25, "v1", "dma-tag"], + ["_stack_", 16, "uint"], + ["_stack_", 32, "dma-packet"], + ["_stack_", 64, "dma-packet"], + ["_stack_", 80, "dma-packet"] + ], + "(method 16 drawable-inline-array-node)": [[[1, 7], "v1", "draw-node"]], + "(method 15 drawable-tree)": [ + [[1, 4], "v1", "drawable-inline-array-node"], + [[29, 34], "t0", "drawable-inline-array-node"], + [[28, 32], "t2", "drawable-inline-array-node"], + [[42, 46], "t2", "(pointer int8)"] + ], + "glst-find-node-by-name": [[6, "s5", "glst-named-node"]], + "glst-length-of-longest-name": [[5, "s5", "glst-named-node"]], + "history-print": [[20, "a1", "int"]], + "joint-mod-foot-rot-handler": [ + [[0, 7], "s5", "joint-mod"], + [[35, 152], "s5", "joint-mod"] + ], + "joint-mod-joint-set-handler": [[[2, 23], "s4", "joint-mod"]], + "joint-mod-joint-set-world-handler": [[[6, 197], "s5", "joint-mod"]], + "joint-mod-polar-look-at-callback": [ + [[0, 363], "s5", "joint-mod-polar-look-at"] + ], + "joint-mod-scale-handler": [[[1, 14], "s5", "joint-mod"]], + "real-joint-mod-gun-look-at-handler": [ + [1, "v1", "joint-mod"], + [2, "v1", "joint-mod"] + ], + "joint-mod-blend-local-callback": [[[1, 28], "gp", "joint-mod-blend-local"]], + "joint-mod-blend-world-callback": [[[1, 150], "gp", "joint-mod-blend-world"]], + "joint-mod-rotate-world-callback": [ + [[0, 24], "s3", "joint-mod-rotate-world"] + ], + "joint-mod-set-local-callback": [[[1, 24], "v1", "joint-mod-set-local"]], + "joint-mod-set-world-callback": [[[1, 4], "v1", "joint-mod-set-local"]], + "joint-mod-set-world-no-trans-callback": [ + [[1, 25], "s4", "joint-mod-set-world-no-trans"] + ], + "(method 15 lightning-bolt)": [ + [47, "v1", "float"], + [64, "v1", "float"] + ], + "(method 17 lightning-bolt)": [[36, "v1", "float"]], + "(method 20 lightning-bolt)": [ + [15, "v1", "float"], + [32, "v1", "float"] + ], + "(method 21 lightning-bolt)": [ + [49, "v1", "float"], + [77, "v1", "float"], + ["_stack_", 32, "float"] + ], + "update-light-hash": [ + [[234, 239], "a1", "light-hash-bucket"], + [[207, 211], "a0", "light-hash-bucket"] + ], + "dgo-load-begin": [[[19, 43], "s1", "load-dgo-msg"]], + "dgo-load-continue": [[[5, 23], "gp", "load-dgo-msg"]], + "dgo-load-get-next": [[[14, 31], "v1", "load-dgo-msg"]], + "str-ambient-play": [[[7, 20], "s5", "play-chunk-msg"]], + "str-ambient-stop": [[[7, 20], "s5", "play-chunk-msg"]], + "str-load": [[[18, 44], "s2", "load-chunk-msg"]], + "str-load-status": [ + [[18, 22], "v1", "load-chunk-msg"], + [26, "v1", "load-chunk-msg"] + ], + "str-play-async": [[[7, 40], "s2", "play-chunk-msg"]], + "str-play-queue": [[[7, 98], "s4", "play-chunk-msg"]], + "str-play-stop": [[[7, 36], "s4", "play-chunk-msg"]], + "cube-root": [ + [17, "f0", "float"], + [17, "f1", "float"], + [18, "f0", "float"], + [18, "f1", "float"], + [[23, 32], "f0", "float"] + ], + "log2f": [ + [12, "f0", "float"], + [12, "f1", "float"], + [19, "f0", "float"], + [19, "f1", "float"] + ], + "logf": [ + [12, "f0", "float"], + [12, "f1", "float"], + [19, "f0", "float"], + [19, "f1", "float"] + ], + "debug-menu-find-from-template": [ + [9, "s5", "string"], + [10, "s4", "debug-menu-item"], + [18, "s4", "debug-menu-item-submenu"], + [3, "s5", "debug-menu"] + ], + "debug-menu-func-decode": [[18, "a0", "symbol"]], + "debug-menu-item-get-max-width": [ + [5, "a0", "debug-menu-item-submenu"], + [20, "a0", "debug-menu-item-var"] + ], + "debug-menu-item-var-joypad-handler": [ + [206, "a1", "int"], + [207, "v1", "int"] + ], + "debug-menu-item-var-make-float": [[32, "f0", "int"]], + "debug-menu-item-var-update-display-str": [ + [48, "v1", "int"], + [63, "v1", "int"], + [68, "v1", "int"], + [46, "v1", "int"], + [45, "v1", "int"], + [65, "v1", "int"], + [66, "v1", "int"] + ], + "debug-menu-rebuild": [[7, "a0", "debug-menu-item"]], + "debug-menu-send-msg": [ + [17, "s2", "debug-menu-item-submenu"], + [12, "s2", "debug-menu-item"] + ], + "(method 10 mysql-nav-node)": [[4, "v1", "mysql-nav-edge"]], + "(method 19 mysql-nav-graph)": [ + [42, "a0", "mysql-nav-edge"], + [46, "a0", "mysql-nav-edge"], + [60, "a0", "mysql-nav-edge"] + ], + "joint-channel-float-delete!": [ + [7, "a0", "pointer"], + [7, "a1", "pointer"] + ], + "num-func-chan": [[7, "v1", "joint-control-channel"]], + "ramdisk-load": [[[7, 12], "v1", "ramdisk-rpc-load"]], + "(method 15 res-lump)": [[132, "s5", "res-tag-pair"]], + "(method 16 res-lump)": [ + [22, "t1", "(pointer uint64)"], + [29, "t2", "(pointer uint64)"] + ], + "(method 17 res-lump)": [[22, "s4", "(pointer pointer)"]], + "(method 18 res-lump)": [["_stack_", 16, "object"]], + "(method 19 res-lump)": [ + [38, "t2", "int"], + [38, "a2", "int"] + ], + "(method 20 res-lump)": [[341, "t0", "(pointer uint128)"]], + "(method 21 res-lump)": [ + ["_stack_", 16, "res-tag"], + ["_stack_", 32, "res-tag"] + ], + "(method 0 script-context)": [[[8, 17], "v0", "script-context"]], + "shadow-vu1-add-matrix": [ + [[11, 19], "a3", "dma-packet"], + [[26, 30], "v1", "matrix"] + ], + "shrubbery-login-post-texture": [ + [[13, 15], "a3", "qword"], + [16, "a3", "pointer"], + [24, "a3", "pointer"], + [[17, 23], "a3", "qword"], + [[13, 23], "a1", "qword"], + [14, "a2", "qword"], + [[27, 29], "a3", "qword"], + [[27, 29], "a1", "qword"], + [[35, 37], "a3", "qword"], + [[35, 37], "a2", "qword"] + ], + "(method 2 sparticle-cpuinfo)": [[14, "f0", "float"]], + "sprite-add-2d-chunk": [ + [[7, 21], "a0", "dma-packet"], + [[33, 53], "a0", "dma-packet"], + [[57, 77], "a0", "dma-packet"], + [[78, 88], "v1", "dma-packet"], + [65, "a3", "int"] + ], + "sprite-add-3d-chunk": [ + [[7, 21], "a0", "dma-packet"], + [[33, 53], "a0", "dma-packet"], + [[57, 77], "a0", "dma-packet"], + [[78, 88], "v1", "dma-packet"], + [65, "a3", "int"] + ], + "sprite-add-frame-data": [[[3, 17], "a0", "dma-packet"]], + "add-shader-to-dma": [[[6, 8], "v1", "(pointer uint32)"]], + "sprite-glow-add-simple-sprite": [ + [[0, 33], "v1", "sprite-glow-ref-template"] + ], + "sprite-glow-add-sprite": [[[0, 33], "v1", "sprite-glow-cnt-template"]], + "(method 9 texture-anim-layer)": [ + [5, "v1", "symbol"], + [11, "v1", "symbol"] + ], + "add-tfrag-data": [ + [[3, 17], "a0", "dma-packet"], + [[24, 31], "v1", "dma-packet"] + ], + "tfrag-end-buffer": [ + [[21, 28], "a2", "dma-packet"], + [[31, 38], "a0", "(pointer vif-tag)"], + [[38, 42], "a0", "(pointer int32)"], + [[43, 49], "a0", "(pointer vif-tag)"] + ], + "(method 9 clock)": [[47, "v1", "float"]], + "vector4-array-add!": [ + [11, "s5", "(inline-array vector4)"], + [12, "s4", "(inline-array vector4)"], + [13, "gp", "(inline-array vector4)"] + ], + "vector4-array-lerp!": [ + [13, "s5", "(inline-array vector4)"], + [14, "s4", "(inline-array vector4)"], + [15, "gp", "(inline-array vector4)"] + ], + "vector4-array-madd!": [ + [13, "s5", "(inline-array vector4)"], + [14, "s4", "(inline-array vector4)"], + [15, "gp", "(inline-array vector4)"] + ], + "vector4-array-msub!": [ + [13, "s5", "(inline-array vector4)"], + [14, "s4", "(inline-array vector4)"], + [15, "gp", "(inline-array vector4)"] + ], + "vector4-array-mul!": [ + [11, "s5", "(inline-array vector4)"], + [12, "s4", "(inline-array vector4)"], + [13, "gp", "(inline-array vector4)"] + ], + "vector4-array-scale!": [ + [11, "s5", "(inline-array vector4)"], + [12, "gp", "(inline-array vector4)"] + ], + "vector4-array-sub!": [ + [11, "s5", "(inline-array vector4)"], + [12, "s4", "(inline-array vector4)"], + [13, "gp", "(inline-array vector4)"] + ], + "ellipsoid-random-point-on!": [ + [19, "v1", "float"], + [44, "v1", "float"] + ], + "(method 15 engine)": [[[0, 36], "v1", "connection"]], + "(method 10 connection)": [[8, "a0", "pointer"]], + "(method 3 connection-minimap)": [ + [97, "a3", "float"], + [[97, 99], "a3", "float"], + [97, "f0", "float"] + ], + "(method 0 prim-strip)": [[[101, 121], "a0", "vector"]], + "(method 0 fact-info-target)": [[3, "v0", "fact-info-target"]], + "(method 0 fact-info-crate)": [[3, "v0", "fact-info-crate"]], + "(method 0 fact-info-enemy)": [ + [7, "v0", "fact-info-enemy"], + ["_stack_", 16, "res-tag"], + ["_stack_", 32, "res-tag"] + ], + "(method 0 fact-info)": [ + [87, "v1", "(pointer int32)"], + [11, "v1", "res-lump"] + ], + "(method 0 collide-shape-moving)": [[[5, 12], "v0", "collide-shape-moving"]], + "joint-mod-spinner-callback": [[[2, 63], "gp", "joint-mod-spinner"]], + "joint-mod-add-local-callback": [[[1, 37], "s4", "joint-mod-add-local"]], + "(top-level-login eye-h)": [[76, "a3", "eye-control"]], + "joint-mod-rotate-local-callback": [ + [[2, 16], "v1", "joint-mod-rotate-local"] + ], + "joint-mod-trans-rot-local-callback": [ + [[2, 16], "v1", "joint-mod-trans-rot-local"] + ], + "(method 8 res-lump)": [ + [258, "s0", "array"], + [[157, 239], "s0", "(array object)"] + ], + "(method 2 array)": [ + [23, "gp", "(array int32)"], + [43, "gp", "(array uint32)"], + [63, "gp", "(array int64)"], + [83, "gp", "(array uint64)"], + [102, "gp", "(array int8)"], + [121, "gp", "(array uint8)"], + [141, "gp", "(array int16)"], + [161, "gp", "(array uint16)"], + [186, "gp", "(array uint128)"], + [204, "gp", "(array int32)"], + [223, "gp", "(array float)"], + [232, "gp", "(array float)"], + [249, "gp", "(array basic)"], + [258, "gp", "(array basic)"] + ], + "(method 3 array)": [ + [51, "gp", "(array int32)"], + [69, "gp", "(array uint32)"], + [87, "gp", "(array int64)"], + [105, "gp", "(array uint64)"], + [122, "gp", "(array int8)"], + [139, "gp", "(array int8)"], + [157, "gp", "(array int16)"], + [175, "gp", "(array uint16)"], + [198, "gp", "(array uint128)"], + [214, "gp", "(array int32)"], + [233, "gp", "(array float)"], + [250, "gp", "(array basic)"] + ], + "(method 9 bounding-box)": [ + [13, "a1", "(inline-array sphere)"], + [24, "a1", "(inline-array sphere)"], + [31, "a1", "(inline-array sphere)"], + [38, "a1", "(inline-array sphere)"] + ], + "generate-rand-vector-on-sphere": [ + [12, "v1", "float"], + [28, "v1", "float"] + ], + "vector-segment-distance-point!": [[[21, 30], "f1", "float"]], + "string-cat-to-last-char": [ + [3, "s5", "(pointer uint8)"], + [4, "s5", "string"] + ], + "to-upper": [ + [6, "a0", "(pointer uint8)"], + [8, "a0", "string"] + ], + "mem-copy!": [ + [[18, 69], "s5", "(pointer uint128)"], + [[18, 69], "s4", "(pointer uint128)"] + ] } diff --git a/decompiler/config/jakx/ntsc_v1/var_names.jsonc b/decompiler/config/jakx/ntsc_v1/var_names.jsonc index 2c63c08510..b5854fe6cb 100644 --- a/decompiler/config/jakx/ntsc_v1/var_names.jsonc +++ b/decompiler/config/jakx/ntsc_v1/var_names.jsonc @@ -1,2 +1,519 @@ { + "(method 0 inline-array-class)": { + "args": ["allocation", "type-to-make", "count"] + }, + "(method 9 inline-array-class)": { + "args": ["object-to-insert"] + }, + "(method 3 inline-array-class)": { + "args": ["idx-to-remove"] + }, + "identity": { + "args": ["obj"] + }, + "1/": { + "args": ["x"] + }, + "+": { + "args": ["a", "b"] + }, + "-": { + "args": ["a", "b"] + }, + "*": { + "args": ["a", "b"] + }, + "/": { + "args": ["a", "b"] + }, + "ash": { + "args": ["x", "shift-amount"] + }, + "mod": { + "args": ["a", "b"] + }, + "rem": { + "args": ["a", "b"] + }, + "abs": { + "args": ["x"] + }, + "min": { + "args": ["a", "b"] + }, + "max": { + "args": ["a", "b"] + }, + "logior": { + "args": ["a", "b"] + }, + "logand": { + "args": ["a", "b"] + }, + "lognor": { + "args": ["a", "b"] + }, + "logxor": { + "args": ["a", "b"] + }, + "lognot": { + "args": ["x"] + }, + "basic-type?": { + "args": ["obj", "typ"] + }, + "type-type?": { + "args": ["check-type", "parent-type"] + }, + "type?": { + "args": ["obj", "desired-type"] + }, + "find-parent-method": { + "args": ["typ", "method-id"] + }, + "ref&": { + "args": ["list", "idx"] + }, + "ref": { + "args": ["list", "idx"] + }, + "last": { + "args": ["list"] + }, + "member": { + "args": ["obj-to-find", "list"] + }, + "nmember": { + "args": ["obj-to-find", "list"] + }, + "assoc": { + "args": ["key", "assoc-list"] + }, + "assoce": { + "args": ["key", "assoc-list"] + }, + "nassoc": { + "args": ["key", "assoc-list"] + }, + "nassoce": { + "args": ["key", "assoc-list"] + }, + "append!": { + "args": ["list", "new-obj"] + }, + "delete!": { + "args": ["obj", "list"] + }, + "delete-car!": { + "args": ["car-to-match", "list"] + }, + "insert-cons!": { + "args": ["new-obj", "list"] + }, + "sort": { + "args": ["list", "compare-func"] + }, + "string->symbol-debug": { + "args": ["str"] + }, + "symbol->string-debug": { + "args": ["sym"] + }, + "symbol->hash": { + "args": ["sym"] + }, + "mem-copy!": { + "args": ["dst", "src", "bytes"] + }, + "qmem-copy<-!": { + "args": ["dst", "src", "qwc"] + }, + "qmem-copy->!": { + "args": ["dst", "src", "qwc"] + }, + "qmem-clear!": { + "args": ["dst", "qwc"] + }, + "mem-set32!": { + "args": ["dst", "word-count", "value"] + }, + "mem-or!": { + "args": ["dst", "src", "bytes"] + }, + "fact": { + "args": ["x"] + }, + "print": { + "args": ["obj"] + }, + "printl": { + "args": ["obj"] + }, + "inspect": { + "args": ["obj"] + }, + "mem-print": { + "args": ["ptr", "word-count"] + }, + "print-tree-bitmask": { + "args": ["mask", "count"] + }, + "valid?": { + "args": [ + "obj", + "expected-type", + "err-msg-str", + "allow-false", + "err-msg-dest" + ] + }, + "(method 10 collide-mesh-cache)": { + "args": ["this", "id"] + }, + "(method 11 touching-prims-entry-pool)": { + "vars": { + "v1-0": "prev", + "a1-0": "current", + "a2-0": "next" + } + }, + "add-debug-box-with-transform": { + "args": ["enable", "bucket", "box", "mat", "color"] + }, + "add-debug-cspace": { + "args": ["enable", "bucket", "cs"] + }, + "add-debug-text-sphere": { + "args": ["enable", "bucket", "pos", "radius", "text", "color"] + }, + "add-debug-vector": { + "args": ["enable", "bucket", "base", "dir", "len-scale", "color"] + }, + "debug-reset-buffers": { + "args": ["enable", "bucket", "p0", "p1", "color"] + }, + "get-debug-text-3d": { + "args": ["enable", "bucket", "p0", "p1", "color", "mode", "color2"] + }, + "transform-float-point": { + "args": ["src-world-pt", "dst-gs-screen-pt"] + }, + "dma-bucket-insert-tag": { + "args": ["buckets", "bucket", "start-tag", "end-tag-to-patch"] + }, + "dma-buffer-add-buckets": { + "args": ["dma-buf", "bucket-count"] + }, + "dma-buffer-patch-buckets": { + "args": ["base", "count"] + }, + "(method 0 dma-buffer)": { + "args": ["allocation", "type-to-make", "size-bytes"] + }, + "dma-buffer-add-vu-function": { + "args": ["dma-buf", "vu-func", "flush-path-3"] + }, + "dma-buffer-free": { + "args": ["dma-buf"] + }, + "dma-buffer-inplace-new": { + "args": ["dma-buff", "size-bytes"] + }, + "dma-buffer-length": { + "args": ["dma-buf"] + }, + "dma-buffer-send": { + "args": ["chan", "buf"] + }, + "dma-buffer-send-chain": { + "args": ["chan", "buf"] + }, + "disasm-dma-list": { + "args": ["data", "mode", "verbose", "stream", "expected-size"] + }, + "disasm-dma-tag": { + "args": ["tag", "format-dest"] + }, + "disasm-vif-details": { + "args": ["fmt-dest", "vif-data", "unpack-cmd", "unpack-count"] + }, + "disasm-vif-tag": { + "args": ["tag", "count", "format-dest", "details?"] + }, + "(method 13 effect-control)": { + "args": ["this", "offset"] + }, + "(method 11 focus)": { + "args": ["this", "cspec"] + }, + "(method 0 clock)": { + "args": ["allocation", "type-to-make", "index"] + }, + "(method 0 sql-result)": { + "args": ["allocation", "type-to-make", "num-elts"] + }, + "(method 16 clock)": { + "args": ["this", "xor-val"] + }, + "(method 17 clock)": { + "args": ["this", "xor-val"] + }, + "(method 18 clock)": { + "args": ["this", "xor-val"] + }, + "(method 19 clock)": { + "args": ["this", "xor-val"] + }, + "(method 20 clock)": { + "args": ["this", "xor-val"] + }, + "(method 21 clock)": { + "args": ["this", "xor-val"] + }, + "(method 22 clock)": { + "args": ["this", "xor-val"] + }, + "(method 23 clock)": { + "args": ["this", "xor-val"] + }, + "(method 10 joint-mod-polar-look-at)": { + "args": ["this", "pos"] + }, + "(method 11 joint-mod-polar-look-at)": { + "args": ["this", "other", "pos"] + }, + "(method 12 joint-mod-polar-look-at)": { + "args": ["this", "duration", "final-val", "restart-if-in-progress"] + }, + "(method 13 joint-mod)": { + "args": ["this", "x", "y", "z"] + }, + "(method 13 joint-mod-polar-look-at)": { + "args": ["this", "duration", "restart-if-in-progress"] + }, + "(method 14 joint-mod)": { + "args": ["this", "trans", "quat", "scale"] + }, + "(method 9 joint-mod)": { + "args": ["this", "mode"] + }, + "(method 9 joint-mod-ik)": { + "args": ["this", "pos"] + }, + "joint-mod-blend-local-callback": { + "args": ["bone-cspace", "joint-transform"] + }, + "joint-mod-blend-world-callback": { + "args": ["bone-cspace", "joint-transform"] + }, + "joint-mod-rotate-world-callback": { + "args": ["bone-cspace", "joint-transform"] + }, + "joint-mod-set-local-callback": { + "args": ["bone-cspace", "joint-transform"] + }, + "joint-mod-set-world-callback": { + "args": ["bone-cspace", "joint-trasnform"] + }, + "joint-mod-set-world-no-trans-callback": { + "args": ["bone-cspace", "joint-transform"] + }, + "vector<-cspace2!": { + "args": ["output-vec", "input-cspace"] + }, + "light-group-lerp!": { + "args": ["group", "backup-ptr", "other", "scalar"] + }, + "light-group-madd!": { + "args": ["group", "backup-ptr", "other", "scalar"], + "vars": { + "s4-0": "new-light", + "f30-0": "ambi-scaled", + "f24-0": "dir0-scaled", + "f26-0": "dir1-scaled", + "f28-0": "dir2-scaled" + } + }, + "light-group-process!": { + "args": ["vu-lights", "light-group", "vec1", "vec2"] + }, + "light-group-scale!": { + "args": ["group", "backup-ptr", "scale"], + "vars": { + "arg1": "other", + "v1-4": "light-idx" + } + }, + "light-group-slerp": { + "args": ["light-group-out", "light-group-a", "light-group-b", "alpha"], + "vars": { + "s2-0": "group-idx" + } + }, + "light-merge!": { + "args": ["out", "other"] + }, + "light-slerp": { + "args": ["light-out", "light-a", "light-b", "alpha"], + "vars": { + "s3-0": "clamped-alpha", + "f0-2": "extra-x-a", + "f1-2": "extra-x-b" + } + }, + "lookup-light-sphere-by-name": { + "args": ["name", "hash"], + "vars": { + "s4-0": "num-lights", + "s3-0": "light" + } + }, + "shadow-info-copy!": { + "args": ["dest", "src"], + "vars": { + "v1-0": "light-idx" + } + }, + "vu-lights-default!": { + "args": ["lights"] + }, + "destroy-mem": { + "args": ["start", "end"] + }, + "dgo-load-begin": { + "args": ["name", "buffer1", "buffer2", "buffer-top"] + }, + "dgo-load-continue": { + "args": ["buffer1", "buffer2", "buffer-top"] + }, + "dgo-load-get-next": { + "args": ["done-out"] + }, + "find-temp-buffer": { + "args": ["size"] + }, + "str-ambient-play": { + "args": ["name"] + }, + "str-ambient-stop": { + "args": ["name"] + }, + "str-load": { + "args": ["name", "chunk-idx", "dest-addr", "max-len"] + }, + "str-load-status": { + "args": ["maxlen-out"] + }, + "str-play-async": { + "args": ["name", "id", "volume", "group"] + }, + "str-play-queue": { + "args": ["name0", "name1", "name2", "name3", "ids", "mask"] + }, + "str-play-stop": { + "args": ["name", "id"] + }, + "merc-fragment-fp-data": { + "args": ["frag"] + }, + "(method 13 mood-control)": { + "args": ["this", "target-interp", "rate-interp", "set-current-interp?"], + "vars": { + "f0-1": "clamped-interp" + } + }, + "init-mood-control": { + "args": ["ctrl"] + }, + "cspace-index-by-name-no-fail": { + "args": ["proc", "name"], + "vars": { + "v0-0": "idx" + } + }, + "joint-channel-float-delete!": { + "args": ["chan"] + }, + "num-func-+!": { + "args": ["chan", "arg1", "arg2", "arg3"] + }, + "num-func--!": { + "args": ["chan", "arg1", "arg2", "arg3"] + }, + "num-func-identity": { + "args": ["chan", "arg1", "arg2", "arg3"] + }, + "num-func-loop!": { + "args": ["chan", "arg1", "arg2", "arg3"] + }, + "num-func-loop-set!": { + "args": ["chan", "frame"] + }, + "num-func-none": { + "args": ["chan", "arg1", "arg2", "arg3"] + }, + "num-func-seek!": { + "args": ["chan", "arg1", "arg2", "arg3"] + }, + "(method 15 res-lump)": { + "vars": { + "s5-0": ["tag-pair", "res-tag-pair"], + "s2-0": "existing-tag", + "s3-0": "data-size", + "v1-25": "resource-mem" + } + }, + "(method 17 res-lump)": { + "args": ["this", "tag", "arg2"] + }, + "(method 20 res-lump)": { + "args": ["this", "arg1", "tag-pair", "arg3"] + }, + "(method 9 res-lump)": { + "args": ["this", "name", "mode", "time"] + }, + "(method 0 rpc-buffer)": { + "args": ["allocation", "type-to-make", "elt-size", "elt-count"] + }, + "(method 0 rpc-buffer-pair)": { + "args": ["allocation", "type-to-make", "elt-size", "elt-count", "rpc-port"] + }, + "(method 12 rpc-buffer-pair)": { + "args": ["this", "print-stall-warning"] + }, + "(method 9 rpc-buffer-pair)": { + "args": ["this", "fno", "recv-buffer", "recv-buffer-size"] + }, + "(method 10 smush-control)": { + "vars": { + "f30-0": "elapsed-time", + "f0-2": "period" + } + }, + "(method 11 smush-control)": { + "vars": { + "f30-0": "elapsed-time", + "f0-2": "period" + } + }, + "(method 12 smush-control)": { + "args": [ + "this", + "amplitude", + "period", + "duration", + "damp-amplitude", + "damp-period", + "clock" + ] + }, + "(method 9 clock)": { + "args": ["this", "rate"] + }, + "vector-rad<-vector-deg!": { + "args": ["out", "in"] + }, + "vector-rad<-vector-deg/2!": { + "args": ["out", "in"] + } } diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index a2b886a497..e38c0834c4 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -1070,7 +1070,8 @@ const std::unordered_map< }}, {GameVersion::JakX, { - // TODO + {"lightning-probe-vars", + {{"probe-dirs", ArrayFieldDecompMeta(TypeSpec("vector"), 16)}}}, }}}; goos::Object decompile_structure(const TypeSpec& type, diff --git a/decompiler/util/type_utils.h b/decompiler/util/type_utils.h index d1674a6220..6d634c3854 100644 --- a/decompiler/util/type_utils.h +++ b/decompiler/util/type_utils.h @@ -16,5 +16,5 @@ constexpr PerGameVersion SYMBOL_TO_STRING_MEM_OFFSET_DECOMP = { 8167 * 8, jak2::SYM_TO_STRING_OFFSET, -99999, -99999, // not supported this way! }; -constexpr PerGameVersion OFFSET_OF_NEXT_STATE_STORE = {72, 64, 68, 68}; +constexpr PerGameVersion OFFSET_OF_NEXT_STATE_STORE = {72, 64, 68, 76}; } // namespace decompiler diff --git a/goal_src/goal-lib.gc b/goal_src/goal-lib.gc index f298d8ad15..cfe67746c3 100644 --- a/goal_src/goal-lib.gc +++ b/goal_src/goal-lib.gc @@ -1283,4 +1283,7 @@ ((eq? GAME_VERSION 'jak3) (asm-file "goal_src/jak3/compiler-setup.gc") ) + ((eq? GAME_VERSION 'jakx) + (asm-file "goal_src/jakx/compiler-setup.gc") + ) ) diff --git a/goal_src/jakx/compiler-setup.gc b/goal_src/jakx/compiler-setup.gc new file mode 100644 index 0000000000..5625599f44 --- /dev/null +++ b/goal_src/jakx/compiler-setup.gc @@ -0,0 +1,37 @@ +;; +;; Compiler Setup for Jak X +;; + +;; load kernel type definitions. +;; these types/functions are provided by Jak X's runtime. +(asm-file "goal_src/jakx/kernel-defs.gc") + +;; load jak x project +(load-project "goal_src/jakx/game.gp") + +(defmacro basic? (obj) + ;; todo, make this more efficient + `(= 4 (logand (the integer ,obj) #b111)) + ) + +(defmacro pair? (obj) + ;; todo, make this more efficient + ;`(= 2 (logand (the integer ,obj) #b111)) + `(< (shl (the-as int ,obj) 62) 0) + ) + +(defmacro not-pair? (obj) + `(>= (shl (the-as int ,obj) 62) 0) + ) + +(defmacro binteger? (obj) + `(zero? (logand (the integer ,obj) #b111)) + ) + +(defmacro rtype-of (obj) + `(cond ((binteger? ,obj) binteger) + ((pair? ,obj) pair) + ((basic? ,obj) (-> (the basic ,obj) type)) + (else symbol) + ) + ) diff --git a/goal_src/jakx/dgos/game.gd b/goal_src/jakx/dgos/game.gd index 99e15f277d..326162ad40 100644 --- a/goal_src/jakx/dgos/game.gd +++ b/goal_src/jakx/dgos/game.gd @@ -29,6 +29,7 @@ "video-h.o" "vu1-user-h.o" "profile-h.o" + "dma.o" "dma-buffer.o" "dma-bucket.o" "dma-disasm.o" @@ -203,15 +204,19 @@ "history.o" "merc-vu1.o" "emerc-vu1.o" + "merc-blend-shape.o" "merc.o" "emerc.o" "ripple.o" "bones.o" "debug-foreground.o" + "foreground.o" "generic-vu0.o" "generic-vu1.o" + "generic-effect.o" "generic-merc.o" "generic-tie.o" + "shadow-cpu.o" "shadow-vu1.o" "warp.o" "hflip.o" @@ -264,7 +269,9 @@ "collide-hash.o" "collide-probe.o" "collide-frag.o" + "collide-mesh.o" "collide-touch.o" + "collide-shape.o" "collide-shape-rider.o" "collide.o" "collide-planes.o" @@ -315,9 +322,11 @@ "main-collide.o" "video.o" "main.o" + "collide-cache.o" "collide-debug.o" "relocate.o" "memory-usage.o" + "entity.o" "path.o" "vol.o" "nav-engine.o" @@ -327,6 +336,7 @@ "water-part.o" "water.o" "water-flow.o" + "task-control.o" "scene.o" "movie-path.o" "pov-camera.o" @@ -391,6 +401,7 @@ "net-aux-voice.o" "net-mgr-medius.o" "net-mgr-muis.o" + "net-mgr-medius-cache.o" "net-mgr-medius-players.o" "net-mgr-medius-buddies.o" "net-mgr-medius-clans.o" @@ -421,6 +432,7 @@ "udp-layer.o" "headset.o" "idle-control.o" + "water-anim.o" "rigid-body-debug.o" "rigid-body-surface.o" "rigid-body.o" @@ -482,6 +494,7 @@ "part-tester.o" "manipulator.o" "editable-h.o" + "editable.o" "editable-player.o" "mysql-nav-graph.o" "nav-graph-editor.o" @@ -547,7 +560,6 @@ "helmet-e-ag.go" "helmet-f-ag.go" "menu2-part.o" - "menu2-COMMON-GAME.o" "intro-part.o" "intro-scenes2.o" "intro-scenes.o" @@ -638,6 +650,7 @@ "wcar-daxtermobile.o" "drift.o" "race-mesh.o" + "race-line.o" "race-ai-tuning.o" "minimap.o" "jakx-init.o" diff --git a/goal_src/jakx/dgos/kernel.gd b/goal_src/jakx/dgos/kernel.gd index 58a5eeea88..426f4499b1 100644 --- a/goal_src/jakx/dgos/kernel.gd +++ b/goal_src/jakx/dgos/kernel.gd @@ -4,6 +4,7 @@ "gkernel-h.o" "gkernel.o" "pskernel.o" + "gstring.o" "dgo-h.o" "gstate.o" )) diff --git a/goal_src/jakx/dgos/menu2.gd b/goal_src/jakx/dgos/menu2.gd index 414b86c389..d48cdc1eec 100644 --- a/goal_src/jakx/dgos/menu2.gd +++ b/goal_src/jakx/dgos/menu2.gd @@ -80,5 +80,5 @@ "garage-turntable-ag.go" "garage-door-ag.go" "interface-cam-ag.go" - "menu2-MENU2.o" + "menu2.go" )) diff --git a/goal_src/jakx/engine/ambient/ambient-h.gc b/goal_src/jakx/engine/ambient/ambient-h.gc index 2f51f0823d..f649e1d2be 100644 --- a/goal_src/jakx/engine/ambient/ambient-h.gc +++ b/goal_src/jakx/engine/ambient/ambient-h.gc @@ -5,5 +5,2178 @@ ;; name in dgo: ambient-h ;; dgos: ENGINE, GAME +;; +++talker-flags +(defenum talker-flags + :type uint16 + :bitfield #t + (play-only-once 0) + (reduce-volume 1) + (auto-save-on-each-start 2) + (auto-save-once-on-exit 3) + (only-play-in-region 4) + (fade-in 5) + (slide-in 6) + (bigger-font 7) + (long-timeout 8) + ) +;; ---talker-flags + +(define-extern kill-current-talker (function pair pair symbol none)) +(define-extern talker-surpress! (function int)) +(define-extern voicebox-spawn (function process-drawable vector (pointer process))) + +(declare-type talker-speech-class structure) +(define-extern talker-spawn-func (function talker-speech-class process-tree vector region sound-id)) +(declare-type talker process) +(define-extern talker-init (function talker-speech-class vector region none :behavior talker)) + ;; DECOMP BEGINS +(deftype talker-speech-class (structure) + "Contains metadata about a voice line or hint text being played/displayed. +In the talker state, there's a pos-state and neg-state. +Calling yes-play! adjusts the pos-state and no-play! adjusts the neg-state. +Playback is only allowed if the pos-state is less than or equal to pos +and neg-state is greater than or equal to neg. +" + ((name string) + (channel gui-channel) + (flags talker-flags) + (speech uint16) + (text-duration uint16) + (delay uint16) + (pos uint16) + (neg uint16) + (text-message text-id) + (on-close pair) + (camera string) + ) + :pack-me + (:methods + (should-play? (_type_) symbol) + (mark-played! (_type_) none) + (reset-state! (_type_) none) + (yes-play! (_type_ int) none) + (no-play! (_type_ int) none) + ) + ) + + +(deftype talker (process) + ((trans vector :inline) + (message talker-speech-class) + (total-time time-frame) + (total-off-time time-frame) + (start-time time-frame) + (state-time time-frame) + (voicebox handle) + (voice-id sound-id) + (message-id sound-id) + (region region) + (interp float) + (save? symbol) + (grab? symbol) + ) + (:state-methods + idle + active + exit + ) + (:methods + (draw-text (_type_) none) + ) + ) + + +(define *talker-speech* (new 'static 'inline-array talker-speech-class 233 + (new 'static 'talker-speech-class :name "none") + (new 'static 'talker-speech-class + :name "intro01" + :channel (gui-channel notice) + :flags (talker-flags fade-in) + :speech #x1 + :text-duration (seconds 3.5) + :neg #x1 + :text-message (text-id text-id-341) + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "intro01e" + :channel (gui-channel notice) + :flags (talker-flags fade-in) + :speech #x2 + :text-duration (seconds 3.5) + :neg #x1 + :text-message (text-id text-id-342) + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "intro01j" + :channel (gui-channel notice) + :flags (talker-flags fade-in) + :speech #x3 + :text-duration (seconds 3.5) + :neg #x1 + :text-message (text-id text-id-344) + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "intro01k" + :channel (gui-channel notice) + :flags (talker-flags fade-in) + :speech #x4 + :text-duration (seconds 3.5) + :neg #x1 + :text-message (text-id text-id-343) + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "intro03" + :channel (gui-channel notice-low) + :speech #x5 + :text-duration (seconds 5) + :neg #x1 + :text-message (text-id text-id-522) + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "won1" + :channel (gui-channel alert) + :speech #x6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit101r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit102r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x8 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit103r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x9 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit104r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xa + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit105r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xb + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit106r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xc + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit107r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xd + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit108r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xe + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit109r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xf + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit110r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x10 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit111r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x11 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit112r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x12 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit113r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x13 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit114r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x14 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit115r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x15 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit116r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x16 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit117r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x17 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit118r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x18 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit119r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x19 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit120r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit121r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit122r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit123r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit124r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit125r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit126r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x20 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit127r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x21 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit128r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x22 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit129r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x23 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit130r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x24 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit131r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x25 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit132r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x26 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit133r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x27 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit134r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x28 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit135r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x29 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit136r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit137r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit138r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit139r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit140r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit141r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit142r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x30 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit143r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x31 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit144r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x32 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit145r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x33 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit146r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x34 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit147r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x35 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit148r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x36 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit149r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x37 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit150r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x38 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit151r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x39 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit152r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit153r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit154r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit155r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit156r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit157r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit158r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x40 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit159r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x41 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit160r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x42 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit161r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x43 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit162r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x44 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit163r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x45 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit164r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x46 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit165r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x47 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit166r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x48 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit167r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x49 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit168r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit169r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit170r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit171r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit175r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit176r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit177r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x50 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit178r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x51 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit179r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x52 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit180r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x53 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit181r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x54 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit182r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x55 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit183r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x56 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit184r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x57 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit185r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x58 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit186r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x59 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit187r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit188r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit189r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit190r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit191r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit192r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit193r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x60 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit194r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x61 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit195r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x62 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit196r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x63 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit197r" + :channel (gui-channel daxter) + :flags (talker-flags play-only-once reduce-volume) + :speech #x64 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit198r" + :channel (gui-channel daxter) + :flags (talker-flags play-only-once reduce-volume) + :speech #x65 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit199r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x66 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit200r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x67 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit201r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x68 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "train1" + :channel (gui-channel daxter) + :speech #x69 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "train2" + :channel (gui-channel daxter) + :speech #x6a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "award1" + :channel (gui-channel alert) + :speech #x6b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak011r" + :channel (gui-channel speech) + :speech #x6c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak012r" + :channel (gui-channel speech) + :speech #x6d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak020r" + :channel (gui-channel speech) + :speech #x6e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak021r" + :channel (gui-channel speech) + :speech #x6f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak022r" + :channel (gui-channel speech) + :speech #x70 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "miz003r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume) + :speech #x71 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb583" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x72 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb584" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x73 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec586" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x74 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb585" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x75 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb590" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x76 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec591" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x77 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb586" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x78 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec587" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x79 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb587" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec588" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb588" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec589" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec585" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb598" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb596" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x80 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec598" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x81 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb600" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x82 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb591" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x83 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec592" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x84 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec603" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x85 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb615" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x86 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec599" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x87 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb610" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x88 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec593" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x89 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec596" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb607" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec613" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb609" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb616" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb602" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb604" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x90 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec597" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x91 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb589" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x92 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec590" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x93 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec611" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x94 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb597" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x95 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb599" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x96 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb601" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x97 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb611" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x98 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec605" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x99 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb603" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb605" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb606" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec612" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb608" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb612" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb617" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa0 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb614" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa1 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec594" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa2 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec595" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa3 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec601" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa4 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec602" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa5 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec614" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "dax012" + :channel (gui-channel daxter) + :flags (talker-flags play-only-once) + :speech #xa7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "dax013" + :channel (gui-channel daxter) + :flags (talker-flags play-only-once) + :speech #xa8 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "dax014" + :channel (gui-channel daxter) + :flags (talker-flags play-only-once) + :speech #xa9 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb011" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xaa + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb012" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xab + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb013" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xac + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb015" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xad + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb017" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xae + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb018" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xaf + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb019" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb0 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb020" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb1 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb021" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb2 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb022" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb3 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb023" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb4 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb024" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb5 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb025" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb026" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb027" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb8 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb028" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb9 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb029" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xba + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb030" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xbb + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb031" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xbc + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb032" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xbd + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb033" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xbe + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb034" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xbf + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb035" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc0 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb036" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc1 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb037" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc2 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb038" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc3 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb039" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc4 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb040" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc5 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb041" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb042" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb043" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc8 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb044" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc9 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb045" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xca + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb046" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xcb + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb047" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xcc + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb048" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xcd + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb049" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xce + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb050" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xcf + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb051" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd0 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb052" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd1 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb053" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd2 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb054" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd3 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb055" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd4 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb056" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd5 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb014" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb016" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb057" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd8 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "awardcar" + :channel (gui-channel alert) + :flags (talker-flags reduce-volume long-timeout) + :speech #xd9 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "raz140r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xda + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "klev115r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xdb + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keir235r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xdc + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "tar104r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xdd + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "sig109r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xde + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "UR86101r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xdf + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "kaed109r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe0 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "rayn107r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe1 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "rat109r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe2 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak205r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe3 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak226r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe4 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "dax175r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe5 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb273r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec327r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "xim101r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe8 + :neg #x1 + :on-close #f + :camera #f + ) + ) + ) diff --git a/goal_src/jakx/engine/anim/joint-h.gc b/goal_src/jakx/engine/anim/joint-h.gc index daeff892af..3926bd4da8 100644 --- a/goal_src/jakx/engine/anim/joint-h.gc +++ b/goal_src/jakx/engine/anim/joint-h.gc @@ -5,5 +5,162 @@ ;; name in dgo: joint-h ;; dgos: ENGINE, GAME +;; +++joint-control-command +(defenum joint-control-command + :type uint64 + (push 1) + (blend 2) + (four 4) + (eight 8) + (push1 19) + (jcc32 32) + (stack 36) + (float 42) + (stack1 52) + ) +;; ---joint-control-command + + +;; +++joint-control-status +(defenum joint-control-status + :type uint16 + :bitfield #t + + (sync-math 0) ;; 1 + (spooling 1) ;; 2 + (spooling-not-last-block 2) ;; 4 + (blend-shape 3) ;; 8 + (math-when-off-screen 4) ;; 16 + (valid-spooled-frame 5) ;; 32 + (blend-shape-valid 6) ;; 64 + (eye-anim-valid 7) ;; 128 + (eye-anim 8) ;; 256 + (force-math 9) + (no-joint-callbacks 10) + ) +;; ---joint-control-status + +(declare-type joint-control basic) + +(define-extern cspace<-transformq! (function cspace transformq matrix)) +(define-extern cspace<-parented-transformq-joint! (function cspace transformq none)) + +(declare-type effect-control basic) + ;; DECOMP BEGINS +(deftype joint-control-channel (structure) + "A single animation channel that controls a number of joints. +Multiple channels are used to blend animations together." + ((parent joint-control) + (frame-group art-joint-anim) + (frame-num float) + (dist meters) + (num-func (function joint-control-channel float float float float)) + (param float 3) + (frame-interp float 2) + (inspector-amount uint8) + (command joint-control-command) + (group-sub-index int8) + (group-size int8) + (eval-time uint32) + ) + ) + + +(deftype top-anim-joint-control (basic) + ((process (pointer process-drawable)) + (interp-select uint64 2) + (base-anim basic) + (base-anim-speed float) + (base-anim-blend float) + (interp float) + (frame-group art-joint-anim) + (frame-group-push art-joint-anim) + (frame-num float) + (frame-targ art-joint-anim) + (frame-speed float) + (frame-blend float) + (frame-cur-blend float) + (frame-start float) + (frame-post-blend float) + (frame-post-end float) + (frame-push-time time-frame) + (frame-post-put-away basic) + (update-time time-frame) + ) + (:methods + (new (symbol type process-drawable) _type_) + (reset (_type_) none) + (update (_type_) none) + (get-channel (_type_ int) joint-control-channel) + (push-anim-to-targ (_type_ art-joint-anim float int int float float symbol) none) + ) + ) + + +(deftype joint-control (basic) + "Every [[process-drawable]] has a [[joint-control]] that handles all the animation channels." + ((status joint-control-status) + (allocated-length uint8) + (active-channels uint8) + (root-channel (inline-array joint-control-channel) :offset 16) + (blend-index uint8) + (active-frame-interp uint8) + (float-channels uint8) + (generate-frame-function (function joint-anim-frame int joint-control int)) + (prebind-function (function joint-anim-frame int joint-control int)) + (postbind-function (function draw-control cspace-array joint-control none)) + (effect effect-control) + (interp-select int64 2) + (top-anim top-anim-joint-control) + (override (array float)) + (channel joint-control-channel :inline :dynamic) + ) + (:methods + (new (symbol type int) _type_) + (current-cycle-distance (_type_) float) + (update-anim-data (_type_) none) + (debug-print-channels (_type_ symbol) int) + (joint-control-method-12 (_type_ int) joint-control-channel) + ) + ) + + +(deftype matrix-stack (structure) + ((top matrix) + (data matrix 24 :inline) + ) + ) + + +(deftype channel-upload-info (structure) + "Information about an upload of animation data to a single joint channel." + ((fixed joint-anim-compressed-fixed) + (fixed-qwc int32) + (frame joint-anim-compressed-frame) + (frame-qwc int32) + (amount float) + (interp float) + ) + :pack-me + ) + + +(deftype joint-work (structure) + ((temp-mtx matrix :inline) + (joint-stack matrix-stack :inline) + (fix-jmp-table (function none) 16) + (frm-jmp-table (function none) 16) + (pair-jmp-table (function none) 16) + (uploads channel-upload-info 24 :inline) + (num-uploads int32) + (mtx-acc matrix 2 :inline) + (tq-acc transformq 100 :inline) + (jacp-hdr joint-anim-compressed-hdr :inline) + (fixed-data joint-anim-compressed-fixed :inline) + (frame-data joint-anim-compressed-frame 2 :inline) + (flatten-array float 576 :overlay-at mtx-acc) + (flattened vector 24 :inline :overlay-at mtx-acc) + ) + ) diff --git a/goal_src/jakx/engine/anim/joint-mod-h.gc b/goal_src/jakx/engine/anim/joint-mod-h.gc index df9f57bbf9..df3d37d0fe 100644 --- a/goal_src/jakx/engine/anim/joint-mod-h.gc +++ b/goal_src/jakx/engine/anim/joint-mod-h.gc @@ -5,5 +5,74 @@ ;; name in dgo: joint-mod-h ;; dgos: ENGINE, GAME +;; +++joint-mod-base-flags +(defenum joint-mod-base-flags + :bitfield #t + :type uint16 + (attached 0) + (trans 1) + (quat 2) + (scale 3) + ) +;; ---joint-mod-base-flags + + +;; +++joint-mod-polar-flags +(defenum joint-mod-polar-flags + :type uint32 + :bitfield #t + (no-z-rot 0) + (blending-to-zero 1) + (negate-nose 2) + (negate-ear 3) + (negate-up 4) + ) +;; ---joint-mod-polar-flags + +;; +++joint-mod-mode +(defenum joint-mod-mode + :bitfield #t + :type uint32 + (flex-blend) + (look-at) + (world-look-at) + (rotate) + (joint-set) + (joint-set*) + (rotate2) ;; ?? + (reset) + (polar-look-at) + (joint-set*-world) + (gun-look-at) + (foot-rot) + (joint-set-world) + ) +;; ---joint-mod-mode + +;; +++track-mode +(defenum track-mode + :bitfield #t + :type uint16 + (track-on 0) ;; 1 + (track-x 1) ;; 2 + (track-y 2) ;; 4 + (lock-on 3) ;; 8 + (no-trans 4) ;; 16 + (no-rotate 5) ;; 32 + (no-scale 6) ;; 64 + ) +;; ---track-mode + +;; +++joint-mod-ik-flags +(defenum joint-mod-ik-flags + :bitfield #t + :type uint8 + (enable) + (elbow-trans-neg) + (elbow-rot-neg) + ) +;; ---joint-mod-ik-flags + + ;; DECOMP BEGINS diff --git a/goal_src/jakx/engine/anim/mspace-h.gc b/goal_src/jakx/engine/anim/mspace-h.gc index c11718ea14..3a3bf0be35 100644 --- a/goal_src/jakx/engine/anim/mspace-h.gc +++ b/goal_src/jakx/engine/anim/mspace-h.gc @@ -7,3 +7,84 @@ ;; DECOMP BEGINS +(deftype joint (basic) + "A joint from an animated skeleton. This defines the graph of the skeleton, and also the bind pose +used for the mesh data. The joints are shared between all instances of the same model." + ((name basic) + (number int32) + (parent joint) + (bind-pose matrix :inline) + ) + ) + + +(deftype bone-cache (structure) + "Unused type. Existed in Jak 1, but wasn't used there." + ((bone-matrix uint32) + (parent-matrix uint32) + (dummy uint32) + (frame uint32) + ) + ) + + +(deftype bone (structure) + "The location and scale of a bone in an animated skeleton. Each instance of a skeleton +has its own copy of the bones. This data is used for collision checking or other gameplay math, +but, despite the name, isn't directly used in rendering." + ((transform matrix :inline) + (position vector :inline :overlay-at (-> transform data 12)) + (scale vector :inline) + ) + ) + + +(deftype skeleton (inline-array-class) + "Skeleton is an array of bones for the entire character. The bones are stored in an inline array so they can be +easily dma'd to the scratchpad later." + ((bones bone :inline :dynamic) + ) + ) + + +(set! (-> skeleton heap-base) (the-as uint 80)) + +(deftype cspace (structure) + "A cspace describes how to control a bone. It contains a reference to the joint, bone, and a callback function. +The callback function is used to take the joint transforms out of the joint animation, then update the bone." + ((parent cspace) + (joint joint) + (joint-num int16) + (geo drawable) + (bone bone) + (param0 (function cspace transformq none)) + (param1 basic) + (param2 basic) + ) + (:methods + (new (symbol type drawable) _type_) + (reset-and-assign-geo! (_type_ drawable) _type_) + ) + ) + + +(deftype cspace-array (inline-array-class) + ((data cspace :inline :dynamic) + ) + ) + + +(set! (-> cspace-array heap-base) (the-as uint 32)) + +(defmethod print ((this cspace)) + (format + #t + "#" + (if (-> this joint) + (-> this joint name) + "nojoint" + ) + this + ) + this + ) diff --git a/goal_src/jakx/engine/camera/cam-debug-h.gc b/goal_src/jakx/engine/camera/cam-debug-h.gc index 1212b8643b..eea5f8465f 100644 --- a/goal_src/jakx/engine/camera/cam-debug-h.gc +++ b/goal_src/jakx/engine/camera/cam-debug-h.gc @@ -7,3 +7,107 @@ ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) + +(define *redline-table* (the-as (pointer float) (malloc 'debug 1600))) + +(define *redline-index* 0) + +(defun float-save-redline ((arg0 float)) + (set! (-> *redline-table* *redline-index*) arg0) + (set! *redline-index* (+ *redline-index* 1)) + (when (>= *redline-index* 400) + (set! *redline-index* 0) + 0 + ) + (none) + ) + +(defun float-lookup-redline ((arg0 float)) + (let ((a0-3 (mod (+ (the int arg0) -1 *redline-index*) 400))) + (-> *redline-table* a0-3) + ) + ) + +(define *blueline-table* (the-as (pointer float) (malloc 'debug 1600))) + +(define *blueline-index* 0) + +(defun float-save-blueline ((arg0 float)) + (set! (-> *blueline-table* *blueline-index*) arg0) + (set! *blueline-index* (+ *blueline-index* 1)) + (when (>= *blueline-index* 400) + (set! *blueline-index* 0) + 0 + ) + (none) + ) + +(defun float-lookup-blueline ((arg0 float)) + (let ((a0-3 (mod (+ (the int arg0) -1 *blueline-index*) 400))) + (-> *blueline-table* a0-3) + ) + ) + +(define *greenline-table* (the-as (pointer float) (malloc 'debug 1600))) + +(define *greenline-index* 0) + +(defun float-save-greenline ((arg0 float)) + (set! (-> *greenline-table* *greenline-index*) arg0) + (set! *greenline-index* (+ *greenline-index* 1)) + (when (>= *greenline-index* 400) + (set! *greenline-index* 0) + 0 + ) + (none) + ) + +(defun float-lookup-greenline ((arg0 float)) + (let ((a0-3 (mod (+ (the int arg0) -1 *greenline-index*) 400))) + (-> *greenline-table* a0-3) + ) + ) + +(define *yellowline-table* (the-as (pointer float) (malloc 'debug 1600))) + +(define *yellowline-index* 0) + +(defun float-save-yellowline ((arg0 float)) + (set! (-> *yellowline-table* *yellowline-index*) arg0) + (set! *yellowline-index* (+ *yellowline-index* 1)) + (when (>= *yellowline-index* 400) + (set! *yellowline-index* 0) + 0 + ) + (none) + ) + +(defun float-lookup-yellowline ((arg0 float)) + (let ((a0-3 (mod (+ (the int arg0) -1 *yellowline-index*) 400))) + (-> *yellowline-table* a0-3) + ) + ) + +(define *timeplot-table* (the-as (pointer float) (malloc 'debug 1600))) + +(define *timeplot-index* 0) + +(defun float-save-timeplot ((arg0 float)) + (set! (-> *timeplot-table* *timeplot-index*) arg0) + (set! *timeplot-index* (+ *timeplot-index* 1)) + (when (>= *timeplot-index* 400) + (set! *timeplot-index* 0) + 0 + ) + (none) + ) + +(defun float-lookup-timeplot ((arg0 float)) + (let ((a0-3 (mod (+ (the int arg0) -1 *timeplot-index*) 400))) + (-> *timeplot-table* a0-3) + ) + ) + +(define-perm *cam-layout* symbol #f) diff --git a/goal_src/jakx/engine/camera/cam-interface-h.gc b/goal_src/jakx/engine/camera/cam-interface-h.gc index 804947b99e..d6d38584b7 100644 --- a/goal_src/jakx/engine/camera/cam-interface-h.gc +++ b/goal_src/jakx/engine/camera/cam-interface-h.gc @@ -5,5 +5,13 @@ ;; name in dgo: cam-interface-h ;; dgos: ENGINE, GAME +(define-extern math-camera-matrix (function matrix)) +(define-extern camera-pos (function vector)) +(define-extern math-camera-pos (function vector)) +(define-extern matrix-local->world (function symbol symbol matrix)) +(define-extern matrix-world->local (function symbol object matrix)) +(define-extern camera-matrix (function matrix)) + ;; DECOMP BEGINS +(define-perm *camera-init-mat* matrix #f) diff --git a/goal_src/jakx/engine/camera/cam-update-h.gc b/goal_src/jakx/engine/camera/cam-update-h.gc index 24fc0154a7..45a5b24f0e 100644 --- a/goal_src/jakx/engine/camera/cam-update-h.gc +++ b/goal_src/jakx/engine/camera/cam-update-h.gc @@ -5,5 +5,46 @@ ;; name in dgo: cam-update-h ;; dgos: ENGINE, GAME +;; +++external-cam-option +(defenum external-cam-option + :bitfield #t + (allow-z 0) + ) +;; ---external-cam-option + +(define-extern *camera-look-through-other* int) + ;; DECOMP BEGINS +(define *external-cam-options* (the-as external-cam-option 0)) + +(define *external-cam-mode* #f) + +(when (or (not *camera-look-through-other*) (zero? *camera-look-through-other*)) + (set! *camera-look-through-other* 0) + 0 + ) + +(define-perm *camera-other-fov* bfloat (new 'static 'bfloat :data 11650.845)) + +(define-perm *camera-other-trans* vector (vector-reset! (new 'global 'vector))) + +(define-perm *camera-other-matrix* matrix (matrix-identity! (new 'global 'matrix))) + +(define-perm *camera-smush-control* smush-control (set-zero! (new 'global 'smush-control))) + +(define-perm *camera-smush-control-horizontal* smush-control (set-zero! (new 'global 'smush-control))) + +(define-perm *camera-smush-control-into* smush-control (set-zero! (new 'global 'smush-control))) + +(define-perm *camera-smush-control-2* smush-control (set-zero! (new 'global 'smush-control))) + +(define-perm *camera-smush-control-horizontal-2* smush-control (set-zero! (new 'global 'smush-control))) + +(define-perm *camera-smush-control-into-2* smush-control (set-zero! (new 'global 'smush-control))) + +(define-perm *camera-other-root* vector (vector-reset! (new 'global 'vector))) + +(define *fix-visible-level-mask* 6) + +(define *manual-sample-point* #f) diff --git a/goal_src/jakx/engine/camera/camera-defs-h.gc b/goal_src/jakx/engine/camera/camera-defs-h.gc index c7ce771300..bf5fda52a3 100644 --- a/goal_src/jakx/engine/camera/camera-defs-h.gc +++ b/goal_src/jakx/engine/camera/camera-defs-h.gc @@ -7,3 +7,55 @@ ;; DECOMP BEGINS +(deftype camera-bank (basic) + ((collide-move-rad float) + (joypad uint32) + (min-detectable-velocity float) + (attack-timeout time-frame) + (default-string-max-y meters) + (default-string-min-y meters) + (default-string-max-z meters) + (default-string-min-z meters) + (default-string-push-z meters) + (default-tilt-adjust degrees) + ) + ) + + +(define *CAMERA-bank* (new 'static 'camera-bank + :collide-move-rad 1638.4 + :min-detectable-velocity 40.96 + :attack-timeout (seconds 0.25) + :default-string-max-y (meters 3) + :default-string-min-y (meters 1) + :default-string-max-z (meters 12.5) + :default-string-min-z (meters 5) + :default-string-push-z (meters 10) + :default-tilt-adjust (degrees -6.5000005) + ) + ) + +(deftype camera-master-bank (basic) + ((onscreen-head-height meters) + (onscreen-foot-height meters) + (target-height meters) + (up-move-to-pitch-ratio-in-air float) + (down-move-to-pitch-ratio-in-air float) + (up-move-to-pitch-on-ground float) + (down-move-to-pitch-on-ground float) + (pitch-off-blend float) + ) + ) + + +(define *CAMERA_MASTER-bank* (new 'static 'camera-master-bank + :onscreen-head-height (meters 2.65) + :onscreen-foot-height (meters -0.5) + :target-height (meters 2.15) + :up-move-to-pitch-ratio-in-air 1.0 + :down-move-to-pitch-ratio-in-air 0.5 + :up-move-to-pitch-on-ground 0.9 + :down-move-to-pitch-on-ground 0.9 + :pitch-off-blend 0.5 + ) + ) diff --git a/goal_src/jakx/engine/camera/camera-h.gc b/goal_src/jakx/engine/camera/camera-h.gc index b6929801a3..59264de4b8 100644 --- a/goal_src/jakx/engine/camera/camera-h.gc +++ b/goal_src/jakx/engine/camera/camera-h.gc @@ -5,5 +5,57 @@ ;; name in dgo: camera-h ;; dgos: ENGINE, GAME -;; DECOMP BEGINS +;; +++cam-index-options +(defenum cam-index-options + :type uint32 + :bitfield #t + (SPHERICAL) + (RADIAL) + ) +;; ---cam-index-options +;; +++slave-los-state +(defenum slave-los-state + :type uint32 + (none 0) + (cw 1) + (ccw 2) + (between 3) + ) +;; ---slave-los-state + +;; +++camera-blend-to-type +(defenum camera-blend-to-type + :type uint64 + (unknown-0 0) + (unknown-1 1) + (unknown-2 2) + ) +;; ---camera-blend-to-type + +;; +++camera-blend-from-type +(defenum camera-blend-from-type + :type uint64 + (unknown-0 0) + (unknown-1 1) + (unknown-2 2) + ) +;; ---camera-blend-from-type + +;; +++cam-slave-options-u32 +(defenum cam-slave-options-u32 + :type uint32 + :bitfield #t + :copy-entries cam-slave-options + ) +;; ---cam-slave-options-u32 + +;; +++cam-master-options-u32 +(defenum cam-master-options-u32 + :type uint32 + :bitfield #t + :copy-entries cam-master-options + ) +;; ---cam-master-options-u32 + +;; DECOMP BEGINS diff --git a/goal_src/jakx/engine/camera/pov-camera-h.gc b/goal_src/jakx/engine/camera/pov-camera-h.gc index e589872b9c..7b83b92b6a 100644 --- a/goal_src/jakx/engine/camera/pov-camera-h.gc +++ b/goal_src/jakx/engine/camera/pov-camera-h.gc @@ -6,4 +6,3 @@ ;; dgos: ENGINE, GAME ;; DECOMP BEGINS - diff --git a/goal_src/jakx/engine/collide/collide-cache-h.gc b/goal_src/jakx/engine/collide/collide-cache-h.gc index de1f98b9b6..32e574981d 100644 --- a/goal_src/jakx/engine/collide/collide-cache-h.gc +++ b/goal_src/jakx/engine/collide/collide-cache-h.gc @@ -5,5 +5,166 @@ ;; name in dgo: collide-cache-h ;; dgos: ENGINE, GAME +;; +++prim-type +(defenum prim-type + :type int8 + (prim -2) + (sphere -1) + (group 0) + (mesh 1) + (fake-prim 2) + ) +;; ---prim-type + +(declare-type collide-cache-prim structure) +(declare-type collide-using-spheres-params structure) +(declare-type instance-tie structure) +(declare-type collide-list structure) + ;; DECOMP BEGINS +(deftype collide-puss-sphere (structure) + "A query sphere from the user for the porbe-using-spheres query. +This is used internally by the collide-cache implementation." + ((bsphere sphere :inline) + (bbox4w bounding-box4w :inline) + ) + ) + + +(deftype collide-puss-work (structure) + "Scratchpad memory map for probe-using-spheres query." + ((closest-pt vector :inline) + (tri-normal vector :inline) + (tri-bbox4w bounding-box4w :inline) + (spheres-bbox4w bounding-box4w :inline) + (spheres collide-puss-sphere 64 :inline) + ) + (:methods + (check-mesh-prim-against-spheres (_type_ collide-cache-prim collide-using-spheres-params) symbol) + (check-sphere-prim-against-spheres (_type_ collide-cache-prim collide-using-spheres-params) symbol) + ) + ) + + +(deftype collide-cache-tri (structure) + "A single triangle inside the collision cache. +Contains a reference back to the source object (like a collide-shape or water-control), and the prim itself." + ((vertex vector 3 :inline) + (extra-quad uint8 16) + (pat pat-surface :overlay-at (-> extra-quad 0)) + (collide-ptr basic :overlay-at (-> extra-quad 4)) + (prim-index uint16 :overlay-at (-> extra-quad 8)) + (user16 uint16 :overlay-at (-> extra-quad 10)) + (user32 uint32 :overlay-at (-> extra-quad 12)) + (clear-flags uint128 :overlay-at (-> extra-quad 0)) + ) + ) + + +(deftype collide-cache-prim (structure) + "A primitive inside the collide-cache. +This can represent a sphere, a triangle mesh, or a group of other primitives within a bounding sphere." + ((prim-core collide-prim-core :inline) + (extra-quad uint8 16) + (ccache collide-cache :overlay-at (-> extra-quad 0)) + (prim collide-shape-prim :overlay-at (-> extra-quad 4)) + (first-tri uint16 :overlay-at (-> extra-quad 8)) + (num-tris uint16 :overlay-at (-> extra-quad 10)) + (extra basic :overlay-at (-> extra-quad 12)) + (world-sphere vector :inline :overlay-at (-> prim-core world-sphere)) + (collide-as collide-spec :overlay-at (-> prim-core collide-as)) + (action collide-action :overlay-at (-> prim-core action)) + (prim-type prim-type :overlay-at (-> prim-core prim-type)) + ) + (:methods + (resolve-moving-sphere-tri (_type_ collide-query sphere vector float collide-action) float) + (resolve-moving-sphere-sphere (_type_ collide-query sphere vector float collide-action) float) + ) + ) + + +(deftype collide-cache (basic) + "The collide-cache is a structure to accelerate collision queries. +In particular, it helps with queries where you don't know what you might hit. +It can detect collision with the background geometry, foreground dynamic collision shapes (spheres and meshes), and water. +To use it, it must first be 'filled' with geometry. Then you can manually inspect the geometry, or use one of the queries. +The supported queries are 'line-sphere' (raycast) and 'spheres' (check if intersecting anything). +It is not useful for ollision queries against a specific foreground object, like 'am I on top of platform X right now?'." + ((num-tris int32) + (max-tris int32) + (num-prims int32) + (max-prims int32) + (ignore-mask pat-surface) + (ignore-processes process 2) + (collide-box bounding-box :inline) + (collide-box4w bounding-box4w :inline) + (collide-with collide-spec) + (unused uint32 3) + (prims collide-cache-prim 4) + (tris collide-cache-tri) + ) + (:methods + (new (symbol type int int) _type_) + (collide-cache-method-9 () none) + (collide-cache-method-10 () none) + (collide-cache-method-11 () none) + (collide-cache-method-12 () none) + (collide-cache-method-13 () none) + (collide-cache-method-14 () none) + (collide-cache-method-15 () none) + (collide-cache-method-16 () none) + (collide-cache-method-17 () none) + (collide-cache-method-18 () none) + (collide-cache-method-19 () none) + (collide-cache-method-20 () none) + (collide-cache-method-21 () none) + (collide-cache-method-22 () none) + (collide-cache-method-23 () none) + (collide-cache-method-24 () none) + (collide-cache-method-25 () none) + (collide-cache-method-26 () none) + (collide-cache-method-27 () none) + ) + ) + + +(deftype collide-list-item (structure) + "Entry on the broad-phase collision list. +Can represent instanced collision, as a TIE instance, or a single non-instanced mesh fragment." + ((mesh instance-tie) + (inst basic) + ) + :pack-me + ) + + +(deftype collide-list (structure) + "List of items returned by the broad-phase collision query." + ((num-items int32) + (items collide-list-item 256 :inline :offset 16) + ) + ) + + +(defmethod new collide-cache ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int)) + (let* ((s3-0 (logand -16 (+ (-> type-to-make size) 19))) + (gp-0 (* 48 arg0)) + (v1-3 (* (+ arg1 1) 64)) + (v0-0 (object-new allocation type-to-make (the-as int (+ s3-0 gp-0 v1-3)))) + ) + (set! (-> v0-0 max-tris) arg1) + (set! (-> v0-0 max-prims) arg0) + (set! (-> v0-0 prims 0) (the-as collide-cache-prim (logand -16 (+ (+ s3-0 15) (the-as uint v0-0))))) + (set! (-> v0-0 tris) (the-as collide-cache-tri (+ (the-as uint (-> v0-0 prims 0)) gp-0))) + v0-0 + ) + ) + +(kmemopen global "collide-cache-buffers") + +(define-perm *collide-cache* collide-cache (new 'global 'collide-cache 100 460)) + +(define-perm *collide-list* collide-list (new 'global 'collide-list)) + +(kmemclose) diff --git a/goal_src/jakx/engine/collide/collide-frag-h.gc b/goal_src/jakx/engine/collide/collide-frag-h.gc index 486b6b1d20..b785359a90 100644 --- a/goal_src/jakx/engine/collide/collide-frag-h.gc +++ b/goal_src/jakx/engine/collide/collide-frag-h.gc @@ -7,3 +7,43 @@ ;; DECOMP BEGINS +(deftype collide-frag-vertex (vector) + () + ) + + +(deftype collide-frag-mesh (basic) + "Unused Jak 1 background collision mesh fragment." + ((packed-data uint32) + (pat-array uint32) + (strip-data-len uint16) + (poly-count uint16) + (base-trans vector4w :inline) + (vertex-count uint8 :overlay-at (-> base-trans data 3)) + (vertex-data-qwc uint8 :offset 29) + (total-qwc uint8 :offset 30) + (unused uint8 :offset 31) + ) + ) + + +(deftype collide-fragment (drawable) + "Unused Jak 1 background collision drawable tree node." + ((mesh collide-frag-mesh :offset 8) + (collide-new basic :offset 12) + ) + ) + + +(deftype drawable-inline-array-collide-fragment (drawable-inline-array) + "Unused Jak 1 background collision drawable tree inline-array class." + ((data collide-fragment 1 :inline) + (pad uint32) + ) + ) + + +(deftype drawable-tree-collide-fragment (drawable-tree) + "Unused jak 1 background collision data." + () + ) diff --git a/goal_src/jakx/engine/collide/collide-func-h.gc b/goal_src/jakx/engine/collide/collide-func-h.gc index e366b63c26..33ac8b229f 100644 --- a/goal_src/jakx/engine/collide/collide-func-h.gc +++ b/goal_src/jakx/engine/collide/collide-func-h.gc @@ -6,4 +6,3 @@ ;; dgos: ENGINE, GAME ;; DECOMP BEGINS - diff --git a/goal_src/jakx/engine/collide/collide-h.gc b/goal_src/jakx/engine/collide/collide-h.gc index 89276c76f3..bee6d44f73 100644 --- a/goal_src/jakx/engine/collide/collide-h.gc +++ b/goal_src/jakx/engine/collide/collide-h.gc @@ -7,3 +7,50 @@ ;; DECOMP BEGINS +(deftype collide-query (structure) + "Very general collision-query structure. The meaning is different depending on where it used. +This has both inputs from the user, and collision results." + ((best-other-tri collide-tri-result :inline) + (best-my-tri collide-tri-result :inline :overlay-at best-other-tri) + (ignore-processes process-tree 2) + (ignore-process0 process-tree :overlay-at (-> ignore-processes 0)) + (ignore-process1 process-tree :overlay-at (-> ignore-processes 1)) + (ignore-pat pat-surface) + (ignore-pat-s32 int32 :overlay-at ignore-pat) + (collide-with collide-spec) + (collide-with-s32 int32 :overlay-at collide-with) + (overlay-params uint32 3 :offset 112) + (bbox bounding-box :inline) + (bbox4w bounding-box4w :inline) + (bsphere sphere :inline) + (start-pos vector :inline) + (move-dist vector :inline) + (rlength vector :inline) + (exit-planes plane 2 :inline) + (radius float :overlay-at (-> exit-planes 0 data 3)) + (inv-mat matrix :inline :offset 288) + (spheres (inline-array sphere) :overlay-at (-> overlay-params 0)) + (num-spheres uint32 :overlay-at (-> overlay-params 1)) + (solid-only symbol :overlay-at (-> overlay-params 2)) + (best-dist float :overlay-at spheres) + (best-other-prim collide-shape-prim :overlay-at num-spheres) + (best-my-prim collide-shape-prim :overlay-at solid-only) + (move-vec vector :inline :overlay-at move-dist) + (best-u float :overlay-at best-dist) + (action-mask collide-action :offset 352) + (local-box4w bounding-box4w :inline) + (search-box bounding-box4w :inline) + (search-vector vector4w :inline) + (instance-mat matrix :inline) + (instance-ptr basic) + (x-addr uint32) + (x-step uint32) + (y-addr uint32) + (y-step uint32) + (z-addr uint32) + (z-step uint32) + ) + ) + + +(define *collide-test-flag* #f) diff --git a/goal_src/jakx/engine/collide/collide-mesh-h.gc b/goal_src/jakx/engine/collide/collide-mesh-h.gc index 8a5d9404e2..fe4991c72b 100644 --- a/goal_src/jakx/engine/collide/collide-mesh-h.gc +++ b/goal_src/jakx/engine/collide/collide-mesh-h.gc @@ -5,5 +5,102 @@ ;; name in dgo: collide-mesh-h ;; dgos: ENGINE, GAME +(declare-type collide-mesh-cache-tri structure) +(declare-type collide-shape-prim-mesh basic) + ;; DECOMP BEGINS +(deftype collide-tri-result (structure) + "A triangle result of a collision." + ((vertex vector 3 :inline) + (intersect vector :inline) + (normal vector :inline) + (pat pat-surface) + (collide-ptr basic) + ) + ) + + +(deftype collide-mesh-tri (structure) + "A triangle for foreground collision meshes." + ((vertex-index uint8 3) + (unused uint8) + (pat pat-surface) + ) + :pack-me + ) + + +(deftype collide-mesh (basic) + "A collision mesh for foreground objects, +bound to the joint specified by `joint-id`." + ((joint-id int32) + (num-tris uint32) + (num-verts uint32) + (vertex-data (inline-array vector)) + (tris collide-mesh-tri 1 :inline :offset 32) + ) + (:methods + (debug-draw-tris (_type_ process-drawable int) none) + (overlap-test (_type_ collide-mesh-cache-tri vector) symbol) + (should-push-away-test (_type_ collide-mesh-cache-tri collide-tri-result vector float) float) + (sphere-on-platform-test (_type_ collide-mesh-cache-tri collide-tri-result vector float) float) + (unpack-mesh-to-cache! (_type_ (inline-array collide-mesh-cache-tri) matrix) none) + (collide-mesh-math-1 (_type_ object object) none) + (collide-mesh-math-2 (_type_ object object object) none) + ) + ) + + +(deftype collide-mesh-cache-tri (structure) + "A triangle stored in the foreground mesh collide cache." + ((vertex vector 3 :inline) + (normal vector :inline) + (bbox4w bounding-box4w :inline) + (pat pat-surface :overlay-at (-> normal data 3)) + ) + ) + + +(deftype collide-mesh-cache-entry (structure) + "A foreground mesh collide cache entry." + ((mat matrix :inline) + (tris collide-mesh-cache-tri :inline :dynamic) + ) + ) + + +(deftype collide-mesh-cache (basic) + "A collide cache for foreground meshes." + ((used-size uint32) + (max-size uint32) + (id uint32) + (data uint8 48000) + ) + (:methods + (populate-for-prim-mesh (_type_ collide-shape-prim-mesh) collide-mesh-cache-entry) + (is-id? (_type_ int) symbol) + (next-id! (_type_) uint) + (allocate! (_type_ int) collide-mesh-cache-entry) + ) + ) + + +;; ERROR: function was not converted to expressions. Cannot decompile. + +(defmethod is-id? ((this collide-mesh-cache) (id int)) + "Does this cache have the given ID?" + (= (-> this id) id) + ) + +(kmemopen global "collide-mesh-cache") + +(define-perm *collide-mesh-cache* collide-mesh-cache (new 'global 'collide-mesh-cache)) + +(set! (-> *collide-mesh-cache* id) (the-as uint 1)) + +(set! (-> *collide-mesh-cache* used-size) (the-as uint 0)) + +(set! (-> *collide-mesh-cache* max-size) (the-as uint #xbb80)) + +(kmemclose) diff --git a/goal_src/jakx/engine/collide/collide-shape-h.gc b/goal_src/jakx/engine/collide/collide-shape-h.gc index 598653366c..66fd75ac5f 100644 --- a/goal_src/jakx/engine/collide/collide-shape-h.gc +++ b/goal_src/jakx/engine/collide/collide-shape-h.gc @@ -5,5 +5,510 @@ ;; name in dgo: collide-shape-h ;; dgos: ENGINE, GAME +;; +++overlaps-others-options +(defenum overlaps-others-options + :type uint32 + :bitfield #t + (oo0) + (oo1) + (oo2) + (oo3) + (oo4) + ) +;; ---overlaps-others-options + +;; +++collide-action +(defenum collide-action + :bitfield #t + :type uint32 + (solid 0) ;; 1 + (semi-solid 1) ;; 2 + (rideable 2) ;; 4 + (can-ride 3) ;; 8 + (dont-push-away 4) ;; 16 + (pull-rider-can-collide 5) ;; 32 + (deadly 6) ;; 64 + (persistent-attack 7) ;; 128 + (no-smack 8) ;; 256 + (no-standon 9) ;; 512 + (block-turn-around 10) ;; 1024 + (check-edge 11) ;; 2048 + (check-stuck 12) ;; 4096 + (stuck-wall-escape 13) ;; 8192 + (no-normal-reset 14) ;; 163884 + (edge-grabbed 15) ;; 32768 + (nav-sphere 16) ;; hi 1 + ) +;; ---collide-action + +;; +++collide-list-enum +(defenum collide-list-enum + (hit-by-player) + (usually-hit-by-player) + (hit-by-others) + (player) + ) +;; ---collide-list-enum + +;; +++nav-flags +(defenum nav-flags + :type uint8 + :bitfield #t + (has-root-sphere 0) + (has-extra-sphere 1) + (has-child-spheres 2) + ) +;; ---nav-flags + +;; +++collide-status +(defenum collide-status + :bitfield #t + :type uint64 + (on-surface 0) + (on-ground 1) + (touch-surface 2) + (touch-wall 3) + (touch-ceiling 4) + (touch-actor 5) + (on-special-surface 6) + (touch-edge 7) + (no-touch 8) + (blocked 9) + (on-water 10) + (impact-surface 11) + (touch-background 12) + (stuck 13) + (touch-ceiling-sticky 14) + (glance 15) + (probe-hit 16) + ) +;; ---collide-status + +(declare-type collide-shape trsqv) +(declare-type collide-shape-moving collide-shape) +(declare-type control-info collide-shape-moving) +(declare-type touching-list structure) +(declare-type collide-query structure) +(declare-type water-info structure) +(declare-type collide-shape-prim-group basic) +(declare-type collide-cache-prim structure) +(declare-type collide-shape-prim basic) +(declare-type collide-cache basic) +(declare-type rigid-body structure) + +(define-extern cshape-reaction-update-state (function control-info collide-query vector none)) +(define-extern cshape-reaction-just-move (function control-info collide-query vector collide-status)) +(define-extern collide-shape-draw-debug-marks (function none)) + ;; DECOMP BEGINS +(deftype collide-rider (structure) + "Something that rides a moving object." + ((rider-handle handle) + (sticky-prim collide-shape-prim) + (prim-ry float) + (rider-local-pos vector :inline) + ) + ) + + +(deftype collide-rider-pool (basic) + "A pool containing all the riders of an object." + ((alloc-count int32) + (riders collide-rider 20 :inline) + ) + (:methods + (add-rider (_type_ handle) collide-rider) + (prepare (_type_) none) + ) + ) + + +(defmethod prepare ((this collide-rider-pool)) + "Gets this pool ready to be used to allow allocations. This should be called once at the start of every frame." + (set! (-> this alloc-count) 0) + 0 + (none) + ) + +(deftype pull-rider-info (structure) + ((rider collide-rider) + (rider-cshape collide-shape-moving) + (rider-delta-ry float) + (rider-dest vector :inline) + ) + ) + + +(kmemopen global "collide-lists") + +(define *collide-hit-by-player-list* (new 'global 'engine 'collide-hit-by-player-list 640 connection)) + +(define *collide-hit-by-others-list* (new 'global 'engine 'collide-hit-by-others-list 768 connection)) + +(define *collide-player-list* (new 'global 'engine 'collide-player-list 32 connection)) + +(kmemclose) + +(deftype overlaps-others-params (structure) + ((options overlaps-others-options) + (collide-with-filter collide-spec) + (tlist touching-list) + (filtered-root-collide-with collide-spec) + (filtered-child-collide-with collide-spec) + (filtered-other-collide-as collide-spec) + ) + ) + + +(deftype move-above-ground-params (structure) + ((gnd-collide-with collide-spec) + (popup float) + (dont-move-if-overlaps? symbol) + (hover-if-no-ground? symbol) + (overlaps-params overlaps-others-params :inline) + (new-pos vector :inline) + (old-gspot-pos vector :inline) + (old-gspot-normal vector :inline) + (pat pat-surface) + (on-ground? symbol) + (do-move? symbol) + ) + ) + + +(deftype collide-prim-core (structure) + "Collide primitives use this to store their world sphere and their collision flags." + ((world-sphere vector :inline) + (collide-as collide-spec) + (collide-with collide-spec) + (action collide-action) + (prim-type int8) + (unused1 uint8 3) + (quad uint128 2 :overlay-at (-> world-sphere data 0)) + ) + ) + + +(deftype collide-shape-prim (basic) + "Base class for collide primitives." + ((cshape collide-shape) + (prim-id uint32) + (transform-index int8) + (unused2 int8 3) + (prim-core collide-prim-core :inline :offset 16) + (local-sphere vector :inline :offset 48) + (specific uint8 16 :offset 64) + (world-sphere vector :inline :overlay-at (-> prim-core quad 0)) + (collide-as collide-spec :overlay-at (-> prim-core quad 1)) + (collide-with collide-spec :offset 36) + (action collide-action :offset 40) + (prim-type int8 :offset 44) + (radius meters :overlay-at (-> local-sphere w)) + ) + (:methods + (new (symbol type collide-shape uint int) _type_) + (debug-draw (_type_) none) + (add-fg-prim-using-box (_type_ collide-cache) none) + (add-fg-prim-using-line-sphere (_type_ collide-cache object) none) + (overlaps-others-test (_type_ overlaps-others-params collide-shape-prim) symbol) + (overlaps-others-group (_type_ overlaps-others-params collide-shape-prim-group) symbol) + (collide-shape-prim-method-14 () none) + (collide-with-collide-cache-prim-mesh (_type_ collide-query collide-cache-prim) none) + (collide-with-collide-cache-prim-sphere (_type_ collide-query collide-cache-prim) none) + (on-platform-test (_type_ collide-shape-prim collide-query float) none) + (should-push-away-test (_type_ collide-shape-prim collide-query) none) + (should-push-away-a-group-test (_type_ collide-shape-prim-group collide-query) none) + ) + ) + + +(deftype collide-shape-prim-sphere (collide-shape-prim) + "A sphere primitive for collide shapes." + ((pat pat-surface :overlay-at (-> specific 0)) + (nav-radius float :overlay-at (-> specific 4)) + (line-sphere-count int8 :overlay-at (-> specific 8)) + (line-sphere-prim-id int8 :overlay-at (-> specific 9)) + ) + (:methods + (new (symbol type collide-shape uint) _type_) + ) + ) + + +(deftype collide-shape-prim-mesh (collide-shape-prim) + "A mesh primitive for collide shapes." + ((mesh collide-mesh :overlay-at (-> specific 0)) + (mesh-id int32 :overlay-at (-> specific 4)) + (mesh-cache-id uint32 :overlay-at (-> specific 8)) + (mesh-cache-entry collide-mesh-cache-entry :overlay-at (-> specific 12)) + ) + (:methods + (new (symbol type collide-shape uint uint) _type_) + ) + ) + + +(deftype collide-shape-prim-group (collide-shape-prim) + "A group of collide primitives." + ((num-children uint8 :overlay-at (-> specific 0)) + (num-alloc-children uint8 :overlay-at (-> specific 1)) + (child (inline-array collide-shape-prim) :overlay-at (-> specific 4)) + ) + (:methods + (new (symbol type collide-shape uint int) _type_) + ) + ) + + +(deftype collide-shape (trsqv) + "The parent of all of an object's collide primitives. +Most [[process-drawable]]s have a [[collide-shape]] that represents their root transform." + ((actor-hash-index int16 :offset 12) + (process process-drawable) + (max-iteration-count uint8) + (nav-flags nav-flags) + (total-prims uint8) + (num-riders uint8) + (pat-ignore-mask pat-surface) + (event-self symbol :offset 152) + (event-other symbol) + (root-prim collide-shape-prim) + (riders (inline-array collide-rider)) + (penetrate-using penetrate) + (penetrated-by penetrate) + (backup-collide-as collide-spec) + (backup-collide-with collide-spec) + (event-priority uint8 :offset 192) + (rider-max-momentum float) + ) + (:methods + (new (symbol type process-drawable collide-list-enum) _type_) + (move-by-vector! (_type_ vector) none) + (move-to-point! (_type_ vector) none) + (debug-draw (_type_) none) + (fill-cache-for-shape (_type_ float collide-query) none) + (fill-cache-integrate-and-collide (_type_ vector collide-query meters) none) + (find-prim-by-id (_type_ uint) collide-shape-prim) + (find-prim-by-id-logtest (_type_ uint) collide-shape-prim) + (detect-riders! (_type_) symbol) + (build-bounding-box-for-shape (_type_ bounding-box float collide-spec) symbol) + (integrate-and-collide! (_type_ vector) none) + (find-collision-meshes (_type_) none) + (on-platform (_type_ collide-shape collide-query) symbol) + (find-overlapping-shapes (_type_ overlaps-others-params) symbol) + (shove-to-closest-point-on-path (_type_ attack-info float) vector) + (should-push-away (_type_ collide-shape collide-query) symbol) + (pull-rider! (_type_ pull-rider-info) none) + (pull-riders! (_type_) symbol) + (do-push-aways (_type_) collide-spec) + (update-transforms (_type_) none) + (set-collide-with! (_type_ collide-spec) none) + (set-collide-as! (_type_ collide-spec) none) + (modify-collide-as! (_type_ int collide-spec collide-spec) none) + (send-shoves (_type_ process touching-shapes-entry float float float) symbol) + (above-ground? (_type_ collide-query vector collide-spec float float float) symbol) + (water-info-init! (_type_ water-info collide-action) water-info) + (iterate-prims (_type_ (function collide-shape-prim none)) none) + (pusher-init (_type_) none) + ) + ) + + +(deftype collide-shape-moving (collide-shape) + "A [[collide-shape]] for moving objects." + ((rider-time uint64) + (rider-last-move vector :inline) + (trans-old vector :inline) + (poly-pat pat-surface :offset 272) + (cur-pat pat-surface) + (ground-pat pat-surface) + (status uint64) + (reaction (function control-info collide-query vector vector collide-status) :offset 316) + (no-reaction (function collide-shape-moving collide-query vector vector object)) + (local-normal vector :inline) + (surface-normal vector :inline) + (poly-normal vector :inline) + (ground-poly-normal vector :inline) + (gspot-pos vector :inline) + (gspot-normal vector :inline) + (ground-touch-point vector :inline) + (ground-impact-vel meters) + (surface-angle float) + (poly-angle float) + (touch-angle float) + (coverage float) + (dynam dynamics) + ) + (:methods + (new (symbol type process-drawable collide-list-enum) _type_) + (collide-shape-moving-method-55 () none) + (collide-shape-moving-method-56 () none) + (collide-shape-moving-method-57 () none) + (collide-shape-moving-method-58 () none) + (collide-shape-moving-method-59 () none) + (collide-shape-moving-method-60 () none) + (collide-shape-moving-method-61 () none) + (collide-shape-moving-method-62 () none) + (collide-shape-moving-method-63 () none) + (collide-shape-moving-method-64 () none) + (collide-shape-moving-method-65 () none) + (collide-shape-moving-method-66 () none) + ) + ) + + +(defmethod new collide-shape-prim ((allocation symbol) (type-to-make type) (arg0 collide-shape) (arg1 uint) (arg2 int)) + (let ((v0-0 (object-new allocation type-to-make arg2))) + (set! (-> v0-0 cshape) arg0) + (set! (-> v0-0 prim-id) arg1) + (set! (-> v0-0 prim-core action) (collide-action)) + (set! (-> v0-0 prim-core collide-as) (collide-spec)) + (set! (-> v0-0 prim-core collide-with) (collide-spec)) + (set! (-> v0-0 transform-index) -2) + (set! (-> v0-0 prim-core prim-type) -2) + v0-0 + ) + ) + +;; WARN: Return type mismatch collide-shape-prim vs collide-shape-prim-sphere. +(defmethod new collide-shape-prim-sphere ((allocation symbol) (type-to-make type) (arg0 collide-shape) (arg1 uint)) + (let ((v0-0 ((method-of-type collide-shape-prim new) allocation type-to-make arg0 arg1 80))) + (set! (-> (the-as collide-shape-prim-sphere v0-0) pat) + (new 'static 'pat-surface :mode (pat-mode obstacle) :material (pat-material stone)) + ) + (set! (-> (the-as collide-shape-prim-sphere v0-0) prim-core prim-type) -1) + (the-as collide-shape-prim-sphere v0-0) + ) + ) + +;; WARN: Return type mismatch collide-shape-prim vs collide-shape-prim-mesh. +(defmethod new collide-shape-prim-mesh ((allocation symbol) (type-to-make type) (arg0 collide-shape) (arg1 uint) (arg2 uint)) + (let ((v0-0 ((method-of-type collide-shape-prim new) allocation type-to-make arg0 arg2 80))) + (set! (-> (the-as collide-shape-prim-mesh v0-0) mesh) #f) + (set! (-> (the-as collide-shape-prim-mesh v0-0) mesh-id) (the-as int arg1)) + (set! (-> (the-as collide-shape-prim-mesh v0-0) mesh-cache-id) (the-as uint 0)) + (set! (-> (the-as collide-shape-prim-mesh v0-0) prim-core prim-type) 1) + (the-as collide-shape-prim-mesh v0-0) + ) + ) + +;; WARN: Return type mismatch collide-shape-prim vs collide-shape-prim-group. +(defmethod new collide-shape-prim-group ((allocation symbol) (type-to-make type) (arg0 collide-shape) (arg1 uint) (arg2 int)) + (let ((v0-0 ((method-of-type collide-shape-prim new) allocation type-to-make arg0 (the-as uint arg2) 80))) + (set! (-> (the-as collide-shape-prim-group v0-0) num-children) arg1) + (set! (-> (the-as collide-shape-prim-group v0-0) num-alloc-children) arg1) + (set! (-> (the-as collide-shape-prim-group v0-0) prim-core prim-type) 0) + (set! (-> (the-as collide-shape-prim-group v0-0) child) + (the-as (inline-array collide-shape-prim) (&+ (the-as collide-shape-prim-group v0-0) 80)) + ) + (the-as collide-shape-prim-group v0-0) + ) + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod length ((this collide-shape-prim-group)) + (the-as int (-> this num-children)) + ) + +(defmethod new collide-shape ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 collide-list-enum)) + (let ((s5-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s5-0 actor-hash-index) -1) + (set! (-> s5-0 process) arg0) + (set! (-> s5-0 max-iteration-count) (the-as uint 1)) + (set! (-> s5-0 nav-flags) (nav-flags has-root-sphere)) + (set! (-> s5-0 event-self) #f) + (set! (-> s5-0 event-other) #f) + (set! (-> s5-0 riders) (the-as (inline-array collide-rider) #f)) + (set! (-> s5-0 root-prim) #f) + (set! (-> s5-0 penetrate-using) (penetrate)) + (set! (-> s5-0 penetrated-by) (penetrate)) + (set! (-> s5-0 event-priority) (the-as uint 0)) + (set! (-> s5-0 rider-max-momentum) 409600.0) + (case (-> arg0 type symbol) + (('camera) + (set! (-> s5-0 pat-ignore-mask) + (new 'static 'pat-surface :nocamera #x1 :nogrind #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + ) + (('target) + (set! (-> s5-0 pat-ignore-mask) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :board #x1)) + ) + (else + (set! (-> s5-0 pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + ) + ) + (set! (-> s5-0 trans w) 1.0) + (quaternion-identity! (the-as quaternion (-> s5-0 rot))) + (vector-identity! (-> s5-0 scale)) + (cond + ((= arg1 (collide-list-enum hit-by-player)) + (add-connection *collide-hit-by-player-list* arg0 #f s5-0 #f #f) + ) + ((= arg1 (collide-list-enum usually-hit-by-player)) + (add-connection *collide-hit-by-others-list* arg0 #f s5-0 #f #f) + ) + ((= arg1 (collide-list-enum hit-by-others)) + (add-connection *collide-player-list* arg0 #f s5-0 #f #f) + ) + (else + (format 0 "Unsupported collide-list-enum in collide-shape constructor!~%") + ) + ) + s5-0 + ) + ) + +(defmethod new collide-shape-moving ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 collide-list-enum)) + (let ((v0-0 ((method-of-type collide-shape new) allocation type-to-make arg0 arg1))) + (set! (-> (the-as collide-shape-moving v0-0) gspot-pos y) -40959590.0) + (set! (-> (the-as collide-shape-moving v0-0) gspot-normal quad) (-> *y-vector* quad)) + (the-as collide-shape-moving v0-0) + ) + ) + +(define *collide-shape-prim-backgnd* + (new 'static 'collide-shape-prim-mesh + :cshape #f + :prim-core (new 'static 'collide-prim-core + :world-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :collide-as (collide-spec backgnd) + :action (collide-action solid) + :prim-type 2 + ) + :local-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :mesh #f + ) + ) + +(define *collide-shape-prim-water* + (new 'static 'collide-shape-prim-mesh + :cshape #f + :prim-core (new 'static 'collide-prim-core + :world-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :collide-as (collide-spec water) + :action (collide-action solid) + :prim-type 2 + ) + :local-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :mesh #f + ) + ) + +(define *collide-shape-prim-nav-mesh* + (new 'static 'collide-shape-prim-mesh + :cshape #f + :prim-core (new 'static 'collide-prim-core + :world-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :collide-as (collide-spec nav-mesh) + :action (collide-action solid) + :prim-type 2 + ) + :local-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :mesh #f + ) + ) + +(define-perm *collide-rider-pool* collide-rider-pool (new 'global 'collide-rider-pool)) diff --git a/goal_src/jakx/engine/collide/collide-touch-h.gc b/goal_src/jakx/engine/collide/collide-touch-h.gc index 0b5e820b03..d60997d950 100644 --- a/goal_src/jakx/engine/collide/collide-touch-h.gc +++ b/goal_src/jakx/engine/collide/collide-touch-h.gc @@ -7,3 +7,148 @@ ;; DECOMP BEGINS +(deftype touching-prim (structure) + "A collide primitive that's touching another. +Potentially also stores the triangle that is involved." + ((cprim collide-shape-prim) + (has-tri? symbol) + (tri collide-tri-result :inline) + ) + ) + + +(deftype touching-prims-entry (structure) + "A record of two primitives touching." + ((next touching-prims-entry) + (prev touching-prims-entry) + (allocated? symbol) + (u float) + (prim1 touching-prim :inline) + (prim2 touching-prim :inline) + ) + (:methods + (touching-prims-entry-method-9 (_type_ vector) vector) + (get-middle-of-bsphere-overlap (_type_ vector) vector) + (get-touched-prim (_type_ collide-shape touching-shapes-entry) collide-shape-prim) + (get-touched-tri (_type_ collide-shape touching-shapes-entry) collide-tri-result) + ) + ) + + +(deftype touching-prims-entry-pool (structure) + "A pool of up to 64 touching prim records." + ((head touching-prims-entry) + (nodes touching-prims-entry 64 :inline) + ) + (:methods + (new (symbol type) _type_) + (alloc-node (_type_) touching-prims-entry) + (get-free-node-count (_type_) int) + (init-list! (_type_) none) + (free-node (_type_ touching-prims-entry) touching-prims-entry) + ) + ) + + +(defmethod init-list! ((this touching-prims-entry-pool)) + (let ((prev (the-as touching-prims-entry #f))) + (let ((current (the-as touching-prims-entry (-> this nodes)))) + (set! (-> this head) current) + (countdown (a0-1 64) + (set! (-> current prev) prev) + (let ((next (&+ current 240))) + (set! (-> current next) (the-as touching-prims-entry next)) + (set! (-> current allocated?) #f) + (set! prev current) + (set! current (the-as touching-prims-entry next)) + ) + ) + ) + (set! (-> prev next) #f) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch structure vs touching-prims-entry-pool. +(defmethod new touching-prims-entry-pool ((allocation symbol) (type-to-make type)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + (let ((gp-0 (t9-0 allocation v1-1))) + ((method-of-type touching-prims-entry-pool init-list!) (the-as touching-prims-entry-pool gp-0)) + (the-as touching-prims-entry-pool gp-0) + ) + ) + ) + +(deftype touching-shapes-entry (structure) + "A record of two collide shapes touching, +storing a record of the primitives involved." + ((cshape1 collide-shape) + (cshape2 collide-shape) + (resolve-u int8) + (head touching-prims-entry) + (handle1 handle) + (handle2 handle) + ) + :pack-me + (:methods + (get-head (_type_) touching-prims-entry) + (get-next (_type_ touching-shapes-entry) touching-prims-entry) + (get-touched-shape (_type_ collide-shape) collide-shape) + (prims-touching? (_type_ collide-shape uint) touching-prims-entry) + (prims-touching-action? (_type_ collide-shape collide-action collide-action) basic) + (free-touching-prims-list (_type_) none) + ) + ) + + +(deftype touching-list (structure) + "Contains a record of touching collide shape pairs." + ((num-touching-shapes int32) + (resolve-u int8) + (touching-shapes touching-shapes-entry 32 :inline) + ) + (:methods + (new (symbol type) _type_) + (add-touching-prims (_type_ collide-shape-prim collide-shape-prim float collide-tri-result collide-tri-result) none) + (free-nodes (_type_) none) + (update-from-step-size (_type_ float) none) + (send-events-for-touching-shapes (_type_) none) + (get-shapes-entry (_type_ collide-shape collide-shape) touching-shapes-entry) + ) + ) + + +;; WARN: Return type mismatch structure vs touching-list. +(defmethod new touching-list ((allocation symbol) (type-to-make type)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + (let ((v0-0 (t9-0 allocation v1-1))) + (set! (-> (the-as touching-list v0-0) num-touching-shapes) 0) + (set! (-> (the-as touching-list v0-0) resolve-u) 0) + (the-as touching-list v0-0) + ) + ) + ) + +(defmethod get-head ((this touching-shapes-entry)) + (-> this head) + ) + +;; WARN: Return type mismatch collide-shape vs touching-prims-entry. +(defmethod get-next ((this touching-shapes-entry) (arg0 touching-shapes-entry)) + (the-as touching-prims-entry (-> arg0 cshape1)) + ) + +(kmemopen global "collide-touching-lists") + +(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)) + +(kmemclose) diff --git a/goal_src/jakx/engine/collide/find-nearest-h.gc b/goal_src/jakx/engine/collide/find-nearest-h.gc index d40b21bfdc..a3b55dab12 100644 --- a/goal_src/jakx/engine/collide/find-nearest-h.gc +++ b/goal_src/jakx/engine/collide/find-nearest-h.gc @@ -7,3 +7,23 @@ ;; DECOMP BEGINS +(define *HACK-find-nearest-focusable-ignore* #f) + +(deftype find-sorted-targets-params (structure) + ((near-point vector :inline) + (in-dir vector :inline) + (reject-team int8) + (min-dist float) + (max-dist float) + (inv-slope-dist float) + (reject-inside-dist float) + (min-angle-cos float) + (max-angle-cos float) + (inv-slope-ang float) + (required-flags uint32) + (priority-flags uint32) + (weights vector :inline) + (validate basic) + (validator-params basic) + ) + ) diff --git a/goal_src/jakx/engine/collide/pat-h.gc b/goal_src/jakx/engine/collide/pat-h.gc index c7976814c8..d2c8401ede 100644 --- a/goal_src/jakx/engine/collide/pat-h.gc +++ b/goal_src/jakx/engine/collide/pat-h.gc @@ -5,5 +5,340 @@ ;; name in dgo: pat-h ;; dgos: ENGINE, GAME +;; +++pat-mode +(defenum pat-mode + :type uint8 + (ground 0) + (wall 1) + (obstacle 2) + (halfpipe 3) + ) +;; ---pat-mode + +;; +++pat-material +(defenum pat-material + :type uint8 + (unknown 0) + (ice 1) + (quicksand 2) + (waterbottom 3) + (tar 4) + (sand 5) + (wood 6) + (grass 7) + (pcmetal 8) + (snow 9) + (deepsnow 10) + (hotcoals 11) + (lava 12) + (crwood 13) + (gravel 14) + (dirt 15) + (metal 16) + (straw 17) + (tube 18) + (swamp 19) + (stopproj 20) + (rotate 21) + (neutral 22) + (stone 23) + (crmetal 24) + (carpet 25) + (grmetal 26) + (shmetal 27) + (hdwood 28) + (squish 29) + (invisible 30) ;; mhshroom + (forest 31) + (forcefield 32) ;; mhswamp + (dmaker 33) +) +;; ---pat-material + +;; +++pat-event +(defenum pat-event + :type uint8 + (none 0) + (deadly 1) + (nodamage 2) ;; endlessfall + (e01 3) ;; burn + (e02 4) ;; deadlyup + (e03 5) ;; burnup + (e04 6) ;; melt + (e05 7) ;; slide + (e06 8) ;; lip + (e07 9) ;; lipramp + (e08 10) ;; shock + (e09 11) ;; shockup + (e10 12) ;; hide + (e11 13) ;; rail + (slippery 14) + (e13 15) ;; drag + (e14 16) ;; waterfloor + (e15 17) ;; hang + (e16 18) ;; fry + (e17 19) ;; slime +) +;; ---pat-event + ;; DECOMP BEGINS +(deftype pat-surface (uint32) + ((skip uint8 :offset 0 :size 7) + (mode pat-mode :offset 7 :size 3) + (material pat-material :offset 10 :size 6) + (camera uint8 :offset 16 :size 1) + (event pat-event :offset 18 :size 6) + (skip2 uint8 :offset 24 :size 5) + (noentity uint8 :offset 0 :size 1) + (nocamera uint8 :offset 1 :size 1) + (noedge uint8 :offset 2 :size 1) + (nogrind uint8 :offset 3 :size 1) + (nojak uint8 :offset 4 :size 1) + (noboard uint8 :offset 5 :size 1) + (nopilot uint8 :offset 6 :size 1) + (probe uint8 :offset 24 :size 1) + (nomech uint8 :offset 25 :size 1) + (noproj uint8 :offset 26 :size 1) + (noendlessfall uint8 :offset 27 :size 1) + (noprobe uint8 :offset 28 :size 1) + (nolineofsight uint8 :offset 16 :size 1) + (board uint8 :offset 4 :size 1) + ) + ) + + +(defun-debug pat-material->string ((arg0 pat-surface)) + (case (-> arg0 material) + (((pat-material deepsnow)) + "deepsnow" + ) + (((pat-material neutral)) + "neutral" + ) + (((pat-material carpet)) + "carpet" + ) + (((pat-material shmetal)) + "shmetal" + ) + (((pat-material grmetal)) + "grmetal" + ) + (((pat-material lava)) + "lava" + ) + (((pat-material crmetal)) + "crmetal" + ) + (((pat-material pcmetal)) + "pcmetal" + ) + (((pat-material grass)) + "grass" + ) + (((pat-material snow)) + "snow" + ) + (((pat-material swamp)) + "swamp" + ) + (((pat-material stone)) + "stone" + ) + (((pat-material hotcoals)) + "hotcoals" + ) + (((pat-material unknown)) + "unknown" + ) + (((pat-material dirt)) + "dirt" + ) + (((pat-material dmaker)) + "dmaker" + ) + (((pat-material tube)) + "tube" + ) + (((pat-material forest)) + "forest" + ) + (((pat-material stopproj)) + "stopproj" + ) + (((pat-material invisible)) + "invisible" + ) + (((pat-material forcefield)) + "forcefield" + ) + (((pat-material tar)) + "tar" + ) + (((pat-material straw)) + "straw" + ) + (((pat-material wood)) + "wood" + ) + (((pat-material quicksand)) + "quicksand" + ) + (((pat-material squish)) + "squish" + ) + (((pat-material ice)) + "ice" + ) + (((pat-material rotate)) + "rotate" + ) + (((pat-material crwood)) + "crwood" + ) + (((pat-material waterbottom)) + "waterbottom" + ) + (((pat-material hdwood)) + "hdwood" + ) + (((pat-material sand)) + "sand" + ) + (((pat-material gravel)) + "gravel" + ) + (((pat-material metal)) + "metal" + ) + (else + "*unknown*" + ) + ) + ) + +(defun-debug pat-mode->string ((arg0 pat-surface)) + (case (-> arg0 mode) + (((pat-mode wall)) + "wall" + ) + (((pat-mode halfpipe)) + "halfpipe" + ) + (((pat-mode obstacle)) + "obstacle" + ) + (((pat-mode ground)) + "ground" + ) + (else + "*unknown*" + ) + ) + ) + +(defun-debug pat-event->string ((arg0 pat-surface)) + (case (-> arg0 event) + (((pat-event nodamage)) + "nodamage" + ) + (((pat-event e09)) + "e09" + ) + (((pat-event deadly)) + "deadly" + ) + (((pat-event e02)) + "e02" + ) + (((pat-event e08)) + "e08" + ) + (((pat-event slippery)) + "slippery" + ) + (((pat-event e11)) + "e11" + ) + (((pat-event e01)) + "e01" + ) + (((pat-event e17)) + "e17" + ) + (((pat-event e07)) + "e07" + ) + (((pat-event e10)) + "e10" + ) + (((pat-event e16)) + "e16" + ) + (((pat-event e06)) + "e06" + ) + (((pat-event e15)) + "e15" + ) + (((pat-event e05)) + "e05" + ) + (((pat-event none)) + "none" + ) + (((pat-event e14)) + "e14" + ) + (((pat-event e04)) + "e04" + ) + (((pat-event e13)) + "e13" + ) + (((pat-event e03)) + "e03" + ) + (else + "*unknown*" + ) + ) + ) + +(deftype pat-mode-info (structure) + ((name string) + (wall-angle float) + (color rgba) + (hilite-color rgba) + ) + ) + + +(define *pat-mode-info* (new 'static 'inline-array pat-mode-info 4 + (new 'static 'pat-mode-info + :name "ground" + :wall-angle 0.2 + :color (new 'static 'rgba :r #x7f :a #x40) + :hilite-color (new 'static 'rgba :r #xff :a #x80) + ) + (new 'static 'pat-mode-info + :name "wall" + :wall-angle 2.0 + :color (new 'static 'rgba :b #x7f :a #x40) + :hilite-color (new 'static 'rgba :b #xff :a #x80) + ) + (new 'static 'pat-mode-info + :name "obstacle" + :wall-angle 0.82 + :color (new 'static 'rgba :r #x7f :b #x7f :a #x40) + :hilite-color (new 'static 'rgba :r #xff :b #xff :a #x80) + ) + (new 'static 'pat-mode-info + :name "halfpipe" + :wall-angle -2.0 + :color (new 'static 'rgba :r #x7f :g #x7f :a #x40) + :hilite-color (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) diff --git a/goal_src/jakx/engine/common-obs/cloth-art-h.gc b/goal_src/jakx/engine/common-obs/cloth-art-h.gc index 6db65cd872..031c7d75c8 100644 --- a/goal_src/jakx/engine/common-obs/cloth-art-h.gc +++ b/goal_src/jakx/engine/common-obs/cloth-art-h.gc @@ -5,5 +5,138 @@ ;; name in dgo: cloth-art-h ;; dgos: ENGINE, GAME +;; +++cloth-flag +(defenum cloth-flag + :type uint64 + :bitfield #t + (no-gravity 0) + (use-wind 1) + (need-reset 2) + (double-sided 3) + (suppress-mesh-failure 4) + (active 5) + (check-ground 6) + (flip-normals 7) + (wraps 8) + (inited 9) + (no-draw 10) + (need-setup 11) + (use-global-wind 12) + (autogen-uvs 13) + (use-momentum 14) + (use-parent-momentum 15) + (riding 16) + (hidden 17) + (local-space 18) + (local-space-xyz 19) + (local-space-y 20) + (use-old-resets 21) + (using-alt-tex 22) + ) +;; ---cloth-flag + ;; DECOMP BEGINS +(deftype cloth-pt (structure) + ((pt vector :inline) + (u float) + (v float) + ) + ) + + +(deftype anchor-transform (structure) + ((offset vector :inline) + (joint-name string) + (joint int16) + (constraint-index int16) + ) + ) + + +(deftype sphere-transform (structure) + ((offset vector :inline) + (joint-name string) + (radius float) + (joint int16) + ) + ) + + +(deftype disc-transform (structure) + ((offset vector :inline) + (normal vector :inline) + (joint-name basic) + (radius float) + (joint int16) + (start-particle-index int16) + (end-particle-index int16) + ) + ) + + +(deftype anchor-transform-array (inline-array-class) + ((data anchor-transform :dynamic) + ) + ) + + +(set! (-> anchor-transform-array heap-base) (the-as uint 32)) + +(deftype sphere-transform-array (inline-array-class) + ((data sphere-transform :dynamic) + ) + ) + + +(set! (-> sphere-transform-array heap-base) (the-as uint 32)) + +(deftype disc-transform-array (inline-array-class) + ((data disc-transform :dynamic) + ) + ) + + +(set! (-> disc-transform-array heap-base) (the-as uint 48)) + +(deftype cloth-thickness-array (inline-array-class) + ((data uint8 :dynamic) + ) + ) + + +(set! (-> cloth-thickness-array heap-base) (the-as uint 1)) + +(deftype cloth-params (structure) + ((mesh int16) + (gravity-constant meters) + (wind-constant float) + (cloth-width uint16) + (num-sphere-constraints uint16) + (num-disc-constraints uint16) + (num-anchor-points uint16) + (flags cloth-flag) + (tex-name string) + (tex-name2 string) + (tex-name3 string) + (alt-tex-name string) + (alt-tex-name2 string) + (alt-tex-name3 string) + (cloth-thickness float) + (initial-xform int16) + (drag float) + (ball-collision-radius meters) + (num-iterations int8) + (timestep-frequency int8) + (secret-disable game-secrets) + ) + ) + + +(deftype cloth-base (basic) + () + (:methods + (update! (_type_) int) + (setup-from-params! (_type_ cloth-params handle) int) + ) + ) diff --git a/goal_src/jakx/engine/common-obs/matrix-compose.gc b/goal_src/jakx/engine/common-obs/matrix-compose.gc index a063a97eaf..85e9f17857 100644 --- a/goal_src/jakx/engine/common-obs/matrix-compose.gc +++ b/goal_src/jakx/engine/common-obs/matrix-compose.gc @@ -7,3 +7,102 @@ ;; DECOMP BEGINS +(defun matrix-fur-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 rvec quad) (-> arg3 quad)) + (set! (-> arg0 uvec quad) (-> arg2 quad)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + arg0 + ) + +(defun matrix-fu-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (set! (-> arg0 uvec quad) (-> arg2 quad)) + (vector-cross! (-> arg0 rvec) arg2 arg1) + arg0 + ) + +(defun matrix-fr-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (set! (-> arg0 rvec quad) (-> arg2 quad)) + (vector-cross! (-> arg0 uvec) arg1 arg2) + arg0 + ) + +(defun matrix-ur-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 rvec quad) (-> arg2 quad)) + (set! (-> arg0 uvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 fvec) arg1 arg2) + arg0 + ) + +(defun matrix-f-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 rvec) arg2 arg1) + (vector-normalize! (-> arg0 rvec) 1.0) + (vector-cross! (-> arg0 uvec) arg1 (-> arg0 rvec)) + arg0 + ) + +(defun matrix-f-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 uvec) arg1 arg2) + (vector-normalize! (-> arg0 uvec) 1.0) + (vector-cross! (-> arg0 rvec) (-> arg0 uvec) arg1) + arg0 + ) + +(defun matrix-u-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 uvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 rvec) arg1 arg2) + (vector-normalize! (-> arg0 rvec) 1.0) + (vector-cross! (-> arg0 fvec) (-> arg0 rvec) arg1) + arg0 + ) + +(defun matrix-u-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 uvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 fvec) arg2 arg1) + (vector-normalize! (-> arg0 fvec) 1.0) + (vector-cross! (-> arg0 rvec) arg1 (-> arg0 fvec)) + arg0 + ) + +(defun matrix-r-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 rvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 uvec) arg2 arg1) + (vector-normalize! (-> arg0 uvec) 1.0) + (vector-cross! (-> arg0 fvec) arg1 (-> arg0 uvec)) + arg0 + ) + +(defun matrix-r-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 rvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 fvec) arg1 arg2) + (vector-normalize! (-> arg0 fvec) 1.0) + (vector-cross! (-> arg0 uvec) (-> arg0 fvec) arg1) + arg0 + ) + +(defun matrix-f-compose ((arg0 matrix) (arg1 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (let ((a2-0 (vector-get-unique! (new 'stack-no-clear 'vector) arg1))) + (matrix-f-u-compose arg0 arg1 a2-0) + ) + arg0 + ) + +(defun matrix-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 uvec quad) (-> arg1 quad)) + (let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1))) + (matrix-u-f-compose arg0 arg1 a2-1) + ) + arg0 + ) + +(defun matrix-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 rvec quad) (-> arg1 quad)) + (let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1))) + (matrix-r-f-compose arg0 arg1 a2-1 arg3) + ) + arg0 + ) diff --git a/goal_src/jakx/engine/common-obs/prim-h.gc b/goal_src/jakx/engine/common-obs/prim-h.gc index 012ec671f8..4d085e6097 100644 --- a/goal_src/jakx/engine/common-obs/prim-h.gc +++ b/goal_src/jakx/engine/common-obs/prim-h.gc @@ -5,5 +5,22 @@ ;; name in dgo: prim-h ;; dgos: ENGINE, GAME +;; +++prim-flags +(defenum prim-flags + :type uint32 + :bitfield #t + (alpha-blend-enable 0) ;; set by default + (texture-enable 1) ;; set by default + (fog-enable 2) + (pf3 3) ;; auto-clear vertices? + (pf4 4) ;; has new verts to draw? + (no-texture-name 5) ;; only has the ID. + ) +;; ---prim-flags + +(define-extern process-drawable-art-error (state string process-drawable)) +(define-extern *prim-engine* engine) + + ;; DECOMP BEGINS diff --git a/goal_src/jakx/engine/common-obs/water-info-h.gc b/goal_src/jakx/engine/common-obs/water-info-h.gc index 9206531938..002b3d8928 100644 --- a/goal_src/jakx/engine/common-obs/water-info-h.gc +++ b/goal_src/jakx/engine/common-obs/water-info-h.gc @@ -5,5 +5,63 @@ ;; name in dgo: water-info-h ;; dgos: ENGINE, GAME +;; +++water-flag +(defenum water-flag + :type uint32 + :bitfield #t + (active 0) + (can-wade 1) + (can-swim 2) + (swim-ground 3) + (can-ground 4) + (use-ocean 5) + (tar 6) + (mud 7) + (deadly 8) + (use-water-anim 9) + (no-grab-sound 10) + (dark-eco 11) + (lava 12) + (swamp 13) + (flow 14) + (under-water 15) + (head-under-water 16) + (bouncing 17) + (wading 18) + (swimming 19) + (touch-water 20) + (jump-out 21) + (break-surface 22) + (spawn-drip 23) + (part-splash 24) + (part-drip 25) + (part-rings 26) + (part-water 27) + (event 28) + (over-water 29) + (find-water 30) + (touch-water-good 31) + ) +;; ---water-flag + ;; DECOMP BEGINS +(deftype water-info (structure) + ((trans vector :inline) + (normal vector :inline) + (base-height meters) + (depth meters) + (handle handle) + (flags water-flag) + (prim drawable-region-prim) + (extra-flags uint32) + ) + ) + + +(deftype water-sphere (structure) + ((sphere sphere :inline) + (flags water-flag) + (user0 int32) + ) + ) diff --git a/goal_src/jakx/engine/data/art-h.gc b/goal_src/jakx/engine/data/art-h.gc index cef56fe807..55cc07da0f 100644 --- a/goal_src/jakx/engine/data/art-h.gc +++ b/goal_src/jakx/engine/data/art-h.gc @@ -5,5 +5,185 @@ ;; name in dgo: art-h ;; dgos: ENGINE, GAME +;; +++draw-control-status +(defenum draw-control-status + :type uint32 + :bitfield #t + (close-to-screen 0) + (no-draw 1) + (no-draw-temp) + (on-screen) + (uninited) + (no-draw-bounds) + (no-closest-distance) + (math-skel) + (force-vu1) + (no-draw-bounds2) + (force-fade) + (warp-cross-fade) + (lod-set) + (disable-fog) + (hud) + (no-bounds-check) + ) +;; ---draw-control-status + + +;; +++draw-control-data-format +(defenum draw-control-data-format + :type uint8 + :bitfield #f + (pris 0) + (merc 1) + ) +;; ---draw-control-data-format + + +;; +++draw-control-global-effect +(defenum draw-control-global-effect + :type uint8 + :bitfield #t + (bit-0) + (bit-1) + (title-light) + (disable-envmap) + (rim-lights) + (rim-lights2) + (rim-lights3) + (no-textures) + ) +;; ---draw-control-global-effect + + ;; DECOMP BEGINS +(deftype joint-anim (basic) + "Base class for all joint animations. These are animations that store joint transforms." + ((name string :offset-assert 4) ;; guessed by decompiler + (number int16 :offset-assert 8) + (length int16 :offset-assert 10) + ) + :method-count-assert 9 + :size-assert #xc + :flag-assert #x90000000c + ) + +(deftype joint-anim-matrix (joint-anim) + "Joint animation which stores matrices directly. Not used." + ((data matrix :inline :dynamic :offset 16)) + :flag-assert #x900000010 + ) + +(deftype joint-anim-transformq (joint-anim) + "Joint animation which stores transformq's directly. Not used." + ((data transformq :dynamic :inline :offset-assert 16) ;; guessed by decompiler + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype joint-anim-drawable (joint-anim) + "Mysterious unused joint animation type." + ((data drawable :dynamic :offset-assert 12) ;; guessed by decompiler + ) + :method-count-assert 9 + :size-assert #xc + :flag-assert #x90000000c + ) + +(deftype joint-anim-frame (structure) + "Frame containing all joint transforms. Note that there are two special frames: align and prejoint. + The 'align' frame is used for the complicated animation alignment system, which allows the animation to move + a character, among other things. The prejoint is just the root of the skeleton. + The remaining transformq's are the joint transforms you'd expect." + ((matrices matrix 2 :inline :offset-assert 0) ;; guessed by decompiler + (data transformq :dynamic :inline :offset-assert 128) ;; guessed by decompiler + ) + (:methods + (new (symbol type int) _type_) + ) + :method-count-assert 9 + :size-assert #x80 + :flag-assert #x900000080 + ) + +(deftype joint-anim-compressed-hdr (structure) + "Header for the compressed joint animation format." + ((control-bits uint32 14 :offset-assert 0) ;; guessed by decompiler + (num-joints uint32 :offset-assert 56) + (matrix-bits uint32 :offset-assert 60) + ) + :method-count-assert 9 + :size-assert #x40 + :flag-assert #x900000040 + ) + +(deftype joint-anim-compressed-fixed (structure) + ((hdr joint-anim-compressed-hdr :inline :offset-assert 0) + (offset-64 uint32 :offset-assert 64) + (offset-32 uint32 :offset-assert 68) + (offset-16 uint32 :offset-assert 72) + (reserved uint32 :offset-assert 76) + (data vector 133 :inline :offset-assert 80) ;; guessed by decompiler + ) + :method-count-assert 9 + :size-assert #x8a0 + :flag-assert #x9000008a0 + ) + +(deftype joint-anim-compressed-frame (structure) + ((offset-64 uint32 :offset-assert 0) + (offset-32 uint32 :offset-assert 4) + (offset-16 uint32 :offset-assert 8) + (reserved uint32 :offset-assert 12) + (data vector 133 :inline :offset-assert 16) ;; guessed by decompiler + ) + :method-count-assert 9 + :size-assert #x860 + :flag-assert #x900000860 + ) + +(deftype joint-anim-compressed-control (structure) + ((num-frames uint16 :offset-assert 0) + (flags uint16 :offset-assert 2) + (fixed-qwc uint32 :offset-assert 4) + (frame-qwc uint32 :offset-assert 8) + (fixed joint-anim-compressed-fixed :offset-assert 12) + (data joint-anim-compressed-frame :dynamic :offset-assert 16) ;; guessed by decompiler + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype art (basic) + "Base class for anything considered `art`. This is typically foreground model data. + This can be either an art container containing more arts, or an actual art thing (art-element)." + ((name string :offset 8) ;; guessed by decompiler + (length int32 :offset-assert 12) + (extra res-lump :offset-assert 16) ;; guessed by decompiler + ) + :method-count-assert 14 + :size-assert #x14 + :flag-assert #xe00000014 + (:methods + (login (_type_) _type_) ;; 9 + (art-method-10 (_type_) _type_) ;; 10 + (get-art-by-name-method "Look inside this art for an art with the given name and type. Return #f if not found" (_type_ string type) basic) ;; 11 + (get-art-idx-by-name-method "Look inside this art for an art with the given name and type and return the index of the art. Return #f if not found." (_type_ string type) int) ;; 12 + (contains-art-for-other-group? "Some art groups have placeholder #f's for some art that will be loaded separately as needed. + Does this art group contain art that needs to be added to another group?" (_type_) symbol) ;; 13 + ) + ) + +(deftype art-element (art) + "Base class Art which is not a container of more art." + ((master-art-group-name string :offset-assert 20) + (master-art-group-index int32 :offset-assert 24) + (pad uint8 20) + ) + :method-count-assert 14 + :size-assert #x30 + :flag-assert #xe00000030 + ) \ No newline at end of file diff --git a/goal_src/jakx/engine/debug/debug-h.gc b/goal_src/jakx/engine/debug/debug-h.gc index 53e5c99437..59a60ac2a8 100644 --- a/goal_src/jakx/engine/debug/debug-h.gc +++ b/goal_src/jakx/engine/debug/debug-h.gc @@ -5,5 +5,174 @@ ;; name in dgo: debug-h ;; dgos: ENGINE, GAME +(define-extern add-debug-line (function symbol bucket-id vector vector rgba symbol rgba symbol)) +(define-extern add-debug-matrix (function symbol bucket-id matrix meters matrix)) +(define-extern add-debug-sphere (function symbol bucket-id vector meters rgba symbol)) +(define-extern add-debug-text-sphere (function symbol bucket-id vector meters string rgba symbol)) +(define-extern add-debug-vector (function symbol bucket-id vector vector meters rgba symbol)) +(define-extern add-debug-quaternion (function symbol bucket-id vector quaternion none)) +(define-extern drawable-frag-count (function drawable int)) +(define-extern drawable-tri-count (function drawable int)) +(define-extern add-debug-x (function symbol bucket-id vector rgba symbol)) +(define-extern add-debug-text-3d (function symbol bucket-id string vector font-color vector2h symbol)) +(define-extern add-debug-flat-triangle (function symbol bucket-id vector vector vector rgba symbol)) +(define-extern add-debug-box-with-transform (function symbol bucket-id bounding-box matrix rgba symbol)) +(define-extern add-debug-line-sphere (function symbol bucket-id vector vector float rgba none)) + ;; DECOMP BEGINS +(deftype pos-history (structure) + ((points (inline-array vector)) + (num-points int32) + (h-first int32) + (h-last int32) + ) + ) + + +(deftype debug-vertex (structure) + ((trans vector4w :inline) + (normal vector3h :inline) + (st vector2h :inline) + (color uint32) + ) + ) + + +(deftype debug-vertex-stats (basic) + ((length int32) + (pos-count int32) + (vertex debug-vertex 600 :inline) + ) + ) + + +(define *color-black* (new 'static 'rgba :a #x80)) + +(define *color-white* (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)) + +(define *color-gray* (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)) + +(define *color-red* (new 'static 'rgba :r #xff :a #x80)) + +(define *color-green* (new 'static 'rgba :g #xff :a #x80)) + +(define *color-blue* (new 'static 'rgba :b #xff :a #x80)) + +(define *color-cyan* (new 'static 'rgba :g #xff :b #xff :a #x80)) + +(define *color-magenta* (new 'static 'rgba :r #xff :b #xff :a #x80)) + +(define *color-yellow* (new 'static 'rgba :r #xff :g #xff :a #x80)) + +(define *color-purple* (new 'static 'rgba :r #x40 :b #x80 :a #x80)) + +(define *color-light-gray* (new 'static 'rgba :r #xb0 :g #xb0 :b #xb0 :a #xb0)) + +(define *color-light-red* (new 'static 'rgba :r #xff :g #x80 :b #x80 :a #x80)) + +(define *color-light-green* (new 'static 'rgba :r #x80 :g #xff :b #x80 :a #x80)) + +(define *color-light-blue* (new 'static 'rgba :r #x80 :g #x80 :b #xff :a #x80)) + +(define *color-light-cyan* (new 'static 'rgba :r #x80 :g #xff :b #xff :a #x80)) + +(define *color-light-magenta* (new 'static 'rgba :r #xff :g #x80 :b #xff :a #x80)) + +(define *color-light-yellow* (new 'static 'rgba :r #xff :g #xff :b #x80 :a #x80)) + +(define *color-dark-red* (new 'static 'rgba :r #x80 :a #x80)) + +(define *color-dark-green* (new 'static 'rgba :g #x80 :a #x80)) + +(define *color-dark-blue* (new 'static 'rgba :b #x80 :a #x80)) + +(define *color-dark-cyan* (new 'static 'rgba :g #x80 :b #x80 :a #x80)) + +(define *color-dark-magenta* (new 'static 'rgba :r #x80 :b #x80 :a #x80)) + +(define *color-dark-yellow* (new 'static 'rgba :r #x80 :g #x80 :a #x80)) + +(define *color-orange* (new 'static 'rgba :r #xff :g #x80 :a #x80)) + +(defun-debug draw-debug-text-3d ((arg0 string) (arg1 vector) (arg2 bucket-id) (arg3 font-color) (arg4 vector2h) (arg5 rgba)) + (add-debug-text-3d #t arg2 arg0 arg1 arg3 arg4) + 0 + (none) + ) + +(defun-debug draw-debug-x ((arg0 vector) (arg1 bucket-id) (arg2 rgba)) + (add-debug-x #t arg1 arg0 arg2) + 0 + (none) + ) + +(defun-debug draw-debug-line ((arg0 vector) (arg1 vector) (arg2 bucket-id) (arg3 rgba) (arg4 symbol) (arg5 rgba)) + (add-debug-line #t arg2 arg0 arg1 arg3 arg4 arg5) + 0 + (none) + ) + +(defun-debug draw-debug-vector ((arg0 vector) (arg1 vector) (arg2 bucket-id) (arg3 rgba) (arg4 meters)) + (add-debug-vector #t arg2 arg0 arg1 arg4 arg3) + 0 + (none) + ) + +(defun-debug draw-debug-flat-triangle ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 bucket-id) (arg4 rgba)) + (add-debug-flat-triangle #t arg3 arg0 arg1 arg2 arg4) + 0 + (none) + ) + +(defun-debug draw-debug-sphere ((arg0 vector) (arg1 bucket-id) (arg2 float) (arg3 rgba)) + (add-debug-sphere + #t + arg1 + arg0 + (if (< 0.0 arg2) + arg2 + (-> arg0 w) + ) + arg3 + ) + 0 + (none) + ) + +(defun-debug draw-debug-matrix ((arg0 matrix) (arg1 bucket-id) (arg2 float)) + (add-debug-matrix #t arg1 arg0 arg2) + 0 + (none) + ) + +(defun-debug draw-debug-box-with-transform ((arg0 bounding-box) (arg1 matrix) (arg2 bucket-id) (arg3 rgba)) + (add-debug-box-with-transform #t arg2 arg0 arg1 arg3) + 0 + (none) + ) + +(defun-debug draw-debug-line-sphere ((arg0 vector) (arg1 vector) (arg2 bucket-id) (arg3 float) (arg4 rgba)) + (add-debug-line-sphere + #t + arg2 + arg0 + arg1 + (if (< 0.0 arg3) + arg3 + (-> arg0 w) + ) + arg4 + ) + 0 + (none) + ) + +(deftype stack-debug (structure) + ((r29 uint128) + (r31 uint128) + (test-count int32) + (visit int32) + (obj basic) + ) + ) diff --git a/goal_src/jakx/engine/debug/memory-usage-h.gc b/goal_src/jakx/engine/debug/memory-usage-h.gc index d3e92db53c..6eb872131d 100644 --- a/goal_src/jakx/engine/debug/memory-usage-h.gc +++ b/goal_src/jakx/engine/debug/memory-usage-h.gc @@ -7,3 +7,33 @@ ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) + +(deftype memory-usage-info (structure) + ((name string) + (count int32) + (used int32) + (total int32) + ) + ) + + +(deftype memory-usage-block (basic) + ((work-bsp basic) + (length int32) + (data memory-usage-info 112 :inline) + ) + (:methods + (reset! (_type_) _type_) + (calculate-total (_type_) int) + (print-mem-usage (_type_ level object) _type_) + ) + ) + + +(define *mem-usage* (new 'debug 'memory-usage-block)) + +(define *dma-mem-usage* (new 'debug 'memory-usage-block)) + +(define *temp-mem-usage* (the-as memory-usage-block #f)) diff --git a/goal_src/jakx/engine/debug/stats-h.gc b/goal_src/jakx/engine/debug/stats-h.gc index 6b1951083c..934fb8313b 100644 --- a/goal_src/jakx/engine/debug/stats-h.gc +++ b/goal_src/jakx/engine/debug/stats-h.gc @@ -5,5 +5,339 @@ ;; name in dgo: stats-h ;; dgos: ENGINE, GAME +;; +++perf-stat-bucket +(defenum perf-stat-bucket + :type uint32 + (all-code) + (spatial-hash-build) + (spatial-hash-search) + (collide) + (collide-list) + (collide-fill) + (actor-hash) + (nav) + (nav-dma-all) + (nav-dma-read) + (nav-dma-write) ;; 10 + (nav-dma-work) + (nav-part1) + (nav-part2) + (nav-part3) + (nav-part4) + (nav-part5) + (nav-part6) + (nav-part7) + (nav-part8) + (nav-part9) ;; 20 + (nav-part10) + + ;; renamed + (rb-all) ;; add-to-translation + (rb-fc) ;; update-current-poly + (rb-physics) ;; clamp-vector-to-mesh + (rb-callback) ;; ray-step + (rb-move) ;; update-spheres + (rb-probe) ;; travel-around-spheres + (vqp-all) ;; avoid-spheres + (vqp-sound) ;; check-vector-collision-with-nav-spheres + (vqp-parts) ;; find-nearest-poly + (vqp-ja-post) ;; find-containing-poly ;; 30 + + (vqp-sections) ;; generate-velocity + (vqp-post) ;; apply-rotation + (vqp-common) ;; apply-velocity + (find-nearest-poly) ;; travel-post + (find-containing-poly) ;; common-post + (misc) + (mercneric) + (tie-generic) + (background) ;; 40 + (drawable) + (tfrag) + (tfrag-scissor) + (inst-shrub) + (proto-shrub) + (inst-tie) + (proto-tie) + (bones) + (camera) + (foreground) ;; 50 + ;; hover / vehicle / hud renames + (vehicle-ai) ;; hover-path + (vehicle-ai-calculate-vector) ;; hover-spheres + (update-los) ;; hover-update + (race-line) ;; hover-move + (hud) ;; hover-find-closest + (hud-format) ;; update-los + ;; explicit HUD buckets + (hud-draw-string) ;; perf-stat-bucket-57 + (hud-draw-sprite) ;; perf-stat-bucket-58 +) +;; ---perf-stat-bucket + + ;; DECOMP BEGINS +(deftype tr-stat (structure) + "triangle stats for a renderer. This can apply to a lot of different renderer types." + ((groups uint16) + (fragments uint16) + (tris uint32) + (dverts uint32) + (instances uint16) + (pad uint16) + ) + ) + + +(deftype merc-global-stats (structure) + "Triangle stats for all merc renderers." + ((merc tr-stat :inline) + (emerc tr-stat :inline) + (mercneric tr-stat :inline) + ) + ) + + +(deftype perf-stat (structure) + "Performance statistics for a single 'bucket' or category. Unlike the more general profile-bars, +this records statistics like cache hits/instruction counts." + ((frame-number uint32) + (count uint32) + (cycles uint32) + (instructions uint32) + (icache uint32) + (dcache uint32) + (select uint32) + (ctrl uint32) + (accum0 uint32) + (accum1 uint32) + (to-vu0-waits uint32) + (to-spr-waits uint32) + (from-spr-waits uint32) + ) + :pack-me + (:methods + (perf-stat-method-9 () none) + (print-to-stream (_type_ string basic) none) + (start-profiling! (_type_) none) + (stop-profiling! (_type_) none) + (update-wait-stats (_type_ uint uint uint) none) + ) + ) + + +(defun-debug perf-stat-bucket->string ((arg0 perf-stat-bucket)) + (case arg0 + (((perf-stat-bucket collide-fill)) + "collide-fill" + ) + (((perf-stat-bucket nav)) + "nav" + ) + (((perf-stat-bucket bones)) + "bones" + ) + (((perf-stat-bucket hud-draw-string)) + "hud-draw-string" + ) + (((perf-stat-bucket rb-move)) + "rb-move" + ) + (((perf-stat-bucket vehicle-ai)) + "vehicle-ai" + ) + (((perf-stat-bucket foreground)) + "foreground" + ) + (((perf-stat-bucket inst-tie)) + "inst-tie" + ) + (((perf-stat-bucket vqp-common)) + "vqp-common" + ) + (((perf-stat-bucket nav-dma-write)) + "nav-dma-write" + ) + (((perf-stat-bucket collide-list)) + "collide-list" + ) + (((perf-stat-bucket rb-physics)) + "rb-physics" + ) + (((perf-stat-bucket nav-part3)) + "nav-part3" + ) + (((perf-stat-bucket mercneric)) + "mercneric" + ) + (((perf-stat-bucket rb-probe)) + "rb-probe" + ) + (((perf-stat-bucket vehicle-ai-calculate-vector)) + "vehicle-ai-calculate-vector" + ) + (((perf-stat-bucket tfrag-scissor)) + "tfrag-scissor" + ) + (((perf-stat-bucket vqp-sections)) + "vqp-sections" + ) + (((perf-stat-bucket misc)) + "misc" + ) + (((perf-stat-bucket find-nearest-poly)) + "find-nearest-poly" + ) + (((perf-stat-bucket nav-part6)) + "nav-part6" + ) + (((perf-stat-bucket nav-part2)) + "nav-part2" + ) + (((perf-stat-bucket inst-shrub)) + "inst-shrub" + ) + (((perf-stat-bucket proto-shrub)) + "proto-shrub" + ) + (((perf-stat-bucket rb-all)) + "rb-all" + ) + (((perf-stat-bucket drawable)) + "drawable" + ) + (((perf-stat-bucket nav-part9)) + "nav-part9" + ) + (((perf-stat-bucket all-code)) + "all-code" + ) + (((perf-stat-bucket actor-hash)) + "actor-hash" + ) + (((perf-stat-bucket nav-dma-all)) + "nav-dma-all" + ) + (((perf-stat-bucket hud-draw-sprite)) + "hud-draw-sprite" + ) + (((perf-stat-bucket nav-part10)) + "nav-part10" + ) + (((perf-stat-bucket hud-format)) + "hud-format" + ) + (((perf-stat-bucket race-line)) + "race-line" + ) + (((perf-stat-bucket nav-dma-work)) + "nav-dma-work" + ) + (((perf-stat-bucket update-los)) + "update-los" + ) + (((perf-stat-bucket proto-tie)) + "proto-tie" + ) + (((perf-stat-bucket nav-part4)) + "nav-part4" + ) + (((perf-stat-bucket spatial-hash-search)) + "spatial-hash-search" + ) + (((perf-stat-bucket find-containing-poly)) + "find-containing-poly" + ) + (((perf-stat-bucket vqp-ja-post)) + "vqp-ja-post" + ) + (((perf-stat-bucket rb-callback)) + "rb-callback" + ) + (((perf-stat-bucket nav-part7)) + "nav-part7" + ) + (((perf-stat-bucket tfrag)) + "tfrag" + ) + (((perf-stat-bucket vqp-sound)) + "vqp-sound" + ) + (((perf-stat-bucket hud)) + "hud" + ) + (((perf-stat-bucket collide)) + "collide" + ) + (((perf-stat-bucket nav-dma-read)) + "nav-dma-read" + ) + (((perf-stat-bucket rb-fc)) + "rb-fc" + ) + (((perf-stat-bucket vqp-post)) + "vqp-post" + ) + (((perf-stat-bucket vqp-parts)) + "vqp-parts" + ) + (((perf-stat-bucket spatial-hash-build)) + "spatial-hash-build" + ) + (((perf-stat-bucket camera)) + "camera" + ) + (((perf-stat-bucket tie-generic)) + "tie-generic" + ) + (((perf-stat-bucket vqp-all)) + "vqp-all" + ) + (((perf-stat-bucket background)) + "background" + ) + (((perf-stat-bucket nav-part5)) + "nav-part5" + ) + (((perf-stat-bucket nav-part1)) + "nav-part1" + ) + (((perf-stat-bucket nav-part8)) + "nav-part8" + ) + (else + "*unknown*" + ) + ) + ) + +(deftype perf-stat-array (inline-array-class) + "Array of all stats for all buckets." + ((data perf-stat :inline :dynamic) + ) + ) + + +(set! (-> perf-stat-array heap-base) (the-as uint 52)) + +(defmethod start-profiling! ((this perf-stat)) + 0 + (none) + ) + +(defmethod stop-profiling! ((this perf-stat)) + 0 + (none) + ) + +(defmethod update-wait-stats ((this perf-stat) (arg0 uint) (arg1 uint) (arg2 uint)) + 0 + (none) + ) + +(when (not *debug-segment*) + (set! (-> perf-stat method-table 11) nothing) + (set! (-> perf-stat method-table 12) nothing) + (set! (-> perf-stat method-table 13) nothing) + ) diff --git a/goal_src/jakx/engine/dma/dma-bucket.gc b/goal_src/jakx/engine/dma/dma-bucket.gc index 6792ccfeb9..64b96d390c 100644 --- a/goal_src/jakx/engine/dma/dma-bucket.gc +++ b/goal_src/jakx/engine/dma/dma-bucket.gc @@ -7,3 +7,60 @@ ;; DECOMP BEGINS +;; WARN: Return type mismatch pointer vs (inline-array dma-bucket). +(defun dma-buffer-add-buckets ((dma-buf dma-buffer) (bucket-count int)) + (let ((v0-0 (-> dma-buf base))) + (let ((v1-0 (the-as object v0-0))) + (dotimes (a2-0 bucket-count) + (set! (-> (the-as dma-bucket v1-0) tag) + (new 'static 'dma-tag :id (dma-tag-id next) :addr (the-as int (&+ (the-as pointer v1-0) 16))) + ) + (set! (-> (the-as dma-bucket v1-0) last) (the-as (pointer dma-tag) v1-0)) + (set! v1-0 (&+ (the-as pointer v1-0) 16)) + ) + (set! (-> dma-buf base) (the-as pointer v1-0)) + ) + (the-as (inline-array dma-bucket) v0-0) + ) + ) + +(defun dma-buffer-patch-buckets ((base dma-bucket) (count int)) + (when (nonzero? base) + (dotimes (v1-1 count) + (cond + ((= base (-> base last)) + (set! (-> base tag) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> base clear) (the-as uint 0)) + 0 + ) + (else + (set! (-> base last 0 addr) (the-as int (&+ base 16))) + (cond + ((and (or *display-profile* *stats-profile-bars*) (not *display-capture-mode*)) + (set! (-> (the-as dma-packet base) vif0) (new 'static 'vif-tag :cmd (vif-cmd mark) :imm v1-1)) + (set! (-> (the-as dma-packet base) vif1) (new 'static 'vif-tag :irq #x1)) + ) + (else + (set! (-> base clear) (the-as uint 0)) + 0 + ) + ) + ) + ) + (&+! base 16) + ) + ) + base + ) + +(defun dma-bucket-insert-tag ((buckets (inline-array dma-bucket)) + (bucket bucket-id) + (start-tag pointer) + (end-tag-to-patch (pointer dma-tag)) + ) + (let ((v1-1 (-> buckets bucket))) + (set! (-> (the-as dma-bucket (-> v1-1 last)) next) (the-as uint start-tag)) + (set! (-> v1-1 last) end-tag-to-patch) + ) + start-tag + ) diff --git a/goal_src/jakx/engine/dma/dma-buffer.gc b/goal_src/jakx/engine/dma/dma-buffer.gc index 3e13e0f23e..16270ace5b 100644 --- a/goal_src/jakx/engine/dma/dma-buffer.gc +++ b/goal_src/jakx/engine/dma/dma-buffer.gc @@ -5,5 +5,470 @@ ;; name in dgo: dma-buffer ;; dgos: ENGINE, GAME +(defmacro gs-reg-list (&rest reg-ids) + "Generate a giftag register descriptor list from reg-ids." + + (let ((reg-count (length reg-ids))) + (when (> (length reg-ids) 16) + (ferror "too many regs passed to gs-reg-list") + ) + (let ((list-to-splice '()) + (cur-lst reg-ids) + (i -1)) + + ;; this is questionable. + (while (and (not (null? cur-lst)) (< i 15)) + (push! list-to-splice (cons 'gif-reg-id (cons (car cur-lst) '()))) + (push! list-to-splice (string->symbol-format ":regs{}" (inc! i))) + (pop! cur-lst) + ) + + `(new 'static 'gif-tag-regs + ,@list-to-splice + ) + ) + #| ;; the opengoal compiler does not have enough constant propagation for this for now + (let ((i -1)) + + `(the-as gif-tag-regs (logior ,@(apply (lambda (x) + `(shl (the-as uint (gif-reg-id ,x)) ,(* 4 (inc! i))) + ) reg-ids) + )) + + )|# + ) + ) + +(defmacro dma-buffer-add-base-type (buf pkt dma-type &rest body) + "Base macro for adding stuff to a dma-buffer. Don't use this directly!" + + (with-gensyms (dma-buf) + `(let* ((,dma-buf ,buf) + (,pkt (the-as ,dma-type (-> ,dma-buf base)))) + + ,@body + + (set! (-> ,dma-buf base) (&+ (the-as pointer ,pkt) (size-of ,dma-type))) + + ) + ) + ) + +(defmacro dma-buffer-add-base-data (buf data-type forms) + "Base macro for adding data words to a dma-buffer. + Each form in forms is converted into data-type and added to the buffer. NO TYPE CHECKING is performed, so be careful!" + + (with-gensyms (dma-buf ptr) + `(let* ((,dma-buf ,buf) + (,ptr (the-as (pointer ,data-type) (-> ,dma-buf base)))) + + ,@(apply-i (lambda (x i) `(set! (-> ,ptr ,i) (the-as ,data-type ,x))) forms) + + (set! (-> ,dma-buf base) (&+ (the-as pointer ,ptr) (* ,(length forms) (size-of ,data-type)))) + + ) + ) + ) + + +(defmacro dma-buffer-add-cnt-vif2 (buf qwc vif0 vif1) + "Add a dma-packet to a dma-buffer. + The packet is made up of a 'cnt' DMAtag (transfer qwc qwords of data after the tag and continue from after that point) + and includes two vif-tags for vifcode, or something else if needed." + + (with-gensyms (pkt) + `(dma-buffer-add-base-type ,buf ,pkt dma-packet + + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc ,qwc)) + + (set! (-> ,pkt vif0) ,vif0) + (set! (-> ,pkt vif1) ,vif1) + + ) + ) + ) + +(defmacro dma-buffer-add-ref-vif2 (buf qwc addr vif0 vif1) + "Add a dma-packet to a dma-buffer. + The packet is made up of a 'cnt' DMAtag (transfer qwc qwords of data at addr and continue from after the tag) + and includes two vif-tags for vifcode, or something else if needed." + + (with-gensyms (pkt) + `(dma-buffer-add-base-type ,buf ,pkt dma-packet + + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id ref) :qwc ,qwc :addr (the-as int ,addr))) + + (set! (-> ,pkt vif0) ,vif0) + (set! (-> ,pkt vif1) ,vif1) + + ) + ) + ) + +(defmacro dma-buffer-add-ret (buf) + "Add a dma-packet to a dma-buffer. This packet simply does a DMA 'return' " + + (with-gensyms (pkt) + `(dma-buffer-add-base-type ,buf ,pkt dma-packet + + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id ret) :qwc 0)) + + (set! (-> ,pkt vif0) (new 'static 'vif-tag :cmd (vif-cmd nop))) + (set! (-> ,pkt vif1) (new 'static 'vif-tag :cmd (vif-cmd nop))) + + ) + ) + ) + +(defmacro dma-buffer-add-gif-tag (buf giftag gifregs) + "Add a giftag to a dma-buffer." + + (with-gensyms (pkt) + `(dma-buffer-add-base-type ,buf ,pkt gs-gif-tag + + (set! (-> ,pkt tag) ,giftag) + + (set! (-> ,pkt regs) ,gifregs) + + ) + ) + ) + +(defmacro dma-buffer-add-uint64 (buf &rest body) + "Add 64-bit words to a dma-buffer. See dma-buffer-add-base-data" + + `(dma-buffer-add-base-data ,buf uint64 ,body) + ) + +(defmacro dma-buffer-add-uint128 (buf &rest body) + "Add 128-bit words to a dma-buffer. See dma-buffer-add-base-data" + + `(dma-buffer-add-base-data ,buf uint128 ,body) + ) + +(defmacro dma-buffer-add-gs-set-flusha (buf &rest reg-list) + "Add a gif cnt dma packet to a dma-buffer for setting GS registers. Up to 16 can be set at once. + The packet runs the flusha command which waits for GIF transfer to end and VU1 microprogram to stop. + reg-list is a list of pairs where the car is the register name and the cadr is the value to be set for that register." + + (let ((reg-count (length reg-list)) + (qwc (+ (length reg-list) 1)) + (reg-names (apply first reg-list)) + (reg-datas (apply second reg-list)) + ) + `(begin + ;; dma tag + (dma-buffer-add-cnt-vif2 ,buf ,qwc + (new 'static 'vif-tag :cmd (vif-cmd flusha)) + (new 'static 'vif-tag :cmd (vif-cmd direct) :imm ,qwc) + ) + + ;; gif tag for editing gs regs + (dma-buffer-add-gif-tag ,buf (new 'static 'gif-tag64 :nloop 1 :eop 1 :nreg ,reg-count) + (gs-reg-list a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d) + ) + + ;; gs regs + (dma-buffer-add-uint64 ,buf + ,@(apply2 (lambda (x) x) (lambda (x) `(gs-reg64 ,x)) reg-datas reg-names) + ) + ) + ) + ) + +(defmacro dma-buffer-add-gs-set (buf &rest reg-list) + "Add a gif cnt dma packet to a dma-buffer for setting GS registers. Up to 16 can be set at once. + reg-list is a list of pairs where the car is the register name and the cadr is the value to be set for that register." + + (let ((reg-count (length reg-list)) + (qwc (+ (length reg-list) 1)) + (reg-names (apply first reg-list)) + (reg-datas (apply second reg-list)) + ) + `(begin + ;; dma tag + (dma-buffer-add-cnt-vif2 ,buf ,qwc + (new 'static 'vif-tag :cmd (vif-cmd nop)) + (new 'static 'vif-tag :cmd (vif-cmd direct) :imm ,qwc) + ) + + ;; gif tag for editing gs regs + (dma-buffer-add-gif-tag ,buf (new 'static 'gif-tag64 :nloop 1 :eop 1 :nreg ,reg-count) + (gs-reg-list a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d) + ) + + ;; gs regs + (dma-buffer-add-uint64 ,buf + ,@(apply2 (lambda (x) x) (lambda (x) `(gs-reg64 ,x)) reg-datas reg-names) + ) + ) + ) + ) + +(defmacro with-cnt-vif-block (bindings &rest body) + "Start a cnt w/ vif direct to gif dma packet setup for the dma-buffer in bindings. + With this, you can transfer data through PATH2 without having to setup the tag yourself. + The qwc of the transfer is determined at runtime at the end of this block." + + (let ((buf (first bindings))) + + (with-gensyms (buf-start buf-qwc) + `(let ((,buf-start (-> ,buf base))) + + ;; setup the dmatag for PATH2 transfer, qwc is 0 (patched later) + (dma-buffer-add-cnt-vif2 ,buf 0 + (new 'static 'vif-tag :cmd (vif-cmd nop)) + (new 'static 'vif-tag :cmd (vif-cmd direct)) + ) + + ;; things with this buffer! + ,@body + + ;; patch qwc! just do the difference between the current ptr and the old one and turn it into qwords. + ;; we take one qword out because it's the initial dmatag which isnt part of the count. + ;; this rounds *down*, so make sure to fill the buffer in 128-bit boundaries. + (let ((,buf-qwc (/ (+ (&- -16 ,buf-start) (the int (-> ,buf base))) 16))) + (cond + ((nonzero? ,buf-qwc) ;; stuff was added to the buffer + ;; patch the DMA tag + (logior! (-> (the-as (pointer dma-tag) ,buf-start) 0) (the-as uint (new 'static 'dma-tag :qwc ,buf-qwc))) + ;; patch the 2nd vifcode's imm field (qwc) + (logior! (-> (the-as (pointer dma-tag) ,buf-start) 1) (the-as uint (shl (shr (shl ,buf-qwc 48) 48) 32))) + ) + (else ;; nothing was added to the buffer. delete the dmatag, you cannot transfer 0 qwords. + (set! (-> ,buf base) ,buf-start) + ) + ) + ) + ) + + )) + ) + +(defmacro with-cnt-vif-block-qwc (bindings &rest body) + "Start a cnt w/ vif direct to gif dma packet setup for the dma-buffer in bindings. + With this, you can transfer data through PATH2 without having to setup the tag yourself. + The qwc of the transfer is determined at runtime at the end of this block. + WARNING: You MUST guarantee that the resulting qwc is NOT zero!" + + (let ((buf (first bindings))) + + (with-gensyms (buf-start buf-qwc) + `(let ((,buf-start (the-as dma-packet (-> ,buf base)))) + ;; dmatag will be added at the end so we reserve + (&+! (-> ,buf base) 16) + + ;; setup the dmatag for PATH2 transfer, qwc is 0 (patched later) + (dma-buffer-add-cnt-vif2 ,buf 0 + (new 'static 'vif-tag :cmd (vif-cmd nop)) + (new 'static 'vif-tag :cmd (vif-cmd direct)) + ) + + ;; things with this buffer! + ,@body + + ;; we make the dmatag now! its at the start. + (let ((,buf-qwc (/ (+ (- -16 (the-as int ,buf-start)) (the-as int (-> ,buf base))) 16))) + (set! (-> ,buf-start dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc ,buf-qwc)) + (set! (-> ,buf-start vif0) (new 'static 'vif-tag)) + (set! (-> ,buf-start vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm ,buf-qwc)) + ) + ) + + )) + ) + +(defmacro with-dma-bucket (bindings &rest body) + "Start a new dma-bucket in body that will be finished at the end. + The bindings are the dma-buffer, dma-bucket and bucket-id respectively." + + (let ((buf (first bindings)) + (bucket (second bindings)) + (bucket-id (third bindings)) + ) + + (with-gensyms (buf-start bucket-edge pkt) + `(let ((,buf-start (-> ,buf base))) + + ,@body + + ;; we end the chain with a next. The bucket system will patch the next chain to this, + ;; and then patch all the buckets togehter before sending the DMA. + (let ((,bucket-edge (the (pointer dma-tag) (-> ,buf base)))) + + ;; if nothing was added, skip the tag entirely. + ;;(when (!= ,bucket-edge ,buf-start) + (let ((,pkt (the-as dma-packet (-> ,buf base)))) + + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> ,pkt vif0) (new 'static 'vif-tag :cmd (vif-cmd nop))) + (set! (-> ,pkt vif1) (new 'static 'vif-tag :cmd (vif-cmd nop))) + + (set! (-> ,buf base) (&+ (the-as pointer ,pkt) (size-of dma-packet))) + + ) + (dma-bucket-insert-tag ,bucket ,bucket-id + ,buf-start ;; the first thing in this chain, bucket will patch previous to this + ,bucket-edge ;; end of this chain (ptr to next tag) + ) + ;; ) + ) + ) + ) + ) + ) + +(defmacro with-dma-buffer-add-bucket (bindings &key (bucket-group (-> (current-frame) bucket-group)) &rest body) + "Bind a dma-buffer to a variable and use it on a block to allow adding things to a new bucket. + usage: (with-dma-buffer-add-bucket ((buffer-name buffer) bucket-id) &rest body) + example: (with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf)) (bucket-id debug-no-zbuf)) ...)" + + `(let ((,(caar bindings) ,(cadar bindings))) + (with-dma-bucket (,(caar bindings) ,bucket-group ,(cadr bindings)) + ,@body + ) + ) + ) + ;; DECOMP BEGINS +(deftype dma-packet (structure) + "The header for a DMA transfer, containing an DMA tag, and VIF tags." + ((dma dma-tag) + (vif0 vif-tag) + (vif1 vif-tag) + (quad uint128 :overlay-at dma) + ) + ) + + +(deftype dma-packet-array (inline-array-class) + "Unused dma array. Unclear how it should be used." + ((data dma-packet :dynamic) + ) + ) + + +(set! (-> dma-packet-array heap-base) (the-as uint 16)) + +(deftype dma-gif (structure) + "Believed unused GIF header type." + ((gif uint64 2) + (gif0 uint64 :overlay-at (-> gif 0)) + (gif1 uint64 :overlay-at (-> gif 1)) + (quad uint128 :overlay-at (-> gif 0)) + ) + ) + + +(deftype dma-gif-packet (structure) + "The header for a DMA transfer that goes directly to GIF, containing DMA, VIF, GIF tags." + ((dma-vif dma-packet :inline) + (gif uint64 2) + (gif0 uint64 :overlay-at (-> gif 0)) + (gif1 uint64 :overlay-at (-> gif 1)) + (quad uint128 2 :overlay-at (-> dma-vif dma)) + ) + ) + + +(deftype dma-buffer (basic) + "A buffer for DMA data." + ((allocated-length int32) + (base pointer) + (end pointer) + (real-buffer-end int32) + (data-buffer uint8 :dynamic :overlay-at real-buffer-end) + (data uint64 1 :offset 32) + ) + (:methods + (new (symbol type int) _type_) + ) + ) + + +(defmethod new dma-buffer ((allocation symbol) (type-to-make type) (size-bytes int)) + "Allocate a DMA buffer to hold the given size" + (let ((v0-0 (object-new allocation type-to-make (+ size-bytes -4 (-> type-to-make size))))) + (set! (-> v0-0 base) (-> v0-0 data)) + (set! (-> v0-0 allocated-length) size-bytes) + (set! (-> v0-0 real-buffer-end) (the-as int (&+ (-> v0-0 data) size-bytes))) + v0-0 + ) + ) + +(defun dma-buffer-inplace-new ((dma-buff dma-buffer) (size-bytes int)) + (set! (-> dma-buff base) (-> dma-buff data)) + (set! (-> dma-buff allocated-length) size-bytes) + dma-buff + ) + +(defmethod length ((this dma-buffer)) + (-> this allocated-length) + ) + +(defmethod asize-of ((this dma-buffer)) + (+ (-> this allocated-length) -4 (-> dma-buffer size)) + ) + +(defun dma-buffer-length ((dma-buf dma-buffer)) + (shr (+ (&- (-> dma-buf base) (the-as uint (-> dma-buf data))) 15) 4) + ) + +(defun dma-buffer-free ((dma-buf dma-buffer)) + (shr (+ (&- (-> dma-buf end) (the-as uint (-> dma-buf base))) 15) 4) + ) + +;; ERROR: Failed store: (s.w! (+ t2-0 8) t3-5) at op 23 +;; ERROR: Failed store: (s.w! (+ t2-0 12) t3-8) at op 32 +(defun dma-buffer-add-vu-function ((dma-buf dma-buffer) (vu-func vu-function) (flush-path-3 int)) + "Add DMA tags to load the given VU function. The destination in vu instruction memory + is specific inside the vu-function. This does NOT copy the vu-function into the buffer, + but creates a reference to the existing VU function." + ;; The first 4 bytes of a vu-function object's data are discarded because they aren't aligned. + (let ((func-ptr (the-as pointer (&-> vu-func data 4))) + ;; og:preserve-this we rely on the vu functions being empty on pc + (qlen (#if PC_PORT 0 (-> vu-func qlength))) ;; number of quadwords + (origin (-> vu-func origin)) ;; destination address in VU instruction memory. + ) + ;; loop until whole program is transferred. + (while (> qlen 0) + ;; transfer up to 127 quadwords at a single time. + (let ((qwc-now (min 127 qlen))) + ;; Set up DMA to transfer the data from the vu-function + ;; ref id = reference to data outside of the buffer. + (dma-buffer-add-ref-vif2 dma-buf qwc-now func-ptr + ;; Set up first vifcode as a flush. + (new 'static 'vif-tag :cmd (if (zero? flush-path-3) (vif-cmd flushe) (vif-cmd flusha))) + ;; next vifcode, transfer microprogram. This is in 64-bit units (VU instructions) + (new 'static 'vif-tag :cmd (vif-cmd mpg) :num (shl qwc-now 1) :imm origin) + ) + ;; increment by qwc-now quadwords. + (&+! func-ptr (shl qwc-now 4)) + (set! qlen (- qlen qwc-now)) + (+! origin (shl qwc-now 1)) + ) + ) + ) + #f + ) + +(defun dma-buffer-send ((chan dma-bank) (buf dma-buffer)) + "Send the DMA buffer! DOES NOT TRANSFER TAG, you probably want dma-buffer-send-chain instead." + (when (< (-> buf allocated-length) (&- (-> buf base) (the-as uint (-> buf data)))) + (crash!) + 0 + ) + (dma-send chan (the-as uint (-> buf data)) (the-as uint (dma-buffer-length buf))) + (none) + ) + +(defun dma-buffer-send-chain ((chan dma-bank-source) (buf dma-buffer)) + "Send the DMA buffer! Sends the tags, so this is suitable for the main graphics chain." + (when (< (-> buf allocated-length) (&- (-> buf base) (the-as uint (-> buf data)))) + (crash!) + 0 + ) + (dma-send-chain chan (the-as uint (-> buf data))) + (none) + ) \ No newline at end of file diff --git a/goal_src/jakx/engine/dma/dma-disasm.gc b/goal_src/jakx/engine/dma/dma-disasm.gc index 29b816640b..f31d8723d9 100644 --- a/goal_src/jakx/engine/dma/dma-disasm.gc +++ b/goal_src/jakx/engine/dma/dma-disasm.gc @@ -7,3 +7,715 @@ ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) + +(deftype vif-disasm-element (structure) + ((mask uint32) + (tag vif-cmd-32) + (val uint32) + (print uint32) + (string1 string) + (string2 string) + ) + ) + + +(define *vif-disasm-table* + (new 'static 'boxed-array :type vif-disasm-element + (new 'static 'vif-disasm-element :mask #x7f :string1 "nop") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 stcycl) :print #x2 :string1 "stcycl") + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 offset) + :print #x1 + :string1 "offset" + :string2 "offset" + ) + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 base) :print #x1 :string1 "base" :string2 "base") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 itop) :print #x1 :string1 "itop" :string2 "addr") + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 stmod) + :print #x1 + :string1 "stmod" + :string2 "mode" + ) + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 mskpath3) + :print #x1 + :string1 "mskpath3" + :string2 "mask" + ) + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 mark) :print #x1 :string1 "mark" :string2 "mark") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 flushe) :string1 "flushe") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 flush) :string1 "flush") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 flusha) :string1 "flusha") + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 mscal) + :print #x1 + :string1 "mscal" + :string2 "addr" + ) + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 mscnt) :string1 "mscnt") + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 mscalf) + :print #x1 + :string1 "mscalf" + :string2 "addr" + ) + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 stmask) + :print #x3 + :string1 "stmask" + :string2 "mask" + ) + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 strow) + :print #x4 + :string1 "strow" + :string2 "row" + ) + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 stcol) + :print #x4 + :string1 "stcol" + :string2 "col" + ) + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 mpg) :print #x5 :string1 "mpg") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 direct) :print #x6 :string1 "direct") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 directhl) :print #x6 :string1 "directhl") + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-s-32) + :val #x10 + :print #x7 + :string1 "unpack-s-32" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-s-16) + :val #x8 + :print #x7 + :string1 "unpack-s-16" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-s-8) + :val #x4 + :print #x7 + :string1 "unpack-s-8" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v2-32) + :val #x8 + :print #x7 + :string1 "unpack-v2-32" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v2-16) + :val #x4 + :print #x7 + :string1 "unpack-v2-16" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v2-8) + :val #x2 + :print #x7 + :string1 "unpack-v2-8" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v3-32) + :val #xc + :print #x7 + :string1 "unpack-v3-32" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v3-16) + :val #x6 + :print #x7 + :string1 "unpack-v3-16" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v3-8) + :val #x3 + :print #x7 + :string1 "unpack-v3-8" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v4-32) + :val #x10 + :print #x7 + :string1 "unpack-v4-32" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v4-16) + :val #x8 + :print #x7 + :string1 "unpack-v4-16" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v4-8) + :val #x4 + :print #x7 + :string1 "unpack-v4-8" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v4-5) + :val #x2 + :print #x7 + :string1 "unpack-v4-5" + ) + (new 'static 'vif-disasm-element :print #x8) + ) + ) + +(defun disasm-vif-details ((fmt-dest symbol) (vif-data (pointer uint8)) (unpack-cmd vif-cmd) (unpack-count int)) + "Disassemble the data stored in a vif unpack." + (let ((s4-0 unpack-count)) + (cond + ((= unpack-cmd (vif-cmd unpack-v4-8)) + (let ((s3-0 (&-> vif-data 4))) + (dotimes (s2-0 s4-0) + (format + fmt-dest + " #x~X: #x~2X #x~2X #x~2X #x~2X~%" + (+ (+ (* s2-0 4) 4) (the-as int vif-data)) + (-> s3-0 (* s2-0 4)) + (-> s3-0 (+ (* s2-0 4) 1)) + (-> s3-0 (+ (* s2-0 4) 2)) + (-> s3-0 (+ (* s2-0 4) 3)) + ) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-s-8)) + (let ((s3-1 (&-> vif-data 4))) + (dotimes (s2-1 s4-0) + (format fmt-dest " #x~X: #x~2x~%" (+ (+ s2-1 4) (the-as int vif-data)) unpack-count) + (-> s3-1 (* 3 s2-1)) + (-> s3-1 (+ (* 3 s2-1) 1)) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-v4-32)) + (let ((s3-2 (&-> vif-data 4))) + (dotimes (s2-2 s4-0) + (format + fmt-dest + " #x~X: #x~8x #x~8x #x~8x #x~8x~%" + (+ (+ (* s2-2 16) 4) (the-as int vif-data)) + (-> (the-as (pointer uint32) (&+ s3-2 (* (* s2-2 4) 4)))) + (-> (the-as (pointer uint32) (&+ s3-2 (* (+ (* s2-2 4) 1) 4)))) + (-> (the-as (pointer uint32) (&+ s3-2 (* (+ (* s2-2 4) 2) 4)))) + (-> (the-as (pointer uint32) (&+ s3-2 (* (+ (* s2-2 4) 3) 4)))) + ) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-v4-16)) + (let ((s3-3 (&-> vif-data 4))) + (dotimes (s2-3 s4-0) + (format + fmt-dest + " #x~X: #x~4x #x~4x #x~4x #x~4x~%" + (+ (+ (* s2-3 8) 4) (the-as int vif-data)) + (-> (the-as (pointer uint16) (&+ s3-3 (* (* s2-3 4) 2)))) + (-> (the-as (pointer uint16) (&+ s3-3 (* (+ (* s2-3 4) 1) 2)))) + (-> (the-as (pointer uint16) (&+ s3-3 (* (+ (* s2-3 4) 2) 2)))) + (-> (the-as (pointer uint16) (&+ s3-3 (* (+ (* s2-3 4) 3) 2)))) + ) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-v3-32)) + (let ((s3-4 (&-> vif-data 4))) + (dotimes (s2-4 s4-0) + (format + fmt-dest + " #x~X: #x~8x #x~8x #x~8x~%" + (+ (+ (* 12 s2-4) 4) (the-as int vif-data)) + (-> (the-as (pointer uint32) (&+ s3-4 (* 12 s2-4)))) + (-> (the-as (pointer uint32) (&+ s3-4 (* (+ (* 3 s2-4) 1) 4)))) + (-> (the-as (pointer uint32) (&+ s3-4 (* (+ (* 3 s2-4) 2) 4)))) + ) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-v3-16)) + (let ((s3-5 (&-> vif-data 4))) + (dotimes (s2-5 s4-0) + (format + fmt-dest + " #x~X: #x~4x #x~4x #x~4x~%" + (+ (+ (* 6 s2-5) 4) (the-as int vif-data)) + (-> (the-as (pointer uint16) (&+ s3-5 (* 6 s2-5)))) + (-> (the-as (pointer uint16) (&+ s3-5 (* (+ (* 3 s2-5) 1) 2)))) + (-> (the-as (pointer uint16) (&+ s3-5 (* (+ (* 3 s2-5) 2) 2)))) + ) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-v2-16)) + (let ((s3-6 (&-> vif-data 4))) + (dotimes (s2-6 s4-0) + (format + fmt-dest + " #x~X: #x~4x #x~4x~%" + (+ (+ (* s2-6 4) 4) (the-as int vif-data)) + (-> (the-as (pointer uint16) (&+ s3-6 (* 6 s2-6)))) + (-> (the-as (pointer uint16) (&+ s3-6 (* (+ (* 3 s2-6) 1) 2)))) + ) + ) + ) + ) + (else + (format + fmt-dest + " #x~X: Data format #b~b not yet supported, add it for yourself!~%" + (&-> vif-data 4) + unpack-cmd + ) + ) + ) + ) + #f + ) + +(defun disasm-vif-tag ((tag (pointer vif-tag)) (count int) (format-dest symbol) (details? symbol)) + "Disassemble vif tag, and possibly the associated data." + (let ((gp-0 0)) + (while (< gp-0 (* count 4)) + (let ((s0-0 4)) + (let ((s1-0 (-> tag 0))) + (format format-dest " #x~X:" tag) + (dotimes (v1-0 (-> *vif-disasm-table* length)) + (let ((sv-16 (-> s1-0 cmd))) + (when (= (logand sv-16 (-> *vif-disasm-table* v1-0 mask)) (-> *vif-disasm-table* v1-0 tag)) + (let ((a0-12 (-> *vif-disasm-table* v1-0 print))) + (cond + ((zero? a0-12) + (format format-dest " (~s :irq ~D)~%" (-> *vif-disasm-table* v1-0 string1) (-> s1-0 irq)) + ) + ((= a0-12 1) + (format + format-dest + " (~s :irq ~D :~s #x~X)~%" + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> *vif-disasm-table* v1-0 string2) + (-> s1-0 imm) + ) + ) + ((= a0-12 2) + (let ((t1-1 (-> s1-0 imm))) + (format + format-dest + " (~s :irq ~D :wl ~D :cl ~D)~%" + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (shr (shl t1-1 48) 56) + (shr (shl t1-1 56) 56) + ) + ) + ) + ((= a0-12 3) + (set! s0-0 8) + (format + format-dest + " (~s :irq ~D :~s #x~X)~%" + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> *vif-disasm-table* v1-0 string2) + (-> tag 1) + ) + ) + ((= a0-12 4) + (set! s0-0 20) + (format + format-dest + " (~s :irq ~D :~s " + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> *vif-disasm-table* v1-0 string2) + ) + (format format-dest "#x~X #x~X #x~X #x~X)~%" (-> tag 1) (-> tag 2) (-> tag 3) (-> tag 4)) + ) + ((= a0-12 5) + (format + format-dest + " (~s :irq ~D :instructions #x~D :addr #x~X)~%" + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> s1-0 num) + (-> s1-0 imm) + ) + ) + ((= a0-12 6) + (if (-> s1-0 imm) + (set! s0-0 #x100000) + (set! s0-0 (the-as int (* (-> s1-0 imm) 16))) + ) + (format + format-dest + " (~s :irq ~D :qwc #x~D)~%" + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> s1-0 imm) + ) + (let ((sv-32 (&-> tag 1)) + (sv-48 0) + ) + (while (< sv-48 (the-as int (-> s1-0 imm))) + (format + format-dest + " #x~X: #x~8x #x~8x #x~8x #x~8x~%" + (+ (+ (* sv-48 16) 4) (the-as int tag)) + (-> sv-32 (* sv-48 4)) + (-> sv-32 (+ (* sv-48 4) 1)) + (-> sv-32 (+ (* sv-48 4) 2)) + (-> sv-32 (+ (* sv-48 4) 3)) + ) + (+! sv-48 1) + ) + ) + #f + ) + ((= a0-12 7) + (set! s0-0 (the-as int (+ (logand -4 (+ (* (-> *vif-disasm-table* v1-0 val) (-> s1-0 num)) 3)) 4))) + (let ((sv-64 (-> s1-0 imm))) + (format + format-dest + " (~s :irq ~D :num ~D :addr #x~X " + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> s1-0 num) + (shr (shl sv-64 54) 54) + ) + (format + format-dest + ":msk ~D :flg ~D :usn ~D [skip ~d])~%" + (-> s1-0 msk) + (shr (shl sv-64 48) 63) + (shr (shl sv-64 49) 63) + (the-as uint s0-0) + ) + ) + (if details? + (disasm-vif-details + format-dest + (the-as (pointer uint8) tag) + (logand sv-16 (vif-cmd cmd-mask)) + (the-as int (-> s1-0 num)) + ) + ) + ) + ((= a0-12 8) + (format format-dest " (*unknown* vif-tag #x~X)~%" (-> s1-0 cmd)) + ) + ) + ) + (set! v1-0 (-> *vif-disasm-table* length)) + ) + ) + ) + ) + (+! gp-0 s0-0) + (&+! tag s0-0) + ) + ) + (- gp-0 (* count 4)) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defun disasm-dma-tag ((tag dma-tag) (format-dest symbol)) + "Disassemble just the 64-byte dma tag" + (format format-dest "(dma-tag ") + (let ((t9-1 format) + (a0-2 format-dest) + (a1-2 "~s") + (v1-1 (-> tag id)) + ) + (t9-1 a0-2 a1-2 (cond + ((= v1-1 (dma-tag-id refe)) + "refe" + ) + ((= v1-1 (dma-tag-id refs)) + "refs" + ) + ((= v1-1 (dma-tag-id ret)) + "ret" + ) + ((= v1-1 (dma-tag-id cnt)) + "cnt" + ) + ((= v1-1 (dma-tag-id next)) + "next" + ) + ((= v1-1 (dma-tag-id call)) + "call" + ) + ((= v1-1 (dma-tag-id ref)) + "ref" + ) + ((= v1-1 (dma-tag-id end)) + "end" + ) + (else + "*unknown*" + ) + ) + ) + ) + (if (> (-> tag addr) 0) + (format format-dest " :addr #x~8x" (-> tag addr)) + ) + (if (> (-> tag qwc) 0) + (format format-dest " :qwc ~d" (-> tag qwc)) + ) + (if (> (-> tag spr) 0) + (format format-dest " :spr ~d" (-> tag spr)) + ) + (if (> (-> tag irq) 0) + (format format-dest " :irq ~d" (-> tag irq)) + ) + (if (> (-> tag pce) 0) + (format format-dest " :pce ~d" (-> tag pce)) + ) + (format format-dest ")~%") + (none) + ) + +(define *dma-disasm* #t) + +;; WARN: Check prologue - tricky store of a0 +(defun disasm-dma-list ((data dma-packet) (mode symbol) (verbose symbol) (stream symbol) (expected-size int)) + "Print out an entire DMA list. + If mode is #t, print vif tags too. If mode is 'details, also print data unpacked by vif-tags. + If verbose is #t, print out the addresses of each tag, and total size statistics. + If expected size is negative, it is ignored. Otherwise, only disassemble this much dma data." + (let ((sv-32 data) + (s2-0 mode) + (s3-0 verbose) + (gp-0 stream) + (s1-0 expected-size) + ) + (if s3-0 + (format gp-0 "~%--- ~X -----------------------------~%" sv-32) + ) + (let ((s0-0 #f)) + (let ((s4-0 0) + (s5-0 0) + ) + (let ((sv-16 (the-as uint 0)) + (sv-48 0) + (sv-64 (the-as dma-packet 0)) + (sv-80 (the-as dma-packet 1)) + (sv-96 -1) + (sv-112 (new 'static 'dma-tag)) + ) + (while (not s0-0) + (let ((t9-1 valid?) + (a0-2 sv-32) + (a1-2 #f) + (a2-2 "dma-list tag pointer") + ) + (cond + ((not (t9-1 a0-2 (the-as type a1-2) a2-2 #t gp-0)) + (format gp-0 "ERROR: dma-list tag pointer invalid~%") + (set! s0-0 'error) + ) + (else + (set! sv-112 (-> (the-as dma-packet sv-32) dma)) + (when (not (or (zero? s5-0) (let ((t9-3 valid?) + (a0-4 sv-16) + (a1-4 #f) + ) + (set! a2-2 "dma-list data pointer") + (t9-3 a0-4 (the-as type a1-4) a2-2 #t gp-0) + ) + ) + ) + (format gp-0 "ERROR: dma-list data pointer invalid~%") + (set! s0-0 'error) + ) + (when (logtest? (the-as dma-tag #x3ff0000) sv-112) + (format gp-0 "ERROR: dma tag has data in reserved bits ~X~%" (the-as none a2-2)) + (set! s0-0 'error) + ) + ) + ) + ) + (when (or s3-0 (= s0-0 'error)) + (format gp-0 "#x~8x: " sv-32) + (cond + ((zero? sv-96) + (format gp-0 " ") + ) + ((= sv-96 1) + (format gp-0 " ") + ) + ) + (disasm-dma-tag sv-112 gp-0) + ) + (cond + (s0-0 + ) + ((or (= (-> sv-112 id) (dma-tag-id ref)) (= (-> sv-112 id) (dma-tag-id refs)) (zero? (-> sv-112 id))) + (set! sv-16 (-> sv-112 addr)) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (when s2-0 + (let ((v0-10 + (disasm-vif-tag (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) 2 gp-0 (= s2-0 'details)) + ) + ) + (disasm-vif-tag + (the-as (pointer vif-tag) (+ (the-as int sv-16) v0-10)) + (the-as int (- (* (the-as uint sv-48) 4) (the-as uint (/ v0-10 4)))) + gp-0 + (= s2-0 'details) + ) + ) + ) + (set! sv-32 (the-as dma-packet (&-> (the-as (pointer uint64) sv-32) 2))) + (if (= (-> sv-112 id) (dma-tag-id refe)) + (set! s0-0 #t) + ) + ) + ((= (-> sv-112 id) (dma-tag-id cnt)) + (set! sv-16 (the-as uint (&-> (the-as (pointer uint64) sv-32) 2))) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (if s2-0 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) + (the-as int (+ (* (the-as uint sv-48) 4) 2)) + gp-0 + (= s2-0 'details) + ) + ) + (set! sv-32 (the-as dma-packet (+ (the-as uint sv-32) (* (+ (the-as uint sv-48) 1) 16)))) + sv-32 + ) + ((= (-> sv-112 id) (dma-tag-id next)) + (set! sv-16 (the-as uint (&-> (the-as (pointer uint64) sv-32) 2))) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (if s2-0 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) + (the-as int (+ (* (the-as uint sv-48) 4) 2)) + gp-0 + (= s2-0 'details) + ) + ) + (when (= sv-32 (-> sv-112 addr)) + (format gp-0 "ERROR: next tag creates infinite loop.~%") + (set! s0-0 'error) + ) + (set! sv-32 (the-as dma-packet (-> sv-112 addr))) + sv-32 + ) + ((= (-> sv-112 id) (dma-tag-id call)) + (set! sv-16 (the-as uint (&-> (the-as (pointer uint64) sv-32) 2))) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (if s2-0 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) + (the-as int (+ (* (the-as uint sv-48) 4) 2)) + gp-0 + (= s2-0 'details) + ) + ) + (set! sv-32 (the-as dma-packet (-> sv-112 addr))) + (+! sv-96 1) + (cond + ((zero? sv-96) + (set! sv-64 (the-as dma-packet (&+ (the-as (pointer uint64) sv-16) (the-as uint sv-48)))) + sv-64 + ) + (else + (set! sv-80 (the-as dma-packet (&+ (the-as (pointer uint64) sv-16) (the-as uint sv-48)))) + sv-80 + ) + ) + ) + ((= (-> sv-112 id) (dma-tag-id ret)) + (set! sv-16 (the-as uint (&-> (the-as (pointer uint64) sv-32) 2))) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (if s2-0 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) + (the-as int (+ (* (the-as uint sv-48) 4) 2)) + gp-0 + (= s2-0 'details) + ) + ) + (let ((v1-123 sv-96)) + (cond + ((zero? v1-123) + (set! sv-32 sv-64) + sv-32 + ) + ((= v1-123 1) + (set! sv-32 sv-80) + sv-32 + ) + (else + (set! s0-0 #t) + ) + ) + ) + (+! sv-96 -1) + sv-96 + ) + ((= (-> sv-112 id) (dma-tag-id end)) + (set! sv-16 (the-as uint (&-> (the-as (pointer uint64) sv-32) 2))) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (set! s0-0 #t) + (if s2-0 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) + (the-as int (+ (* (the-as uint sv-48) 4) 2)) + gp-0 + (= s2-0 'details) + ) + ) + ) + (else + (format gp-0 "ERROR: Unknown DMA TAG command.~%") + (set! s0-0 'error) + ) + ) + (+! s4-0 sv-48) + (+! s5-0 1) + (if (and (>= s1-0 0) (>= s5-0 s1-0)) + (set! s0-0 #t) + ) + ) + ) + (when (or s3-0 (= s0-0 'error)) + (format gp-0 "NOTICE: Total tags: ~d~%" s5-0) + (format gp-0 "NOTICE: Total QWC: ~d~%" s4-0) + (format gp-0 "--------------------------------~%~%") + ) + ) + (!= s0-0 'error) + ) + ) + ) diff --git a/goal_src/jakx/engine/dma/dma-h.gc b/goal_src/jakx/engine/dma/dma-h.gc index 27b3a1d145..7e3d49be75 100644 --- a/goal_src/jakx/engine/dma/dma-h.gc +++ b/goal_src/jakx/engine/dma/dma-h.gc @@ -5,5 +5,251 @@ ;; name in dgo: dma-h ;; dgos: ENGINE, GAME +;; +++vif-cmd +;; all these have mask (only applies to unpacks) and interrupt not set. +(defenum vif-cmd + :bitfield #f + :type uint8 + (nop 0) ;; no-op, can still have irq set. + (stcycl 1) ;; set write recycle register + (offset 2) ;; set offset register + (base 3) ;; set base register + (itop 4) ;; set data pointer register (itops) + (stmod 5) ;; set mode register + (mskpath3 6) ;; set path 3 mask + (mark 7) ;; set mark register + (pc-port 8) ;; special tag for PC Port data. + (flushe 16) ;; wait for end of microprogram + (flush 17) ;; wait for end of microprogram and transfer (path1/path2) + (flusha 19) ;; wait for end of microprogram and transfer (path1/path2/path3) + (mscal 20) ;; activate microprogram (call) + (mscalf 21) ;; flushe and activate (call) + (mscnt 23) ;; activate microprogram (continue) + (stmask 32) ;; set MASK register. + (strow 48) ;; set filling data + (stcol 49) ;; set filling data + (mpg 74) ;; transfer microprogram + (direct 80) ;; straight to GIF. + (directhl 81) + (unpack-s-32 96) + (unpack-s-16 97) + (unpack-s-8 98) + ;; 99 is invllid + (unpack-v2-32 100) + (unpack-v2-16 101) + (unpack-v2-8 102) + ;; 103 is invalid + (unpack-v3-32 104) + (unpack-v3-16 105) + (unpack-v3-8 106) + ;; 107 is invalid + (unpack-v4-32 108) + (unpack-v4-16 109) + (unpack-v4-8 110) + (unpack-v4-5 111) + (cmd-mask 239) ;; not sure what this is. + ) +;; ---vif-cmd + + +;; +++vif-cmd-32 +;; this makes a copy of the above type, but uses a uint32. +(defenum vif-cmd-32 + :bitfield #f + :type uint32 + :copy-entries vif-cmd + ) +;; ---vif-cmd-32 + + +;; +++dma-tag-id +(defenum dma-tag-id + :bitfield #f + :type uint8 + (refe 0) ;; addr=ADDR, ends after this transfer + (cnt 1) ;; addr=after tag, next-tag=after data + (next 2) ;; addr=after tag, next-tag=ADDR + (ref 3) ;; addr=ADDR, next-tag=after tag + (refs 4) ;; ref, but stall controled + (call 5) ;; + (ret 6) ;; + (end 7) ;; next, but ends. + ) +;; ---dma-tag-id + + ;; DECOMP BEGINS +(deftype dma-chcr (uint32) + "Memory mapped DMA channel control register. Typically used to start and check on DMA transfer." + ((dir uint8 :offset 0 :size 1) + (mod uint8 :offset 2 :size 2) + (asp uint8 :offset 4 :size 2) + (tte uint8 :offset 6 :size 1) + (tie uint8 :offset 7 :size 1) + (str uint8 :offset 8 :size 1) + (tag uint16 :offset 16 :size 16) + ) + ) + + +(deftype dma-bank (structure) + "Bank of memory mapped DMA registers for a single channel. Used to control DMA." + ((chcr dma-chcr :offset 0) + (madr uint32 :offset 16) + (qwc uint32 :offset 32) + ) + ) + + +(deftype dma-bank-source (dma-bank) + "DMA channel registers for a DMA channel supporting source-chain." + ((tadr uint32 :offset 48) + ) + ) + + +(deftype dma-bank-vif (dma-bank-source) + "DMA channel registers for a DMA channel with call/ret stack." + ((as0 uint32 :offset 64) + (as1 uint32 :offset 80) + ) + ) + + +(deftype dma-bank-spr (dma-bank-source) + "DMA channel registers for a DMA channel supporting scratchpad transfer." + ((sadr uint32 :offset 128) + ) + ) + + +(deftype dma-ctrl (uint32) + "Main DMA control register, shared for all channels." + ((dmae uint8 :offset 0 :size 1) + (rele uint8 :offset 1 :size 1) + (mfd uint8 :offset 2 :size 2) + (sts uint8 :offset 4 :size 2) + (std uint8 :offset 6 :size 2) + (rcyc uint8 :offset 8 :size 3) + ) + ) + +(deftype dma-enable (uint32) + ((cpnd uint8 :offset 16 :size 1) + ) + ) + +(deftype dma-sqwc (uint32) + ((sqwc uint8 :offset 0 :size 8) + (tqwc uint8 :offset 16 :size 8) + ) + ) + +(deftype dma-bank-control (structure) + "Memory mapping for shared DMA registers." + ((ctrl dma-ctrl :offset 0) + (stat uint32 :offset 16) + (pcr uint32 :offset 32) + (sqwc dma-sqwc :offset 48) + (rbsr uint32 :offset 64) + (rbor uint32 :offset 80) + (stadr uint32 :offset 96) + (enabler uint32 :offset 5408) + (enablew uint32 :offset 5520) + ) + ) + + +(deftype vu-code-block (basic) + "Unused type for some VU code. vu-function is used instead." + ((name basic) + (code uint32) + (size int32) + (dest-address uint32) + ) + ) + + +(deftype vu-stat (uint64) + () + ) + +(deftype dma-tag (uint64) + "The 64-bit tag used by the DMA system." + ((qwc uint16 :offset 0 :size 16) + (pce uint8 :offset 26 :size 2) + (id dma-tag-id :offset 28 :size 3) + (irq uint8 :offset 31 :size 1) + (addr uint32 :offset 32 :size 31) + (spr uint8 :offset 63 :size 1) + ) + ) + + +(deftype dma-bucket (structure) + "A linked list of DMA data, typically all in the same category. Used to organize the full DMA chain." + ((tag dma-tag) + (last (pointer dma-tag)) + (dummy uint32) + (next uint32 :offset 4) + (clear uint64 :overlay-at last) + (vif0 uint32 :overlay-at last) + (vif1 uint32 :overlay-at dummy) + ) + ) + + +(deftype vif-mask (uint32) + ((m0 uint8 :offset 0 :size 2) + (m1 uint8 :offset 2 :size 2) + (m2 uint8 :offset 4 :size 2) + (m3 uint8 :offset 6 :size 2) + (m4 uint8 :offset 8 :size 2) + (m5 uint8 :offset 10 :size 2) + (m6 uint8 :offset 12 :size 2) + (m7 uint8 :offset 14 :size 2) + (m8 uint8 :offset 16 :size 2) + (m9 uint8 :offset 18 :size 2) + (m10 uint8 :offset 20 :size 2) + (m11 uint8 :offset 22 :size 2) + (m12 uint8 :offset 24 :size 2) + (m13 uint8 :offset 26 :size 2) + (m14 uint8 :offset 28 :size 2) + (m15 uint8 :offset 30 :size 2) + ) + ) + +(deftype vif-stcycl-imm (uint16) + "The imm field of a VIF code using STCYCL, which adjusts the pattern for storing data." + ((cl uint8 :offset 0 :size 8) + (wl uint8 :offset 8 :size 8) + ) + ) + +(deftype vif-unpack-imm (uint16) + "The imm field of a VIF code using UNPACK, which transfers data to VU memory." + ((addr uint16 :offset 0 :size 10) + (usn uint8 :offset 14 :size 1) + (flg uint8 :offset 15 :size 1) + ) + ) + +(deftype vif-tag (uint32) + "A tag consumed by the VIF, which accepts DMA data." + ((imm uint16 :offset 0 :size 16) + (num uint8 :offset 16 :size 8) + (cmd vif-cmd :offset 24 :size 7) + (irq uint8 :offset 31 :size 1) + (msk uint8 :offset 28 :size 1) + ) + ) + + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. diff --git a/goal_src/jakx/engine/dma/dma.gc b/goal_src/jakx/engine/dma/dma.gc index 9a84bc7fcb..c83c1591ae 100644 --- a/goal_src/jakx/engine/dma/dma.gc +++ b/goal_src/jakx/engine/dma/dma.gc @@ -7,3 +7,156 @@ ;; DECOMP BEGINS +(defun dma-sync-hang ((bank dma-bank)) + "Hang here until the dma transfer is completed. + This is worse than the dma-sync-fast because it ends + up spamming the DMA bank register more often, and reduces + the speed of the DMA transfer. + This function is unused." + (crash!) + (none) + ) + +(defun dma-sync-crash ((arg0 dma-bank)) + "Wait for DMA to finish for a while, then crash if we can't. + This function is unused." + (crash!) + (none) + ) + +(defun dma-send ((arg0 dma-bank) (madr uint) (qwc uint)) + "Send DMA given an address and a quadword count. + The madr can be in main memory or scratchpad. + This is appropriate for VIF0/GIF transfers. + It can be used for VIF1, but will do VIF -> madr, which is probably + not what you want." + (crash!) + (none) + ) + +(defun dma-send-chain ((arg0 dma-bank-source) (tadr uint)) + "Send DMA! tadr should be a tag address, possibly in spad ram. + This is useful for sending to VIF. + Tag transfer is enabled, and DIR is set so a VIF1 transfer + goes from tadr -> VIF." + (crash!) + (none) + ) + +(defun dma-send-chain-no-tte ((arg0 dma-bank-source) (arg1 uint)) + "Send DMA chain! TTE bit is not set, don't transfer tags. + This is never used." + (crash!) + (none) + ) + +(defun dma-send-chain-no-flush ((arg0 dma-bank-source) (arg1 uint)) + "Send DMA chain! But don't flush the cache, so be careful here. TTE enable." + (crash!) + (none) + ) + +(defun dma-send-to-spr ((sadr uint) (madr uint) (qwc uint) (sync symbol)) + "Transfer data to spr" + (crash!) + (none) + ) + +(defun dma-send-to-spr-no-flush ((sadr uint) (madr uint) (qwc uint) (sync symbol)) + "Transfer to spr. Doesn't flush the cache first, so be careful." + (crash!) + (none) + ) + +(defun dma-send-from-spr ((madr uint) (sadr uint) (qwc uint) (sync symbol)) + "Transfer from spr." + (crash!) + (none) + ) + +(defun dma-send-from-spr-no-flush ((madr uint) (sadr uint) (qwc uint) (sync symbol)) + "Transfer from spr, don't flush the cache." + (crash!) + (none) + ) + +(defun dma-initialize () + "Due to a bug in the PS2 hardware, you must always disable the DMAtag mismatch + error. This is done here." + + (#when PC_PORT + (return 0) + ) + + (set! (-> (the-as vif-bank #x10003800) err me0) 1) + (set! (-> (the-as vif-bank #x10003c00) err me0) 1) + (none) + ) + +(defun clear-vu0-mem () + "Set the vu0 data memory to 0xabadbeef. This uses the slow EE mapping of VU memory. + Will crash on PC Port." + (crash!) + (none) + ) + +(defun clear-vu1-mem () + "Set the vu1 data memory to 0xabadbeef. This uses the slow EE mapping of VU memory. + Will crash on PC Port." + (crash!) + (none) + ) + +(defun dump-vu1-mem () + "Print VU1 memory to runtime stdout. + Will crash on PC Port." + (crash!) + (none) + ) + +(defun dump-vu1-range ((start uint) (total-count uint)) + "Print part of VU1 memory to runtime stdout. + Will crash on PC Port." + (crash!) + #f + ) + +(defun reset-vif1-path () + "When things go wrong, totally reset vif1." + (#unless PC_PORT + ;; changed for jak 3! now prints to 0. + (format 0 "~`dma-bank-vif`I~`vif-bank`I" #x10009000 #x10003c00) + ) + (reset-path) + (set-graphics-mode) + (format 0 "gkernel: vif1 path reset!~%") + (none) + ) + +(defun ultimate-memcpy ((dst pointer) (src pointer) (size-bytes uint)) + "The Fastest Memory Copy, for larger transfers. + Memory is copied in ascending order, in 4 kB blocks. + The size should be a multiple of 16 bytes." + ;; on PC Port, just call C mem-move, it's the fastest. + (__mem-move dst src size-bytes) + (none) + ) + +(defun symlink2 () + "symlink2 is a handwritten assembly version of the v2 linking routine. + it is not ported because the OpenGOAL linker has its own implementation already." + (crash!) + (none) + ) + +(defun symlink3 () + "symlink3 is a handwritten assembly version of the v3 linking routine. + OpenGOAL uses a different format for v3, customized for x86-64, so this is not + needed. The C++ implementation is plenty fast enough" + (crash!) + (none) + ) + +;; configuration required to work around hardware bug on the PS2. +;; doesn't do anything important +(dma-initialize) \ No newline at end of file diff --git a/goal_src/jakx/engine/draw/draw-node-h.gc b/goal_src/jakx/engine/draw/draw-node-h.gc index b0b733db6a..ddae3e3a89 100644 --- a/goal_src/jakx/engine/draw/draw-node-h.gc +++ b/goal_src/jakx/engine/draw/draw-node-h.gc @@ -7,3 +7,35 @@ ;; DECOMP BEGINS +(deftype draw-node (drawable) + "Node in a bounding volume heirarchy. This is a base class, and there are no children. +The child is a pointer to the start of inline array of drawables (note: not a drawable-inline-array, literally a bunch of plain drawables) +The size of this array is child-count. The type is either more draw-nodes, or, some other drawable like tfragment, depending on the flags. +Different renderers have different restrictions on the tree structure, like max child count, or if all children have the same depth. +Generally, tfrag/collide use a very rigid equal depth, max 8 children rule, but with shrub, anything goes. +This is a very awkward data structure to traverse, but it is designed for fast view frustum culling. +Note that there can be multiple ways to reach drawables in here in some cases - for example you can follow +this tree, or check one of the depth arrays found in tfrag. +" + ((child-count uint8 :offset 6) + (flags uint8 :offset 7) + (child drawable :offset 8) + (distance float :offset 12) + ) + ) + + +(deftype drawable-inline-array-node (drawable-inline-array) + "Top level container for a BVH made of draw-nodes." + ((data draw-node 1 :inline) + (pad uint32) + ) + ) + +(deftype draw-node-dma (structure) + "DMA buffer layout for draw node culling routine, which copies draw-nodes directly to scratchpad in bulk. +This would not work with the memory layout of shrub." + ((banka draw-node 32 :inline) + (bankb draw-node 32 :inline) + ) + ) diff --git a/goal_src/jakx/engine/draw/drawable-actor-h.gc b/goal_src/jakx/engine/draw/drawable-actor-h.gc index 3463e964ab..d7b16d5a1d 100644 --- a/goal_src/jakx/engine/draw/drawable-actor-h.gc +++ b/goal_src/jakx/engine/draw/drawable-actor-h.gc @@ -7,3 +7,30 @@ ;; DECOMP BEGINS +(deftype drawable-actor (drawable) + "Wrapper around an entity-actor to put it in the drawable system. +Note that this is never used to actually draw actors - it is just used as a list of all entity-actors +for the entity/birth system." + ((actor entity-actor :offset 8) + ) + ) + + +(deftype drawable-tree-actor (drawable-tree) + "Adapater for putting the actors in the tree-array." + () + ) + +(deftype drawable-inline-array-actor (drawable-inline-array) + "Array of drawable-actors." + ((data drawable-actor 1 :inline) + (pad uint8 4) + ) + ) + +(defmethod draw ((this drawable-tree-actor)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + 0 + (none) + ) diff --git a/goal_src/jakx/engine/draw/drawable-group-h.gc b/goal_src/jakx/engine/draw/drawable-group-h.gc index 738248edf8..8e45cad482 100644 --- a/goal_src/jakx/engine/draw/drawable-group-h.gc +++ b/goal_src/jakx/engine/draw/drawable-group-h.gc @@ -7,3 +7,13 @@ ;; DECOMP BEGINS +(deftype drawable-group (drawable) + "Base class for an array of references to other drawables. +These are typically used for very high-level organization of drawable." + ((length int16 :offset 6) + (data drawable :dynamic) + ) + (:methods + (new (symbol type int) _type_) + ) + ) diff --git a/goal_src/jakx/engine/draw/drawable-h.gc b/goal_src/jakx/engine/draw/drawable-h.gc index 1e9193f121..74e3c07ece 100644 --- a/goal_src/jakx/engine/draw/drawable-h.gc +++ b/goal_src/jakx/engine/draw/drawable-h.gc @@ -5,5 +5,43 @@ ;; name in dgo: drawable-h ;; dgos: ENGINE, GAME +(declare-type region-prim-list structure) +(declare-type region-prim-area structure) +(declare-type draw-control structure) + +(define-extern sphere-cull "Is this sphere visible? Uses cached camera matrix registers, so use with care." (function vector symbol)) +(define-extern sphere-in-view-frustum? (function sphere symbol)) +(define-extern line-in-view-frustum? (function vector vector symbol)) +(define-extern vis-cull (function int symbol)) +(define-extern calc-vu1-lights (function vu-lights draw-control symbol none)) + ;; DECOMP BEGINS +(deftype drawable (basic) + "Base class for `drawable` scene graph system. +This base class is really abused in many ways, and the meaning of the various methods differ depending +on the exact type. Not even the ID and bsphere here are always populated. +This is used for very high level organization of different rendering data types, and also very low-level +culling/rendering optimizations. It supports both array-of-references and inline-array containers with precise +control over memory layout for use with DMA." + ((id int16) + (bsphere vector :inline) + ) + (:methods + (login (_type_) _type_) + (draw (_type_) none) + (drawable-method-11 (_type_) none) + (drawable-method-12 (_type_) none) + (collect-stats (_type_) none) + (debug-draw (_type_) none) + (unpack-vis (_type_ (pointer int8) (pointer int8)) (pointer int8)) + (collect-regions (_type_ sphere int region-prim-list) none) + ) + ) + + +(deftype drawable-error (drawable) + "A drawable which just represents an error. When drawn, it simply displays a sphere with an error message." + ((name string) + ) + ) diff --git a/goal_src/jakx/engine/draw/drawable-inline-array-h.gc b/goal_src/jakx/engine/draw/drawable-inline-array-h.gc index 897a087375..3b3f78a60e 100644 --- a/goal_src/jakx/engine/draw/drawable-inline-array-h.gc +++ b/goal_src/jakx/engine/draw/drawable-inline-array-h.gc @@ -7,3 +7,7 @@ ;; DECOMP BEGINS +(deftype drawable-inline-array (drawable) + ((length int16 :offset 6) + ) + ) diff --git a/goal_src/jakx/engine/draw/drawable-tree-h.gc b/goal_src/jakx/engine/draw/drawable-tree-h.gc index f7d40f2e14..c3cb02d832 100644 --- a/goal_src/jakx/engine/draw/drawable-tree-h.gc +++ b/goal_src/jakx/engine/draw/drawable-tree-h.gc @@ -7,3 +7,16 @@ ;; DECOMP BEGINS +(deftype drawable-tree (drawable-group) + "A drawable tree is a container of drawables of a specific rendering type. +Instead of having a single large tree of mixed types, there will be a tree of tfrags, a tree of ties, etc. +The top-level tfrag tree will have a type that's a child of drawable-tree. +Generally, the object passed to a large renderer is a drawable-tree." + () + ) + +(deftype drawable-tree-array (drawable-group) + "Collection of drawable trees. This might have a tfrag tree, tie tree, etc." + ((trees drawable-tree :dynamic :offset 32) + ) + ) diff --git a/goal_src/jakx/engine/engine/connect.gc b/goal_src/jakx/engine/engine/connect.gc index 0a26e298a9..04da033016 100644 --- a/goal_src/jakx/engine/engine/connect.gc +++ b/goal_src/jakx/engine/engine/connect.gc @@ -5,5 +5,683 @@ ;; name in dgo: connect ;; dgos: ENGINE, GAME +#|@file +This extremely confusing "connection system" allows the connection between +"engines" and "processes". Basically, a process can "register" itself with any number of "engines". +The "engines" can then iterate through all the connected processes. If a process is destroyed, it will +be removed from all engines. It is okay to connect a process to multiple engines, or even to the same engine +multiple times. + +Some example uses: +- a "foreground-engine" has connections to all foreground objects that need to be drawn on each frame. +- when a process wants to change a game setting, it opens a connection to the settings engine to request a change. + when the process is killed (or it stops requesting the change), the setting change is reverted. + +A "connection" is really just a function that gets called when the engine runs, or a set of parameters that the engine can iterate through. +|# + +(declare-type engine basic) + ;; DECOMP BEGINS +(deftype connectable (structure) + ((next0 connectable) + (prev0 connectable) + (next1 connectable) + (prev1 connectable) + ) + ) + + +(deftype connection (connectable) + "This is the actual data for the connection. +It may be used in multiple ways, but the most common is to use `param0` as a function. +It receives `param1`, `param2`, `param3`, and the engine as the arguments. +In some cases, the return value is checked for `'dead`." + ((param0 basic) + (param1 basic) + (param2 int32) + (param3 int32) + (quad uint128 2 :overlay-at next0) + ) + (:methods + (get-engine (connection) engine) + (get-process (connection) process) + (belongs-to-engine? (connection engine) symbol) + (belongs-to-process? (connection process) symbol) + (move-to-dead (connection) connection) + ) + ) + + +(deftype engine (basic) + "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. + +New for Jak 2: You can use a child class of [[connection]]." + ((name symbol) + (engine-time time-frame :offset 16) + (allocated-length int16 :offset 10) + (length int16 :offset 8) + (element-type type :offset 12) + (alive-list connectable :inline) + (alive-list-end connectable :inline) + (dead-list connectable :inline) + (dead-list-end connectable :inline) + (data connection :inline :dynamic) + ) + (:methods + (new (symbol type symbol int type) _type_) + (inspect-all-connections (engine) engine) + (apply-to-connections (engine (function connectable none)) int) + (apply-to-connections-reverse (engine (function connectable none)) int) + (execute-connections (engine object) int) + (execute-connections-and-move-to-dead (engine object) int) + (execute-connections-if-needed (engine object) int) + (add-connection (engine process object object object object) connection) + (remove-from-process (engine process) int) + (remove-matching (engine (function connection engine symbol)) int) + (remove-all (engine) int) + (remove-by-param0 (engine object) int) + (remove-by-param1 (engine int) int) + (remove-by-param2 (engine int) int) + (get-first-connectable (engine) connectable) + (get-last-connectable (engine) connectable) + (get-next-connectable (_type_ connectable) connectable) + (get-prev-connectable (_type_ connectable) connectable) + ) + ) + +(defmethod belongs-to-process? ((this connection) (arg0 process)) + "Does this connection belong to the given process?" + (= arg0 (get-process this)) + ) + +(defmethod print ((this connection)) + (format + #t + "#" + (-> this param0) + (-> this param1) + (-> this param2) + (-> this param3) + this + ) + this + ) + +;; WARN: Return type mismatch pointer vs engine. +(defmethod get-engine ((this connection)) + "Get the engine for this connection. This must be used on a live connection." + (while (-> (the-as connectable this) prev0) + (nop!) + (nop!) + (set! this (the-as connection (-> (the-as connectable this) prev0))) + ) + (the-as engine (&+ (the-as pointer this) -28)) + ) + +;; WARN: Return type mismatch pointer vs process. +(defmethod get-process ((this connection)) + "Get the process for this connection." + (while (-> (the-as connectable this) prev1) + (nop!) + (nop!) + (set! this (the-as connection (-> (the-as connectable this) prev1))) + ) + (the-as process (&+ (the-as pointer this) -124)) + ) + +(defmethod belongs-to-engine? ((this 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." + (and (< (the-as int arg0) (the-as int this)) + (< (the-as int this) (the-as int (&+ + (&+ (the-as pointer arg0) (-> arg0 type size)) + (* (-> arg0 allocated-length) (the-as int (-> arg0 element-type size))) + ) + ) + ) + ) + ) + +(defmethod get-first-connectable ((this engine)) + (-> this alive-list next0) + ) + +(defmethod get-last-connectable ((this engine)) + (-> this alive-list-end) + ) + +(defmethod get-next-connectable ((this engine) (arg0 connectable)) + (-> arg0 next0) + ) + +(defmethod get-prev-connectable ((this engine) (arg0 connectable)) + (-> arg0 prev0) + ) + +(defmethod new engine ((allocation symbol) (type-to-make type) (arg0 symbol) (arg1 int) (arg2 type)) + (let ((v0-0 + (object-new + allocation + type-to-make + (the-as int (+ (-> type-to-make size) (* (the-as uint arg1) (-> arg2 size)))) + ) + ) + ) + (set! (-> v0-0 allocated-length) arg1) + (set! (-> v0-0 length) 0) + (set! (-> v0-0 name) arg0) + (set! (-> v0-0 element-type) arg2) + (set! (-> v0-0 alive-list next0) (-> v0-0 alive-list-end)) + (set! (-> v0-0 alive-list prev0) #f) + (set! (-> v0-0 alive-list next1) #f) + (set! (-> v0-0 alive-list prev1) #f) + (set! (-> v0-0 alive-list-end next0) #f) + (set! (-> v0-0 alive-list-end prev0) (-> v0-0 alive-list)) + (set! (-> v0-0 alive-list-end next1) #f) + (set! (-> v0-0 alive-list-end prev1) #f) + (set! (-> v0-0 dead-list next0) (the-as connectable (-> v0-0 data))) + (set! (-> v0-0 dead-list prev0) #f) + (set! (-> v0-0 dead-list next1) #f) + (set! (-> v0-0 dead-list prev1) #f) + (set! (-> v0-0 dead-list-end next0) #f) + (set! (-> v0-0 dead-list-end prev0) + (the-as connectable (+ (+ (* (the-as uint (+ arg1 -1)) (-> arg2 size)) 92) (the-as uint v0-0))) + ) + (set! (-> v0-0 dead-list-end next1) #f) + (set! (-> v0-0 dead-list-end prev1) #f) + (let ((v1-9 (the-as object (-> v0-0 data)))) + (set! (-> v0-0 data 0 prev0) (-> v0-0 dead-list)) + (set! (-> v0-0 data 0 next0) (the-as connectable (&+ (the-as pointer v1-9) (-> arg2 size)))) + (let ((v1-10 (the-as object (&+ (the-as pointer v1-9) (-> arg2 size))))) + (let ((a0-6 1) + (a1-3 (+ arg1 -2)) + ) + (while (>= a1-3 a0-6) + (set! (-> (the-as connectable v1-10) prev0) + (the-as connectable (&- (the-as pointer v1-10) (the-as uint (-> arg2 size)))) + ) + ;; og:preserve-this cast changed to (pointer pointer) + (set! (-> (the-as (pointer pointer) v1-10)) (&+ (the-as pointer v1-10) (-> arg2 size))) + (set! v1-10 (&+ (the-as pointer v1-10) (-> arg2 size))) + (+! a0-6 1) + ) + ) + (set! (-> (the-as connectable v1-10) prev0) + (the-as connectable (&- (the-as pointer v1-10) (the-as uint (-> arg2 size)))) + ) + ;; og:preserve-this cast changed to (pointer collectable) + (set! (-> (the-as (pointer connectable) v1-10)) (-> v0-0 dead-list-end)) + ) + ) + v0-0 + ) + ) + +(defmethod print ((this engine)) + (format #t "#<~A ~A @ #x~X>" (-> this type) (-> this name) this) + this + ) + + +(defmethod length ((this engine)) + (-> this length) + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this engine)) + (the-as int (+ (-> this type size) (* (-> this allocated-length) (the-as int (-> this element-type size))))) + ) + +(defmethod apply-to-connections ((this engine) (arg0 (function connectable none))) + "Apply arg0 to all connections for the engine. + It's okay to have arg0 remove the connection." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (arg0 a0-1) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +(defmethod apply-to-connections-reverse ((this engine) (arg0 (function connectable none))) + "Apply arg0 to all connections, reverse order. + Do not use arg0 to remove yourself from the list." + (let ((s4-0 (-> this alive-list-end prev0))) + (while (!= s4-0 (-> this alive-list)) + (arg0 s4-0) + (set! s4-0 (-> s4-0 prev0)) + ) + ) + 0 + ) + +(defmethod execute-connections ((this engine) (arg0 object)) + "Run the engine!" + (set! (-> this engine-time) (-> *display* real-clock frame-counter)) + (let ((s4-0 (the-as connection (-> this alive-list-end prev0)))) + (while (!= s4-0 (-> this alive-list)) + ((the-as (function object object object object object) (-> s4-0 param0)) + (-> s4-0 param1) + (-> s4-0 param2) + (-> s4-0 param3) + arg0 + ) + (set! s4-0 (the-as connection (-> s4-0 prev0))) + ) + ) + 0 + ) + +(defmethod execute-connections-and-move-to-dead ((this engine) (arg0 object)) + "Run the engine! If any objects return `'dead`, remove them." + (set! (-> this engine-time) (-> *display* real-clock frame-counter)) + (let ((s4-0 (the-as connection (-> this alive-list-end prev0)))) + (while (!= s4-0 (-> this alive-list)) + (let ((v1-3 ((the-as (function object object object object object) (-> s4-0 param0)) + (-> s4-0 param1) + (-> s4-0 param2) + (-> s4-0 param3) + arg0 + ) + ) + ) + (set! s4-0 (the-as connection (-> s4-0 prev0))) + (if (= v1-3 'dead) + ((method-of-type connection move-to-dead) (the-as connection (-> s4-0 next0))) + ) + ) + ) + ) + 0 + ) + +(defmethod execute-connections-if-needed ((this engine) (arg0 object)) + "Execute connections, but only if it hasn't been done on this frame." + (if (!= (-> *display* real-clock frame-counter) (-> this engine-time)) + (execute-connections this arg0) + ) + 0 + ) + +(defun connection-process-apply ((arg0 process) (arg1 (function object none))) + "Apply a function to all connectables of a process." + (when arg0 + (let ((s5-0 (-> arg0 connection-list next1))) + (while s5-0 + (arg1 s5-0) + (set! s5-0 (-> s5-0 next1)) + ) + ) + #f + ) + ) + + +(defmethod add-connection ((this engine) (arg0 process) (arg1 object) (arg2 object) (arg3 object) (arg4 object)) + "Add a connection between this engine and a given process." + (let ((v1-0 (the-as connection (-> this dead-list next0)))) + (when (not (or (not arg0) (= v1-0 (-> this dead-list-end)))) + (set! (-> v1-0 param0) (the-as basic arg1)) + (set! (-> v1-0 param1) (the-as basic arg2)) + (set! (-> v1-0 param2) (the-as int arg3)) + (set! (-> v1-0 param3) (the-as int arg4)) + (set! (-> this dead-list next0) (-> v1-0 next0)) + (set! (-> v1-0 next0 prev0) (-> this dead-list)) + (set! (-> v1-0 next0) (-> this alive-list next0)) + (set! (-> v1-0 next0 prev0) v1-0) + (set! (-> v1-0 prev0) (-> this alive-list)) + (set! (-> this alive-list next0) v1-0) + (set! (-> v1-0 next1) (-> arg0 connection-list next1)) + (if (-> v1-0 next1) + (set! (-> v1-0 next1 prev1) v1-0) + ) + (set! (-> v1-0 prev1) (-> arg0 connection-list)) + (set! (-> arg0 connection-list next1) v1-0) + (+! (-> this length) 1) + v1-0 + ) + ) + ) + +(defmethod move-to-dead ((this connection)) + "Move this connection from the alive list to the dead list." + (let ((v1-1 (get-engine this))) + (set! (-> this prev0 next0) (-> this next0)) + (set! (-> this next0 prev0) (-> this prev0)) + (set! (-> this prev1 next1) (-> this next1)) + (if (-> this next1) + (set! (-> this next1 prev1) (-> this prev1)) + ) + (set! (-> this next0) (-> v1-1 dead-list next0)) + (set! (-> this next0 prev0) this) + (set! (-> this prev0) (-> v1-1 dead-list)) + (set! (-> v1-1 dead-list next0) this) + (+! (-> v1-1 length) -1) + ) + this + ) + +(defun process-disconnect ((arg0 process)) + "Disconnect all connections for the given process." + (when arg0 + (let ((gp-0 (-> arg0 connection-list next1))) + (while gp-0 + ((method-of-type connection move-to-dead) (the-as connection gp-0)) + (set! gp-0 (-> gp-0 next1)) + ) + ) + ) + 0 + ) + +(defmethod remove-from-process ((this engine) (arg0 process)) + "Remove all connections from process for this engine." + (when arg0 + (let ((s5-0 (-> arg0 connection-list next1))) + (while s5-0 + (if ((method-of-type connection belongs-to-engine?) (the-as connection s5-0) this) + ((method-of-type connection move-to-dead) (the-as connection s5-0)) + ) + (set! s5-0 (-> s5-0 next1)) + ) + ) + ) + 0 + ) + +(defmethod remove-matching ((this 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." + (let* ((s4-0 (-> this alive-list next0)) + (s3-0 (-> s4-0 next0)) + ) + (while (!= s4-0 (-> this alive-list-end)) + (if (arg0 (the-as connection s4-0) this) + ((method-of-type connection move-to-dead) (the-as connection s4-0)) + ) + (set! s4-0 s3-0) + (set! s3-0 (-> s3-0 next0)) + ) + ) + 0 + ) + +(defmethod remove-all ((this engine)) + "Remove all connections from an engine." + (let* ((a0-1 (-> this alive-list next0)) + (s5-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this 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)) + ) + ) + 0 + ) + +(defmethod remove-by-param0 ((this engine) (arg0 object)) + "Remove all connections with param0 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param0) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +(defmethod remove-by-param1 ((this engine) (arg0 int)) + "Remove all connections with param1 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param1) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +(defmethod remove-by-param2 ((this engine) (arg0 int)) + "Remove all connections with param2 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param2) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +(deftype connection-pers (structure) + "This is another engine system, very similar to the first, but not specific to a process. +Each connection has a `key`, which is like the process, but unlike normal engine, +the key's don't track which engine-pers they belong to. + +Unlike [[engine]], users can use [[engine-pers]] as a parent class." + ((next connection-pers) + (key object) + (update-time time-frame) + (param object 4) + (param-int32 int32 4 :overlay-at (-> param 0)) + (param-int64 int64 2 :overlay-at (-> param 0)) + (param-float float 4 :overlay-at (-> param 0)) + (param-quat uint128 :overlay-at (-> param 0)) + ) + ) + + +(deftype engine-pers (basic) + ((name symbol) + (length int16) + (allocated-length int16) + (element-type type) + (execute-time time-frame) + (alive-list connection-pers) + (dead-list connection-pers) + (data connection-pers :inline :dynamic) + ) + (:methods + (new (symbol type symbol int type) _type_) + (schedule-callback (_type_ object time-frame) connection-pers) + (kill-callback (_type_ connection-pers) none) + (kill-by-key (_type_ object) none) + (kill-matching (_type_ (function engine-pers connection-pers object object symbol) object object) none) + (update-callback (_type_) none) + (run-pending-updates! (_type_ time-frame) none) + ) + ) + + +(defmethod new engine-pers ((allocation symbol) (type-to-make type) (arg0 symbol) (arg1 int) (arg2 type)) + (let ((v0-0 (object-new + allocation + type-to-make + (the-as int (+ (-> type-to-make size) (* (the-as uint arg1) (-> arg2 size)))) + ) + ) + ) + (set! (-> v0-0 allocated-length) arg1) + (set! (-> v0-0 length) 0) + (set! (-> v0-0 name) arg0) + (set! (-> v0-0 element-type) arg2) + (set! (-> v0-0 alive-list) #f) + (set! (-> v0-0 dead-list) (the-as connection-pers (-> v0-0 data))) + (let ((v1-3 (the-as object (-> v0-0 data)))) + ;; og:preserve-this + (dotimes (a0-1 arg1) + (set! (-> (the-as (pointer uint32) v1-3) 0) (the-as uint (&+ (the-as pointer v1-3) (-> arg2 size)))) + (set! v1-3 (&+ (the-as pointer v1-3) (-> arg2 size))) + ) + (set! (-> (the-as (pointer symbol) (&- (the-as pointer v1-3) (the-as uint (-> arg2 size))))) #f) + ) + v0-0 + ) + ) + +(defmethod length ((this engine-pers)) + (-> this length) + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this engine-pers)) + (the-as int (+ (-> this type size) (* (-> this allocated-length) (the-as int (-> this element-type size))))) + ) + +(defmethod schedule-callback ((this engine-pers) (arg0 object) (arg1 time-frame)) + "Get a connection for this key. + If no connection exists, add it. + Schedule an update to happen in arg1 seconds." + (local-vars (v0-0 connection-pers)) + (let ((v1-0 (-> this alive-list))) + (while v1-0 + (when (= arg0 (-> v1-0 key)) + (set! v0-0 v1-0) + (goto cfg-8) + ) + (set! v1-0 (-> v1-0 next)) + ) + ) + (set! v0-0 (-> this dead-list)) + (when v0-0 + (set! (-> this dead-list) (-> v0-0 next)) + (set! (-> v0-0 next) (-> this alive-list)) + (set! (-> this alive-list) v0-0) + (+! (-> this length) 1) + (set! (-> v0-0 key) arg0) + (set! (-> v0-0 param-quat) (the-as uint128 0)) + 0 + ) + (label cfg-8) + (if v0-0 + (set! (-> v0-0 update-time) (+ (-> this execute-time) arg1)) + ) + v0-0 + ) + +(defmethod kill-callback ((this engine-pers) (arg0 connection-pers)) + "Called when a connection is removed." + 0 + (none) + ) + +(defmethod update-callback ((this engine-pers)) + "Called when a connection is run. + Users can override this as needed." + 0 + (none) + ) + +(defmethod kill-by-key ((this engine-pers) (arg0 object)) + "Remove connections with this key, calling `kill-callback`." + (let ((s4-0 (&-> this alive-list)) + (s2-0 (-> this alive-list)) + ) + (while s2-0 + (let ((s3-0 (-> s2-0 next))) + (cond + ((!= arg0 (-> s2-0 key)) + (set! s4-0 (&-> s2-0 next)) + ) + (else + (kill-callback this s2-0) + (set! (-> s4-0 0) (-> s2-0 next)) + (set! (-> s2-0 next) (-> this dead-list)) + (set! (-> this dead-list) s2-0) + (+! (-> this length) -1) + ) + ) + (set! s2-0 s3-0) + ) + ) + ) + 0 + (none) + ) + +(defmethod kill-matching ((this engine-pers) + (arg0 (function engine-pers connection-pers object object symbol)) + (arg1 object) + (arg2 object) + ) + "Call the given function on each connection. If it returns truthy, kill that connection." + (let ((s2-0 (&-> this alive-list)) + (s0-0 (-> this alive-list)) + ) + (while s0-0 + (let ((s1-0 (-> s0-0 next))) + (cond + ((not (arg0 this s0-0 arg1 arg2)) + (set! s2-0 (&-> s0-0 next)) + ) + (else + (kill-callback this s0-0) + (set! (-> s2-0 0) (-> s0-0 next)) + (set! (-> s0-0 next) (-> this dead-list)) + (set! (-> this dead-list) s0-0) + (+! (-> this length) -1) + ) + ) + (set! s0-0 s1-0) + ) + ) + ) + 0 + (none) + ) + +(defmethod run-pending-updates! ((this engine-pers) (arg0 time-frame)) + "Run updates if they scheduled. If something is found that has no pending update, kill it. + Note that we won't kill things on this call if they fail to update their `update-time`. + They will survive until the next call to `run-pending-updates`! + (or you can modify their `update-time` before that to prevent them from being killed.)" + (let ((s4-0 (-> this execute-time)) + (s2-0 (&-> this alive-list)) + (s1-0 (-> this alive-list)) + ) + (while s1-0 + (let ((s3-0 (-> s1-0 next))) + (cond + ((>= (-> s1-0 update-time) s4-0) + (update-callback this) + (set! s2-0 (&-> s1-0 next)) + ) + (else + (kill-callback this s1-0) + (set! (-> s2-0 0) (-> s1-0 next)) + (set! (-> s1-0 next) (-> this dead-list)) + (set! (-> this dead-list) s1-0) + (+! (-> this length) -1) + ) + ) + (set! s1-0 s3-0) + ) + ) + ) + (set! (-> this execute-time) arg0) + 0 + (none) + ) diff --git a/goal_src/jakx/engine/engine/engines.gc b/goal_src/jakx/engine/engine/engines.gc index 2cb4386253..3adff513b1 100644 --- a/goal_src/jakx/engine/engine/engines.gc +++ b/goal_src/jakx/engine/engine/engines.gc @@ -5,5 +5,65 @@ ;; name in dgo: engines ;; dgos: ENGINE, GAME +;; +++part-local-space-flags +(defenum part-local-space-flags + :type uint32 + :bitfield #t + (pls0 0) + (pls1 1) + (pls2 2) + ) +;; ---part-local-space-flags + ;; DECOMP BEGINS +(kmemopen global "engines") + +(define *background-draw-engine* (new 'global 'engine 'draw 6 connection)) + +(define *matrix-engine* (new 'global 'boxed-array handle 384)) + +(set! (-> *matrix-engine* length) 0) + +(define *cloth-engine* (new 'global 'boxed-array handle 32)) + +(set! (-> *cloth-engine* length) 0) + +(define *part-engine* (new 'global 'engine 'sparticle-launcher 256 connection)) + +(deftype particle-local-space-info (connection) + ((params basic 3 :overlay-at param1) + (mat-prev matrix :inline) + (mat-new matrix :inline) + (hand handle) + (flags part-local-space-flags) + (pad uint32 1) + ) + ) + + +(define *cam-post-hook-engine* (new 'global 'engine 'cam-post-hook-engine 4 connection)) + +(define *part-local-space-engine* + (new 'global 'engine 'particle-local-space-info 112 particle-local-space-info) + ) + +(define *camera-engine* (new 'global 'engine 'camera-eng 128 connection)) + +(when *debug-segment* +(define *debug-engine* (new 'debug 'engine 'debug 64 connection)) + +) +(define *pad-engine* (new 'global 'engine 'pad 4 connection)) + +(define *lightning-engine* (new 'global 'engine 'lightning-control 64 connection)) + +(define *hud-engine* (new 'global 'engine 'hud 16 connection)) + +(define *prim-client-engine* (new 'global 'engine 'prim-client 32 connection)) + +(define *prim-engine* (new 'global 'engine 'prim-strip 128 connection)) + +(define *task-manager-engine* (new 'global 'engine 'task-manager 16 connection)) + +(kmemclose) diff --git a/goal_src/jakx/engine/entity/entity-h.gc b/goal_src/jakx/engine/entity/entity-h.gc index d35a574f1c..bb002b013f 100644 --- a/goal_src/jakx/engine/entity/entity-h.gc +++ b/goal_src/jakx/engine/entity/entity-h.gc @@ -5,5 +5,157 @@ ;; name in dgo: entity-h ;; dgos: ENGINE, GAME +;; +++entity-perm-status +(defenum entity-perm-status + :bitfield #t + :type uint16 + (bit-0 0) ;; blocks birth + (error 1) + (dead 2) + (no-kill 3) + (bit-4 4) + (bit-5 5) + (subtask-complete 6) + (special 7) + (complete 8) + (bit-9 9) + (bit-10 10) + (save 11) + (bit-12 12) + (bit-13 13) + (bit-14 14) + (bit-15 15) + ) +;; ---entity-perm-status + ;; DECOMP BEGINS +(define *generate-actor-vis* #f) + +(define *generate-actor-vis-start* #f) + +(define *generate-actor-vis-output* #f) + +(deftype entity-perm (structure) + "Entity information that gets persisted in the save file." + ((user-object object 2) + (user-uint64 uint64 :overlay-at (-> user-object 0)) + (user-float float 2 :overlay-at (-> user-object 0)) + (user-int32 int32 2 :overlay-at (-> user-object 0)) + (user-uint32 uint32 2 :overlay-at (-> user-object 0)) + (user-int16 int16 4 :overlay-at (-> user-object 0)) + (user-uint16 uint16 4 :overlay-at (-> user-object 0)) + (user-int8 int8 8 :overlay-at (-> user-object 0)) + (user-uint8 uint8 8 :overlay-at (-> user-object 0)) + (status entity-perm-status) + (dummy uint8 1) + (task game-task) + (aid actor-id) + (quad uint128 :overlay-at (-> user-object 0)) + ) + (:methods + (update (_type_ symbol entity-perm-status) _type_) + ) + ) + + +(deftype entity-links (structure) + "A linked list of entities with some extra data about their current status." + ((prev-link entity-links) + (next-link entity-links) + (entity entity) + (process process) + (level level) + (vis-id int32) + (kill-mask task-mask) + (vis-dist meters) + (trans vector :inline) + (perm entity-perm :inline) + (status entity-perm-status :overlay-at (-> perm status)) + (aid uint32 :overlay-at (-> perm aid)) + (task game-task :overlay-at (-> perm task)) + ) + (:methods + (birth? (_type_ vector) symbol) + ) + ) + + +(deftype entity-perm-array (inline-array-class) + ((data entity-perm :inline :dynamic) + ) + ) + + +(set! (-> entity-perm-array heap-base) (the-as uint 16)) + +(deftype entity-links-array (inline-array-class) + "An array of [[entity-links]]. +Levels store a reference to this which holds all the entities in the level." + ((data entity-links :inline :dynamic) + ) + ) + + +(set! (-> entity-links-array heap-base) (the-as uint 64)) + +(deftype entity (res-lump) + "Entities are mainly used to place objects in a level. + +As a child of [[res-lump]], they store various types of metadata +in [[res-tag]]s (such as name, curve data, volume data, etc.) +that gets accessed by the accompanying process." + ((trans vector :inline) + (aid uint32) + (unknown uint32) + ) + (:methods + (birth! (_type_) _type_) + (kill! (_type_) _type_) + (entity-method-24 (_type_) _type_) + (entity-method-25 (_type_) _type_) + (get-level (_type_) level) + ) + ) + +;; type entity-camera is defined here, but it is unknown to the decompiler + +;; type entity-nav-mesh is defined here, but it is unknown to the decompiler + +;; type entity-race-mesh is defined here, but it is unknown to the decompiler + +;; type entity-actor is defined here, but it is unknown to the decompiler + +(deftype actor-reference (structure) + ((actor entity-actor) + (id uint32) + ) + :pack-me + ) + + +(deftype actor-group (inline-array-class) + ((data actor-reference :dynamic) + ) + ) + + +(set! (-> actor-group heap-base) (the-as uint 8)) + +(deftype entity-info (basic) + ((ptype object) + (pool symbol) + (heap-size int32) + ) + ) + + +(deftype actor-bank (basic) + ((pause-dist float) + (birth-dist float) + (birth-max int32) + ) + ) + + +(define *ACTOR-bank* (new 'static 'actor-bank :pause-dist 204800.0 :birth-dist 901120.0 :birth-max 10)) diff --git a/goal_src/jakx/engine/entity/res-h.gc b/goal_src/jakx/engine/entity/res-h.gc index 907c2c85da..5a004df78c 100644 --- a/goal_src/jakx/engine/entity/res-h.gc +++ b/goal_src/jakx/engine/entity/res-h.gc @@ -5,5 +5,70 @@ ;; name in dgo: res-h ;; dgos: ENGINE, GAME +;; +++res-lump-flags +(defenum res-lump-flags + :type uint16 + :bitfield #t + (sorted 0) + (rlf1 1) + ) +;; ---res-lump-flags + +;; +++res-tag-pair +;; made-up type +(deftype res-tag-pair (uint64) + "The indices of two [[res-tag]]s. If the specific key-frame time is in between two + res-tags, this type is used to return the indices of the first res-tag before and after + the specified time." + ((lo int32 :offset 0) + (hi int32 :offset 32) + ) + ) +;; ---res-tag-pair + +(declare-type entity-links structure) + ;; DECOMP BEGINS +(deftype res-tag (uint128) + "Metadata about a property in a [[res-lump]], such as name, element type and element count." + ((name symbol :offset 0 :size 32) + (key-frame float :offset 32 :size 32) + (elt-type type :offset 64 :size 32) + (data-offset uint16 :offset 96 :size 16) + (elt-count uint32 :offset 112 :size 15) + (inlined? uint8 :offset 127 :size 1) + ) + ) + +(deftype res-lump (basic) + "A collection of [[res-tag]]s and their data." + ((length int32) + (allocated-length int16) + (flags res-lump-flags) + (data-base pointer) + (data-top pointer) + (data-size int32) + (extra entity-links) + (tag (pointer res-tag)) + ) + (:methods + (new (symbol type int int) _type_) + (get-property-data (_type_ symbol symbol float pointer (pointer res-tag) pointer) pointer :no-virtual) + (get-property-struct (_type_ symbol symbol float structure (pointer res-tag) pointer) structure :no-virtual) + (get-property-value (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 :no-virtual) + (get-property-value-float (_type_ symbol symbol float float (pointer res-tag) pointer) float) + (get-tag-index-data (_type_ int) pointer) + (get-tag-data (_type_ res-tag) pointer) + (allocate-data-memory-for-tag! (_type_ res-tag) res-tag) + (sort! (_type_) _type_) + (add-data! (_type_ res-tag pointer) res-lump) + (add-32bit-data! (_type_ res-tag object) res-lump) + (lookup-tag-idx (_type_ symbol symbol float) res-tag-pair :no-virtual) + (make-property-data (_type_ float res-tag-pair pointer) pointer) + (get-curve-data! (_type_ curve symbol symbol float) symbol) + ) + ) + + +(define *res-key-string* (new 'global 'string 64 (the-as string #f))) diff --git a/goal_src/jakx/engine/game/effect-control-h.gc b/goal_src/jakx/engine/game/effect-control-h.gc index 4ae53ca7e3..835fef9a67 100644 --- a/goal_src/jakx/engine/game/effect-control-h.gc +++ b/goal_src/jakx/engine/game/effect-control-h.gc @@ -5,5 +5,27 @@ ;; name in dgo: effect-control-h ;; dgos: ENGINE, GAME -;; DECOMP BEGINS +;; +++effect-control-flag +(defenum effect-control-flag + :type uint32 + :bitfield #t + (ecf0 0) + (ecf1 1) + (ecf2 2) + (ecf3 3) + (ecf4 4) + (ecf5 5) + (ecf6 6) + (ecf7 7) + (ecf8 8) + (ecf9 9) + (ecf10 10) + (ecf11 11) + (ecf12 12) + (ecf13 13) + (ecf14 14) + (ecf15 15) + ) +;; ---effect-control-flag +;; DECOMP BEGINS diff --git a/goal_src/jakx/engine/game/game-h.gc b/goal_src/jakx/engine/game/game-h.gc index f1e3ccf2bb..108c31972c 100644 --- a/goal_src/jakx/engine/game/game-h.gc +++ b/goal_src/jakx/engine/game/game-h.gc @@ -5,5 +5,127 @@ ;; name in dgo: game-h ;; dgos: ENGINE, GAME +;; +++state-flags +(defenum state-flags + :bitfield #t + :type uint32 + (sf0 0) + (sf1 1) + (sf2 2) + (sf3 3) + (sf4 4) + (sf5 5) + (sf6 6) + (sf7 7) + (sf8 8) + (sf9 9) + (sf10 10) + (sf11 11) + (sf12 12) + (sf13 13) + (sf14 14) + (sf15 15) + (sf16 16) + (sf17 17) + (sf18 18) + (sf19 19) + (sf20 20) + (sf21 21) + (sf22 22) + (sf23 23) + (sf24 24) + (sf25 25) + (hang 26) + (sf27 27) + (invisible 28) + (sf29 29) + (sf30 30) + (sf31 31) + ) +;; ---state-flags + +;; +++attack-mask +(defenum attack-mask + :bitfield #t + :type uint32 + (trans 0) ;; 1 + (vector 1) ;; 2 + (intersection 2) ;; 4 + (attacker 3) ;; 8 + (attack-time 4) ;; 16 + (invinc-time 5) ;; 32 + (mode 6) ;; 64 + (shove-back 7) ;; 128 + (shove-up 8) ;; 256 + (speed 9) ;; 512 + (dist 10) ;; 1024 + (control 11) ;; 2048 + (angle 12) ;; 4096 + (rotate-to 13) ;; 8192 + (prev-state 14) ;; 16384 + (id 15) ;; 32768 + (count 16) ;; hi 1 + (penetrate-using 17) ;; hi 2 + (attacker-velocity 18);; hi 4 + (damage 19) ;; hi 8 + (shield-damage 20) ;; hi16 + (vehicle-damage-factor 21) ;; hi 32 + (vehicle-impulse-factor 22) ;; hi 64 + (knock 23) + (test 24) + (wpn-type 25) + ) +;; ---attack-mask + +(declare-type process-nettable process) +(declare-type process-drawable process-nettable) + +(declare-type nav-control structure) +(declare-type path-control basic) +(declare-type vol-control basic) +(declare-type fact-info basic) +(declare-type actor-link-info basic) +(declare-type water-control basic) +(declare-type carry-info basic) +(declare-type rigid-body-control basic) +(declare-type touching-shapes-entry structure) + ;; DECOMP BEGINS +(deftype attack-info (structure) + "Information about an incoming attack." + ((trans vector :inline :offset-assert 0) + (vector vector :inline :offset-assert 16) + (attacker-velocity vector :inline :offset-assert 32) + (intersection vector :inline :offset-assert 48) + (attacker handle :offset-assert 64) + (attack-time time-frame :offset-assert 72) ;; time-frame + (invinc-time time-frame :offset-assert 80) ;; time-frame + (mask attack-mask :offset-assert 88) ;; attack-mask + (mode symbol :offset-assert 92) ;; guessed by decompiler + (shove-back meters :offset-assert 96) + (shove-up meters :offset-assert 100) + (speed meters :offset-assert 104) + (dist meters :offset-assert 108) + (control float :offset-assert 112) + (angle symbol :offset-assert 116) ;; guessed by decompiler + (rotate-to degrees :offset-assert 120) ;; degrees + (prev-state state :offset-assert 124) ;; guessed by decompiler + (id uint32 :offset-assert 128) + (count uint8 :offset-assert 132) + (penetrate-using penetrate :offset-assert 136) ;; penetrate + (damage float :offset-assert 144) + (shield-damage float :offset-assert 148) + (vehicle-damage-factor float :offset-assert 152) + (vehicle-impulse-factor float :offset-assert 156) + (knock knocked-type :offset-assert 160) ;; knocked-type + (test symbol :offset-assert 164) ;; guessed by decompiler + ) + :method-count-assert 10 + :size-assert #xa8 + :flag-assert #xa000000a8 + ;; field handle is likely a value type. + (:methods + (attack-info-method-9 () none) ;; 9 ;; (attack-info-method-9 (_type_ attack-info process-drawable process-drawable) none) + ) + ) \ No newline at end of file diff --git a/goal_src/jakx/engine/game/game-info-h.gc b/goal_src/jakx/engine/game/game-info-h.gc index 10a33fdc37..9d63c1a88c 100644 --- a/goal_src/jakx/engine/game/game-info-h.gc +++ b/goal_src/jakx/engine/game/game-info-h.gc @@ -7,3 +7,7 @@ ;; DECOMP BEGINS +(deftype actor-id (uint32) + () + :flag-assert #x900000004 + ) \ No newline at end of file diff --git a/goal_src/jakx/engine/game/main-h.gc b/goal_src/jakx/engine/game/main-h.gc index 7a9ab66716..cf07e4a605 100644 --- a/goal_src/jakx/engine/game/main-h.gc +++ b/goal_src/jakx/engine/game/main-h.gc @@ -5,5 +5,913 @@ ;; name in dgo: main-h ;; dgos: ENGINE, GAME +(declare-type debug-menu-context basic) + +;; +++collide-spec +(defenum collide-spec + :bitfield #t + :type uint32 + (backgnd 0) + (jak 1) + (bot 2) + (crate 3) + (civilian 4) + (enemy 5) + (obstacle 6) + (vehicle-sphere 7) + (vehicle-debris 8) ; was hit-by-player-list + (hit-by-player-list 9) ; was hit-by-others-list + (hit-by-others-list 10) ; was player-list + (player-list 11) ; was water + (water 12) ; was collectable + (collectable 13) ; was blocking-plane + (blocking-plane 14) ; was projectile + (projectile 15) ; was jak-vulnerable + (jak-vulnerable 16) ; was camera-blocker + (camera-blocker 17) ; was los-blocker + (los-blocker 18) ; was notice-blue-eco-powerup + (nav-mesh 19) ; was tobot + (pusher 20) + (bot-targetable 21) ; was vehicle-mesh + (coliseum-ball 23) ; was jak-vehicle + (special-obstacle 22) ; unchanged semantically + (impenetrable-obj 25) ; was mech-punch + (obstacle-for-jak 24) ; was special-obstacle + (vehicle-sphere-no-probe 27) ; was vehicle-mesh-probeable + (shield 26) ; was obstacle-for-jak + (impenetrable-obj-alt 28) ; original impenetrable-obj (no mapping shown) + (shield-alt 29) ; original shield (no mapping shown) + (vehicle-mesh-no-block-use 30) + (vehicle-sphere-no-probe-alt 31) +) +;; ---collide-spec + +;; +++strip-lines-controls +(defenum strip-lines-controls + :type int64 + (none 0) + ; (strippable 1) + ; (convertible 2) + ; (good 3) + ; (edgeable 4) + ; (ordinary 8) + ; (color-mismatch 16) + ; (shader-mismatch 32) + ; (uv-mismatch 64) + ; (too-big 128) + ; (bad 240) + ; (all-edges 255) + ; (strips 256) + ; (frags 512) + ) +;; ---strip-lines-controls + +;; +++scene-controls +(defenum scene-controls + :type int64 + :bitfield #t + (channel) + (anim-name) + (dma-size) + (bounds-spheres) + (actors) + (actor-marks) + (special-fma-spheres) + (scene-controls-7) + (scene-controls-8) + (display-controls) + ) +;; ---scene-controls + +;; +++bot-marks-controls +(defenum bot-marks-controls + :type int64 + (all-off 0) + (course-spots 1) + (task-spots 2) + (all-on 3) + (bmc04 4) + (bmc05 5) + (bmc06 6) + (bmc07 7) + (bmc08 8) + (bmc09 9) + (bmc10 10) + (bmc11 11) + (bmc12 12) + (bmc13 13) + (bmc14 14) + (bmc15 15) + (bmc16 16) + ) +;; ---bot-marks-controls + +;; +++race-marks-controls +(defenum race-marks-controls + :type int64 + (all-off 0) + (path0-red 1) + (path1-green 2) + (path2-blue 4) + (path3-yellow 8) + (path4-cyan 16) + (path5-violet 32) + (path6-orange 64) + (path7-black 128) + (all-paths-on 255) + (rmc2040 2040) + ) +;; ---race-marks-controls + +;; +++race-selection +(defenum race-selection + :type int64 + (desertb-race-record 0) + (rs1 1) + (desrally-record 2) + ) +;; ---race-selection + +;; +++subdivide-setting +(defenum subdivide-setting + :type int64 + (textured 0) + (outline 1) + (gouraud 2) + (hack 3)) +;; ---subdivide-setting + +;; +++ocean-height-hack +(defenum ocean-height-hack + :type int64 + ; (zero 1) + ; (far-below 2) + ; (sewer-start 3) + ; (sewer-hi 4) + ; (sewer-med 5) + ; (sewer-lo 6) + ) +;; ---ocean-height-hack + + +;; +++text-id +(defenum text-id + :type uint32 + (null #x0) + + (text-id-341 341) + (text-id-342 342) + (text-id-343 343) + (text-id-344 344) + + (text-id-522 522) + + (text-id-1579 1579) + (text-id-1580 1580) + (text-id-1581 1581) + (text-id-1588 1588) + (text-id-1624 1624) + (text-id-1625 1625) + (text-id-1633 1633) + (text-id-1655 1655) + (text-id-1656 1656) + (text-id-1659 1659) + (text-id-1694 1694) + (text-id-1695 1695) + (text-id-1838 1838) + (text-id-1839 1839) + + (text-id-1940 1940) + + (text-id-2135 2135) + (text-id-2136 2136) + (text-id-2137 2137) + (text-id-2138 2138) + (text-id-2139 2139) + (text-id-2140 2140) + (text-id-2141 2141) + (text-id-2142 2142) + (text-id-2143 2143) + (text-id-2144 2144) + (text-id-2145 2145) + (text-id-2146 2146) + (text-id-2147 2147) + + (text-id-2149 2149) + + (text-id-2163 2163) + (text-id-2164 2164) + (text-id-2165 2165) + (text-id-2166 2166) + (text-id-2167 2167) + (text-id-2168 2168) + (text-id-2169 2169) + (text-id-2170 2170) + (text-id-2171 2171) + (text-id-2172 2172) + (text-id-2173 2173) + (text-id-2174 2174) + (text-id-2175 2175) + (text-id-2176 2176) + (text-id-2177 2177) + (text-id-2178 2178) + (text-id-2179 2179) + (text-id-2183 2183) + (text-id-2184 2184) + (text-id-2185 2185) + (text-id-2186 2186) + (text-id-2187 2187) + (text-id-2188 2188) + (text-id-2189 2189) + (text-id-2190 2190) + + (text-id-2208 2208) + (text-id-2209 2209) + (text-id-2210 2210) + (text-id-2211 2211) + (text-id-2212 2212) + (text-id-2213 2213) + (text-id-2214 2214) + (text-id-2215 2215) + (text-id-2216 2216) + (text-id-2217 2217) + (text-id-2218 2218) + (text-id-2219 2219) + (text-id-2220 2220) + (text-id-2221 2221) + + (text-id-2278 2278) + (text-id-2279 2279) + (text-id-2280 2280) + (text-id-2281 2281) + (text-id-2282 2282) + (text-id-2283 2283) + (text-id-2284 2284) + (text-id-2285 2285) + (text-id-2286 2286) + (text-id-2287 2287) + (text-id-2288 2288) + (text-id-2289 2289) + (text-id-2290 2290) + (text-id-2291 2291) + (text-id-2292 2292) + (text-id-2293 2293) + (text-id-2294 2294) + (text-id-2295 2295) + (text-id-2296 2296) + (text-id-2297 2297) + (text-id-2298 2298) + (text-id-2299 2299) + (text-id-2300 2300) + (text-id-2301 2301) + (text-id-2302 2302) + (text-id-2303 2303) + (text-id-2304 2304) + (text-id-2305 2305) + (text-id-2306 2306) + (text-id-2307 2307) + (text-id-2308 2308) + (text-id-2309 2309) + (text-id-2310 2310) + (text-id-2311 2311) + (text-id-2312 2312) + + (text-id-2513 2513) + + (text-id-2833 2833) + (text-id-2834 2834) + (text-id-2835 2835) + (text-id-2836 2836) + (text-id-2837 2837) + (text-id-2838 2838) + (text-id-2839 2839) + (text-id-2840 2840) + + (text-id-2842 2842) + (text-id-2843 2843) + (text-id-2844 2844) + (text-id-2845 2845) + (text-id-2846 2846) + (text-id-2847 2847) + (text-id-2848 2848) + (text-id-2849 2849) + (text-id-2850 2850) + (text-id-2851 2851) + (text-id-2852 2852) + (text-id-2853 2853) + (text-id-2854 2854) + (text-id-2855 2855) + (text-id-2856 2856) + (text-id-2857 2857) + (text-id-2858 2858) + (text-id-2859 2859) + (text-id-2860 2860) + (text-id-2861 2861) + (text-id-2862 2862) + (text-id-2863 2863) + (text-id-2864 2864) + (text-id-2865 2865) + (text-id-2866 2866) + (text-id-2867 2867) + (text-id-2868 2868) + (text-id-2869 2869) + (text-id-2870 2870) + (text-id-2871 2871) + (text-id-2872 2872) + (text-id-2873 2873) + (text-id-2874 2874) + (text-id-2875 2875) + (text-id-2876 2876) + (text-id-2877 2877) + (text-id-2878 2878) + (text-id-2879 2879) + (text-id-2880 2880) + (text-id-2881 2881) + (text-id-2882 2882) + (text-id-2883 2883) + (text-id-2884 2884) + (text-id-2885 2885) + + (text-id-2886 2886) + + (text-id-2961 2961) + (text-id-2962 2962) + (text-id-2963 2963) + (text-id-2964 2964) + (text-id-2965 2965) + (text-id-2966 2966) + (text-id-2967 2967) + (text-id-2968 2968) + (text-id-2969 2969) + (text-id-2970 2970) + (text-id-2971 2971) + (text-id-2972 2972) + (text-id-2973 2973) + (text-id-2974 2974) + (text-id-2975 2975) + (text-id-2976 2976) + (text-id-2977 2977) + (text-id-2978 2978) + (text-id-2979 2979) + (text-id-2980 2980) + (text-id-2981 2981) + (text-id-2982 2982) + (text-id-2983 2983) + (text-id-2984 2984) + (text-id-2985 2985) + (text-id-2986 2986) + (text-id-2987 2987) + (text-id-2988 2988) + (text-id-2989 2989) + (text-id-2990 2990) + (text-id-2991 2991) + (text-id-2992 2992) + (text-id-2993 2993) + (text-id-2994 2994) + (text-id-2995 2995) + (text-id-2996 2996) + (text-id-2997 2997) + (text-id-2998 2998) + (text-id-2999 2999) + (text-id-3000 3000) + (text-id-3001 3001) + (text-id-3002 3002) + (text-id-3003 3003) + (text-id-3004 3004) + (text-id-3005 3005) + (text-id-3006 3006) + (text-id-3007 3007) + (text-id-3008 3008) + (text-id-3009 3009) + + (text-id-4370 4370) + (text-id-4371 4371) + (text-id-4372 4372) + (text-id-4373 4373) + (text-id-4374 4374) + (text-id-4375 4375) + (text-id-4376 4376) + (text-id-4377 4377) + (text-id-4378 4378) + (text-id-4379 4379) + (text-id-4380 4380) + (text-id-4381 4381) + (text-id-4382 4382) + + (text-id-4660 4660) + (text-id-4661 4661) + (text-id-4662 4662) + (text-id-4663 4663) + (text-id-4664 4664) + (text-id-4665 4665) + (text-id-4666 4666) + (text-id-4667 4667) + (text-id-4668 4668) + (text-id-4669 4669) + (text-id-4670 4670) + (text-id-4671 4671) + (text-id-4672 4672) + (text-id-4673 4673) + (text-id-4674 4674) + (text-id-4675 4675) + (text-id-4676 4676) + (text-id-4677 4677) + (text-id-4678 4678) + (text-id-4679 4679) + (text-id-4680 4680) + (text-id-4681 4681) + (text-id-4682 4682) + (text-id-4683 4683) + (text-id-4684 4684) + (text-id-4685 4685) + (text-id-4686 4686) + (text-id-4687 4687) + (text-id-4688 4688) + (text-id-4689 4689) + (text-id-4690 4690) + (text-id-4691 4691) + + (text-id-4692 4692) + (text-id-4693 4693) + (text-id-4694 4694) + (text-id-4695 4695) + (text-id-4696 4696) + (text-id-4697 4697) + (text-id-4698 4698) + (text-id-4699 4699) + (text-id-4700 4700) + (text-id-4701 4701) + (text-id-4702 4702) + (text-id-4703 4703) + (text-id-4704 4704) + (text-id-4705 4705) + (text-id-4706 4706) + (text-id-4707 4707) + (text-id-4708 4708) + (text-id-4709 4709) + (text-id-4710 4710) + (text-id-4711 4711) + (text-id-4712 4712) + (text-id-4713 4713) + (text-id-4714 4714) + (text-id-4715 4715) + (text-id-4716 4716) + (text-id-4717 4717) + (text-id-4718 4718) + (text-id-4719 4719) + (text-id-4720 4720) + (text-id-4721 4721) + (text-id-4722 4722) + (text-id-4723 4723) + (text-id-4724 4724) + (text-id-4725 4725) + (text-id-4726 4726) + (text-id-4727 4727) + (text-id-4728 4728) + (text-id-4729 4729) + (text-id-4730 4730) + (text-id-4731 4731) + (text-id-4732 4732) + (text-id-4733 4733) + (text-id-4734 4734) + (text-id-4735 4735) + (text-id-4736 4736) + (text-id-4737 4737) + (text-id-4738 4738) + (text-id-4739 4739) + (text-id-4740 4740) + (text-id-4741 4741) + (text-id-4742 4742) + (text-id-4743 4743) + (text-id-4744 4744) + (text-id-4745 4745) + (text-id-4746 4746) + (text-id-4747 4747) + (text-id-4748 4748) + (text-id-4749 4749) + (text-id-4750 4750) + (text-id-4751 4751) + (text-id-4752 4752) + (text-id-4753 4753) + (text-id-4754 4754) + (text-id-4755 4755) + (text-id-4756 4756) + (text-id-4757 4757) + (text-id-4758 4758) + (text-id-4759 4759) + (text-id-4760 4760) + (text-id-4761 4761) + (text-id-4762 4762) + (text-id-4763 4763) + (text-id-4764 4764) + (text-id-4765 4765) + (text-id-4766 4766) + (text-id-4767 4767) + (text-id-4768 4768) + (text-id-4769 4769) + (text-id-4770 4770) + (text-id-4771 4771) + (text-id-4772 4772) + (text-id-4773 4773) + (text-id-4774 4774) + (text-id-4775 4775) + (text-id-4776 4776) + (text-id-4777 4777) + (text-id-4778 4778) + (text-id-4779 4779) + (text-id-4780 4780) + (text-id-4781 4781) + (text-id-4782 4782) + (text-id-4783 4783) + (text-id-4784 4784) + (text-id-4785 4785) + (text-id-4786 4786) + (text-id-4787 4787) + (text-id-4788 4788) + (text-id-4789 4789) + (text-id-4790 4790) + (text-id-4791 4791) + (text-id-4792 4792) + (text-id-4793 4793) + (text-id-4794 4794) + (text-id-4795 4795) + (text-id-4796 4796) + (text-id-4797 4797) + (text-id-4798 4798) + (text-id-4799 4799) + (text-id-4800 4800) + (text-id-4801 4801) + (text-id-4802 4802) + (text-id-4803 4803) + (text-id-4804 4804) + (text-id-4805 4805) + (text-id-4806 4806) + (text-id-4807 4807) + (text-id-4808 4808) + (text-id-4809 4809) + (text-id-4810 4810) + (text-id-4811 4811) +) + +;; ---text-id + ;; DECOMP BEGINS +(define *stats-poly* #f) + +(define *stats-memory* #f) + +(define *stats-memory-short* #f) + +(define *stats-memory-level-index* 0) + +(define *stats-collide* #f) + +(define *stats-bsp* #f) + +(define *stats-buffer* #f) + +(define *stats-target* #f) + +(define *stats-profile-bars* #f) + +(define *stats-perf* #f) + +(define *stats-sound* #f) + +(define *artist-all-visible* #f) + +(define *artist-flip-visible* #f) + +(define *artist-fix-visible* #f) + +(define *artist-fix-frustum* #f) + +(define *artist-error-spheres* #f) + +(define *artist-use-menu-subdiv* #f) + +(define *display-profile* #t) + +(define *display-sidekick-stats* #f) + +(define *display-quad-stats* #f) + +(define *display-tri-stats* #f) + +(define *display-ground-stats* #f) + +(define *display-collision-marks* #f) + +(define *display-collide-cache* #f) + +(define *display-render-collision* #f) + +(define *display-hipri-collision-marks* #f) + +(define *display-edge-collision-marks* #f) + +(define *display-geo-marks* #f) + +(define *display-target-marks* #f) + +(define *target-rc-board-controls* #f) + +(define *display-collide-history* 0) + +(define *amy-cam* #f) + +(define *display-xyz-axes* #f) + +(define *display-cam-collide-history* #f) + +(define *record-cam-collide-history* #f) + +(define *display-cam-master-marks* #f) + +(define *display-cam-other* #f) + +(define *display-camera-marks* #f) + +(define *camera-no-mip-correction* #f) + +(define *camera-turbo-free* #f) + +(define *suppress-vehicle-respawn* (the-as object #f)) + +(define *display-cam-los-info* #f) + +(define *display-cam-los-debug* #f) + +(define *display-cam-los-marks* #f) + +(define *display-cam-coll-marks* #f) + +(define *display-camera-info* #f) + +(define *display-camera-old-stats* #f) + +(define *display-camera-last-attacker* #f) + +(define *display-file-info* #f) + +(define *display-actor-marks* #f) + +(define *display-sprite-info* #f) + +(define *display-sprite-marks* #f) + +(define *display-sprite-spheres* #f) + +(define *display-bsp-errors* #t) + +(define *display-entity-errors* #t) + +(define *display-capture-mode* #f) + +(define *display-instance-info* #f) + +(define *display-deci-count* #f) + +(define *sync-dma* #f) + +(define *display-strip-lines* (the-as strip-lines-controls 0)) + +(define *display-battle-marks* #f) + +(define *display-joint-axes* #f) + +(define *display-nav-marks* #f) + +(define *display-nav-network* #f) + +(define *display-path-marks* #f) + +(define *display-vol-marks* #f) + +(define *display-water-marks* #f) + +(define *display-nav-mesh* #f) + +(define *display-race-mesh* #f) + +(define *display-ai-tuning* #f) + +(define *display-actor-pointer* #f) + +(define *display-actor-vis* #f) + +(define *display-actor-graph* #f) + +(define *display-traffic-height-map* #f) + +(define *display-trail-graph* #f) + +(define *display-color-bars* #f) + +(define *display-bug-report* #f) + +(define *display-level-border* #f) + +(define *display-memcard-info* #f) + +(define *display-split-boxes* #f) + +(define *display-split-box-info* #f) + +(define *display-texture-distances* #f) + +(define *display-texture-download* #f) + +(define *display-art-control* #f) + +(define *display-gui-control* #f) + +(define *display-level-spheres* #f) + +(define *time-of-day-fast* #f) + +(define *display-iop-info* #f) + +(define *slow-frame-rate* #f) + +(define *display-region-marks* #f) + +(define *execute-regions* #t) + +(define *disable-bot* #f) + +(define *debug-reverb* #f) + +(define *debug-whoosh* #f) + +(define *debug-engine-sounds* #f) + +(define *debug-pause* #f) + +(define *debug-view-anims* #f) + +(define *debug-unkillable* #f) + +(define *debug-player-vehicle-unkillable* #f) + +(define *debug-actor* (the-as process #f)) + +(define *debug-force-highspeed* #f) + +(define *gun-marks* #f) + +(define *debug-split-screen* #f) + +(define *ignore-want-load-display* #f) + +(define *bug-report-output-mode* (if *debug-segment* + 'file-stream + '*stdcon* + ) + ) + +(define *draw-debug-boxes* #f) + +(define *hide-menus* #f) + +(define *list-all-scenes* #f) + +(define *display-scene-control* (the-as scene-controls 0)) + +(define *display-bot-marks* (the-as bot-marks-controls 0)) + +(define *display-race-marks* (the-as race-marks-controls 0)) + +(define *race-record-path* #f) + +(define *select-race* (race-selection desrally-record)) + +(define *select-race-path* 0) + +(define *bot-record-path* -1) + +(define *subdivide-draw-mode* (the-as subdivide-setting 0)) + +(define *subdivide-scissor-draw-mode* (the-as subdivide-setting 0)) + +(define *subdivide-foreground-draw-mode* (the-as subdivide-setting 0)) + +(define *subdivide-ocean-draw-mode* (the-as subdivide-setting 0)) + +(define-perm *dproc* process #f) + +(define *run* #f) + +(define *teleport* #f) + +(define *teleport-count* 0) + +(define *draw-hook* nothing) + +(define *debug-hook* '()) + +(define *menu-hook* (the-as (function debug-menu-context) nothing)) + +(define *progress-hook* nothing) + +(define *dma-timeout-hook* nothing) + +(deftype frame-stats (structure) + ((field-time time-frame 2) + (field int32) + ) + ) + + +(define *frame-stats* (new 'static 'frame-stats)) + +(deftype screen-filter (basic) + ((draw? symbol) + (bucket bucket-id) + (depth int32) + (ztest uint64) + (color vector :inline) + (color-src vector :inline) + (color-dest vector :inline) + (extra vector :inline) + (speed float :overlay-at (-> extra data 0)) + (current-interp float :overlay-at (-> extra data 1)) + (lock-vsync? symbol) + (idx int32) + (frames int32) + ) + (:methods + (screen-filter-method-9 () none) + (screen-filter-method-10 () none) + (screen-filter-method-11 () none) + ) + ) + + +(deftype col-rend (basic) + ((draw? symbol) + (outline? symbol) + (show-back-faces? symbol) + (show-normals? symbol) + (ghost-hidden? symbol) + (show-only uint32) + (show-only-mask uint32) + (cspec collide-spec) + (track uint8) + (bbox-radius float) + (bbox-center vector :inline) + (camera-to-bbox-dist float) + ) + (:methods + (draw (_type_) none) + ) + ) + + +(define *col-rend* (new 'static 'col-rend + :draw? #f + :outline? #t + :show-back-faces? #t + :show-normals? #f + :ghost-hidden? #t + :cspec (collide-spec crate civilian enemy) + :track #x1 + :bbox-radius 24576.0 + :camera-to-bbox-dist 65536.0 + ) + ) + +(defun-debug debug-actor? ((arg0 object)) + (= arg0 *debug-actor*) + ) + +(define *record-fma* #f) + +(define *record-fma-use-path* #f) + +(define *record-fma-path-mode* #f) + +(define *record-fma-path-high-res* #f) + +(define *record-fma-path-dry-run* #f) + +(define *record-fma-real* #f) + +(define *record-fma-low-res* #f) + +(define *record-fma-start* 0) + +(define *record-fma-end* 0) + +(define *record-fma-pal* #f) + +(define *profile-slot* 0) + +(define *game-mode* #f) + +(define *lobby-local-players* 1) + +(define *first-boot* #t) + +(define *cheat-temp* (the-as (pointer int32) (malloc 'global 32))) diff --git a/goal_src/jakx/engine/game/penetrate-h.gc b/goal_src/jakx/engine/game/penetrate-h.gc index c999a935af..66b19f8bc9 100644 --- a/goal_src/jakx/engine/game/penetrate-h.gc +++ b/goal_src/jakx/engine/game/penetrate-h.gc @@ -5,5 +5,91 @@ ;; name in dgo: penetrate-h ;; dgos: ENGINE, GAME +;; +++knocked-type +(defenum knocked-type + :type uint8 + (none 0) + (mech-punch 1) + (explode-or-darkjak 2) + (dark-shot 3) + (yellow-shot 4) + (red-shot 5) + (blue-shot 6) + (vehicle 7) + (knocked-off 8) + ) +;; ---knocked-type + +;; +++penetrate +(defenum penetrate + :type uint64 + :bitfield #t + (touch 0) + (generic-attack 1) + (lunge 2) + (flop 3) + (punch 4) + (spin 5) + (roll 6) + (uppercut 7) + (bonk 8) + (tube 9) + (vehicle 10) + (flut-attack 11) + (board 12) + (mech 13) + (mech-punch 14) + (mech-bonk 15) + (dark-skin 16) + (dark-punch 17) + (dark-bomb 18) + (dark-smack 19) + (flut 20) + (shield 21) + (explode 22) + (jak-yellow-shot 23) + (jak-red-shot 24) + (jak-blue-shot 25) + (jak-dark-shot 26) + (enemy-yellow-shot 27) + (enemy-dark-shot 28) + (eco-yellow 29) + (eco-red 30) + (eco-blue 31) + (eco-green 32) + (knocked 33) + (jak-red-shockwave 34) + (jak-dark-nuke 35) + (jak-dark-blackhole 36) + (emp-blast 37) + (penetrate38 38) + (penetrate39 39) + (penetrate40 40) + (penetrate41 41) + (penetrate42 42) + (penetrate43 43) + (penetrate44 44) + (penetrate45 45) + (penetrate46 46) + (penetrate47 47) + (penetrate48 48) + (penetrate49 49) + (penetrate50 50) + (penetrate51 51) + (penetrate52 52) + (penetrate53 53) + (penetrate54 54) + (penetrate55 55) + (penetrate56 56) + (penetrate57 57) + (penetrate58 58) + (penetrate59 59) + (penetrate60 60) + (penetrate61 61) + (penetrate64 62) + (penetrate63 63) + ) +;; ---penetrate + ;; DECOMP BEGINS diff --git a/goal_src/jakx/engine/game/settings-h.gc b/goal_src/jakx/engine/game/settings-h.gc index 2ba8f6e913..a3a20d098e 100644 --- a/goal_src/jakx/engine/game/settings-h.gc +++ b/goal_src/jakx/engine/game/settings-h.gc @@ -5,5 +5,517 @@ ;; name in dgo: settings-h ;; dgos: ENGINE, GAME +(declare-type setting-control structure) +(define-extern *setting-control* setting-control) + +;; +++cam-master-options +(defenum cam-master-options + :type uint64 + :bitfield #t + (HAVE_TARGET) ;; 1 + (SET_COMBINER_AXIS) ;; 2 + (FLIP_COMBINER) ;; 4 + (HAVE_EASE_TO_POS) ;; 8 + (IN_BASE_REGION) ;; 10 + (IGNORE_ANALOG) ;; 20 + (BLOCK_RIGHT_STICK) ;; 40 + (USE_L1_R1) ;; 80 + (READ_BUTTONS) + (IMMEDIATE_STRING_MIN_MAX) + ) +;; ---cam-master-options + + +;; +++cam-slave-options +(defenum cam-slave-options + :type uint64 + :bitfield #t + (BUTT_CAM) + (SAME_SIDE) + (MOVE_SPHERICAL) + (ALLOW_Z_ROT) + (JUMP_PITCHES) + (COLLIDE) + (FIND_HIDDEN_TARGET) + (DRAG) + (PLAYER_MOVING_CAMERA) + (LINE_OF_SIGHT) + (MOVEMENT_BLOCKED) + (SHRINK_MAX_ANGLE) + (GOTO_GOOD_POINT) + (BIKE_MODE) + (NO_ROTATE) + (STICKY_ANGLE) + (BLOCK_RIGHT_STICK) + (ALLOW_SHIFT_BUTTONS) + (GUN_CAM) + (WIDE_FOV) + (RAPID_TRACKING) + (EASE_SPLINE_IDX) + (VERTICAL_FOLLOW_MATCHES_CAMERA) + (HAVE_BUTT_HANDLE) + (BOMBBOT) + (JUMP_LAG) + ) +;; ---cam-slave-options + + +;; +++game-feature +(defenum game-feature + :type uint64 + :bitfield #t + (feature0 0) + (feature1 1) + (feature2 2) + (feature3 3) + (feature4 4) + (gun 5) + (gun-red-1 6) + (gun-red-2 7) + (gun-red-3 8) + (gun-yellow-1 9) + (gun-yellow-2 10) + (gun-yellow-3 11) + (gun-blue-1 12) + (gun-blue-2 13) + (gun-blue-3 14) + (gun-dark-1 15) + (gun-dark-2 16) + (gun-dark-3 17) + (board 18) + (feature19 19) + (sidekick 20) + (feature21 21) + (feature22 22) + (gun-upgrade-yellow-ammo-1 23) + (gun-upgrade-yellow-ammo-2 24) + (gun-upgrade-red-ammo-1 25) + (gun-upgrade-red-ammo-2 26) + (gun-upgrade-blue-ammo-1 27) + (gun-upgrade-blue-ammo-2 28) + (gun-upgrade-dark-ammo-1 29) + (gun-upgrade-dark-ammo-2 30) + (feature31 31) + (feature32 32) + (feature33 33) + (feature34 34) + (feature35 35) + (feature36 36) + (board-launch 37) + (board-trail 38) + (board-zap 39) + (darkjak 40) + (darkjak-smack 41) + (darkjak-bomb0 42) + (darkjak-bomb1 43) + (darkjak-tracking 44) + (darkjak-invinc 45) + (lightjak 46) + (lightjak-regen 47) + (lightjak-swoop 48) + (lightjak-freeze 49) + (lightjak-shield 50) + (artifact-invis 51) + (armor0 52) + (armor1 53) + (armor2 54) + (armor3 55) + (jakc 56) + (lighteco 57) + (darkeco 58) + (feature59 59) + (feature60 60) + (feature61 61) + (feature62 62) + (feature63 63) + ) +;; ---game-feature + + +;; +++game-secrets +(defenum game-secrets + :type uint64 + :bitfield #t + (hero-mode 0) + ) +;; ---game-secrets + +(defmacro setting-control-func! (func s &rest args) + (let ((argb #f) + (argi 0) + (argf 0.0) + (setting (car s))) + (cond + (#t + (set! argb (car args)) + (set! argf (cadr args)) + (set! argi (caddr args)) + ) + ) + `(,func *setting-control* (with-pp pp) ,s ,argb ,argf ,argi) + ) + ) + +(defmacro add-setting! (s &rest args) + `(setting-control-func! add-setting ,s ,@args) + ) +(defmacro set-setting! (s &rest args) + `(setting-control-func! set-setting ,s ,@args) + ) +(defmacro remove-setting! (s) + `(remove-setting *setting-control* (with-pp pp) ,s) + ) + +;; +++game-score +(defenum game-score + :type uint64 + (none) + (gs0) + (gs1) + (gs2) + (gs3) + (gs4) + (gs5) + (gs6) + (gs7) + (gs8) + (gs9) + (gs10) + (gs11) + (gs12) + (gs13) + (gs14) + (gs15) + (gs16) + (gs17) + (gs18) + (gs19) + (gs20) + ) +;; ---game-score + + +;; +++game-vehicles +(defenum game-vehicles + :type uint64 + :bitfield #t + (v-turtle 0) + (v-snake 1) + (v-scorpion 2) + (v-toad 3) + (v-fox 4) + (v-rhino 5) + (v-mirage 6) + (v-x-ride 7) + ) +;; ---game-vehicles + + +(declare-type resetter-spec structure) + +;; +++game-vehicle-u8 +(defenum game-vehicle-u8 + :type uint8 + :bitfield #t + :copy-entries game-vehicles + ) +;; ---game-vehicle-u8 + +(defmacro language? (&rest langs) + "is the current language any of the ones specified?" + `(or ,@(apply (lambda (x) `(= (-> *setting-control* user-default language) (language-enum ,x))) langs))) + +(defmacro text-language? (&rest langs) + "is the current language any of the ones specified?" + `(or ,@(apply (lambda (x) `(= (-> *pc-settings* text-language) (pc-language ,x))) langs))) + ;; DECOMP BEGINS +(define *settings-dialog-volume* 0.95) + +(define *settings-music-volume* 0.7) + +(define *settings-sfx-volume* 0.75) + +(define *settings-music-seek-speed* 2.0) + +(deftype user-setting-data (structure) + ((border-mode symbol) + (process-mask process-mask) + (common-page int32) + (language language-enum) + (unknown-usd-1 int32) + (unknown-usd-2 int32) + (unknown-usd-3 int32) + (unknown-usd-4 int32) + (movie (pointer process)) + (talking (pointer process)) + (spooling (pointer process)) + (hint (pointer process)) + (ambient (pointer process)) + (video-mode symbol) + (aspect-ratio symbol) + (unknown-usd-5 int32) + (unknown-usd-6 int32) + (unknown-usd-7 int32) + (auto-save symbol) + (unknown-usd-8 int32) + (bg-r float) + (bg-g float) + (bg-b float) + (bg-a float) + (bg-a-speed float) + (bg-a-force float) + (blur-a float) + (blur-a-speed float) + (allow-progress symbol) + (allow-in-game-menu basic) + (allow-pause symbol) + (unknown-usd-9 int32) + (unknown-usd-10 int32) + (unknown-usd-11 int32) + (movie-name symbol) + (weather symbol) + (unknown-usd-12 int32) + (unknown-usd-13 int32) + (unknown-usd-14 int32) + (task-mask task-mask) + (unknown-usd-15 int32) + (speed-mult float) + (features uint64) + (vehicles uint64) + (sfx-volume float) + (sfx-volume-movie float) + (music-volume float) + (music-volume-movie float) + (dialog-volume float) + (dialog-volume-talker float) + (ambient-volume float) + (ambient-volume-movie float) + (dynamic-ambient-volume float) + (talker-volume float) + (mode-sound-bank uint32) + (sound-reverb float) + (sound-reverb-mode int32) + (sound-reverb-seek-speed float) + (stereo-mode int32) + (music symbol) + (spool-anim spool-anim) + (task-manager (pointer process)) + (task symbol) + (airlock symbol) + (minimap uint32) + (allow-continue symbol) + (unknown-usd-16 int32) + (unknown-usd-17 int32) + (subtitle symbol) + (doorway symbol) + (gem symbol) + (half-speed symbol) + (gun-buoy symbol) + (double-jump symbol) + (pilot symbol) + (pilot-exit symbol) + (pilot-death symbol) + (speech-control symbol) + (vehicle-hijacking symbol) + (endlessfall symbol) + (rain float) + (snow float) + (exclusive-load symbol) + (render symbol) + (allow-timeout symbol) + (mirror symbol) + (movie-skip-frame float) + (allow-blackout symbol) + (race-minimap int32) + (beard symbol) + (ignore-target symbol) + (subtitle-language uint8) + (sound-bank-load symbol) + (allow-error symbol) + (under-water-pitch-mod float) + (unknown-usd-18 int32) + (restart-info resetter-spec) + (fail-info resetter-spec) + (death-info resetter-spec) + (quit-info resetter-spec) + (extra-bank-count uint32) + (extra-bank pair 3) + (borrow-count uint32) + (borrow pair 3) + (exclusive-task-count uint32) + (exclusive-task int32 3) + (level-trans-time int32) + (unknown-usd-19 int32) + (unknown-usd-20 int32) + (unknown-usd-21 int32) + (unknown-usd-22 int32) + (unknown-usd-23 int32) + (letterbox float) + (letterbox-speed float) + (unknown-usd-24 int32) + (unknown-usd-25 int32) + (unknown-usd-26 int32) + (unknown-usd-27 int32) + (unknown-usd-28 int32) + (unknown-usd-29 int32) + (unknown-usd-30 int32) + (unknown-usd-31 int32) + (unknown-usd-32 int32) + (borrow-city-count uint32) + (borrow-city pair 3) + (unknown-usd-33 int32 28) + (audio-language uint8) + (unknown-usd-34 int32 11) + (special-volume float) + (unknown-usd-35 int32 17) + ) + (:methods + (user-setting-data-method-9 () none) + (user-setting-data-method-10 () none) + ) + ) + + +(deftype cam-setting-data (structure) + ((fov degrees) + (pov-handle uint64 :offset 16) + (pov-bone int32) + (pov-offset vector :inline) + (string-default symbol) + (string-max-length meters) + (string-min-length meters) + (string-max-height meters) + (string-min-height meters) + (string-cliff-height meters) + (string-camera-floor meters) + (string-camera-ceiling meters) + (gun-max-height meters) + (gun-min-height meters) + (string-local-down vector :inline) + (slave-options cam-slave-options) + (matrix-blend-max-angle degrees) + (matrix-blend-max-partial float) + (string-spline-max-move meters) + (string-spline-accel meters) + (string-spline-max-move-player meters) + (string-spline-accel-player meters) + (string-startup-vector vector :inline) + (use-string-startup-vector symbol) + (look-at-point vector :inline) + (use-look-at-point symbol) + (target-height meters) + (foot-offset meters) + (head-offset meters) + (teleport-on-entity-change symbol) + (entity-name string) + (cam-slope string) + (entity-or-mode-changed symbol) + (master-options cam-master-options) + (entity-mask uint32) + (mode-name symbol) + (real-entity-name string) + (cam-mode symbol) + (interp-time uint32) + (no-intro symbol) + (use-point-of-interest symbol) + (point-of-interest vector :inline) + (handle-of-interest uint64) + (mouse-tumble-point vector :inline) + (use-mouse-tumble-point symbol) + (mouse-input symbol) + (cpad1-skip-buttons symbol) + (butt-handle uint64) + (butt-angle float) + (extra-follow-height float) + (interp-time-priority uint32) + (string-max-length-default symbol) + (string-min-length-default symbol) + (string-max-height-default symbol) + (string-min-height-default symbol) + (flip-vertical symbol) + (flip-horizontal symbol) + (dummy object 1) + (fov-priority float) + (ocean-off basic) + (ocean-override basic) + (crash-cam-force-freeze basic) + ) + (:methods + (cam-setting-data-method-9 () none) + (cam-setting-data-method-10 () none) + ) + ) + + +(deftype cam-setting-state (structure) + ((current cam-setting-data :inline) + (target cam-setting-data :inline) + (default cam-setting-data :inline) + ) + ) + + +(deftype engine-group (structure) + ((engine basic) + (engine-pers basic) + (engine-hi basic) + ) + ) + + +(deftype setting-control (basic) + ((user-current user-setting-data :inline) + (user-target user-setting-data :inline) + (user-default user-setting-data :inline) + (cam-settings cam-setting-state 4 :inline) + (engine engine) + (engine-pers engine-pers) + (engine-hi engine) + (cam-engines engine-group 4) + ) + (:methods + (new (symbol type int) _type_) + (setting-control-method-9 () none) + (setting-control-method-10 () none) + (setting-control-method-11 () none) + (setting-control-method-12 () none) + (setting-control-method-13 () none) + (setting-control-method-14 () none) + (setting-control-method-15 () none) + (setting-control-method-16 () none) + (setting-control-method-17 () none) + (setting-control-method-18 () none) + (setting-control-method-19 () none) + (setting-control-method-20 () none) + (setting-control-method-21 () none) + (setting-control-method-22 () none) + (setting-control-method-23 () none) + (setting-control-method-24 () none) + ) + ) + + +(defmethod new setting-control ((allocation symbol) (type-to-make type) (arg0 int)) + (let ((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 arg0 connection)) + (set! (-> s4-0 engine-hi) ((method-of-type engine new) allocation engine 'setting-control arg0 connection)) + (set! (-> s4-0 engine-pers) + ((method-of-type engine-pers new) allocation engine-pers 'setting-control arg0 connection-pers) + ) + (dotimes (s3-0 4) + (set! (-> s4-0 cam-engines s3-0) (new 'global 'engine-group)) + (set! (-> s4-0 cam-engines s3-0 engine) + ((method-of-type engine new) allocation engine 'setting-control arg0 connection) + ) + (set! (-> s4-0 cam-engines s3-0 engine-hi) + ((method-of-type engine new) allocation engine 'setting-control arg0 connection) + ) + (set! (-> s4-0 cam-engines s3-0 engine-pers) + ((method-of-type engine-pers new) allocation engine-pers 'setting-control arg0 connection-pers) + ) + ) + s4-0 + ) + ) diff --git a/goal_src/jakx/engine/game/task/game-task-h.gc b/goal_src/jakx/engine/game/task/game-task-h.gc index d298103918..148a65f2d2 100644 --- a/goal_src/jakx/engine/game/task/game-task-h.gc +++ b/goal_src/jakx/engine/game/task/game-task-h.gc @@ -5,5 +5,552 @@ ;; name in dgo: game-task-h ;; dgos: ENGINE, GAME + +;; +++game-task +(defenum game-task + :type uint8 + :bitfield #f + (unknown -1) +) +;; ---game-task + +;; +++game-task-node +(defenum game-task-node + :type uint16 + (none) + ) +;; ---game-task-node + ;; DECOMP BEGINS +(define *net-play-mode-names* (new 'static 'boxed-array :type symbol + 'race + 'deathrace + 'timebox + 'timetrial + 'deathmatch + 'hunt + 'collect + 'ctf + 'reversi + 'team-deathmatch + 'football + 'artifact + 'king-of-hill + 'rushhour + 'assassin + 'training + 'training2 + 'boss-battle + 'artist + 'invalid + 'intro-b + ) + ) + +(define *net-play-mode-text-ids* (new 'static 'array text-id 24 + (text-id text-id-1581) + (text-id text-id-1588) + (text-id text-id-1655) + (text-id text-id-2183) + (text-id text-id-1580) + (text-id text-id-1579) + (text-id text-id-1838) + (text-id text-id-1694) + (text-id text-id-1839) + (text-id text-id-1695) + (text-id text-id-1624) + (text-id text-id-1625) + (text-id text-id-1633) + (text-id text-id-1656) + (text-id text-id-2513) + (text-id text-id-1659) + (text-id text-id-1659) + (text-id text-id-1940) + (text-id null) + (text-id null) + (text-id null) + (text-id null) + (text-id null) + (text-id null) + ) + ) + +(define *net-play-mode-icon-string* (new 'static 'boxed-array :type string + "amode-icon-crace-01" + "amode-icon-drace-01" + "amode-icon-ttrial-01" + "amode-icon-ttrial-01" + "amode-icon-dmatch-01" + "amode-icon-shunt-01" + "common-white" + "amode-icon-cflag-01" + "common-white" + "common-white" + "amode-icon-derby-01" + "amode-icon-arace-01" + "common-white" + "amode-icon-rhour-01" + "common-white" + "common-white" + "common-white" + "common-white" + "common-white" + "common-white" + ) + ) + +(deftype task-level-info (structure) + ((flags uint32) + (text-id uint32) + (venue-text-id uint32) + (caps-text-id uint32) + (tex-name basic) + (race-mesh-name basic) + (race-banner-name basic) + (race-ai-tuning-name basic) + ) + ) + + +(define *task-level* (new 'static 'boxed-array :type symbol + 'default + 'brdroom + 'jungle + 'snow + 'kras + 'canyon + 'canspar + 'temple + 'spartem + 'haven + 'havjung + 'havsew + 'havtour + 'ice + 'sewer + 'coliseum + 'desarena + 'snobowl + 'cliffs + 'spargus + 'spatour + 'docks + 'dockkra + 'dromdoc + 'kcross + 'peak + 'iceberg + 'icepass + 'drome + 'kratour + 'icetour + 'desisle + 'atoll + 'fort + 'garage + 'hiphog + 'eight + 'eightb + 'rustyh + 'curve + 'andrew + 'ben + 'test + 'city + 'artist + ) + ) + +(define *task-level-info* (new 'static 'boxed-array :type task-level-info + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x55f + :venue-text-id #xf10 + :caps-text-id #x631 + :tex-name "icon-jungle" + :race-mesh-name "race-mesh-25" + :race-banner-name "race-banner-4" + :race-ai-tuning-name "*jungle-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x54f + :venue-text-id #xf20 + :caps-text-id #x633 + :tex-name "icon-snow" + :race-mesh-name "race-mesh-26" + :race-banner-name "race-banner-2" + :race-ai-tuning-name "*snow-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x550 + :venue-text-id #xf08 + :caps-text-id #x632 + :tex-name "icon-kras" + :race-mesh-name "race-mesh-22" + :race-banner-name "race-banner-3" + :race-ai-tuning-name "*kras-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x5e9 + :venue-text-id #xf19 + :caps-text-id #x70e + :tex-name "icon-canyon" + :race-mesh-name "race-mesh-41" + :race-banner-name "race-banner-12" + :race-ai-tuning-name "*canyon-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x76b + :venue-text-id #xf1b + :caps-text-id #x730 + :tex-name "icon-canspar" + :race-mesh-name "race-mesh-42" + :race-banner-name "race-banner-9" + :race-ai-tuning-name "*canspar-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x7a1 + :venue-text-id #xf1a + :caps-text-id #x7a5 + :tex-name "icon-temple" + :race-mesh-name "race-mesh-55" + :race-banner-name "race-banner-20" + :race-ai-tuning-name "*temple-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x92e + :venue-text-id #xf1d + :caps-text-id #x793 + :tex-name "icon-spartem" + :race-mesh-name "race-mesh-56" + :race-banner-name "race-banner-21" + :race-ai-tuning-name "*spartem-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x5ae + :venue-text-id #xf11 + :caps-text-id #x674 + :tex-name "icon-haven" + :race-mesh-name "race-mesh-27" + :race-banner-name "race-banner-5" + :race-ai-tuning-name "*haven-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x673 + :venue-text-id #xf13 + :caps-text-id #x676 + :tex-name "icon-havjung" + :race-mesh-name "race-mesh-31" + :race-banner-name "race-banner-6" + :race-ai-tuning-name "*havjung-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x74b + :venue-text-id #xf14 + :caps-text-id #x731 + :tex-name "icon-havsew" + :race-mesh-name "race-mesh-40" + :race-banner-name "race-banner-8" + :race-ai-tuning-name "*havsew-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x7ea + :venue-text-id #xf15 + :caps-text-id #x732 + :tex-name "icon-havtour" + :race-mesh-name "race-mesh-50" + :race-banner-name "race-banner-10" + :race-ai-tuning-name "*havtour-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x9e8 + :venue-text-id #xf22 + :caps-text-id #x733 + :tex-name "icon-ice" + :race-mesh-name "race-mesh-66" + :race-banner-name "race-banner-18" + :race-ai-tuning-name "*ice-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x11c + :venue-text-id #xf12 + :caps-text-id #x734 + :tex-name "icon-sewer" + :race-mesh-name "race-mesh-37" + :race-banner-name "race-banner-11" + :race-ai-tuning-name "*sewer-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x561 + :venue-text-id #xf0e + :caps-text-id #x630 + :tex-name "icon-coliseum" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x562 + :venue-text-id #xf1e + :caps-text-id #x62f + :tex-name "icon-desert" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x5af + :venue-text-id #xf26 + :caps-text-id #x675 + :tex-name "icon-snobowl" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x560 + :venue-text-id #xf17 + :caps-text-id #x62e + :tex-name "icon-cliffs" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x74c + :venue-text-id #xf18 + :caps-text-id #x735 + :tex-name "icon-spargus" + :race-mesh-name "race-mesh-38" + :race-banner-name "race-banner-7" + :race-ai-tuning-name "*spargus-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x79f + :venue-text-id #xf1c + :caps-text-id #x7a6 + :tex-name "icon-spatour" + :race-mesh-name "race-mesh-79" + :race-banner-name "race-banner-15" + :race-ai-tuning-name "*spatour-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x5e8 + :venue-text-id #xf09 + :caps-text-id #x736 + :tex-name "icon-docks" + :race-mesh-name "race-mesh-44" + :race-banner-name "race-banner-13" + :race-ai-tuning-name "*docks-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x8d0 + :venue-text-id #xf0b + :caps-text-id #x737 + :tex-name "icon-dockkra" + :race-mesh-name "race-mesh-45" + :race-banner-name "race-banner-14" + :race-ai-tuning-name "*dockkra-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x7a2 + :venue-text-id #xf0c + :caps-text-id #x7a9 + :tex-name "icon-dromdoc" + :race-mesh-name "race-mesh-73" + :race-banner-name "race-banner-19" + :race-ai-tuning-name "*dromdoc-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x6fe + :venue-text-id #xf0f + :caps-text-id #x6ff + :tex-name "icon-kcross" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x977 + :venue-text-id #xf21 + :caps-text-id #x738 + :tex-name "icon-peak" + :race-mesh-name "race-mesh-69" + :race-banner-name "race-banner-23" + :race-ai-tuning-name "*peak-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x9e9 + :venue-text-id #xf23 + :caps-text-id #x792 + :tex-name "icon-iceberg" + :race-mesh-name "race-mesh-64" + :race-banner-name "race-banner-22" + :race-ai-tuning-name "*iceberg-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x9ea + :venue-text-id #xf24 + :caps-text-id #x791 + :tex-name "icon-icepass" + :race-mesh-name "race-mesh-63" + :race-banner-name "race-banner-25" + :race-ai-tuning-name "*icepass-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x9ed + :venue-text-id #xf0a + :caps-text-id #x75b + :tex-name "icon-drome" + :race-mesh-name "race-mesh-72" + :race-banner-name "race-banner-16" + :race-ai-tuning-name "*drome-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x7a3 + :venue-text-id #xf0d + :caps-text-id #x7a7 + :tex-name "icon-kratour" + :race-mesh-name "race-mesh-76" + :race-banner-name "race-banner-24" + :race-ai-tuning-name "*kratour-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x7a0 + :venue-text-id #xf25 + :caps-text-id #x7a4 + :tex-name "icon-icetour" + :race-mesh-name "race-mesh-84" + :race-banner-name "race-banner-26" + :race-ai-tuning-name "*icetour-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x9e7 + :venue-text-id #xf1f + :caps-text-id #x739 + :tex-name "icon-desisle" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x11b + :venue-text-id #xf16 + :caps-text-id #x7a8 + :tex-name "icon-atoll" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x9eb + :caps-text-id #x9ec + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "race-mesh-1" + :race-banner-name "" + :race-ai-tuning-name "*generic-ai-tuning*" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + ) + ) + +(define *driver-list-cup1* (new 'static 'boxed-array :type uint8 #xb #xa #x1 #x5 #x7 #x9 #x6)) + +(define *driver-list-cup1-gp* (new 'static 'boxed-array :type uint8 #xb #xa #x1 #x5 #x7)) + +(define *driver-list-cup1-temp* (new 'static 'boxed-array :type uint8 #x1 #x5 #xa #x9 #x6)) + +(define *driver-list-cup2* (new 'static 'boxed-array :type uint8 #x3)) + +(define *driver-list-cup2-gp* (new 'static 'boxed-array :type uint8 #x3 #x1 #xb #xa #x7)) + +(define *driver-list-cup3* (new 'static 'boxed-array :type uint8 #x2 #xd)) + +(define *driver-list-cup3-capture* (new 'static 'boxed-array :type uint8 #xb #x1 #x3 #xa #x7)) + +(define *driver-list-cup3-gp* (new 'static 'boxed-array :type uint8 #x2 #xb #xd #x3 #xa)) + +(define *driver-list-cup4-capture* (new 'static 'boxed-array :type uint8 #xb #x1 #x2 #xa #x7)) + +(define *driver-list-cup4-gp* (new 'static 'boxed-array :type uint8 #x13 #x2 #xb #x3 #x4)) + +(define *driver-list-boss* (new 'static 'boxed-array :type uint8 #x13)) + +(define *driver-list-training* (new 'static 'boxed-array :type uint8 #x5 #x6 #x7 #xb)) diff --git a/goal_src/jakx/engine/geometry/bounding-box-h.gc b/goal_src/jakx/engine/geometry/bounding-box-h.gc index f8aa3ef2f2..1a6ad0f8bf 100644 --- a/goal_src/jakx/engine/geometry/bounding-box-h.gc +++ b/goal_src/jakx/engine/geometry/bounding-box-h.gc @@ -7,3 +7,53 @@ ;; DECOMP BEGINS +(deftype bounding-box (structure) + ((min vector :inline) + (max vector :inline) + ) + (:methods + (add-spheres! (_type_ (inline-array sphere) int) int) + (add-box! (_type_ bounding-box) int) + (add-point! (_type_ vector) none) + (intersects-line-segment? (_type_ vector vector) symbol) + (set-from-point-offset! (_type_ vector vector) none) + (set-from-point-offset-pad! (_type_ vector vector float) int) + (set-to-point! (_type_ vector) none) + (set-from-sphere! (_type_ sphere) none) + (set-from-spheres! (_type_ (inline-array sphere) int) int) + (get-bounding-sphere (_type_ vector) vector) + (inside-xyz? (_type_ vector) symbol) + (inside-xz? (_type_ vector) symbol) + (bounding-box-method-21 (_type_ (inline-array vector)) symbol) + ) + ) + + +(deftype bounding-box2 (structure) + ((min vector2 :inline) + (max vector2 :inline) + ) + ) + + +(deftype bounding-box4w (structure) + ((min vector4w :inline) + (max vector4w :inline) + ) + ) + + +(deftype bounding-box-both (structure) + ((box bounding-box :inline) + (box4w bounding-box4w :inline) + ) + ) + + +(deftype bounding-box-array (inline-array-class) + ((data bounding-box :dynamic) + ) + ) + + +(set! (-> bounding-box-array heap-base) (the-as uint 32)) diff --git a/goal_src/jakx/engine/geometry/geometry-h.gc b/goal_src/jakx/engine/geometry/geometry-h.gc index 3050997bf9..55b0a9e5c5 100644 --- a/goal_src/jakx/engine/geometry/geometry-h.gc +++ b/goal_src/jakx/engine/geometry/geometry-h.gc @@ -5,5 +5,133 @@ ;; name in dgo: geometry-h ;; dgos: ENGINE, GAME +(define-extern quaternion-from-two-vectors-max-angle! (function quaternion vector vector float quaternion)) +(define-extern vector-orient-by-quat! (function vector vector quaternion vector)) +(define-extern quaternion-from-two-vectors-partial! + "Create a quaternion representing the rotation between two vectors, + doing arg3 fraction of the total rotation." + (function quaternion vector vector float quaternion)) + ;; DECOMP BEGINS +(deftype curve (structure) + ((cverts (inline-array vector)) + (num-cverts int32) + (knots (pointer float)) + (num-knots int32) + (length float) + ) + :allow-misaligned + ) + + +(deftype line-intersection-val (structure) + ((tt0 float) + (tt1 float) + ) + ) + + +(deftype border-plane (basic) + ((name symbol) + (action basic) + (slot int8) + (trans vector :inline) + (normal vector :inline) + ) + (:methods + (debug-draw (_type_) int) + (point-past-plane? (_type_ vector) symbol) + ) + ) + + +(deftype lissajous (structure) + "A curve where the x and y position are set by two different sinusoids. +This stores the parameters and state for evaluating this curve." + ((x-mag float) + (y-mag float) + (theta float) + (wx float) + (wy float) + (period-shift float) + (theta-rate float) + ) + :pack-me + (:methods + (evaluate! (_type_ vector) vector) + ) + ) + + +(deftype lissajous-interp (structure) + "Handles interpolating between two different lissajous parameters, and also +stepping forward the dynamics." + ((current lissajous :inline) + (dest lissajous :inline) + (rate lissajous :inline) + ) + (:methods + (evaluate! (_type_ vector) vector) + (update! (_type_) float) + ) + ) + + +(deftype ellipsoid (vector) + ((width float :overlay-at (-> data 0)) + (height float :overlay-at (-> data 1)) + (length float :overlay-at (-> data 2)) + (h float :overlay-at (-> data 1)) + (l float :overlay-at (-> data 2)) + ) + ) + + +(defun point-in-ellipsoid? ((arg0 ellipsoid) (arg1 vector)) + (let ((v1-1 (vector*! (new 'stack-no-clear 'vector) arg1 arg1))) + (+ (/ (-> v1-1 x) (square (-> arg0 w))) + (/ (-> v1-1 y) (square (-> arg0 y))) + (/ (-> v1-1 z) (square (-> arg0 z))) + ) + ) + ) + +(defun ellipsoid-random-point-on! ((arg0 ellipsoid) (arg1 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (let* ((s2-0 sincos-rad!) + (s1-0 s5-0) + (f30-0 -3.1415925) + (f28-0 6.283185) + (v1-3 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-4 (the-as number (logior #x3f800000 v1-3))) + ) + (s2-0 s1-0 (+ f30-0 (* f28-0 (+ -1.0 (the-as float v1-4))))) + ) + (let* ((s2-1 sincos-rad!) + (s1-1 s4-0) + (f30-1 -1.5707963) + (f28-1 3.1415925) + (v1-9 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-10 (the-as number (logior #x3f800000 v1-9))) + ) + (s2-1 s1-1 (+ f30-1 (* f28-1 (+ -1.0 (the-as float v1-10))))) + ) + (set! (-> arg1 x) (* (-> arg0 w) (-> s4-0 y) (-> s5-0 x))) + (set! (-> arg1 y) (* (-> arg0 y) (-> s4-0 x))) + (set! (-> arg1 z) (* (-> arg0 z) (-> s4-0 y) (-> s5-0 y))) + ) + arg1 + ) + +(defun ellipsoid-normal-at! ((arg0 ellipsoid) (arg1 vector) (arg2 vector)) + (let ((v0-0 arg1)) + (set! (-> v0-0 x) (/ (-> arg2 x) (square (-> arg0 w)))) + (set! (-> v0-0 y) (/ (-> arg2 y) (square (-> arg0 y)))) + (set! (-> v0-0 z) (/ (-> arg2 z) (square (-> arg0 z)))) + (set! (-> v0-0 w) 1.0) + v0-0 + ) + ) diff --git a/goal_src/jakx/engine/geometry/geometry.gc b/goal_src/jakx/engine/geometry/geometry.gc index 172ef7c08f..61df0b86bd 100644 --- a/goal_src/jakx/engine/geometry/geometry.gc +++ b/goal_src/jakx/engine/geometry/geometry.gc @@ -7,3 +7,1642 @@ ;; DECOMP BEGINS +(defun vector-flatten! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Get the projection of src onto a plane with the given normal + The normal should have magnitude 1.0." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.mov.vf.w vf3 vf0) + (.outer.product.a.vf acc vf1 vf2) + (.outer.product.b.vf vf3 vf2 vf1 acc) + (.outer.product.a.vf acc vf2 vf3) + (.outer.product.b.vf vf3 vf3 vf2 acc) + (.svf (&-> arg0 quad) vf3) + arg0 + ) + ) + +(defun vector-reflect! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Reflect a vector off of a plane." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.mov.vf.w vf3 vf0) + (.outer.product.a.vf acc vf1 vf2) + (.outer.product.b.vf vf3 vf2 vf1 acc) + (.outer.product.a.vf acc vf2 vf3) + (.outer.product.b.vf vf3 vf3 vf2 acc) + (.add.vf.xyz acc vf3 vf3) + (.sub.mul.w.vf.xyz vf3 vf1 vf0 acc) + (.svf (&-> arg0 quad) vf3) + arg0 + ) + ) + +(defun vector-reflect-flat! ((arg0 vector) (arg1 vector) (arg2 vector)) + "This is a weird one. It doesn't care about the value of src dot normal + and it effectively replaces the component of src normal to the plane with + the plane's normal. I think this requires src/normal to both be unit vectors + in order to make sense. + NOTE: src should point from positive halfspace to negative otherwise it + doesn't work." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.mov.vf.w vf3 vf0) + (.outer.product.a.vf acc vf1 vf2) + (.outer.product.b.vf vf3 vf2 vf1 acc) + (.outer.product.a.vf acc vf2 vf3) + (.outer.product.b.vf vf3 vf3 vf2 acc) + (.add.vf.xyz vf3 vf3 vf2) + (.svf (&-> arg0 quad) vf3) + arg0 + ) + ) + +(defun vector-reflect-flat-above! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Not really a reflect. Same as flatten." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.mov.vf.w vf3 vf0) + (.outer.product.a.vf acc vf1 vf2) + (.outer.product.b.vf vf3 vf2 vf1 acc) + (.outer.product.a.vf acc vf2 vf3) + (.outer.product.b.vf vf3 vf3 vf2 acc) + (.svf (&-> arg0 quad) vf3) + (let* ((f0-0 (vector-length arg0)) + (f1-1 (vector-dot arg0 arg2)) + (f0-2 (- (/ f0-0 50) f1-1)) + ) + (vector+float*! arg0 arg0 arg2 (fmin 16384.0 (* 16.0 f0-2))) + ) + ) + ) + +(defun vector-reflect-flat-gravity! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-copy! s4-0 arg1) + (vector-reflect-flat! arg0 s4-0 arg2) + ;; og:preserve-this + (let* ((s2-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) s4-0 1.0)) ;; src normalized + (f28-0 (vector-length s4-0)) ;; src original len + (f30-0 (vector-length arg0)) ;; dst original len + (f0-1 (vector-dot s2-0 arg2)) ;; original (normalized) dot normal + (f1-1 (vector-dot arg3 arg2)) + ) + (when (and (< 0.0001 f1-1) (< 8192.0 f28-0)) + (let ((f0-3 (- (/ f0-1 f1-1)))) + (vector+float*! arg0 s4-0 arg3 (* f28-0 f0-3)) + ) + (vector+! arg0 arg0 arg2) + (vector-normalize! arg0 f30-0) + ) + ) + ) + arg0 + ) + +(defun vector-segment-distance-point! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + "Compute the distance from a point to the closest point on the line segment. + arg0 is the point. arg1/arg2 are the endpoints of the line segment. + arg3 is an optional output closest point." + (local-vars (v0-0 float) (v1-0 float) (v1-1 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + ) + (init-vf0-vector) + (nop!) + (.lvf vf3 (&-> arg1 quad)) + (.lvf vf4 (&-> arg2 quad)) + (.lvf vf5 (&-> arg0 quad)) + (.sub.vf vf1 vf4 vf3) + (.sub.vf vf6 vf5 vf3) + (.mul.vf vf2 vf1 vf1) + (.mul.x.vf.w acc vf0 vf2) + (.add.mul.y.vf.w acc vf0 vf2 acc) + (.add.mul.z.vf.w vf2 vf0 vf2 acc) + (.sqrt.vf Q vf2 :ftf #b11) + (.wait.vf) + (.add.vf.x vf2 vf0 Q) + (.nop.vf) + (.nop.vf) + (.div.vf Q vf0 vf2 :fsf #b11 :ftf #b0) + (.mov v1-0 vf2) + (let ((f2-0 v1-0)) + (.wait.vf) + (.mul.vf vf1 vf1 Q) + (.mul.vf vf7 vf1 vf6) + (let ((f1-0 (the-as float 0.0))) + (.add.y.vf.x vf7 vf7 vf7) + (.add.z.vf.x vf7 vf7 vf7) + (.mov v1-1 vf7) + (let ((f0-0 v1-1)) + (b! (< f0-0 f1-0) cfg-4 :likely-delay (set! f0-0 f1-0)) + (b! (< f2-0 f0-0) cfg-4 :likely-delay (set! f0-0 f2-0)) + (label cfg-4) + (let ((v1-2 f0-0)) + (.mov vf7 v1-2) + ) + ) + ) + ) + (.mul.x.vf vf1 vf1 vf7) + (b! (= arg3 #f) cfg-6 :delay (.mov.vf.w vf8 vf0)) + (.add.vf.xyz vf8 vf3 vf1) + (.svf (&-> arg3 quad) vf8) + (label cfg-6) + (.sub.vf vf2 vf6 vf1) + (.mul.vf vf2 vf2 vf2) + (.mul.x.vf.w acc vf0 vf2) + (.add.mul.y.vf.w acc vf0 vf2 acc) + (.add.mul.z.vf.w vf2 vf0 vf2 acc) + (.sqrt.vf Q vf2 :ftf #b11) + (.wait.vf) + (.add.vf.x vf2 vf0 Q) + (.nop.vf) + (.mov v0-0 vf2) + v0-0 + ) + ) + +(defun vector-segment-xz-distance-point! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((v1-0 (new 'stack-no-clear 'matrix))) + (set-vector! (-> v1-0 rvec) (-> arg0 x) 0.0 (-> arg0 z) 0.0) + (set-vector! (-> v1-0 uvec) (-> arg1 x) 0.0 (-> arg1 z) 1.0) + (set-vector! (-> v1-0 fvec) (-> arg2 x) 0.0 (-> arg2 z) 1.0) + (vector-segment-distance-point! (-> v1-0 rvec) (-> v1-0 uvec) (-> v1-0 fvec) arg3) + ) + ) + +(defun vector-line-distance ((arg0 vector) (arg1 vector) (arg2 vector)) + "Weird function: given a point arg1, and an infinite line connecting arg2 and arg1, compute the distance + from arg0 to that line." + (let* ((a1-3 (vector-normalize! (vector-! (new-stack-vector0) arg2 arg1) 1.0)) + (gp-1 (vector-! (new-stack-vector0) arg0 arg1)) + (f0-1 (vector-dot a1-3 gp-1)) + (v1-3 (vector-float*! (new-stack-vector0) a1-3 f0-1)) + ) + (vector-length (vector-! (new-stack-vector0) gp-1 v1-3)) + ) + ) + +(defun vector-line-distance-point! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + "Same as above function, but returns the point on arg2/arg1 in arg3 (ignored if #f)" + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let* ((a1-3 (vector-normalize! (vector-! (new-stack-vector0) arg2 arg1) 1.0)) + (s4-1 (vector-! (new-stack-vector0) arg0 arg1)) + (f0-1 (vector-dot a1-3 s4-1)) + (v1-4 (vector-float*! (new-stack-vector0) a1-3 f0-1)) + ) + (when arg3 + (let ((a0-6 v1-4)) + (.lvf vf4 (&-> arg1 quad)) + (.lvf vf5 (&-> a0-6 quad)) + ) + (.mov.vf.w vf6 vf0) + (.add.vf.xyz vf6 vf4 vf5) + (.svf (&-> arg3 quad) vf6) + ) + (vector-length (vector-! (new-stack-vector0) s4-1 v1-4)) + ) + ) + ) + +(defun vector-line-xz-distance-point! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((v1-0 (new 'stack-no-clear 'matrix))) + (set-vector! (-> v1-0 rvec) (-> arg0 x) 0.0 (-> arg0 z) 0.0) + (set-vector! (-> v1-0 uvec) (-> arg1 x) 0.0 (-> arg1 z) 1.0) + (set-vector! (-> v1-0 fvec) (-> arg2 x) 0.0 (-> arg2 z) 1.0) + (vector-line-distance-point! (-> v1-0 rvec) (-> v1-0 uvec) (-> v1-0 fvec) arg3) + ) + ) + +(defun vector-segment-overlap ((arg0 vector) (arg1 vector) (arg2 vector)) + "Seems to compute (v1 - v0).dot(v2 - v1), but in a weird way." + (let* ((gp-1 (vector-! (new 'stack-no-clear 'vector) arg1 arg2)) + (s5-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) gp-1 1.0)) + ) + ;; og:preserve-this + ;; this vector-line-distance-point! is totally unused. + (let ((a3-0 (new 'stack-no-clear 'vector))) + (vector-line-distance-point! arg0 arg1 arg2 a3-0) + ) + (/ (vector-dot s5-0 (vector-! (new 'stack-no-clear 'vector) arg1 arg0)) (vector-length gp-1)) + ) + ) + +(defun line-sphere-intersection? ((arg0 vector) (arg1 vector) (arg2 vector)) + "Does [arg1, arg2] intersect sphere arg0?" + (let ((s5-0 (new 'stack-no-clear 'vector))) + (let ((s3-0 (new 'stack-no-clear 'vector)) + (f30-0 0.0) + ) + (vector-! s3-0 arg2 arg1) + (let ((f0-0 (vector-length-squared s3-0))) + (if (< 0.0 f0-0) + (set! f30-0 (/ 1.0 f0-0)) + ) + ) + (let ((v1-6 (new 'stack-no-clear 'vector))) + (vector-! v1-6 arg0 arg1) + (let* ((f1-2 (* (vector-dot s3-0 v1-6) f30-0)) + (f0-5 (fmax 0.0 (fmin 1.0 f1-2))) + ) + (vector+float*! s5-0 arg1 s3-0 f0-5) + ) + ) + ) + (< (vector-vector-distance-squared s5-0 arg0) (square (-> arg0 w))) + ) + ) + +(defun nearest-dist2-between-moving-points ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float)) + (let ((v1-0 (new 'stack-no-clear 'inline-array 'vector 2))) + (vector-! (-> v1-0 0) arg2 arg0) + (vector-! (-> v1-0 1) arg3 arg1) + (let ((f0-1 (vector-dot (-> v1-0 0) (-> v1-0 0))) + (f1-1 (vector-dot (-> v1-0 1) (-> v1-0 1))) + (f2-1 (vector-dot (-> v1-0 0) (-> v1-0 1))) + (f3-0 0.0) + ) + (if (< 0.0 f1-1) + (set! f3-0 (fmax 0.0 (fmin (/ (- f2-1) f1-1) arg4))) + ) + (+ f0-1 (* 2.0 f2-1 f3-0) (* (square f3-0) f1-1)) + ) + ) + ) + +(defun vector-orient-by-quat! ((arg0 vector) (arg1 vector) (arg2 quaternion)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg2 quad)) + (.lvf vf6 (&-> arg1 quad)) + (.add.vf vf5 vf1 vf1) + (.add.w.vf.x vf2 vf0 vf1) + (.add.z.vf.y vf2 vf0 vf1) + (.sub.y.vf.z vf2 vf0 vf1) + (.sub.w.vf.w vf2 vf0 vf0) + (.sub.z.vf.x vf3 vf0 vf1) + (.add.w.vf.y vf3 vf0 vf1) + (.add.x.vf.z vf3 vf0 vf1) + (.sub.w.vf.w vf3 vf0 vf0) + (.add.y.vf.x vf4 vf0 vf1) + (.sub.x.vf.y vf4 vf0 vf1) + (.add.w.vf.z vf4 vf0 vf1) + (.sub.w.vf.w vf4 vf0 vf0) + (.outer.product.a.vf acc vf5 vf2) + (.outer.product.b.vf vf2 vf2 vf5 acc) + (.outer.product.a.vf acc vf5 vf3) + (.outer.product.b.vf vf3 vf3 vf5 acc) + (.outer.product.a.vf acc vf5 vf4) + (.outer.product.b.vf vf4 vf4 vf5 acc) + (.add.w.vf.x vf2 vf2 vf0) + (.add.w.vf.y vf3 vf3 vf0) + (.add.w.vf.z vf4 vf4 vf0) + (.mul.w.vf acc vf0 vf6) + (.add.mul.x.vf acc vf2 vf6 acc) + (.add.mul.y.vf acc vf3 vf6 acc) + (.add.mul.z.vf vf6 vf4 vf6 acc) + (.svf (&-> arg0 quad) vf6) + arg0 + ) + ) + +;; ERROR: Bad vector register dependency: vf7 +(defun vector-inv-orient-by-quat! ((arg0 vector) (arg1 vector) (arg2 quaternion)) + "Rotate a vector by the inverse rotation." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + ;; og:preserve-this + ;; (.sub.vf vf7 vf7 vf7) + (.xor.vf vf7 vf7 vf7) + (.lvf vf1 (&-> arg2 quad)) + (.lvf vf6 (&-> arg1 quad)) + (.sub.vf.xyz vf1 vf7 vf1) + (.add.vf vf5 vf1 vf1) + (.add.w.vf.x vf2 vf0 vf1) + (.add.z.vf.y vf2 vf0 vf1) + (.sub.y.vf.z vf2 vf0 vf1) + (.sub.w.vf.w vf2 vf0 vf0) + (.sub.z.vf.x vf3 vf0 vf1) + (.add.w.vf.y vf3 vf0 vf1) + (.add.x.vf.z vf3 vf0 vf1) + (.sub.w.vf.w vf3 vf0 vf0) + (.add.y.vf.x vf4 vf0 vf1) + (.sub.x.vf.y vf4 vf0 vf1) + (.add.w.vf.z vf4 vf0 vf1) + (.sub.w.vf.w vf4 vf0 vf0) + (.outer.product.a.vf acc vf5 vf2) + (.outer.product.b.vf vf2 vf2 vf5 acc) + (.outer.product.a.vf acc vf5 vf3) + (.outer.product.b.vf vf3 vf3 vf5 acc) + (.outer.product.a.vf acc vf5 vf4) + (.outer.product.b.vf vf4 vf4 vf5 acc) + (.add.w.vf.x vf2 vf2 vf0) + (.add.w.vf.y vf3 vf3 vf0) + (.add.w.vf.z vf4 vf4 vf0) + (.mul.w.vf acc vf0 vf6) + (.add.mul.x.vf acc vf2 vf6 acc) + (.add.mul.y.vf acc vf3 vf6 acc) + (.add.mul.z.vf vf6 vf4 vf6 acc) + (.svf (&-> arg0 quad) vf6) + arg0 + ) + ) + +(defun vector-cap-rotation! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (cond + ((>= arg3 (acos (vector-dot arg1 arg2))) + (empty) + arg2 + ) + (else + (let ((s2-0 (new 'stack-no-clear 'quaternion))) + (quaternion-from-two-vectors-max-angle! (the-as quaternion (&-> s2-0 x)) arg1 arg2 arg3) + (vector-orient-by-quat! arg0 arg1 (the-as quaternion (&-> s2-0 x))) + ) + ) + ) + ) + +(defun vector-interp-angle! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (cond + ((>= 0.0 arg3) + (set! (-> arg0 quad) (-> arg1 quad)) + arg0 + ) + ((>= arg3 1.0) + (set! (-> arg0 quad) (-> arg2 quad)) + arg0 + ) + (else + (let ((s4-0 (new 'stack-no-clear 'quaternion))) + (quaternion-from-two-vectors-partial! (the-as quaternion (&-> s4-0 x)) arg1 arg2 arg3) + (quaternion-normalize! (the-as quaternion (&-> s4-0 x))) + (vector-orient-by-quat! arg0 arg1 (the-as quaternion (&-> s4-0 x))) + ) + ) + ) + ) + +;; The "forward down" function take a direction for forward (+z) and down (-y) +;; and convert to a transform. +;; Note that the normal functions take their pitch from the forward vector, but +;; the "nopitch" ones use the pitch from the up/down. Of course, if you are +;; consistent and provide orthogonal forward/down, they do the same thing. + +(defun forward-down->inv-matrix ((arg0 matrix) (arg1 vector) (arg2 vector)) + "Create a matrix representing an inverse transform where arg1 is forward (+z) + and arg2 is down (-y). Will have the pitch of forward." + (vector-normalize-copy! (-> arg0 fvec) arg1 1.0) + (vector-cross! (-> arg0 rvec) (-> arg0 fvec) arg2) + (vector-normalize! (-> arg0 rvec) 1.0) + (vector-cross! (-> arg0 uvec) arg1 (-> arg0 rvec)) + (vector-normalize! (-> arg0 uvec) 1.0) + (set! (-> arg0 trans quad) (the-as uint128 0)) + (set! (-> arg0 rvec w) 0.0) + (set! (-> arg0 uvec w) 0.0) + (set! (-> arg0 fvec w) 0.0) + (set! (-> arg0 trans w) 1.0) + arg0 + ) + +(defun forward-down-nopitch->inv-matrix ((arg0 matrix) (arg1 vector) (arg2 vector)) + "Create a matrix representing an inverse transform where arg1 is forward (+z) + and arg2 is down (-y). Will not use the pitch of forward." + (vector-normalize-copy! (-> arg0 uvec) arg2 1.0) + (vector-negate! (-> arg0 uvec) (-> arg0 uvec)) + (vector-cross! (-> arg0 rvec) (-> arg0 uvec) arg1) + (vector-normalize! (-> arg0 rvec) 1.0) + (vector-cross! (-> arg0 fvec) (-> arg0 rvec) (-> arg0 uvec)) + (vector-normalize! (-> arg0 fvec) 1.0) + (set! (-> arg0 trans quad) (the-as uint128 0)) + (set! (-> arg0 rvec w) 0.0) + (set! (-> arg0 uvec w) 0.0) + (set! (-> arg0 fvec w) 0.0) + (set! (-> arg0 trans w) 1.0) + arg0 + ) + +(defun forward-up->inv-matrix ((arg0 matrix) (arg1 vector) (arg2 vector)) + "Create a matrix representing an inverse transform where arg1 is forward (+z) + and arg2 is up (+y). Will use the pitch of forward." + (forward-down->inv-matrix arg0 arg1 (vector-negate! (new 'stack-no-clear 'vector) arg2)) + ) + +(defun forward-up-nopitch->inv-matrix ((arg0 matrix) (arg1 vector) (arg2 vector)) + "Create a matrix representing an inverse transform where arg1 is forward (+z) + and arg2 is up (+y). Will not use the pitch of forward." + (forward-down-nopitch->inv-matrix arg0 arg1 (vector-negate! (new-stack-vector0) arg2)) + ) + +(defun forward-up-nopitch->quaternion ((arg0 quaternion) (arg1 vector) (arg2 vector)) + "Create a quaternion representing a transform where arg1 is forward (+z) + and arg2 is up (+y). Will not use the pitch of forward." + ;; og:preserve-this + (matrix->quaternion arg0 (forward-up-nopitch->inv-matrix (new-stack-matrix0) arg1 arg2)) + ) + +(defun forward-up->quaternion ((arg0 quaternion) (arg1 vector) (arg2 vector)) + "Create a quaternion representing a transform where arg1 is forward (+z) + and arg2 is up (+y). Will use the pitch of forward." + ;; og:preserve-this + (matrix->quaternion + arg0 + (forward-down->inv-matrix (new-stack-matrix0) arg1 (vector-negate! (new 'stack-no-clear 'vector) arg2)) + ) + ) + +(defun quaternion-from-two-vectors! ((arg0 quaternion) (arg1 vector) (arg2 vector)) + "Create a quaternion representing the rotation between two vectors." + (let* ((s5-0 (vector-cross! (new-stack-vector0) arg1 arg2)) + (f1-0 (vector-length s5-0)) + (f0-1 (vector-dot arg1 arg2)) + ) + (let ((f1-1 (/ (sqrtf (* 0.5 (- 1.0 f0-1))) f1-0))) + (set! (-> arg0 x) (* (-> s5-0 x) f1-1)) + (set! (-> arg0 y) (* (-> s5-0 y) f1-1)) + (set! (-> arg0 z) (* (-> s5-0 z) f1-1)) + ) + (set! (-> arg0 w) (sqrtf (* 0.5 (+ 1.0 f0-1)))) + ) + arg0 + ) + +(defun quaternion-from-two-vectors-partial! ((arg0 quaternion) (arg1 vector) (arg2 vector) (arg3 float)) + "Create a quaternion representing the rotation between two vectors, + doing arg3 fraction of the total rotation." + (let* ((s5-0 (vector-cross! (new-stack-vector0) arg1 arg2)) + (f0-0 (vector-length s5-0)) + (f1-1 (+ 1.0 (* arg3 (+ -1.0 (vector-dot arg1 arg2))))) + ) + (let ((f0-1 (/ (sqrtf (* 0.5 (- 1.0 f1-1))) f0-0))) + (set! (-> arg0 x) (* (-> s5-0 x) f0-1)) + (set! (-> arg0 y) (* (-> s5-0 y) f0-1)) + (set! (-> arg0 z) (* (-> s5-0 z) f0-1)) + ) + (set! (-> arg0 w) (sqrtf (* 0.5 (+ 1.0 f1-1)))) + ) + arg0 + ) + +(defun quaternion-from-two-vectors-max-angle! ((arg0 quaternion) (arg1 vector) (arg2 vector) (arg3 float)) + "Create a quaternion representing the rotation between two vectors, + allowing at most a rotation of arg3 degrees." + (let* ((s5-0 (vector-cross! (new-stack-vector0) arg1 arg2)) + (f30-0 (vector-length s5-0)) + (f0-1 (fmax (cos arg3) (vector-dot arg1 arg2))) + ) + (let ((f1-5 (/ (sqrtf (* 0.5 (- 1.0 f0-1))) f30-0))) + (set! (-> arg0 x) (* (-> s5-0 x) f1-5)) + (set! (-> arg0 y) (* (-> s5-0 y) f1-5)) + (set! (-> arg0 z) (* (-> s5-0 z) f1-5)) + ) + (set! (-> arg0 w) (sqrtf (* 0.5 (+ 1.0 f0-1)))) + ) + arg0 + ) + +(defun quaternion-from-two-vectors-max-angle-partial! ((arg0 quaternion) (arg1 vector) (arg2 vector) (arg3 float) (arg4 float)) + "Create a quaternion representing the arg4 fraction of the rotation between two vectors, + allowing at most a rotation of arg3 degrees." + (let* ((s5-0 (vector-cross! (new-stack-vector0) arg1 arg2)) + (f30-0 (vector-length s5-0)) + (f0-1 (fmax (cos arg3) (+ 1.0 (* arg4 (+ -1.0 (vector-dot arg1 arg2)))))) + ) + (let ((f1-5 (/ (sqrtf (* 0.5 (- 1.0 f0-1))) f30-0))) + (set! (-> arg0 x) (* (-> s5-0 x) f1-5)) + (set! (-> arg0 y) (* (-> s5-0 y) f1-5)) + (set! (-> arg0 z) (* (-> s5-0 z) f1-5)) + ) + (set! (-> arg0 w) (sqrtf (* 0.5 (+ 1.0 f0-1)))) + ) + arg0 + ) + +(defun matrix-from-two-vectors! ((arg0 matrix) (arg1 vector) (arg2 vector)) + "Create a rotation matrix representing the rotation between two vectors." + (let* ((a1-3 (vector-normalize! (vector-cross! (new-stack-vector0) arg2 arg1) 1.0)) + (f0-1 (vector-dot arg1 arg2)) + (f1-2 (sqrtf (- 1.0 (square f0-1)))) + ) + (matrix-axis-sin-cos! arg0 a1-3 f1-2 f0-1) + ) + ) + +(defun matrix-from-two-vectors-max-angle! ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 float)) + "Create a rotation matrix representing the rotation between two vectors, + allowing at most a rotation of arg3 degrees." + (let ((s4-1 (vector-normalize! (vector-cross! (new-stack-vector0) arg2 arg1) 1.0)) + (f30-0 (vector-dot arg1 arg2)) + (f28-0 (cos arg3)) + ) + (if (< f30-0 f28-0) + (matrix-axis-sin-cos! arg0 s4-1 (sin arg3) f28-0) + (matrix-axis-sin-cos! arg0 s4-1 (sqrtf (- 1.0 (square f30-0))) f30-0) + ) + ) + ) + +;; og:preserve-this +;; hack for the smoothed matrix from vectors to handle cases where they accidentally set turnvf to 0. +;; this causes the smoothing to go away on ps2, due to some behavior of inf/nan that differ. +;; if we cheat this to a small but nonzero value, it behaves like on ps2. +(defmacro int-to-float-nonzero-hack (f) + `(if (= ,f 0) + 0.00000000001 + (the float ,f) + ) + ) + +(defun matrix-from-two-vectors-smooth! ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 float) (arg4 int)) + "This function can help smoothly rotate from a current heading vector to a target one. + It returns a rotation to move arg1 closer to arg2, subject to two different speed limits. + arg3 is a rotations-per-frame rate. This limit takes frame rate into account (when lagging, the rotation is larger) + arg4 is a 'slow down when getting close to the end' limit. + This is used in rotate-toward-orientation, which is much improved from jak 1." + (let* ((s5-1 (vector-normalize! (vector-cross! (new 'stack-no-clear 'vector) arg2 arg1) 1.0)) + (f0-1 (vector-dot arg1 arg2)) + (f0-2 (acos f0-1)) + ;; og:preserve-this + (f1-2 (fmin (* arg3 (seconds-per-frame)) (/ (* 5.0 (fabs f0-2)) (int-to-float-nonzero-hack arg4)))) + (f30-0 (fmax (fmin f0-2 f1-2) (- f1-2))) + ) + (matrix-axis-sin-cos! arg0 s5-1 (sin f30-0) (cos f30-0)) + ) + arg0 + ) + +(defun matrix-from-two-vectors-the-long-way-smooth! ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 float) (arg4 int)) + "Same as above, but rotates you away from the target. + Note that the 'near the end' smoothing will apply when you're near the target." + (let* ((s5-1 (vector-normalize! (vector-cross! (new 'stack-no-clear 'vector) arg2 arg1) 1.0)) + (f0-1 (vector-dot arg1 arg2)) + (f0-3 (- (acos f0-1))) + ;; og:preserve-this + (f1-2 (fmin (* arg3 (seconds-per-frame)) (/ (* 5.0 (fabs f0-3)) (int-to-float-nonzero-hack arg4)))) + (f30-0 (fmax (fmin f0-3 f1-2) (- f1-2))) + ) + (matrix-axis-sin-cos! arg0 s5-1 (sin f30-0) (cos f30-0)) + ) + arg0 + ) + +(defun quaternion-from-two-vectors-smooth! ((arg0 quaternion) (arg1 vector) (arg2 vector) (arg3 float) (arg4 int)) + "Same as above, but returns a quaternion." + (let ((a1-1 (matrix-from-two-vectors-smooth! (new 'stack-no-clear 'matrix) arg1 arg2 arg3 arg4))) + (matrix->quaternion arg0 a1-1) + ) + ) + +(defun matrix-from-two-vectors-max-angle-partial! ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 float) (arg4 float)) + "Create a rotation matrix representing the given fraction of the rotation between two heading vectors, + rotating by at most the given angle." + (let* ((s4-1 (vector-normalize! (vector-cross! (new 'stack-no-clear 'vector) arg2 arg1) 1.0)) + (f28-0 (vector-dot arg1 arg2)) + (f30-0 (cos arg3)) + (f0-2 (+ 1.0 (* (+ -1.0 f28-0) arg4))) + ) + (if (< f0-2 f30-0) + (matrix-axis-sin-cos! arg0 s4-1 (sin arg3) f30-0) + (matrix-axis-sin-cos! arg0 s4-1 (sqrtf (- 1.0 (square f0-2))) f0-2) + ) + ) + ) + +(defun matrix-from-two-vectors-partial-linear! ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 float)) + "Create a rotation matrix representing doing arg3 fraction of the rotation between two vectors." + (let ((gp-1 (vector-normalize! (vector-cross! (new-stack-vector0) arg2 arg1) 1.0)) + (f0-1 (vector-dot arg1 arg2)) + ) + (cond + ((< 0.9999 (fabs f0-1)) + (matrix-identity! arg0) + ) + (else + (let ((f0-4 (cos (* arg3 (acos f0-1))))) + (matrix-axis-sin-cos! arg0 gp-1 (sqrtf (- 1.0 (square f0-4))) f0-4) + ) + ) + ) + ) + ) + +(defun matrix-remove-z-rot ((arg0 matrix) (arg1 vector)) + "Remove the z rotation component of a rotation." + (let ((s4-0 (new-stack-vector0))) + 0.0 + 0.0 + (let ((s5-0 (new-stack-matrix0))) + (vector-negate! s4-0 arg1) + (vector-flatten! s4-0 s4-0 (-> arg0 fvec)) + (vector-normalize! s4-0 1.0) + (let ((f30-0 (vector-dot (-> arg0 uvec) s4-0))) + (when (< f30-0 0.99999) + (vector-cross! s4-0 (-> arg0 uvec) s4-0) + (let ((f0-4 (vector-length s4-0))) + (if (< 0.0 (vector-dot s4-0 (-> arg0 fvec))) + (set! f0-4 (- f0-4)) + ) + (matrix-axis-sin-cos! s5-0 (-> arg0 fvec) f0-4 f30-0) + ) + (matrix*! arg0 arg0 s5-0) + ) + ) + ) + ) + arg0 + ) + +(defun matrix-rot-diff! ((arg0 quaternion) (arg1 matrix) (arg2 matrix)) + "Get the difference of rotation between two matrices, expressed as a quaternion." + (let ((s3-0 (new-stack-quaternion0)) + (s2-0 (new-stack-quaternion0)) + (s5-0 (new-stack-quaternion0)) + ) + 0.0 + (matrix->quaternion s3-0 arg1) + (matrix->quaternion s2-0 arg2) + (quaternion-conjugate! s5-0 s3-0) + (quaternion*! s5-0 s2-0 s5-0) + (quaternion-normalize! s5-0) + (if (< (-> s5-0 w) 0.0) + (quaternion-negate! s5-0 s5-0) + ) + (let ((f30-1 (* 2.0 (acos (-> s5-0 w))))) + (set! (-> arg0 quad) (-> s5-0 quad)) + (vector-negate! (-> arg0 vec) (-> arg0 vec)) + (if (= (vector-normalize-ret-len! (-> arg0 vec) 1.0) 0.0) + (set! (-> arg0 y) 1.0) + ) + f30-1 + ) + ) + ) + +(defun quaternion-seek ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion) (arg3 float) (arg4 float)) + "Strange quaternion rotate toward function. arg3 is ignored. arg4 is the max seek amount." + (let ((s5-0 (new-stack-matrix0)) + (s4-0 (new-stack-matrix0)) + ) + (quaternion->matrix s5-0 arg1) + (quaternion->matrix s4-0 arg2) + (let ((s2-1 (new-stack-quaternion0))) + (quaternion-from-two-vectors-max-angle! s2-1 (-> s5-0 fvec) (-> s4-0 fvec) arg4) + (quaternion-normalize! (quaternion*! arg0 arg0 s2-1)) + ) + ) + ) + +(defun vector-deg-seek ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Make one vector closer to another, doing at most a rotation by arg3 degrees." + (let ((s4-0 (new-stack-matrix0))) + (matrix-from-two-vectors-max-angle! s4-0 arg1 arg2 arg3) + (vector-matrix*! arg0 arg1 s4-0) + ) + ) + +(defun vector-deg-slerp ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Slerp for vectors. (imagine that they are the z axis of two frames)" + (cond + ((>= 0.0 arg3) + (set! (-> arg0 quad) (-> arg1 quad)) + arg0 + ) + ((>= arg3 1.0) + (set! (-> arg0 quad) (-> arg2 quad)) + arg0 + ) + (else + (let ((s1-0 (new-stack-matrix0))) + (let ((s2-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) arg1 1.0)) + (a2-3 (vector-normalize-copy! (new 'stack-no-clear 'vector) arg2 1.0)) + ) + (matrix-from-two-vectors-partial-linear! s1-0 s2-0 a2-3 arg3) + ) + (vector-matrix*! arg0 arg1 s1-0) + ) + ) + ) + ) + +(defun vector-vector-deg-slerp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float) (arg4 vector)) + "Unused. No clue what this does." + (cond + ((>= 0.0 arg3) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + ((>= arg3 1.0) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + (else + (let* ((s0-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) arg1 1.0)) + (s1-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) arg2 1.0)) + (s0-1 (forward-up->quaternion (new 'stack-no-clear 'quaternion) s0-0 arg4)) + (a2-5 (forward-up->quaternion (new 'stack-no-clear 'quaternion) s1-0 arg4)) + (a1-6 (quaternion-slerp! (new 'stack-no-clear 'quaternion) s0-1 a2-5 arg3)) + ) + (vector-normalize-copy! + arg0 + (vector-z-quaternion! (new 'stack-no-clear 'vector) a1-6) + (lerp (vector-length arg1) (vector-length arg2) arg3) + ) + ) + ) + ) + arg0 + ) + +(defun normal-of-plane ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + "Given three points on a plane, compute the plane's normal." + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (.lvf vf3 (&-> arg2 quad)) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg3 quad)) + (.sub.vf vf1 vf3 vf1) + (.sub.vf vf2 vf3 vf2) + (.outer.product.a.vf acc vf2 vf1) + (.outer.product.b.vf vf4 vf1 vf2 acc) + (.mul.vf vf5 vf4 vf4) + (.add.y.vf.x vf5 vf5 vf5) + (.add.z.vf.x vf5 vf5 vf5) + (.isqrt.vf Q vf0 vf5 :fsf #b11 :ftf #b0) + (.mov.vf.w vf4 vf0) + (.wait.vf) + (.mul.vf.xyz vf4 vf4 Q) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +(defun vector-3pt-cross! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + "Cross product of 2 - 1 and 3 - 1. (will give a normal to the plane, but not of magnitude 1)" + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.lvf vf3 (&-> arg3 quad)) + (.add.x.vf.w vf4 vf0 vf0) + (.sub.vf vf2 vf2 vf1) + (.sub.vf vf3 vf3 vf1) + (.outer.product.a.vf acc vf2 vf3) + (.outer.product.b.vf vf4 vf3 vf2 acc) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +(defun closest-pt-in-triangle ((arg0 vector) (arg1 vector) (arg2 matrix) (arg3 vector)) + "arg2 is the vertices of the triangle, arg3 is the normal, arg1 is the input point, arg0 is the output." + ;; (declare (print-asm)) + (local-vars + ;; og:preserve-this float -> uint + (v1-0 uint) + (v1-4 uint) + (v1-5 uint) + (v1-6 uint) + (v1-7 uint) + (v1-10 uint) + ;; og:preserve-this float -> uint + (a0-1 uint) + (a1-1 uint) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (nop!) + (nop!) + (.lvf vf3 (&-> arg2 quad 1)) + (nop!) + (.lvf vf4 (&-> arg2 quad 2)) + (nop!) + (.lvf vf5 (&-> arg1 quad)) + (.sub.vf vf6 vf3 vf4) + (.lvf vf2 (&-> arg2 quad 0)) + (.sub.vf vf7 vf3 vf5) + (.lvf vf1 (&-> arg3 quad)) + (.sub.vf vf8 vf3 vf2) + (.sub.vf vf9 vf5 vf4) + (.sub.vf vf10 vf5 vf2) + (.outer.product.a.vf acc vf7 vf8) + (.outer.product.b.vf vf14 vf8 vf7 acc) + (.outer.product.a.vf acc vf6 vf7) + (.outer.product.b.vf vf15 vf7 vf6 acc) + (.mul.vf vf11 vf14 vf1) + (.outer.product.a.vf acc vf9 vf10) + (.outer.product.b.vf vf16 vf10 vf9 acc) + (.mul.vf vf12 vf15 vf1) + (.add.x.vf.y vf11 vf11 vf11) + (.mul.vf vf13 vf16 vf1) + (.add.x.vf.y vf12 vf12 vf12) + (.add.x.vf.y vf13 vf13 vf13) + (.add.z.vf.y vf11 vf11 vf11) + (.add.z.vf.y vf12 vf12 vf12) + (.add.z.vf.y vf13 vf13 vf13) + ;; og:preserve-this these types were changed to uint to make this copy 64 bits. + (.mov v1-0 vf11) + (.mov a1-1 vf12) + (.mov a0-1 vf13) + (let* ((v1-1 (shr (the-as int v1-0) 63)) + (a1-2 (shr (the-as int a1-1) 63)) + (a0-2 (shr (the-as int a0-1) 63)) + (a1-3 (* a1-2 2)) + (a0-3 (* a0-2 4)) + (v1-3 (logior (logior v1-1 a1-3) a0-3)) + ) + (b! (nonzero? v1-3) cfg-3 :delay (set! v1-4 (the-as uint (+ v1-3 -1)))) + ) + (.sub.vf vf17 vf5 vf2) + (.mov.vf.w vf18 vf0) + (.outer.product.a.vf acc vf17 vf1) + (.outer.product.b.vf vf18 vf1 vf17 acc) + (.outer.product.a.vf acc vf1 vf18) + (.outer.product.b.vf vf18 vf18 vf1 acc) + (.add.vf.xyz vf18 vf18 vf2) + (b! #t cfg-24 :delay (.svf (&-> arg0 quad) vf18)) + (nop!) + (label cfg-3) + (b! (nonzero? v1-4) cfg-6 :delay (set! v1-5 (+ v1-4 -1))) + (vector-segment-distance-point! arg1 (the-as vector (-> arg2 vector)) (-> arg2 vector 1) arg0) + (goto cfg-24) + (label cfg-6) + (b! (nonzero? v1-5) cfg-9 :delay (set! v1-6 (+ v1-5 -1))) + (vector-segment-distance-point! arg1 (-> arg2 vector 1) (-> arg2 vector 2) arg0) + (goto cfg-24) + (label cfg-9) + (b! (nonzero? v1-6) cfg-14 :delay (set! v1-7 (+ v1-6 -1))) + (let ((f30-0 (vector-segment-distance-point! arg1 (-> arg2 vector 1) (the-as vector (-> arg2 vector)) arg0)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (if (< (vector-segment-distance-point! arg1 (-> arg2 vector 1) (-> arg2 vector 2) s3-0) f30-0) + (set! (-> arg0 quad) (-> s3-0 quad)) + ) + ) + (goto cfg-24) + (label cfg-14) + (b! (nonzero? v1-7) cfg-17 :delay (set! v1-10 (+ v1-7 -1))) + (vector-segment-distance-point! arg1 (-> arg2 vector 2) (the-as vector (-> arg2 vector)) arg0) + (goto cfg-24) + (label cfg-17) + (b! (nonzero? v1-10) cfg-22 :delay (nop!)) + (let ((f30-1 (vector-segment-distance-point! arg1 (the-as vector (-> arg2 vector)) (-> arg2 vector 1) arg0)) + (s3-1 (new 'stack-no-clear 'vector)) + ) + (if (< (vector-segment-distance-point! arg1 (the-as vector (-> arg2 vector)) (-> arg2 vector 2) s3-1) f30-1) + (set! (-> arg0 quad) (-> s3-1 quad)) + ) + ) + (goto cfg-24) + (label cfg-22) + (let ((f30-2 (vector-segment-distance-point! arg1 (-> arg2 vector 2) (the-as vector (-> arg2 vector)) arg0)) + (s3-2 (new 'stack-no-clear 'vector)) + ) + (if (< (vector-segment-distance-point! arg1 (-> arg2 vector 2) (-> arg2 vector 1) s3-2) f30-2) + (set! (-> arg0 quad) (-> s3-2 quad)) + ) + ) + (label cfg-24) + 0 + (none) + ) + ) + +(defun point-in-triangle-cross ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 vector)) + "Check if point is in the triangle using cross product check (so you have to get the order of points right)" + ;; og:preserve-this float -> int + (local-vars (v1-0 int) (a0-1 int) (a1-1 int)) + (rlet ((acc :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (.lvf vf3 (&-> arg3 quad)) + (.lvf vf4 (&-> arg4 quad)) + (.lvf vf5 (&-> arg0 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.lvf vf1 (&-> arg1 quad)) + (.sub.vf vf6 vf3 vf4) + (.sub.vf vf7 vf3 vf5) + (.sub.vf vf8 vf3 vf2) + (.sub.vf vf9 vf5 vf4) + (.sub.vf vf10 vf5 vf2) + (.outer.product.a.vf acc vf6 vf7) + (.outer.product.b.vf vf2 vf7 vf6 acc) + (.outer.product.a.vf acc vf7 vf8) + (.outer.product.b.vf vf3 vf8 vf7 acc) + (.outer.product.a.vf acc vf9 vf10) + (.outer.product.b.vf vf4 vf10 vf9 acc) + (.mul.vf vf2 vf2 vf1) + (.mul.vf vf3 vf3 vf1) + (.nop.vf) + (.mul.vf vf4 vf4 vf1) + (.add.x.vf.y vf2 vf2 vf2) + (.add.x.vf.y vf3 vf3 vf3) + (.add.x.vf.y vf4 vf4 vf4) + (.nop.vf) + (.add.z.vf.y vf2 vf2 vf2) + (.add.z.vf.y vf3 vf3 vf3) + (.add.z.vf.y vf4 vf4 vf4) + (.nop.vf) + (.mov a0-1 vf2) + (.mov a1-1 vf3) + (.mov v1-0 vf4) + ;; og:preserve-this + (>= (the-as int (logior (logior a0-1 a1-1) v1-0)) 0) + ) + ) + +(defun point-in-plane-<-point+normal! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Very strange function. Takes a plane, in point-normal form, then returns some other point on that plane. + It will move 1m in two of {x, y, z} directions. The direction not moved in is the one which is closest to point-in-triangle-cross + in the same direction of the normal (this prevent moving huge distances for nearly vertical planes for example)." + (let ((f0-3 (+ (* (-> arg2 x) (-> arg1 x)) (* (-> arg2 y) (-> arg1 y)) (* (-> arg2 z) (-> arg1 z))))) + (set! (-> arg0 w) 1.0) + (let ((f1-7 (fabs (-> arg2 x))) + (f2-3 (fabs (-> arg2 y))) + (f3-1 (fabs (-> arg2 z))) + ) + (cond + ((and (< f2-3 f1-7) (< f3-1 f1-7)) + (set! (-> arg0 y) (+ 4096.0 (-> arg1 y))) + (set! (-> arg0 z) (+ 4096.0 (-> arg1 z))) + (set! (-> arg0 x) (/ (+ (- (- (* (-> arg2 y) (-> arg0 y))) (* (-> arg2 z) (-> arg0 z))) f0-3) (-> arg2 x))) + ) + ((and (< f1-7 f2-3) (< f3-1 f2-3)) + (set! (-> arg0 x) (+ 4096.0 (-> arg1 x))) + (set! (-> arg0 z) (+ 4096.0 (-> arg1 z))) + (set! (-> arg0 y) (/ (- (- f0-3 (* (-> arg2 x) (-> arg0 x))) (* (-> arg2 z) (-> arg0 z))) (-> arg2 y))) + ) + (else + (set! (-> arg0 x) (+ 4096.0 (-> arg1 x))) + (set! (-> arg0 y) (+ 4096.0 (-> arg1 y))) + (set! (-> arg0 z) (/ (+ (- (- (* (-> arg2 x) (-> arg0 x))) (* (-> arg2 y) (-> arg0 y))) f0-3) (-> arg2 z))) + ) + ) + ) + ) + arg0 + ) + +(defun circle-circle-xz-intersect ((arg0 sphere) (arg1 sphere) (arg2 vector) (arg3 vector)) + ;; this function is unused and really complicated, so not implementing it for now. + (format 0 "circle-circle-xz-intersect~%") + (crash!) + 0 + ) + +;; WARN: Return type mismatch object vs none. +(defun circle-test () + "Test the circle-circle-xz-intersect function." + (let ((s4-0 (new 'stack 'sphere)) + (a1-2 (new 'stack 'sphere)) + (s5-0 (new-stack-vector0)) + (gp-0 (new-stack-vector0)) + ) + (let ((v1-3 s4-0)) + (set! (-> v1-3 x) 0.0) + (set! (-> v1-3 y) 0.0) + (set! (-> v1-3 z) 0.0) + (set! (-> v1-3 r) 1.0) + ) + (let ((v1-4 a1-2)) + (set! (-> v1-4 x) 100.0) + (set! (-> v1-4 y) 0.0) + (set! (-> v1-4 z) 0.0) + (set! (-> v1-4 r) 10000.0) + ) + (let ((a2-1 (circle-circle-xz-intersect s4-0 a1-2 s5-0 gp-0))) + (format #t "res = ~d~%" a2-1) + ) + (format #t "(~f, ~f)~%" (-> s5-0 x) (-> s5-0 z)) + (format #t "(~f, ~f)~%" (-> gp-0 x) (-> gp-0 z)) + ) + (none) + ) + +(defun vector-circle-tangent-new ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + "Unused." + (rlet ((Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (let ((a1-2 (new 'stack 'sphere))) + (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + (let ((v1-3 #x3f000000)) + (.lvf vf3 (&-> arg1 quad)) + (.mov vf2 v1-3) + ) + (.lvf vf4 (&-> arg0 quad)) + (.add.vf vf1 vf3 vf4) + (.sub.vf vf5 vf4 vf3) + (.mul.x.vf vf1 vf1 vf2) + (.mul.x.vf vf5 vf5 vf2) + (.mul.vf.xz vf5 vf5 vf5) + (.add.z.vf.x vf5 vf5 vf5) + (.sqrt.vf Q vf5 :ftf #b0) + (.wait.vf) + (.mul.vf.w vf1 vf0 Q) + (.nop.vf) + (.nop.vf) + (.svf (&-> a1-2 quad) vf1) + (circle-circle-xz-intersect (the-as sphere arg1) a1-2 arg2 arg3) + ) + 0 + (none) + ) + ) + +(defun vector-circle-tangent ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + "Also unused." + (let* ((s3-1 (vector-! (new 'stack-no-clear 'vector) arg1 arg0)) + (f0-0 (vector-xz-length s3-1)) + (f28-0 (acos (/ (-> arg1 w) f0-0))) + ) + (cond + ((>= 546.13336 f28-0) + (set! (-> arg2 x) (- (-> arg0 x) (-> s3-1 z))) + (set! (-> arg2 y) 0.0) + (set! (-> arg2 z) (+ (-> arg0 z) (-> s3-1 x))) + (set! (-> arg3 x) (+ (-> arg0 x) (-> s3-1 z))) + (set! (-> arg3 y) 0.0) + (set! (-> arg3 z) (- (-> arg0 z) (-> s3-1 x))) + ) + (else + (let ((f0-15 (atan (-> s3-1 z) (-> s3-1 x))) + (f30-0 (- (-> arg1 w))) + (s3-2 (new 'stack-no-clear 'vector)) + ) + (let ((s2-1 (new 'stack-no-clear 'vector))) + (let ((a2-1 (new 'stack-no-clear 'vector))) + (set! (-> a2-1 x) (- f0-15 f28-0)) + (set! (-> a2-1 y) (+ f0-15 f28-0)) + (vector-sincos! s3-2 s2-1 a2-1) + ) + (set! (-> arg2 x) (+ (-> arg1 x) (* f30-0 (-> s2-1 x)))) + (set! (-> arg2 z) (+ (-> arg1 z) (* f30-0 (-> s3-2 x)))) + (set! (-> arg3 x) (+ (-> arg1 x) (* f30-0 (-> s2-1 y)))) + ) + (set! (-> arg3 z) (+ (-> arg1 z) (* f30-0 (-> s3-2 y)))) + ) + ) + ) + ) + 0 + (none) + ) + +(defun find-knot-span ((arg0 int) (arg1 int) (arg2 float) (arg3 (inline-array vector))) + "Binary serach over knots to find which contains the value float in (arg0 arg1). Unused." + (local-vars (v0-0 int)) + (b! (= arg2 (-> (&-> arg3 0 data (+ arg0 1)) 0)) cfg-11 :delay (set! v0-0 arg0)) + (let ((v1-3 (the int arg2))) + (let* ((a2-1 (+ v1-3 3)) + (t0-1 (&-> arg3 0 data a2-1)) + (f1-2 (-> t0-1 0)) + (f2-0 (-> t0-1 1)) + ) + (b! (> f1-2 arg2) cfg-4) + (b! (>= arg2 f2-0) cfg-4 :delay (set! v0-0 a2-1)) + ) + (b! #t cfg-11 :delay (nop!)) + (label cfg-4) + (let ((a1-1 arg1) + (a0-1 (+ arg0 1)) + ) + (label cfg-5) + (let ((a2-3 (/ (+ a1-1 a0-1) 2))) + (let ((t0-3 (&-> arg3 0 data a2-3))) + (b! (>= arg2 (-> t0-3 0)) cfg-7) + (b! #t cfg-5 :delay (set! a0-1 a2-3)) + (label cfg-7) + (b! (< arg2 (-> t0-3 1)) cfg-9) + ) + (b! #t cfg-5 :delay (set! a1-1 a2-3)) + (label cfg-9) + (set! v0-0 a2-3) + ) + ) + (b! (= v0-0 v1-3) cfg-11 :delay (nop!)) + ) + (nop!) + (nop!) + (label cfg-11) + v0-0 + ) + +(defun calculate-basis-functions-vector! ((arg0 vector) (arg1 int) (arg2 float) (arg3 (pointer float))) + "Calculate polynomial basis for a given control point." + (local-vars (v1-0 int) (v1-1 object)) + ;; og:preserve-this + ;;(.sll v1-0 arg1 2) + (set! v1-0 (* 4 arg1)) ;; originally used 32-bit asm + (let ((a1-1 #x3f800000) + (f3-0 arg2) + ) + ;; og:preserve-this + ;;(.addu v1-1 arg3 v1-0) + (set! v1-1 (&+ arg3 v1-0)) + (let* ((f1-0 (the-as float a1-1)) ;; trick to load float constant. + (f5-0 f1-0) + ) + 0.0 + 0.0 + (let* ((f0-2 (-> (the-as (pointer float) v1-1) 0)) + (f2-0 (-> (the-as (pointer float) v1-1) 1)) + (f0-3 (- f3-0 f0-2)) + (f4-0 (- f2-0 f3-0)) + (f10-0 (/ f1-0 (+ f4-0 f0-3))) + (f2-2 (-> (the-as (pointer float) v1-1) -1)) + (f8-0 (-> (the-as (pointer float) v1-1) 2)) + (f2-3 (- f3-0 f2-2)) + (f9-0 (+ f4-0 f2-3)) + (f6-0 (-> (the-as (pointer float) v1-1) -2)) + (f7-0 (-> (the-as (pointer float) v1-1) 3)) + (f9-1 (/ f1-0 f9-0)) + (f5-1 (* f5-0 f10-0)) + (f11-0 (* f4-0 f5-1)) + (f10-1 (* f0-3 f5-1)) + (f5-2 (- f8-0 f3-0)) + (f8-1 (* f11-0 f9-1)) + (f11-1 (/ f1-0 (+ f5-2 f0-3))) + (f9-3 (* f4-0 f8-1)) + (f8-2 (* f2-3 f8-1)) + (f11-2 (* f10-1 f11-1)) + (f10-3 (+ (* f5-2 f11-2) f8-2)) + (f8-3 (* f0-3 f11-2)) + (f6-1 (- f3-0 f6-0)) + (f3-1 (- f7-0 f3-0)) + (f7-3 (* f9-3 (/ f1-0 (+ f4-0 f6-1)))) + (f4-1 (* f4-0 f7-3)) + (f6-2 (* f6-1 f7-3)) + (f7-6 (* f10-3 (/ f1-0 (+ f5-2 f2-3)))) + (f5-4 (+ (* f5-2 f7-6) f6-2)) + (f2-4 (* f2-3 f7-6)) + (f1-2 (* f8-3 (the-as float (/ f1-0 (+ f3-1 f0-3))))) + (f2-5 (+ (* f3-1 f1-2) f2-4)) + (f0-4 (* f0-3 f1-2)) + ) + (set! (-> arg0 x) f4-1) + (set! (-> arg0 y) f5-4) + (set! (-> arg0 z) f2-5) + (set! (-> arg0 w) f0-4) + ) + ) + ) + arg0 + ) + +(defun curve-evaluate! ((arg0 vector) (arg1 float) (arg2 (inline-array vector)) (arg3 int) (arg4 (pointer float)) (arg5 int)) + "Evaluate a curve. + arg0 is the output + arg1 is the input. + arg2 is control vertices + arg3 is the number of control vertices + arg4 is the knot points + arg5 is the number of knots + " + (local-vars (v1-7 int) (v1-8 int) (v1-10 float) (s3-0 int)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (new 'static 'vector))) + 0 + ;; lookup knot + (let* ((f0-0 (-> arg4 0)) + (f1-0 (-> (&-> arg4 (+ arg5 -1)) 0)) + (a2-1 (fmax (fmin (* arg1 f1-0) f1-0) f0-0)) + ) + (let* ((a1-1 (+ arg5 -5)) + (a3-1 3) + (f0-2 a2-1) + (v1-5 arg4) + (f0-3 f0-2) + ) + (b! (= f0-3 (-> (&-> v1-5 (+ a1-1 1)) 0)) + cfg-11 + :delay (set! s3-0 a1-1) + ) + (let ((a0-4 (the int f0-3))) + (let* ((t1-1 (+ a0-4 3)) + (t2-1 (&-> v1-5 t1-1)) + (f1-4 (-> t2-1 0)) + (f2-3 (-> t2-1 1)) + ) + (b! (> f1-4 f0-3) cfg-4) + (b! (>= f0-3 f2-3) cfg-4 :delay (set! s3-0 t1-1)) + ) + (b! #t cfg-11) + (label cfg-4) + (let ((a3-2 a3-1) + (a1-2 (+ a1-1 1)) + ) + (label cfg-5) + (let ((t1-3 (/ (+ a3-2 a1-2) 2))) + (let ((t2-3 (&-> v1-5 t1-3))) + (b! (>= f0-3 (-> t2-3 0)) cfg-7) + (b! #t cfg-5 :delay (set! a1-2 t1-3)) + (label cfg-7) + (b! (< f0-3 (-> t2-3 1)) cfg-9) + ) + (b! #t cfg-5 :delay (set! a3-2 t1-3)) + (label cfg-9) + (set! s3-0 t1-3) + ) + ) + (b! (= s3-0 a0-4) cfg-11) + ) + ) + (nop!) + (nop!) + (label cfg-11) + ;; og:preserve-this + ;; calculate coefficients for this knot's polynomial, store in s4-0 + (calculate-basis-functions-vector! + s4-0 + s3-0 + a2-1 + (the-as (pointer float) arg4) + ) + ) + ;; og:preserve-this + ;;(.addiu v1-7 s3-0 -3) + (set! v1-7 (- s3-0 3)) + (.lvf vf6 s4-0) + ) + ;; og:preserve-this + ;; evaluate polynomial! + ;;(.sll v1-8 v1-7 4) + (set! v1-8 (* v1-7 16)) + (.add.x.vf.w vf1 vf0 vf0) + (let ((v1-9 (+ v1-8 (the-as int arg2)))) + (nop!) + (nop!) + (.lvf vf2 (&-> (the-as (pointer int128) v1-9))) + (nop!) + (.lvf vf3 (+ v1-9 16)) + (nop!) + (.lvf vf4 (+ v1-9 32)) + (nop!) + (.lvf vf5 (+ v1-9 48)) + ) + (.mul.x.vf acc vf2 vf6) + (nop!) + (.add.mul.y.vf.xyz acc vf3 vf6 acc) + (nop!) + (.add.mul.z.vf.xyz acc vf4 vf6 acc) + (nop!) + (.add.mul.w.vf.xyz vf1 vf5 vf6 acc) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (.svf (&-> arg0 quad) vf1) + (.mov v1-10 vf1) + arg0 + ) + ) + +(defun curve-get-pos! ((arg0 vector) (arg1 float) (arg2 curve)) + "Get the position on the curve at the given input." + (curve-evaluate! arg0 arg1 (-> arg2 cverts) (-> arg2 num-cverts) (-> arg2 knots) (-> arg2 num-knots)) + ) + +(defun curve-length ((arg0 curve)) + "Compute the approximate curve length as the sum of distances between knots." + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (s3-0 (* 3 (-> arg0 num-cverts))) + (f30-0 0.0) + ) + (when (nonzero? s3-0) + (curve-evaluate! + s4-0 + (-> arg0 knots 0) + (-> arg0 cverts) + (-> arg0 num-cverts) + (-> arg0 knots) + (-> arg0 num-knots) + ) + (dotimes (s2-0 s3-0) + (set! (-> s5-0 quad) (-> s4-0 quad)) + (curve-evaluate! + s4-0 + (/ (the float (+ s2-0 1)) (the float s3-0)) + (-> arg0 cverts) + (-> arg0 num-cverts) + (-> arg0 knots) + (-> arg0 num-knots) + ) + (+! f30-0 (vector-vector-distance s5-0 s4-0)) + ) + ) + f30-0 + ) + ) + +(defun curve-copy! ((arg0 curve) (arg1 curve)) + "Shallow copy a curve." + (set! (-> arg0 cverts) (-> arg1 cverts)) + (set! (-> arg0 num-cverts) (-> arg1 num-cverts)) + (set! (-> arg0 knots) (-> arg1 knots)) + (set! (-> arg0 num-knots) (-> arg1 num-knots)) + (set! (-> arg0 length) (-> arg1 length)) + arg0 + ) + +(defun curve-closest-point ((arg0 curve) (arg1 vector) (arg2 float) (arg3 float) (arg4 int) (arg5 float)) + "Get the input value for the point on the curve. Approximate! And is O(n_knots)." + (let ((sv-48 arg3) + (s3-0 arg4) + (gp-0 arg5) + (f30-0 (curve-length arg0)) + (s2-0 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + ) + 0.0 + 0.0 + 0.0 + 0.0 + (let ((f28-0 0.5)) + 0.0 + (if (< 0.0 sv-48) + (set! f28-0 (/ sv-48 f30-0)) + ) + (let* ((s0-1 (- arg2 (/ gp-0 f30-0))) + (f26-0 (- s0-1 f28-0)) + (f24-0 (+ s0-1 f28-0)) + ) + (curve-get-pos! s2-0 f26-0 arg0) + (curve-get-pos! s1-0 f24-0 arg0) + (let ((f22-0 (vector-vector-distance-squared s2-0 arg1)) + (f20-0 (vector-vector-distance-squared s1-0 arg1)) + ) + (while (> s3-0 0) + (+! s3-0 -1) + (set! f28-0 (/ f28-0 2)) + (let ((v1-6 (cond + ((< f22-0 f20-0) + (curve-get-pos! s1-0 s0-1 arg0) + (set! f20-0 (vector-vector-distance-squared s1-0 arg1)) + (set! f24-0 s0-1) + (- s0-1 f28-0) + ) + (else + (curve-get-pos! s2-0 s0-1 arg0) + (set! f22-0 (vector-vector-distance-squared s2-0 arg1)) + (set! f26-0 s0-1) + (+ s0-1 f28-0) + ) + ) + ) + ) + (set! s0-1 (fmin 1.0 (fmax 0.0 v1-6))) + ) + ) + (+ (if (< f22-0 f20-0) + f26-0 + f24-0 + ) + (/ gp-0 f30-0) + ) + ) + ) + ) + ) + ) + +(defun vector-plane-distance ((arg0 vector) (arg1 plane) (arg2 vector)) + "Unused." + (vector-dot (vector-! (new 'stack-no-clear 'vector) arg0 (the-as vector (-> arg1 data))) arg2) + ) + +(defun intersect-ray-plane ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + "arg1 is ray direction, arg3 is plane normal, others don't really make sense to me." + (let ((f0-1 (vector-dot arg3 arg1))) + (if (= f0-1 0.0) + -1.0 + (/ (- (vector-dot arg3 arg0) (vector-dot arg3 arg2)) (- f0-1)) + ) + ) + ) + +(defun line-line-find-intersection-xz ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 vector)) + (let* ((f0-0 (-> arg1 x)) + (f3-0 (-> arg1 z)) + (f4-0 (-> arg3 x)) + (f5-0 (-> arg3 z)) + (f1-3 (+ (* -1.0 f5-0 f0-0) (* f3-0 f4-0))) + ) + (cond + ((< 0.0001 (fabs f1-3)) + (let* ((f2-3 (* -1.0 f1-3)) + (f5-2 (* -1.0 f5-0 (- (-> arg2 x) (-> arg0 x)))) + (f4-1 (* (- (-> arg2 z) (-> arg0 z)) f4-0)) + (f3-2 (* -1.0 f3-0 (- (-> arg0 x) (-> arg2 x)))) + (f0-1 (* (- (-> arg0 z) (-> arg2 z)) f0-0)) + (f1-4 (/ (+ f5-2 f4-1) f1-3)) + ) + (let ((f0-3 (/ (+ f3-2 f0-1) f2-3))) + (when arg4 + (set! (-> arg4 y) f0-3) + (set! (-> arg4 x) f1-4) + ) + ) + (return f1-4) + ) + ) + (else + (when arg4 + (set! (-> arg4 y) -100000000.0) + (set! (-> arg4 x) -100000000.0) + ) + (return -100000000.0) + ) + ) + ) + 0.0 + ) + +(defun segment-segment-find-intersection-xz ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (line-line-find-intersection-xz arg0 arg1 arg2 arg3 gp-0) + (if (and (>= (-> gp-0 x) 0.0) (>= (-> gp-0 y) 0.0) (>= 1.0 (-> gp-0 x)) (>= 1.0 (-> gp-0 y))) + (-> gp-0 x) + -100000000.0 + ) + ) + ) + +(defun generate-rand-vector-on-sphere ((arg0 vector)) + (let* ((f30-0 65536.0) + (v1-2 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-3 (the-as number (logior #x3f800000 v1-2))) + (f30-1 (* f30-0 (+ -1.0 (the-as float v1-3)))) + (f28-0 65536.0) + (v1-7 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-8 (the-as number (logior #x3f800000 v1-7))) + (f28-1 (* f28-0 (+ -1.0 (the-as float v1-8)))) + ) + 0.0 + (let ((f26-0 (cos f30-1))) + (set-vector! arg0 (* f26-0 (cos f28-1)) (* f26-0 (sin f28-1)) (sin f30-1) 1.0) + ) + ) + (vector-normalize! arg0 1.0) + ) + +(defmethod evaluate! ((this lissajous-interp) (arg0 vector)) + "Set the x and y component of the vector to the current point on the curve." + (evaluate! (-> this current) arg0) + ) + +(defmethod update! ((this lissajous-interp)) + "Update both the interpolation, and the curves themselves." + (seek! (-> this current x-mag) (-> this dest x-mag) (-> this rate x-mag)) + (seek! (-> this current y-mag) (-> this dest y-mag) (-> this rate y-mag)) + (seek! (-> this current theta-rate) (-> this dest theta-rate) (-> this rate theta-rate)) + (seek! (-> this current theta) (-> this dest theta) (* (-> this current theta-rate) (-> this rate theta))) + (seek! (-> this current wx) (-> this dest wx) (-> this rate wx)) + (seek! (-> this current wy) (-> this dest wy) (-> this rate wy)) + (set! (-> this current period-shift) + (seek (-> this current period-shift) (-> this dest period-shift) (-> this rate period-shift)) + ) + ) + +(defmethod evaluate! ((this lissajous) (arg0 vector)) + "Set the x and y component of the vector to the current point on the curve." + 0.0 + 0.0 + (let ((f30-0 (* (cos (* (-> this theta) (-> this wx))) (-> this x-mag))) + (f0-8 (* (cos (+ (-> this period-shift) (* (-> this theta) (-> this wy)))) (-> this y-mag))) + ) + (set-vector! arg0 f30-0 f0-8 0.0 1.0) + ) + arg0 + ) + +(defun ellipsoid-get-foci ((arg0 ellipsoid) (arg1 vector) (arg2 vector)) + (let ((f0-4 (sqrtf (- (square (-> arg0 z)) (square (-> arg0 w)))))) + (set-vector! arg1 0.0 0.0 f0-4 1.0) + (set-vector! arg2 0.0 0.0 (- f0-4) 1.0) + f0-4 + ) + ) diff --git a/goal_src/jakx/engine/geometry/path-h.gc b/goal_src/jakx/engine/geometry/path-h.gc index b54d839f27..79d8c1ac48 100644 --- a/goal_src/jakx/engine/geometry/path-h.gc +++ b/goal_src/jakx/engine/geometry/path-h.gc @@ -5,5 +5,18 @@ ;; name in dgo: path-h ;; dgos: ENGINE, GAME +;; +++path-control-flag +(defenum path-control-flag + :bitfield #t + :type uint32 + (display 0) + (draw-line 1) ;; TODO - only seen it used to control debug drawing so far + (draw-point 2) ;; TODO - only seen it used to control debug drawing so far + (draw-text 3) ;; TODO - only seen it used to control debug drawing so far + (not-found 4) + ) +;; ---path-control-flag + + ;; DECOMP BEGINS diff --git a/goal_src/jakx/engine/gfx/background/background-h.gc b/goal_src/jakx/engine/gfx/background/background-h.gc index ca332439d6..fc6cdd1e51 100644 --- a/goal_src/jakx/engine/gfx/background/background-h.gc +++ b/goal_src/jakx/engine/gfx/background/background-h.gc @@ -7,3 +7,32 @@ ;; DECOMP BEGINS +(deftype background-work (basic) + "List of all things for the background renderer to draw." + ((tfrag-tree-count int32) + (tfrag-trees drawable-tree-tfrag 19) + (tfrag-levels level 19) + (tfrag-trans-tree-count int32) + (tfrag-trans-trees drawable-tree-tfrag-trans 19) + (tfrag-trans-levels level 19) + (tfrag-water-tree-count int32) + (tfrag-water-trees drawable-tree-tfrag-water 19) + (tfrag-water-levels level 19) + (tfrag-shared-tree-count int32) + (tfrag-shared-trees drawable-tree-tfrag-shared 19) + (tfrag-shared-levels level 19) + (tfrag-trans-shared-tree-count int32) + (tfrag-trans-shared-trees drawable-tree-tfrag-trans-shared 19) + (tfrag-trans-shared-levels level 19) + (tfrag-water-shared-tree-count int32) + (tfrag-water-shared-trees drawable-tree-tfrag-water-shared 19) + (tfrag-water-shared-levels level 19) + (shrub-tree-count int32) + (shrub-trees drawable-tree-instance-shrub 19) + (shrub-levels level 19) + (tie-tree-count int32) + (tie-trees drawable-tree-instance-tie 19) + (tie-levels level 19) + (wait-to-vu0 uint32) + ) + ) diff --git a/goal_src/jakx/engine/gfx/background/prototype-h.gc b/goal_src/jakx/engine/gfx/background/prototype-h.gc index cd2b14cb6f..f8731b0fba 100644 --- a/goal_src/jakx/engine/gfx/background/prototype-h.gc +++ b/goal_src/jakx/engine/gfx/background/prototype-h.gc @@ -5,5 +5,218 @@ ;; name in dgo: prototype-h ;; dgos: ENGINE, GAME +;; +++prototype-flags +(defenum prototype-flags + :bitfield #t + :type uint16 + (disable 0) ;; set from debug menu, for debugging + (tpage-alpha 2) + (vanish 3) + (visible 5) ;; set by prototypes-game-visible-set! to hide things on purpose + (no-collide 6) + (tpage-water 7) + ) +;; ---prototype-flags + +;; +++instance-flags +(defenum instance-flags + :type uint16 + :bitfield #t + (no-collide 0) + ) +;; ---instance-flags + + +(declare-type prototype-tie drawable) +(declare-type collide-hash-fragment-array basic) + ;; DECOMP BEGINS +(deftype prototype-bucket (basic) + ((name string) + (flags prototype-flags) + (texture-masks-index uint16) + (in-level uint16) + (utextures uint16) + (geometry drawable 4) + (dists vector :inline) + (rdists vector :inline) + (near-plane meters :overlay-at (-> dists data 0)) + (near-stiff meters :overlay-at (-> dists data 1)) + (mid-plane meters :overlay-at (-> dists data 2)) + (far-plane meters :overlay-at (-> dists data 3)) + (rlength-near float :overlay-at (-> rdists data 0)) + (rlength-stiff float :overlay-at (-> rdists data 1)) + (rlength-mid float :overlay-at (-> rdists data 2)) + (stiffness float :overlay-at (-> rdists data 3)) + ) + ) + + +(deftype prototype-bucket-shrub (prototype-bucket) + ((next uint32 4) + (count uint16 4) + (count-quad uint128 :overlay-at (-> count 0)) + (mod-count uint16 4 :offset 88) + (last dma-packet 4) + (next-clear uint128 :overlay-at (-> next 0)) + (count-clear uint64 :overlay-at (-> count 0)) + (last-clear uint128 :overlay-at (-> last 0)) + ) + ) + + +(deftype prototype-inline-array-shrub (drawable) + ((length int16 :offset 6) + (data prototype-bucket-shrub 1 :inline :offset 32) + (pad uint32) + ) + ) + + +(deftype prototype-array-shrub-info (basic) + ((prototype-inline-array-shrub prototype-inline-array-shrub) + (wind-vectors uint32) + (wind-count int32) + ) + ) + + +(deftype prototype-bucket-tie (prototype-bucket) + ((next uint32 12) + (count uint16 12) + (frag-count uint8 4) + (index-start uint8 4) + (base-qw uint16 4) + (tie-rvanish float) + (tie-vanish-far float) + (envmap-rfade float) + (envmap-fade-far float) + (envmap-shader adgif-shader) + (tint-color uint32) + (collide-hash-fragment-array collide-hash-fragment-array) + (tie-colors time-of-day-palette) + (data uint32 :dynamic) + (color-index-qwc uint32 :dynamic) + (scissor-frag-count uint8 :overlay-at (-> frag-count 0)) + (near-frag-count uint8 :overlay-at (-> frag-count 1)) + (mid-frag-count uint8 :overlay-at (-> frag-count 2)) + (far-frag-count uint8 :overlay-at (-> frag-count 3)) + (scissor-index-start uint8 :overlay-at (-> index-start 0)) + (near-index-start uint8 :overlay-at (-> index-start 1)) + (mid-index-start uint8 :overlay-at (-> index-start 2)) + (far-index-start uint8 :overlay-at (-> index-start 3)) + (scissor-base-qw uint16 :overlay-at (-> base-qw 0)) + (near-base-qw uint16 :overlay-at (-> base-qw 1)) + (mid-base-qw uint16 :overlay-at (-> base-qw 2)) + (far-base-qw uint16 :overlay-at (-> base-qw 3)) + (tie-next uint32 4 :overlay-at (-> next 0)) + (tie-scissor-next uint32 :overlay-at (-> next 0)) + (tie-near-next uint32 :overlay-at (-> next 1)) + (tie-mid-next uint32 :overlay-at (-> next 2)) + (tie-far-next uint32 :overlay-at (-> next 3)) + (trans-next uint32 4 :overlay-at (-> next 0)) + (trans-scissor-next uint32 4 :overlay-at (-> next 0)) + (trans-near-next uint32 :overlay-at (-> next 1)) + (trans-mid-next uint32 :overlay-at (-> next 2)) + (trans-far-next uint32 :overlay-at (-> next 3)) + (water-next uint32 4 :overlay-at (-> next 0)) + (water-scissor-next uint32 4 :overlay-at (-> next 0)) + (water-near-next uint32 :overlay-at (-> next 1)) + (water-mid-next uint32 :overlay-at (-> next 2)) + (water-far-next uint32 :overlay-at (-> next 3)) + (envmap-next uint32 4 :overlay-at (-> next 4)) + (envmap-scissor-next uint32 4 :overlay-at (-> next 4)) + (envmap-near-next uint32 :overlay-at (-> next 5)) + (envmap-mid-next uint32 :overlay-at (-> next 6)) + (envmap-far-next uint32 :overlay-at (-> next 7)) + (generic-next uint32 3 :overlay-at (-> next 8)) + (generic-near-next uint32 :overlay-at (-> next 8)) + (generic-mid-next uint32 :overlay-at (-> next 9)) + (generic-far-next uint32 :overlay-at (-> next 10)) + (vanish-next uint32 :overlay-at (-> next 11)) + (tie-count uint16 4 :overlay-at (-> count 0)) + (tie-scissor-count uint16 :overlay-at (-> count 0)) + (tie-near-count uint16 :overlay-at (-> count 1)) + (tie-mid-count uint16 :overlay-at (-> count 2)) + (tie-far-count uint16 :overlay-at (-> count 3)) + (trans-count uint16 4 :overlay-at (-> count 0)) + (trans-scissor-count uint16 :overlay-at (-> count 0)) + (trans-near-count uint16 :overlay-at (-> count 1)) + (trans-mid-count uint16 :overlay-at (-> count 2)) + (trans-far-count uint16 :overlay-at (-> count 3)) + (water-count uint16 4 :overlay-at (-> count 0)) + (water-scissor-count uint16 :overlay-at (-> count 0)) + (water-near-count uint16 :overlay-at (-> count 1)) + (water-mid-count uint16 :overlay-at (-> count 2)) + (water-far-count uint16 :overlay-at (-> count 3)) + (envmap-count uint16 4 :overlay-at (-> count 4)) + (envmap-scissor-count uint16 :overlay-at (-> count 4)) + (envmap-near-count uint16 :overlay-at (-> count 5)) + (envmap-mid-count uint16 :overlay-at (-> count 6)) + (envmap-far-count uint16 :overlay-at (-> count 7)) + (generic-count uint16 3 :overlay-at (-> count 8)) + (generic-near-count uint16 :overlay-at (-> count 8)) + (generic-mid-count uint16 :overlay-at (-> count 9)) + (generic-far-count uint16 :overlay-at (-> count 10)) + (vanish-count uint16 :overlay-at (-> count 11)) + (next-clear uint128 3 :overlay-at (-> next 0)) + (count-clear uint64 3 :overlay-at (-> count 0)) + (tie-geom prototype-tie 4 :overlay-at (-> geometry 0)) + ) + ) + + +(deftype prototype-array-tie (array) + ((array-data prototype-bucket-tie :dynamic :offset 16) + ) + (:methods + (prototype-array-tie-method-9 () none) + ) + ) + + +(deftype proxy-prototype-array-tie (basic) + ((prototype-array-tie prototype-array-tie) + (wind-vectors uint32) + (wind-count uint16) + (prototype-max-qwc uint16) + ) + ) + + +(deftype prototype-node (structure) + ((prototype basic) + (level basic) + (id int16) + (next-prototype int16) + (next-child int16) + (prev-child int16) + ) + ) + + +(deftype prototype-node-group (basic) + ((next-prototype int16) + (next-free int16) + (next-child-prototype int16 19) + (data prototype-node 512 :inline) + ) + (:methods + (prototype-node-group-method-9 () none) + (prototype-node-group-method-10 () none) + (prototype-node-group-method-11 () none) + (prototype-node-group-method-12 () none) + (prototype-node-group-method-13 () none) + (prototype-node-group-method-14 () none) + ) + ) + + +(deftype instance (drawable) + ((bucket-index uint16 :offset 6) + (origin matrix4h :inline) + (flags instance-flags :overlay-at (-> origin data 7)) + (wind-index uint16 :overlay-at (-> origin data 15)) + ) + ) diff --git a/goal_src/jakx/engine/gfx/background/subdivide-h.gc b/goal_src/jakx/engine/gfx/background/subdivide-h.gc index 850eea79ef..b50836d320 100644 --- a/goal_src/jakx/engine/gfx/background/subdivide-h.gc +++ b/goal_src/jakx/engine/gfx/background/subdivide-h.gc @@ -7,3 +7,151 @@ ;; DECOMP BEGINS +(deftype subdivide-settings (basic) + "Input settings for distances for switching mesh level of details. +These are set by the level code and read by rendering code." + ((dist float 5) + (meters float 5) + (close float 20) + (far float 20) + ) + (:methods + (new (symbol type float float) _type_) + ) + ) + + +(defmethod new subdivide-settings ((allocation symbol) (type-to-make type) (arg0 float) (arg1 float)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (dotimes (v1-2 18) + (set! (-> v0-0 close v1-2) arg0) + (set! (-> v0-0 far v1-2) arg1) + ) + v0-0 + ) + ) + +(deftype subdivide-dists (structure) + "Unused subdivide distances. Internally, tfrag/tie figure these out instead." + ((data uint32 32 :offset 0) + (vector vector 8 :overlay-at (-> data 0)) + (k0s uint128 4 :overlay-at (-> data 0)) + (k1s uint128 4 :overlay-at (-> data 16)) + ) + ) + + +(deftype terrain-stats (structure) + "Desptie the name `terrain-stats`, these are more general triangle stats for all renderers." + ((pris tr-stat :inline) + (tie-generic tr-stat :inline) + (tie-vanish tr-stat :inline) + (tie tr-stat :inline) + (tie-scissor tr-stat :inline) + (tie-envmap tr-stat :inline) + (tie-envmap-scissor tr-stat :inline) + (tie-trans tr-stat :inline) + (tie-scissor-trans tr-stat :inline) + (tie-envmap-trans tr-stat :inline) + (tie-envmap-scissor-trans tr-stat :inline) + (tie-water tr-stat :inline) + (tie-scissor-water tr-stat :inline) + (tie-envmap-water tr-stat :inline) + (tie-envmap-scissor-water tr-stat :inline) + (shrub-near tr-stat :inline) + (shrub tr-stat :inline) + (tfrag-scissor tr-stat :inline) + (tfrag tr-stat :inline) + (billboard tr-stat :inline) + (tfrag-trans tr-stat :inline) + (tfrag-scissor-trans tr-stat :inline) + (tfrag-water tr-stat :inline) + (tfrag-scissor-water tr-stat :inline) + (trans-pris tr-stat :inline) + (trans-shrub tr-stat :inline) + (ocean-mid tr-stat :inline) + (ocean-near tr-stat :inline) + (shadow tr-stat :inline) + (total tr-stat :inline) + ) + ) + + +(deftype background-area (structure) + "Scratchpad memory layout for most background rendering +This uses the full scratchpad so it should only be used when the stack isn't on the scratchpad (rendering code). +Interestingly, dma-area went from a union of all the -dma types to a plain array of bytes in jak 3." + ((dma-area uint8 14336) + (vis-list uint8 2048) + ) + ) + + +(deftype foreground-area (structure) + "Scratchpad memory layout for most foreground rendering." + ((generic-work generic-work :inline :offset 0) + (foreground-work foreground-work :inline :offset 0) + (joint-work joint-work :inline :offset 0) + (bone-mem bone-memory :inline :offset 0) + (shadow-work shadow-work :inline :offset 0) + ) + ) + + +(deftype region-prim-area (structure) + "Scratchpad memory layout for regions." + ((region-prim-list region-prim-list :inline) + (pos vector :inline) + (exit-pos vector :inline) + (ray vector :inline) + (exit-ray vector :inline) + (region-enter-count int32) + (region-enter-list region 320) + (region-enter-prim-list drawable-region-sphere 320) + (region-exit-count int32) + (region-exit-list region 320) + (region-exit-prim-list drawable-region-sphere 320) + (region-inside-count int32) + (region-inside-list region 320) + (region-inside-prim-list drawable-region-sphere 320) + (region-start-count int32) + (region-start-list region 320) + (region-start-prim-list drawable-region-sphere 320) + ) + (:methods + (track-entered-region! (_type_ drawable-region-sphere) int) + (track-exited-region! (_type_ drawable-region-sphere) int) + (track-inside-region! (_type_ drawable-region-sphere) int) + (track-start-region! (_type_ drawable-region-sphere) int) + ) + ) + + +(deftype sprite-area (structure) + "Scratchpad memory layout for sprites." + ((clock-data vector 22 :inline) + (buffer uint8 :dynamic) + ) + ) + + +(deftype work-area (structure) + "All scratchpad memory layouts." + ((background background-area :inline :offset 0) + (foreground foreground-area :inline :offset 0) + (region-prim region-prim-area :inline :offset 0) + (sprite sprite-area :inline :offset 0) + ) + ) + + +(deftype terrain-context (structure) + "Useless wrapper around work-area. (this added some stuff in jak 1)" + ((work work-area :inline) + ) + ) + + +(define *terrain-stats* (new 'global 'terrain-stats)) + +(define *collide-stats* (new 'global 'collide-stats)) diff --git a/goal_src/jakx/engine/gfx/background/tfrag/tfrag-h.gc b/goal_src/jakx/engine/gfx/background/tfrag/tfrag-h.gc index 9637056788..0dfc29b7fa 100644 --- a/goal_src/jakx/engine/gfx/background/tfrag/tfrag-h.gc +++ b/goal_src/jakx/engine/gfx/background/tfrag/tfrag-h.gc @@ -7,3 +7,224 @@ ;; DECOMP BEGINS +(deftype tfragment-stats (structure) + "Triangle and vertex stats for a single tfragment." + ((num-tris uint16 4) + (num-dverts uint16 4) + ) + ) + + +(deftype tfragment-debug-data (structure) + "Optional debug information (stats, lines) for a tfragment." + ((stats tfragment-stats :inline) + (debug-lines (array vector-array)) + ) + ) + + +(deftype generic-tfragment (structure) + "Unused. Could have been a way to render tfrag's through generic." + ((dummy int32) + ) + ) + + +(deftype tfragment (drawable) + "A tfrag mesh fragment. This is just references to DMA data, plus some metadata." + ((color-index uint16 :offset 6) + (debug-data tfragment-debug-data :offset 8) + (color-indices uint32 :offset 12) + (colors uint32 :overlay-at color-indices) + (dma-chain uint32 3 :offset 32) + (dma-common uint32 :overlay-at (-> dma-chain 0)) + (dma-level-0 uint32 :overlay-at dma-common) + (dma-base uint32 :overlay-at (-> dma-chain 1)) + (dma-level-1 uint32 :overlay-at (-> dma-chain 2)) + (dma-qwc uint8 4 :offset 44) + (dma-qwc-word uint32 :overlay-at (-> dma-qwc 0)) + (shader (inline-array adgif-shader) :offset 48) + (num-shaders uint8 :offset 52) + (num-base-colors uint8 :offset 53) + (num-level0-colors uint8 :offset 54) + (num-level1-colors uint8 :offset 55) + (color-offset uint8 :offset 56) + (color-count uint8 :offset 57) + (texture-masks-index uint16 :offset 58) + (generic generic-tfragment :offset 60) + (generic-u32 uint32 :overlay-at generic) + ) + ) + + +(deftype drawable-inline-array-tfrag (drawable-inline-array) + "Array of tfragments" + ((data tfragment 1 :inline) + (pad uint32) + ) + ) + +(deftype drawable-inline-array-tfrag-trans (drawable-inline-array-tfrag) + ((data2 tfragment 1 :inline) + (pad2 uint32) + ) + ) + +(deftype drawable-inline-array-tfrag-water (drawable-inline-array-tfrag) + ((data2 tfragment 1 :inline) + (pad2 uint32) + ) + ) + +(deftype drawable-tree-tfrag (drawable-tree) + "top level tfrag tree." + ((time-of-day-pal time-of-day-palette :offset 12) + (arrays drawable-inline-array :dynamic :offset 32) + ) + ) + +(deftype drawable-tree-tfrag-trans (drawable-tree-tfrag) + () + ) + +(deftype drawable-tree-tfrag-water (drawable-tree-tfrag-trans) + () + ) + +(deftype drawable-tree-tfrag-shared (drawable-tree-tfrag) + () + ) + +(deftype drawable-tree-tfrag-trans-shared (drawable-tree-tfrag-shared) + () + ) + +(deftype drawable-tree-tfrag-water-shared (drawable-tree-tfrag-shared) + () + ) + +(deftype tfrag-dists (structure) + "Distances for mesh level-of-detail blending for use on VU1." + ((data uint32 16) + (vector vector 4 :overlay-at (-> data 0)) + (k0s vector 2 :overlay-at (-> data 0)) + (k1s vector 2 :overlay-at (-> data 8)) + ) + ) + + +(deftype tfrag-data (structure) + "Constants for VU1 data memory for tfrag rendering." + ((data uint32 56) + (vector vector 14 :overlay-at (-> data 0)) + (fog vector :inline :overlay-at (-> data 0)) + (val vector :inline :overlay-at (-> data 4)) + (strgif gs-gif-tag :inline :overlay-at (-> data 8)) + (fangif gs-gif-tag :inline :overlay-at (-> data 12)) + (adgif gs-gif-tag :inline :overlay-at (-> data 16)) + (hvdf-offset vector :inline :overlay-at (-> data 20)) + (hmge-scale vector :inline :overlay-at (-> data 24)) + (invh-scale vector :inline :overlay-at (-> data 28)) + (ambient vector :inline :overlay-at (-> data 32)) + (guard vector :inline :overlay-at (-> data 36)) + (dists tfrag-dists :inline :overlay-at (-> data 40)) + (k0s uint128 2 :overlay-at (-> data 40)) + (k1s uint128 2 :overlay-at (-> data 48)) + ) + ) + + +(deftype tfrag-control (structure) + "VU1 'control' data containing address and counters." + ((num-base-points uint32) + (num-shared-base-points uint32) + (num-level0-points uint32) + (num-shared-level0-points uint32) + (num-level1-points uint32) + (num-shared-level1-points uint32) + (ptr-vtxdata uint32) + (ptr-base-points uint32) + (ptr-shared-base-points uint32) + (ptr-level0-points uint32) + (ptr-shared-level0-points uint32) + (ptr-level1-points uint32) + (ptr-shared-level1-points uint32) + (ptr-draw-points uint32) + (ptr-interpolated-0 uint32) + (ptr-shared-interpolated-0 uint32) + (ptr-interpolated1 uint32) + (ptr-shared-interpolated1 uint32) + (ptr-strip-data uint32) + (ptr-texture-data uint32) + ) + ) + + +(deftype tfrag-stats (structure) + "TFRAG statistics computed on EE." + ((from int32) + (to int32) + (cnt int32) + (tris int32) + (tfaces int32) + (tfrags int32) + (dtris int32) + (base-verts int32) + (level0-verts int32) + (level1-verts int32) + (dma-cnt int32) + (dma-dta int32) + (dma-tex int32) + (strips int32) + (drawpoints int32) + (vif int32) + ) + ) + + +(deftype tfrag-packet (structure) + ((tag uint128 2) + ) + ) + + +(deftype tfrag-work (structure) + "Scratch space for generating TFRAG DMA." + ((base-tmpl dma-packet :inline) + (level-0-tmpl dma-packet :inline) + (common-tmpl dma-packet :inline) + (level-1-tmpl dma-packet :inline) + (color-tmpl dma-packet :inline) + (frag-dists vector :inline) + (min-dist vector :inline) + (color-ptr vector4w :inline) + (tr-stat-tfrag tr-stat) + (tr-stat-tfrag-scissor tr-stat) + (vu1-enable-tfrag int32) + (vu1-enable-tfrag-scissor int32) + (cur-vis-bits uint32) + (end-vis-bits uint32) + (src-ptr uint32) + (last-call uint32) + (dma-buffer basic) + (test-id uint32) + (wait-from-spr uint32) + (wait-to-spr uint32) + (near-wait-from-spr uint32) + (near-wait-to-spr uint32) + (max-fragment uint16) + (min-fragment uint16) + (texture-dists uint32) + ) + ) + + +(deftype tfrag-dma (structure) + "Memory layout for to/from scratchpad for tfrag." + ((banka tfragment 16 :inline) + (bankb tfragment 16 :inline) + (outa uint128 128) + (outb uint128 128) + (colors rgba 2047) + ) + ) diff --git a/goal_src/jakx/engine/gfx/background/tie/generic-tie-h.gc b/goal_src/jakx/engine/gfx/background/tie/generic-tie-h.gc index e629feff2f..b7936571f3 100644 --- a/goal_src/jakx/engine/gfx/background/tie/generic-tie-h.gc +++ b/goal_src/jakx/engine/gfx/background/tie/generic-tie-h.gc @@ -7,3 +7,197 @@ ;; DECOMP BEGINS +(deftype generic-tie-instance (structure) + ((matrix-tag dma-packet :inline) + (matrix-data vector 6 :inline) + (index-tag dma-packet :inline) + (indices uint8 224) + (end-tag dma-packet :inline) + ) + ) + + +(deftype generic-tie-input (structure) + ((palette-tag dma-packet :inline) + (palette rgba 128) + (model-tag dma-packet :inline) + (model vector 146 :inline) + (matrix-tag dma-packet :inline) + (matrix-data vector 6 :inline) + (index-tag dma-packet :inline) + (indices uint8 224) + (end-tag dma-packet :inline) + ) + ) + + +(deftype generic-tie-run-control (structure) + ((skip-bp2 uint8) + (skip-ips uint8) + (gifbuf-skip uint8) + (strips uint8) + (target-bp1 uint8) + (target-bp2 uint8) + (target-ip1 uint8) + (target-ip2 uint8) + (target-bps uint8) + (target-ips uint8) + (is-generic uint8) + (reserved uint8) + ) + ) + + +(deftype generic-tie-base-point (structure) + ((data uint16 8) + (quad uint128 :overlay-at (-> data 0)) + (x int16 :overlay-at (-> data 0)) + (y int16 :overlay-at (-> data 1)) + (z int16 :overlay-at (-> data 2)) + (d0 int16 :overlay-at (-> data 3)) + (vtx uint64 :overlay-at (-> data 0)) + (u int16 :overlay-at (-> data 4)) + (v int16 :overlay-at (-> data 5)) + (tex uint32 :overlay-at (-> data 4)) + (w int16 :overlay-at (-> data 6)) + (d1 int16 :overlay-at (-> data 7)) + ) + ) + + +(deftype generic-tie-bps (structure) + ((bp generic-tie-base-point 4 :inline) + ) + ) + + +(deftype generic-tie-interp-point (structure) + ((data uint16 12) + (x int16 :overlay-at (-> data 0)) + (y int16 :overlay-at (-> data 1)) + (z int16 :overlay-at (-> data 2)) + (d0 int16 :overlay-at (-> data 3)) + (vtx0 uint64 :overlay-at (-> data 0)) + (dx int16 :overlay-at (-> data 4)) + (dy int16 :overlay-at (-> data 5)) + (dz int16 :overlay-at (-> data 6)) + (unused int16 :overlay-at (-> data 7)) + (vtx1 uint64 :overlay-at (-> data 4)) + (u int16 :overlay-at (-> data 8)) + (v int16 :overlay-at (-> data 9)) + (tex uint32 :overlay-at (-> data 8)) + (w int16 :overlay-at (-> data 10)) + (d1 int16 :overlay-at (-> data 11)) + ) + :pack-me + ) + +;; ERROR: failed type prop at 19: Could not figure out load: (set! a2 (l.q gp)) + +(deftype generic-tie-ips (structure) + ((ip generic-tie-interp-point 2 :inline) + ) + ) + + +(deftype generic-tie-header (structure) + ((effect uint8) + (interp-table-size uint8) + (num-bps uint8) + (num-ips uint8) + (tint-color uint32) + (index-table-offset uint16) + (kick-table-offset uint16) + (normal-table-offset uint16) + (interp-table-offset uint16) + (gsf-header gsf-header :inline) + ) + ) + + +(deftype generic-tie-matrix (structure) + ((matrix matrix :inline) + (morph vector :inline) + (fog qword :inline) + ) + ) + + +(deftype generic-tie-normal (structure) + ((x int8) + (y int8) + (z int8) + (dummy int8) + ) + ) + + +(deftype generic-tie-control (structure) + ((ptr-palette uint32) + (ptr-shaders uint32) + (ptr-runctrl generic-tie-run-control) + (ptr-verts uint32) + (ptr-generic generic-tie-header) + (ptr-dps uint32) + (ptr-kicks uint32) + (ptr-normals uint32) + (ptr-interp uint32) + (ptr-mtxs generic-tie-matrix) + (ptr-cinds uint32) + (next-instance uint32) + (next-model uint32) + (next-is-model uint32) + (tie-type uint32) + ) + ) + + +(deftype generic-tie-stats (structure) + ((num-bps uint32) + (num-ips uint32) + (num-dps uint32) + (num-shaders uint32) + (num-models uint32) + (num-instances uint32) + (num-waits uint32) + (num-qwc uint32) + (max-qwc uint32) + ) + ) + + +(deftype generic-tie-calls (structure) + ((generic-prepare-dma-double basic) + (generic-envmap-dproc basic) + (generic-interp-dproc basic) + (generic-no-light-dproc basic) + ) + :pack-me + ) + + +(deftype generic-tie-shadow (structure) + ((out-buf gsf-buffer) + (cur-buf uint32) + (tie-type int32) + (ptr-inst uint32) + (ptr-buf uint32) + (inst-xor int32) + (end-of-chain uint32) + (write-limit uint32) + (calls generic-tie-calls :inline) + ) + :pack-me + ) + + +(deftype generic-tie-work (structure) + ((control generic-tie-control :inline) + (interp-job generic-interp-job :inline) + (shadow generic-tie-shadow :inline) + (input-a generic-tie-input :inline) + (input-b generic-tie-input :inline) + (inst-buf generic-tie-instance :inline) + (palette-buf rgba 128) + ) + ) diff --git a/goal_src/jakx/engine/gfx/background/tie/tie-h.gc b/goal_src/jakx/engine/gfx/background/tie/tie-h.gc index eaf2c8922e..f7338d500b 100644 --- a/goal_src/jakx/engine/gfx/background/tie/tie-h.gc +++ b/goal_src/jakx/engine/gfx/background/tie/tie-h.gc @@ -7,3 +7,310 @@ ;; DECOMP BEGINS +(deftype tie-fragment-debug (structure) + "Optional debug information about a tie-fragment." + ((num-tris uint16) + (num-dverts uint16) + (debug-lines (array vector-array)) + ) + ) + + +(deftype tie-fragment (drawable) + "A mesh fragment of a TIE. This is a chunk of mesh that is rendered by VU1, stored as DMA chains." + ((gif-ref (inline-array adgif-shader) :overlay-at id) + (point-ref uint32 :offset 8) + (color-index uint16 :offset 12) + (base-colors uint8 :offset 14) + (tex-count uint16 :offset 32) + (gif-count uint16 :offset 34) + (vertex-count uint16 :offset 36) + (color-count uint16) + (dp-ref uint32) + (dp-qwc uint32) + (generic-ref uint32) + (generic-count uint16) + (normal-count uint16) + (normal-ref uint32) + (debug tie-fragment-debug) + ) + ) + + +(deftype instance-tie (instance) + "A TIE model instance." + ((color-indices uint32 :offset 8) + (bucket-ptr prototype-bucket-tie :offset 12) + (max-scale uint16 :overlay-at (-> origin data 3)) + (rmin-scale uint16 :overlay-at (-> origin data 11)) + ) + ) + + +(deftype drawable-inline-array-instance-tie (drawable-inline-array) + "Array of tie instances stored in the level." + ((data instance-tie 1 :inline) + (pad uint32) + ) + ) + +(deftype drawable-tree-instance-tie (drawable-tree) + "Top-level drawable-tree for TIEs" + ((prototypes proxy-prototype-array-tie :offset 8) + ) + ) + + +(deftype prototype-tie (drawable-inline-array) + "Prototype for a TIE: just an array of fragments." + ((data tie-fragment 1 :inline) + (pad uint32) + ) + ) + +(deftype tie-matrix (structure) + "Per-instance matrix for TIE VU1 rendering." + ((mat matrix :inline) + (morph qword :inline) + (fog qword :inline) + (envmap-flag uint32 :overlay-at (-> fog data 0)) + (guard-flag uint32 :overlay-at (-> fog data 1)) + (vertex-alpha float :overlay-at (-> fog data 2)) + (fog-value float :overlay-at (-> fog data 3)) + (fixed-alpha float :overlay-at (-> morph data 1)) + ) + ) + + +(deftype instance-tie-work (structure) + "workspace for TIE instance DMA generation" + ((wind-const vector :inline) + (hmge-d vector :inline) + (hvdf-offset vector :inline) + (wind-force vector :inline) + (constant vector :inline) + (far-morph vector :inline) + (dist-test vector :inline) + (min-dist vector :inline) + (guard-plane plane 4 :inline) + (upload-color-0 dma-packet :inline) + (upload-color-1 dma-packet :inline) + (upload-color-2 dma-packet :inline) + (upload-color-ret dma-packet :inline) + (upload-color-temp dma-packet :inline) + (generic-color-0 dma-packet :inline) + (generic-color-1 dma-packet :inline) + (generic-color-end dma-packet :inline) + (envmap-color-0 dma-packet :inline) + (envmap-color-1 dma-packet :inline) + (tie-scissor-perspective-matrix matrix :inline) + (tod-env-color vector :inline) + (morph-temp vector :inline) + (fog-temp vector :inline) + (fade-temp float) + (wind-vectors uint32) + (test-id uint32) + (test-id2 uint32) + (dma-buffer basic) + (to-spr uint32) + (from-spr uint32) + (wind-work uint32) + (cur-vis-bits uint32) + (end-vis-bits uint32) + (refl-fade-fac float) + (refl-fade-end float) + (flags uint32) + (vanish-flag uint32) + (translucent-flag uint32) + (wait-from-spr uint32) + (wait-to-spr uint32) + (use-etie symbol) + (buffer-start uint32) + (buffer-end uint32) + (tfrag-dists uint32) + (alpha-dists uint32) + (water-dists uint32) + ) + ) + + +(deftype instance-tie-dma (structure) + "Scratchpad memory layout for TIE instance DMA generation." + ((banka instance-tie 32 :inline) + (bankb instance-tie 32 :inline) + (outa uint128 256) + (outb uint128 256) + (work instance-tie-work :dynamic) + ) + ) + + +(deftype prototype-tie-work (structure) + "workspace for TIE protype DMA generation." + ((upload-flushe dma-packet :inline) + (upload-palette dma-packet :inline) + (upload-model-0 dma-packet :inline) + (upload-model-1 dma-packet :inline) + (upload-model-2 dma-packet :inline) + (upload-model-3 dma-packet :inline) + (upload-model-near-0 dma-packet :inline) + (upload-model-near-1 dma-packet :inline) + (upload-model-near-2 dma-packet :inline) + (upload-model-near-3 dma-packet :inline) + (upload-model-near-4 dma-packet :inline) + (envmap-palette dma-packet :inline) + (envmap-shader dma-packet :inline) + (upload-envmap-0 dma-packet :inline) + (upload-envmap-1 dma-packet :inline) + (upload-envmap-2 dma-packet :inline) + (upload-envmap-3 dma-packet :inline) + (upload-envmap-4 dma-packet :inline) + (upload-envmap-scissor-4 dma-packet :inline) + (generic-palette dma-packet :inline) + (generic-model-0 dma-packet :inline) + (generic-model-1 dma-packet :inline) + (generic-model-2 dma-packet :inline) + (model-next dma-packet :inline) + (clamp uint64) + (prototype-array basic) + (wait-from-spr uint32) + (wait-to-spr uint32) + (mood mood-context) + (wide-level-index uint32) + (prototype-tie-work-todo-01 uint32) + (last uint32 16) + (next uint32 16) + (count uint16 16) + (tie-last uint32 :overlay-at (-> last 0)) + (tie-next uint32 :overlay-at (-> next 0)) + (tie-count uint16 :overlay-at (-> count 0)) + (trans-last uint32 :overlay-at (-> last 1)) + (trans-next uint32 :overlay-at (-> next 1)) + (trans-count uint16 :overlay-at (-> count 1)) + (water-last uint32 :overlay-at (-> last 2)) + (water-next uint32 :overlay-at (-> next 2)) + (water-count uint16 :overlay-at (-> count 2)) + (scissor-last uint32 :overlay-at (-> last 3)) + (scissor-next uint32 :overlay-at (-> next 3)) + (scissor-count uint16 :overlay-at (-> count 3)) + (scissor-trans-last uint32 :overlay-at (-> last 4)) + (scissor-trans-next uint32 :overlay-at (-> next 4)) + (scissor-trans-count uint16 :overlay-at (-> count 4)) + (scissor-water-last uint32 :overlay-at (-> last 5)) + (scissor-water-next uint32 :overlay-at (-> next 5)) + (scissor-water-count uint16 :overlay-at (-> count 5)) + (envmap-last uint32 :overlay-at (-> last 6)) + (envmap-next uint32 :overlay-at (-> next 6)) + (envmap-count uint16 :overlay-at (-> count 6)) + (envmap-trans-last uint32 :overlay-at (-> last 7)) + (envmap-trans-next uint32 :overlay-at (-> next 7)) + (envmap-trans-count uint16 :overlay-at (-> count 7)) + (envmap-water-last uint32 :overlay-at (-> last 8)) + (envmap-water-next uint32 :overlay-at (-> next 8)) + (envmap-water-count uint16 :overlay-at (-> count 8)) + (envmap-scissor-last uint32 :overlay-at (-> last 9)) + (envmap-scissor-next uint32 :overlay-at (-> next 9)) + (envmap-scissor-count uint16 :overlay-at (-> count 9)) + (envmap-scissor-trans-last uint32 :overlay-at (-> last 10)) + (envmap-scissor-trans-next uint32 :overlay-at (-> next 10)) + (envmap-scissor-trans-count uint16 :overlay-at (-> count 10)) + (envmap-scissor-water-last uint32 :overlay-at (-> last 11)) + (envmap-scissor-water-next uint32 :overlay-at (-> next 11)) + (envmap-scissor-water-count uint16 :overlay-at (-> count 11)) + (generic-last uint32 :overlay-at (-> last 12)) + (generic-next uint32 :overlay-at (-> next 12)) + (generic-count uint16 :overlay-at (-> count 12)) + (generic-trans-last uint32 :overlay-at (-> last 13)) + (generic-trans-next uint32 :overlay-at (-> next 13)) + (generic-trans-count uint16 :overlay-at (-> count 13)) + (generic-water-last uint32 :overlay-at (-> last 14)) + (generic-water-next uint32 :overlay-at (-> next 14)) + (generic-water-count uint16 :overlay-at (-> count 14)) + (vanish-last uint32 :overlay-at (-> last 15)) + (vanish-next uint32 :overlay-at (-> next 15)) + (vanish-count uint16 :overlay-at (-> count 15)) + ) + ) + + +(deftype prototype-tie-dma (structure) + ((colora rgba 256) + (colorb rgba 256) + (outa uint128 256) + (outb uint128 256) + (geometry uint32 4) + (next uint32 12) + (count uint16 12) + (counts uint32 4) + (palette-ptr uint32 :overlay-at (-> counts 2)) + (model-ptr uint32 :overlay-at (-> counts 3)) + (ret-ptr uint32) + (length uint32) + (flags uint32) + (dma-buffer basic) + (this-frag-count uint32) + (frag-count uint8 4) + (from-spr uint32) + (to-spr uint32) + (spr-out uint32) + (this-count uint32) + (scissor-geometry uint32 :overlay-at (-> geometry 0)) + (near-geometry uint32 :overlay-at (-> geometry 1)) + (mid-geometry uint32 :overlay-at (-> geometry 2)) + (far-geometry uint32 :overlay-at (-> geometry 3)) + (scissor-frag-count uint8 :overlay-at (-> frag-count 0)) + (near-frag-count uint8 :overlay-at (-> frag-count 1)) + (mid-frag-count uint8 :overlay-at (-> frag-count 2)) + (far-frag-count uint8 :overlay-at (-> frag-count 3)) + (tie-scissor-next uint32 :overlay-at (-> next 0)) + (tie-near-next uint32 :overlay-at (-> next 1)) + (tie-mid-next uint32 :overlay-at (-> next 2)) + (tie-far-next uint32 :overlay-at (-> next 3)) + (trans-scissor-next uint32 4 :overlay-at (-> next 0)) + (trans-near-next uint32 :overlay-at (-> next 1)) + (trans-mid-next uint32 :overlay-at (-> next 2)) + (trans-far-next uint32 :overlay-at (-> next 3)) + (water-scissor-next uint32 4 :overlay-at (-> next 0)) + (water-near-next uint32 :overlay-at (-> next 1)) + (water-mid-next uint32 :overlay-at (-> next 2)) + (water-far-next uint32 :overlay-at (-> next 3)) + (envmap-scissor-next uint32 4 :overlay-at (-> next 4)) + (envmap-near-next uint32 :overlay-at (-> next 5)) + (envmap-mid-next uint32 :overlay-at (-> next 6)) + (envmap-far-next uint32 :overlay-at (-> next 7)) + (generic-near-next uint32 :overlay-at (-> next 8)) + (generic-mid-next uint32 :overlay-at (-> next 9)) + (generic-far-next uint32 :overlay-at (-> next 10)) + (vanish-next uint32 :overlay-at (-> next 11)) + (tie-count uint16 :overlay-at (-> count 0)) + (tie-scissor-count uint16 :overlay-at (-> count 0)) + (tie-near-count uint16 :overlay-at (-> count 1)) + (tie-mid-count uint16 :overlay-at (-> count 2)) + (tie-far-count uint16 :overlay-at (-> count 3)) + (trans-count uint16 :overlay-at (-> count 0)) + (trans-scissor-count uint16 :overlay-at (-> count 0)) + (trans-near-count uint16 :overlay-at (-> count 1)) + (trans-mid-count uint16 :overlay-at (-> count 2)) + (trans-far-count uint16 :overlay-at (-> count 3)) + (water-count uint16 :overlay-at (-> count 0)) + (water-scissor-count uint16 :overlay-at (-> count 0)) + (water-near-count uint16 :overlay-at (-> count 1)) + (water-mid-count uint16 :overlay-at (-> count 2)) + (water-far-count uint16 :overlay-at (-> count 3)) + (envmap-count uint16 :overlay-at (-> count 4)) + (envmap-scissor-count uint16 :overlay-at (-> count 4)) + (envmap-near-count uint16 :overlay-at (-> count 5)) + (envmap-mid-count uint16 :overlay-at (-> count 6)) + (envmap-far-count uint16 :overlay-at (-> count 7)) + (generic-count uint16 :overlay-at (-> count 8)) + (generic-near-count uint16 :overlay-at (-> count 8)) + (generic-mid-count uint16 :overlay-at (-> count 9)) + (generic-far-count uint16 :overlay-at (-> count 10)) + (vanish-count uint16 :overlay-at (-> count 11)) + (next-clear uint32 3 :overlay-at (-> next 0)) + (count-clear uint16 3 :overlay-at (-> count 0)) + ) + ) + + +(define *instance-tie-work-copy* (the-as instance-tie-work #f)) diff --git a/goal_src/jakx/engine/gfx/background/wind-h.gc b/goal_src/jakx/engine/gfx/background/wind-h.gc index 09677926c4..d5a720f967 100644 --- a/goal_src/jakx/engine/gfx/background/wind-h.gc +++ b/goal_src/jakx/engine/gfx/background/wind-h.gc @@ -7,3 +7,78 @@ ;; DECOMP BEGINS +(deftype wind-vector (structure) + ((wind-pos vector4w :inline) + (wind-vel vector4w :inline) + (stiffness float :overlay-at (-> wind-vel data 3)) + ) + ) + + +(define *wind-scales* (new 'static 'boxed-array :type uint8 + #x2 + #x5 + #x2 + #x3 + #x2 + #x2 + #x3 + #x10 + #xa + #x2 + #x4 + #x2 + #x8 + #x2 + #x2 + #x10 + #x2 + #x2 + #x8 + #x2 + #x10 + #x2 + #x4 + #x10 + #xa + #x2 + #x4 + #x2 + #x8 + #x2 + #x2 + #x10 + ) + ) + +(deftype wind-work (basic) + ((wind-array vector 64 :inline) + (wind-normal vector :inline) + (wind-temp vector :inline) + (wind-force float 64) + (wind-const vector :inline) + (wind-time uint32) + (wait-to-vu0 uint32) + (wait-to-spr uint32) + (wait-from-spr uint32) + (spr-index uint32) + (count uint32) + (next-count uint32) + (last-count uint32) + (to-spr uint32) + (from-spr uint32) + (next-mem uint32) + (last-mem uint32) + (next-spr uint32) + (last-spr uint32) + (to-ptrs uint32 3) + ) + ) + + +(deftype wind-dma (structure) + ((buffer0 wind-vector 128 :inline) + (buffer1 wind-vector 128 :inline) + (buffer2 wind-vector 128 :inline) + ) + ) diff --git a/goal_src/jakx/engine/gfx/blit-displays-h.gc b/goal_src/jakx/engine/gfx/blit-displays-h.gc index c57a7eee35..693f9b1b3e 100644 --- a/goal_src/jakx/engine/gfx/blit-displays-h.gc +++ b/goal_src/jakx/engine/gfx/blit-displays-h.gc @@ -7,3 +7,56 @@ ;; DECOMP BEGINS +(deftype blit-displays-work (structure) + ((adgif-tmpl dma-gif-packet :inline) + (sprite-tmpl dma-gif-packet :inline) + (contrast-tmpl dma-gif-packet :inline) + (sprite-slow-tmpl dma-gif-packet :inline) + (screen-tmpl dma-gif-packet :inline) + (blur-tmpl dma-gif-packet :inline) + (blur-tmpl2 dma-gif-packet :inline) + (line-tmpl dma-gif-packet :inline) + (scan-tmpl dma-gif-packet :inline) + (color vector4w :inline) + (line-color uint64) + (scan-colors vector4w 15 :inline) + (vu1-enable-user-menu uint64) + (texture-enable-user-menu uint32) + (horizontal-flip-flag symbol) + (scan-alpha float) + (scanline uint32) + (progress-interp float) + (progress-interp-dest float) + (progress-interp-speed float) + ) + (:methods + (blit-displays-work-method-9 () none) + (blit-displays-work-method-10 () none) + (blit-displays-work-method-11 () none) + (blit-displays-work-method-12 () none) + (blit-displays-work-method-13 () none) + (blit-displays-work-method-14 () none) + (blit-displays-work-method-15 () none) + (blit-displays-work-method-16 () none) + (blit-displays-work-method-17 () none) + (blit-displays-work-method-18 () none) + (get-horizontal-flip-flag (_type_) symbol) + (set-horizontal-flip-flag (_type_ symbol) symbol) + (blit-displays-work-method-21 () none) + (blit-displays-work-method-22 () none) + (blit-displays-work-method-23 () none) + (blit-displays-work-method-24 () none) + (blit-displays-work-method-25 () none) + (blit-displays-work-method-26 () none) + ) + ) + + +(defmethod get-horizontal-flip-flag ((this blit-displays-work)) + (-> this horizontal-flip-flag) + ) + +(defmethod set-horizontal-flip-flag ((this blit-displays-work) (arg0 symbol)) + (set! (-> this horizontal-flip-flag) arg0) + arg0 + ) diff --git a/goal_src/jakx/engine/gfx/font-h.gc b/goal_src/jakx/engine/gfx/font-h.gc index 7f9d0651ce..bac23ef8db 100644 --- a/goal_src/jakx/engine/gfx/font-h.gc +++ b/goal_src/jakx/engine/gfx/font-h.gc @@ -5,5 +5,75 @@ ;; name in dgo: font-h ;; dgos: ENGINE, GAME +;; +++font-flags +(defenum font-flags + :type uint16 + :bitfield #t + (shadow 0) + (kerning 1) + (middle 2) + (middle-vert 3) + (right 4) + (large 5) + (pc-hack 6) + (ff7 7) + (ff8 8) + (ff9 9) + ) +;; ---font-flags + + +;; +++font-color +(defenum font-color + :type uint8 + (default 0) + (white 1) + (transparent 2) + (red 3) + (orange 4) + (yellow 5) + (green 6) + (blue 7) + (cyan 8) + (pink 9) + (menu-selected 10) + (menu-selected-parent 11) + (menu 12) + (menu-parent 13) + (menu-func-bad 14) + (menu-flag-on 15) + (menu-flag-on-parent 16) + (menu-flag-off 17) + (menu-flag-off-parent 18) + (menu-invalid 19) + (flat-yellow 20) + (font-color-21 21) + (pad-back 22) + (pad-shine 23) + (pad-square 24) + (pad-circle 25) + (pad-triangle 26) + (pad-x 27) + (progress-old-blue 28) + (progress-old-yellow 29) + (progress-old-selected 30) + (progress-old-percent 31) + (font-color-32 32) + (font-color-33 33) + (font-color-34 34) + (font-color-35 35) + (font-color-36 36) + (font-color-37 37) + (font-color-38 38) + (font-color-39 39) + (font-color-40 40) + (font-color-41 41) + (font-color-42 42) + (font-color-43 43) + (font-color-44 44) + ) +;; ---font-color + + ;; DECOMP BEGINS diff --git a/goal_src/jakx/engine/gfx/foreground/bones-h.gc b/goal_src/jakx/engine/gfx/foreground/bones-h.gc index e4cfb0f9b4..174b17ff00 100644 --- a/goal_src/jakx/engine/gfx/foreground/bones-h.gc +++ b/goal_src/jakx/engine/gfx/foreground/bones-h.gc @@ -5,5 +5,92 @@ ;; name in dgo: bones-h ;; dgos: ENGINE, GAME +;; +++bone-calc-flags +(defenum bone-calc-flags + :type uint16 + :bitfield #t + (write-ripple-data 0) + (no-cam-rot 1) + ) +;; ---bone-calc-flags + + ;; DECOMP BEGINS +(deftype bone-buffer (structure) + ((joint matrix 16 :inline) + (bone bone 16 :inline) + (output pris-mtx 16 :inline) + ) + ) + + +(deftype bone-layout (structure) + ((data uint16 8) + (joint (inline-array matrix) 2 :overlay-at (-> data 0)) + (bone (inline-array bone) 2 :overlay-at (-> data 4)) + (output (inline-array pris-mtx) 2 :offset 16) + (unused uint32 2 :offset 24) + ) + ) + + +(deftype bone-regs (structure) + ((dma-buf dma-buffer) + (wait-count uint32) + (in-count uint32) + (sp-size uint32) + (sp-bufnum uint32) + (joint-ptr (inline-array joint)) + (bone-ptr (inline-array bone)) + (num-bones uint32) + (mtxs (inline-array pris-mtx)) + ) + ) + + +(deftype bone-work (structure) + ((layout bone-layout :inline) + (regs bone-regs :inline) + ) + ) + + +(deftype bone-debug (structure) + ((time-ctr uint32) + (timing uint32 360) + ) + ) + + +(deftype bone-memory (structure) + ((work bone-work :inline) + (buffer bone-buffer 2 :inline) + ) + ) + + +(deftype bone-calculation (structure) + ((flags bone-calc-flags) + (num-bones uint16) + (matrix-area (inline-array pris-mtx)) + (joints (inline-array joint)) + (bones (inline-array bone)) + (ripple-scale float) + (ripple-y-scale float) + (ripple-normal-scale float) + (ripple-area (inline-array vector)) + (ripple-vec vector :inline :overlay-at ripple-scale) + (next bone-calculation) + (dummy-1 uint32) + (dummy-2 uint32) + (dummy-3 uint32) + ) + ) + + +(deftype bone-calculation-list (structure) + ((first bone-calculation) + (next bone-calculation) + ) + ) diff --git a/goal_src/jakx/engine/gfx/foreground/eye-h.gc b/goal_src/jakx/engine/gfx/foreground/eye-h.gc index 74d733c630..ced41b3633 100644 --- a/goal_src/jakx/engine/gfx/foreground/eye-h.gc +++ b/goal_src/jakx/engine/gfx/foreground/eye-h.gc @@ -7,3 +7,72 @@ ;; DECOMP BEGINS +(deftype eye (structure) + "Data for a single eye." + ((data vector 2 :inline) + (x float :overlay-at (-> data 0 data 0)) + (y float :overlay-at (-> data 0 data 1)) + (lid float :overlay-at (-> data 0 data 2)) + (iris-scale float :offset 16) + (pupil-scale float :offset 20) + (lid-scale float :offset 24) + (tbp int32) + (shader-count uint32) + (shader adgif-shader 8) + ) + ) + + +(deftype eye-control (structure) + ((process uint64) + (random-time uint16) + (bucket uint16) + (blink float) + (shaders (inline-array adgif-shader)) + (eyes eye 2 :inline) + (left eye :inline :overlay-at (-> eyes 0)) + (right eye :inline :offset 112) + (level-index int16) + (high-res? symbol) + (level-texture-page uint32) + (art-group-name uint8 67 :offset 201) + ) + ) + + +(deftype eye-control-array (basic) + "An array of [[eye-control]]s." + ((data eye-control 32 :inline) + ) + ) + + +(deftype eye-work (structure) + "Eye renderer DMA data." + ((sprite-tmpl dma-gif-packet :inline) + (sprite-tmpl2 dma-gif-packet :inline) + (adgif-tmpl dma-gif-packet :inline) + (blink-table float 10) + ) + ) + + +(define *eye-control-array* (new 'static 'eye-control-array)) + +(dotimes (v1-5 32) + (let ((a0-11 (-> *eye-control-array* data v1-5))) + (set! (-> a0-11 process) (the-as uint #f)) + (set! (-> a0-11 random-time) (the-as uint 60)) + (set! (-> a0-11 blink) 0.0) + (set! (-> a0-11 shaders) (the-as (inline-array adgif-shader) #f)) + (set! (-> a0-11 level-index) -1) + (set! (-> a0-11 high-res?) #f) + (set! (-> a0-11 art-group-name 3) (the-as uint 0)) + (dotimes (a1-11 2) + (set! (-> a0-11 eyes a1-11 shader-count) (the-as uint 0)) + (dotimes (a2-11 8) + (set! (-> (the-as eye-control (+ (+ (* a2-11 4) (* 80 a1-11)) (the-as int a0-11))) left shader 0) #f) + ) + ) + ) + ) diff --git a/goal_src/jakx/engine/gfx/foreground/foreground-h.gc b/goal_src/jakx/engine/gfx/foreground/foreground-h.gc index b13325eebe..18dbbdbe49 100644 --- a/goal_src/jakx/engine/gfx/foreground/foreground-h.gc +++ b/goal_src/jakx/engine/gfx/foreground/foreground-h.gc @@ -5,5 +5,636 @@ ;; name in dgo: foreground-h ;; dgos: ENGINE, GAME +;; +++merc-mode +(defenum merc-mode + :type int32 + (merc 0) + (emerc 1) + (mercneric 2) + (texture 3) + (mercneric2 4) + (mm5 5) + ) +;; ---merc-mode + ;; DECOMP BEGINS +(deftype mercneric-chain (structure) + "A DMA chain for drawing with mercneric, and metadata needed to append. +This chain is assumed to run with a specific tpage from a specific level available." + ((first uint32) + (next uint32) + (state generic-bucket-state :inline) + (vu1-bucket bucket-id) + ) + :pack-me + ) + + +(deftype merc-chain (structure) + "A DMA chain for drawing with merc. +This chain is assumed to run with a specific tpage from a specific level available." + ((first dma-packet) + (patch dma-packet) + (vu1-bucket bucket-id) + ) + :pack-me + ) + + +(deftype foreground-bucket (structure) + "A foreground bucket is merc, emerc, and mercneric chain for a given texture mode." + ((merc merc-chain :inline) + (emerc merc-chain :inline) + (mercneric mercneric-chain :inline) + ) + ) + + +(deftype foreground-level-buckets (structure) + "Collection of buckets for a single level. +Each bucket has a different texture. The order is: +tfrag, pris, shrub, alpha, water, pris, pris2" + ((data foreground-bucket 10 :inline) + ) + ) + + +(deftype foreground-bucket-grid (structure) + "Array of buckets for each level, plus the single warp chain shared between everybody." + ((level-buckets foreground-level-buckets 19 :inline) + (warp-chain mercneric-chain :inline) + ) + ) + + +(deftype foreground-regs (structure) + "Frequently accessed foreground values. These are in scratchpad for fast access +during foreground processing." + ((dist float) + (merc-used uint32) + (emerc-used uint32) + (mercneric-used uint32) + (use-isometric uint32) + (base-start dma-packet) + (joint-ptr (inline-array joint)) + (bone-ptr (inline-array bone)) + (num-bones uint32) + (mtxs (inline-array pris-mtx)) + (dma-buf dma-buffer) + (default-texture-index uint32) + (mercneric-chain mercneric-chain) + (level-buckets foreground-level-buckets) + ) + ) + + +(deftype foreground-work (structure) + "Memory map for scratchpad during foreground processing. +This is not used by the renderers, bone matrix, or joint code - just the code +that assigns stuff to buckets and prepares DMA for merc (or requests for generic merc)." + ((regs foreground-regs :inline) + (draw-index-map uint8 19 :offset 64) + (grid foreground-bucket-grid :inline) + (bounds sphere :inline) + (lights vu-lights :inline) + (distance vector :inline) + (next-tmpl dma-packet :inline) + ) + ) + + +;; ERROR: Unsupported inline assembly instruction kind - [cache dxwbin a0, 0] +;; ERROR: Unsupported inline assembly instruction kind - [cache dxwbin a0, 1] +(defun invalidate-cache-line ((arg0 pointer)) + ;; og:preserve-this + ; (.sync.l) + ; (.cache dxwbin arg0 0) + ; (.sync.l) + ; (.cache dxwbin arg0 1) + ; (.sync.l) + 0 + ) + +(deftype texscroll-globals (structure) + "List of all merc-effects that need texscroll applied." + ((requests int32) + (effects merc-effect 32) + ) + ) + + +(deftype merc-effect-bucket-info (structure) + "Scratch info computed per-merc-effect by the foreground code, then later read by merc +DMA generation. This is only for the currently-processing merc model's effects." + ((color-fade rgba) + (alpha uint8 :offset 3) + (merc-path uint8) + (ignore-alpha uint8) + (disable-draw uint8) + (disable-envmap uint8) + ) + :pack-me + ) + + +(deftype merc-bucket-info (structure) + "Scratch info for the current merc-ctrl. Written by the foreground code, read by merc DMA generation." + ((light vu-lights :inline) + (needs-clip int32) + (need-mercprime-if-merc int32) + (must-use-mercneric-for-clip int32) + (effect merc-effect-bucket-info 64 :inline) + ) + ) + + +(deftype foreground-globals (structure) + "The foreground renderer state: all DMA chains, settings for the current merc-ctrl, texscroll list." + ((foreground-grid foreground-bucket-grid :inline) + (merc-bucket-info merc-bucket-info :inline) + (texscroll texscroll-globals :inline) + ) + ) + + +(deftype shadow-dma-packet (structure) + "DMA tag for submitting shadow data." + ((tag generic-merc-tag :inline) + (settings shadow-settings :inline) + (geo-ref dma-packet :inline) + (mtx-ref dma-packet :inline) + (end-tag dma-packet :inline) + ) + ) + + +(define *bucket-map* (new 'static 'array bucket-id-16 462 + (bucket-id-16 tfrag-scissor-l0-tfrag) + (bucket-id-16 tie-scissor-l0-tfrag) + (bucket-id-16 etie-scissor-l0-tfrag) + (bucket-id-16 bucket7) + (bucket-id-16 emerc-l0-tfrag) + (bucket-id-16 bucket0) + (bucket-id-16 etie-l1-tfrag) + (bucket-id-16 tfrag-scissor-l1-tfrag) + (bucket-id-16 tie-scissor-l1-tfrag) + (bucket-id-16 bucket7) + (bucket-id-16 merc-l1-tfrag) + (bucket-id-16 bucket6) + (bucket-id-16 merc-l5-water) + (bucket-id-16 gmerc-l5-water) + (bucket-id-16 tfrag-l5-water) + (bucket-id-16 tex-l5-water) + (bucket-id-16 tie-l5-water) + (bucket-id-16 emerc-l4-tfrag) + (bucket-id-16 etie-l5-water) + (bucket-id-16 tie-scissor-l5-water) + (bucket-id-16 tfrag-scissor-l5-water) + (bucket-id-16 tex-l5-water) + (bucket-id-16 etie-scissor-l5-water) + (bucket-id-16 etie-l5-tfrag) + (bucket-id-16 shrub-l2-shrub) + (bucket-id-16 shrub-near-l2-shrub) + (bucket-id-16 billboard-l2-shrub) + (bucket-id-16 shrub-near-trans-l1-shrub) + (bucket-id-16 shrub-vanish-l2-shrub) + (bucket-id-16 tie-l0-tfrag) + (bucket-id-16 tex-l3-shrub) + (bucket-id-16 shrub-l3-shrub) + (bucket-id-16 shrub-near-l3-shrub) + (bucket-id-16 shrub-near-trans-l1-shrub) + (bucket-id-16 billboard-l3-shrub) + (bucket-id-16 emerc-l0-tfrag) + (bucket-id-16 tex-l3-alpha) + (bucket-id-16 tfrag-l3-alpha) + (bucket-id-16 tie-l3-alpha) + (bucket-id-16 tfrag-scissor-l2-alpha) + (bucket-id-16 gmerc-l3-alpha) + (bucket-id-16 tie-l1-tfrag) + (bucket-id-16 gmerc2-l3-alpha) + (bucket-id-16 tex-l4-alpha) + (bucket-id-16 tfrag-l4-alpha) + (bucket-id-16 tfrag-scissor-l2-alpha) + (bucket-id-16 emerc-l4-alpha) + (bucket-id-16 emerc-l1-tfrag) + (bucket-id-16 bucket634) + (bucket-id-16 bucket634) + (bucket-id-16 bucket635) + (bucket-id-16 bucket633) + (bucket-id-16 bucket642) + (bucket-id-16 tex-l7-tfrag) + (bucket-id-16 bucket643) + (bucket-id-16 bucket643) + (bucket-id-16 bucket644) + (bucket-id-16 bucket633) + (bucket-id-16 bucket651) + (bucket-id-16 merc-l7-tfrag) + (bucket-id-16 merc-l5-water) + (bucket-id-16 gmerc-l5-water) + (bucket-id-16 tfrag-l5-water) + (bucket-id-16 tex-l5-water) + (bucket-id-16 tie-l5-water) + (bucket-id-16 emerc-l4-tfrag) + (bucket-id-16 etie-l5-water) + (bucket-id-16 tie-scissor-l5-water) + (bucket-id-16 tfrag-scissor-l5-water) + (bucket-id-16 tex-l5-water) + (bucket-id-16 etie-scissor-l5-water) + (bucket-id-16 etie-l5-tfrag) + (bucket-id-16 debug-no-zbuf1) + (bucket-id-16 tex-hud-hud-alpha) + (bucket-id-16 hud-draw-hud-alpha) + (bucket-id-16 generic-warp) + (bucket-id-16 tex-hud-pris2) + (bucket-id-16 tie-vanish-l5-tfrag) + (bucket-id-16 hud-draw-pris2) + (bucket-id-16 bucket582) + (bucket-id-16 debug) + (bucket-id-16 generic-warp) + (bucket-id-16 debug-no-zbuf2) + (bucket-id-16 tie-scissor-l6-tfrag) + (bucket-id-16 debug-no-zbuf1) + (bucket-id-16 tex-hud-hud-alpha) + (bucket-id-16 hud-draw-hud-alpha) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket768) + (bucket-id-16 tie-l8-tfrag) + (bucket-id-16 hud-draw-pris2) + (bucket-id-16 bucket582) + (bucket-id-16 debug) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket771) + (bucket-id-16 etie-l8-tfrag) + (bucket-id-16 debug-no-zbuf1) + (bucket-id-16 tex-hud-hud-alpha) + (bucket-id-16 hud-draw-hud-alpha) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket770) + (bucket-id-16 tfrag-scissor-l8-tfrag) + (bucket-id-16 hud-draw-pris2) + (bucket-id-16 bucket582) + (bucket-id-16 debug) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket773) + (bucket-id-16 tie-scissor-l8-tfrag) + (bucket-id-16 debug-no-zbuf1) + (bucket-id-16 tex-hud-hud-alpha) + (bucket-id-16 hud-draw-hud-alpha) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 hud-draw-pris2) + (bucket-id-16 bucket582) + (bucket-id-16 debug) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 etie-l2-tfrag) + (bucket-id-16 tfrag-scissor-l2-tfrag) + (bucket-id-16 tie-scissor-l2-tfrag) + (bucket-id-16 emerc-l1-tfrag) + (bucket-id-16 merc-l2-tfrag) + (bucket-id-16 bucket1) + (bucket-id-16 tie-l3-tfrag) + (bucket-id-16 etie-l3-tfrag) + (bucket-id-16 tfrag-scissor-l3-tfrag) + (bucket-id-16 emerc-l1-tfrag) + (bucket-id-16 etie-scissor-l3-tfrag) + (bucket-id-16 bucket7) + (bucket-id-16 tex-l6-water) + (bucket-id-16 merc-l6-water) + (bucket-id-16 gmerc-l6-water) + (bucket-id-16 gmerc2-l5-water) + (bucket-id-16 tfrag-l6-water) + (bucket-id-16 gmerc-l4-tfrag) + (bucket-id-16 tie-l6-water) + (bucket-id-16 etie-l6-water) + (bucket-id-16 tie-scissor-l6-water) + (bucket-id-16 gmerc2-l5-water) + (bucket-id-16 tfrag-scissor-l6-water) + (bucket-id-16 tfrag-scissor-l5-tfrag) + (bucket-id-16 tex-l4-shrub) + (bucket-id-16 shrub-l4-shrub) + (bucket-id-16 shrub-near-l4-shrub) + (bucket-id-16 shrub-vanish-l3-shrub) + (bucket-id-16 billboard-l4-shrub) + (bucket-id-16 etie-l0-tfrag) + (bucket-id-16 gmerc2-l4-shrub) + (bucket-id-16 tex-l5-shrub) + (bucket-id-16 shrub-l5-shrub) + (bucket-id-16 shrub-vanish-l3-shrub) + (bucket-id-16 shrub-near-l5-shrub) + (bucket-id-16 gmerc-l0-tfrag) + (bucket-id-16 gmerc2-l4-alpha) + (bucket-id-16 tex-l5-alpha) + (bucket-id-16 tfrag-l5-alpha) + (bucket-id-16 gmerc-l4-alpha) + (bucket-id-16 emerc-l5-alpha) + (bucket-id-16 etie-l1-tfrag) + (bucket-id-16 etie-scissor-l5-alpha) + (bucket-id-16 gmerc2-l5-alpha) + (bucket-id-16 tex-l6-alpha) + (bucket-id-16 gmerc-l4-alpha) + (bucket-id-16 merc-l6-alpha) + (bucket-id-16 gmerc-l1-tfrag) + (bucket-id-16 bucket653) + (bucket-id-16 bucket653) + (bucket-id-16 bucket654) + (bucket-id-16 bucket652) + (bucket-id-16 bucket661) + (bucket-id-16 tfrag-l7-tfrag) + (bucket-id-16 bucket662) + (bucket-id-16 bucket662) + (bucket-id-16 bucket663) + (bucket-id-16 bucket652) + (bucket-id-16 bucket670) + (bucket-id-16 emerc-l7-tfrag) + (bucket-id-16 tex-l6-water) + (bucket-id-16 merc-l6-water) + (bucket-id-16 gmerc-l6-water) + (bucket-id-16 gmerc2-l5-water) + (bucket-id-16 tfrag-l6-water) + (bucket-id-16 gmerc-l4-tfrag) + (bucket-id-16 tie-l6-water) + (bucket-id-16 etie-l6-water) + (bucket-id-16 tie-scissor-l6-water) + (bucket-id-16 gmerc2-l5-water) + (bucket-id-16 tfrag-scissor-l6-water) + (bucket-id-16 tfrag-scissor-l5-tfrag) + (bucket-id-16 bucket586) + (bucket-id-16 bucket587) + (bucket-id-16 bucket588) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket589) + (bucket-id-16 gmerc2-l5-tfrag) + (bucket-id-16 bucket590) + (bucket-id-16 bucket591) + (bucket-id-16 bucket592) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket593) + (bucket-id-16 etie-scissor-l6-tfrag) + (bucket-id-16 bucket586) + (bucket-id-16 bucket587) + (bucket-id-16 bucket588) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket768) + (bucket-id-16 tie-l8-tfrag) + (bucket-id-16 bucket590) + (bucket-id-16 bucket591) + (bucket-id-16 bucket592) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket771) + (bucket-id-16 etie-l8-tfrag) + (bucket-id-16 bucket586) + (bucket-id-16 bucket587) + (bucket-id-16 bucket588) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket770) + (bucket-id-16 tfrag-scissor-l8-tfrag) + (bucket-id-16 bucket590) + (bucket-id-16 bucket591) + (bucket-id-16 bucket592) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket773) + (bucket-id-16 tie-scissor-l8-tfrag) + (bucket-id-16 bucket586) + (bucket-id-16 bucket587) + (bucket-id-16 bucket588) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 bucket590) + (bucket-id-16 bucket591) + (bucket-id-16 bucket592) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 tie-l4-tfrag) + (bucket-id-16 etie-l4-tfrag) + (bucket-id-16 tfrag-scissor-l4-tfrag) + (bucket-id-16 merc-l3-tfrag) + (bucket-id-16 etie-scissor-l4-tfrag) + (bucket-id-16 bucket2) + (bucket-id-16 tfrag-l5-tfrag) + (bucket-id-16 tie-l5-tfrag) + (bucket-id-16 etie-l5-tfrag) + (bucket-id-16 merc-l3-tfrag) + (bucket-id-16 tie-scissor-l5-tfrag) + (bucket-id-16 hfrag) + (bucket-id-16 gmerc2-l6-water) + (bucket-id-16 tex-l7-water) + (bucket-id-16 merc-l7-water) + (bucket-id-16 etie-scissor-l6-water) + (bucket-id-16 gmerc-l7-water) + (bucket-id-16 tie-vanish-l4-tfrag) + (bucket-id-16 tfrag-l7-water) + (bucket-id-16 tie-l7-water) + (bucket-id-16 etie-l7-water) + (bucket-id-16 etie-scissor-l6-water) + (bucket-id-16 tie-scissor-l7-water) + (bucket-id-16 tie-scissor-l5-tfrag) + (bucket-id-16 gmerc2-l5-shrub) + (bucket-id-16 tex-l6-shrub) + (bucket-id-16 shrub-l6-shrub) + (bucket-id-16 billboard-l5-shrub) + (bucket-id-16 shrub-near-l6-shrub) + (bucket-id-16 tfrag-scissor-l0-tfrag) + (bucket-id-16 gmerc-l6-shrub) + (bucket-id-16 gmerc2-l6-shrub) + (bucket-id-16 tex-l7-shrub) + (bucket-id-16 billboard-l5-shrub) + (bucket-id-16 shrub-l7-shrub) + (bucket-id-16 tie-vanish-l0-tfrag) + (bucket-id-16 etie-scissor-l6-alpha) + (bucket-id-16 gmerc2-l6-alpha) + (bucket-id-16 tex-l7-alpha) + (bucket-id-16 emerc-l6-alpha) + (bucket-id-16 merc-l7-alpha) + (bucket-id-16 tfrag-scissor-l1-tfrag) + (bucket-id-16 tie-scissor-l7-alpha) + (bucket-id-16 etie-scissor-l7-alpha) + (bucket-id-16 gmerc2-l7-alpha) + (bucket-id-16 emerc-l6-alpha) + (bucket-id-16 etie-l8-alpha) + (bucket-id-16 tie-vanish-l1-tfrag) + (bucket-id-16 bucket672) + (bucket-id-16 bucket672) + (bucket-id-16 bucket673) + (bucket-id-16 bucket671) + (bucket-id-16 bucket680) + (bucket-id-16 tie-l7-tfrag) + (bucket-id-16 bucket681) + (bucket-id-16 bucket681) + (bucket-id-16 bucket682) + (bucket-id-16 bucket671) + (bucket-id-16 bucket689) + (bucket-id-16 gmerc-l7-tfrag) + (bucket-id-16 gmerc2-l6-water) + (bucket-id-16 tex-l7-water) + (bucket-id-16 merc-l7-water) + (bucket-id-16 etie-scissor-l6-water) + (bucket-id-16 gmerc-l7-water) + (bucket-id-16 tie-vanish-l4-tfrag) + (bucket-id-16 tfrag-l7-water) + (bucket-id-16 tie-l7-water) + (bucket-id-16 etie-l7-water) + (bucket-id-16 etie-scissor-l6-water) + (bucket-id-16 tie-scissor-l7-water) + (bucket-id-16 tie-scissor-l5-tfrag) + (bucket-id-16 bucket595) + (bucket-id-16 bucket596) + (bucket-id-16 bucket597) + (bucket-id-16 bucket594) + (bucket-id-16 bucket598) + (bucket-id-16 tex-l6-tfrag) + (bucket-id-16 bucket599) + (bucket-id-16 bucket600) + (bucket-id-16 bucket601) + (bucket-id-16 bucket594) + (bucket-id-16 bucket602) + (bucket-id-16 merc-l6-tfrag) + (bucket-id-16 bucket595) + (bucket-id-16 bucket596) + (bucket-id-16 bucket597) + (bucket-id-16 bucket594) + (bucket-id-16 bucket768) + (bucket-id-16 tie-l8-tfrag) + (bucket-id-16 bucket599) + (bucket-id-16 bucket600) + (bucket-id-16 bucket601) + (bucket-id-16 bucket594) + (bucket-id-16 bucket771) + (bucket-id-16 etie-l8-tfrag) + (bucket-id-16 bucket595) + (bucket-id-16 bucket596) + (bucket-id-16 bucket597) + (bucket-id-16 bucket594) + (bucket-id-16 bucket770) + (bucket-id-16 tfrag-scissor-l8-tfrag) + (bucket-id-16 bucket599) + (bucket-id-16 bucket600) + (bucket-id-16 bucket601) + (bucket-id-16 bucket594) + (bucket-id-16 bucket773) + (bucket-id-16 tie-scissor-l8-tfrag) + (bucket-id-16 bucket595) + (bucket-id-16 bucket596) + (bucket-id-16 bucket597) + (bucket-id-16 bucket594) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 bucket599) + (bucket-id-16 bucket600) + (bucket-id-16 bucket601) + (bucket-id-16 bucket594) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 tfrag-l6-tfrag) + (bucket-id-16 tie-l6-tfrag) + (bucket-id-16 etie-l6-tfrag) + (bucket-id-16 etie-scissor-l5-tfrag) + (bucket-id-16 tie-scissor-l6-tfrag) + (bucket-id-16 blit) + (bucket-id-16 tex-l7-tfrag) + (bucket-id-16 tfrag-l7-tfrag) + (bucket-id-16 tie-l7-tfrag) + (bucket-id-16 etie-scissor-l5-tfrag) + (bucket-id-16 tfrag-scissor-l7-tfrag) + (bucket-id-16 hfrag-scissor) + (bucket-id-16 etie-scissor-l7-water) + (bucket-id-16 gmerc2-l7-water) + (bucket-id-16 tex-l8-water) + (bucket-id-16 tfrag-scissor-l7-water) + (bucket-id-16 merc-l8-water) + (bucket-id-16 gmerc2-l4-tfrag) + (bucket-id-16 gmerc-l8-water) + (bucket-id-16 tfrag-l8-water) + (bucket-id-16 tie-l8-water) + (bucket-id-16 tfrag-scissor-l7-water) + (bucket-id-16 etie-l8-water) + (bucket-id-16 etie-scissor-l5-tfrag) + (bucket-id-16 gmerc-l7-shrub) + (bucket-id-16 gmerc2-l7-shrub) + (bucket-id-16 tex-l8-shrub) + (bucket-id-16 shrub-near-l7-shrub) + (bucket-id-16 shrub-l8-shrub) + (bucket-id-16 tie-scissor-l0-tfrag) + (bucket-id-16 emerc-l8-shrub) + (bucket-id-16 gmerc-l8-shrub) + (bucket-id-16 gmerc2-l8-shrub) + (bucket-id-16 shrub-near-l7-shrub) + (bucket-id-16 tex-l9-shrub) + (bucket-id-16 gmerc2-l0-tfrag) + (bucket-id-16 tie-scissor-l8-alpha) + (bucket-id-16 etie-scissor-l8-alpha) + (bucket-id-16 gmerc2-l8-alpha) + (bucket-id-16 merc-l8-alpha) + (bucket-id-16 etie-l9-alpha) + (bucket-id-16 tie-scissor-l1-tfrag) + (bucket-id-16 tfrag-scissor-l9-alpha) + (bucket-id-16 tie-scissor-l9-alpha) + (bucket-id-16 etie-scissor-l9-alpha) + (bucket-id-16 merc-l8-alpha) + (bucket-id-16 emerc-lcom-tfrag) + (bucket-id-16 gmerc2-l1-tfrag) + (bucket-id-16 bucket691) + (bucket-id-16 bucket691) + (bucket-id-16 bucket692) + (bucket-id-16 bucket690) + (bucket-id-16 bucket699) + (bucket-id-16 etie-l7-tfrag) + (bucket-id-16 bucket700) + (bucket-id-16 bucket700) + (bucket-id-16 bucket701) + (bucket-id-16 bucket690) + (bucket-id-16 bucket708) + (bucket-id-16 tie-vanish-l7-tfrag) + (bucket-id-16 etie-scissor-l7-water) + (bucket-id-16 gmerc2-l7-water) + (bucket-id-16 tex-l8-water) + (bucket-id-16 tfrag-scissor-l7-water) + (bucket-id-16 merc-l8-water) + (bucket-id-16 gmerc2-l4-tfrag) + (bucket-id-16 gmerc-l8-water) + (bucket-id-16 tfrag-l8-water) + (bucket-id-16 tie-l8-water) + (bucket-id-16 tfrag-scissor-l7-water) + (bucket-id-16 etie-l8-water) + (bucket-id-16 etie-scissor-l5-tfrag) + (bucket-id-16 bucket604) + (bucket-id-16 bucket605) + (bucket-id-16 bucket606) + (bucket-id-16 bucket603) + (bucket-id-16 bucket607) + (bucket-id-16 tfrag-l6-tfrag) + (bucket-id-16 bucket608) + (bucket-id-16 bucket609) + (bucket-id-16 bucket610) + (bucket-id-16 bucket603) + (bucket-id-16 bucket611) + (bucket-id-16 emerc-l6-tfrag) + (bucket-id-16 bucket604) + (bucket-id-16 bucket605) + (bucket-id-16 bucket606) + (bucket-id-16 bucket603) + (bucket-id-16 bucket768) + (bucket-id-16 tie-l8-tfrag) + (bucket-id-16 bucket608) + (bucket-id-16 bucket609) + (bucket-id-16 bucket610) + (bucket-id-16 bucket603) + (bucket-id-16 bucket771) + (bucket-id-16 etie-l8-tfrag) + (bucket-id-16 bucket604) + (bucket-id-16 bucket605) + (bucket-id-16 bucket606) + (bucket-id-16 bucket603) + (bucket-id-16 bucket770) + (bucket-id-16 tfrag-scissor-l8-tfrag) + ) + ) + +(defun vu1-bucket-map ((arg0 int) (arg1 int) (arg2 int) (arg3 merc-mode)) + (-> *bucket-map* (+ (+ (* 120 arg0) (* 12 arg1) (* 6 arg2)) (the-as int arg3))) + ) diff --git a/goal_src/jakx/engine/gfx/foreground/lights-h.gc b/goal_src/jakx/engine/gfx/foreground/lights-h.gc index c41d0578e5..c1132c8931 100644 --- a/goal_src/jakx/engine/gfx/foreground/lights-h.gc +++ b/goal_src/jakx/engine/gfx/foreground/lights-h.gc @@ -7,3 +7,100 @@ ;; DECOMP BEGINS +(deftype vu-lights (structure) + ((direction vector 3 :inline) + (color vector 3 :inline) + (ambient vector :inline) + (fade-int uint32 :offset 44) + (fade-flags uint32 :offset 28) + ) + ) + + +(deftype light (structure) + "extra: {?, shadow, ?, ?}" + ((direction vector :inline) + (color rgbaf :inline) + (extra vector :inline) + (level float :overlay-at (-> extra data 0)) + (luminance float :overlay-at (-> extra data 2)) + (priority float :overlay-at (-> extra data 3)) + (bytes uint8 4 :overlay-at (-> extra data 1)) + (mask uint16 :overlay-at (-> extra data 1)) + (palette-index int8 :overlay-at (-> bytes 3)) + ) + ) + + +(deftype light-shadow-mask (uint32) + () + ) + +(deftype light-sphere (structure) + ((name string) + (bsphere vector :inline) + (direction vector :inline) + (color vector :inline) + (decay-start float :offset 4) + (ambient-point-ratio float :offset 8) + (brightness float :offset 12) + (bytes uint8 4 :overlay-at (-> color data 3)) + (mask uint16 :overlay-at (-> color data 3)) + (palette-index int8 :overlay-at (-> bytes 3)) + (shadow uint32 :overlay-at (-> direction data 0)) + ) + ) + + +(deftype light-hash-bucket (structure) + ((index uint16) + (count uint16) + ) + :pack-me + ) + + +(deftype light-hash (basic) + ((num-lights uint16) + (num-indices uint16) + (num-buckets uint16) + (bucket-step uint8 2) + (base-trans vector :inline) + (axis-scale vector :inline) + (dimension-array vector4w :inline) + (bucket-array (inline-array light-hash-bucket)) + (index-array pointer) + (light-sphere-array (inline-array light-sphere)) + ) + ) + + +(deftype light-hash-work (structure) + ((ones vector4w :inline) + ) + ) + + +(define *light-hash* (the-as light-hash #f)) + +(defmethod print ((this light)) + (format + #t + "# this extra x) + (-> this direction x) + (-> this direction y) + (-> this direction z) + ) + (format #t "~F ~F ~F @ #x~X>" (-> this color x) (-> this color y) (-> this color z) this) + this + ) + +(deftype light-group (structure) + ((dir0 light :inline) + (dir1 light :inline) + (dir2 light :inline) + (ambi light :inline) + (lights light 4 :inline :overlay-at dir0) + ) + ) diff --git a/goal_src/jakx/engine/gfx/foreground/merc/generic-merc-h.gc b/goal_src/jakx/engine/gfx/foreground/merc/generic-merc-h.gc index a00494fc36..f53d2d38e2 100644 --- a/goal_src/jakx/engine/gfx/foreground/merc/generic-merc-h.gc +++ b/goal_src/jakx/engine/gfx/foreground/merc/generic-merc-h.gc @@ -7,3 +7,108 @@ ;; DECOMP BEGINS +(deftype merc-matrix (structure) + ((quad uint128 8) + (vector vector 8 :inline :overlay-at (-> quad 0)) + (tag uint64 :overlay-at (-> quad 0)) + ) + ) + + +(deftype generic-merc-tag (dma-packet) + ((next-ptr uint32 :overlay-at vif1) + (size uint32 :overlay-at vif0) + ) + ) + + +(deftype generic-merc-ctrl (structure) + ((tag generic-merc-tag :inline) + (lights vu-lights :inline) + (header merc-ctrl-header :inline) + (effect merc-effect :inline) + ) + ) + + +(deftype generic-merc-ctrl-with-sfx (generic-merc-ctrl) + ((sfx-data uint128 11) + ) + ) + + +(deftype generic-merc-input (structure) + ((geo-tag generic-merc-tag :inline) + (geo-block uint8 1296) + (byte-header merc-byte-header :inline :overlay-at (-> geo-block 0)) + (matrix merc-matrix 9 :inline) + (control generic-merc-ctrl-with-sfx :inline) + (end-tag generic-merc-tag :inline) + (shader adgif-shader :inline) + ) + ) + + +(deftype generic-merc-output (structure) + ((info gsf-info :inline) + (header gsf-header :inline) + (index-kick-table uint16 80) + (index-table uint8 160 :overlay-at (-> index-kick-table 0)) + (inverse-table uint8 256) + (vertex-table gsf-vertex 72 :inline) + ) + ) + + +(deftype generic-merc-dcache (structure) + ((output-a generic-merc-output :inline) + (output-b generic-merc-output :inline) + (inv-table-1 uint8 544) + (inv-table-7 uint8 544) + (inv-safety uint8 16) + (effect-data uint8 1584) + ) + ) + + +(deftype gm-shadow (structure) + ((perspective matrix :inline) + (isometric matrix :inline) + (inv-camera-rot matrix :inline) + (envmap-shader adgif-shader :inline) + (current-chain uint32) + (next-chain uint32) + (buf-index uint32) + (fragment-count uint32) + (write-limit int32) + (indexed-input-base generic-merc-input) + (other-input-base generic-merc-input) + (indexed-output-base generic-merc-output) + (other-output-base generic-merc-output) + (p-input uint32) + (gsf-buf generic-merc-dcache) + (p-fheader merc-fp-header) + (curr-chain basic) + (mercneric-convert basic) + (generic-prepare-dma-single basic) + (generic-prepare-dma-double basic) + (generic-light-proc basic) + (generic-envmap-proc basic) + (high-speed-reject basic) + (dummy-0 uint32) + (hsr-xmult vector :inline) + (hsr-ymult vector :inline) + (warp-consts vector :inline) + (warp-nums vector :inline) + ) + ) + + +(deftype generic-merc-work (structure) + ((input-a generic-merc-input :inline) + (input-b generic-merc-input :inline) + (ctrl generic-merc-ctrl-with-sfx :inline) + (shadow gm-shadow :inline) + (stack uint128 16) + ) + ) diff --git a/goal_src/jakx/engine/gfx/foreground/merc/merc-h.gc b/goal_src/jakx/engine/gfx/foreground/merc/merc-h.gc index 8ebf460116..4be1d866b5 100644 --- a/goal_src/jakx/engine/gfx/foreground/merc/merc-h.gc +++ b/goal_src/jakx/engine/gfx/foreground/merc/merc-h.gc @@ -5,5 +5,408 @@ ;; name in dgo: merc-h ;; dgos: ENGINE, GAME +;; +++effect-bits +(defenum effect-bits + :type uint8 + :bitfield #t + (texscroll 0) + (no-fade-out 1) ;; translucent. + (ripple 2) + (emerc 3) ;; envmap?? + (ignore-tod-for-envmap-tint 4) ;; color thing + (force-mercneric 5) ;; some mercneric-only effect + (cross-fade 6) ;; WARP? + (ignore-alpha 7) + ) +;; ---effect-bits + ;; DECOMP BEGINS +(deftype ripple-merc-query (inline-array-class) + "Information about which merc vertices to apply the 'ripple' effect to." + ((start-vertex int32) + (vertex-skip int32) + (vertex-count int32) + (current-loc int32) + (data vector :inline :dynamic) + ) + ) + + +(set! (-> ripple-merc-query heap-base) (the-as uint 16)) + +(deftype merc-byte-header (structure) + "Header for a single [[merc-fragment]] uploaded to the VU." + ((srcdest-off uint8) + (rgba-off uint8) + (lump-off uint8) + (fp-off uint8) + (mat1-cnt uint8) + (mat2-cnt uint8) + (mat3-cnt uint8) + (samecopy-cnt uint8) + (crosscopy-cnt uint8) + (strip-len uint8) + (mm-quadword-fp-off uint8) + (mm-quadword-size uint8) + (perc-off uint8) + (mat-slot uint8 10) + ) + ) + + +(deftype merc-fragment (structure) + "A single merc fragment that fits into VU memory." + ((header merc-byte-header :inline) + (rest uint8 1) + ) + (:methods + (login-adgifs (_type_) merc-fragment) + ) + ) + + +(deftype merc-vtx (structure) + "A packed merc vertex." + ((mat-0 uint8) + (mat-1 uint8) + (nrm-x uint8) + (pos-x uint8) + (dst-0 uint8) + (dst-1 uint8) + (nrm-y uint8) + (pos-y uint8) + (tex-s uint8) + (tex-t uint8) + (nrm-z uint8) + (pos-z uint8) + ) + ) + + +(deftype merc-fp-header (structure) + "Merc header for a [[merc-fragment]]'s floating point data." + ((x-add float) + (y-add float) + (z-add float) + (shader-cnt uint8) + (kick-info-offset uint8) + (kick-info-step uint8) + (hword-cnt uint8) + ) + ) + + +;; WARN: Return type mismatch int vs merc-fp-header. +(defun merc-fragment-fp-data ((frag merc-fragment)) + "Get the floating point data of a [[merc-fragment]]." + (the-as merc-fp-header (+ (the-as uint frag) (* (-> frag header mm-quadword-fp-off) 16))) + ) + +(deftype merc-mat-dest (structure) + "Metadata for a merc matrix upload." + ((matrix-number uint8) + (matrix-dest uint8) + ) + :pack-me + ) + + +(deftype merc-fragment-control (structure) + "Data about a [[merc-fragment]] needed for merc DMA generation." + ((unsigned-four-count uint8) + (lump-four-count uint8) + (fp-qwc uint8) + (mat-xfer-count uint8) + (mat-dest-data merc-mat-dest :inline :dynamic) + ) + ) + + +(deftype merc-blend-data (structure) + "Packed BLERC data." + ((int8-data int8 :dynamic) + ) + ) + + +(deftype merc-blend-ctrl (structure) + "Information about the vertices of a model modified by BLERC." + ((blend-vtx-count uint8) + (nonzero-index-count uint8) + (bt-index uint8 :dynamic) + ) + ) + + +(deftype mei-envmap-tint (structure) + "Data for the extra 'envmap tint' effect." + ((fade0 float) + (fade1 float) + (tint rgba) + (dummy int32) + ) + ) + + +(deftype mei-texture-scroll (structure) + "Data for the extra 'texscroll' effect." + ((max-dist float) + (st-int-scale uint8) + (time-factor uint8) + (scroll-dir uint8) + (cached-time uint8) + (time-delta uint8) + (dummy uint8 7) + ) + ) + + +(deftype mei-ripple (structure) + "Data for the extra 'ripple' effect." + ((x-base float) + (z-base float) + (grid-size float) + (angle float) + ) + ) + + +(deftype merc-extra-info (structure) + "Info for merc extra effects." + ((envmap-tint-offset uint8) + (shader-offset uint8) + (texture-scroll-offset uint8) + (ripple-offset uint8) + (dummy uint8 12) + ) + ) + + +(deftype merc-effect (structure) + "A collection of [[merc-fragment]]s with data for any extra effects." + ((frag-geo merc-fragment) + (frag-ctrl merc-fragment-control) + (blend-data merc-blend-data) + (blend-ctrl merc-blend-ctrl) + (merc-effect-version uint8) + (effect-bits effect-bits) + (frag-count uint16) + (blend-frag-count uint16) + (tri-count uint16) + (dvert-count uint16) + (texture-index uint8) + (effect-usage uint8) + (extra-info merc-extra-info) + ) + (:methods + (login-adgifs (_type_) none) + ) + ) + + +(deftype merc-eye-ctrl (structure) + "Eye info for both eyes of a merc model." + ((eye-slot int8) + (shader-offset int8) + (shader-count int8) + (eye-ctrl-index int8) + (shader adgif-shader 6 :inline) + (left-iris-shader adgif-shader :inline :overlay-at (-> shader 0)) + (left-pupil-shader adgif-shader :inline :overlay-at (-> shader 1)) + (left-lid-shader adgif-shader :inline :overlay-at (-> shader 2)) + (right-iris-shader adgif-shader :inline :overlay-at (-> shader 3)) + (right-pupil-shader adgif-shader :inline :overlay-at (-> shader 4)) + (right-lid-shader adgif-shader :inline :overlay-at (-> shader 5)) + ) + ) + + +(deftype merc-eye-anim-frame (structure) + "A single frame of a merc eye animation." + ((pupil-trans-x int8) + (pupil-trans-y int8) + (blink int8) + (iris-scale int8 :offset 4) + (pupil-scale int8 :offset 5) + (lid-scale int8 :offset 6) + (dword uint64 :overlay-at pupil-trans-x) + ) + :pack-me + ) + + +(deftype merc-eye-anim-block (structure) + "A list of eye animation frames." + ((max-frame int16) + (data merc-eye-anim-frame :inline :dynamic) + ) + ) + + +(deftype texture-usage-group (structure) + ((data texture-masks 7 :inline) + ) + ) + + +(deftype merc-ctrl-header (structure) + "The header for a [[merc-ctrl]], +containing metadata about the model used for drawing." + ((xyz-scale float) + (st-magic uint32) + (st-out-a uint32) + (st-out-b uint32) + (st-vif-add uint32) + (st-int-off uint16) + (st-int-scale uint16) + (effect-count uint32) + (blend-target-count uint32) + (fragment-count uint16) + (tri-count uint16) + (matrix-count uint8) + (shader-count uint8) + (transform-vertex-count uint16) + (dvert-count uint16) + (one-mat-count uint16) + (two-mat-count uint16) + (two-mat-reuse-count uint16) + (three-mat-count uint16) + (three-mat-reuse-count uint16) + (shader-upload-count uint8) + (matrix-upload-count uint8) + (same-copy-count uint16) + (cross-copy-count uint16) + (num-verts uint16) + (longest-edge float) + (eye-ctrl merc-eye-ctrl) + (pad uint32 3) + (masks-padding texture-masks :inline) + (texture-usage-group texture-usage-group :overlay-at (-> masks-padding data 0 mask data 0)) + (dummy-bytes uint8 :dynamic :overlay-at fragment-count) + (envmap-tint uint32 :overlay-at fragment-count) + (query basic :overlay-at matrix-count) + (needs-clip uint8 :overlay-at dvert-count) + (use-isometric uint8 :offset 41) + (use-attached-shader uint8 :overlay-at one-mat-count) + (display-triangles uint8 :offset 43) + (death-vertex-skip uint16 :overlay-at two-mat-count) + (death-start-vertex uint16 :overlay-at two-mat-reuse-count) + (death-effect uint32 :overlay-at three-mat-count) + (use-translucent uint8 :overlay-at shader-upload-count) + (display-this-fragment uint8 :overlay-at matrix-upload-count) + (use-warp uint8 :overlay-at same-copy-count) + (ignore-alpha uint8 :offset 55) + (force-fade uint8 :overlay-at cross-copy-count) + (disable-fog uint8 :offset 57) + (disable-envmap uint8 :overlay-at num-verts) + ) + ) + + +(deftype merc-ctrl (art-element) + "The merc data for a single model as it's stored in an art group. +Consists of a header and a list of [[merc-effect]]s." + ((num-joints int32 :overlay-at length) + (seg-table (array uint64) :overlay-at (-> pad 0)) + (header merc-ctrl-header :inline) + (effect merc-effect :inline :dynamic) + ) + ) + + +(deftype merc-vu1-low-mem (structure) + ((tri-strip-gif gs-gif-tag :inline) + (ad-gif gs-gif-tag :inline) + (hvdf-offset vector :inline) + (perspective uint128 4) + (fog vector :inline) + ) + ) + + +(deftype emerc-vu1-low-mem (structure) + ((tri-strip-gif gs-gif-tag :inline) + (ad-gif gs-gif-tag :inline) + (hvdf-offset vector :inline) + (perspective vector 4 :inline) + (fog vector :inline) + (unperspect vector :inline) + ) + ) + + +(deftype texture-login-data (structure) + ((default-texture-index int32) + (current-texture-index int32) + (texture-usage-group texture-usage-group) + (merc-ctrl-header merc-ctrl-header) + (name basic) + ) + ) + + +(deftype ripple-wave (structure) + ((scale float) + (offs float) + (xdiv int16) + (zdiv int16) + (speed float) + (xmul float) + (zmul float) + (delta float) + ) + :pack-me + ) + + +(deftype ripple-wave-set (basic) + ((count int32) + (converted basic) + (normal-scale float) + (wave ripple-wave 4 :inline) + (frame-save uint64) + ) + ) + + +(deftype ripple-control (basic) + ((global-scale float) + (last-frame-scale float) + (close-fade-dist float) + (far-fade-dist float) + (faded-scale float) + (individual-normal-scale float) + (waveform ripple-wave-set) + (send-query symbol) + (query ripple-merc-query) + ) + (:methods + (new (symbol type) _type_) + ) + ) + + +(defmethod new ripple-control ((allocation symbol) (type-to-make type)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 global-scale) 0.0) + (set! (-> v0-0 last-frame-scale) -0.001) + (set! (-> v0-0 close-fade-dist) 4096000000.0) + (set! (-> v0-0 far-fade-dist) 8192000000.0) + (set! (-> v0-0 faded-scale) -0.001) + (set! (-> v0-0 waveform) #f) + (set! (-> v0-0 individual-normal-scale) 1.0) + (set! (-> v0-0 send-query) #f) + (set! (-> v0-0 query) #f) + v0-0 + ) + ) + +(deftype death-info (basic) + ((vertex-skip uint16) + (timer uint8) + (overlap uint8) + (effect uint32) + (sound string) + ) + ) diff --git a/goal_src/jakx/engine/gfx/foreground/shadow-cpu-h.gc b/goal_src/jakx/engine/gfx/foreground/shadow-cpu-h.gc index 94925e6168..7403a842d7 100644 --- a/goal_src/jakx/engine/gfx/foreground/shadow-cpu-h.gc +++ b/goal_src/jakx/engine/gfx/foreground/shadow-cpu-h.gc @@ -5,5 +5,249 @@ ;; name in dgo: shadow-cpu-h ;; dgos: ENGINE, GAME +;; +++shadow-flags +(defenum shadow-flags + :bitfield #t + :type int32 + (shdf00) ;; unused + (disable-fade) + (shdf02) ;; only set, never used. + (shdf03) + (shdf04) ;; unused + (disable-draw) + (shdf06) + (shdf07) + (shdf08) + ) +;; ---shadow-flags + +(declare-type shadow-vu1-constants structure) +(define-extern shadow-execute-all (function dma-buffer none)) + ;; DECOMP BEGINS +(deftype shadow-settings (structure) + "Settings used to draw a shadow." + ((center vector :inline) + (flags shadow-flags :overlay-at (-> center data 3)) + (shadow-dir vector :inline) + (dist-to-locus float :overlay-at (-> shadow-dir data 3)) + (bot-plane plane :inline) + (top-plane plane :inline) + (fade-vec vector :inline :offset 64) + (fade-dist float :overlay-at (-> fade-vec x)) + (fade-start float :overlay-at (-> fade-vec y)) + (dummy-2 int32 :overlay-at (-> fade-vec z)) + (shadow-type int32 :overlay-at (-> fade-vec w)) + ) + ) + + +(deftype shadow-control (basic) + ((settings shadow-settings :inline) + ) + (:methods + (new (symbol type float float float vector shadow-flags float) _type_) + (enable-draw (shadow-control) int) + (disable-draw (shadow-control) int) + (set-top-plane-offset (shadow-control float) int) + (set-bottom-plane-offset (shadow-control float) int) + (probe-line-for-shadow (_type_ vector float float float) none) + (shadow-control-method-14 (_type_ vector vector float float float) none) + ) + ) + + +(defmethod enable-draw ((this shadow-control)) + (logclear! (-> this settings flags) (shadow-flags disable-draw)) + 0 + ) + +(defmethod disable-draw ((this shadow-control)) + (logior! (-> this settings flags) (shadow-flags disable-draw)) + 0 + ) + +(defmethod set-bottom-plane-offset ((this shadow-control) (arg0 float)) + (set! (-> this settings bot-plane w) (- arg0)) + 0 + ) + +(defmethod set-top-plane-offset ((this shadow-control) (arg0 float)) + (set! (-> this settings top-plane w) (- arg0)) + 0 + ) + +(deftype shadow-data (structure) + "DMA data for the shadow renderer." + ((dma-unpack-template dma-packet :inline) + (dma-cnt dma-tag) + (vif-nop vif-tag) + (vif-unpack-v4-8 vif-tag) + (pdc basic) + (dist float) + (waits uint32) + (inside-volume? uint32) + ) + ) + + +(deftype shadow-work (structure) + ((shadow-data shadow-data :inline) + (inbuf uint128 600) + ) + ) + + +(deftype shadow-bucket (structure) + ((first pointer) + (next pointer) + (bucket-id bucket-id) + (shadow-color rgba) + (constants shadow-vu1-constants) + ) + :allow-misaligned + ) + + +(deftype shadow-bucket-views (structure) + ((data shadow-bucket 2 :inline) + ) + :allow-misaligned + ) + + +(deftype shadow-globals (structure) + ((num-buckets uint32) + (cur-bucket uint32) + (data shadow-bucket-views 3 :inline) + ) + ) + + +(define *shadow-globals* (new 'global 'shadow-globals)) + +(set! (-> *shadow-globals* data 0 data 0 bucket-id) (bucket-id emerc-lcom-pris)) + +(set! (-> *shadow-globals* data 0 data 1 bucket-id) (bucket-id gmerc-lcom-pris)) + +(set! (-> *shadow-globals* data 1 data 0 bucket-id) (bucket-id bucket774)) + +(set! (-> *shadow-globals* data 1 data 1 bucket-id) (bucket-id bucket775)) + +(set! (-> *shadow-globals* data 2 data 0 bucket-id) (bucket-id bucket776)) + +(set! (-> *shadow-globals* data 2 data 1 bucket-id) (bucket-id bucket777)) + +(deftype shadow-vertex (structure) + ((x float) + (y float) + (z float) + (weight float) + ) + ) + + +(deftype shadow-matrix-ref (structure) + ((joint-0 uint8) + (joint-1 uint8) + ) + ) + + +(deftype shadow-edge (structure) + ((ind-0 uint8) + (ind-1 uint8) + (tri-0 uint8) + (tri-1 uint8) + ) + ) + +;; ERROR: failed type prop at 14: Could not figure out load: (set! a2 (l.hu gp)) + +(deftype shadow-tri (structure) + ((ind-0 uint8) + (ind-1 uint8) + (ind-2 uint8) + (faces uint8) + ) + ) + + +;; og:preserve-this +;; (deftype shadow-edge (structure) +;; ((ind-0 uint8) +;; (ind-1 uint8) +;; (tri-0 uint8) +;; (tri-1 uint8) +;; ) +;; ) + + +(deftype shadow-frag-header (structure) + ((qwc-data uint32) + (num-joints uint32) + (num-verts uint16) + (num-twos uint16) + (num-single-tris uint16) + (num-single-edges uint16) + (num-double-tris uint16) + (num-double-edges uint16) + (ofs-verts uint32) + (ofs-refs uint32) + (ofs-single-tris uint32) + (ofs-single-edges uint32) + (ofs-double-tris uint32) + (ofs-double-edges uint32) + ) + ) + + +(deftype shadow-frag-ref (structure) + ((header shadow-frag-header) + (qwc uint32) + ) + :pack-me + ) + + +(deftype shadow-geo (art-element) + "The low poly model used for drawing the shadow." + ((version uint32 :overlay-at (-> pad 0)) + (total-size uint32 :overlay-at (-> pad 4)) + (total-qwc uint32) + (num-joints uint32) + (num-fragments uint32) + (frags shadow-frag-ref :inline :dynamic) + ) + ) + + +(defmethod new shadow-control ((allocation symbol) + (type-to-make type) + (arg0 float) + (arg1 float) + (arg2 float) + (arg3 vector) + (arg4 shadow-flags) + (arg5 float) + ) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (if arg3 + (set! (-> v0-0 settings center quad) (-> arg3 quad)) + ) + (set! (-> v0-0 settings flags) arg4) + (set-vector! (-> v0-0 settings shadow-dir) 0.0 -1.0 0.0 arg2) + (set-vector! (-> v0-0 settings bot-plane) 0.0 1.0 0.0 (- arg0)) + (set-vector! (-> v0-0 settings top-plane) 0.0 1.0 0.0 (- arg1)) + (set! (-> v0-0 settings fade-dist) arg5) + (set! (-> v0-0 settings shadow-type) 0) + v0-0 + ) + ) + +(define *shadow* #f) + +(define *shadow-object* #f) + +(define *shadow-debug* #f) diff --git a/goal_src/jakx/engine/gfx/foreground/shadow-vu1-h.gc b/goal_src/jakx/engine/gfx/foreground/shadow-vu1-h.gc index e68445c684..4b55b0e552 100644 --- a/goal_src/jakx/engine/gfx/foreground/shadow-vu1-h.gc +++ b/goal_src/jakx/engine/gfx/foreground/shadow-vu1-h.gc @@ -6,4 +6,3 @@ ;; dgos: ENGINE, GAME ;; DECOMP BEGINS - diff --git a/goal_src/jakx/engine/gfx/generic/generic-h.gc b/goal_src/jakx/engine/gfx/generic/generic-h.gc index 907be6dcd0..372513c8f1 100644 --- a/goal_src/jakx/engine/gfx/generic/generic-h.gc +++ b/goal_src/jakx/engine/gfx/generic/generic-h.gc @@ -7,3 +7,202 @@ ;; DECOMP BEGINS +(deftype gsf-vertex (structure) + "Vertex used by generic. GSF = generic stripped fragment?" + ((data uint32 8) + (byte uint8 32 :overlay-at (-> data 0)) + (quad uint128 2 :overlay-at (-> data 0)) + (vt qword :inline :overlay-at (-> data 0)) + (pos vector3s :inline :overlay-at (-> data 0)) + (tex vector2uh :inline :overlay-at (-> data 3)) + (nrm vector3s :inline :overlay-at (-> data 4)) + (nc qword :inline :overlay-at (-> data 4)) + (clr vector4ub :inline :overlay-at (-> data 7)) + (dtex vector2uh :inline :overlay-at (-> data 4)) + (dclr vector4ub :inline :overlay-at (-> data 5)) + ) + ) + + +(deftype gsf-vertex-array (structure) + ((vtx gsf-vertex :dynamic) + ) + ) + + +(deftype gsf-fx-vertex (structure) + "Color/texture data only. Possibly used to share with a gsf-vertex with +the same position/normal." + ((clr vector4ub :inline) + (tex vector2uh :inline) + ) + ) + + +(deftype gsf-fx-vertex-array (structure) + ((data gsf-fx-vertex :dynamic) + ) + ) + + +(deftype gsf-header (structure) + "Header for generic data." + ((num-strips uint8) + (num-new-vtxs uint8) + (num-dps uint16) + (num-vtxs uint16) + (strip-table uint8 10) + ) + ) + + +(deftype gsf-ik (structure) + ((index uint8) + (no-kick uint8) + ) + ) + + +(deftype gsf-info (structure) + ((ptr-iks uint32) + (ptr-verts uint32) + (ptr-fx uint32) + (dummy2 uint32) + ) + ) + + +(deftype gsf-buffer (structure) + ((data uint8 8192) + (info gsf-info :inline :overlay-at (-> data 0)) + (header gsf-header :inline :overlay-at (-> data 16)) + (work-area uint8 :dynamic :overlay-at (-> data 32)) + ) + ) + + +(deftype generic-frag (structure) + ((start-pos uint16) + (end-pos uint16) + ) + ) + + +(deftype generic-strip (structure) + ((pos uint16) + (len uint16) + ) + ) + + +(deftype generic-envmap-saves (structure) + ((index-mask vector4w :inline) + (verts uint128 12) + (kicks uint128 4) + ) + ) + + +(deftype generic-interp-job (structure) + ((job-type uint16) + (num uint16) + (first uint16) + (pad uint16) + (ptr-data uint32) + (morph-z uint16) + (morph-w uint16) + ) + :pack-me + ) + + +(deftype generic-saves (structure) + ((ptr-dma uint32) + (ptr-vtxs uint32) + (ptr-clrs uint32) + (ptr-texs uint32) + (ptr-env-clrs uint32) + (ptr-env-texs uint32) + (cur-outbuf uint32) + (ptr-fx-buf uint32) + (xor-outbufs uint32) + (num-dps uint32) + (qwc uint32) + (gsf-buf gsf-buffer) + (ptr-shaders uint32) + (ptr-env-shader uint32) + (is-envmap uint16) + (is-translucent uint16) + (basep uint32) + (ptr-interp-job generic-interp-job) + (gifbuf-adr uint32) + (inbuf-adr uint32) + (fade-val uint32) + (time-of-day-color rgba) + (to-vu0-waits uint32) + (to-spr-waits uint32) + (from-spr-waits uint32) + (envmap generic-envmap-saves :inline) + ) + ) + + +(deftype generic-gif-tag (structure) + ((data uint32 4) + (qword qword :inline :overlay-at (-> data 0)) + (fan-prim gif-tag-prim :overlay-at (-> data 0)) + (str-prim gif-tag-prim :overlay-at (-> data 1)) + (regs gif-tag-regs-32 :overlay-at (-> data 2)) + (num-strips uint32 :overlay-at (-> data 3)) + ) + ) + + +(deftype generic-envmap-consts (structure) + ((consts vector :inline) + (strgif generic-gif-tag :inline) + (colors vector4w :inline) + (shader adgif-shader :inline) + ) + ) + + +(deftype generic-consts (structure) + ((dma-header dma-packet :inline) + (vif-header uint32 4) + (dma-ref-vtxs dma-packet :inline) + (dma-cnt-call dma-packet :inline) + (matrix matrix :inline) + (base-strgif generic-gif-tag :inline) + (alpha-opaque gs-adcmd :inline) + (alpha-translucent gs-adcmd :inline) + (ztest-normal gs-adcmd :inline) + (ztest-opaque gs-adcmd :inline) + (adcmd-offsets uint8 16) + (stcycle-tag uint32) + (unpack-vtx-tag uint32) + (unpack-clr-tag uint32) + (unpack-tex-tag uint32) + (mscal-tag uint32) + (flush-tag uint32) + (reset-cycle-tag uint32) + (dummy0 uint32) + (dma-tag-cnt uint64) + (envmap generic-envmap-consts :inline) + (light-consts vector :inline) + (texture-offset uint16 8) + ) + ) + + +(deftype generic-storage (structure) + ((data uint128 16) + ) + ) + + +(kmemopen global "gsf-buffer") + +(define *gsf-buffer* (the-as object (kmalloc global 9216 (kmalloc-flags align-64) "malloc"))) + +(kmemclose) diff --git a/goal_src/jakx/engine/gfx/generic/generic-vu1-h.gc b/goal_src/jakx/engine/gfx/generic/generic-vu1-h.gc index 7ba4ffa3c5..fb76e46054 100644 --- a/goal_src/jakx/engine/gfx/generic/generic-vu1-h.gc +++ b/goal_src/jakx/engine/gfx/generic/generic-vu1-h.gc @@ -7,3 +7,72 @@ ;; DECOMP BEGINS +(deftype pris-mtx (structure) + "Matrix for merc rendering. Named after the earlier 'pris' renderer. +Contains a transformation matrix for vertices, one for normals, and a scale. +This matrix is likely not used by generic VU1, but is used by the merc -> generic converter." + ((data float 32) + (vector vector 8 :overlay-at (-> data 0)) + (t-mtx matrix :inline :overlay-at (-> data 0)) + (n-mtx matrix3 :inline :overlay-at (-> data 16)) + (scale vector :inline :overlay-at (-> data 28)) + ) + ) + + +(deftype generic-pris-mtx-save (structure) + ((loc-mtx pris-mtx :inline) + (par-mtx pris-mtx :inline) + (dif-mtx pris-mtx :inline) + ) + ) + + +(deftype generic-constants (structure) + "Constant data sent to VU1 for generic rendering." + ((fog vector :inline) + (adgif gs-gif-tag :inline) + (hvdf-offset vector :inline) + (hmge-scale vector :inline) + (invh-scale vector :inline) + (guard vector :inline) + (flush qword :inline) + (stores qword :inline) + ) + ) + + +(deftype generic-shrub-constants (structure) + ((shrub-giftag generic-gif-tag :inline) + (shrub-adnop qword :inline) + ) + ) + + +(deftype gcf-shader (structure) + ((adgif uint128 5) + (shader adgif-shader :inline :overlay-at (-> adgif 0)) + (pos uint32 :offset 12) + (num uint32 :offset 28) + ) + ) + + +(deftype gcf-control (structure) + ((matrix matrix :inline) + (giftag generic-gif-tag :inline) + (adnops gs-adcmd 2 :inline) + (num-strips uint32 :overlay-at (-> giftag data 3)) + (num-dps uint32 :overlay-at (-> adnops 0 word 3)) + (kick-offset uint32 :offset 108) + (shader gcf-shader :inline :dynamic) + ) + ) + + +(deftype gcf-vertex (structure) + ((tex vector4w :inline) + (clr gs-packed-rgba :inline) + (pos gs-packed-xyzw :inline) + ) + ) diff --git a/goal_src/jakx/engine/gfx/generic/generic-work-h.gc b/goal_src/jakx/engine/gfx/generic/generic-work-h.gc index 7cc98fb439..7e7f4cca82 100644 --- a/goal_src/jakx/engine/gfx/generic/generic-work-h.gc +++ b/goal_src/jakx/engine/gfx/generic/generic-work-h.gc @@ -7,3 +7,78 @@ ;; DECOMP BEGINS +(deftype generic-input-buffer (structure) + ((data uint128 473) + (merc generic-merc-work :inline :overlay-at (-> data 0)) + (tie generic-tie-work :inline :overlay-at (-> data 0)) + ) + ) + + +(deftype generic-debug (structure) + ((locks uint32 4) + (timer uint32 32) + (count uint32 32) + (vps uint32 32) + (buffer int32) + (start-addr int32) + (lock int32) + ) + ) + + +(deftype generic-vu1-header (structure) + ((matrix matrix :inline) + (strgif generic-gif-tag :inline) + (adcmds gs-adcmd 2 :inline) + (adnop1 gs-adcmd :inline :overlay-at (-> adcmds 0)) + (adnop2 gs-adcmd :inline :overlay-at (-> adcmds 1)) + (dps uint16 :overlay-at (-> adcmds 0 word 3)) + (kickoff uint16 :overlay-at (-> adnop2 w)) + (strips uint16 :overlay-at (-> strgif data 3)) + ) + ) + + +(deftype generic-vu1-texbuf (structure) + ((header generic-vu1-header :inline) + (shader uint32 :dynamic) + ) + ) + + +(deftype generic-texbuf (structure) + ((tag dma-packet :inline) + (header generic-vu1-header :inline) + (shader uint32 :dynamic) + ) + ) + + +(deftype generic-effect-work (structure) + ((consts generic-consts :inline) + (storage generic-storage :inline) + (storage2 generic-storage :inline) + (lights vu-lights :inline) + ) + ) + + +(deftype generic-effect-buffer (structure) + ((outbuf-0 uint8 3552) + (work generic-effect-work :inline) + (outbuf-1 uint8 3552) + ) + ) + + +(deftype generic-work (structure) + ((saves generic-saves :inline) + (storage generic-storage :inline) + (in-buf generic-input-buffer :inline) + (fx-buf generic-effect-buffer :inline) + ) + ) + + +(define *generic-debug* (new 'global 'generic-debug)) diff --git a/goal_src/jakx/engine/gfx/generic/lightning/lightning-h.gc b/goal_src/jakx/engine/gfx/generic/lightning/lightning-h.gc index 4478b7a9b0..71bbac8f6c 100644 --- a/goal_src/jakx/engine/gfx/generic/lightning/lightning-h.gc +++ b/goal_src/jakx/engine/gfx/generic/lightning/lightning-h.gc @@ -5,5 +5,266 @@ ;; name in dgo: lightning-h ;; dgos: ENGINE, GAME +;; +++lightning-spec-flags +(defenum lightning-spec-flags + :type uint16 + :bitfield #t + (lsf0 0) + (lsf1 1) + (lsf2 2) + (lsf3 3) + (lsf4 4) + (lsf5 5) + (lsf6 6) + (lsf7 7) + (lsf8 8) + (lsf9 9) + (lsf10 10) + (lsf11 11) + (lsf12 12) + (lsf13 13) + (lsf14 14) + (lsf15 15) + ) +;; ---lightning-spec-flags + +;; +++lightning-mode +(defenum lightning-mode + :type uint8 + (lm-1 -1) + (lm0 0) + (lm1 1) + (lm2 2) + (lm3 3) + ) +;; ---lightning-mode + +(declare-type lightning-spec basic) +(define-extern *lightning-spec-id-table* (array lightning-spec)) + +(define-extern lightning-fractal-gen (function (inline-array vector) int int float lightning-spec none)) +(define-extern lightning-uniform-gen (function (inline-array vector) int int float lightning-spec none)) +(define-extern lightning-trail-uniform-gen (function (inline-array vector) (inline-array vector) float int symbol)) +(define-extern lightning-trail-fractal-gen (function (inline-array vector) (inline-array vector) int int float lightning-spec none)) +(define-extern process-drawable-art-error (state string process-drawable)) +(define-extern unlink-lightning-spec-by-heap (function kheap none)) +(define-extern lightning-draw-all (function none)) + ;; DECOMP BEGINS +(deftype lightning-spec (basic) + ((name string) + (flags lightning-spec-flags) + (rand-func uint8) + (adjust-distance uint8) + (start-color rgba) + (end-color rgba) + (fade-to-color rgba) + (fade-start-factor float) + (fade-time float) + (texture texture-id) + (reduction float) + (num-points int32) + (box-size float) + (merge-factor float) + (merge-count int32) + (radius float) + (duration float) + (duration-rand float) + (sound sound-spec) + (delay float) + (delay-rand float) + ) + ) + + +(defun lookup-lightning-spec-by-name ((arg0 string)) + (let* ((s5-0 *lightning-spec-id-table*) + (s4-0 (-> s5-0 length)) + ) + (dotimes (s3-0 s4-0) + (let ((s2-0 (-> s5-0 s3-0))) + (if (and (nonzero? s2-0) (string= arg0 (-> s2-0 name))) + (return s2-0) + ) + ) + ) + ) + (the-as lightning-spec #f) + ) + +(deftype lightning-state (structure) + ((mode uint8) + (counter float) + (points-to-draw int32) + (box-size float) + (gcf-control gcf-control :inline) + (line vector-array) + (meet vector-array) + (path vector-array) + (start-color rgba) + (end-color rgba) + ) + ) + + +(deftype lightning-control (basic) + ((spec lightning-spec) + (process (pointer process)) + (state lightning-state :inline) + ) + (:methods + (new (symbol type lightning-spec process float) _type_) + (change-mode (_type_ lightning-mode) lightning-mode) + (get-mode (_type_) lightning-mode) + (set-point! (_type_ int vector) none) + (set-first-meet-point (_type_ vector) none) + (set-last-meet-point (_type_ vector) none) + ) + ) + + +(defmethod change-mode ((this lightning-control) (arg0 lightning-mode)) + (let ((v1-1 (!= arg0 (-> this state mode)))) + (case arg0 + (((lightning-mode lm3)) + (if v1-1 + (set! (-> this state counter) 0.0) + ) + ) + (((lightning-mode lm1)) + (set! (-> this state start-color) (-> this spec start-color)) + (set! (-> this state end-color) (-> this spec end-color)) + ) + ) + ) + (set! (-> this state mode) (the-as uint arg0)) + arg0 + ) + +;; WARN: Return type mismatch uint vs lightning-mode. +(defmethod get-mode ((this lightning-control)) + (the-as lightning-mode (-> this state mode)) + ) + +(defmethod set-point! ((this lightning-control) (arg0 int) (arg1 vector)) + (let ((v1-0 (-> this state))) + (when (and (-> v1-0 path) (>= arg0 0) (< arg0 (-> v1-0 path length))) + (set! (-> v1-0 path data arg0 quad) (-> arg1 quad)) + (when (and (< (+ (-> v1-0 points-to-draw) -1) arg0) (case (-> v1-0 mode) + ((2 3) + #t + ) + (else + #f + ) + ) + ) + (set! (-> v1-0 line data arg0 quad) (-> arg1 quad)) + (set! (-> v1-0 meet data arg0 quad) (-> arg1 quad)) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch (inline-array vector) vs none. +(defmethod set-first-meet-point ((this lightning-control) (arg0 vector)) + (set! (-> this state meet data 0 quad) (-> arg0 quad)) + (none) + ) + +;; WARN: Return type mismatch vector vs none. +(defmethod set-last-meet-point ((this lightning-control) (arg0 vector)) + (set! (-> this state meet data (+ (-> this state points-to-draw) -1) quad) (-> arg0 quad)) + (none) + ) + +(defmethod relocate ((this lightning-control) (offset int)) + (&+! (-> this state line) offset) + (&+! (-> this state meet) offset) + (if (-> this state path) + (&+! (-> this state path) offset) + ) + (let ((v1-8 (-> this spec))) + (if (and (>= (the-as int v1-8) (-> *kernel-context* relocating-min)) + (< (the-as int v1-8) (-> *kernel-context* relocating-max)) + ) + (&+! (-> this spec) offset) + ) + ) + this + ) + +;; WARN: Return type mismatch object vs lightning-control. +(defmethod new lightning-control ((allocation symbol) (type-to-make type) (arg0 lightning-spec) (arg1 process) (arg2 float)) + (with-pp + (let ((gp-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (when (zero? (the-as lightning-control gp-0)) + (go process-drawable-art-error "memory") + (set! gp-0 0) + (goto cfg-14) + ) + (let ((s3-0 (-> arg0 num-points))) + (let ((f0-0 (-> arg0 box-size))) + (when (logtest? (-> arg0 flags) (lightning-spec-flags lsf4)) + (let ((f1-1 (fmax 1.0 (fmin 5.0 (/ arg2 (* 4096.0 (the float (-> arg0 adjust-distance)))))))) + (set! s3-0 (* s3-0 (the int f1-1))) + (set! f0-0 (* f0-0 f1-1)) + ) + ) + (set! (-> (the-as lightning-control gp-0) state box-size) f0-0) + ) + (set! (-> (the-as lightning-control gp-0) process) (process->ppointer arg1)) + (set! (-> (the-as lightning-control gp-0) state mode) (the-as uint 1)) + (set! (-> (the-as lightning-control gp-0) state line) + ((method-of-type vector-array new) allocation vector-array s3-0) + ) + (set! (-> (the-as lightning-control gp-0) state meet) + ((method-of-type vector-array new) allocation vector-array s3-0) + ) + (let ((v1-18 (-> arg0 rand-func))) + (set! (-> (the-as lightning-control gp-0) state path) + (if (or (= v1-18 2) (= v1-18 3)) + ((method-of-type vector-array new) allocation vector-array s3-0) + (the-as vector-array #f) + ) + ) + ) + (set! (-> (the-as lightning-control gp-0) state counter) 0.0) + (set! (-> (the-as lightning-control gp-0) state points-to-draw) s3-0) + ) + (set! (-> (the-as lightning-control gp-0) spec) arg0) + (set! (-> (the-as lightning-control gp-0) state start-color) (-> arg0 start-color)) + (set! (-> (the-as lightning-control gp-0) state end-color) (-> arg0 end-color)) + (add-connection *lightning-engine* pp nothing (the-as lightning-control gp-0) #f #f) + (label cfg-14) + (the-as lightning-control gp-0) + ) + ) + ) + +(deftype lightning-probe-vars (basic) + ((src-joint-index uint32) + (next-spawn-time time-frame) + (last-valid-time time-frame) + (point vector 2 :inline) + (start-pos vector :inline :overlay-at (-> point 0)) + (end-pos vector :inline :overlay-at (-> point 1)) + (probe-dirs (inline-array vector)) + ) + ) + + +(define *lightning-probe-vars* (new 'static 'lightning-probe-vars + :probe-dirs (new 'static 'inline-array vector 6 + (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 1.0 1.0)) + (new 'static 'vector :data (new 'static 'array float 4 1.0 0.0 0.0 1.0)) + (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 -1.0 1.0)) + (new 'static 'vector :data (new 'static 'array float 4 -1.0 0.0 0.0 1.0)) + (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0)) + (new 'static 'vector :data (new 'static 'array float 4 0.0 -1.0 0.0 1.0)) + ) + ) + ) diff --git a/goal_src/jakx/engine/gfx/hw/display-h.gc b/goal_src/jakx/engine/gfx/hw/display-h.gc index b4c47f1002..b349fb3e91 100644 --- a/goal_src/jakx/engine/gfx/hw/display-h.gc +++ b/goal_src/jakx/engine/gfx/hw/display-h.gc @@ -5,5 +5,125 @@ ;; name in dgo: display-h ;; dgos: ENGINE, GAME +(declare-type display basic) +(define-extern set-display (function display display)) + +(define-extern *display* display) + +(defmacro current-frame () + `(-> *display* frames (-> *display* on-screen)) + ) + +(defmacro integral-current-time () + `(-> *display* integral-frame-counter) + ) + +(defmacro real-current-time () + `(-> *display* real-frame-counter) + ) + +;; debug stuff really +(defmacro get-screen-x (frac) + `(the int (* ,frac 512))) + +(defmacro get-screen-y (frac) + `(the int (* ,frac 416))) + ;; DECOMP BEGINS +(deftype display-frame (basic) + ((buffer dma-buffer 11) + (calc-buf dma-buffer :overlay-at (-> buffer 1)) + (vu1-buf dma-buffer :overlay-at (-> buffer 1)) + (debug-buf dma-buffer :overlay-at (-> buffer 8)) + (global-buf dma-buffer :overlay-at (-> buffer 9)) + (bucket-group (inline-array dma-bucket) :overlay-at (-> buffer 10)) + (profile-array profile-array :inline :offset 48) + (start-time uint64 :offset 56) + (run-time uint64 :offset 64) + ) + (:methods + (new (symbol type) _type_) + ) + ) + + +(defmethod new display-frame ((allocation symbol) (type-to-make type)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> gp-0 calc-buf) (the-as dma-buffer 0)) + (set! (-> gp-0 global-buf) (the-as dma-buffer 0)) + (set! (-> gp-0 debug-buf) (the-as dma-buffer 0)) + (when *debug-segment* + (set! (-> gp-0 profile-array data 0) (new 'debug 'profile-segment-array)) + (set! (-> gp-0 profile-array data 1) (new 'debug 'profile-segment-array)) + ) + gp-0 + ) + ) + +(deftype display (basic) + ((on-screen int32) + (last-screen int32) + (frames display-frame 2) + (bgcolor uint64) + (pmode uint64) + (clock clock 22) + (session-clock clock :overlay-at (-> clock 0)) + (game-clock clock :overlay-at (-> clock 1)) + (base-clock clock :overlay-at (-> clock 2)) + (real-clock clock :overlay-at (-> clock 3)) + (frame-clock clock :overlay-at (-> clock 4)) + (real-frame-clock clock :overlay-at (-> clock 5)) + (target-clock clock :overlay-at (-> clock 6)) + (entity-clock clock :overlay-at (-> clock 7)) + (part-clock clock :overlay-at (-> clock 8)) + (bg-clock clock :overlay-at (-> clock 9)) + (camera-clock clock :overlay-at (-> clock 10)) + (total-game-clock clock :overlay-at (-> clock 11)) + (user0-clock clock :overlay-at (-> clock 12)) + (user1-clock clock :overlay-at (-> clock 13)) + (user2-clock clock :overlay-at (-> clock 14)) + (user3-clock clock :overlay-at (-> clock 15)) + (user4-clock clock :overlay-at (-> clock 16)) + (user5-clock clock :overlay-at (-> clock 17)) + (user6-clock clock :overlay-at (-> clock 18)) + (user7-clock clock :overlay-at (-> clock 19)) + (user8-clock clock :overlay-at (-> clock 20)) + (user9-clock clock :overlay-at (-> clock 21)) + (time-factor float) + (dog-ratio float) + (vblank-start-time int64 2) + (total-run-time uint64) + (run-half-speed symbol) + (vu1-enable-user uint64) + (vu1-enable-user-menu uint64) + (force-sync uint32) + (mem-reserve-size uint32) + (dma-buffer-overflow symbol) + (default-end-buffer basic) + (init-buffer-zbuf-on basic) + (init-buffer-zbuf-off basic) + ) + (:methods + (new (symbol type int int int int int) _type_) + (set-time-ratios (_type_ float) float) + ) + ) + + +(defmethod new display ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 int)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set-display gp-0) + (set! (-> gp-0 frames 0) (new 'global 'display-frame)) + (set! (-> gp-0 frames 1) (new 'global 'display-frame)) + (set! (-> gp-0 pmode) (the-as uint 165)) + (set! (-> gp-0 run-half-speed) #f) + (set! (-> gp-0 vu1-enable-user-menu) (the-as uint #x5fffffff8)) + (set! (-> gp-0 vu1-enable-user) (the-as uint #x5fffffff8)) + gp-0 + ) + ) + +(define *pre-draw-hook* (the-as (function object none) nothing)) + +(define *post-draw-hook* (the-as (function dma-buffer none) nothing)) diff --git a/goal_src/jakx/engine/gfx/hw/gs.gc b/goal_src/jakx/engine/gfx/hw/gs.gc index da9a248cfc..e40e3ac6f9 100644 --- a/goal_src/jakx/engine/gfx/hw/gs.gc +++ b/goal_src/jakx/engine/gfx/hw/gs.gc @@ -5,5 +5,904 @@ ;; name in dgo: gs ;; dgos: ENGINE, GAME +;; +++gs-psm +(defenum gs-psm + :bitfield #f + :type uint8 + (ct32 0) + (ct24 1) + (ct16 2) + (ct16s 10) + (mt8 19) + (mt4 20) + (mt8h 27) + (mt4hl 36) + (mt4hh 44) + (mz32 48) + (mz24 49) + (mz16 50) + (mz16s 58) + ) +;; ---gs-psm + + +;; +++gs-reg +(defenum gs-reg + :type uint8 + (prim 0) + (rgbaq 1) + (st 2) + (uv 3) + (xyzf2 4) + (xyz2 5) + (tex0-1 6) + (tex0-2 7) + (clamp-1 8) + (clamp-2 9) + (fog 10) + (xyzf3 12) + (xyz3 13) + (tex1-1 20) + (tex1-2 21) + (tex2-1 22) + (tex2-2 23) + (xyoffset-1 24) + (xyoffset-2 25) + (prmodecont 26) + (prmode 27) + (texclut 28) + (scanmsk 34) + (miptbp1-1 52) + (miptbp1-2 53) + (miptbp2-1 54) + (miptbp2-2 55) + (texa 59) + (fogcol 61) + (texflush 63) + (scissor-1 64) + (scissor-2 65) + (alpha-1 66) + (alpha-2 67) + (dimx 68) + (dthe 69) + (colclamp 70) + (test-1 71) + (test-2 72) + (pabe 73) + (fba-1 74) + (fba-2 75) + (frame-1 76) + (frame-2 77) + (zbuf-1 78) + (zbuf-2 79) + (bitbltbuf 80) + (trxpos 81) + (trxreg 82) + (trxdir 83) + (hwreg 84) + (signal 96) + (finish 97) + (label 98) + (hack 127) + ) +;; ---gs-reg + + +;; +++gs-reg64 +(defenum gs-reg64 + :type uint64 + :copy-entries gs-reg + ) +;; ---gs-reg64 + + +;; +++gs-reg32 +(defenum gs-reg32 + :type uint32 + :copy-entries gs-reg + ) +;; ---gs-reg32 + + +;; +++gs-prim-type +(defenum gs-prim-type + :type uint8 + (point 0) + (line 1) + (line-strip 2) + (tri 3) + (tri-strip 4) + (tri-fan 5) + (sprite 6) + ) +;; ---gs-prim-type + + +;; +++gs-atest +(defenum gs-atest + :type uint8 + (never 0) + (always 1) + (less 2) + (less-equal 3) + (equal 4) + (greater-equal 5) + (greater 6) + (not-equal 7) + ) +;; ---gs-atest + + +;; +++gs-ztest +(defenum gs-ztest + :type uint8 + (never 0) + (always 1) + (greater-equal 2) + (greater 3) + ) +;; ---gs-ztest + + +;; +++gs-tex-wrap-mode +(defenum gs-tex-wrap-mode + :type uint8 + (repeat 0) + (clamp 1) + (region-clamp 2) + (region-repeat 3) + ) +;; ---gs-tex-wrap-mode + + +;; +++gif-flag +(defenum gif-flag + :type uint8 + (packed 0) + (reg-list 1) + (image 2) + (disable 3) + ) +;; ---gif-flag + + +;; +++gif-reg-id +(defenum gif-reg-id + :type uint8 + (prim 0) + (rgbaq 1) + (st 2) + (uv 3) + (xyzf2 4) + (xyz2 5) + (tex0-1 6) + (tex0-2 7) + (clamp-1 8) + (clamp-2 9) + (fog 10) + (xyzf3 12) + (xyz3 13) + (a+d 14) + (nop 15) + ) +;; ---gif-reg-id + +(defconstant GIF_REGS_ALL_AD + (new 'static 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id a+d) + :regs2 (gif-reg-id a+d) + :regs3 (gif-reg-id a+d) + :regs4 (gif-reg-id a+d) + :regs5 (gif-reg-id a+d) + :regs6 (gif-reg-id a+d) + :regs7 (gif-reg-id a+d) + :regs8 (gif-reg-id a+d) + :regs9 (gif-reg-id a+d) + :regs10 (gif-reg-id a+d) + :regs11 (gif-reg-id a+d) + :regs12 (gif-reg-id a+d) + :regs13 (gif-reg-id a+d) + :regs14 (gif-reg-id a+d) + :regs15 (gif-reg-id a+d) + ) + ) + +;; +++gif-tag-regs +(deftype gif-tag-regs (uint64) + ((regs0 gif-reg-id :offset 0 :size 4) + (regs1 gif-reg-id :offset 4 :size 4) + (regs2 gif-reg-id :offset 8 :size 4) + (regs3 gif-reg-id :offset 12 :size 4) + (regs4 gif-reg-id :offset 16 :size 4) + (regs5 gif-reg-id :offset 20 :size 4) + (regs6 gif-reg-id :offset 24 :size 4) + (regs7 gif-reg-id :offset 28 :size 4) + (regs8 gif-reg-id :offset 32 :size 4) + (regs9 gif-reg-id :offset 36 :size 4) + (regs10 gif-reg-id :offset 40 :size 4) + (regs11 gif-reg-id :offset 44 :size 4) + (regs12 gif-reg-id :offset 48 :size 4) + (regs13 gif-reg-id :offset 52 :size 4) + (regs14 gif-reg-id :offset 56 :size 4) + (regs15 gif-reg-id :offset 60 :size 4) + ) + ) +;; ---gif-tag-regs + +;; +++gif-tag-regs-32 +(deftype gif-tag-regs-32 (uint32) + ((regs0 gif-reg-id :offset 0 :size 4) + (regs1 gif-reg-id :offset 4 :size 4) + (regs2 gif-reg-id :offset 8 :size 4) + (regs3 gif-reg-id :offset 12 :size 4) + (regs4 gif-reg-id :offset 16 :size 4) + (regs5 gif-reg-id :offset 20 :size 4) + (regs6 gif-reg-id :offset 24 :size 4) + (regs7 gif-reg-id :offset 28 :size 4) + ) + ) +;; ---gif-tag-regs-32 + +;; we unfortunately kind of need this +(defmacro gif-tag->static-array (tag regs) + "Allocates a new static array of two uint64's making up the gif-tag and the tag registers" + + `(new 'static 'array uint64 2 ,tag ,regs) + ) + +(defmacro gif-prim (prim-type) + `(new 'static 'gs-prim :prim (gs-prim-type ,prim-type) :iip 1 :abe 1) + ) + +(defmacro gs-reg-list (&rest reg-ids) + "Generate a giftag register descriptor list from reg-ids." + + (let ((reg-count (length reg-ids))) + (when (> (length reg-ids) 16) + (ferror "too many regs passed to gs-reg-list") + ) + (let ((list-to-splice '()) + (cur-lst reg-ids) + (i -1)) + + ;; this is questionable. + (while (and (not (null? cur-lst)) (< i 15)) + (push! list-to-splice (cons 'gif-reg-id (cons (car cur-lst) '()))) + (push! list-to-splice (string->symbol-format ":regs{}" (inc! i))) + (pop! cur-lst) + ) + + `(new 'static 'gif-tag-regs + ,@list-to-splice + ) + ) + #| ;; the opengoal compiler does not have enough constant propagation for this for now + (let ((i -1)) + + `(the-as gif-tag-regs (logior ,@(apply (lambda (x) + `(shl (the-as uint (gif-reg-id ,x)) ,(* 4 (inc! i))) + ) reg-ids) + )) + + )|# + ) + ) + ;; DECOMP BEGINS +(deftype gs-pmode (uint64) + ((en1 uint8 :offset 0 :size 1) + (en2 uint8 :offset 1 :size 1) + (crtmd uint8 :offset 2 :size 3) + (mmod uint8 :offset 5 :size 1) + (amod uint8 :offset 6 :size 1) + (slbg uint8 :offset 7 :size 1) + (alp uint8 :offset 8 :size 8) + ) + ) + +(deftype gs-smode2 (uint64) + ((int uint8 :offset 0 :size 1) + (ffmd uint8 :offset 1 :size 1) + (dpms uint8 :offset 2 :size 2) + ) + ) + +(defun psm-size ((arg0 gs-psm)) + (cond + ((= arg0 (gs-psm mt8)) + 64 + ) + ((= arg0 (gs-psm mt4)) + 32 + ) + ((or (= arg0 (gs-psm ct16)) (= arg0 (gs-psm ct16s)) (= arg0 (gs-psm mz16)) (= arg0 (gs-psm mz16s))) + 128 + ) + (else + 256 + ) + ) + ) + +(defun psm-page-height ((arg0 gs-psm)) + (cond + ((= arg0 (gs-psm mt8)) + 64 + ) + ((= arg0 (gs-psm mt4)) + 128 + ) + ((or (= arg0 (gs-psm ct16)) (= arg0 (gs-psm ct16s)) (= arg0 (gs-psm mz16)) (= arg0 (gs-psm mz16s))) + 64 + ) + (else + 32 + ) + ) + ) + +(defun psm->string ((arg0 gs-psm)) + (case arg0 + (((gs-psm ct24)) + "ct24" + ) + (((gs-psm mt4)) + "mt4" + ) + (((gs-psm ct32)) + "ct32" + ) + (((gs-psm mz16s)) + "mz16s" + ) + (((gs-psm ct16s)) + "ct16s" + ) + (((gs-psm mt8)) + "mt8" + ) + (((gs-psm mt8h)) + "mt8h" + ) + (((gs-psm mz16)) + "mz16" + ) + (((gs-psm mz24)) + "mz24" + ) + (((gs-psm mt4hh)) + "mt4hh" + ) + (((gs-psm ct16)) + "ct16" + ) + (((gs-psm mt4hl)) + "mt4hl" + ) + (((gs-psm mz32)) + "mz32" + ) + (else + "*unknown*" + ) + ) + ) + +(deftype gs-display-fb (uint64) + ((fbp uint16 :offset 0 :size 9) + (fbw uint8 :offset 9 :size 6) + (psm gs-psm :offset 15 :size 5) + (dbx uint16 :offset 32 :size 11) + (dby uint16 :offset 43 :size 11) + ) + ) + +(deftype gs-display (uint64) + "the GS's DISPLAY registers make settings for the display position on the screen regarding +information on Rectangular Area Read Output Circuit n for the PCRTC. +write-only" + ((dx uint16 :offset 0 :size 12) + (dy uint16 :offset 12 :size 11) + (magh uint8 :offset 23 :size 4) + (magv uint8 :offset 27 :size 2) + (dw uint16 :offset 32 :size 12) + (dh uint16 :offset 44 :size 11) + ) + ) + +(deftype gs-bgcolor (uint64) + "The GS's BGCOLOR register sets the background color of the PCRTC with RGB value. +write-only" + ((r uint8 :offset 0 :size 8) + (g uint8 :offset 8 :size 8) + (b uint8 :offset 16 :size 8) + ) + ) + +(deftype gs-csr (uint64) + "The GS's CSR register sets and obtains various GS statuses. +read-write. The fields have different effects depending on whether they're being read from +or written to. + +Bits 5 and 6 (0x20 and 0x40) should be zero." + ((signal uint8 :offset 0 :size 1) + (finish uint8 :offset 1 :size 1) + (hsint uint8 :offset 2 :size 1) + (vsint uint8 :offset 3 :size 1) + (edwint uint8 :offset 4 :size 1) + (flush uint8 :offset 8 :size 1) + (reset uint8 :offset 9 :size 1) + (nfield uint8 :offset 12 :size 1) + (field uint8 :offset 13 :size 1) + (fifo uint8 :offset 14 :size 2) + (rev uint8 :offset 16 :size 8) + (id uint8 :offset 24 :size 8) + ) + ) + +(deftype gs-bank (structure) + "Memory layout of the GS's privileged registers (mapped to EE memory). +It is missing the SIGLBLID/LABELID register at 4224 (useless anyway?)" + ((pmode gs-pmode) + (smode2 gs-smode2 :offset 32) + (dspfb1 gs-display-fb :offset 112) + (display1 gs-display :offset 128) + (dspfb2 gs-display-fb :offset 144) + (display2 gs-display :offset 160) + (extbuf uint64 :offset 176) + (extdata uint64 :offset 192) + (extwrite uint64 :offset 208) + (bgcolor gs-bgcolor :offset 224) + (csr gs-csr :offset 4096) + (imr uint64 :offset 4112) + (busdir uint64 :offset 4160) + ) + ) + + +;; type gs-frame is defined here, but it is unknown to the decompiler + +;; type gs-zbuf is defined here, but it is unknown to the decompiler + +;; type gs-xy-offset is defined here, but it is unknown to the decompiler + +;; type gs-scissor is defined here, but it is unknown to the decompiler + +;; type gs-prmode-cont is defined here, but it is unknown to the decompiler + +;; type gs-color-clamp is defined here, but it is unknown to the decompiler + +;; type gs-dthe is defined here, but it is unknown to the decompiler + +(deftype gs-test (uint64) + "The GS's TEST register performs settings related to the pixel test." + ((ate uint8 :offset 0 :size 1) + (atst gs-atest :offset 1 :size 3) + (aref uint8 :offset 4 :size 8) + (afail uint8 :offset 12 :size 2) + (date uint8 :offset 14 :size 1) + (datm uint8 :offset 15 :size 1) + (zte uint8 :offset 16 :size 1) + (ztst gs-ztest :offset 17 :size 2) + ) + ) + +(deftype gs-prim (uint64) + ((prim gs-prim-type :offset 0 :size 3) + (iip uint8 :offset 3 :size 1) + (tme uint8 :offset 4 :size 1) + (fge uint8 :offset 5 :size 1) + (abe uint8 :offset 6 :size 1) + (aa1 uint8 :offset 7 :size 1) + (fst uint8 :offset 8 :size 1) + (ctxt uint8 :offset 9 :size 1) + (fix uint8 :offset 10 :size 1) + ) + ) + +;; type gs-rgbaq is defined here, but it is unknown to the decompiler + +;; type gs-xyz is defined here, but it is unknown to the decompiler + +;; type gs-uv is defined here, but it is unknown to the decompiler + +;; type gs-st is defined here, but it is unknown to the decompiler + +;; type gs-xyzf is defined here, but it is unknown to the decompiler + +(deftype gs-adcmd (structure) + ((word uint32 4) + (quad uint128 :overlay-at (-> word 0)) + (data uint64 :overlay-at (-> word 0)) + (cmds gs-reg64 :overlay-at (-> word 2)) + (cmd uint8 :overlay-at (-> word 2)) + (x uint32 :overlay-at (-> word 0)) + (y uint32 :overlay-at (-> word 1)) + (z uint32 :overlay-at (-> word 2)) + (w uint32 :overlay-at (-> word 3)) + ) + ) + + +(deftype gs-trxpos (uint64) + "The GS's TRXPOS register specifies the position and +scanning direction of the rectangular area +in each buffer where buffer transmission is performed." + ((ssax uint16 :offset 0 :size 11) + (ssay uint16 :offset 16 :size 11) + (dsax uint16 :offset 32 :size 11) + (dsay uint16 :offset 48 :size 11) + (dir uint8 :offset 59 :size 2) + ) + ) + +(deftype gs-trxreg (uint64) + "The GS's TRXREG register specifies the size of the rectangular area, where the transmission +between buffers is implemented, in units of pixels. +The pixel mode must be the one set by the BITBLTBUF register." + ((rrw uint16 :offset 0 :size 12) + (rrh uint16 :offset 32 :size 12) + ) + ) + +(deftype gs-trxdir (uint64) + "The GS's TRXDIR register specifies the transmission direction in the transmission between +buffers, and activates transmission. +Appropriate settings must be made by the BITBLTBUF/TRXPOS/TRXREG before activating +the transmission." + ((xdir uint8 :offset 0 :size 2) + ) + ) + +(deftype gs-bitbltbuf (uint64) + "The GS's BITBLTBUF register stores buffer-related settings for transmission source and +destination during transmission between buffers." + ((sbp uint16 :offset 0 :size 14) + (sbw uint8 :offset 16 :size 6) + (spsm uint8 :offset 24 :size 6) + (dbp uint16 :offset 32 :size 14) + (dbw uint8 :offset 48 :size 6) + (dpsm gs-psm :offset 56 :size 6) + ) + ) + +(deftype gs-tex0 (uint64) + "The GS's TEX0 registers set various kinds of information regarding the textures to be used." + ((tbp0 uint16 :offset 0 :size 14) + (tbw uint8 :offset 14 :size 6) + (psm uint8 :offset 20 :size 6) + (tw uint8 :offset 26 :size 4) + (th uint8 :offset 30 :size 4) + (tcc uint8 :offset 34 :size 1) + (tfx uint8 :offset 35 :size 2) + (cbp uint16 :offset 37 :size 14) + (cpsm uint8 :offset 51 :size 4) + (csm uint8 :offset 55 :size 1) + (csa uint8 :offset 56 :size 5) + (cld uint8 :offset 61 :size 3) + ) + ) + +(deftype gs-tex1 (uint64) + "The GS's TEX1 registers set information on the sampling method of the textures." + ((lcm uint8 :offset 0 :size 1) + (mxl uint8 :offset 2 :size 3) + (mmag uint8 :offset 5 :size 1) + (mmin uint8 :offset 6 :size 3) + (mtba uint8 :offset 9 :size 1) + (l uint8 :offset 19 :size 2) + (k int16 :offset 32 :size 12) + ) + ) + +(deftype gs-texa (uint64) + "The GS's TEXA register sets the Alpha value to be referred to when the Alpha value of the +texture is not an 8-bit value." + ((ta0 uint8 :offset 0 :size 8) + (aem uint8 :offset 15 :size 1) + (ta1 uint8 :offset 32 :size 8) + ) + ) + +(deftype gs-texclut (uint64) + "The GS's TEXCLUT register specifies the CLUT position in the buffer when the CLUT storage mode +is CSM=1 (CSM2 mode)." + ((cbw uint8 :offset 0 :size 6) + (cou uint8 :offset 6 :size 6) + (cov uint16 :offset 12 :size 10) + ) + ) + +(deftype gs-miptbp (uint64) + "the GS's MIPTBP registers set the buffer pointer and buffer width of textures when performing +MIPMAP. MIPTBP1 sets levels 1 to 3, MIPTBP2 sets levels 4 to 6." + ((tbp1 uint16 :offset 0 :size 14) + (tbw1 uint8 :offset 14 :size 6) + (tbp2 uint16 :offset 20 :size 14) + (tbw2 uint8 :offset 34 :size 6) + (tbp3 uint16 :offset 40 :size 14) + (tbw3 uint8 :offset 54 :size 6) + ) + ) + +(deftype gs-alpha (uint64) + ((a uint8 :offset 0 :size 2) + (b uint8 :offset 2 :size 2) + (c uint8 :offset 4 :size 2) + (d uint8 :offset 6 :size 2) + (fix uint8 :offset 32 :size 8) + ) + ) + + +(deftype gs-clamp (uint64) + ((wms gs-tex-wrap-mode :offset 0 :size 2) + (wmt gs-tex-wrap-mode :offset 2 :size 2) + (minu uint16 :offset 4 :size 10) + (maxu uint16 :offset 14 :size 10) + (minv uint16 :offset 24 :size 10) + (maxv uint16 :offset 34 :size 10) + ) + ) + +(deftype gs-fog (uint64) + ((f uint8 :offset 56 :size 8) + ) + ) + + +(deftype gs-fogcol (uint64) + ((fcr uint8 :offset 0 :size 8) + (fcg uint8 :offset 8 :size 8) + (fcb uint8 :offset 16 :size 8) + ) + ) + + +(deftype gif-ctrl (uint32) + ((rst uint8 :offset 0 :size 1) + (pse uint8 :offset 3 :size 1) + ) + ) + +(deftype gif-mode (uint32) + ((m3r uint8 :offset 0 :size 1) + (imt uint8 :offset 2 :size 1) + ) + ) + +(deftype gif-stat (uint32) + ((m3r uint8 :offset 0 :size 1) + (m3p uint8 :offset 1 :size 1) + (imt uint8 :offset 2 :size 1) + (pse uint8 :offset 3 :size 1) + (ip3 uint8 :offset 5 :size 1) + (p3q uint8 :offset 6 :size 1) + (p2q uint8 :offset 7 :size 1) + (p1q uint8 :offset 8 :size 1) + (oph uint8 :offset 9 :size 1) + (apath uint8 :offset 10 :size 2) + (dir uint8 :offset 12 :size 1) + (fqc uint8 :offset 24 :size 5) + ) + ) + +(deftype gif-cnt (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (regcnt uint8 :offset 16 :size 4) + (vuaddr uint16 :offset 20 :size 10) + ) + ) + +(deftype gif-p3cnt (uint32) + ((p3cnt uint16 :offset 0 :size 15) + ) + ) + +(deftype gif-p3tag (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + ) + +(deftype gif-bank (structure) + ((ctrl gif-ctrl :offset 0) + (mode gif-mode :offset 16) + (stat gif-stat :offset 32) + (tag0 uint32 :offset 64) + (tag1 uint32 :offset 80) + (tag2 uint32 :offset 96) + (tag3 uint32 :offset 112) + (cnt gif-cnt :offset 128) + (p3cnt gif-p3cnt :offset 144) + (p3tag gif-p3tag :offset 160) + ) + ) + + +(deftype gif-tag-prim (uint32) + ((id uint16 :offset 0 :size 14) + (pre uint8 :offset 14 :size 1) + (prim gs-prim :offset 15 :size 11) + (flg gif-flag :offset 26 :size 2) + (nreg uint8 :offset 28 :size 4) + ) + ) + +(deftype gif-tag-count (uint32) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + ) + +(deftype gif-tag64 (uint64) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim gs-prim :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + ) + ) + +(deftype gif-tag (uint128) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim uint16 :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + (regs0 gif-reg-id :offset 64 :size 4) + (regs1 gif-reg-id :offset 68 :size 4) + (regs2 gif-reg-id :offset 72 :size 4) + (regs3 gif-reg-id :offset 76 :size 4) + (regs4 gif-reg-id :offset 80 :size 4) + (regs5 gif-reg-id :offset 84 :size 4) + (regs6 gif-reg-id :offset 88 :size 4) + (regs7 gif-reg-id :offset 92 :size 4) + (regs8 gif-reg-id :offset 96 :size 4) + (regs9 gif-reg-id :offset 100 :size 4) + (regs10 gif-reg-id :offset 104 :size 4) + (regs11 gif-reg-id :offset 108 :size 4) + (regs12 gif-reg-id :offset 112 :size 4) + (regs13 gif-reg-id :offset 116 :size 4) + (regs14 gif-reg-id :offset 120 :size 4) + (regs15 gif-reg-id :offset 124 :size 4) + ) + ) + +(deftype gs-gif-tag (structure) + ((qword uint128) + (tag gif-tag64 :overlay-at qword) + (regs gif-tag-regs :offset 8) + (dword uint64 2 :overlay-at qword) + (word uint32 4 :overlay-at qword) + ) + ) + + +;; WARN: Return type mismatch object vs gif-tag. + +(define *fog-color* (new 'static 'rgba :r #x80)) + +(deftype gif-packet (basic) + "Unused type for building a dynamically sized gif packet." + ((reg-count int32) + (gif-tag gs-gif-tag :inline) + (gif-tag0 uint128 :overlay-at (-> gif-tag qword)) + (args uint64 1) + ) + (:methods + (new (symbol type int) _type_) + ) + ) + + +(defmethod new gif-packet ((allocation symbol) (type-to-make type) (arg0 int)) + (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* (+ arg0 -1) 8)))) + ) + +(defun open-gif-packet ((arg0 gif-packet)) + (set! (-> arg0 reg-count) 0) + (set! (-> arg0 gif-tag regs) (new 'static 'gif-tag-regs)) + arg0 + ) + +;; WARN: Return type mismatch gif-packet vs none. +(defun add-reg-gif-packet ((arg0 gif-packet) (arg1 int) (arg2 int)) + (let ((v1-0 (-> arg0 gif-tag))) + (logior! (-> v1-0 regs) (ash arg1 (* (-> arg0 reg-count) 4))) + ) + (set! (-> (&-> arg0 args (-> arg0 reg-count)) 0) (the-as uint arg2)) + (+! (-> arg0 reg-count) 1) + (none) + ) + +(defun close-gif-packet ((arg0 gif-packet) (arg1 int)) + (set! (-> arg0 gif-tag tag) + (new 'static 'gif-tag64 :nloop #x1 :flg (gif-flag reg-list) :eop arg1 :nreg (-> arg0 reg-count)) + ) + arg0 + ) + +(deftype draw-context (basic) + ((orgx int32) + (orgy int32) + (orgz int32) + (width int32) + (height int32) + (color rgba 4) + ) + (:methods + (new (symbol type int int int int rgba) _type_) + ) + ) + + +(defmethod new draw-context ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 rgba)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 orgx) arg0) + (set! (-> v0-0 orgy) arg1) + (set! (-> v0-0 orgz) #xffffff) + (set! (-> v0-0 width) arg2) + (set! (-> v0-0 height) arg3) + (set! (-> v0-0 color 0) arg4) + v0-0 + ) + ) + +(defun draw-context-set-xy ((arg0 draw-context) (arg1 int) (arg2 int)) + (set! (-> arg0 orgx) arg1) + (set! (-> arg0 orgy) arg2) + (none) + ) + +(deftype gs-packed-rgba (vector4w) + ((r int32 :overlay-at (-> data 0)) + (g int32 :overlay-at (-> data 1)) + (b int32 :overlay-at (-> data 2)) + (a int32 :overlay-at (-> data 3)) + ) + ) + + +(deftype gs-packed-xyzw (vector) + ((ix int32 :overlay-at (-> data 0)) + (iy int32 :overlay-at (-> data 1)) + (iz int32 :overlay-at (-> data 2)) + (iw int32 :overlay-at (-> data 3)) + ) + ) + + +(deftype gs-packed-stq (vector) + ((tex-s float :overlay-at (-> data 0)) + (tex-t float :overlay-at (-> data 1)) + (tex-q float :overlay-at (-> data 2)) + ) + ) + + +(deftype gs-packed-uv (vector) + ((u int16 :overlay-at (-> data 0)) + (v int16 :overlay-at (-> data 1)) + ) + ) + + +(deftype gs-packed-gt (structure) + ((stq gs-packed-stq :inline :offset 0) + (rgba gs-packed-rgba :inline :offset 16) + (xyzw gs-packed-xyzw :inline :offset 32) + ) + ) + + +(deftype gs-packed-gt4 (structure) + ((data gs-packed-gt 4 :inline) + ) + ) diff --git a/goal_src/jakx/engine/gfx/hw/video-h.gc b/goal_src/jakx/engine/gfx/hw/video-h.gc index 3522786801..fdf03e937b 100644 --- a/goal_src/jakx/engine/gfx/hw/video-h.gc +++ b/goal_src/jakx/engine/gfx/hw/video-h.gc @@ -5,5 +5,35 @@ ;; name in dgo: video-h ;; dgos: ENGINE, GAME +(define-extern set-graphics-mode (function none)) +(define-extern get-video-mode (function symbol)) +(define-extern get-aspect-ratio (function symbol)) +(define-extern set-progressive-scan (function symbol none)) + ;; DECOMP BEGINS +(deftype video-params (structure) + "Parameters for the framebuffer." + ((set-video-mode symbol) + (reset-video-mode symbol) + (relative-x-scale float :offset 16) + (display-dx int32) + (display-dy int32) + (display-sy int32) + (relative-x-scale-reciprical float) + (smode2 uint64) + (aspect-ratio symbol) + ) + ) + + +(define *video-params* (new 'static 'video-params + :set-video-mode #f + :reset-video-mode #f + :relative-x-scale 1.0 + :display-dy 8 + :display-sy #xe0 + :relative-x-scale-reciprical 1.0 + :aspect-ratio 'aspect4x3 + ) + ) diff --git a/goal_src/jakx/engine/gfx/math-camera-h.gc b/goal_src/jakx/engine/gfx/math-camera-h.gc index d578b26615..dc90df683f 100644 --- a/goal_src/jakx/engine/gfx/math-camera-h.gc +++ b/goal_src/jakx/engine/gfx/math-camera-h.gc @@ -7,3 +7,104 @@ ;; DECOMP BEGINS +(deftype vis-gif-tag (structure) + "Unused." + ((fog0 uint32) + (strip uint32) + (regs uint32) + (fan uint32) + ) + ) + + +(deftype cull-info (structure) + "Also seems unused." + ((x-fact float) + (y-fact float) + (z-fact float) + (cam-radius float) + (cam-x float) + (cam-y float) + (xz-dir-ax float) + (xz-dir-az float) + (xz-dir-bx float) + (xz-dir-bz float) + (xz-cross-ab float) + (yz-dir-ay float) + (yz-dir-az float) + (yz-dir-by float) + (yz-dir-bz float) + (yz-cross-ab float) + ) + :allow-misaligned + ) + + +(deftype math-camera (basic) + ((d meters) + (f meters) + (fov degrees) + (x-ratio float) + (y-ratio float) + (x-pix float) + (x-clip float) + (x-clip-ratio-in float) + (x-clip-ratio-over float) + (y-pix float) + (y-clip float) + (y-clip-ratio-in float) + (y-clip-ratio-over float) + (cull-info cull-info :inline) + (fog-start meters) + (fog-end meters) + (fog-max float) + (fog-min float) + (reset int32) + (smooth-step float) + (smooth-t float) + (perspective matrix :inline) + (isometric matrix :inline) + (sprite-2d matrix :inline) + (sprite-2d-hvdf vector :inline) + (camera-rot matrix :inline) + (inv-camera-rot matrix :inline) + (inv-camera-rot-smooth matrix :inline) + (inv-camera-rot-smooth-from quaternion :inline) + (camera-temp matrix :inline) + (prev-camera-temp matrix :inline) + (prev-inv-camera-rot matrix :inline) + (prev-trans vector :inline) + (hmge-scale vector :inline) + (inv-hmge-scale vector :inline) + (hvdf-off vector :inline) + (guard vector :inline) + (vis-gifs vis-gif-tag 4) + (giftex uint128 :overlay-at (-> vis-gifs 0)) + (gifgr uint128 :offset 864) + (giftex-trans uint128 :offset 880) + (gifgr-trans uint128 :offset 896) + (pfog0 float) + (pfog1 float) + (trans vector :inline) + (plane plane 4 :inline) + (guard-plane plane 4 :inline) + (shrub-mat matrix :inline) + (quat-other quaternion :inline) + (trans-other vector :inline) + (shrub-mat-other matrix :inline) + (camera-temp-other matrix :inline) + (camera-rot-other matrix :inline) + (camera-rot-other-sky matrix :inline) + (camera-rot-other-sprite matrix :inline) + (inv-camera-rot-other matrix :inline) + (plane-other plane 4 :inline) + (guard-plane-other plane 4 :inline) + (mirror-trans vector :inline) + (mirror-normal vector :inline) + (fov-correction-factor float) + ) + (:methods + (new (symbol type) _type_) + (math-camera-method-9 () none) + ) + ) diff --git a/goal_src/jakx/engine/gfx/mood/mood-h.gc b/goal_src/jakx/engine/gfx/mood/mood-h.gc index ea978adb76..ca65106f9b 100644 --- a/goal_src/jakx/engine/gfx/mood/mood-h.gc +++ b/goal_src/jakx/engine/gfx/mood/mood-h.gc @@ -5,5 +5,304 @@ ;; name in dgo: mood-h ;; dgos: ENGINE, GAME +(declare-type sky-color-day structure) +(declare-type mood-context structure) + +(define-extern movie? (function symbol)) + +(define-extern clear-mood-context (function mood-context symbol)) + ;; DECOMP BEGINS +(deftype mood-channel (structure) + ((data float 24) + (vecs vector4 6 :inline :overlay-at (-> data 0)) + ) + ) + + +(deftype mood-channel-group (structure) + ((data mood-channel 4 :inline) + ) + ) + + +(deftype mood-fog (structure) + ((fog-color vector :inline) + (fog-dists vector :inline) + (fog-start meters :overlay-at (-> fog-dists data 0)) + (fog-end meters :overlay-at (-> fog-dists data 1)) + (fog-max float :overlay-at (-> fog-dists data 2)) + (fog-min float :overlay-at (-> fog-dists data 3)) + (erase-color vector :inline) + ) + ) + + +(deftype mood-fog-table (structure) + ((data mood-fog 8 :inline) + (_data uint128 24 :overlay-at data) + ) + ) + + +(deftype mood-color (structure) + ((lgt-color vector :inline) + (amb-color vector :inline) + ) + ) + + +(deftype mood-direction-table (structure) + ((data vector 4 :inline) + ) + ) + + +(deftype mood-color-table (structure) + ((data mood-color 8 :inline) + (_data uint128 16 :overlay-at data) + ) + ) + + +(deftype mood-sky-table (structure) + ((data vector 8 :inline) + ) + ) + + +(deftype mood-clouds (structure) + ((cloud-min float) + (cloud-max float) + ) + ) + + +(deftype mood-weather (structure) + ((data float 2) + (cloud float :overlay-at (-> data 0)) + (fog float :overlay-at (-> data 1)) + ) + :pack-me + :allow-misaligned + ) + + +(deftype mood-iweather (structure) + ((data int32 2) + (cloud int32 :overlay-at (-> data 0)) + (fog int32 :overlay-at (-> data 1)) + ) + :allow-misaligned + ) + + +(deftype mood-range (structure) + ((data float 4) + (min-cloud float :overlay-at (-> data 0)) + (max-cloud float :overlay-at (-> data 1)) + (min-fog float :overlay-at (-> data 2)) + (max-fog float :overlay-at (-> data 3)) + (quad uint128 :overlay-at (-> data 0)) + ) + ) + + +(deftype mood-filters-table (structure) + ((data vector 8 :inline) + ) + ) + + +(deftype mood-table (basic) + ((mood-fog-table mood-fog-table) + (mood-color-table mood-color-table) + (mood-channel-group mood-channel-group) + (mood-direction-table mood-direction-table) + (mood-sky-table mood-sky-table) + (mood-interp-table sky-color-day) + ) + ) + + +(deftype light-state (structure) + ((time float) + (fade float) + ) + :pack-me + ) + + +(deftype flicker-state (structure) + ((flicker-off uint8) + (flicker-on uint8) + ) + :allow-misaligned + ) + + +(deftype florescent-state (structure) + ((value float) + (delay int8) + (delay2 int8) + ) + ) + + +(deftype electricity-state (structure) + ((value float) + (scale float) + ) + :pack-me + ) + + +(deftype pulse-state (structure) + ((pulse float) + (brightness float) + (target-brightness float) + (speed float) + ) + :pack-me + ) + + +(deftype strobe-state (structure) + ((time float) + ) + ) + + +(deftype flames-state (structure) + ((time float) + (index uint8) + (length uint8) + (height uint8) + ) + :pack-me + ) + + +(deftype mood-context-core (structure) + ((current-fog mood-fog :inline) + (current-sky-color vector :inline) + (current-env-color vector :inline) + (current-prt-color vector :inline) + (current-shadow-color vector :inline) + ) + ) + + +(deftype mood-context-core2 (mood-context-core) + ((light-group light-group 8 :inline) + ) + ) + + +(deftype mood-context-core3 (mood-context-core2) + ((times vector 8 :inline) + ) + ) + + +(deftype mood-context (mood-context-core3) + ((itimes vector4w 4 :inline) + (state uint32 32) + (data uint128 123 :overlay-at (-> current-fog fog-color data 0)) + ) + ) + + +(deftype mood-control-work (structure) + ((color vector4w :inline) + (weather mood-weather :inline) + (iweather mood-iweather :inline) + (interp mood-weather :inline) + (index int32 4) + (color-interp float) + (color-index int32 2) + (channel-interp float) + (channel-index int32 2) + (cloud-interp float) + (cloud-index int32 2) + ) + ) + + +(deftype mood-control (mood-table) + ((mood-clouds mood-clouds) + (current-interp mood-weather :inline) + (target-interp mood-weather :inline) + (speed-interp mood-weather :inline) + (range mood-range :inline) + (time-until-random mood-weather :inline) + (time-until-random-min mood-weather :inline) + (time-until-random-max mood-weather :inline) + (current-special-interp float) + (target-special-interp float) + (rate-special-interp float) + (display-flag symbol) + (overide-weather-flag symbol) + (pad int32) + (overide mood-weather :inline) + (lightning-index int32) + (lightning-val int32) + (lightning-time int32) + (lightning-time2 float) + (lightning-time3 float) + (lightning-flash float) + (lightning-id sound-id) + (lightning-count0 uint32) + (lightning-count1 uint32) + (lightning-count2 uint32) + (rain-id sound-id) + (sound-pitch float) + (fogs mood-fog-table 9) + (colors mood-color-table 3) + (channels mood-channel-group 3) + (clouds mood-clouds 9) + ) + (:methods + (init-weather! (_type_) none) + (set-cloud-and-fog-interp! (_type_ float float float float) none) + (update-mood-range! (_type_ float float float float) none) + (set-time-for-random-weather! (_type_ float float) none) + (set-special-interps! (_type_ float float symbol) none) + (weather-event-concluded? (_type_) symbol) + (set-lightning-time! (_type_ int int float) none) + (apply-mood-clouds-and-fog (_type_ mood-control-work) none) + (apply-mood-fog (_type_ mood-control-work mood-color-table mood-color-table mood-color-table float) none) + (apply-fog-height (_type_ mood-control-work float float float float) none) + (apply-mood-colors (_type_ mood-control-work) none) + (mood-control-method-20 (_type_ mood-control-work mood-color-table mood-color-table mood-color-table float) none) + (apply-mood-channels (_type_ mood-control-work) none) + (adjust-num-clouds (_type_ mood-control-work) none) + (gen-lightning-and-thunder! (_type_ int) none) + (play-or-stop-lightning-sfx! (_type_ sound-spec vector) none) + ) + ) + + +(defmethod set-special-interps! ((this mood-control) (target-interp float) (rate-interp float) (set-current-interp? symbol)) + "Sets the `*-special-interp` values with the given values + @param! this The [[mood-control]] + @param target-interp Clamped between 0.0 and 1.0 + @param rate-interp Value to set [[this::rate-special-interp]] + @param set-current-interp? Uses `target-interp` to set [[this::current-special-interp] + @returns [[none]]" + (let ((clamped-interp (fmax 0.0 (fmin 1.0 target-interp)))) + (set! (-> this target-special-interp) clamped-interp) + (set! (-> this rate-special-interp) rate-interp) + (if set-current-interp? + (set! (-> this current-special-interp) clamped-interp) + ) + ) + 0 + (none) + ) + +(defmethod weather-event-concluded? ((this mood-control)) + "@returns [[#t]] if [[this::override-weather-flag]] is set, we aren't in a cutscene and [[this::current-special-interp]] is equal to `0.0`" + (and (-> this overide-weather-flag) (not (movie?)) (= (-> this current-special-interp) 0.0)) + ) diff --git a/goal_src/jakx/engine/gfx/mood/time-of-day-h.gc b/goal_src/jakx/engine/gfx/mood/time-of-day-h.gc index b483ccc6e8..40c52ce0fc 100644 --- a/goal_src/jakx/engine/gfx/mood/time-of-day-h.gc +++ b/goal_src/jakx/engine/gfx/mood/time-of-day-h.gc @@ -5,5 +5,147 @@ ;; name in dgo: time-of-day-h ;; dgos: ENGINE, GAME +(define-extern time-of-day-setup (function symbol symbol)) + +;; +++time-of-day-palette-id +(defenum time-of-day-palette-id + :type uint32 + :bitfield #t + (unk0 0) ;; 1 + (unk1 1) ;; 2 + (unk2 2) ;; 4 + (unk3 3) ;; 8 + (palette-0 4) ;; 16 + (palette-1 5) ;; 32 + (palette-2 6) ;; 64 + (palette-3 7) ;; 128 + (palette-4 8) ;; 256 + (palette-5 9) ;; 512 + (palette-6 10) ;; 1024 + (palette-7 11) ;; 2048 + ) +;; ---time-of-day-palette-id + +(declare-type sparticle-launch-control inline-array-class) +(declare-type time-of-day-palette structure) +(define-extern time-of-day-interp-colors (function (pointer rgba) uint mood-context none)) +(define-extern time-of-day-interp-colors-scratch (function (pointer rgba) time-of-day-palette mood-context none)) +(declare-type time-of-day-proc process) +(declare-type time-of-day-context structure) +(define-extern *time-of-day* (pointer time-of-day-proc)) +(define-extern update-time-of-day (function time-of-day-context none)) +(define-extern init-time-of-day-context (function time-of-day-context symbol)) +(define-extern calc-fade-from-fog (function vector float)) + ;; DECOMP BEGINS +(deftype palette-fade-control (structure) + "Unused interface to the time-of-day control. Was used in jak 1 as an interface between level code, +and the code in mood.gc, which set the actual fade values for time-of-day." + ((trans vector :inline) + (fade float) + (actor-dist float) + ) + ) + + +(deftype palette-fade-controls (basic) + "Unused interface to the time-of-day control. Was used in jak 1 as an interface between level code, +and the code in mood.gc, which set the actual fade values for time-of-day." + ((control palette-fade-control 8 :inline) + ) + (:methods + (reset! (_type_) none) + (set-fade! (_type_ int float float vector) object) + ) + ) + + +(define-perm *palette-fade-controls* palette-fade-controls (new 'global 'palette-fade-controls)) + +(deftype time-of-day-proc (process) + "Process for running things that change with the time-of-day, like lighting, sun/stars/moon, etc." + ((hours int32) + (minutes int32) + (seconds int32) + (old-frame uint64) + (current-frame uint64) + (frames uint64) + (time-of-day float) + (old-frame-save uint64) + (current-frame-save uint64) + (frames-save uint64) + (time-of-day-save float) + (time-ratio float) + (dest-time-ratio float) + (dest-time-delta float) + (sun-count int32) + (sun sparticle-launch-control) + (green-sun-count int32) + (green-sun sparticle-launch-control) + (moon-count int32) + (moon sparticle-launch-control) + (start-timer int32) + ) + ) + + +(deftype time-of-day-palette (basic) + "Pre-baked lighting values used by rendering code. The exact meaning of this data can vary, +but in all cases, the time-of-day system can do linear interpolation of two palettes to +blend between them." + ((width int32) + (height int32) + (pad int32) + (data int32 1) + ) + ) + + +(deftype time-of-day-context (basic) + "A mix of inputs/outputs to the time-of-day system." + ((interp float 18) + (current-fog mood-fog :inline) + (current-sky-color vector :inline) + (current-env-color vector :inline) + (current-prt-color vector :inline) + (current-shadow-color vector :inline) + (light-group light-group 8 :inline) + (current-clouds mood-clouds :inline) + (times vector 8 :inline) + (title-light-group light-group :inline) + (rim-light-group light-group :inline) + (front-rear-light-group light-group :inline) + (fog-override mood-fog :inline) + (filter vector :inline) + (filter-color vector :inline) + (time float) + (target-interp float) + (erase-color rgba) + (sky symbol) + (special-mood basic) + (use-camera-other basic) + (title-updated symbol) + (mode time-of-day-palette-id) + (override-enable basic) + (override-palette uint32) + (max-rain float) + (exterior-level basic) + (ocean-alpha float) + (shadow-override float) + (fog-override-interp float) + ) + ) + + +(deftype time-of-day-dma (structure) + "Memory layout for the time-of-day interpolation functions." + ((outa uint32 256) + (outb uint32 256) + (banka uint32 256) + (bankb uint32 256) + ) + ) + + +(define *time-of-day-context* (new 'static 'time-of-day-context)) diff --git a/goal_src/jakx/engine/gfx/ocean/ocean-h.gc b/goal_src/jakx/engine/gfx/ocean/ocean-h.gc index 3a0646683e..a0d8502046 100644 --- a/goal_src/jakx/engine/gfx/ocean/ocean-h.gc +++ b/goal_src/jakx/engine/gfx/ocean/ocean-h.gc @@ -7,3 +7,412 @@ ;; DECOMP BEGINS +(deftype ocean-corner (structure) + ((bsphere sphere :inline) + (start-corner vector :inline) + (y-scales vector :inline) + (alphas vector :inline) + (colors uint32 4) + ) + ) + + +(deftype ocean-wave-info (structure) + ((frequency float) + (amplitude float) + (wave-speed float) + (angle float) + (kx float) + (ky float) + (w float) + (flags int32) + ) + ) + + +(deftype ocean-vertex (structure) + ((pos vector :inline) + (stq vector :inline) + (col vector :inline) + ) + ) + + +(deftype ocean-spheres (structure) + ((spheres sphere 36 :inline) + ) + ) + + +(deftype ocean-colors (structure) + ((colors rgba 2548) + ) + ) + + +(deftype ocean-colors-float (structure) + ((colors vector 2548 :inline) + ) + ) + + +(deftype ocean-mid-mask (structure) + ((mask uint8 8) + (dword uint64 :overlay-at (-> mask 0)) + ) + :pack-me + ) + + +(deftype ocean-mid-indices (basic) + ((data uint16 36) + ) + ) + + +(deftype ocean-mid-masks (basic) + ((data (inline-array ocean-mid-mask)) + ) + ) + + +(deftype ocean-trans-mask (structure) + ((mask uint8 4) + (word int32 :overlay-at (-> mask 0)) + ) + :pack-me + ) + + +(deftype ocean-trans-index (structure) + ((parent int16) + (child int16) + ) + :pack-me + ) + + +(deftype ocean-trans-indices (basic) + ((data ocean-trans-index 2304 :inline) + ) + ) + + +(deftype ocean-near-index (structure) + ((data uint16 16) + ) + ) + + +(deftype ocean-near-indices (basic) + ((data (inline-array ocean-near-index)) + ) + ) + + +(deftype ocean-near-colors (structure) + ((color0 vector :inline) + (color1 vector :inline) + (color2 vector :inline) + (color3 vector :inline) + ) + ) + + +(deftype ocean-trans-strip (structure) + ((verts uint128 10) + ) + ) + + +(deftype ocean-trans-strip-array (structure) + ((data ocean-trans-strip 4 :inline) + ) + ) + + +(deftype ocean-wave-data (structure) + ((data uint8 1024) + ) + ) + + +(deftype ocean-wave-frames (structure) + ((frame ocean-wave-data 64 :inline) + ) + ) + + +(deftype ocean-texture-constants (structure) + ((giftag qword :inline) + (buffers vector4w :inline) + (dests vector4w :inline) + (start vector :inline) + (offsets vector :inline) + (constants vector :inline) + (cam-nrm vector :inline) + ) + ) + + +(deftype ocean-mid-vertex (structure) + ((stq vector :inline) + (col vector :inline) + (pos vector :inline) + ) + ) + + +(deftype ocean-mid-constants (structure) + ((hmge-scale vector :inline) + (inv-hmge-scale vector :inline) + (hvdf-offset vector :inline) + (fog vector :inline) + (constants vector :inline) + (constants2 vector :inline) + (drw-fan qword :inline) + (env-fan qword :inline) + (drw-adgif qword :inline) + (drw-texture adgif-shader :inline) + (drw-strip-0 qword :inline) + (drw-strip-1 qword :inline) + (env-adgif qword :inline) + (env-texture adgif-shader :inline) + (env-strip qword :inline) + (env-color vector :inline) + (index-table vector4w 8 :inline) + (pos0 vector :inline) + (pos1 vector :inline) + (pos2 vector :inline) + (pos3 vector :inline) + ) + ) + + +(deftype ocean-mid-upload (structure) + ((rot matrix :inline) + (matrix matrix :inline) + (colors uint128 108) + (masks uint128 2) + ) + ) + + +(deftype ocean-mid-upload2 (structure) + ((rot matrix :inline) + (matrix matrix :inline) + (count vector4w :inline) + (tex0 vector :inline) + (tex1 vector :inline) + (tex2 vector :inline) + (tex3 vector :inline) + (clr0 vector :inline) + (clr1 vector :inline) + (clr2 vector :inline) + (clr3 vector :inline) + (verts uint128 18) + ) + ) + + +(deftype ocean-mid-work (structure) + ((env0 vector :inline) + (env1 vector :inline) + (env2 vector :inline) + (hmg0 vector :inline) + (hmg1 vector :inline) + (hmg2 vector :inline) + (indices uint128 16) + ) + ) + + +(deftype ocean-near-constants (structure) + ((hmge-scale vector :inline) + (inv-hmge-scale vector :inline) + (hvdf-offset vector :inline) + (fog vector :inline) + (constants vector :inline) + (constants2 vector :inline) + (constants3 vector :inline) + (constants4 vector :inline) + (constants5 vector :inline) + (drw-fan qword :inline) + (drw2-fan qword :inline) + (env-fan qword :inline) + (drw-adgif qword :inline) + (drw-texture adgif-shader :inline) + (drw-strip qword :inline) + (env-adgif qword :inline) + (env-texture adgif-shader :inline) + (env-strip qword :inline) + (env-color vector :inline) + (drw2-adgif qword :inline) + (drw2-tex0 qword :inline) + (drw2-frame qword :inline) + (drw2-strip qword :inline) + (drw3-adgif qword :inline) + (drw3-frame qword :inline) + (index-table vector4w 4 :inline) + ) + ) + + +(deftype ocean-near-upload (structure) + ((rot matrix :inline) + (matrix matrix :inline) + (masks uint128 2) + (start-height vector4w :inline) + (start-st vector :inline) + (near-colors ocean-near-colors :inline) + ) + ) + + +(deftype ocean-near-vertex (structure) + ((stq vector :inline) + (clr vector :inline) + (pos vector :inline) + ) + ) + + +(deftype ocean-near-work (structure) + ((verts-ptr vector :inline) + (indices uint128 16) + ) + ) + + +(deftype ocean-height-array (structure) + ((data float 1024) + ) + ) + + +(deftype ocean-map (structure) + ((start-corner vector :inline) + (far-color vector :inline) + (ocean-colors ocean-colors) + (ocean-mid-indices ocean-mid-indices) + (ocean-trans-indices ocean-trans-indices) + (ocean-near-indices ocean-near-indices) + (ocean-mid-masks ocean-mid-masks) + ) + (:methods + (ocean-map-method-9 () none) + (ocean-map-method-10 () none) + ) + ) + + +(deftype ocean (ocean-map) + ((off symbol) + (near-off symbol) + (far-on symbol) + (all-on symbol) + (ocean-facing uint32) + (mid-mask-ptrs pointer 36) + (mid-camera-masks uint64 36) + (trans-mask-ptrs pointer 64) + (trans-camera-masks ocean-trans-mask 16) + (trans-temp-masks uint32 16) + (haze-lights haze-lights :inline) + (near-mask-indices uint16 16) + (mid-minx uint8) + (mid-maxx uint8) + (mid-minz uint8) + (mid-maxz uint8) + (near-minx uint8) + (near-maxx uint8) + (near-minz uint8) + (near-maxz uint8) + (temp-minx uint8) + (temp-maxx uint8) + (temp-minz uint8) + (temp-maxz uint8) + (tex1 uint64) + (tex1-near uint64) + (wait-to-vu0 uint32) + ) + (:methods + (ocean-method-11 () none) + (ocean-method-12 () none) + (ocean-method-13 () none) + (ocean-method-14 () none) + (ocean-method-15 () none) + (ocean-method-16 () none) + (ocean-method-17 () none) + (ocean-method-18 () none) + (ocean-method-19 () none) + (ocean-method-20 () none) + (ocean-method-21 () none) + (ocean-method-22 () none) + (ocean-method-23 () none) + (ocean-method-24 () none) + (ocean-method-25 () none) + (ocean-method-26 () none) + (ocean-method-27 () none) + (ocean-method-28 () none) + (ocean-method-29 () none) + (ocean-method-30 () none) + (ocean-method-31 () none) + (ocean-method-32 () none) + (ocean-method-33 () none) + (ocean-method-34 () none) + (ocean-method-35 () none) + (ocean-method-36 () none) + (ocean-method-37 () none) + (ocean-method-38 () none) + (ocean-method-39 () none) + (ocean-method-40 () none) + (ocean-method-41 () none) + (ocean-method-42 () none) + (ocean-method-43 () none) + (ocean-method-44 () none) + (ocean-method-45 () none) + (ocean-method-46 () none) + (ocean-method-47 () none) + (ocean-method-48 () none) + (ocean-method-49 () none) + (ocean-method-50 () none) + (ocean-method-51 () none) + (ocean-method-52 () none) + (ocean-method-53 () none) + (ocean-method-54 () none) + (ocean-method-55 () none) + (ocean-method-56 () none) + (ocean-method-57 () none) + (ocean-method-58 () none) + (ocean-method-59 () none) + (ocean-method-60 () none) + (ocean-method-61 () none) + (ocean-method-62 () none) + (ocean-method-63 () none) + (ocean-method-64 () none) + (ocean-method-65 () none) + (ocean-method-66 () none) + (ocean-method-67 () none) + (ocean-method-68 () none) + (ocean-method-69 () none) + (ocean-method-70 () none) + (ocean-method-71 () none) + (ocean-method-72 () none) + (ocean-method-73 () none) + (ocean-method-74 () none) + (ocean-method-75 () none) + (ocean-method-76 () none) + (ocean-method-77 () none) + (ocean-method-78 () none) + (ocean-method-79 () none) + (ocean-method-80 () none) + (ocean-method-81 () none) + (ocean-method-82 () none) + (ocean-method-83 () none) + ) + ) + + +(define *ocean-map* (the-as ocean-map #f)) + +(define *ocean* (new 'static 'ocean :tex1 #xf6f00000178 :tex1-near #xf6f00000164)) diff --git a/goal_src/jakx/engine/gfx/shrub/shrubbery-h.gc b/goal_src/jakx/engine/gfx/shrub/shrubbery-h.gc index d71db9b8e5..6c9751b906 100644 --- a/goal_src/jakx/engine/gfx/shrub/shrubbery-h.gc +++ b/goal_src/jakx/engine/gfx/shrub/shrubbery-h.gc @@ -7,3 +7,240 @@ ;; DECOMP BEGINS +(deftype billboard (drawable) + "A billboard for shrubbery in the distance. This is simple a quad that faces the camera. +The only data needed is the texture/mode. The location is determined by bsphere." + ((flat adgif-shader :inline) + ) + ) + + +(deftype shrub-view-data (structure) + "Camera and general settings for shrubbery VU1 program." + ((data uint128 3) + (texture-giftag gs-gif-tag :inline :overlay-at (-> data 0)) + (consts vector :inline :overlay-at (-> data 1)) + (fog-clamp vector :inline :overlay-at (-> data 2)) + (tex-start-ptr int32 :overlay-at (-> data 1)) + (gifbufsum float :overlay-at (-> data 1)) + (mtx-buf-ptr int32 :overlay-at (-> consts y)) + (exp23 float :overlay-at mtx-buf-ptr) + (fog-0 float :overlay-at (-> consts z)) + (fog-1 float :overlay-at (-> consts w)) + (fog-min float :overlay-at (-> data 2)) + (fog-max float :overlay-at (-> fog-clamp y)) + ) + ) + + +(deftype shrubbery (drawable) + "Prototype (mesh/geometry) for a shrub. not _really_ a drawable in any way, as it +overwrites all the normal drawable fields." + ((textures (inline-array adgif-shader) :overlay-at id) + (header qword :offset 8) + (obj-qwc uint8 :offset 12) + (vtx-qwc uint8 :offset 13) + (col-qwc uint8 :offset 14) + (stq-qwc uint8 :offset 15) + (obj uint32 :overlay-at (-> bsphere data 0)) + (vtx uint32 :overlay-at (-> bsphere data 1)) + (col uint32 :overlay-at (-> bsphere data 2)) + (stq uint32 :overlay-at (-> bsphere data 3)) + ) + ) + + +(deftype instance-shrubbery (instance) + "Instance of a shrub." + ((flat-normal vector :inline) + (flat-hwidth float :overlay-at (-> flat-normal data 3)) + (color uint32 :offset 8) + ) + ) + + +(deftype drawable-inline-array-instance-shrub (drawable-inline-array) + "Array of shrub instances stored in the level data." + ((data instance-shrubbery 1 :inline) + (pad uint32) + ) + ) + +(deftype drawable-tree-instance-shrub (drawable-tree) + "Drawable-tree for the shrubs." + ((info prototype-array-shrub-info :offset 8) + (colors-added time-of-day-palette :offset 12) + ) + ) + +(deftype generic-shrub-fragment (drawable) + "Shrub data, converted into the format for generic. +The shrub renderer doesn't support clipping, so it falls back to generic. +This requires storing the data for all shrubs prototype twice!" + ((textures (inline-array adgif-shader) :overlay-at id) + (vtx-cnt uint32 :offset 8) + (cnt-qwc uint8 :offset 12) + (vtx-qwc uint8 :offset 13) + (col-qwc uint8 :offset 14) + (stq-qwc uint8 :offset 15) + (cnt uint32 :overlay-at (-> bsphere data 0)) + (vtx uint32 :overlay-at (-> bsphere data 1)) + (col uint32 :overlay-at (-> bsphere data 2)) + (stq uint32 :overlay-at (-> bsphere data 3)) + ) + ) + + +(deftype prototype-shrubbery (drawable-inline-array) + "Array of shrub prototypes." + ((data shrubbery 1 :inline) + (pad uint32) + ) + ) + +(deftype prototype-trans-shrubbery (prototype-shrubbery) + "Array of transparent shrub prototypes." + () + ) + +(deftype prototype-generic-shrub (drawable-group) + () + ) + +(deftype shrubbery-matrix (structure) + "Instance matrix for a shrub, contains interpolated color." + ((mat matrix :inline) + (color qword :inline) + ) + ) + + +;; WARN: Return type mismatch symbol vs none. +(defun shrubbery-login-post-texture ((arg0 shrubbery)) + "Do some weird fix-up to the shrubbery textures. this is likely to present normal-looking adgifs to the texture system, but then we scramble them up for easier consumption by VU1." + (let* ((v1-1 (-> arg0 header data 0)) + (a1-1 (the-as object (+ (the-as uint (-> arg0 header)) (* (+ (-> arg0 header data 1) 1) 16)))) + (a2-5 (the-as object (+ (the-as int a1-1) (* v1-1 64)))) + (a3-0 (the-as object (-> arg0 textures))) + ) + (dotimes (a0-1 (the-as int v1-1)) + (set! (-> (the-as qword a2-5) quad) (-> (the-as qword a3-0) quad)) + (let ((a2-6 (the-as object (+ (the-as int a2-5) 16))) + (a3-1 (the-as object (&+ (the-as pointer a3-0) 16))) + ) + (set! (-> (the-as qword a1-1) vector4w x) (the-as int (-> (the-as qword a3-1) data 0))) + (set! (-> (the-as qword a1-1) vector4w y) (the-as int (-> (the-as qword a3-1) data 1))) + (set! (-> (the-as qword a1-1) vector4w z) (the-as int (-> (the-as qword a3-1) data 2))) + (set! a1-1 (+ (the-as int a1-1) 16)) + (let ((a3-2 (the-as object (&+ (the-as pointer a3-1) 16)))) + (dotimes (t0-4 3) + (set! (-> (the-as qword a1-1) quad) (-> (the-as qword a3-2) quad)) + (set! a1-1 (+ (the-as int a1-1) 16)) + (set! a3-2 (&+ (the-as pointer a3-2) 16)) + ) + (set! (-> (the-as qword a2-6) quad) (-> (the-as qword a3-2) quad)) + (set! a2-5 (+ (the-as int a2-6) 16)) + (set! a3-0 (&+ (the-as pointer a3-2) 80)) + ) + ) + ) + ) + (none) + ) + +(define *shrub-state* 0) + +(deftype shrub-near-packet (structure) + "DMA templates for generic rendering of shrubs." + ((matrix-tmpl dma-packet :inline) + (header-tmpl dma-packet :inline) + (stq-tmpl dma-packet :inline) + (color-tmpl dma-packet :inline) + (vertex-tmpl dma-packet :inline) + (mscal-tmpl dma-packet :inline) + (init-tmpl dma-packet :inline) + (init-data qword 2 :inline) + ) + ) + + +(deftype instance-shrub-work (structure) + "Scratchpad layout for generating shrub DMA." + ((dummy qword 3 :inline) + (chaina qword 8 :inline) + (chainb qword 8 :inline) + (colors rgba 1024) + (matrix-tmpl qword 20 :inline) + (count-tmpl vector4w 20 :inline) + (mscalf-tmpl dma-packet :inline) + (mscalf-ret-tmpl dma-packet :inline) + (adgif-tmpl dma-gif-packet :inline) + (billboard-tmpl dma-gif-packet :inline) + (billboard-const vector :inline) + (shrub-near-packets shrub-near-packet 6 :inline) + (dma-ref dma-packet :inline) + (dma-end dma-packet :inline) + (wind-const vector :inline) + (constants vector :inline) + (color-constant vector4w :inline) + (hmge-d vector :inline) + (hvdf-offset vector :inline) + (wind-force vector :inline) + (color vector :inline) + (bb-color vector :inline) + (min-dist vector :inline) + (temp-vec vector :inline) + (guard-plane plane 4 :inline) + (plane plane 4 :inline) + (last uint32 4) + (next uint32 4) + (count uint16 4) + (mod-count uint16 4) + (wind-vectors uint32) + (instance-ptr uint32) + (chain-ptr uint32) + (chain-ptr-next uint32) + (stack-ptr uint32) + (bucket-ptr uint32) + (src-ptr uint32) + (to-spr uint32) + (from-spr uint32) + (shrub-count uint32) + (stack-ptr2 uint32 :overlay-at stack-ptr) + (node uint32 6 :offset 6428) + (length uint32 6) + (prototypes uint32) + (bucket-ptr2 uint32 :overlay-at bucket-ptr) + (start-bank uint8 20 :offset 6484) + (buffer-index uint32) + (current-spr uint32) + (current-mem uint32) + (current-shrub-near-packet uint32) + (current-shrub-near-trans-packet uint32) + (to-spr2 uint32 :overlay-at to-spr) + (dma-buffer basic :offset 6528) + (near-last uint32) + (near-next uint32) + (near-count uint32) + (near-trans-last uint32) + (near-trans-next uint32) + (near-trans-count uint32) + (last-shrubs uint32) + (chains uint32) + (flags uint32) + (node-count uint32) + (inst-count uint32) + (wait-from-spr uint32) + (wait-to-spr uint32) + (texture-dists uint32) + ) + ) + + +(deftype instance-shrub-dma (structure) + ((instancea uint128 325) + (instanceb uint128 325) + (outa uint128 128) + (outb uint128 128) + ) + ) diff --git a/goal_src/jakx/engine/gfx/sky/sky-h.gc b/goal_src/jakx/engine/gfx/sky/sky-h.gc index cf50616774..8724805f5c 100644 --- a/goal_src/jakx/engine/gfx/sky/sky-h.gc +++ b/goal_src/jakx/engine/gfx/sky/sky-h.gc @@ -7,3 +7,214 @@ ;; DECOMP BEGINS +(deftype sky-color-hour (structure) + ((snapshot1 int32) + (snapshot2 int32) + (morph-start float) + (morph-end float) + ) + ) + + +(deftype sky-color-day (structure) + ((hour sky-color-hour 24 :inline) + ) + ) + + +(deftype sky-sun-data (structure) + ((data uint128 4) + (pos vector :inline :overlay-at (-> data 0)) + (r-sun float :overlay-at (-> data 1)) + (r-halo float :offset 20) + (r-aurora float :offset 24) + (c-sun-start rgba :overlay-at (-> data 2)) + (c-sun-end rgba :overlay-at (-> data 3)) + (c-halo-start rgba :offset 36) + (c-halo-end rgba :offset 52) + (c-aurora-start rgba :offset 40) + (c-aurora-end rgba :offset 56) + ) + ) + + +(deftype sky-moon-data (structure) + ((data uint128 2) + (pos vector :inline :overlay-at (-> data 0)) + (scale vector :inline :overlay-at (-> data 1)) + ) + ) + + +(deftype sky-orbit (structure) + ((high-noon float) + (tilt float) + (rise float) + (dist float) + (min-halo float) + (max-halo float) + ) + :allow-misaligned + ) + + +(deftype sky-upload-data (structure) + ((data uint128 12) + (sun sky-sun-data 2 :inline :overlay-at (-> data 0)) + (moon sky-moon-data :inline :overlay-at (-> data 8)) + ) + ) + + +(deftype sky-vertex (structure) + ((pos vector :inline) + (stq vector :inline) + (col vector :inline) + ) + ) + + + +(deftype cloud-vertex (structure) + ((pos vector :inline) + (stq vector :inline) + (col vector :inline) + (nrm vector :inline) + (stq2 vector :inline) + (col2 vector :inline) + (nrm2 vector :inline) + ) + ) + + +(deftype cloud-vert-array (structure) + ((data cloud-vertex 100 :inline) + ) + ) + + +(deftype haze-vertex (structure) + ((pos vector :inline) + (nrm vector :inline) + (col vector :inline) + ) + ) + + +(deftype haze-vert-array (structure) + ((data haze-vertex 36 :inline) + ) + ) + + +(deftype cloud-lights (structure) + ((sun0-normal vector :inline) + (sun1-normal vector :inline) + (moon-normal vector :inline) + (ambi-color vector :inline) + (ambi-color-lower vector :inline) + (sun0-color vector :inline) + (sun1-color vector :inline) + (moon-color vector :inline) + (sun0-color-lower vector :inline) + (sun0-scale float) + (sun1-scale float) + (moon-scale float) + ) + ) + + +(deftype haze-lights (structure) + ((sun0-normal vector :inline) + (sun1-normal vector :inline) + (moon-normal vector :inline) + (ambi-color vector :inline) + (sun0-color vector :inline) + (sun1-color vector :inline) + (moon-color vector :inline) + (sun0-scale float) + (sun1-scale float) + (moon-scale float) + ) + ) + + +(deftype sky-work (structure) + ((adgif-tmpl dma-gif-packet :inline) + (draw-tmpl dma-gif-packet :inline) + (draw-tmpl2 dma-gif-packet :inline) + (fog-tmpl dma-gif-packet :inline) + (blend-tmpl dma-gif-packet :inline) + (sprite-tmpl dma-gif-packet :inline) + (sprite-tmpl2 dma-gif-packet :inline) + (sun-coords vector 2 :inline) + (green-coords vector 2 :inline) + (moon0-coords vector 2 :inline) + (moon1-coords vector 2 :inline) + (moon2-coords vector 2 :inline) + (star-coords vector 2 :inline) + (sun-colors vector4w 2 :inline) + (green-colors vector4w 2 :inline) + (moon-colors vector4w 3 :inline) + (star-colors vector4w 16 :inline) + (st-coords vector 2 :inline) + (random vector4w 8 :inline) + (giftag-base dma-gif :inline) + (giftag-haze dma-gif :inline) + (giftag-roof dma-gif :inline) + (giftag-clouds dma-gif :inline) + (giftag-ocean dma-gif :inline) + (fog vector :inline) + (sky float 8) + (time float) + (off-s uint16) + (off-t uint16) + (orbit sky-orbit 3 :inline) + (upload-data sky-upload-data :inline) + (ambi-color vector :inline) + (ambi-color-lower vector :inline) + (sun0-color vector :inline) + (sun1-color vector :inline) + (moon-color vector :inline) + (sun0-color-lower vector :inline) + (cam-mat matrix :inline) + (star-mat matrix :inline) + (vec0 vector4w :inline) + (vec1 vector4w :inline) + (cloud-lights cloud-lights :inline) + (haze-lights haze-lights :inline) + (buf dma-buffer) + (stars vector 512 :inline) + (disable-day-star basic) + ) + (:methods + (sky-work-method-9 () none) + (sky-work-method-10 () none) + (sky-work-method-11 () none) + (sky-work-method-12 () none) + (sky-work-method-13 () none) + (sky-work-method-14 () none) + (sky-work-method-15 () none) + (sky-work-method-16 () none) + (sky-work-method-17 () none) + (sky-work-method-18 () none) + (sky-work-method-19 () none) + (sky-work-method-20 () none) + (sky-work-method-21 () none) + (sky-work-method-22 () none) + (sky-work-method-23 () none) + (sky-work-method-24 () none) + (sky-work-method-25 () none) + (sky-work-method-26 () none) + (sky-work-method-27 () none) + (sky-work-method-28 () none) + (sky-work-method-29 () none) + (sky-work-method-30 () none) + (sky-work-method-31 () none) + (sky-work-method-32 () none) + (sky-work-method-33 () none) + (sky-work-method-34 () none) + (sky-work-method-35 () none) + (sky-work-method-36 () none) + ) + ) diff --git a/goal_src/jakx/engine/gfx/sprite/particles/sparticle-h.gc b/goal_src/jakx/engine/gfx/sprite/particles/sparticle-h.gc index 41c5523e6c..8d15643e20 100644 --- a/goal_src/jakx/engine/gfx/sprite/particles/sparticle-h.gc +++ b/goal_src/jakx/engine/gfx/sprite/particles/sparticle-h.gc @@ -5,5 +5,123 @@ ;; name in dgo: sparticle-h ;; dgos: ENGINE, GAME +;; +++sp-cpuinfo-flag +(defenum sp-cpuinfo-flag + :bitfield #t + :type uint32 + ;; todo copied from jak 2 + (sp-cpuinfo-flag-0 0) + (sp-cpuinfo-flag-1 1) + (sp-cpuinfo-flag-2 2) ;; cleared after an aux has its func set to add-to-sprite-aux-lst + (sp-cpuinfo-flag-3 3) + (sp-cpuinfo-flag-4 4) + (sp-cpuinfo-flag-5 5) + (ready-to-launch 6) ;; maybe just just death? + (distort 7) ;; distort sprite + (aux-list 8) ;; prevents relaunch, adds to aux + (sp-cpuinfo-flag-9 9) + (level0 10) + (level1 11) + (sp-cpuinfo-flag-12 12) ;; required to relaunch + (sp-cpuinfo-flag-13 13) + (sp-cpuinfo-flag-14 14) + (glow 15) ;; glow sprite + (use-global-acc 16) + (launch-along-z 17) + (left-multiply-quat 18) + (right-multiply-quat 19) + (set-conerot 20) + (sp-cpuinfo-flag-21 21) + ) +;; ---sp-cpuinfo-flag + +;; +++sp-cpuinfo-flag-s32 +(defenum sp-cpuinfo-flag-s32 + :bitfield #t + :type int32 + :copy-entries sp-cpuinfo-flag + ) +;; ---sp-cpuinfo-flag-s32 + ;; DECOMP BEGINS +(define *sp-60-hz* #t) + +(deftype sparticle-cpuinfo (structure) + "The per-particle information. This stays on the CPU, and isn't uploaded to the VU." + ((sprite sprite-vec-data-2d) + (adgif adgif-shader) + (radius float) + (omega float) + (vel-sxvel vector :inline) + (rot-syvel vector :inline) + (fade rgbaf :inline) + (acc vector :inline) + (rotvel3d quaternion :inline) + (vel vector3s :inline :overlay-at (-> vel-sxvel data 0)) + (accel vector3s :inline :overlay-at (-> acc data 0)) + (scalevelx float :overlay-at (-> vel-sxvel data 3)) + (scalevely float :overlay-at (-> rot-syvel data 3)) + (friction float) + (timer int32) + (flags sp-cpuinfo-flag) + (flags-s32 sp-cpuinfo-flag-s32 :overlay-at flags) + (user-int32 int32) + (user-uint32 uint32 :overlay-at user-int32) + (user-float float :overlay-at user-int32) + (user-pntr uint32 :overlay-at user-int32) + (user-object basic :overlay-at user-int32) + (user-sprite sprite-vec-data-2d :overlay-at user-int32) + (sp-func (function sparticle-system sparticle-cpuinfo sprite-vec-data-3d uint none)) + (next-time uint32) + (next-launcher basic) + (cache-alpha float) + (valid uint8) + (clock-index uint8) + (user1-int16 uint16) + (key sparticle-launch-control) + (binding sparticle-launch-state) + (data uint32 1 :overlay-at omega) + (datab int8 4 :overlay-at omega) + (dataf float 1 :overlay-at omega) + (datac uint8 1 :overlay-at omega) + ) + ) + + +(deftype sparticle-launchinfo (structure) + "Settings for launching a particle. These are a temporary thing consumed by the assembly particle code, and modified by particle callbacks." + ((launchrot vector :inline) + (conerot vector :inline) + (rotate-x float) + (rotate-y float) + (rotate-z float) + (coneradius float) + (rotate vector :inline :overlay-at rotate-x) + (scale-x float) + (scale-y float) + (scale-z float) + (dummy float) + (scale vector :inline :overlay-at scale-x) + (data uint8 1 :overlay-at (-> launchrot data 0)) + ) + ) + + +(deftype sparticle-system (basic) + "An entire particle 'system', which is a pipeline for spawning, updating, and generating sprite-renderer DMA data. +There are separate systems for different modes of sprite rendering: 2D/billboard, full 3D, and screen-space (HUD)" + ((blocks int32 2) + (length int32 2) + (num-alloc int32 2) + (is-3d basic) + (flags uint32) + (alloc-table (pointer uint64)) + (cpuinfo-table (inline-array sparticle-cpuinfo)) + (vecdata-table pointer) + (adgifdata-table (inline-array adgif-shader)) + ) + (:methods + (new (symbol type int int symbol pointer (inline-array adgif-shader)) _type_) + ) + ) diff --git a/goal_src/jakx/engine/gfx/sprite/particles/sparticle-launcher-h.gc b/goal_src/jakx/engine/gfx/sprite/particles/sparticle-launcher-h.gc index e7ec4c28c1..ff32487b04 100644 --- a/goal_src/jakx/engine/gfx/sprite/particles/sparticle-launcher-h.gc +++ b/goal_src/jakx/engine/gfx/sprite/particles/sparticle-launcher-h.gc @@ -5,5 +5,374 @@ ;; name in dgo: sparticle-launcher-h ;; dgos: ENGINE, GAME +(declare-type sprite-vec-data-3d structure) +(declare-type sparticle-cpuinfo structure) +(declare-type sparticle-system structure) + +;; +++sp-field-id +(defenum sp-field-id + :type uint16 + ;; todo copied from jak 2 + (misc-fields-start 0) + (spt-texture 1) + (spt-anim 2) + (spt-anim-speed 3) + (spt-birth-func 4) + (spt-joint/refpoint 5) + (spt-num 6) + (spt-sound 7) + (misc-fields-end 8) + + (sprite-fields-start 9) + (spt-x 10) + (spt-y 11) + (spt-z 12) + (spt-scale-x 13) + (spt-rot-x 14) + (spt-rot-y 15) + (spt-rot-z 16) + (spt-scale-y 17) + (spt-r 18) + (spt-g 19) + (spt-b 20) + (spt-a 21) + (sprite-fields-end 22) + + (cpu-fields-start 23) + (spt-omega 24) + (spt-vel-x 25) + (spt-vel-y 26) + (spt-vel-z 27) + (spt-scalevel-x 28) + (spt-rotvel-x 29) + (spt-rotvel-y 30) + (spt-rotvel-z 31) + (spt-scalevel-y 32) + (spt-fade-r 33) + (spt-fade-g 34) + (spt-fade-b 35) + (spt-fade-a 36) + (spt-accel-x 37) + (spt-accel-y 38) + (spt-accel-z 39) + (spt-dummy 40) + (spt-quat-x 41) + (spt-quat-y 42) + (spt-quat-z 43) + (spt-quad-w 44) + (spt-friction 45) + (spt-timer 46) + (spt-flags 47) + (spt-userdata 48) + (spt-func 49) + (spt-next-time 50) + (spt-next-launcher 51) + (cpu-fields-end 52) + + (launch-fields-start 53) + (spt-launchrot-x 54) + (spt-launchrot-y 55) + (spt-launchrot-z 56) + (spt-launchrot-w 57) + (spt-conerot-x 58) + (spt-conerot-y 59) + (spt-conerot-z 60) + (spt-conerot-w 61) + (spt-rotate-x 62) + (spt-rotate-y 63) + (spt-rotate-z 64) + + (spt-conerot-radius 65) + (spt-mat-scale-x 66) + (spt-mat-scale-y 67) + (spt-mat-scale-z 68) + (launch-fields-end 69) + + (spt-scale 70) + (spt-scalevel 71) + (spt-end 72) + ) +;; ---sp-field-id + +;; +++sp-flag +(defenum sp-flag + :type uint16 + ;; todo copied from jak 2 + (int 0) ;; int + (float 1) ;; float + (float-int-rand 2) ;; float with int rand + (copy-from-other 3) ;; copy + (object 4) ;; label + (symbol 5) ;; symbol + (launcher 6) ;; launcher from id + (float-store 7) ;; float and store result in *sp-temp* + ) +;; ---sp-flag + +;; +++sp-group-item-flag +(defenum sp-group-item-flag + :bitfield #t + :type uint16 + (is-3d) + (sp1) + (sp2) + (sp3) + (sp4) + (sp5) + (sp6) + (sp7) + (sp8) + (sp9) + (sp10) + (sp11) + (sp12) + (sp13) + (sp14) + (sp15) + ) +;; ---sp-group-item-flag + +;; +++sp-launch-state-flags +(defenum sp-launch-state-flags + :bitfield #t + :type uint16 + (sp0) + (sp1) + (sp2) + ) +;; ---sp-launch-state-flags + +;; +++sp-group-flag +(defenum sp-group-flag + :bitfield #t + :type uint16 + (sp0) + (sp1) + (sp2) + (sp3) + (sp4) + (sp5) + (sp6) + (sp7) + (sp8) + (sp9) + (sp10) + (sp11) + (sp12) + (sp13) + (sp14) + (sp15) + ) +;; ---sp-group-flag + ;; DECOMP BEGINS +(deftype sparticle-birthinfo (structure) + "Used internally by the sparticle code." + ((sprite uint32) + (anim int32) + (anim-speed float) + (birth-func basic) + (joint-ppoint int32) + (num-to-birth float) + (dataf float 1 :overlay-at sprite) + (data uint32 1 :overlay-at sprite) + ) + ) + + +(deftype sp-field-init-spec (structure) + "Part of a particle definition - how to initialize a field of a particle." + ((field sp-field-id) + (flags sp-flag) + (initial-valuef float) + (random-rangef float) + (random-multf float) + (initial-value int32 :overlay-at initial-valuef) + (random-range int32 :overlay-at random-rangef) + (random-mult int32 :overlay-at random-multf) + (func symbol :overlay-at initial-valuef) + (tex texture-id :overlay-at initial-valuef) + (pntr pointer :overlay-at initial-valuef) + (object basic :overlay-at initial-valuef) + (sym symbol :overlay-at initial-valuef) + ) + :allow-misaligned + ) + + +(deftype sparticle-launcher (basic) + "A definition of a single particle, as a list of init specs." + ((birthaccum float) + (soundaccum float) + (init-specs (inline-array sp-field-init-spec)) + ) + (:methods + (get-field-spec-by-id (_type_ sp-field-id) sp-field-init-spec) + (setup-special-textures (_type_ string) none) + ) + ) + + +(deftype sparticle-group-item (structure) + "A reference to a single sparticle-launcher (by ID) and some parameters for using it." + ((launcher uint32) + (fade-after meters) + (falloff-to meters) + (flags sp-group-item-flag) + (period uint16) + (length uint16) + (offset int16) + (hour-mask uint32) + (binding uint32) + ) + ) + + +(deftype sparticle-launch-state (structure) + "The state associated with a launcher of a given sparticle." + ((group-item sparticle-group-item) + (flags sp-launch-state-flags) + (randomize uint16) + (center vector) + (sprite3d sprite-vec-data-3d) + (sprite sparticle-cpuinfo) + (offset uint32) + (accum float) + (spawn-time uint32) + (control sparticle-launch-control) + (swarm basic :overlay-at offset) + (seed uint32 :overlay-at accum) + (time uint32 :overlay-at spawn-time) + (spec basic :overlay-at sprite) + (id uint32 :overlay-at sprite3d) + ) + ) + + +(deftype sparticle-launch-group (basic) + "Definition of multiple a particle-group, which is a collection of particle effects." + ((length int16) + (duration uint16) + (linger-duration uint16) + (flags sp-group-flag) + (name string) + (launcher (inline-array sparticle-group-item)) + (rotate-x degrees) + (rotate-y degrees) + (rotate-z degrees) + (scale-x float) + (scale-y float) + (scale-z float) + (bounds sphere :inline) + ) + (:methods + (create-launch-control (_type_ process) sparticle-launch-control) + ) + ) + + +(define *launch-matrix* (matrix-identity! (new 'global 'matrix))) + +(deftype sparticle-launch-control (inline-array-class) + "Top-level type containing all the state needed to launch a particle group. +These are typically owned by a process, and allocated on the process heap. +These refer to static particle definitions, and then spawn particles that are tracked by the +particle system itself. This type just holds the launching-related state." + ((group sparticle-launch-group) + (proc process-drawable) + (local-clock int32) + (local-space-binding particle-local-space-info :offset 28) + (matrix int8) + (pointer-control uint32) + (last-spawn-frame int32) + (last-spawn-time int32) + (origin matrix :inline) + (center vector :inline :overlay-at (-> origin data 12)) + (data sparticle-launch-state :inline :dynamic) + ) + (:methods + (sparticle-launch-control-method-14 () none) + (sparticle-launch-control-method-15 () none) + (sparticle-launch-control-method-16 () none) + (sparticle-launch-control-method-17 () none) + (sparticle-launch-control-method-18 () none) + (sparticle-launch-control-method-19 () none) + (sparticle-launch-control-method-20 () none) + (sparticle-launch-control-method-21 () none) + ) + ) + + +(set! (-> sparticle-launch-control heap-base) (the-as uint 48)) + +(deftype sparticle-subsampler (basic) + ((min-emit float) + (accum float) + (spt-num float) + (sp-system sparticle-system) + (part-id uint32) + (spawn-mat matrix :inline) + (inited? symbol) + (per-meter-method? symbol) + ) + (:methods + (new (symbol type sparticle-system uint float symbol float) _type_) + (sparticle-subsampler-method-9 () none) + (sparticle-subsampler-method-10 () none) + ) + ) + + +(defmethod new sparticle-subsampler ((allocation symbol) + (type-to-make type) + (arg0 sparticle-system) + (arg1 uint) + (arg2 float) + (arg3 symbol) + (arg4 float) + ) + (let ((s1-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (if (zero? s1-0) + (go process-drawable-art-error "sparticle-subsampler") + ) + (set! (-> s1-0 per-meter-method?) arg3) + (set! (-> s1-0 part-id) arg1) + (set! (-> s1-0 inited?) #f) + (set! (-> s1-0 sp-system) arg0) + (set! (-> s1-0 spt-num) arg2) + (set! (-> s1-0 min-emit) arg4) + (matrix-identity! (-> s1-0 spawn-mat)) + s1-0 + ) + ) + +(defun compute-rot-in-screenspace ((arg0 vector)) + 0.0 + (let ((a0-1 (-> (math-camera-matrix) fvec))) + 0.0 + (let ((v1-0 (new 'stack-no-clear 'vector))) + (let ((f0-3 (vector-dot a0-1 arg0))) + (vector-float*! v1-0 a0-1 f0-3) + ) + (vector-! arg0 arg0 v1-0) + ) + ) + (let ((a2-1 (matrix-transpose! (new 'stack-no-clear 'matrix) (math-camera-matrix)))) + (vector-matrix*! arg0 arg0 a2-1) + ) + (the float (sar (shl (the int (atan (-> arg0 y) (* -1.0 (-> arg0 x)))) 48) 48)) + ) + +(deftype particle-birth-work (structure) + ((quat quaternion :inline) + (vel-range vector 2 :inline) + (vel vector :inline :overlay-at (-> vel-range 0)) + (pos-range vector 2 :inline) + (pos vector :inline :overlay-at (-> pos-range 0)) + (d-pos vector :inline :overlay-at (-> pos-range 1)) + (mat matrix :inline) + (tt float) + (t-step float) + ) + ) diff --git a/goal_src/jakx/engine/gfx/sprite/simple-sprite-h.gc b/goal_src/jakx/engine/gfx/sprite/simple-sprite-h.gc index d0acedfcfe..787a6218b8 100644 --- a/goal_src/jakx/engine/gfx/sprite/simple-sprite-h.gc +++ b/goal_src/jakx/engine/gfx/sprite/simple-sprite-h.gc @@ -7,3 +7,43 @@ ;; DECOMP BEGINS +(deftype sprite-glow-data (structure) + ((position vector :inline) + (size-x float :overlay-at (-> position data 3)) + (size-probe float :offset 16) + (z-offset float) + (rot-angle float) + (size-y float) + (color rgbaf :inline) + (fade-a float) + (fade-b float) + (tex-id texture-id) + (dummy uint32) + (quads vector 4 :inline :overlay-at position) + ) + (:methods + (set-trans (_type_ vector) none) + ) + ) + + +(defmethod set-trans ((this sprite-glow-data) (arg0 vector)) + (let ((f0-0 (-> this position w))) + (set! (-> this position quad) (-> arg0 quad)) + (set! (-> this position w) f0-0) + ) + 0 + (none) + ) + +(deftype simple-sprite-system (structure) + ((count int16) + (max-count int16) + (data (inline-array sprite-glow-data)) + ) + (:methods + (add! (_type_ sprite-glow-data) none) + (draw-all-sprites! (_type_ dma-buffer) none) + (clear! (_type_) none) + ) + ) diff --git a/goal_src/jakx/engine/gfx/sprite/sprite-h.gc b/goal_src/jakx/engine/gfx/sprite/sprite-h.gc index c2522c82fc..088e5b988d 100644 --- a/goal_src/jakx/engine/gfx/sprite/sprite-h.gc +++ b/goal_src/jakx/engine/gfx/sprite/sprite-h.gc @@ -7,3 +7,81 @@ ;; DECOMP BEGINS +(deftype sprite-vec-data-2d (structure) + "Per-particle data needed for rendering. This is sent to VU1." + ((x-y-z-sx vector :inline) + (flag-rot-sy vector :inline) + (r-g-b-a vector :inline) + (x float :overlay-at (-> x-y-z-sx data 0)) + (y float :overlay-at (-> x-y-z-sx data 1)) + (z float :overlay-at (-> x-y-z-sx data 2)) + (sx float :overlay-at (-> x-y-z-sx data 3)) + (sy float :overlay-at (-> flag-rot-sy data 3)) + (rot float :overlay-at (-> flag-rot-sy data 2)) + (flag int32 :overlay-at (-> flag-rot-sy data 0)) + (matrix int32 :overlay-at (-> flag-rot-sy data 1)) + (warp-turns int32 :overlay-at (-> flag-rot-sy data 0)) + (r float :overlay-at (-> r-g-b-a data 0)) + (g float :overlay-at (-> r-g-b-a data 1)) + (b float :overlay-at (-> r-g-b-a data 2)) + (a float :overlay-at (-> r-g-b-a data 3)) + (trans vector3s :inline :overlay-at (-> x-y-z-sx data 0)) + (color rgbaf :inline :overlay-at (-> r-g-b-a data 0)) + (data uint128 1 :overlay-at (-> x-y-z-sx data 0)) + (data64 uint64 6 :overlay-at (-> x-y-z-sx data 0)) + ) + ) + + +(deftype sprite-array-2d (basic) + "Array of sprite data for all 2D sprites. There are two groups: normal and HUD." + ((num-sprites int32 2) + (num-valid int32 2) + (vec-data pointer) + (adgif-data (inline-array adgif-shader)) + (pad uint128 4) + (data uint128 1) + ) + (:methods + (new (symbol type int int) _type_) + ) + ) + + +(deftype sprite-vec-data-3d (structure) + "Per-particle data needed for rendering. This is sent to VU1." + ((x-y-z-sx vector :inline) + (qx-qy-qz-sy vector :inline) + (r-g-b-a vector :inline) + (x float :overlay-at (-> x-y-z-sx data 0)) + (y float :overlay-at (-> x-y-z-sx data 1)) + (z float :overlay-at (-> x-y-z-sx data 2)) + (sx float :overlay-at (-> x-y-z-sx data 3)) + (sy float :overlay-at (-> qx-qy-qz-sy data 3)) + (qx float :overlay-at (-> qx-qy-qz-sy data 0)) + (qy float :overlay-at (-> qx-qy-qz-sy data 1)) + (qz float :overlay-at (-> qx-qy-qz-sy data 2)) + (r float :overlay-at (-> r-g-b-a data 0)) + (g float :overlay-at (-> r-g-b-a data 1)) + (b float :overlay-at (-> r-g-b-a data 2)) + (a float :overlay-at (-> r-g-b-a data 3)) + (trans vector3s :inline :overlay-at (-> x-y-z-sx data 0)) + (rot vector3s :inline :overlay-at (-> qx-qy-qz-sy data 0)) + (color rgbaf :inline :overlay-at (-> r-g-b-a data 0)) + (data uint128 1 :overlay-at (-> x-y-z-sx data 0)) + ) + ) + + +(deftype sprite-array-3d (basic) + "Array of sprite data for all 3D sprites. There are two groups, but only the first is used." + ((num-sprites int32 2) + (num-valid int32 2) + (vec-data pointer) + (adgif-data (inline-array adgif-shader)) + (data uint128 1) + ) + (:methods + (new (symbol type int int) _type_) + ) + ) diff --git a/goal_src/jakx/engine/gfx/texture/texture-anim-h.gc b/goal_src/jakx/engine/gfx/texture/texture-anim-h.gc index 889d93f86e..ac99b1d170 100644 --- a/goal_src/jakx/engine/gfx/texture/texture-anim-h.gc +++ b/goal_src/jakx/engine/gfx/texture/texture-anim-h.gc @@ -7,3 +7,445 @@ ;; DECOMP BEGINS +(deftype texture-anim-layer (structure) + ((interpolated-color vector :inline) + (interpolated-scale-offset vector :inline) + (interpolated-st-scale-offset vector :inline) + (interpolated-qs vector :inline) + (interpolated-rot vector :inline) + (extra vector :inline :offset 240) + (func (function dma-buffer uint int int texture-anim-layer float int)) + (func-id symbol :overlay-at func) + (init-func (function texture-anim-layer int)) + (init-func-id symbol :overlay-at init-func) + (tex texture) + (start-time float) + (end-time float) + (tex-name string) + (test gs-test) + (alpha gs-alpha) + (clamp gs-clamp) + (start-vectors vector 5 :inline :offset 80) + (start-color vector :inline :overlay-at (-> start-vectors 0)) + (start-scale vector2 :inline :offset 96) + (start-offset vector2 :inline :offset 104) + (start-st-scale vector2 :inline :offset 112) + (start-st-offset vector2 :inline :offset 120) + (start-qs vector :inline :overlay-at (-> start-vectors 3)) + (start-rot degrees :offset 144) + (start-st-rot degrees :offset 148) + (end-vectors vector 5 :inline :offset 160) + (end-color vector :inline :overlay-at (-> end-vectors 0)) + (end-scale vector2 :inline :offset 176) + (end-offset vector2 :inline :offset 184) + (end-st-scale vector2 :inline :offset 192) + (end-st-offset vector2 :inline :offset 200) + (end-qs vector :inline :overlay-at (-> end-vectors 3)) + (end-rot degrees :offset 224) + (end-st-rot degrees :offset 228) + ) + (:methods + (initialize-texture! (_type_) _type_) + (clear-texture! (_type_) _type_) + ) + ) + + +(deftype texture-anim (structure) + ((num-layers uint32) + (func (function dma-buffer texture-anim int)) + (func-id symbol :overlay-at func) + (init-func (function texture-anim int)) + (init-func-id symbol :overlay-at init-func) + (mip-func basic) + (mip-func-id basic :overlay-at mip-func) + (time-func basic) + (time-func-id basic :overlay-at time-func) + (tex texture) + (tex-name string) + (extra vector :inline) + (color rgba) + (frame-time float) + (frame-delta float) + (frame-mod float) + (test uint64) + (alpha uint64) + (clamp uint64) + (data texture-anim-layer :dynamic) + ) + (:methods + (texture-anim-method-9 () none) + (texture-anim-method-10 () none) + ) + ) + + +(deftype texture-anim-array (array) + ((array-data texture-anim :dynamic) + ) + (:methods + (init! (_type_) _type_) + (clear! (_type_) _type_) + ) + ) + + +(deftype texture-anim-work (structure) + ((erase-tmpl dma-gif-packet :inline) + (draw-tmpl dma-gif-packet :inline) + (draw2-tmpl dma-gif-packet :inline) + (sprite-tmpl dma-gif-packet :inline) + (fill-tmpl dma-gif-packet :inline) + (adgif-tmpl dma-gif-packet :inline) + (corner0 vector :inline) + (corner1 vector :inline) + (corner2 vector :inline) + (corner3 vector :inline) + (const vector :inline) + (color vector4w :inline) + (random vector4w 8 :inline) + (random-index uint8) + (color80808040 vector4w :inline) + (color80808060 vector4w :inline) + (color80808000 vector4w :inline) + (st0000 vector :inline) + (st0505 vector :inline) + (st1010 vector :inline) + (uv00 vector4w :inline) + (uv44 vector4w :inline) + (uv88 vector4w :inline) + (uv1010 vector4w :inline) + (uv2020 vector4w :inline) + (uv4040 vector4w :inline) + (uv8080 vector4w :inline) + (xy0000 vector4w :inline) + (xy4040 vector4w :inline) + (xy0040 vector4w :inline) + (xy2060 vector4w :inline) + (xy2040 vector4w :inline) + (xy3050 vector4w :inline) + (xy3040 vector4w :inline) + (xy3848 vector4w :inline) + (xy3840 vector4w :inline) + (xy4048 vector4w :inline) + (xy3048 vector4w :inline) + (xy3850 vector4w :inline) + (xy4060 vector4w :inline) + ) + ) + + +(deftype clut16x16 (structure) + ((clut rgba 256) + ) + ) + + +(deftype noise8x8 (structure) + ((image uint8 64) + ) + ) + + +(deftype noise16x16 (structure) + ((image uint8 256) + ) + ) + + +(deftype noise32x32 (structure) + ((image uint8 1024) + ) + ) + + +(deftype noise64x64 (structure) + ((image uint8 4096) + ) + ) + + +(deftype noise128x128 (structure) + ((image uint8 16384) + ) + ) + + +(deftype fog8x256 (structure) + ((image uint8 256) + ) + ) + + +(deftype fog-texture-work (structure) + ((fog-height float) + (fog-near float) + (fog-far float) + (fog-delta float) + (alpha-near float) + (alpha-far float) + (alpha-delta float) + (color rgba) + ) + ) + + +(define *clut-translate* (new 'static 'array uint8 256 + #x0 + #x1 + #x2 + #x3 + #x4 + #x5 + #x6 + #x7 + #x10 + #x11 + #x12 + #x13 + #x14 + #x15 + #x16 + #x17 + #x8 + #x9 + #xa + #xb + #xc + #xd + #xe + #xf + #x18 + #x19 + #x1a + #x1b + #x1c + #x1d + #x1e + #x1f + #x20 + #x21 + #x22 + #x23 + #x24 + #x25 + #x26 + #x27 + #x30 + #x31 + #x32 + #x33 + #x34 + #x35 + #x36 + #x37 + #x28 + #x29 + #x2a + #x2b + #x2c + #x2d + #x2e + #x2f + #x38 + #x39 + #x3a + #x3b + #x3c + #x3d + #x3e + #x3f + #x40 + #x41 + #x42 + #x43 + #x44 + #x45 + #x46 + #x47 + #x50 + #x51 + #x52 + #x53 + #x54 + #x55 + #x56 + #x57 + #x48 + #x49 + #x4a + #x4b + #x4c + #x4d + #x4e + #x4f + #x58 + #x59 + #x5a + #x5b + #x5c + #x5d + #x5e + #x5f + #x60 + #x61 + #x62 + #x63 + #x64 + #x65 + #x66 + #x67 + #x70 + #x71 + #x72 + #x73 + #x74 + #x75 + #x76 + #x77 + #x68 + #x69 + #x6a + #x6b + #x6c + #x6d + #x6e + #x6f + #x78 + #x79 + #x7a + #x7b + #x7c + #x7d + #x7e + #x7f + #x80 + #x81 + #x82 + #x83 + #x84 + #x85 + #x86 + #x87 + #x90 + #x91 + #x92 + #x93 + #x94 + #x95 + #x96 + #x97 + #x88 + #x89 + #x8a + #x8b + #x8c + #x8d + #x8e + #x8f + #x98 + #x99 + #x9a + #x9b + #x9c + #x9d + #x9e + #x9f + #xa0 + #xa1 + #xa2 + #xa3 + #xa4 + #xa5 + #xa6 + #xa7 + #xb0 + #xb1 + #xb2 + #xb3 + #xb4 + #xb5 + #xb6 + #xb7 + #xa8 + #xa9 + #xaa + #xab + #xac + #xad + #xae + #xaf + #xb8 + #xb9 + #xba + #xbb + #xbc + #xbd + #xbe + #xbf + #xc0 + #xc1 + #xc2 + #xc3 + #xc4 + #xc5 + #xc6 + #xc7 + #xd0 + #xd1 + #xd2 + #xd3 + #xd4 + #xd5 + #xd6 + #xd7 + #xc8 + #xc9 + #xca + #xcb + #xcc + #xcd + #xce + #xcf + #xd8 + #xd9 + #xda + #xdb + #xdc + #xdd + #xde + #xdf + #xe0 + #xe1 + #xe2 + #xe3 + #xe4 + #xe5 + #xe6 + #xe7 + #xf0 + #xf1 + #xf2 + #xf3 + #xf4 + #xf5 + #xf6 + #xf7 + #xe8 + #xe9 + #xea + #xeb + #xec + #xed + #xee + #xef + #xf8 + #xf9 + #xfa + #xfb + #xfc + #xfd + #xfe + #xff + ) + ) diff --git a/goal_src/jakx/engine/gfx/texture/texture-h.gc b/goal_src/jakx/engine/gfx/texture/texture-h.gc index 950daa92dc..46c6671c27 100644 --- a/goal_src/jakx/engine/gfx/texture/texture-h.gc +++ b/goal_src/jakx/engine/gfx/texture/texture-h.gc @@ -5,5 +5,1404 @@ ;; name in dgo: texture-h ;; dgos: ENGINE, GAME +(declare-type texture-page basic) +(declare-type texture-pool basic) +(declare-type fog-texture-work structure) +(declare-type adgif-shader structure) +(declare-type texture basic) +(declare-type texture-id uint32) +(declare-type texture-anim-array array) +(declare-type texture-anim structure) +(define-extern adgif-shader<-texture-simple! (function adgif-shader texture adgif-shader)) +(define-extern lookup-texture-by-id-fast (function texture-id texture)) +(define-extern *edit-shader* texture-id) +(define-extern adgif-shader-update! (function adgif-shader texture none)) +(declare-type texture-page-dir basic) +(define-extern texture-page-dir-inspect (function texture-page-dir symbol none)) +(define-extern *texture-pool* texture-pool) +(define-extern *fog-texture-work* fog-texture-work) +(define-extern *skull-gem-texture-anim-array* (texture-anim-array texture-anim)) + +;; +++tex-upload-mode +(defenum tex-upload-mode + (none -3) + (seg0-1 -2) + (seg0-1-2 -1) + (seg0 0) + (seg2 2) + ) +;; ---tex-upload-mode + + +;; +++link-test-flags +(defenum link-test-flags + :type uint32 + :bitfield #t + (needs-log-in 8) + (bit-9 9) + (backup-sprite-tex 10) ;; set when particle-setup-adgif fails texture lookup. + ) +;; ---link-test-flags + ;; DECOMP BEGINS +(deftype texture-id (uint32) + "Unique identifier for a texture +as the tpage number and index of the texture within the tpage." + ((index uint16 :offset 8 :size 12) + (page uint16 :offset 20 :size 12) + ) + ) + + +(deftype texture-pool-segment (structure) + "A chunk of VRAM." + ((dest uint32) + (size uint32) + ) + :pack-me + :allow-misaligned + ) + + +(deftype texture-pool (basic) + "The manager for the VRAM." + ((top int32) + (cur int32) + (allocate-func (function texture-pool texture-page kheap int texture-page)) + (font-palette int32) + (segment texture-pool-segment 4 :inline) + (segment-near texture-pool-segment :inline :overlay-at (-> segment 0)) + (segment-common texture-pool-segment :inline :overlay-at (-> segment 1)) + (common-page texture-page 32) + (common-page-mask int32) + (update-sprites-flag symbol) + (update-flag symbol) + (texture-enable-user texture-enable-mask) + (texture-enable-user-menu texture-enable-mask) + (ids uint32 128) + ) + (:methods + (new (symbol type) _type_) + (texture-pool-method-9 () none) + (texture-pool-method-10 () none) + (texture-pool-method-11 () none) + (texture-pool-method-12 () none) + (texture-pool-method-13 () none) + (texture-pool-method-14 () none) + (texture-pool-method-15 () none) + (texture-pool-method-16 () none) + (texture-pool-method-17 () none) + (texture-pool-method-18 () none) + (texture-pool-method-19 () none) + (texture-pool-method-20 () none) + (texture-pool-method-21 () none) + (texture-pool-method-22 () none) + (texture-pool-method-23 () none) + (texture-pool-method-24 () none) + (texture-pool-method-25 () none) + (texture-pool-method-26 () none) + (texture-pool-method-27 () none) + ) + ) + + +(deftype texture-mask (structure) + "Mask where each bit indicates if some part of a tpage is used, by a texture. +Additionally, the w component holds a minimum distance. The texture is only needed +if the distance to the object is smaller than this." + ((mask vector4w :inline) + (dist float :overlay-at (-> mask data 3)) + (long uint64 2 :overlay-at (-> mask data 0)) + (quad uint128 :overlay-at (-> mask data 0)) + ) + ) + + +(deftype texture-masks (structure) + "Grouping of three masks, corresponding to the 3 segments of the texture. +So mask 0 is needed if segment 0 of the texture is needed, etc..." + ((data texture-mask 3 :inline) + (level basic :overlay-at (-> data 0 mask data 2)) + ) + ) + + +(deftype texture-masks-array (inline-array-class) + "Group of all texture-masks for a given tpage." + ((data texture-masks :inline :dynamic) + ) + ) + + +(set! (-> texture-masks-array heap-base) (the-as uint 48)) + +(define *texture-masks* (the-as texture-masks #f)) + +(define *texture-masks-array* (the-as texture-masks-array #f)) + +(deftype texture (basic) + "Metadata for a texture." + ((w int16) + (h int16) + (num-mips uint8) + (tex1-control uint8) + (psm gs-psm) + (mip-shift uint8) + (clutpsm uint16) + (dest uint16 7) + (clutdest uint16) + (width uint8 7) + (name string) + (size uint32) + (uv-dist float) + (pad uint32 3) + (masks texture-masks :inline) + ) + ) + + +(deftype texture-page-segment (structure) + "Metadata for a 'segment' of a texture page. +Each texture page has 3 segments - smaller number segments have higher detail mips." + ((block-data pointer) + (size uint32) + (dest uint32) + ) + :pack-me + :allow-misaligned + ) + + +(defun texture-mip->segment ((arg0 int) (arg1 int)) + (if (>= 2 arg1) + (+ (- -1 arg0) arg1) + (max 0 (- 2 arg0)) + ) + ) + +(deftype texture-page (basic) + "A collection of textures. There is a tpage per category per level. +These tpages are loaded from the DVD. +e.g.: prison tfrag is its own tpage. +The tpage has multiple textures, and 3 segments. +Lower number segments are larger and have hi-res versions of textures." + ((info file-info) + (name string) + (id uint32) + (length int32) + (mip0-size uint32) + (size uint32) + (segment texture-page-segment 3 :inline) + (dram-size uint32) + (vram-size uint32) + (pad uint32 14) + (data texture :dynamic) + ) + (:methods + (texture-page-method-9 () none) + (texture-page-method-10 () none) + (texture-page-method-11 () none) + (texture-page-method-12 () none) + (texture-page-method-13 () none) + (texture-page-method-14 () none) + ) + ) + + +(deftype shader-ptr (uint32) + "A pointer to an adgif-shader, stored in bits 8-32. This allows them to fit into +an adgif shader easily." + ((first-8 uint8 :offset 0 :size 8) + (shader uint32 :offset 8 :size 24) + ) + ) + +(deftype texture-link (structure) + "An overlay structure containing a shader-ptr that points to the next adgif-shader +in a linked list." + ((next shader-ptr 1) + ) + ) + + +(deftype texture-page-dir-entry (structure) + "An entry for a texture in the texture-page-dir. +The texture-page-dir contains an entry for each tpage. +Each entry contains a reference to the tpage, and a linked list of shaders +using it." + ((length int16) + (status uint16) + (page texture-page) + (link texture-link) + ) + :pack-me + :allow-misaligned + ) + + +(deftype texture-page-dir (basic) + "The list of all texture pages. +This is static data loaded from the DVD at boot." + ((length int32) + (entries texture-page-dir-entry 1 :inline) + ) + (:methods + (relocate (_type_ kheap (pointer uint8)) none :replace) + (unlink-shaders-in-heap (_type_ kheap) int) + (texture-page-dir-method-10 (_type_) none) + ) + ) + +(deftype texture-relocate-later (basic) + "Unused in Jak 2, but metadata for postponing tpage copies until a second frame, +to have a smaller impact on frame times when loading." + ((memcpy symbol) + (dest uint32) + (source uint32) + (move uint32) + (entry texture-page-dir-entry) + (page texture-page) + ) + ) + + +(define *texture-relocate-later* (new 'global 'texture-relocate-later)) + +(set! (-> *texture-relocate-later* memcpy) #f) + +(define *texture-page-dir* (the-as texture-page-dir #f)) + +(deftype adgif-shader (structure) + "GS texturing/blending settings, called adgif-shader. +These are used by many different renderers and partially managed by the texture system. +For example, the texture system will automatically update tbp to point to the location +of the texture." + ((quad qword 5 :inline) + (prims gs-reg64 10 :overlay-at quad) + (reg-0 gs-reg :overlay-at (-> quad 0 data 2)) + (reg-1 gs-reg :overlay-at (-> prims 3)) + (reg-2 gs-reg :overlay-at (-> prims 5)) + (reg-3 gs-reg :overlay-at (-> prims 7)) + (reg-4 gs-reg :overlay-at (-> prims 9)) + (tex0 gs-tex0 :overlay-at (-> quad 0 data 0)) + (tex1 gs-tex1 :overlay-at (-> prims 2)) + (miptbp1 gs-miptbp :overlay-at (-> prims 4)) + (clamp gs-clamp :overlay-at (-> prims 6)) + (clamp-reg gs-reg64 :overlay-at reg-3) + (alpha gs-miptbp :overlay-at (-> prims 8)) + (link-test link-test-flags :overlay-at (-> quad 0 data 2)) + (texture-id texture-id :overlay-at reg-1) + (next shader-ptr :overlay-at reg-2) + (alpha-as-miptb2 gs-miptbp :overlay-at alpha) + (reg-4-u32 gs-reg32 :overlay-at reg-4) + ) + ) + + +(deftype adgif-shader-array (inline-array-class) + ((data adgif-shader :inline :dynamic) + ) + ) + + +(set! (-> adgif-shader-array heap-base) (the-as uint 80)) + +(deftype texture-base (structure) + "Metadata about an area of VRAM set aside for fancy dynamic texture effects +(sky, eye, etc)." + ((vram-page uint32) + (vram-block uint32) + (vram-word uint32) + ) + ) + + +(define ct32-24-block-table (new 'static 'boxed-array :type int32 + 0 + 1 + 4 + 5 + 16 + 17 + 20 + 21 + 2 + 3 + 6 + 7 + 18 + 19 + 22 + 23 + 8 + 9 + 12 + 13 + 24 + 25 + 28 + 29 + 10 + 11 + 14 + 15 + 26 + 27 + 30 + 31 + ) + ) + +(define mz32-24-block-table (new 'static 'boxed-array :type int32 + 16 + 17 + 20 + 21 + 0 + 1 + 4 + 5 + 18 + 19 + 22 + 23 + 2 + 3 + 6 + 7 + 24 + 25 + 28 + 29 + 8 + 9 + 12 + 13 + 26 + 27 + 30 + 31 + 10 + 11 + 14 + 15 + ) + ) + +(define ct16-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + ) + ) + +(define ct16s-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 16 + 18 + 1 + 3 + 17 + 19 + 8 + 10 + 24 + 26 + 9 + 11 + 25 + 27 + 4 + 6 + 20 + 22 + 5 + 7 + 21 + 23 + 12 + 14 + 28 + 30 + 13 + 15 + 29 + 31 + ) + ) + +(define mz16-block-table (new 'static 'boxed-array :type int32 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + ) + ) + +(define mz16s-block-table (new 'static 'boxed-array :type int32 + 16 + 18 + 0 + 2 + 17 + 19 + 1 + 3 + 24 + 26 + 8 + 10 + 25 + 27 + 9 + 11 + 20 + 22 + 4 + 6 + 21 + 23 + 5 + 7 + 28 + 30 + 12 + 14 + 29 + 31 + 13 + 15 + ) + ) + +(define mt8-block-table (new 'static 'boxed-array :type int32 + 0 + 1 + 4 + 5 + 16 + 17 + 20 + 21 + 2 + 3 + 6 + 7 + 18 + 19 + 22 + 23 + 8 + 9 + 12 + 13 + 24 + 25 + 28 + 29 + 10 + 11 + 14 + 15 + 26 + 27 + 30 + 31 + ) + ) + +(define mt4-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + ) + ) + +(deftype texture-page-translate-item (structure) + ((bucket bucket-id) + (level-index uint32) + (level-texture-page tpage-category-u32) + (texture-user texture-enable-mask-u32) + ) + ) + + +(define *texture-page-translate* (new 'static 'boxed-array :type texture-page-translate-item + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-lcom-sky-pre) + :level-index #x12 + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 sky) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l1-tfrag) + :level-index #x1 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l3-tfrag) + :level-index #x2 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id etie-scissor-l5-tfrag) + :level-index #x3 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tie-scissor-l7-tfrag) + :level-index #x4 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tfrag-scissor-l9-tfrag) + :level-index #x5 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id shrub-near-trans-l1-shrub) + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id shrub-vanish-l3-shrub) + :level-index #x1 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id billboard-l5-shrub) + :level-index #x2 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id shrub-near-l7-shrub) + :level-index #x3 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id shrub-l9-shrub) + :level-index #x4 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l0-alpha) + :level-index #x5 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tfrag-scissor-l2-alpha) + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l4-alpha) + :level-index #x1 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l6-alpha) + :level-index #x2 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l8-alpha) + :level-index #x3 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-lcom-tfrag) + :level-index #x4 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l2-pris) + :level-index #x5 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l6-pris) + :level-index #x12 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l8-pris) + :level-index #x12 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x12 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-lcom-pris2) + :level-index #xc + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #xc + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id etie-l0-water) + :level-index #xd + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #xd + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tie-l1-water) + :level-index #xe + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #xe + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tfrag-l2-water) + :level-index #xf + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #xf + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l3-water) + :level-index #x10 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x10 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l4-water) + :level-index #x11 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x11 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l5-water) + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l5-water) + :level-index #x1 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id etie-scissor-l6-water) + :level-index #x2 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tfrag-scissor-l7-water) + :level-index #x3 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tie-scissor-l8-water) + :level-index #x4 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id etie-l9-water) + :level-index #x5 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id anti-alias) + :level-index #x12 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id generic-warp) + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id debug-menu) + :level-index #x1 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket594) + :level-index #x2 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket603) + :level-index #x3 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket612) + :level-index #x4 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket621) + :level-index #x5 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket630) + :level-index #x12 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 sky) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket633) + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket652) + :level-index #x1 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket671) + :level-index #x2 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket690) + :level-index #x3 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket709) + :level-index #x4 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket728) + :level-index #x5 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket747) + :level-index #x12 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x1 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x2 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x3 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x4 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x5 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x12 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x1 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x2 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x3 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x4 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x5 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x12 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x1 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x2 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x3 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x4 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x5 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x12 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + ) + ) diff --git a/goal_src/jakx/engine/gfx/view-h.gc b/goal_src/jakx/engine/gfx/view-h.gc index 56b7c2d8dd..a7160e3f1a 100644 --- a/goal_src/jakx/engine/gfx/view-h.gc +++ b/goal_src/jakx/engine/gfx/view-h.gc @@ -7,3 +7,28 @@ ;; DECOMP BEGINS +(define *view-count* 1) + +(define *view-assert* #f) + +(deftype view (basic) + ((index int8) + (control-scheme uint8) + (camera basic) + (camera-combiner basic) + (target basic) + (math-camera basic) + ) + ) + + +(define *views* + "Length of 2, initialized empty" + (new 'static 'boxed-array :type view :length 0 :allocated-length 2) + ) + +(define *view-context-stack* (new 'static 'boxed-array :type int32 :length 0 :allocated-length 8)) + +(define *view-context-stack-ptr* (the-as (pointer int32) -1)) + +(define *view-default* (the-as symbol 0)) diff --git a/goal_src/jakx/engine/gfx/vu1-user-h.gc b/goal_src/jakx/engine/gfx/vu1-user-h.gc index 3e0f7828fb..52f57fe222 100644 --- a/goal_src/jakx/engine/gfx/vu1-user-h.gc +++ b/goal_src/jakx/engine/gfx/vu1-user-h.gc @@ -5,5 +5,897 @@ ;; name in dgo: vu1-user-h ;; dgos: ENGINE, GAME +;; +++tpage-category +;; TODO - copied from jak 3 +(defenum tpage-category + :type int8 + (tfrag 0) ;; + (pris 1) + (shrub 2) + (alpha 3) + (water 4) + (warp 5) + (pris2 6) + (sprite 7) + (hud 8) ;; or map? + (sky 9) + (hfrag 10) + ) +;; ---tpage-category + +;; +++tpage-category-u32 +(defenum tpage-category-u32 + :type uint32 + :copy-entries tpage-category + ) +;; ---tpage-category-u32 + +;; +++bucket-id +;; -l- +(defenum bucket-id + :type int32 + (bucket0 0) + (bucket1 1) + (bucket2 2) ;; pc vis stuff + (blit 3) + (tex-lcom-sky-pre 4) + (sky 5) ;; sky + (bucket6 6) ;; ocean + (bucket7 7) ;; unknown new jak 3 texture upload, for all levels. + (hfrag 8) ;; hfrag + (hfrag-scissor 9) ;; hfrag + + (tex-l0-tfrag 10) ;; texture + (tfrag-l0-tfrag 11) ;; tfrag + (tie-l0-tfrag 12) ;; tie + (etie-l0-tfrag 13) ;; tie + (tfrag-scissor-l0-tfrag 14) ;; tfrag + (tie-scissor-l0-tfrag 15) ;; tie + (etie-scissor-l0-tfrag 16) ;; tie + (merc-l0-tfrag 17) ;; merc + (emerc-l0-tfrag 18) ;; emerc + (gmerc-l0-tfrag 19) ;; generic + (tie-vanish-l0-tfrag 20) ;; tie + (gmerc2-l0-tfrag 21) ;; generic + + (tex-l1-tfrag 22) + (tfrag-l1-tfrag 23) + (tie-l1-tfrag 24) + (etie-l1-tfrag 25) + (tfrag-scissor-l1-tfrag 26) + (tie-scissor-l1-tfrag 27) + (etie-scissor-l1-tfrag 28) + (merc-l1-tfrag 29) + (emerc-l1-tfrag 30) + (gmerc-l1-tfrag 31) + (tie-vanish-l1-tfrag 32) + (gmerc2-l1-tfrag 33) + + (tex-l2-tfrag 34) + (tfrag-l2-tfrag 35) + (tie-l2-tfrag 36) + (etie-l2-tfrag 37) + (tfrag-scissor-l2-tfrag 38) + (tie-scissor-l2-tfrag 39) + (etie-scissor-l2-tfrag 40) + (merc-l2-tfrag 41) + (emerc-l2-tfrag 42) + (gmerc-l2-tfrag 43) + (tie-vanish-l2-tfrag 44) + (gmerc2-l2-tfrag 45) + + (tex-l3-tfrag 46) + (tfrag-l3-tfrag 47) + (tie-l3-tfrag 48) + (etie-l3-tfrag 49) + (tfrag-scissor-l3-tfrag 50) + (tie-scissor-l3-tfrag 51) + (etie-scissor-l3-tfrag 52) + (merc-l3-tfrag 53) + (emerc-l3-tfrag 54) + (gmerc-l3-tfrag 55) + (tie-vanish-l3-tfrag 56) + (gmerc2-l3-tfrag 57) + + (tex-l4-tfrag 58) + (tfrag-l4-tfrag 59) + (tie-l4-tfrag 60) + (etie-l4-tfrag 61) + (tfrag-scissor-l4-tfrag 62) + (tie-scissor-l4-tfrag 63) + (etie-scissor-l4-tfrag 64) + (merc-l4-tfrag 65) + (emerc-l4-tfrag 66) + (gmerc-l4-tfrag 67) + (tie-vanish-l4-tfrag 68) + (gmerc2-l4-tfrag 69) + + (tex-l5-tfrag 70) + (tfrag-l5-tfrag 71) + (tie-l5-tfrag 72) + (etie-l5-tfrag 73) + (tfrag-scissor-l5-tfrag 74) + (tie-scissor-l5-tfrag 75) + (etie-scissor-l5-tfrag 76) + (merc-l5-tfrag 77) + (emerc-l5-tfrag 78) + (gmerc-l5-tfrag 79) + (tie-vanish-l5-tfrag 80) + (gmerc2-l5-tfrag 81) + + (tex-l6-tfrag 82) + (tfrag-l6-tfrag 83) + (tie-l6-tfrag 84) + (etie-l6-tfrag 85) + (tfrag-scissor-l6-tfrag 86) + (tie-scissor-l6-tfrag 87) + (etie-scissor-l6-tfrag 88) + (merc-l6-tfrag 89) + (emerc-l6-tfrag 90) + (gmerc-l6-tfrag 91) + (tie-vanish-l6-tfrag 92) + (gmerc2-l6-tfrag 93) + + (tex-l7-tfrag 94) + (tfrag-l7-tfrag 95) + (tie-l7-tfrag 96) + (etie-l7-tfrag 97) + (tfrag-scissor-l7-tfrag 98) + (tie-scissor-l7-tfrag 99) + (etie-scissor-l7-tfrag 100) + (merc-l7-tfrag 101) + (emerc-l7-tfrag 102) + (gmerc-l7-tfrag 103) + (tie-vanish-l7-tfrag 104) + (gmerc2-l7-tfrag 105) + + (tex-l8-tfrag 106) + (tfrag-l8-tfrag 107) + (tie-l8-tfrag 108) + (etie-l8-tfrag 109) + (tfrag-scissor-l8-tfrag 110) + (tie-scissor-l8-tfrag 111) + (etie-scissor-l8-tfrag 112) + (merc-l8-tfrag 113) + (emerc-l8-tfrag 114) + (gmerc-l8-tfrag 115) + (tie-vanish-l8-tfrag 116) + (gmerc2-l8-tfrag 117) + + (tex-l9-tfrag 118) + (tfrag-l9-tfrag 119) + (tie-l9-tfrag 120) + (etie-l9-tfrag 121) + (tfrag-scissor-l9-tfrag 122) + (tie-scissor-l9-tfrag 123) + (etie-scissor-l9-tfrag 124) + (merc-l9-tfrag 125) + (emerc-l9-tfrag 126) + (gmerc-l9-tfrag 127) + (tie-vanish-l9-tfrag 128) + (gmerc2-l9-tfrag 129) + + (tex-l0-shrub 130) + (shrub-l0-shrub 131) + (shrub-near-l0-shrub 132) + (billboard-l0-shrub 133) + (shrub-vanish-l0-shrub 134) + (shrub-near-trans-l0-shrub 135) + (merc-l0-shrub 136) + (emerc-l0-shrub 137) + (gmerc-l0-shrub 138) + (gmerc2-l0-shrub 139) + + (tex-l1-shrub 140) + (shrub-l1-shrub 141) + (shrub-near-l1-shrub 142) + (billboard-l1-shrub 143) + (shrub-vanish-l1-shrub 144) + (shrub-near-trans-l1-shrub 145) + (merc-l1-shrub 146) + (emerc-l1-shrub 147) + (gmerc-l1-shrub 148) + (gmerc2-l1-shrub 149) + + (tex-l2-shrub 150) + (shrub-l2-shrub 151) + (shrub-near-l2-shrub 152) + (billboard-l2-shrub 153) + (shrub-vanish-l2-shrub 154) + (shrub-near-trans-l2-shrub 155) + (merc-l2-shrub 156) + (emerc-l2-shrub 157) + (gmerc-l2-shrub 158) + (gmerc2-l2-shrub 159) + + (tex-l3-shrub 160) + (shrub-l3-shrub 161) + (shrub-near-l3-shrub 162) + (billboard-l3-shrub 163) + (shrub-vanish-l3-shrub 164) + (shrub-near-trans-l3-shrub 165) + (merc-l3-shrub 166) + (emerc-l3-shrub 167) + (gmerc-l3-shrub 168) + (gmerc2-l3-shrub 169) + + (tex-l4-shrub 170) + (shrub-l4-shrub 171) + (shrub-near-l4-shrub 172) + (billboard-l4-shrub 173) + (shrub-vanish-l4-shrub 174) + (shrub-near-trans-l4-shrub 175) + (merc-l4-shrub 176) + (emerc-l4-shrub 177) + (gmerc-l4-shrub 178) + (gmerc2-l4-shrub 179) + + (tex-l5-shrub 180) + (shrub-l5-shrub 181) + (shrub-near-l5-shrub 182) + (billboard-l5-shrub 183) + (shrub-vanish-l5-shrub 184) + (shrub-near-trans-l5-shrub 185) + (merc-l5-shrub 186) + (emerc-l5-shrub 187) + (gmerc-l5-shrub 188) + (gmerc2-l5-shrub 189) + + (tex-l6-shrub 190) + (shrub-l6-shrub 191) + (shrub-near-l6-shrub 192) + (billboard-l6-shrub 193) + (shrub-vanish-l6-shrub 194) + (shrub-near-trans-l6-shrub 195) + (merc-l6-shrub 196) + (emerc-l6-shrub 197) + (gmerc-l6-shrub 198) + (gmerc2-l6-shrub 199) + + (tex-l7-shrub 200) + (shrub-l7-shrub 201) + (shrub-near-l7-shrub 202) + (billboard-l7-shrub 203) + (shrub-vanish-l7-shrub 204) + (shrub-near-trans-l7-shrub 205) + (merc-l7-shrub 206) + (emerc-l7-shrub 207) + (gmerc-l7-shrub 208) + (gmerc2-l7-shrub 209) + + (tex-l8-shrub 210) + (shrub-l8-shrub 211) + (shrub-near-l8-shrub 212) + (billboard-l8-shrub 213) + (shrub-vanish-l8-shrub 214) + (shrub-near-trans-l8-shrub 215) + (merc-l8-shrub 216) + (emerc-l8-shrub 217) + (gmerc-l8-shrub 218) + (gmerc2-l8-shrub 219) + + (tex-l9-shrub 220) + (shrub-l9-shrub 221) + (shrub-near-l9-shrub 222) + (billboard-l9-shrub 223) + (shrub-vanish-l9-shrub 224) + (shrub-near-trans-l9-shrub 225) + (merc-l9-shrub 226) + (emerc-l9-shrub 227) + (gmerc-l9-shrub 228) + (gmerc2-l9-shrub 229) + + (tex-l0-alpha 230) + (tfrag-l0-alpha 231) + (tie-l0-alpha 232) + (etie-l0-alpha 233) + (merc-l0-alpha 234) + (emerc-l0-alpha 235) + (gmerc-l0-alpha 236) + (tfrag-scissor-l0-alpha 237) + (tie-scissor-l0-alpha 238) + (etie-scissor-l0-alpha 239) + (gmerc2-l0-alpha 240) + + (tex-l1-alpha 241) + (tfrag-l1-alpha 242) + (tie-l1-alpha 243) + (etie-l1-alpha 244) + (merc-l1-alpha 245) + (emerc-l1-alpha 246) + (gmerc-l1-alpha 247) + (tfrag-scissor-l1-alpha 248) + (tie-scissor-l1-alpha 249) + (etie-scissor-l1-alpha 250) + (gmerc2-l1-alpha 251) + + (tex-l2-alpha 252) + (tfrag-l2-alpha 253) + (tie-l2-alpha 254) + (etie-l2-alpha 255) + (merc-l2-alpha 256) + (emerc-l2-alpha 257) + (gmerc-l2-alpha 258) + (tfrag-scissor-l2-alpha 259) + (tie-scissor-l2-alpha 260) + (etie-scissor-l2-alpha 261) + (gmerc2-l2-alpha 262) + + (tex-l3-alpha 263) + (tfrag-l3-alpha 264) + (tie-l3-alpha 265) + (etie-l3-alpha 266) + (merc-l3-alpha 267) + (emerc-l3-alpha 268) + (gmerc-l3-alpha 269) + (tfrag-scissor-l3-alpha 270) + (tie-scissor-l3-alpha 271) + (etie-scissor-l3-alpha 272) + (gmerc2-l3-alpha 273) + + (tex-l4-alpha 274) + (tfrag-l4-alpha 275) + (tie-l4-alpha 276) + (etie-l4-alpha 277) + (merc-l4-alpha 278) + (emerc-l4-alpha 279) + (gmerc-l4-alpha 280) + (tfrag-scissor-l4-alpha 281) + (tie-scissor-l4-alpha 282) + (etie-scissor-l4-alpha 283) + (gmerc2-l4-alpha 284) + + (tex-l5-alpha 285) + (tfrag-l5-alpha 286) + (tie-l5-alpha 287) + (etie-l5-alpha 288) + (merc-l5-alpha 289) + (emerc-l5-alpha 290) + (gmerc-l5-alpha 291) + (tfrag-scissor-l5-alpha 292) + (tie-scissor-l5-alpha 293) + (etie-scissor-l5-alpha 294) + (gmerc2-l5-alpha 295) + + (tex-l6-alpha 296) + (tfrag-l6-alpha 297) + (tie-l6-alpha 298) + (etie-l6-alpha 299) + (merc-l6-alpha 300) + (emerc-l6-alpha 301) + (gmerc-l6-alpha 302) + (tfrag-scissor-l6-alpha 303) + (tie-scissor-l6-alpha 304) + (etie-scissor-l6-alpha 305) + (gmerc2-l6-alpha 306) + + (tex-l7-alpha 307) + (tfrag-l7-alpha 308) + (tie-l7-alpha 309) + (etie-l7-alpha 310) + (merc-l7-alpha 311) + (emerc-l7-alpha 312) + (gmerc-l7-alpha 313) + (tfrag-scissor-l7-alpha 314) + (tie-scissor-l7-alpha 315) + (etie-scissor-l7-alpha 316) + (gmerc2-l7-alpha 317) + + (tex-l8-alpha 318) + (tfrag-l8-alpha 319) + (tie-l8-alpha 320) + (etie-l8-alpha 321) + (merc-l8-alpha 322) + (emerc-l8-alpha 323) + (gmerc-l8-alpha 324) + (tfrag-scissor-l8-alpha 325) + (tie-scissor-l8-alpha 326) + (etie-scissor-l8-alpha 327) + (gmerc2-l8-alpha 328) + + (tex-l9-alpha 329) + (tfrag-l9-alpha 330) + (tie-l9-alpha 331) + (etie-l9-alpha 332) + (merc-l9-alpha 333) + (emerc-l9-alpha 334) + (gmerc-l9-alpha 335) + (tfrag-scissor-l9-alpha 336) + (tie-scissor-l9-alpha 337) + (etie-scissor-l9-alpha 338) + (gmerc2-l9-alpha 339) + + (tex-lcom-tfrag 340) + (merc-lcom-tfrag 341) + (emerc-lcom-tfrag 342) + (gmerc-lcom-tfrag 343) + (gmerc2-lcom-tfrag 344) + + (tex-lcom-shrub 345) + (merc-lcom-shrub 346) + (emerc-lcom-shrub 347) + (gmerc-lcom-shrub 348) + (gmerc2-lcom-shrub 349) + + (shadow 350) + + (tex-l0-pris 351) + (merc-l0-pris 352) + (emerc-l0-pris 353) + (gmerc-l0-pris 354) + (gmerc2-l0-pris 355) + + (tex-l1-pris 356) + (merc-l1-pris 357) + (emerc-l1-pris 358) + (gmerc-l1-pris 359) + (gmerc2-l1-pris 360) + + (tex-l2-pris 361) + (merc-l2-pris 362) + (emerc-l2-pris 363) + (gmerc-l2-pris 364) + (gmerc2-l2-pris 365) + + (tex-l3-pris 366) + (merc-l3-pris 367) + (emerc-l3-pris 368) + (gmerc-l3-pris 369) + (gmerc2-l3-pris 370) + + (tex-l4-pris 371) + (merc-l4-pris 372) + (emerc-l4-pris 373) + (gmerc-l4-pris 374) + (gmerc2-l4-pris 375) + + (tex-l5-pris 376) + (merc-l5-pris 377) + (emerc-l5-pris 378) + (gmerc-l5-pris 379) + (gmerc2-l5-pris 380) + + (tex-l6-pris 381) + (merc-l6-pris 382) + (emerc-l6-pris 383) + (gmerc-l6-pris 384) + (gmerc2-l6-pris 385) + + (tex-l7-pris 386) + (merc-l7-pris 387) + (emerc-l7-pris 388) + (gmerc-l7-pris 389) + (gmerc2-l7-pris 390) + + (tex-l8-pris 391) + (merc-l8-pris 392) + (emerc-l8-pris 393) + (gmerc-l8-pris 394) + (gmerc2-l8-pris 395) + + (tex-l9-pris 396) + (merc-l9-pris 397) + (emerc-l9-pris 398) + (gmerc-l9-pris 399) + (gmerc2-l9-pris 400) + + (tex-lcom-pris 401) + (merc-lcom-pris 402) + (emerc-lcom-pris 403) + (gmerc-lcom-pris 404) + (gmerc2-lcom-pris 405) + + (tex-l0-pris2 406) + (merc-l0-pris2 407) + (emerc-l0-pris2 408) + (gmerc-l0-pris2 409) + (gmerc2-l0-pris2 410) + + (tex-l1-pris2 411) + (merc-l1-pris2 412) + (emerc-l1-pris2 413) + (gmerc-l1-pris2 414) + (gmerc2-l1-pris2 415) + + (tex-l2-pris2 416) + (merc-l2-pris2 417) + (emerc-l2-pris2 418) + (gmerc-l2-pris2 419) + (gmerc2-l2-pris2 420) + + (tex-l3-pris2 421) + (merc-l3-pris2 422) + (emerc-l3-pris2 423) + (gmerc-l3-pris2 424) + (gmerc2-l3-pris2 425) + + (tex-l4-pris2 426) + (merc-l4-pris2 427) + (emerc-l4-pris2 428) + (gmerc-l4-pris2 429) + (gmerc2-l4-pris2 430) + + (tex-l5-pris2 431) + (merc-l5-pris2 432) + (emerc-l5-pris2 433) + (gmerc-l5-pris2 434) + (gmerc2-l5-pris2 435) + + (tex-l6-pris2 436) + (merc-l6-pris2 437) + (emerc-l6-pris2 438) + (gmerc-l6-pris2 439) + (gmerc2-l6-pris2 440) + + (tex-l7-pris2 441) + (merc-l7-pris2 442) + (emerc-l7-pris2 443) + (gmerc-l7-pris2 444) + (gmerc2-l7-pris2 445) + + (tex-l8-pris2 446) + (merc-l8-pris2 447) + (emerc-l8-pris2 448) + (gmerc-l8-pris2 449) + (gmerc2-l8-pris2 450) + + (tex-l9-pris2 451) + (merc-l9-pris2 452) + (emerc-l9-pris2 453) + (gmerc-l9-pris2 454) + (gmerc2-l9-pris2 455) + + (tex-lcom-pris2 456) + (merc-lcom-pris2 457) + (emerc-lcom-pris2 458) + (gmerc-lcom-pris2 459) + (gmerc2-lcom-pris2 460) + + (tex-lcom-sky-post 461) + (bucket462 462) + + (tex-l0-water 463) + (merc-l0-water 464) + (gmerc-l0-water 465) + (tfrag-l0-water 466) + (tie-l0-water 467) + (etie-l0-water 468) + (tie-scissor-l0-water 469) + (tfrag-scissor-l0-water 470) + (etie-scissor-l0-water 471) + (gmerc2-l0-water 472) + + (tex-l1-water 473) + (merc-l1-water 474) + (gmerc-l1-water 475) + (tfrag-l1-water 476) + (tie-l1-water 477) + (etie-l1-water 478) + (tie-scissor-l1-water 479) + (tfrag-scissor-l1-water 480) + (etie-scissor-l1-water 481) + (gmerc2-l1-water 482) + + (tex-l2-water 483) + (merc-l2-water 484) + (gmerc-l2-water 485) + (tfrag-l2-water 486) + (tie-l2-water 487) + (etie-l2-water 488) + (tie-scissor-l2-water 489) + (tfrag-scissor-l2-water 490) + (etie-scissor-l2-water 491) + (gmerc2-l2-water 492) + + (tex-l3-water 493) + (merc-l3-water 494) + (gmerc-l3-water 495) + (tfrag-l3-water 496) + (tie-l3-water 497) + (etie-l3-water 498) + (tie-scissor-l3-water 499) + (tfrag-scissor-l3-water 500) + (etie-scissor-l3-water 501) + (gmerc2-l3-water 502) + + (tex-l4-water 503) + (merc-l4-water 504) + (gmerc-l4-water 505) + (tfrag-l4-water 506) + (tie-l4-water 507) + (etie-l4-water 508) + (tie-scissor-l4-water 509) + (tfrag-scissor-l4-water 510) + (etie-scissor-l4-water 511) + (gmerc2-l4-water 512) + + (tex-l5-water 513) + (merc-l5-water 514) + (gmerc-l5-water 515) + (tfrag-l5-water 516) + (tie-l5-water 517) + (etie-l5-water 518) + (tie-scissor-l5-water 519) + (tfrag-scissor-l5-water 520) + (etie-scissor-l5-water 521) + (gmerc2-l5-water 522) + + (tex-l6-water 523) + (merc-l6-water 524) + (gmerc-l6-water 525) + (tfrag-l6-water 526) + (tie-l6-water 527) + (etie-l6-water 528) + (tie-scissor-l6-water 529) + (tfrag-scissor-l6-water 530) + (etie-scissor-l6-water 531) + (gmerc2-l6-water 532) + + (tex-l7-water 533) + (merc-l7-water 534) + (gmerc-l7-water 535) + (tfrag-l7-water 536) + (tie-l7-water 537) + (etie-l7-water 538) + (tie-scissor-l7-water 539) + (tfrag-scissor-l7-water 540) + (etie-scissor-l7-water 541) + (gmerc2-l7-water 542) + + (tex-l8-water 543) + (merc-l8-water 544) + (gmerc-l8-water 545) + (tfrag-l8-water 546) + (tie-l8-water 547) + (etie-l8-water 548) + (tie-scissor-l8-water 549) + (tfrag-scissor-l8-water 550) + (etie-scissor-l8-water 551) + (gmerc2-l8-water 552) + + (tex-l9-water 553) + (merc-l9-water 554) + (gmerc-l9-water 555) + (tfrag-l9-water 556) + (tie-l9-water 557) + (etie-l9-water 558) + (tie-scissor-l9-water 559) + (tfrag-scissor-l9-water 560) + (etie-scissor-l9-water 561) + (gmerc2-l9-water 562) + + (tex-lcom-water 563) + (merc-lcom-water 564) + (gmerc-lcom-water 565) + (gmerc2-lcom-water 566) ;; default for prim + (anti-alias 567) + + (tex-sprite 568) + (generic-sprite-1 569) ;; ;prim + (particles 570) + (generic-sprite-2 571) + (shadow2 572) + (shadow3 573) + (generic-sprite-3 574) + + (tex-warp 575) + (generic-warp 576) + + (debug-no-zbuf1 577) ;; debug? + (tex-hud-hud-alpha 578) + (hud-draw-hud-alpha 579) + (tex-hud-pris2 580) + (hud-draw-pris2 581) + (bucket582 582) + (debug 583) + (debug-no-zbuf2 584) + (debug-menu 585) + (bucket586 586) + (bucket587 587) + (bucket588 588) + (bucket589 589) + (bucket590 590) + (bucket591 591) + (bucket592 592) + (bucket593 593) + (bucket594 594) + (bucket595 595) + (bucket596 596) + (bucket597 597) + (bucket598 598) + (bucket599 599) + (bucket600 600) + (bucket601 601) + (bucket602 602) + (bucket603 603) + (bucket604 604) + (bucket605 605) + (bucket606 606) + (bucket607 607) + (bucket608 608) + (bucket609 609) + (bucket610 610) + (bucket611 611) + (bucket612 612) + + (bucket621 621) + + (bucket630 630) + + (bucket633 633) + (bucket634 634) + (bucket635 635) + + (bucket642 642) + (bucket643 643) + (bucket644 644) + + (bucket651 651) + (bucket652 652) + (bucket653 653) + (bucket654 654) + + (bucket661 661) + (bucket662 662) + (bucket663 663) + + (bucket670 670) + (bucket671 671) + (bucket672 672) + (bucket673 673) + + (bucket680 680) + (bucket681 681) + (bucket682 682) + + (bucket689 689) + (bucket690 690) + (bucket691 691) + (bucket692 692) + + (bucket699 699) + (bucket700 700) + (bucket701 701) + + (bucket708 708) + (bucket709 709) + + (bucket728 728) + + (bucket747 747) + + (bucket767 767) + (bucket768 768) + + (bucket770 770) + (bucket771 771) + + (bucket773 773) + (bucket774 774) + (bucket775 775) + (bucket776 776) + (bucket777 777) + + (bucket780 780) + + (bucket785 785) + (bucket786 786) + + (bucket788 788) + ) +;; ---bucket-id + +;; +++bucket-id-16 +(defenum bucket-id-16 + :type int16 + :copy-entries bucket-id + ) +;; ---bucket-id-16 + +;; +++vu1-renderer-mask +;; TODO stolen from Jak 2 (and it was all wrong...) +(defenum vu1-renderer-mask + :type uint64 + :bitfield #t + (rn0) + (rn1) + (rn2) + (sky) + (rn4) + (rn5) + (hfrag) + (hfrag-scissor) + (tfrag) + (tie-scissor) + (tie) + (etie) + (etie-scissor) + (tie-vanish) + (generic) ;; right + (merc) ;; right + (emerc) ;; right + (shrubbery) + (shrub-near) + (billboard) + (shrub-vanish) + (tfrag-trans) + (tie-scissor-trans) + (tie-trans) + (etie-trans) + (etie-scissor-trans) + (tfrag-water) + (tie-scissor-water) + (tie-water) + (etie-water) + (etie-scissor-water) + (sprite) + (rn32) + (rn33) + (rn34) + (rn35) + (depth-cue) + (rn37) + ) +;; ---vu1-renderer-mask + +;; +++tpage-category-u32 +(defenum tpage-category-u32 + :type uint32 + :copy-entries tpage-category + ) +;; ---tpage-category-u32 + +;; +++texture-enable-mask +(defenum texture-enable-mask + :type uint64 + :bitfield #t + (tfrag 0) + (all-pris 1) + (shrub 2) + (alpha 3) + (water 4) + (warp 5) + (sprite 6) + (hud 7) + (sky 8) + (hfrag 9) + ) +;; ---texture-enable-mask + +;; +++texture-enable-mask-u32 +(defenum texture-enable-mask-u32 + :type uint32 + :bitfield #t + :copy-entries texture-enable-mask + ) +;; ---texture-enable-mask-u32 + ;; DECOMP BEGINS +(deftype dma-foreground-sink (basic) + "A specification for where a foreground renderer should output its DMA data." + ((bucket bucket-id) + (foreground-texture-page tpage-category) + (foreground-texture-level int8) + (foreground-output-bucket int8) + ) + ) + + +(deftype generic-bucket-state (structure) + "The state of buffers for the generic renderer. +When generating generic DMA data, you must know the previous state +of the VU's memory to properly double-buffer the input and output data." + ((gifbuf-adr uint32) + (inbuf-adr uint32) + ) + :pack-me + ) + + +(deftype generic-dma-foreground-sink (dma-foreground-sink) + "A specification for where a foreground generic renderer should output DMA data, +and the state of the VU memory buffers at the end of the bucket." + ((state generic-bucket-state :inline) + ) + ) diff --git a/goal_src/jakx/engine/level/bsp-h.gc b/goal_src/jakx/engine/level/bsp-h.gc index 3e44ead1d1..c5099795c6 100644 --- a/goal_src/jakx/engine/level/bsp-h.gc +++ b/goal_src/jakx/engine/level/bsp-h.gc @@ -7,3 +7,15 @@ ;; DECOMP BEGINS +(deftype collide-stats (structure) + "Very strange collide stats type. It has been somewhat broken in all versions of the game. +The final stopwatch is cut off. For jak 3, I just fixed it." + ((calls uint32) + (spheres uint32) + (nodes uint32) + (frags uint32) + (tris uint32) + (output uint32) + (junk (pointer uint32) 24) + ) + ) diff --git a/goal_src/jakx/engine/level/level-h.gc b/goal_src/jakx/engine/level/level-h.gc index 30d9525ff0..deb1acdfeb 100644 --- a/goal_src/jakx/engine/level/level-h.gc +++ b/goal_src/jakx/engine/level/level-h.gc @@ -5,5 +5,717 @@ ;; name in dgo: level-h ;; dgos: ENGINE, GAME +;; max amount of levels in level heap +(defconstant LEVEL_MAX 18) +;; total amount of levels, including ones outside level heap (default-level) +(defconstant LEVEL_TOTAL 19) + +(declare-type bsp-header basic) +(declare-type drawable basic) +(declare-type entity-links-array inline-array-class) +(declare-type light-hash basic) +(declare-type engine basic) +(declare-type game-text-info structure) +(declare-type entity-links structure) +(declare-type level-group basic) +(declare-type level-load-info structure) +(declare-type text-id uint32) +(define-extern *level* level-group) +(define-extern *draw-index* int) +(define-extern *level-index* int) +(define-extern *print-login* symbol) + +(define-extern level-remap-texture (function texture-id texture-id)) +(define-extern lookup-level-info (function symbol level-load-info)) + +;; +++vis-info-flag +(defenum vis-info-flag + :type uint32 + :bitfield #t + (dummy0 0) + (dummy1 1) + (dummy2 2) + (dummy3 3) + (dummy4 4) + (dummy5 5) + (dummy6 6) + (dummy7 7) + (dummy8 8) + (dummy9 9) + (dummy10 10) + (dummy11 11) + (dummy12 12) + (dummy13 13) + (dummy14 14) + (dummy15 15) + (dummy16 16) + (dummy17 17) + (dummy18 18) + (dummy19 19) + (dummy20 20) + (dummy21 21) + (dummy22 22) + (dummy23 23) + (dummy24 24) + (dummy25 25) + (dummy26 26) + (dummy27 27) + (dummy28 28) + (in-iop 29) + (loading 30) + (vis-valid 31) + ) +;; ---vis-info-flag + + +;; +++level-memory-mode +(defenum level-memory-mode + :type uint32 + (micro 0) + (tiny 1) + (tiny-edge 2) + (tiny-center 3) + (small-edge 4) + (small-center 5) + (city-center 6) + (medium 7) + (large 8) + (alias 9) + (borrow 10) + (borrow0 11) + (borrow1 12) + (borrow2 13) + (borrow3 14) + (borrow4 15) + (borrow-city-small 16) + (tiny-center-small 17) + (tiny-center-micro 18) + (city-tiny-edge 19) + ) +;; ---level-memory-mode + + +;; +++task-mask +(defenum task-mask + :type uint32 + :bitfield #t + (task0 0) + (task1 1) + (task2 2) + (task3 3) + (task4 4) + (task5 5) + (task6 6) + (task7 7) + (done 8) + (dummy0 9) + (network 10) + (vehicle 11) + (special 12) + (primary0 13) + (ctywide 14) + (never 15) + (movie0 16) + (movie1 17) + (movie2 18) + (tm19 19) + (tm20 20) + (tm21 21) + (tm22 22) + (tm23 23) + (tm24 24) + (tm25 25) + (tm26 26) + (tm27 27) + (tm28 28) + (tm29 29) + (tm30 30) + (tm31 31) +) +;; ---task-mask + + +;; +++bigmap-id +(defenum bigmap-id + :type uint32 + (city 0) + (comb 1) + (desert 2) + (factory 3) + (forest 4) + (mhcity 5) + (mine 6) + (nest 7) + (nest2 8) + (none 9) + (precursor1 10) + (precursor2 11) + (rubble 12) + (sewer-hum-kg 13) + (sewer-kg-met 14) + (sewer-met-hum 15) + (stadium 16) + (temple1 17) + (temple2 18) + (temple3 19) + (temple4 20) + (tower 21) + (volcano 22) + (wascity 23) + ) +;; ---bigmap-id + + +;; +++level-flags +(defenum level-flags + :type uint32 + :bitfield #t + (lf0 0) + (not-physical 1) + (ctycar 2) + (ctypes 3) + (external 4) + (title 5) + (borrow-load 6) + (end-mode 7) + (flut 8) + (sky 9) + (use-camera-other 10) + (display-wait 11) + (ocean-near-translucent 12) + (ocean-far 13) + (low-res-hfrag 14) + (city-borrow-available 15) + (mech 16) + (allow-unloaded 17) + (check-taskname-for-continue 18) + (city-borrow-high-priority 19) + (ocean-all 20) + (desert 21) + ) +;; ---level-flags + +;; +++city-map-bits +(defenum city-map-bits + :type uint64 + :bitfield #t + (cmb0 0) + (cmb1 1) + (cmb2 2) + (cmb3 3) + (cmb4 4) + (cmb5 5) + (cmb6 6) + (cmb7 7) + (cmb8 8) + (cmb9 9) + (cmb10 10) + (cmb11 11) + (cmb12 12) + (cmb13 13) + (cmb14 14) + (cmb15 15) + (cmb16 16) + (cmb17 17) + (cmb18 18) + (cmb19 19) + (cmb20 20) + (cmb21 21) + (cmb22 22) + (cmb23 23) + (cmb24 24) + (cmb25 25) + (cmb26 26) + (cmb27 27) + (cmb28 28) + (cmb29 29) + (cmb30 30) + (cmb31 31) + (cmb32 32) + (cmb33 33) + ) +;; ---city-map-bits + +(define-extern *level-load-list* pair) +(define-extern *task-level* (array symbol)) + ;; DECOMP BEGINS +(deftype level-vis-info (basic) + ((level level) + (from-level symbol) + (from-bsp bsp-header) + (flags vis-info-flag) + (length uint32) + (allocated-length uint32) + (dictionary-length uint32) + (dictionary uint32) + (string-block uint32) + (ramdisk uint32) + (vis-bits uint32 4) + (current-vis-string uint32 4) + (vis-string uint32 :dynamic) + ) + ) + + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this level-vis-info)) + (the-as int (+ (-> level-vis-info size) (-> this dictionary-length))) + ) + +(deftype level-borrow-info (basic) + ((borrow-size uint16 3) + (borrow-info object 3) + ) + ) + + +(deftype level-load-info (basic) + ((name-list symbol 4) + (name symbol :overlay-at (-> name-list 0)) + (visname symbol :overlay-at (-> name-list 1)) + (nickname symbol :overlay-at (-> name-list 2)) + (dbname symbol :overlay-at (-> name-list 0)) + (taskname symbol :overlay-at (-> name-list 3)) + (index int16) + (task-level uint8) + (race-minimap uint8) + (level-flags level-flags) + (packages pair) + (memory-mode level-memory-mode) + (mood-func symbol) + (special-mood symbol) + (ocean symbol) + (ocean-height float) + (status-cache uint16) + (status-cache-sync uint16) + (draw-priority float) + (base-task-mask task-mask) + (continues pair) + (callback-list pair) + (borrow level-borrow-info) + (bottom-height meters) + (mood-range mood-range) + ) + (:methods + (level-load-info-method-9 () none) + (level-load-info-method-10 () none) + ) + ) + + +(deftype login-state (basic) + ((state int32) + (pos uint32) + (elts uint32) + (elt drawable 16) + ) + ) + + +(deftype level (basic) + ((name symbol) + (load-name symbol) + (nickname symbol) + (index int32) + (status symbol) + (borrow-level level 3) + (borrow-from-level level) + (heap kheap :inline) + (borrow-heap kheap 3 :inline) + (bsp bsp-header) + (art-group load-dir-art-group) + (info level-load-info) + (level-TODO-01 int32) + (texture-page-dir texture-page-segment 11 :inline) + (loaded-texture-page texture-page 16) + (loaded-texture-page-count int32) + (entity entity-links-array) + (closest-object meters 10) + (tie-min-dist float :offset 376) + (fg-tfrag-min-dist float) + (fg-prim-min-dist float) + (fg-shrub-min-dist float) + (fg-warp-min-dist float :offset 396) + (fg-prim2-min-dist float :offset 404) + (upload-size int32 19) + (inside-boxes? symbol) + (display? symbol) + (render? symbol) + (meta-inside? symbol) + (force-inside? symbol) + (load-id uint32) + (mood-context mood-context) + (mood-func (function mood-context float int none)) + (mood-init (function mood-context none)) + (vis-bits pointer 2) + (all-visible? symbol) + (force-all-visible? symbol) + (linking symbol) + (vis-info level-vis-info 8) + (vis-self-index int32) + (vis-adj-index int32) + (vis-buffer uint32) + (mem-usage-block memory-usage-block) + (mem-usage int32) + (code-memory-start pointer) + (code-memory-end pointer) + (load-start-time uint64) + (load-stop-time uint64) + (load-buffer uint32 2) + (load-buffer-size uint32) + (load-buffer-last dgo-header) + (load-buffer-mode level-memory-mode) + (display-start-time uint64) + (memory-mask uint32) + (task-mask task-mask) + (tfrag-gs-test gs-test) + (level-TODO-003 int32) + (level-TODO-004 int32) + (texture-dirty-masks texture-mask 11 :inline) + (texture-mask texture-mask 19 :inline) + (tfrag-last-calls uint32 6) + (texture-anim-array texture-anim-array 11) + (light-hash light-hash) + (draw-priority float) + (draw-index int32) + (part-engine engine) + (user-object basic 4) + (loaded-text-info-count int32) + (loaded-text-info game-text-info 16) + (level-type type) + (load-order uint64) + (slot int32) + (filter-num uint32) + (filter-name string 16) + (filter-look uint8 16) + (buffer kheap) + ) + (:methods + (level-method-9 () none) + (level-method-10 () none) + (level-method-11 () none) + (level-method-12 () none) + (level-method-13 () none) + (level-method-14 () none) + (level-method-15 () none) + (level-method-16 () none) + (level-method-17 () none) + (level-method-18 () none) + (level-method-19 () none) + (level-method-20 () none) + (level-method-21 () none) + (level-method-22 () none) + (level-method-23 () none) + (level-method-24 () none) + (level-method-25 () none) + (level-method-26 () none) + (level-method-27 () none) + (level-method-28 () none) + (level-method-29 () none) + ) + ) + + +(deftype level-group (basic) + ((length int32) + (log-in-level-bsp bsp-header) + (loading-level level) + (entity-link entity-links) + (border? symbol) + (vis? symbol) + (want-level basic) + (receiving-level basic) + (load-commands pair) + (play? symbol) + (prev-target-pos vector 2 :inline) + (curr-target-pos vector 2 :inline) + (prev-camera-pos vector 2 :inline) + (curr-camera-pos vector 2 :inline) + (heap kheap :inline) + (car-heap kheap :inline) + (driver-heap kheap :inline) + (cars-heap kheap :inline) + (sound-bank sound-bank-state 7 :inline) + (disk-load-timing? symbol) + (load-level symbol) + (load-size uint32) + (load-time float) + (load-login-time float) + (draw-level-count int32) + (draw-level level 19) + (draw-index-map uint8 19) + (shared-ties basic) + (status-cache-sync uint16) + (load-order uint64) + (wide-level level 2) + (tfrag-login-level basic) + (level-group-TODO-001 int32 11) + (level level 19 :inline :offset 544) + (level0 level :inline :overlay-at (-> level 0)) + (level1 level :inline :offset 1984) + (level2 level :inline :offset 3424) + (level3 level :inline :offset 4864) + (level4 level :inline :offset 6304) + (level5 level :inline :offset 7744) + (car0 level :inline :offset 9184) + (car1 level :inline :offset 10624) + (car2 level :inline :offset 12064) + (car3 level :inline :offset 13504) + (car4 level :inline :offset 14944) + (car5 level :inline :offset 16384) + (driver0 level :inline :offset 17824) + (driver1 level :inline :offset 19264) + (driver2 level :inline :offset 20704) + (driver3 level :inline :offset 22144) + (driver4 level :inline :offset 23584) + (driver5 level :inline :offset 25024) + (level-default level :inline :offset 26464) + (pad int32) + ) + (:methods + (level-group-method-9 () none) + (level-group-method-10 () none) + (level-group-method-11 () none) + (level-group-method-12 () none) + (level-group-method-13 () none) + (level-group-method-14 () none) + (level-group-method-15 () none) + (level-group-method-16 () none) + (level-group-method-17 () none) + (level-group-method-18 () none) + (level-group-method-19 () none) + (level-group-method-20 () none) + (level-group-method-21 () none) + (level-group-method-22 () none) + (level-group-method-23 () none) + (level-group-method-24 () none) + (level-group-method-25 () none) + (level-group-method-26 () none) + (level-group-method-27 () none) + (level-group-method-28 () none) + (level-group-method-29 () none) + (level-group-method-30 () none) + (level-group-method-31 () none) + (level-group-method-32 () none) + (level-group-method-33 () none) + ) + ) + + +(when (zero? *level*) + (set! *level* + (new 'static 'level-group + :length 18 + :log-in-level-bsp #f + :loading-level #f + :entity-link #f + :border? #f + :vis? #f + :want-level #f + :load-commands '() + :play? #f + :sound-bank (new 'static 'inline-array sound-bank-state 7 + (new 'static 'sound-bank-state :name #f :mode (sound-bank-mode full)) + (new 'static 'sound-bank-state :name #f) + (new 'static 'sound-bank-state :name #f) + (new 'static 'sound-bank-state :name #f) + (new 'static 'sound-bank-state :name #f) + (new 'static 'sound-bank-state :name #f) + (new 'static 'sound-bank-state :name #f) + ) + :disk-load-timing? #f + :status-cache-sync #x1 + :level (new 'static 'inline-array level 19 + (new 'static 'level :name #f :status 'inactive :inside-boxes? #f :force-inside? #f :linking #f :level-type #f) + (new 'static 'level + :name #f + :index 1 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 2 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 3 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 4 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 5 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 6 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 7 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 8 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 9 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 10 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 11 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 12 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 13 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 14 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 15 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 16 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 17 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name 'default + :index 18 + :status 'reserved + :bsp #f + :inside-boxes? #f + :display? #f + :force-inside? #f + :linking #f + :level-type #f + ) + ) + ) + ) + (set! (-> *level* sound-bank 0 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 1 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 2 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 3 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 4 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 5 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 6 str-name) (new 'global 'string 16 (the-as string #f))) + (set! *draw-index* 0) + (set! *level-index* 0) + 0 + ) + +(define *city-mode* #f) + +(define *lobby-levels* (new 'static 'boxed-array :type symbol '#f '#f)) + +(define *lobby-levels-display* (new 'static 'boxed-array :type symbol '#f '#f)) + +(define *lobby-levels-tmp* (new 'static 'boxed-array :type symbol :length 0 :allocated-length 6)) + +(dotimes (v1-27 6) + (set! (-> *lobby-levels-tmp* v1-27) #f) + ) diff --git a/goal_src/jakx/engine/level/region-h.gc b/goal_src/jakx/engine/level/region-h.gc index 11c50e984d..bb79e5e3f6 100644 --- a/goal_src/jakx/engine/level/region-h.gc +++ b/goal_src/jakx/engine/level/region-h.gc @@ -7,3 +7,107 @@ ;; DECOMP BEGINS +(deftype region (structure) + "A region is a closed volume that you can, enter, exit, and be inside. +This stores a unique, and script functions for a single region. +These are stored separately from the actual geometry to allow the geometry to be smaller +and fit in scratchpad/cache better." + ((id uint32) + (on-enter pair) + (on-inside pair) + (on-exit pair) + ) + (:methods + (point-in-region-debug! (_type_ vector) symbol) + ) + ) + + +(deftype region-array (inline-array-class) + "Array of region." + ((data region :inline :dynamic) + ) + ) + + +(set! (-> region-array heap-base) (the-as uint 16)) + +(deftype drawable-region-prim (drawable) + "Base class for a region + geometry. +Note that all child classes of this must be 32-bytes." + ((region region :offset 8) + ) + (:methods + (debug-draw-region (_type_ int) none) + (track-region (_type_ region-prim-area) symbol) + (within-area? (_type_ region-prim-area) symbol) + ) + ) + + +(deftype drawable-tree-region-prim (drawable-tree) + "Top-level container for all regions of a level." + ((name symbol :offset 8) + (data2 drawable-inline-array :dynamic :offset 32) + ) + (:methods + (drawable-tree-region-prim-method-17 (_type_ vector) symbol) + (debug-print (_type_ vector object) none) + ) + ) + + +(deftype drawable-inline-array-region-prim (drawable-inline-array) + "Inline array of drawable-region-prim. This actually stores child classes, but they are +exactly the same size as the parent, so it's okay." + ((data drawable-region-prim 1 :inline) + (pad uint8 4) + ) + ) + +(deftype drawable-region-sphere (drawable-region-prim) + "Region where the bsphere of the drawable is the volume." + () + ) + + +(deftype region-face-data (structure) + "Data to store a single planar face, as a normal and list of vertices." + ((normal vector :inline) + (normal-offset float :overlay-at (-> normal data 3)) + (num-points uint32) + (points vector :inline :dynamic) + ) + ) + + +(deftype drawable-region-face (drawable-region-prim) + "A drawable-region which is just a face. Unclear if `on-inside` is used." + ((data region-face-data :offset 12) + ) + ) + + +(deftype region-face-array (inline-array-class) + "An array of faces that hopefully make a closed volume." + ((data drawable-region-face :inline :dynamic :offset 16) + (pad uint32) + ) + ) + + +(set! (-> region-face-array heap-base) (the-as uint 32)) + +(deftype drawable-region-volume (drawable-region-prim) + "A drawable-region which is a bunch of faces that represent a closed volume." + ((faces region-face-array :offset 12) + ) + ) + + +(deftype region-prim-list (structure) + "A list of drawable-region-prim. This is the return type of queries like `which regions contain this point?`" + ((num-items int32) + (items drawable-region-prim 320) + ) + ) diff --git a/goal_src/jakx/engine/load/decomp-h.gc b/goal_src/jakx/engine/load/decomp-h.gc index dffd114f30..7f2ea2888e 100644 --- a/goal_src/jakx/engine/load/decomp-h.gc +++ b/goal_src/jakx/engine/load/decomp-h.gc @@ -7,3 +7,10 @@ ;; DECOMP BEGINS +(deftype decomp-work (structure) + ((buffer0 uint8 2048) + (buffer1 uint8 2048) + (indices uint16 2048) + (temp-indices uint16 2048) + ) + ) diff --git a/goal_src/jakx/engine/load/file-io.gc b/goal_src/jakx/engine/load/file-io.gc index d070869c36..f77f6596f6 100644 --- a/goal_src/jakx/engine/load/file-io.gc +++ b/goal_src/jakx/engine/load/file-io.gc @@ -5,5 +5,317 @@ ;; name in dgo: file-io ;; dgos: ENGINE, GAME +#|@file +GOAL File I/O +This is mostly not used in the retail game and was more for loading stuff during development. +The file-stream is an inefficient way to load data, but is flexible and can load +from the CD, or over the network in development. +The file-info type is used in actual game data for checking versions. + +Represents a file that can be read/written, similar to FILE* in C. + +NOTE: this is a special type in three ways: + 1). It is used in the C runtime. This must be kept in sync with kmachine.h's FileStream. + 2). This type is built-in to the compiler (see TypeSystem.cpp, add_builtin_types). + It must be kept up to date with that definition as well. + 3). The C runtime constructs this type before anything is loaded. The sizes + must be kept up to date there as well. +|# + +;; +++file-kind +(defenum file-kind + :bitfield #f + (level-bt 0) ;; aka bsp-header. + (art-group 1) + (tpage 2) + (dir-tpage 3) + (level-vs 4) + (tx 5) + (vis 6) + (map 7) + ) +;; ---file-kind + +(defconstant SCE_SEEK_SET 0) +(defconstant SCE_SEEK_CUR 1) +(defconstant SCE_SEEK_END 2) + +(defconstant LEVEL_BT_FILE_VERSION 36) +(defglobalconstant ART_GROUP_FILE_VERSION 8) +(defconstant TPAGE_FILE_VERSION 8) ;; also used for dir +(defconstant LEVEL_VS_FILE_VERSION 30) +(defconstant TX_FILE_VERSION 1) +(defconstant MAP_FILE_VERSION 1) + +(defmacro file-stream-valid? (fs) + `(>= (the-as int (-> ,fs file)) 0) + ) + +(defmacro file-stream-tell (fs) + `(file-stream-seek ,fs 0 SCE_SEEK_CUR)) + +(define *sqlpipe-file-path-send* #f) +(define *sqlpipe-file-path-recv* #f) +(define *sqlpipe-file-buffer* (the-as (pointer uint32) #f)) + ;; DECOMP BEGINS +(deftype file-stream (basic) + ((flags uint32) + (mode symbol) + (name string) + (file uint32) + ) + (:methods + (new (symbol type string symbol) _type_) + ) + ) + + +(defmethod new file-stream ((allocation symbol) (type-to-make type) (arg0 string) (arg1 symbol)) + (let ((a0-1 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (file-stream-open a0-1 arg0 arg1) + ) + ) + +(set! (-> file-stream method-table 4) file-stream-length) + +(defun file-stream-read-string ((arg0 file-stream) (arg1 string)) + (clear arg1) + (file-stream-read arg0 (-> arg1 data) (length arg0)) + arg1 + ) + +(deftype file-info (basic) + ((file-type (pointer string)) + (file-name string) + (major-version uint32) + (minor-version uint32) + (maya-file-name string) + (tool-debug string) + (mdb-file-name string) + ) + ) + + +(defmethod print ((this file-info)) + (format + #t + "#<~A ~A :version ~D.~D @ #x~X>" + (-> this type) + (-> this file-name) + (-> this major-version) + (-> this minor-version) + this + ) + this + ) + +(define *file-temp-string* (new 'global 'string 128 (the-as string #f))) + +(defun make-file-name ((arg0 file-kind) (arg1 string) (arg2 int) (arg3 symbol)) + (clear *file-temp-string*) + (cond + ((= arg0 (file-kind dir-tpage)) + (format *file-temp-string* "texture-page~D/dir-tpages" 8) + ) + ((= arg0 (file-kind tpage)) + (format *file-temp-string* "texture-page~D/tpage-~S" 8 arg1) + ) + ((= arg0 (file-kind level-bt)) + (format *file-temp-string* "level~D/~S-bt" 37 arg1) + ) + ((= arg0 (file-kind tx)) + (format *file-temp-string* "res~D/~S-tx" 1 arg1) + ) + ((= arg0 (file-kind level-vs)) + (format *file-temp-string* "level~D/~S-vs" 37 arg1) + ) + ((= arg0 (file-kind vis)) + (format *file-temp-string* "~S.VIS" arg1) + ) + ((= arg0 (file-kind map)) + (format *file-temp-string* "map~D/~S-mp" 1 arg1) + ) + ((= arg0 (file-kind art-group)) + (format + *file-temp-string* + "art-group~D/~S-ag" + (cond + ((> arg2 0) + (empty) + arg2 + ) + (else + 8 + ) + ) + arg1 + ) + ) + ) + *file-temp-string* + ) + +(defun make-vfile-name ((arg0 file-kind) (arg1 string)) + (clear *file-temp-string*) + (cond + ((= arg0 (file-kind level-bt)) + (format *file-temp-string* "$LEVEL/~S" arg1) + ) + ((= arg0 (file-kind art-group)) + (format *file-temp-string* "$ART_GROUP/~S" arg1) + ) + ) + *file-temp-string* + ) + +(defun file-info-correct-version? ((arg0 file-info) (arg1 file-kind) (arg2 int)) + (let* ((s5-0 (cond + ((zero? arg2) + (case arg1 + (((file-kind tpage) (file-kind dir-tpage)) + 8 + ) + (((file-kind level-bt)) + 37 + ) + (((file-kind art-group)) + 8 + ) + ) + ) + (else + arg2 + ) + ) + ) + (v1-1 arg1) + (s4-0 (cond + ((= v1-1 (file-kind tpage)) + "texture-page" + ) + ((= v1-1 (file-kind level-bt)) + "bsp-header" + ) + ((= v1-1 (file-kind art-group)) + "art-group" + ) + ) + ) + ) + (cond + ((not (name= (-> arg0 file-type 0) s4-0)) + (format 0 "ERROR: file ~A is of type ~S but needs to be ~S.~%" (-> arg0 file-name) (-> arg0 file-type) s4-0) + #f + ) + ((!= s5-0 (-> arg0 major-version)) + (format + 0 + "ERROR: file ~A is version ~D.~D, but needs to be ~D.x~%" + (-> arg0 file-name) + (-> arg0 major-version) + (-> arg0 minor-version) + s5-0 + ) + #f + ) + (else + #t + ) + ) + ) + ) + +(defun file-stream-read-complete ((arg0 file-stream) (arg1 pointer) (arg2 int)) + (let ((gp-0 arg2)) + (while (> arg2 0) + (let ((v1-0 (file-stream-read arg0 arg1 arg2))) + (when (<= v1-0 0) + (set! gp-0 (- gp-0 arg2)) + (goto cfg-7) + ) + (&+! arg1 v1-0) + (set! arg2 (- arg2 v1-0)) + ) + ) + (label cfg-7) + gp-0 + ) + ) + +(defun sqlpipe-query ((arg0 string)) + (format 0 "[sqlpipe-query]: ~A~%" arg0) + (when (not *sqlpipe-file-path-send*) + (set! *sqlpipe-file-path-send* (the-as symbol (new 'debug 'string 1024 (the-as string #f)))) + (format *sqlpipe-file-path-send* "db/sql/~S.send" *user*) + ) + (when (not *sqlpipe-file-path-recv*) + (set! *sqlpipe-file-path-recv* (the-as symbol (new 'debug 'string 1024 (the-as string #f)))) + (format *sqlpipe-file-path-recv* "db/sql/~S.recv" *user*) + ) + (if (not *sqlpipe-file-buffer*) + (set! *sqlpipe-file-buffer* (the-as (pointer uint32) (new 'debug 'string #x10000 (the-as string #f)))) + ) + (let ((s5-0 (new 'stack 'file-stream (the-as string *sqlpipe-file-path-send*) 'write))) + (when (logtest? (-> s5-0 flags) 1) + (format 0 "ERROR: unable to open file ~S~%" *sqlpipe-file-path-send*) + (return (the-as sql-result #f)) + ) + (format s5-0 "~S" arg0) + (file-stream-close s5-0) + ) + (clear (the-as string *sqlpipe-file-buffer*)) + 0 + (let ((s5-1 (new 'stack 'file-stream (the-as string *sqlpipe-file-path-recv*) 'read))) + (when (logtest? (-> s5-1 flags) 1) + (format 0 "ERROR: unable to open file ~S~%" *sqlpipe-file-path-recv*) + (return (the-as sql-result #f)) + ) + (file-stream-read-complete s5-1 (&-> *sqlpipe-file-buffer* 1) 4) + (let ((gp-1 (-> (&-> *sqlpipe-file-buffer* 1) 0))) + (file-stream-read-complete s5-1 (&-> *sqlpipe-file-buffer* 1) #x10000) + (file-stream-close s5-1) + (let ((s5-2 (new 'debug 'sql-result (the-as int gp-1)))) + (let ((s4-0 0) + (s2-0 (the-as (pointer uinteger) (&-> *sqlpipe-file-buffer* 1))) + (s3-0 (string-skip-to-char (the-as (pointer uint8) (&-> *sqlpipe-file-buffer* 1)) (the-as uint 30))) + ) + (while (and (= (-> s3-0 0) 30) (>= (the-as int gp-1) s4-0)) + (let ((s1-0 (new 'debug 'string (&- s3-0 (the-as uint s2-0)) (the-as string #f)))) + (copyn-string<-charp s1-0 (the-as (pointer uint8) s2-0) (&- s3-0 (the-as uint s2-0))) + (if (zero? s4-0) + (set! (-> s5-2 content-type) (the-as type (string->symbol-debug s1-0))) + (set! (-> s5-2 sql-data (+ s4-0 -1)) s1-0) + ) + ) + (+! s4-0 1) + (set! s2-0 (&-> s3-0 1)) + (set! s3-0 (string-skip-to-char (the-as (pointer uint8) s2-0) (the-as uint 30))) + ) + ) + (set! (-> s5-2 length) (the-as int gp-1)) + (let ((v0-8 s5-2)) + (b! #t cfg-23 :delay (nop!)) + (the-as none 0) + (set! v0-8 (the-as sql-result #f)) + (label cfg-23) + v0-8 + ) + ) + ) + ) + ) + +(when (not (and (= *kernel-boot-mode* 'listener) #t)) + (set! *sqlpipe-file-path-send* #f) + (set! *sqlpipe-file-path-recv* #f) + (set! *sqlpipe-file-buffer* (the-as (pointer uint32) #f)) + ;; og:preserve-this stop being weird + ;; (set! file-stream-read-complete L13) + ;; (set! sqlpipe-query L1) + ;; (if (!= sql-query sqlpipe-query) + ;; (set! old-sql-query sql-query) + ;; ) + ;; (set! sql-query sqlpipe-query) + ) diff --git a/goal_src/jakx/engine/load/loader-h.gc b/goal_src/jakx/engine/load/loader-h.gc index e5741cb3ee..d060dccce1 100644 --- a/goal_src/jakx/engine/load/loader-h.gc +++ b/goal_src/jakx/engine/load/loader-h.gc @@ -5,5 +5,197 @@ ;; name in dgo: loader-h ;; dgos: ENGINE, GAME +(declare-type spool-anim basic) +(declare-type art-joint-anim art-element) +(declare-type external-art-buffer basic) +(declare-type process-nettable process) +(declare-type process-drawable process-nettable) +(define-extern external-art-buffer-init (function external-art-buffer int)) +(define-extern ja-abort-spooled-anim (function spool-anim art-joint-anim int int :behavior process-drawable)) +(declare-type art basic) +(declare-type art-group art) +(define-extern *stack-top* pointer) + ;; DECOMP BEGINS +(deftype load-dir (basic) + ((lev level) + (string-array (array string)) + (data-array (array basic)) + ) + (:methods + (new (symbol type int level) _type_) + (load-to-heap-by-name (_type_ string symbol kheap int) art-group) + (set-loaded-art (_type_ art-group) art-group) + ) + ) + +(deftype load-dir-art-group (load-dir) + "Specialization of load-dir for `art-group`s." + ((art-group-array (array art-group) :overlay-at data-array) + ) + (:methods + (new (symbol type int level) _type_) + ) + ) + +(defmethod new load-dir ((allocation symbol) (type-to-make type) (arg0 int) (arg1 level)) + (let ((s4-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s4-0 lev) arg1) + (set! (-> s4-0 string-array) + (the-as (array string) ((method-of-type array new) allocation array string arg0)) + ) + (set! (-> s4-0 string-array length) 0) + (set! (-> s4-0 data-array) (the-as (array basic) ((method-of-type array new) allocation array basic arg0))) + (set! (-> s4-0 data-array length) 0) + s4-0 + ) + ) + +;; WARN: Return type mismatch load-dir vs load-dir-art-group. +(defmethod new load-dir-art-group ((allocation symbol) (type-to-make type) (arg0 int) (arg1 level)) + (let ((v0-0 ((method-of-type load-dir new) allocation type-to-make arg0 arg1))) + (set! (-> v0-0 data-array content-type) art-group) + (the-as load-dir-art-group v0-0) + ) + ) + +(deftype external-art-buffer (basic) + "An `external-art-buffer` is a buffer that streamed files use." + ((index int32) + (other external-art-buffer) + (status symbol) + (locked? symbol) + (login? symbol) + (frame-lock symbol) + (init-heap (function external-art-buffer object)) + (heap kheap :inline) + (pending-load-file string) + (pending-load-file-part int32) + (pending-load-file-owner handle) + (pending-load-file-priority float) + (load-file string) + (load-file-part int32) + (load-file-owner handle) + (load-file-priority float) + (buf pointer) + (len int32) + (art-group art-group) + (art-data uint32 :overlay-at art-group) + ) + (:methods + (new (symbol type int function symbol) _type_) + (set-pending-file (_type_ string int handle float) int) + (update (_type_) int) + (inactive? (_type_) symbol) + (file-status (_type_ string int) symbol) + (link-file (_type_ art-group) art-group) + (unlink-file (_type_ art-group) int) + (unlock! (_type_) int) + ) + ) + + +(defmethod new external-art-buffer ((allocation symbol) (type-to-make type) (arg0 int) (arg1 function) (arg2 symbol)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 index) arg0) + (set! (-> v0-0 init-heap) (the-as (function external-art-buffer object) arg1)) + (set! (-> v0-0 login?) arg2) + (set! (-> v0-0 load-file) #f) + (set! (-> v0-0 load-file-part) -1) + (set! (-> v0-0 load-file-owner) (the-as handle #f)) + (set! (-> v0-0 load-file-priority) 100000000.0) + (set! (-> v0-0 pending-load-file) #f) + (set! (-> v0-0 pending-load-file-part) -1) + (set! (-> v0-0 pending-load-file-owner) (the-as handle #f)) + (set! (-> v0-0 pending-load-file-priority) 100000000.0) + (set! (-> v0-0 art-group) #f) + (set! (-> v0-0 status) 'initialize) + (set! (-> v0-0 locked?) #f) + (set! (-> v0-0 other) #f) + v0-0 + ) + ) + +(deftype spool-anim (basic) + "A `spool-anim` is metadata for an animation that will be loaded in chunks +to a pair of external-art-buffers." + ((name string :offset 16) + (anim-name string) + (buffer external-art-buffer :overlay-at anim-name) + (parts int32) + (hint-id int32 :overlay-at parts) + (priority float) + (owner handle) + (command-list pair) + ) + ) + + +(deftype external-art-control (basic) + "The `external-art-control` manages loading chunks from `spool-anim`s to `external-art-buffer`." + ((buffer external-art-buffer 2) + (rec spool-anim 3 :inline) + (spool-lock handle) + (reserve-buffer external-art-buffer) + (reserve-buffer-count int16) + (dma-reserve-buffer-count int16) + (active-stream string) + (queue-stream (array spool-anim)) + (frame-mask uint32) + (dma-reserve-heap kheap :inline) + ) + (:methods + (new (symbol type) _type_) + (update (_type_ symbol) int) + (clear-rec (_type_) int) + (spool-push (_type_ string int process float) int) + (file-status (_type_ string int) symbol) + (reserve-alloc (_type_) kheap) + (reserve-free (_type_ kheap) int) + (none-reserved? (_type_) symbol) + ) + ) + + +(defmethod new external-art-control ((allocation symbol) (type-to-make type)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (dotimes (s4-0 2) + (set! (-> gp-0 buffer s4-0) + ((method-of-type external-art-buffer new) allocation external-art-buffer s4-0 external-art-buffer-init #t) + ) + ) + (set! (-> gp-0 buffer 0 other) (-> gp-0 buffer 1)) + (set! (-> gp-0 buffer 1 other) (-> gp-0 buffer 0)) + (dotimes (v1-9 3) + (set! (-> gp-0 rec v1-9 name) #f) + (set! (-> gp-0 rec v1-9 priority) 100000000.0) + (set! (-> gp-0 rec v1-9 owner) (the-as handle #f)) + ) + (set! (-> gp-0 spool-lock) (the-as handle #f)) + (set! (-> gp-0 reserve-buffer) #f) + (set! (-> gp-0 active-stream) #f) + (set! (-> gp-0 queue-stream) (new 'global 'boxed-array spool-anim 4)) + (dotimes (s5-1 (-> gp-0 queue-stream allocated-length)) + (set! (-> gp-0 queue-stream s5-1) (new 'global 'spool-anim)) + ) + (set! (-> gp-0 queue-stream length) 0) + gp-0 + ) + ) + +(deftype subtitle-range (basic) + ((start-frame float) + (end-frame float) + (message basic 12) + ) + ) + + +(deftype subtitle-image (basic) + ((width uint16) + (height uint16) + (palette rgba 16 :offset 16) + (data uint8 :dynamic) + ) + ) diff --git a/goal_src/jakx/engine/math/euler-h.gc b/goal_src/jakx/engine/math/euler-h.gc index e283ceb568..f37ba576ab 100644 --- a/goal_src/jakx/engine/math/euler-h.gc +++ b/goal_src/jakx/engine/math/euler-h.gc @@ -7,3 +7,18 @@ ;; DECOMP BEGINS +(define EulSafe + "Maybe euler angle storage orders? +What is this naming convention?" + (new 'static 'boxed-array :type int32 0 1 2 0) + ) + +(define EulNext (new 'static 'boxed-array :type int32 1 2 0 1)) + +(deftype euler-angles (vector) + "Just uses the same xyzw and data array as vector. +The `w` stores an integer that seems to have +bitfields for... something? Like maybe the order? +Euler angles are mostly unused, and the code is a bit of disaster." + () + ) diff --git a/goal_src/jakx/engine/math/euler.gc b/goal_src/jakx/engine/math/euler.gc index be44326407..17d1243b0a 100644 --- a/goal_src/jakx/engine/math/euler.gc +++ b/goal_src/jakx/engine/math/euler.gc @@ -7,3 +7,211 @@ ;; DECOMP BEGINS +(defun set-eul! ((arg0 euler-angles) (arg1 float) (arg2 float) (arg3 float) (arg4 int)) + "Set euler angles and the flag bits." + (set! (-> arg0 x) arg1) + (set! (-> arg0 y) arg2) + (set! (-> arg0 z) arg3) + (set! (-> arg0 w) (the float arg4)) + arg0 + ) + +(defun eul->matrix ((arg0 matrix) (arg1 euler-angles)) + "Convert from euler angles to 4x4 matrix." + (matrix-identity! arg0) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 quad) (-> arg1 quad)) + (when (= (logand (the int (-> s5-0 w)) 1) 1) + (let ((f0-2 (-> s5-0 x))) + (set! (-> s5-0 x) (-> s5-0 z)) + (set! (-> s5-0 z) f0-2) + ) + ) + (when (= (logand (/ (the int (-> s5-0 w)) 4) 1) 1) + (set! (-> s5-0 x) (- (-> s5-0 x))) + (set! (-> s5-0 y) (- (-> s5-0 y))) + (set! (-> s5-0 z) (- (-> s5-0 z))) + ) + (let* ((f26-0 (cos (-> s5-0 x))) + (f30-0 (cos (-> s5-0 y))) + (f22-0 (cos (-> s5-0 z))) + (f24-0 (sin (-> s5-0 x))) + (f28-0 (sin (-> s5-0 y))) + (f4-0 (sin (-> s5-0 z))) + (f0-17 (* f26-0 f22-0)) + (f1-1 (* f26-0 f4-0)) + (f2-0 (* f24-0 f22-0)) + (f3-0 (* f24-0 f4-0)) + ) + 0 + 0 + 0 + (let* ((v1-12 (logand (/ (the int (-> s5-0 w)) 4) 1)) + (a1-2 (-> EulSafe (logand (/ (the int (-> s5-0 w)) 8) 3))) + (a0-21 (-> EulNext (+ a1-2 v1-12))) + (v1-17 (-> EulNext (+ (- 1 v1-12) a1-2))) + ) + (cond + ((= (logand (/ (the int (-> s5-0 w)) 2) 1) 1) + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a1-2 4)) (the-as int arg0)))) f30-0) + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a0-21 4)) (the-as int arg0)))) (* f28-0 f24-0)) + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* v1-17 4)) (the-as int arg0)))) (* f28-0 f26-0)) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a1-2 4)) (the-as int arg0)))) (* f28-0 f4-0)) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a0-21 4)) (the-as int arg0)))) + (- f0-17 (* f30-0 f3-0)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* v1-17 4)) (the-as int arg0)))) + (- (- f2-0) (* f30-0 f1-1)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a1-2 4)) (the-as int arg0)))) (- (* f28-0 f22-0))) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a0-21 4)) (the-as int arg0)))) + (+ f1-1 (* f30-0 f2-0)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* v1-17 4)) (the-as int arg0)))) + (+ (- f3-0) (* f30-0 f0-17)) + ) + ) + (else + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a1-2 4)) (the-as int arg0)))) (* f30-0 f22-0)) + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a0-21 4)) (the-as int arg0)))) + (+ (- f1-1) (* f28-0 f2-0)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* v1-17 4)) (the-as int arg0)))) + (+ f3-0 (* f28-0 f0-17)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a1-2 4)) (the-as int arg0)))) (* f30-0 f4-0)) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a0-21 4)) (the-as int arg0)))) + (+ f0-17 (* f28-0 f3-0)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* v1-17 4)) (the-as int arg0)))) + (+ (- f2-0) (* f28-0 f1-1)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a1-2 4)) (the-as int arg0)))) (- f28-0)) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a0-21 4)) (the-as int arg0)))) (* f30-0 f24-0)) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* v1-17 4)) (the-as int arg0)))) (* f30-0 f26-0)) + ) + ) + ) + ) + ) + arg0 + ) + +(defun matrix->eul ((arg0 euler-angles) (arg1 matrix) (arg2 int)) + "Convert matrix to euler angles with given order flag. + Not clear how this works if the matrix has more than just a rotation." + 0 + 0 + 0 + (let* ((v1-4 (logand (/ arg2 4) 1)) + (s3-0 (-> EulSafe (logand (/ arg2 8) 3))) + (s2-0 (-> EulNext (+ s3-0 v1-4))) + (s1-0 (-> EulNext (+ (- 1 v1-4) s3-0))) + ) + (cond + ((= (logand (/ arg2 2) 1) 1) + (let ((f30-0 (sqrtf (+ (square (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s3-0 16)) (the-as int arg1))))) + (square (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s3-0 16)) (the-as int arg1))))) + ) + ) + ) + ) + (cond + ((< 0.00000000001 f30-0) + (set! (-> arg0 x) (atan + (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s3-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s3-0 16)) (the-as int arg1)))) + ) + ) + (set! (-> arg0 y) (atan f30-0 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1)))))) + (set! (-> arg0 z) (atan + (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1)))) + (- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))))) + ) + ) + ) + (else + (set! (-> arg0 x) (atan + (- (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s2-0 16)) (the-as int arg1))))) + (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s2-0 16)) (the-as int arg1)))) + ) + ) + (set! (-> arg0 y) (atan f30-0 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1)))))) + (set! (-> arg0 z) 0.0) + ) + ) + ) + ) + (else + (let ((f30-1 (sqrtf (+ (square (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))))) + (square (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1))))) + ) + ) + ) + ) + (cond + ((< 0.00000000001 f30-1) + (set! (-> arg0 x) + (atan + (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s1-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s1-0 16)) (the-as int arg1)))) + ) + ) + (set! (-> arg0 y) + (atan (- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))))) f30-1) + ) + (set! (-> arg0 z) (atan + (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1)))) + ) + ) + ) + (else + (set! (-> arg0 x) + (atan + (- (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s2-0 16)) (the-as int arg1))))) + (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s2-0 16)) (the-as int arg1)))) + ) + ) + (set! (-> arg0 y) + (atan (- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))))) f30-1) + ) + (set! (-> arg0 z) 0.0) + ) + ) + ) + ) + ) + ) + (when (= (logand (/ arg2 4) 1) 1) + (set! (-> arg0 x) (- (-> arg0 x))) + (set! (-> arg0 y) (- (-> arg0 y))) + (set! (-> arg0 z) (- (-> arg0 z))) + ) + (when (= (logand arg2 1) 1) + (let ((f0-49 (-> arg0 x))) + (set! (-> arg0 x) (-> arg0 z)) + (set! (-> arg0 z) f0-49) + ) + ) + (set! (-> arg0 w) (the float arg2)) + arg0 + ) + +(defun eul->quat ((arg0 quaternion) (arg1 euler-angles)) + "Convert euler angles to quaternion, not very efficient." + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (eul->matrix s5-0 arg1) + (matrix->quaternion arg0 s5-0) + ) + arg0 + ) + +(defun quat->eul ((arg0 euler-angles) (arg1 quaternion) (arg2 int)) + "Convert quaternion to euler angles with given order, not very efficient." + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (quaternion->matrix s5-0 arg1) + (matrix->eul arg0 s5-0 arg2) + ) + arg0 + ) diff --git a/goal_src/jakx/engine/math/math.gc b/goal_src/jakx/engine/math/math.gc index 28a0f47b11..ef8731036d 100644 --- a/goal_src/jakx/engine/math/math.gc +++ b/goal_src/jakx/engine/math/math.gc @@ -5,5 +5,901 @@ ;; name in dgo: math ;; dgos: ENGINE, GAME +(defmacro init-vf0-vector () + "Initializes the VF0 vector which is a constant vector in the VU set to <0,0,0,1>" + `(.lvf vf0 (new 'static 'vector :x 0.0 :y 0.0 :z 0.0 :w 1.0)) + ) + +(defmacro square (x) + `(* ,x ,x)) + +(defmacro is-nan? (flt) + `(and (< 0.0 ,flt) (< ,flt 0.0))) + ;; DECOMP BEGINS +(defun truncate ((arg0 float)) + "Round (toward zero) to an integer. + @param arg0 float to truncate" + (the float (the int arg0)) + ) + +(defun round ((arg0 float)) + "Round to the nearest integer" + (the float (the int (+ 0.5 arg0))) + ) + +(defun floor ((arg0 float)) + "Round (down) to an integer" + (let ((f0-3 (the float (the int arg0)))) + (if (or (>= arg0 0.0) (= arg0 f0-3)) + f0-3 + (+ -1.0 f0-3) + ) + ) + ) + +(defun ceil ((arg0 float)) + "Round (up) to an integer" + (let ((f0-3 (the float (the int arg0)))) + (if (or (>= 0.0 arg0) (= arg0 f0-3)) + f0-3 + (+ 1.0 f0-3) + ) + ) + ) + +(defun integral? ((arg0 float)) + "Is this number an integer?" + (= (the float (the int arg0)) arg0) + ) + +(defun fractional-part ((arg0 float)) + "Get the fractional part of a float." + (- arg0 (the float (the int arg0))) + ) + +(defun odd? ((arg0 int)) + "Is the number odd?" + (= (logand arg0 1) 1) + ) + +(defun even? ((arg0 int)) + "Is the number even?" + (not (odd? arg0)) + ) + +(defun sawtooth-wave ((arg0 float)) + "Sample a sawtooth with period 1. In range (0, 1)" + (let ((f0-2 (- arg0 (the float (the int arg0))))) + (if (< f0-2 0.0) + (set! f0-2 (+ 1.0 f0-2)) + ) + f0-2 + ) + ) + +(defun triangle-wave ((arg0 float)) + "Sample a triangle wave. Period is 4, in range (-1, 1) (so slope is 1 or -1)." + (let* ((f0-1 (* 0.25 (+ -1.0 arg0))) + (f0-3 (- f0-1 (the float (the int f0-1)))) + ) + (if (< f0-3 0.0) + (set! f0-3 (+ 1.0 f0-3)) + ) + (+ -1.0 (fabs (+ -2.0 (* 4.0 f0-3)))) + ) + ) + +(defun log-x-plus-1-order9 ((arg0 float)) + "Fast approximation of ln(x + 1). Probably only accurate for x in [0, 1]." + (* arg0 + (+ 1.0 + (* arg0 + (+ -0.5 + (* arg0 + (+ 0.33333334 + (* arg0 + (+ -0.25 (* arg0 (+ 0.2 (* arg0 (+ -0.16666666 (* arg0 (+ 0.14285715 (* arg0 (+ -0.125 (/ arg0 9)))))))))) + ) + ) + ) + ) + ) + ) + ) + ) + +(defun logf ((arg0 float)) + "Natural log." + (let ((v1-1 (the-as int (+ (shr (the-as int arg0) 23) -126))) + (a0-2 (the-as number (logior #x3f000000 (logand (the-as uint #x807fffff) (the-as uint arg0))))) + ) + ;; og:preserve-this + (when (< (the-as float a0-2) 0.70710677) + (set! a0-2 (+ (the-as float a0-2) (the-as float a0-2))) + (set! v1-1 (the-as int (+ (the-as uint v1-1) -1))) + ) + (let ((f0-5 (+ -1.0 (the-as float a0-2)))) + (+ (* f0-5 + (+ 1.0 + (* f0-5 + (+ -0.5 + (* f0-5 + (+ 0.33333334 + (* f0-5 + (+ -0.25 + (* f0-5 (+ 0.2 (* f0-5 (+ -0.16666666 (* f0-5 (+ 0.14285715 (* f0-5 (+ -0.125 (* 0.11111111 f0-5))))))))) + ) + ) + ) + ) + ) + ) + ) + ) + (* 0.6931472 (the float v1-1)) + ) + ) + ) + ) + +(defun log2f ((arg0 float)) + "Log base 2." + (let ((v1-1 (the-as int (+ (shr (the-as int arg0) 23) -126))) + (a0-2 (the-as number (logior #x3f000000 (logand (the-as uint #x807fffff) (the-as uint arg0))))) + ) + ;; og:preserve-this + (when (< (the-as float a0-2) 0.70710677) + (set! a0-2 (+ (the-as float a0-2) (the-as float a0-2))) + (set! v1-1 (the-as int (+ (the-as uint v1-1) -1))) + ) + (let* ((f0-5 (+ -1.0 (the-as float a0-2))) + (f0-7 + (* f0-5 + (+ 1.0 + (* f0-5 + (+ -0.5 + (* f0-5 + (+ 0.33333334 + (* f0-5 + (+ -0.25 + (* f0-5 (+ 0.2 (* f0-5 (+ -0.16666666 (* f0-5 (+ 0.14285715 (* f0-5 (+ -0.125 (* 0.11111111 f0-5))))))))) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (+ (* 1.442695 f0-7) (the float v1-1)) + ) + ) + ) + +(deftype float-type (uint32) + () + ) + +(define exp-slead (new 'static 'array float 32 + 1.0 + 1.0218964 + 1.0442734 + 1.0671387 + 1.0905075 + 1.1143799 + 1.1387863 + 1.1637192 + 1.1892014 + 1.2152405 + 1.2418518 + 1.2690506 + 1.2968369 + 1.3252335 + 1.354248 + 1.3839035 + 1.4142075 + 1.4451752 + 1.4768219 + 1.5091629 + 1.5422058 + 1.5759735 + 1.6104889 + 1.645752 + 1.6817856 + 1.7186127 + 1.7562485 + 1.7947083 + 1.8340073 + 1.8741608 + 1.9151993 + 1.9571381 + ) + ) + +(define exp-strail (new 'static 'array float 32 + 0.0 + 0.0000007863494 + 0.00000040596257 + 0.0000017288019 + 0.00000022534104 + 0.0000068597833 + 0.0000023188388 + 0.0000056815315 + 0.0000057600223 + 0.0000068814647 + 0.000006005433 + 0.0000003590472 + 0.0000027016238 + 0.000003183687 + 0.000007500062 + 0.000006378546 + 0.000006103877 + 0.0000056360786 + 0.0000042465254 + 0.0000015247614 + 0.000005014861 + 0.000007334366 + 0.0000014403477 + 0.000003525029 + 0.000007247011 + 0.000006627224 + 0.0000036862523 + 0.00000082304996 + 0.0000008232258 + 0.0000068675085 + 0.000007281612 + 0.000006062652 + ) + ) + +(defun exp ((arg float)) + "Compute e^x." + (local-vars + (f0 float) + (f1 float) + (f2 float) + (f3 float) + (f4 float) + (f5 float) + (f6 float) + (f7 float) + (f8 float) + (f10 float) + (f11 float) + (f12 float) + (f13 float) + (f14 float) + (f15 float) + (f16 float) + (f17 float) + (f18 float) + (a2 int) + (v0 float) + (v1 int) + (a1 int) + (a3 int) + (t0 int) + (a0-2 int) + ) + + (set! f0 arg) + (set! f0 (fabs f0)) + (set! f1 (the-as float #x435c6bba)) + ;;(b! (>=.s f1 f0) L44 (nop!)) + (when-goto (>= f1 f0) L44) + + (set! f0 0.0) + (set! f1 arg) + ;;(b! (>=.s f0 f1) L42 (nop!)) + (when-goto (>= f0 f1) L42) + + (set! v0 (the-as float #x7f7fffff)) + ;;(b! #t L43 (nop!)) + (goto L43) + + (label L42) + (set! v0 (the-as float #x0)) + + (label L43) + ;;(b! #t L49 (nop!)) + (goto L49) + + + (label L44) + (set! f1 (the-as float #x33000000)) + ;;(b! (>=.s f0 f1) L45 (nop!)) + (when-goto (>= f0 f1) L45) + + (set! f0 (the-as float #x3f800000)) + (set! f1 arg) + (set! f0 (+ f0 f1)) + (set! v0 f0) + ;;(b! #t L49 (nop!)) + (goto L49) + + (label L45) + (set! f16 (the-as float #x4238aa3b)) + (set! f12 (the-as float #x3cb17200)) + (set! f13 (the-as float #x333fbe8e)) + (set! f14 (the-as float #x3f000044)) + (set! f15 (the-as float #x3e2aaaec)) + (set! f0 arg) + (set! f0 (* f0 f16)) + ;;(set! f0 (f2i f0)) + ;;(set! a2 (fpr->gpr f0)) + (set! a2 (the int f0)) + (set! v1 (logand a2 31)) + (set! a1 (- a2 v1)) + (set! a3 512) + (set! t0 a2) + ;;(bl! (<0.si t0) L46 (no-delay!)) + ;;(set! t0 (- t0)) + (set! t0 (abs t0)) + + ;;(label L46) + ;;(b! (>=.si a3 t0) L47 (nop!)) + (when-goto (>= a3 t0) L47) + ;;(set! f17 a1) + ;;(set! f18 v1) + ;;(set! f17 (i2f f17)) + ;;(set! f18 (i2f f18)) + (set! f17 (the float a1)) + (set! f18 (the float v1)) + (set! f17 (* f17 f12)) + (set! f18 (* f18 f12)) + (set! f0 arg) + (set! f17 (- f0 f17)) + ;;(b! #t L48 (set! f2 (-.s f17 f18))) + (set! f2 (- f17 f18)) + (goto L48) + + (label L47) + ;;(set! f17 (gpr->fpr a2)) + ;;(set! f17 (i2f f17)) + (set! f17 (the float a2)) + (set! f17 (* f17 f12)) + (set! f0 arg) + (set! f2 (- f0 f17)) + + (label L48) + (set! a0-2 (- a2)) + ;;(set! f17 (gpr->fpr a0)) + ;;(set! f17 (i2f f17)) + (set! f17 (the float a0-2)) + (set! f3 (* f17 f13)) + (set! a0-2 (sar a1 5)) + (set! f4 (+ f2 f3)) + (set! f6 (* f4 f15)) + (set! f6 (+ f14 f6)) + (set! f6 (* f4 f6)) + (set! f6 (* f4 f6)) + (set! f5 (+ f3 f6)) + (set! f5 (+ f2 f5)) + ;;(set! a1 exp-slead) + ;;(set! a2 (sll v1 2)) + ;;(set! a1 (+ a1 a2)) + ;;(set! f10 (l.f a1)) + (set! f10 (-> exp-slead v1)) + ;;(set! a1 exp-strail) + ;;(set! v1 (sll v1 2)) + ;;(set! v1 (+ a1 v1)) + ;;(set! f11 (l.f v1)) + (set! f11 (-> exp-strail v1)) + (set! f7 (+ f10 f11)) + (set! f8 (* f7 f5)) + (set! f8 (+ f11 f8)) + (set! f8 (+ f8 f10)) + (set! v1 (the-as int f8)) + (set! a0-2 (logand a0-2 511)) + (set! a0-2 (shl a0-2 23)) + (set! v0 (the-as float (+ v1 a0-2))) + (label L49) + v0 + ) + +(defun pow ((arg0 float) (arg1 float)) + "Compute arg0^arg1" + (exp (* arg1 (logf arg0))) + ) + +(defun print-exp ((arg0 float)) + "Print in the format AeB where A is in the range (1, 10)" + (let* ((f30-1 (floor (/ (logf (fabs arg0)) (logf 10.0)))) + (f0-4 (pow 10.0 f30-1)) + ) + (format #t "~fe~d" (/ arg0 f0-4) (the int f30-1)) + ) + 0 + (none) + ) + +(deftype rgba (uint32) + ((r uint8 :offset 0 :size 8) + (g uint8 :offset 8 :size 8) + (b uint8 :offset 16 :size 8) + (a uint8 :offset 24 :size 8) + ) + ) + +(deftype xyzw (uint128) + () + ) + +(deftype xyzwh (uint128) + () + ) + +(defun print-time ((arg0 object) (arg1 time-frame)) + "Print a [[time-frame]] as h:mm:ss." + (let* ((f0-1 (* 0.0033333334 (the float arg1))) + (a2-0 (the int (/ f0-1 60))) + (f0-2 (- f0-1 (* 60.0 (the float a2-0)))) + (a3-0 (the int f0-2)) + (f0-3 (- f0-2 (the float a3-0))) + (t0-0 (the int (* 100.0 f0-3))) + ) + (format arg0 "~d:~2,'0,d:~2,'0,d" a2-0 a3-0 t0-0) + ) + (none) + ) + +;; WARN: Return type mismatch uint vs int. +(defun log2 ((arg0 int)) + "Log base 2." + (the-as int (+ (sar (the-as int (the float arg0)) 23) -127)) + ) + +(defun seek ((arg0 float) (arg1 float) (arg2 float)) + "Move arg0 toward arg1 by at most arg2." + (let ((f2-0 (- arg1 arg0))) + (cond + ((>= arg2 (fabs f2-0)) + arg1 + ) + ((>= f2-0 0.0) + (+ arg0 arg2) + ) + (else + (- arg0 arg2) + ) + ) + ) + ) + +(defun seek-ease ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Move arg0 toward arg1, and slow down before reaching the end. + When farther than arg3 away, move by at most arg2. + When closer than arg3, linearly ramp down the movement amount from arg2 to 0 but no lower than arg4." + (let ((f2-0 (- arg1 arg0))) + (when (>= arg3 (fabs f2-0)) + (set! arg2 (* arg2 (- 1.0 (/ (- arg3 (fabs f2-0)) arg3)))) + (if (< arg2 arg4) + (set! arg2 arg4) + ) + ) + (cond + ((>= arg2 (fabs f2-0)) + arg1 + ) + ((>= f2-0 0.0) + (+ arg0 arg2) + ) + (else + (- arg0 arg2) + ) + ) + ) + ) + +(defun seek-ease-in-out ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float) (arg5 float) (arg6 float)) + "Move arg0 toward arg2, and slow down at the start and end. + When within arg4 of arg1 (at the beginning of movement), ramp up speed, with a minimum speed of arg6 + When within arg5 of arg2 (at the end of movement), ramp down speed, with a minimum speed of arg5 + Normally, move at most arg3" + (let ((f2-0 (- arg2 arg0))) + (let ((f4-1 (- arg0 arg1))) + (when (>= arg4 (fabs f4-1)) + (set! arg3 (* arg3 (- 1.0 (/ (- arg4 (fabs f4-1)) arg4)))) + (if (< arg3 arg6) + (set! arg3 arg6) + ) + ) + ) + (when (>= arg5 (fabs f2-0)) + (set! arg3 (* arg3 (- 1.0 (/ (- arg5 (fabs f2-0)) arg5)))) + (if (< arg3 arg6) + (set! arg3 arg6) + ) + ) + (cond + ((>= arg3 (fabs f2-0)) + arg2 + ) + ((>= f2-0 0.0) + (+ arg0 arg3) + ) + (else + (- arg0 arg3) + ) + ) + ) + ) + +(defun lerp ((arg0 float) (arg1 float) (arg2 float)) + "Linearly interpolate between arg0 and arg1." + (+ arg0 (* arg2 (- arg1 arg0))) + ) + +(defun-debug lerp-scale-old ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Linearly remap arg2 in [arg3, arg4] to [arg0, arg1]. + This is the jak 1 implementation, which I claimed was a bad implementation..." + (let ((f0-1 (fmax 0.0 (fmin 1.0 (/ (- arg2 arg3) (- arg4 arg3)))))) + (+ (* (- 1.0 f0-1) arg0) (* f0-1 arg1)) + ) + ) + +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f0, f2] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f1, f3] +(defun lerp-scale ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Linearly remap arg2 in [arg3, arg4] to [arg0, arg1]. +More efficient than the -old version." + (local-vars (f0-2 float)) + (let* ((v1-0 1.0) + (f1-0 0.0) + (f0-0 v1-0) + (f4-0 arg2) + (f2-0 arg3) + (f3-0 arg4) + (f1-2 (fmin (fmax (/ (- f4-0 f2-0) (- f3-0 f2-0)) f1-0) f0-0)) + (f0-1 (- f0-0 f1-2)) + (f2-3 arg0) + (f3-1 arg1) + ) + ;; og:preserve-this + ; (.mula.s f0-1 f2-3) + ; (.madd.s f0-2 f1-2 f3-1) + (set! f0-2 (+ (* f0-1 f2-3) (* f1-2 f3-1))) + ) + f0-2 + ) + +(defun lerp-scale-clamp ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Clamp the input, then linearly remap arg2 in [arg3, arg4] to [arg0, arg1]." + (let ((a2-1 (fmax (fmin arg2 arg4) arg3))) + (lerp-scale arg0 arg1 a2-1 arg3 arg4) + ) + ) + +(defun lerp-clamp ((arg0 float) (arg1 float) (arg2 float)) + "Linearly interpolate between arg0 and arg1. arg2 is clamped to [0, 1]" + (cond + ((>= 0.0 arg2) + arg0 + ) + ((>= arg2 1.0) + arg1 + ) + (else + (+ (* (- 1.0 arg2) arg0) (* arg2 arg1)) + ) + ) + ) + +;; WARN: Return type mismatch int vs rgba. +(defun rgba-lerp ((arg0 rgba) (arg1 rgba) (arg2 rgba)) + (local-vars + (v0-0 uint128) + (v1-0 uint128) + (v1-1 uint128) + (a0-1 uint128) + (a0-2 uint128) + (a1-1 uint128) + (a2-1 uint128) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.pextlb v1-0 0 arg0) + (.pextlb a0-1 0 arg1) + (.pextlh v1-1 0 v1-0) + (.pextlh a0-2 0 a0-1) + (.mov vf1 v1-1) + (.mov vf2 a0-2) + (.mov vf3 arg2) + (.itof.vf vf1 vf1) + (.itof.vf vf2 vf2) + (.mul.w.vf acc vf1 vf0) + (.add.mul.x.vf acc vf2 vf3 acc) + (.sub.mul.x.vf vf1 vf1 vf3 acc) + (.ftoi.vf vf3 vf1) + (.mov a1-1 vf3) + (.ppach a2-1 (the-as uint128 0) a1-1) + (.ppacb v0-0 (the-as uint128 0) a2-1) + (the-as rgba v0-0) + ) + ) + +(defun seekl ((arg0 int) (arg1 int) (arg2 int)) + "Move arg0 toward arg1, by at most arg2." + (let* ((v1-0 (- arg1 arg0)) + (a3-0 (abs v1-0)) + ) + (cond + ((>= arg2 a3-0) + arg1 + ) + ((>= v1-0 0) + (+ arg0 arg2) + ) + (else + (- arg0 arg2) + ) + ) + ) + ) + +(defmacro seek! (place target rate) + "Macro to use seek in-place. place is the base, and where the result is stored." + `(set! ,place (seek ,place ,target ,rate)) + ) + +(defmacro seekl! (place target rate) + "Macro to use seekl in-place. place is the base, and where the result is stored." + `(set! ,place (seekl ,place ,target ,rate)) + ) + +(defmacro seek-ease! (place target rate min-threshold rate-min) + "Macro to use seek-ease in-place. place is the base, and where the result is stored." + `(set! ,place (seek-ease ,place ,target ,rate ,min-threshold ,rate-min)) + ) + +;; in the PS2 there is a R register for generating random numbers +;; it is a "32-bit" register, but the upper bits are fixed so it always +;; represents a float in (1, 2). +;; we don't have this register on x86, so we add a special global: *_vu-reg-R_* +(define *_vu-reg-R_* 0) + +(defun rand-vu-init ((seed float)) + "Initialize the VU0 random generator." + ;; (.ctc2.i R arg0) + ;; (.cfc2.i v0 R) + (set! *_vu-reg-R_* + (logior #x3F800000 (logand (the-as int seed) #x007FFFFF)) + ) + (the-as float *_vu-reg-R_*) + ) + +(rand-vu-init 1.418091) + +(defun rand-vu () + "Get a random number in [0, 1) and advance the random generator." + ;; (.vrget.xyzw vf1) - get current random + (let ((current-random *_vu-reg-R_*)) + ;; here they update the random generate with some junk + ;; for now, we don't do this in OpenGOAL. + ;; (.vsqrty Q vf1) + ;; (.vaddq.x vf2 vf0 Q) ;; you're not allowed to do this! + ;; (.vrxorw vf2) + + ;; and advance + ;; (.vrnext.xyzw vf1) + (let ((x (logand 1 (shr current-random 4))) + (y (logand 1 (shr current-random 22))) + ) + (set! current-random (shl current-random 1)) + (set! current-random (logxor current-random (logxor x y))) + (logxor! current-random (pc-rand)) + (set! *_vu-reg-R_* (logior #x3f800000 (logand current-random #x7fffff))) + ) + ) + + ;; (.vsubw.xyzw vf1 vf1 vf0) + ;; (.qmfc2.i v0 vf1) + (- (the-as float *_vu-reg-R_*) 1.0) + ) + +(defun rand-vu-nostep () + "Get the number currently in the random generator. + This will be equal to the last call of (rand-vu) + This will not update the random generator" + (- (the-as float *_vu-reg-R_*) 1.0) + ) + +(defun rand-vu-float-range ((arg0 float) (arg1 float)) + "Get a random float in between arg0 and arg1." + (+ arg0 (* (rand-vu) (- arg1 arg0))) + ) + +(defun rand-vu-percent? ((arg0 float)) + "Get a boolean that's true with the given probability (in 0, 1)." + (>= arg0 (rand-vu)) + ) + +(defun rand-vu-int-range ((arg0 int) (arg1 int)) + "Get an integer in the given range (inclusive)." + (if (< arg0 arg1) + (set! arg1 (+ arg1 1)) + (set! arg0 (+ arg0 1)) + ) + (let ((f0-4 (rand-vu-float-range (the float arg0) (the float arg1)))) + (if (< f0-4 0.0) + (set! f0-4 (+ -1.0 f0-4)) + ) + (the int f0-4) + ) + ) + +(defun rand-vu-int-count ((arg0 int)) + "Get an integer in the range [0, max)." + (the int (* (rand-vu) (the float arg0))) + ) + +;; WARN: new jak 2 until loop case, check carefully +(defun rand-vu-int-count-excluding ((arg0 int) (arg1 int)) + "Get an integer in the range [0, arg0). +If bit n is set in arg1, exclude this value from being returned." + (let ((s4-0 0) + (s5-0 0) + ) + (let ((v1-0 1)) + (while (nonzero? arg0) + (+! arg0 -1) + (if (not (logtest? arg1 v1-0)) + (+! s4-0 1) + ) + (set! v1-0 (* v1-0 2)) + ) + ) + (when (> s4-0 0) + (let ((v1-4 (the int (* (rand-vu) (the float s4-0)))) + (a0-1 1) + ) + (until #f + (while (logtest? arg1 a0-1) + (nop!) + (nop!) + (+! s5-0 1) + (set! a0-1 (* a0-1 2)) + ) + (if (zero? v1-4) + (goto cfg-14) + ) + (+! v1-4 -1) + (+! s5-0 1) + (set! a0-1 (* a0-1 2)) + ) + ) + #f + ) + (label cfg-14) + s5-0 + ) + ) + +;; WARN: new jak 2 until loop case, check carefully +(defun rand-vu-int-range-exclude ((arg0 int) (arg1 int) (arg2 int)) + "Get an integer in the range [0, arg0), excluding arg2. +Note that this doesn't use bits like rand-vu-int-count-excluding." + (until #f + (let ((v1-0 (rand-vu-int-range arg0 arg1))) + (if (!= v1-0 arg2) + (return v1-0) + ) + ) + ) + (the-as int #f) + ) + +(deftype random-generator (basic) + ((seed uint32) + ) + ) + + +(define *random-generator* (new 'global 'random-generator)) + +(set! (-> *random-generator* seed) (the-as uint #x666edd1e)) + +(defmacro sext32-64 (x) + "Sign extend a 32-bit value to 64-bits" + `(sar (shl ,x 32) 32) + ) + +(defun rand-uint31-gen ((gen random-generator)) + "Generate a supposedly random integer. + Note, this might not quite be right. + But the highest bit is always zero, like it says + and it looks kinda random to me." + (let* ((sd (-> gen seed)) + ;; addiu v1, r0, 16807 + ;; mult3 v0, v1, a1 + (prod (imul64 16807 sd)) + ;; mfhi v1 + (hi (shr prod 32)) ;; sign extend this? + (lo (sar (shl prod 32) 32)) + ;; daddu v1, v1, v1 + (v1 (+ hi hi)) + ;; srl a1, v0, 31 + (a1 (logand #xffffffff (shr lo 31))) + ;; or v1, v1, a1 + ;; daddu v0, v0 v1 + (result (+ lo (logior v1 a1))) + ) + (set! result (shr (logand #xffffffff (shl result 1)) 1)) + (set! (-> gen seed) result) + (the uint result) + ) + ) + +(defun cube-root ((arg0 float)) + "Cube root with cool trick that I don't understand." + (cond + ((!= arg0 0.0) + (let* ((v1-0 arg0) + (a1-2 (+ (logand (shr (the-as int v1-0) 23) 255) -127)) + (f0-1 (the-as float + (logior (logand (the-as uint #x807fffff) (the-as uint v1-0)) (shl (+ (/ (the-as int a1-2) 3) 127) 23)) + ) + ) + ) + ;; somehow f0-1 is a reasonable approximation of cube-root. + ;; then we do 6 iterations of newton's method to get a more accurate answer. + (dotimes (v1-3 6) + (set! f0-1 (- f0-1 + (/ (- (* (* f0-1 f0-1) f0-1) arg0) + (* 3.0 f0-1 f0-1) + ) + ) + ) + ) + f0-1 + ) + ) + (else + 0.0 + ) + ) + ) + +(defun int-noise ((arg0 int)) + "Generate random-ish floats in range -1, 1." + (let ((v1-1 (logxor (shl arg0 13) arg0))) + (- 1.0 (* 0.0000000009313226 + (the float (logand #x7fffffff (+ #x5208dd0d (* v1-1 (+ #xc0ae5 (* (* #x3d73 v1-1) v1-1)))))) + ) + ) + ) + ) + +(defun smooth-step ((arg0 float)) + "Interpolate between 0, 1 with a cubic polynomial. + These are picked so f(0) = 0, f(1) = 1, f'(0) = f'(1) = 0." + (cond + ((>= 0.0 arg0) + 0.0 + ) + ((>= arg0 1.0) + 1.0 + ) + (else + (* arg0 arg0 (+ 3.0 (* -2.0 arg0))) + ) + ) + ) + +(defun smooth-interp ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Remap arg2 from (arg3, arg4) to (arg0, arg1), using cubic interpolation. + Satisfies: + - f(arg3) = arg0 + - f(arg4) = arg1 + - f'(arg3) = f'(arg4) = 0" + (+ arg0 (* (- arg1 arg0) (smooth-step (/ (- arg2 arg3) (- arg4 arg3))))) + ) diff --git a/goal_src/jakx/engine/math/matrix-h.gc b/goal_src/jakx/engine/math/matrix-h.gc index 02e469697f..f2ac91a1f7 100644 --- a/goal_src/jakx/engine/math/matrix-h.gc +++ b/goal_src/jakx/engine/math/matrix-h.gc @@ -5,5 +5,105 @@ ;; name in dgo: matrix-h ;; dgos: ENGINE, GAME +(defmacro new-stack-matrix0 () + "Get a new matrix on the stack that's set to zero." + `(let ((mat (new 'stack-no-clear 'matrix))) + (set! (-> mat quad 0) (the-as uint128 0)) + (set! (-> mat quad 1) (the-as uint128 0)) + (set! (-> mat quad 2) (the-as uint128 0)) + (set! (-> mat quad 3) (the-as uint128 0)) + mat + ) + ) + ;; DECOMP BEGINS +(deftype matrix (structure) + "A 4x4 matrix, stored in row-major order. +some, but not all, functions assume that a matrix is an affine transform. +others assume that the rotation has no scale or shear (and that its inverse is its transpose)." + ((data float 16) + (vector vector 4 :inline :overlay-at (-> data 0)) + (quad uint128 4 :overlay-at (-> data 0)) + (rvec vector :inline :overlay-at (-> data 0)) + (uvec vector :inline :overlay-at (-> data 4)) + (fvec vector :inline :overlay-at (-> data 8)) + (trans vector :inline :overlay-at (-> data 12)) + ) + (:methods + (transform-vectors! (_type_ (inline-array vector) (inline-array vector) int) none) + ) + ) + + +(deftype matrix3 (structure) + "A 3x3 matrix, stored in row-major order. +NOTE: the rows each have an extra 4-bytes of padding, +so this is really a 3x4 matrix. +This type is rarely used." + ((data float 12) + (vector vector 3 :inline :overlay-at (-> data 0)) + (quad uint128 3 :overlay-at (-> data 0)) + ) + ) + + +(deftype matrix4h (structure) + "A matrix stored using 16-bit integers. +Note that these usually have different scaling for the 4th row which +contains the translation in an affine transform. +So you generally should not unpack these to floats without knowing where they came from +and how they were originally packed (for example, in tie/shrub)." + ((data int16 16) + (vector4h vector4h 4 :overlay-at (-> data 0)) + (long int64 4 :overlay-at (-> data 0)) + ) + ) + + +;; og:preserve-this +(defun matrix-copy! ((arg0 matrix) (arg1 matrix)) + "Copy arg1 to arg0" + (declare (inline)) + (let ((v1-0 (-> arg1 rvec quad)) + (a2-0 (-> arg1 uvec quad)) + (a3-0 (-> arg1 fvec quad)) + (a1-1 (-> arg1 trans quad)) + ) + (set! (-> arg0 rvec quad) v1-0) + (set! (-> arg0 uvec quad) a2-0) + (set! (-> arg0 fvec quad) a3-0) + (set! (-> arg0 trans quad) a1-1) + ) + arg0 + ) + +(defun matrix<-vector-yz-exact! ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (set! (-> arg0 uvec quad) (-> arg2 quad)) + (vector-cross! (-> arg0 rvec) (-> arg0 uvec) arg1) + arg0 + ) + +(defun matrix<-vector-yz! ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 rvec) arg2 arg1) + (vector-normalize! (-> arg0 rvec) 1.0) + (vector-cross! (-> arg0 uvec) arg1 (-> arg0 rvec)) + (set! (-> arg0 rvec w) 1.0) + (set! (-> arg0 uvec w) 1.0) + (set! (-> arg0 fvec w) 1.0) + arg0 + ) + +(defun matrix<-vector-z! ((arg0 matrix) (arg1 vector)) + (let* ((s3-0 (new 'stack-no-clear 'vector)) + (v1-0 (vector-get-closest-perpendicular! s3-0 arg1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1))) + (s4-1 arg0) + ) + (set! (-> s4-1 fvec quad) (-> arg1 quad)) + (set! (-> s4-1 uvec quad) (-> v1-0 quad)) + (vector-cross! (-> s4-1 rvec) (-> s4-1 uvec) arg1) + ) + arg0 + ) diff --git a/goal_src/jakx/engine/math/matrix.gc b/goal_src/jakx/engine/math/matrix.gc index b27680581b..f9863d647c 100644 --- a/goal_src/jakx/engine/math/matrix.gc +++ b/goal_src/jakx/engine/math/matrix.gc @@ -5,5 +5,1934 @@ ;; name in dgo: matrix ;; dgos: ENGINE, GAME +#|@file +This file implements the GOAL matrix library. + +In general, a vector is always treated as a row vector. +Chaining transformation is done like v_row * T1_goal * T2_goal, which means do T1 before T2. +This is the opposite of the usual convention: +T2_normal * T1_normal * v_col +However, there is good news: + T1_normal = T1_goal ^ T + T2_normal = T2_goal ^ T +This is due to the property + (A * B)^T = B^T * A^T + +So a homogeneous transformation is: +R_xx R_xy R_xz 0 +R_yx R_yy R_yz 0 +R_zx R_zy R_zz 0 +T_x T_y T_z 1 + +which is probably the transpose of what you're used to. + +note that they also used row-major storage, so the 3rd qword of a matrix is the translation +part of the affine transform. + +In general, be careful with using these functions as they often have strange +requirements for the form of the input matrix or if the input/output matrix are +allowed to be the same memory. +|# + ;; DECOMP BEGINS +(defun matrix-identity! ((arg0 matrix)) + "Set dst to the identity matrix." + (set! (-> arg0 rvec quad) (the-as uint128 0)) + (set! (-> arg0 uvec quad) (the-as uint128 0)) + (set! (-> arg0 fvec quad) (the-as uint128 0)) + (set! (-> arg0 trans quad) (the-as uint128 0)) + (let ((f0-0 1.0)) + (set! (-> arg0 trans w) f0-0) + (set! (-> arg0 fvec z) f0-0) + (set! (-> arg0 uvec y) f0-0) + (set! (-> arg0 rvec x) f0-0) + ) + arg0 + ) + +(define *identity-matrix* (matrix-identity! (new 'global 'matrix))) + +(define *hermite-matrix* (new 'static 'matrix + :rvec (new 'static 'vector :data (new 'static 'array float 4 2.0 -2.0 1.0 1.0)) + :uvec (new 'static 'vector :data (new 'static 'array float 4 -3.0 3.0 -2.0 -1.0)) + :fvec (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 1.0 0.0)) + :trans (new 'static 'vector :data (new 'static 'array float 4 1.0 0.0 0.0 0.0)) + ) + ) + +(defun matrix+! ((arg0 matrix) (arg1 matrix) (arg2 matrix)) + "Set dst = src1 + src2. It is okay for any arguments to be the same data. + This is not an efficient implementation." + (dotimes (v1-0 16) + (set! (-> arg0 rvec data v1-0) (+ (-> arg1 rvec data v1-0) (-> arg2 rvec data v1-0))) + ) + arg0 + ) + +(defun matrix-! ((arg0 matrix) (arg1 matrix) (arg2 matrix)) + "Set dst = src1 - src1. It is okay for any arugments to be the same data. + This is not an efficient implementation." + (dotimes (v1-0 16) + (set! (-> arg0 rvec data v1-0) (- (-> arg1 rvec data v1-0) (-> arg2 rvec data v1-0))) + ) + arg0 + ) + +(defun matrix*! ((arg0 matrix) (arg1 matrix) (arg2 matrix)) + "Set dst = src1 * src2. It is okay for any arguments to be the same data. + This is a moderately efficient implementation." + (rlet ((acc :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf20 :class vf) + (vf21 :class vf) + ) + (.lvf vf10 (&-> arg1 rvec quad)) + (.lvf vf14 (&-> arg2 rvec quad)) + (.lvf vf15 (&-> arg2 uvec quad)) + (.lvf vf16 (&-> arg2 fvec quad)) + (.lvf vf17 (&-> arg2 trans quad)) + (.lvf vf11 (&-> arg1 uvec quad)) + (.lvf vf12 (&-> arg1 fvec quad)) + (.lvf vf13 (&-> arg1 trans quad)) + (.mul.x.vf acc vf14 vf10) + (.add.mul.y.vf acc vf15 vf10 acc) + (.add.mul.z.vf acc vf16 vf10 acc) + (.add.mul.w.vf vf18 vf17 vf10 acc) + (.mul.x.vf acc vf14 vf11) + (.add.mul.y.vf acc vf15 vf11 acc) + (.add.mul.z.vf acc vf16 vf11 acc) + (.add.mul.w.vf vf19 vf17 vf11 acc) + (.mul.x.vf acc vf14 vf12) + (.add.mul.y.vf acc vf15 vf12 acc) + (.add.mul.z.vf acc vf16 vf12 acc) + (.add.mul.w.vf vf20 vf17 vf12 acc) + (.mul.x.vf acc vf14 vf13) + (.add.mul.y.vf acc vf15 vf13 acc) + (.add.mul.z.vf acc vf16 vf13 acc) + (.add.mul.w.vf vf21 vf17 vf13 acc) + (.svf (&-> arg0 rvec quad) vf18) + (.svf (&-> arg0 uvec quad) vf19) + (.svf (&-> arg0 fvec quad) vf20) + (.svf (&-> arg0 trans quad) vf21) + arg0 + ) + ) + +(defun matrixp*! ((arg0 matrix) (arg1 matrix) (arg2 matrix)) + "Set dst = src1 * src2. NOTE: this function is a wrapper around matrix*! + that adds no additional functionality. It seems to be a leftover from + a time when matrix*! wasn't safe to use in place. This is unused." + (let ((s5-0 (new-stack-matrix0))) + (matrix*! s5-0 arg1 arg2) + (set! (-> arg0 rvec quad) (-> s5-0 rvec quad)) + (set! (-> arg0 uvec quad) (-> s5-0 uvec quad)) + (set! (-> arg0 fvec quad) (-> s5-0 fvec quad)) + (set! (-> arg0 trans quad) (-> s5-0 trans quad)) + ) + arg0 + ) + +(defun vector-matrix*! ((arg0 vector) (arg1 vector) (arg2 matrix)) + "Set dst = vec * mat. dst may be equal to src." + (rlet ((acc :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (.lvf vf1 (&-> arg2 rvec quad)) + (.lvf vf2 (&-> arg2 uvec quad)) + (.lvf vf3 (&-> arg2 fvec quad)) + (.lvf vf4 (&-> arg2 trans quad)) + (.lvf vf5 (&-> arg1 quad)) + (.mul.x.vf acc vf1 vf5) + (.add.mul.y.vf acc vf2 vf5 acc) + (.add.mul.z.vf acc vf3 vf5 acc) + (.add.mul.w.vf vf5 vf4 vf5 acc) + (.svf (&-> arg0 quad) vf5) + arg0 + ) + ) + +(defun vector-norm-matrix*! ((arg0 vector) (arg1 vector) (arg2 matrix)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg2 rvec quad)) + (.lvf vf2 (&-> arg2 uvec quad)) + (.lvf vf3 (&-> arg2 fvec quad)) + (.lvf vf4 (&-> arg2 trans quad)) + (.lvf vf5 (&-> arg1 quad)) + (.mul.x.vf acc vf1 vf5) + (.add.mul.y.vf acc vf2 vf5 acc) + (.add.mul.z.vf acc vf3 vf5 acc) + (.add.mul.w.vf vf5 vf4 vf5 acc) + (.div.vf Q vf0 vf5 :fsf #b11 :ftf #b11) + (.wait.vf) + (.mul.vf.xyz vf5 vf5 Q) + (.nop.vf) + (.nop.vf) + (.mov.vf.w vf5 vf0) + (.svf (&-> arg0 quad) vf5) + arg0 + ) + ) + +(defun vector-rotate*! ((arg0 vector) (arg1 vector) (arg2 matrix)) + "Set dst to be the input vector rotated by the rotation part of mat. + The input matrix should be a homogeneous transform with a rotation matrix as its upper-left 3x3. + dst may be equal to src." + (rlet ((acc :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (nop!) + (nop!) + (.lvf vf5 (&-> arg1 quad)) + (nop!) + (.lvf vf1 (&-> arg2 rvec quad)) + (nop!) + (.lvf vf2 (&-> arg2 uvec quad)) + (.mul.x.vf acc vf1 vf5) + (.lvf vf3 (&-> arg2 fvec quad)) + (.add.mul.y.vf acc vf2 vf5 acc) + (.lvf vf4 (&-> arg2 trans quad)) + (.add.mul.z.vf vf5 vf3 vf5 acc) + (nop!) + (nop!) + (.svf (&-> arg0 quad) vf5) + arg0 + ) + ) + +(defun vector3s-matrix*! ((arg0 vector3s) (arg1 vector3s) (arg2 matrix)) + "Set dst to be ([src 1.0] * mat).xyz. Doesn't touch the w of dst. + dst and vec can be the same memory" + (let ((s5-0 (new-stack-vector0))) + (set-vector! s5-0 (-> arg1 x) (-> arg1 y) (-> arg1 z) 1.0) + (vector-matrix*! s5-0 s5-0 arg2) + (set! (-> arg0 x) (-> s5-0 x)) + (set! (-> arg0 y) (-> s5-0 y)) + (set! (-> arg0 z) (-> s5-0 z)) + ) + arg0 + ) + +(defun vector3s-rotate*! ((arg0 vector3s) (arg1 vector3s) (arg2 matrix)) + "Set dst to vec rotated by the rotation in the homogeneous transform mat. + mat should not have a scale/shear (the upper 3x3 should be a pure rotation)." + (let ((s5-0 (new-stack-vector0))) + (set-vector! s5-0 (-> arg1 x) (-> arg1 y) (-> arg1 z) 1.0) + (vector-rotate*! s5-0 s5-0 arg2) + (set! (-> arg0 x) (-> s5-0 x)) + (set! (-> arg0 y) (-> s5-0 y)) + (set! (-> arg0 z) (-> s5-0 z)) + ) + arg0 + ) + +(defun matrix-transpose! ((dst matrix) (src matrix)) + "Set dst = src^T. src and dst can be the same." + (local-vars + (v1-0 uint128) + (v1-1 uint128) + (v1-2 uint128) + (a1-1 uint128) + (a2-1 uint128) + (a3-1 uint128) + (a3-2 uint128) + (t0-1 uint128) + ) + (let ((t0-0 (-> src vector 0 quad))) + (let ((t1-0 (-> src vector 1 quad))) + (let ((a2-0 (-> src vector 2 quad))) + (.pextlw v1-0 t1-0 t0-0) + (let ((a3-0 (-> src vector 3 quad))) + (.pextuw a1-1 t1-0 t0-0) + ;; (.mov r0-0 f31-0) not sure what this weird thing is. + ;; it has no effect, but they use it instead of nop sometimes? + (.pextlw t0-1 a3-0 a2-0) + ;; (.mov r0-1 f31-0) + (.pextuw a2-1 a3-0 a2-0) + ) + ) + ) + ) + ;; (.mov r0-2 f31-0) + (.pcpyld a3-1 t0-1 v1-0) + ;; (.mov r0-3 f31-0) + (.pcpyud v1-1 v1-0 t0-1) + (set! (-> dst vector 0 quad) a3-1) + (.pcpyld a3-2 a2-1 a1-1) + (set! (-> dst vector 1 quad) v1-1) + (.pcpyud v1-2 a1-1 a2-1) + (set! (-> dst vector 2 quad) a3-2) + (set! (-> dst vector 3 quad) v1-2) + dst + ) + +(defun matrix-inverse-of-rot-trans! ((arg0 matrix) (arg1 matrix)) + "Set dst = src^-1, assuming src is a homogeneous tranform with only rotation/translation. + NOTE: THIS FUNCTION REQUIRES dst != src" + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf8 :class vf) + ) + (init-vf0-vector) + (matrix-transpose! arg0 arg1) + (.lvf vf1 (&-> arg0 rvec quad)) + (.lvf vf2 (&-> arg0 uvec quad)) + (.lvf vf3 (&-> arg0 fvec quad)) + (.sub.vf.w vf1 vf1 vf1) + (.sub.vf.w vf2 vf2 vf2) + (.sub.vf.w vf3 vf3 vf3) + (.lvf vf8 (&-> arg1 trans quad)) + (.mul.x.vf acc vf1 vf8) + (.add.mul.y.vf acc vf2 vf8 acc) + (.add.mul.z.vf vf4 vf3 vf8 acc) + (.sub.vf vf4 vf0 vf4) + (.mov.vf.w vf4 vf0) + (.svf (&-> arg0 rvec quad) vf1) + (.svf (&-> arg0 uvec quad) vf2) + (.svf (&-> arg0 fvec quad) vf3) + (.svf (&-> arg0 trans quad) vf4) + arg0 + ) + ) + +;; ERROR: Bad vector register dependency: vf3 +;; ERROR: Bad vector register dependency: vf4 +;; ERROR: Bad vector register dependency: vf5 +(defun matrix-4x4-inverse! ((arg0 matrix) (arg1 matrix)) + "Invert a 4x4 matrix. This assumes that the input is a homogeneous transform. + Src and dst can be the same." + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf2 :class vf) + (vf20 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf3 :class vf) + (vf30 :class vf) + (vf31 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + + ;; og:preserve-this + ;; ADDED: the original implementation does math on vectors where some values are + ;; uninitialized. It doesn't use the result, so there's no problem, but this + ;; may cause strange slowdowns on x86 where doing math on NaNs can be extremely slow. + ;; ideally we should find a better solution. + (.xor.vf vf26 vf26 vf26) + (.xor.vf vf27 vf27 vf27) + (.xor.vf vf28 vf28 vf28) + (.xor.vf vf29 vf29 vf29) + (.xor.vf vf30 vf30 vf30) + (.xor.vf vf31 vf31 vf31) + (.xor.vf vf16 vf16 vf16) + (.xor.vf vf17 vf17 vf17) + (.xor.vf vf18 vf18 vf18) + (.xor.vf vf23 vf23 vf23) + (.xor.vf vf19 vf19 vf19) + (.xor.vf vf3 vf3 vf3) + (.xor.vf vf4 vf4 vf4) + (.xor.vf vf5 vf5 vf5) + + (init-vf0-vector) + (nop!) + (nop!) + (.lvf vf23 (&-> arg1 quad 0)) + (nop!) + (.lvf vf24 (&-> arg1 quad 1)) + (nop!) + (.lvf vf25 (&-> arg1 quad 2)) + (nop!) + (.lvf vf1 (&-> arg1 trans quad)) + (.mul.x.vf vf7 vf24 vf23) + (nop!) + (.mul.y.vf vf8 vf24 vf23) + (nop!) + (.mul.z.vf vf9 vf24 vf23) + (nop!) + (.mul.x.vf vf10 vf25 vf23) + (nop!) + (.mul.y.vf vf11 vf25 vf23) + (nop!) + (.mul.z.vf vf12 vf25 vf23) + (nop!) + (.mul.x.vf vf13 vf25 vf24) + (nop!) + (.mul.y.vf vf14 vf25 vf24) + (nop!) + (.mul.z.vf vf15 vf25 vf24) + (nop!) + (.mul.z.vf.y vf26 vf7 vf25) + (nop!) + (.mul.z.vf.x vf27 vf11 vf24) + (nop!) + (.mul.y.vf.x vf28 vf9 vf25) + (nop!) + (.mul.z.vf.x vf29 vf14 vf23) + (nop!) + (.mul.z.vf.x vf30 vf8 vf25) + (nop!) + (.mul.y.vf.z vf31 vf7 vf25) + (nop!) + (.add.y.vf.x vf16 vf27 vf26) + (nop!) + (.sub.vf vf1 vf0 vf1) + (nop!) + (.add.x.vf.x vf17 vf29 vf30) + (nop!) + (.sub.z.vf.x vf18 vf28 vf31) + (nop!) + (.sub.y.vf.z vf23 vf14 vf15) + (nop!) + (.sub.z.vf.x vf26 vf15 vf13) + (nop!) + (.sub.x.vf.y vf29 vf13 vf14) + (nop!) + (.sub.vf.x vf19 vf16 vf17) + (nop!) + (.sub.z.vf.y vf24 vf12 vf11) + (nop!) + (.sub.x.vf.z vf27 vf10 vf12) + (nop!) + (.sub.y.vf.x vf30 vf11 vf10) + (nop!) + (.add.vf.x vf20 vf19 vf18) + (nop!) + (.sub.y.vf.z vf25 vf8 vf9) + (nop!) + (.sub.z.vf.x vf28 vf9 vf7) + (nop!) + (.sub.x.vf.y vf31 vf7 vf8) + (nop!) + (.div.vf Q vf0 vf20 :fsf #b11 :ftf #b0) + (nop!) + (.sub.w.vf.w vf3 vf3 vf3) + (nop!) + (.sub.w.vf.w vf4 vf4 vf4) + (nop!) + (.sub.w.vf.w vf5 vf5 vf5) + (nop!) + (.mov.vf.w vf6 vf0) + (nop!) + (.wait.vf) + (nop!) + (.add.vf.x vf2 vf0 Q) + (nop!) + (.add.x.vf.xyz vf2 vf0 vf2) + (nop!) + (.mul.z.vf.x vf3 vf2 vf23) + (nop!) + (.mul.x.vf.x vf4 vf2 vf26) + (nop!) + (.mul.y.vf.x vf5 vf2 vf29) + (nop!) + (.mul.y.vf.y vf3 vf2 vf24) + (nop!) + (.mul.z.vf.y vf4 vf2 vf27) + (nop!) + (.mul.x.vf.y vf5 vf2 vf30) + (nop!) + (.mul.z.vf.z vf3 vf2 vf25) + (nop!) + (.mul.x.vf.z vf4 vf2 vf28) + (nop!) + (.mul.y.vf.z vf5 vf2 vf31) + (nop!) + (.mul.x.vf acc vf3 vf1) + (.svf (&-> arg0 quad 0) vf3) + (.add.mul.y.vf acc vf4 vf1 acc) + (.svf (&-> arg0 quad 1) vf4) + (.add.mul.z.vf.xyz vf6 vf5 vf1 acc) + (.svf (&-> arg0 quad 2) vf5) + (nop!) + (.svf (&-> arg0 trans quad) vf6) + arg0 + ) + ) + +(defun matrix-translate! ((arg0 matrix) (arg1 vector)) + "Set dst to a homogeneous transform with only a translation of trans." + (matrix-identity! arg0) + (set! (-> arg0 trans x) (-> arg1 x)) + (set! (-> arg0 trans y) (-> arg1 y)) + (set! (-> arg0 trans z) (-> arg1 z)) + arg0 + ) + +(defun matrix-translate+! ((arg0 matrix) (arg1 matrix) (arg2 vector)) + "Add the given translation to the translation of homogenous transform mat src + and store in dst. It is okay for dst = src." + (set! (-> arg0 trans x) (+ (-> arg1 trans x) (-> arg2 x))) + (set! (-> arg0 trans y) (+ (-> arg1 trans y) (-> arg2 y))) + (set! (-> arg0 trans z) (+ (-> arg1 trans z) (-> arg2 z))) + (when (!= arg0 arg1) + (set! (-> arg0 rvec quad) (-> arg1 rvec quad)) + (set! (-> arg0 uvec quad) (-> arg1 uvec quad)) + (set! (-> arg0 fvec quad) (-> arg1 fvec quad)) + ) + arg0 + ) + +(defun matrix-scale! ((arg0 matrix) (arg1 vector)) + "Set dst to a homogenous transform with only a scale. The x,y,z components + of scale become the x,y,z scaling factors" + (set! (-> arg0 rvec quad) (the-as uint128 0)) + (set! (-> arg0 uvec quad) (the-as uint128 0)) + (set! (-> arg0 fvec quad) (the-as uint128 0)) + (set! (-> arg0 trans quad) (the-as uint128 0)) + (set! (-> arg0 rvec x) (-> arg1 x)) + (set! (-> arg0 uvec y) (-> arg1 y)) + (set! (-> arg0 fvec z) (-> arg1 z)) + (set! (-> arg0 trans w) 1.0) + arg0 + ) + +(defun scale-matrix! ((arg0 matrix) (arg1 vector) (arg2 matrix)) + "Scale an existing matrix. Okay for dst = src. The scaling is applied per row. + This means the x component of scale is used to scale the first row of src. + The w component of scale is used." + (rlet ((vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + ) + (.lvf vf4 (&-> arg1 quad)) + (.lvf vf5 (&-> arg2 rvec quad)) + (.lvf vf6 (&-> arg2 uvec quad)) + (.lvf vf7 (&-> arg2 fvec quad)) + (.lvf vf8 (&-> arg2 trans quad)) + (.mul.x.vf vf5 vf5 vf4) + (.mul.y.vf vf6 vf6 vf4) + (.mul.z.vf vf7 vf7 vf4) + (.mul.w.vf vf8 vf8 vf4) + (.svf (&-> arg0 rvec quad) vf5) + (.svf (&-> arg0 uvec quad) vf6) + (.svf (&-> arg0 fvec quad) vf7) + (.svf (&-> arg0 trans quad) vf8) + arg0 + ) + ) + +(defun matrix-inv-scale! ((arg0 matrix) (arg1 vector)) + "Set dst to a homogeneous transform with only a scale. + The x,y,z components of scale are inverted and used as the x,y,z scaling factors" + (set! (-> arg0 rvec quad) (the-as uint128 0)) + (set! (-> arg0 uvec quad) (the-as uint128 0)) + (set! (-> arg0 fvec quad) (the-as uint128 0)) + (set! (-> arg0 trans quad) (the-as uint128 0)) + (set! (-> arg0 rvec x) (/ 1.0 (-> arg1 x))) + (set! (-> arg0 uvec y) (/ 1.0 (-> arg1 y))) + (set! (-> arg0 fvec z) (/ 1.0 (-> arg1 z))) + (set! (-> arg0 trans w) 1.0) + arg0 + ) + +(defun column-scale-matrix! ((arg0 matrix) (arg1 vector) (arg2 matrix)) + "Scale an existing matrix. Okay for dst = src. The scaling is applied column-wise. + Meaning the x component of scale will scale the first column of src." + (rlet ((vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + ) + (.lvf vf4 (&-> arg1 quad)) + (.lvf vf5 (&-> arg2 rvec quad)) + (.lvf vf6 (&-> arg2 uvec quad)) + (.lvf vf7 (&-> arg2 fvec quad)) + (.lvf vf8 (&-> arg2 trans quad)) + (.mul.vf vf5 vf5 vf4) + (.mul.vf vf6 vf6 vf4) + (.mul.vf vf7 vf7 vf4) + (.mul.vf vf8 vf8 vf4) + (.svf (&-> arg0 rvec quad) vf5) + (.svf (&-> arg0 uvec quad) vf6) + (.svf (&-> arg0 fvec quad) vf7) + (.svf (&-> arg0 trans quad) vf8) + arg0 + ) + ) + +(defun matrix-rotate-x! ((arg0 matrix) (arg1 float)) + "Set dst to a homogeneous transform matrix for a rotation around the x-axis (degrees)." + (let ((f30-0 (sin arg1)) + (f0-0 (cos arg1)) + ) + (set! (-> arg0 rvec quad) (the-as uint128 0)) + (set! (-> arg0 uvec quad) (the-as uint128 0)) + (set! (-> arg0 fvec quad) (the-as uint128 0)) + (set! (-> arg0 trans quad) (the-as uint128 0)) + (set! (-> arg0 rvec x) 1.0) + (set! (-> arg0 uvec y) f0-0) + (set! (-> arg0 uvec z) f30-0) + (set! (-> arg0 fvec y) (- f30-0)) + (set! (-> arg0 fvec z) f0-0) + ) + (set! (-> arg0 trans w) 1.0) + arg0 + ) + +(defun matrix-rotate-y! ((arg0 matrix) (arg1 float)) + "Set dst to a homoegeneous transform matrix for a rotation around the y axis (degrees)." + (let ((f30-0 (sin arg1)) + (f0-0 (cos arg1)) + ) + (set! (-> arg0 rvec quad) (the-as uint128 0)) + (set! (-> arg0 uvec quad) (the-as uint128 0)) + (set! (-> arg0 fvec quad) (the-as uint128 0)) + (set! (-> arg0 trans quad) (the-as uint128 0)) + (set! (-> arg0 rvec x) f0-0) + (set! (-> arg0 rvec z) (- f30-0)) + (set! (-> arg0 uvec y) 1.0) + (set! (-> arg0 fvec x) f30-0) + (set! (-> arg0 fvec z) f0-0) + ) + (set! (-> arg0 trans w) 1.0) + arg0 + ) + +(defun matrix-rotate-z! ((arg0 matrix) (arg1 float)) + "Set dst to a homogeneous transform matrix for a rotation around the z-axis (degrees)." + (let ((f30-0 (sin arg1)) + (f0-0 (cos arg1)) + ) + (set! (-> arg0 rvec quad) (the-as uint128 0)) + (set! (-> arg0 uvec quad) (the-as uint128 0)) + (set! (-> arg0 fvec quad) (the-as uint128 0)) + (set! (-> arg0 trans quad) (the-as uint128 0)) + (set! (-> arg0 rvec x) f0-0) + (set! (-> arg0 rvec y) f30-0) + (set! (-> arg0 uvec x) (- f30-0)) + (set! (-> arg0 uvec y) f0-0) + ) + (set! (-> arg0 fvec z) 1.0) + (set! (-> arg0 trans w) 1.0) + arg0 + ) + +(defun matrix-rotate-zyx! ((arg0 matrix) (arg1 vector)) + "Rotate in z,y,x order." + (let ((gp-0 (new-stack-matrix0)) + (s5-0 (new-stack-matrix0)) + ) + (matrix-rotate-x! arg0 (-> arg1 x)) + (matrix-rotate-y! gp-0 (-> arg1 y)) + (matrix*! s5-0 gp-0 arg0) + (matrix-rotate-z! gp-0 (-> arg1 z)) + (matrix*! arg0 gp-0 s5-0) + ) + arg0 + ) + +(defun-debug matrix-rotate-xyz-2! ((arg0 matrix) (arg1 vector)) + "Jak 1 version of matrix-rotate-xyz. Slower than the one below." + (let ((gp-0 (new 'stack-no-clear 'matrix)) + (s5-0 (new 'stack-no-clear 'matrix)) + ) + (matrix-rotate-z! arg0 (-> arg1 z)) + (matrix-rotate-y! gp-0 (-> arg1 y)) + (matrix*! s5-0 gp-0 arg0) + (matrix-rotate-x! gp-0 (-> arg1 x)) + (matrix*! arg0 gp-0 s5-0) + ) + arg0 + ) + +(defun matrix-rotate-xyz! ((arg0 matrix) (arg1 vector)) + "Rotate in x,y,z order." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (vector-sincos! s4-0 s5-0 arg1) + (let ((f2-0 (-> s4-0 x)) + (f5-0 (-> s4-0 y)) + (f3-0 (-> s4-0 z)) + (f0-0 (-> s5-0 x)) + (f1-0 (-> s5-0 y)) + ) + (let ((f4-0 (-> s5-0 z))) + (set! (-> arg0 rvec x) (* f1-0 f4-0)) + (set! (-> arg0 rvec y) (* f1-0 f3-0)) + (set! (-> arg0 rvec z) (- f5-0)) + (set! (-> arg0 rvec w) 0.0) + (let ((f6-4 (* f2-0 f5-0)) + (f5-1 (* f0-0 f5-0)) + ) + (set! (-> arg0 uvec x) (- (* f6-4 f4-0) (* f0-0 f3-0))) + (set! (-> arg0 uvec y) (+ (* f6-4 f3-0) (* f0-0 f4-0))) + (set! (-> arg0 uvec z) (* f2-0 f1-0)) + (set! (-> arg0 uvec w) 0.0) + (set! (-> arg0 fvec x) (+ (* f2-0 f3-0) (* f5-1 f4-0))) + (set! (-> arg0 fvec y) (- (* f5-1 f3-0) (* f2-0 f4-0))) + ) + ) + (set! (-> arg0 fvec z) (* f0-0 f1-0)) + ) + ) + (set! (-> arg0 fvec w) 0.0) + (.svf (&-> arg0 trans quad) vf0) + arg0 + ) + ) + +(defun matrix-rotate-zxy! ((arg0 matrix) (arg1 vector)) + "Rotate in z,x,y order." + (let ((gp-0 (new-stack-matrix0)) + (s5-0 (new-stack-matrix0)) + ) + (matrix-rotate-y! arg0 (-> arg1 y)) + (matrix-rotate-x! gp-0 (-> arg1 x)) + (matrix*! s5-0 gp-0 arg0) + (matrix-rotate-z! gp-0 (-> arg1 z)) + (matrix*! arg0 gp-0 s5-0) + ) + arg0 + ) + +(defun matrix-rotate-yxz! ((arg0 matrix) (arg1 vector)) + "Rotate in y,x,z order." + (let ((gp-0 (new-stack-matrix0)) + (s5-0 (new-stack-matrix0)) + ) + (matrix-rotate-z! arg0 (-> arg1 z)) + (matrix-rotate-x! gp-0 (-> arg1 x)) + (matrix*! s5-0 gp-0 arg0) + (matrix-rotate-y! gp-0 (-> arg1 y)) + (matrix*! arg0 gp-0 s5-0) + ) + arg0 + ) + +(defun matrix-rotate-yzx! ((arg0 matrix) (arg1 vector)) + "Rotate in y,z,x order." + (let ((gp-0 (new-stack-matrix0)) + (s5-0 (new-stack-matrix0)) + ) + (matrix-rotate-z! arg0 (-> arg1 x)) + (matrix-rotate-x! gp-0 (-> arg1 z)) + (matrix*! s5-0 gp-0 arg0) + (matrix-rotate-y! gp-0 (-> arg1 y)) + (matrix*! arg0 gp-0 s5-0) + ) + arg0 + ) + +(defun matrix-rotate-yxy! ((arg0 matrix) (arg1 vector)) + "Rotate. I believe in yxy order? Compared to the other rotations, this one + is quite a bit more optimized and avoid repeated trig operations." + (let ((a2-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (set-vector! a2-0 (-> arg1 x) (- (-> arg1 y) (-> arg1 z)) (-> arg1 z) 1.0) + (vector-sincos! s5-0 s4-0 a2-0) + (let ((f1-1 (-> s4-0 y)) + (f0-5 (-> s5-0 y)) + (f2-0 (-> s4-0 x)) + (f5-0 (-> s5-0 x)) + (f3-0 (-> s4-0 z)) + (f4-0 (-> s5-0 z)) + ) + (set! (-> arg0 rvec x) (- (* f1-1 f3-0) (* f0-5 f2-0 f4-0))) + (set! (-> arg0 rvec y) (* f0-5 f5-0)) + (set! (-> arg0 rvec z) (- (+ (* f1-1 f4-0) (* f0-5 f2-0 f3-0)))) + (set! (-> arg0 rvec w) 0.0) + (set! (-> arg0 uvec x) (* f5-0 f4-0)) + (set! (-> arg0 uvec y) f2-0) + (set! (-> arg0 uvec z) (* f5-0 f3-0)) + (set! (-> arg0 uvec w) 0.0) + (set! (-> arg0 fvec x) (+ (* f0-5 f3-0) (* f1-1 f2-0 f4-0))) + (set! (-> arg0 fvec y) (- (* f1-1 f5-0))) + (set! (-> arg0 fvec z) (- (* f1-1 f2-0 f3-0) (* f0-5 f4-0))) + ) + ) + (set! (-> arg0 fvec w) 0.0) + (set! (-> arg0 trans x) 0.0) + (set! (-> arg0 trans y) 0.0) + (set! (-> arg0 trans z) 0.0) + (set! (-> arg0 trans w) 1.0) + arg0 + ) + +(defun matrix-rotate-yx! ((arg0 matrix) (arg1 float) (arg2 float)) + "Rotate by y then x." + (matrix-rotate-y! arg0 arg1) + (let* ((t9-1 matrix-rotate-x!) + (a0-2 (new-stack-matrix0)) + (a1-2 (t9-1 a0-2 arg2)) + ) + (matrix*! arg0 a1-2 arg0) + ) + arg0 + ) + +;; WARN: Return type mismatch matrix vs none. +;; ERROR: Unsupported inline assembly instruction kind - [prot3w a1, v1] +;; ERROR: Unsupported inline assembly instruction kind - [prot3w a2, a1] +(defun matrix-axis-sin-cos-vu! ((arg0 matrix) (arg1 vector) (arg2 float) (arg3 float)) + "Create an axis-angle rotation matrix. But given the sin/cos of the angle. Uses the VU." + ;; og:preserve-this unused and basically identital to the non-VU version, so I'm leaving this out. + (/ 0 0) + (none) + ) + +;; ERROR: Unsupported inline assembly instruction kind - [prot3w a0, v1] +;; ERROR: Unsupported inline assembly instruction kind - [prot3w a1, a0] +(defun matrix-axis-sin-cos! ((dst matrix) (axis vector) (s float) (c float)) + "Create an axis-angle rotation matrix. But given the sin/cos of the angle." + ;;or v0, a0, r0 + ;;or v1, a1, r0 + ;;mtc1 f0, a2 + ;;mtc1 f1, a3 + ;;sll r0, r0, 0 + + ;; input scramble: + ;; - v0 = dst + ;; - v1 = axis + ;; - f0 = sine + ;; - f1 = cosine + (rlet ((vf5 :class vf) ;; vf5.x will be sine, vf5.w will be -cosine + (vf6 :class vf) ;; vf6.x will be cosine + (vf1 :class vf) ;; vector. + (vf0 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf11 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + (vf10 :class vf) + (a1 :class i128 :type uint128) + (r0 :class i128 :type uint128)) ;; will be used for zero check. + ;; initialize constant vectors + (init-vf0-vector) + (.xor.p r0 r0 r0) + + ;; this is an overly complicated check to see if xyz = 0. + + (let ((a0 65535) ;; ori a0, r0, 65535 + (v1 (-> axis quad))) ;; lq v1, 0(v1) + + ;; this a0 constant has ffff in the upper 16 bits to mask out w, later on. + ;; dsll32 a0, a0, 16 + (set! a0 (shl a0 48)) ;; a0 = ffff'0000'0000'0000 + + ;;mfc1 a1, f1 + ;;qmtc2.i vf6, a1 + (.mov vf6 c) ;; will set vf6.x to cosine. + + ;;pceqw a1, v1, r0 + ;; compare for equality with zero. + ;; this will set 32-bits for each component. + (.pceqw a1 v1 r0) + + ;; so we pack: [upper64, w0?16, z0?16, y0?16, x0?16] + (.ppach a1 r0 a1) + + ;;qmtc2.i vf1, v1 + (.mov vf1 v1) ;; should be quad move! + + ;;or v1, a1, a0 + ;; make it seem like w is zero. If x,y,z = 0, but w != 0, we want + ;; it to act like zero. + (let ((xyz-zero (logior a0 (the uint a1)))) + ;;mfc1 a0, f0 + ;;qmtc2.i vf5, a0 + (.mov vf5 s) + + ;;daddiu v1, v1, 1 + ;; if all is zero, this will overflow and give us 0. + (+! xyz-zero 1) + + ;;vsubx.w vf5, vf0, vf6 + (.sub.x.vf.w vf5 vf0 vf6) + + ;;beq v1, r0, L15 + ;;vaddx.y vf5, vf0, vf6 + (.add.x.vf.y vf5 vf0 vf6) + (when-goto (zero? xyz-zero) zero-case) + ) + ) + + ;; Nonzero case: + ;; vsubw.w vf2, vf0, vf0 + ;; vsubw.w vf3, vf0, vf0 + ;; vsubw.w vf4, vf0, vf0 + (.xor.vf vf2 vf2 vf2) + (.xor.vf vf3 vf3 vf3) + (.xor.vf vf4 vf4 vf4) + + ;;vmulx.xyz vf11, vf1, vf5 + (.mul.x.vf.xyz vf11 vf1 vf5) + + ;;vaddy.x vf7, vf0, vf5 + (.add.y.vf.x vf7 vf0 vf5) + + ;;vaddy.y vf8, vf0, vf5 + (.add.y.vf.y vf8 vf0 vf5) + + ;;vaddy.z vf9, vf0, vf5 + (.add.y.vf.z vf9 vf0 vf5) + + ;;vmulw.xyz vf10, vf1, vf5 + (.mul.w.vf.xyz vf10 vf1 vf5) + + ;;vsubz.y vf7, vf0, vf11 + (.sub.z.vf.y vf7 vf0 vf11) + + ;;vaddy.z vf7, vf0, vf11 + (.add.y.vf.z vf7 vf0 vf11) + + ;;vaddz.x vf8, vf0, vf11 + (.add.z.vf.x vf8 vf0 vf11) + + ;;vsubx.z vf8, vf0, vf11 + (.sub.x.vf.z vf8 vf0 vf11) + + ;;vmulx.xyz vf2, vf10, vf1 + (.mul.x.vf.xyz vf2 vf10 vf1) + + ;;vmuly.xyz vf3, vf10, vf1 + (.mul.y.vf.xyz vf3 vf10 vf1) + + ;;vmulz.xyz vf4, vf10, vf1 + (.mul.z.vf.xyz vf4 vf10 vf1) + + ;;vsuby.x vf9, vf0, vf11 + (.sub.y.vf.x vf9 vf0 vf11) + + ;;vaddx.y vf9, vf0, vf11 + (.add.x.vf.y vf9 vf0 vf11) + + ;;vadd.xyz vf2, vf2, vf7 + (.add.vf.xyz vf2 vf2 vf7) + + ;;vadd.xyz vf3, vf3, vf8 + (.add.vf.xyz vf3 vf3 vf8) + + ;;vadd.xyz vf4, vf4, vf9 + (.add.vf.xyz vf4 vf4 vf9) + + ;;sqc2 vf2, 0(v0) + ;;sqc2 vf3, 16(v0) + ;;sqc2 vf0, 48(v0) + ;;sqc2 vf4, 32(v0) + (.svf (-> dst vector 0) vf2) + (.svf (-> dst vector 1) vf3) + (.svf (-> dst vector 3) vf0) + (.svf (-> dst vector 2) vf4) + (goto end) + (label zero-case) + ;; overly clever way to set identity matrix + ;;lui v1, 16256 + ;;sqc2 vf0, 48(v0) + ;;pcpyld v1, r0, v1 + ;;mfc1 r0, f31 + ;;prot3w a0, v1 + ;;mfc1 r0, f31 + ;;prot3w a1, a0 + ;;sq v1, 0(v0) + ;;sll r0, r0, 0 + ;;sq a0, 32(v0) + ;;sll r0, r0, 0 + ;;sq a1, 16(v0) + (matrix-identity! dst) + (label end) + ) + dst + ) + +(defun matrix-axis-angle! ((arg0 matrix) (arg1 vector) (arg2 float)) + "Create an axis-angle rotation matrix." + (matrix-axis-sin-cos! arg0 arg1 (sin arg2) (cos arg2)) + ) + +(defun matrix-lerp! ((arg0 matrix) (arg1 matrix) (arg2 matrix) (arg3 float)) + "Lerp an entire matrix, coefficient-wise." + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (.mov vf9 arg3) + (.lvf vf1 (&-> arg1 rvec quad)) + (.lvf vf2 (&-> arg1 uvec quad)) + (.lvf vf3 (&-> arg1 fvec quad)) + (.lvf vf4 (&-> arg1 trans quad)) + (.lvf vf5 (&-> arg2 rvec quad)) + (.lvf vf6 (&-> arg2 uvec quad)) + (.lvf vf7 (&-> arg2 fvec quad)) + (.lvf vf8 (&-> arg2 trans quad)) + (.sub.vf vf5 vf5 vf1) + (.sub.vf vf6 vf6 vf2) + (.sub.vf vf7 vf7 vf3) + (.sub.vf vf8 vf8 vf4) + (.mul.x.vf vf5 vf5 vf9) + (.mul.x.vf vf6 vf6 vf9) + (.mul.x.vf vf7 vf7 vf9) + (.mul.x.vf vf8 vf8 vf9) + (.add.vf vf1 vf1 vf5) + (.add.vf vf2 vf2 vf6) + (.add.vf vf3 vf3 vf7) + (.add.vf vf4 vf4 vf8) + (.svf (&-> arg0 rvec quad) vf1) + (.svf (&-> arg0 uvec quad) vf2) + (.svf (&-> arg0 fvec quad) vf3) + (.svf (&-> arg0 trans quad) vf4) + arg0 + ) + ) + +(defun matrix-3x3-determinant ((arg0 matrix)) + "Compute the determinant of a 3x3 matrix." + (let ((f8-0 (-> arg0 rvec x)) + (f1-0 (-> arg0 rvec y)) + (f4-0 (-> arg0 rvec z)) + (f2-0 (-> arg0 uvec x)) + (f5-0 (-> arg0 uvec y)) + (f9-0 (-> arg0 uvec z)) + (f3-0 (-> arg0 fvec x)) + (f6-0 (-> arg0 fvec y)) + (f0-0 (-> arg0 fvec z)) + ) + (- (+ (* f8-0 f5-0 f0-0) (* f1-0 f9-0 f3-0) (* f4-0 f2-0 f6-0)) + (+ (* f8-0 f9-0 f6-0) (* f4-0 f5-0 f3-0) (* f1-0 f2-0 f0-0)) + ) + ) + ) + +(defun matrix3-determinant ((arg0 matrix)) + "Unused. Not sure if this has limitations compared to the above version." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + ) + (.lvf vf11 (&-> arg0 uvec quad)) + (.lvf vf12 (&-> arg0 fvec quad)) + (.lvf vf10 (&-> arg0 rvec quad)) + (.outer.product.a.vf acc vf11 vf12) + (.outer.product.b.vf vf13 vf12 vf11 acc) + (.mul.vf.xyz vf13 vf13 vf10) + (.add.y.vf.x vf13 vf13 vf13) + (.add.z.vf.x vf13 vf13 vf13) + (.mov v0-0 vf13) + v0-0 + ) + ) + +(defun matrix-3x3-inverse! ((arg0 matrix) (arg1 matrix)) + "Compute the inverse of a 3x3 matrix. Not very efficient. + Requires src != dst." + (let ((f0-0 (matrix-3x3-determinant arg1))) + (set! (-> arg0 rvec x) + (/ (- (* (-> arg1 uvec y) (-> arg1 fvec z)) (* (-> arg1 uvec z) (-> arg1 fvec y))) f0-0) + ) + (set! (-> arg0 uvec x) + (/ (- (* (-> arg1 uvec z) (-> arg1 fvec x)) (* (-> arg1 uvec x) (-> arg1 fvec z))) f0-0) + ) + (set! (-> arg0 fvec x) + (/ (- (* (-> arg1 uvec x) (-> arg1 fvec y)) (* (-> arg1 uvec y) (-> arg1 fvec x))) f0-0) + ) + (set! (-> arg0 rvec y) + (/ (- (* (-> arg1 fvec y) (-> arg1 rvec z)) (* (-> arg1 fvec z) (-> arg1 rvec y))) f0-0) + ) + (set! (-> arg0 uvec y) + (/ (- (* (-> arg1 fvec z) (-> arg1 rvec x)) (* (-> arg1 fvec x) (-> arg1 rvec z))) f0-0) + ) + (set! (-> arg0 fvec y) + (/ (- (* (-> arg1 fvec x) (-> arg1 rvec y)) (* (-> arg1 fvec y) (-> arg1 rvec x))) f0-0) + ) + (set! (-> arg0 rvec z) + (/ (- (* (-> arg1 rvec y) (-> arg1 uvec z)) (* (-> arg1 rvec z) (-> arg1 uvec y))) f0-0) + ) + (set! (-> arg0 uvec z) + (/ (- (* (-> arg1 rvec z) (-> arg1 uvec x)) (* (-> arg1 rvec x) (-> arg1 uvec z))) f0-0) + ) + (set! (-> arg0 fvec z) + (/ (- (* (-> arg1 rvec x) (-> arg1 uvec y)) (* (-> arg1 rvec y) (-> arg1 uvec x))) f0-0) + ) + ) + arg0 + ) + +(defun matrix-3x3-inverse-transpose! ((arg0 matrix) (arg1 matrix)) + "Invert and transpose. + Requires dst != src." + (let ((f0-0 (matrix-3x3-determinant arg1))) + (set! (-> arg0 rvec x) + (/ (- (* (-> arg1 uvec y) (-> arg1 fvec z)) (* (-> arg1 uvec z) (-> arg1 fvec y))) f0-0) + ) + (set! (-> arg0 rvec y) + (/ (- (* (-> arg1 uvec z) (-> arg1 fvec x)) (* (-> arg1 uvec x) (-> arg1 fvec z))) f0-0) + ) + (set! (-> arg0 rvec z) + (/ (- (* (-> arg1 uvec x) (-> arg1 fvec y)) (* (-> arg1 uvec y) (-> arg1 fvec x))) f0-0) + ) + (set! (-> arg0 uvec x) + (/ (- (* (-> arg1 fvec y) (-> arg1 rvec z)) (* (-> arg1 fvec z) (-> arg1 rvec y))) f0-0) + ) + (set! (-> arg0 uvec y) + (/ (- (* (-> arg1 fvec z) (-> arg1 rvec x)) (* (-> arg1 fvec x) (-> arg1 rvec z))) f0-0) + ) + (set! (-> arg0 uvec z) + (/ (- (* (-> arg1 fvec x) (-> arg1 rvec y)) (* (-> arg1 fvec y) (-> arg1 rvec x))) f0-0) + ) + (set! (-> arg0 fvec x) + (/ (- (* (-> arg1 rvec y) (-> arg1 uvec z)) (* (-> arg1 rvec z) (-> arg1 uvec y))) f0-0) + ) + (set! (-> arg0 fvec y) + (/ (- (* (-> arg1 rvec z) (-> arg1 uvec x)) (* (-> arg1 rvec x) (-> arg1 uvec z))) f0-0) + ) + (set! (-> arg0 fvec z) + (/ (- (* (-> arg1 rvec x) (-> arg1 uvec y)) (* (-> arg1 rvec y) (-> arg1 uvec x))) f0-0) + ) + ) + arg0 + ) + +(defun matrix3-inverse-transpose! ((arg0 matrix) (arg1 matrix)) + "Unused. Not sure if this has limitations compared to other version." + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + ) + (init-vf0-vector) + (.lvf vf10 (&-> arg1 rvec quad)) + (.lvf vf11 (&-> arg1 uvec quad)) + (.lvf vf12 (&-> arg1 fvec quad)) + (.outer.product.a.vf acc vf11 vf12) + (.outer.product.b.vf vf13 vf12 vf11 acc) + (.outer.product.a.vf acc vf12 vf10) + (.outer.product.b.vf vf14 vf10 vf12 acc) + (.mul.vf.xyz vf1 vf10 vf13) + (.outer.product.a.vf acc vf10 vf11) + (.outer.product.b.vf vf15 vf11 vf10 acc) + (.nop.vf) + (.add.y.vf.x vf1 vf1 vf1) + (.nop.vf) + (.nop.vf) + (.nop.vf) + (.add.z.vf.x vf1 vf1 vf1) + (.nop.vf) + (.nop.vf) + (.nop.vf) + (.div.vf Q vf0 vf1 :fsf #b11 :ftf #b0) + (.wait.vf) + (.mul.vf vf13 vf13 Q) + (.mul.vf vf14 vf14 Q) + (.mul.vf vf15 vf15 Q) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 rvec quad) vf13) + (.svf (&-> arg0 uvec quad) vf14) + (.svf (&-> arg0 fvec quad) vf15) + arg0 + ) + ) + +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f2, f2] +;; ERROR: Unsupported inline assembly instruction kind - [madda.s f0, f0] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f1, f1] +;; ERROR: Unsupported inline assembly instruction kind - [rsqrt.s f0, f2, f0] +(defun matrix-3x3-normalize! ((arg0 matrix) (arg1 matrix)) + "Unused." + (/ 0 0) + arg0 + #| + (local-vars (f0-1 float) (f0-2 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf16 :class vf) + ) + (init-vf0-vector) + (let ((f2-0 (-> arg1 data 0)) + (f0-0 (-> arg1 data 1)) + (f1-0 (-> arg1 data 2)) + (v1-0 #x3f800000) + ) + (.lvf vf10 (&-> arg1 quad 0)) + (.mula.s f2-0 f2-0) + (.lvf vf11 (&-> arg1 quad 1)) + (let ((f2-1 (gpr->fpr v1-0))) + (.lvf vf12 (&-> arg1 quad 2)) + (.madda.s f0-0 f0-0) + (.sub.w.vf.w vf13 vf0 vf0) + (.madd.s f0-1 f1-0 f1-0) + (.sub.w.vf.w vf14 vf0 vf0) + (.rsqrt.s f0-2 f2-1 f0-1) + ) + ) + (.sub.w.vf.w vf15 vf0 vf0) + (let ((v1-1 f0-2)) + (.mov vf16 v1-1) + ) + (.mul.x.vf.xyz vf13 vf10 vf16) + (.outer.product.a.vf acc vf11 vf13) + (.outer.product.b.vf vf14 vf13 vf11 acc) + (.outer.product.a.vf acc vf13 vf14) + (.outer.product.b.vf vf14 vf14 vf13 acc) + (.mul.vf.xyz vf16 vf14 vf14) + (.mul.x.vf.w acc vf0 vf16) + (.add.mul.y.vf.w acc vf0 vf16 acc) + (.add.mul.z.vf.w vf16 vf0 vf16 acc) + (.isqrt.vf Q vf0 vf16 :fsf #b11 :ftf #b11) + (.wait.vf) + (.mul.vf.xyz vf14 vf14 Q) + (.outer.product.a.vf acc vf13 vf14) + (.outer.product.b.vf vf15 vf14 vf13 acc) + (.svf (&-> arg0 quad 0) vf13) + (.svf (&-> arg0 quad 1) vf14) + (.svf (&-> arg0 quad 2) vf15) + arg0 + ) + |# + ) + +(defun matrix-4x4-determinant ((arg0 matrix)) + "Take the determinant of a 4x4 matrix, but this is wrong." + (let ((f15-0 (-> arg0 rvec x)) + (f14-0 (-> arg0 rvec y)) + (f10-0 (-> arg0 rvec z)) + (f2-0 (-> arg0 rvec w)) + (f9-0 (-> arg0 uvec x)) + (f6-0 (-> arg0 uvec y)) + (f3-0 (-> arg0 uvec z)) + (f11-0 (-> arg0 uvec w)) + (f5-0 (-> arg0 fvec x)) + (f1-0 (-> arg0 fvec y)) + (f8-0 (-> arg0 fvec z)) + (f13-0 (-> arg0 fvec w)) + (f0-0 (-> arg0 trans x)) + (f7-0 (-> arg0 trans y)) + (f4-0 (-> arg0 trans z)) + (f12-0 (-> arg0 trans w)) + ) + (- (+ (* f15-0 f6-0 f8-0 f12-0) + (* f15-0 f3-0 f13-0 f7-0) + (* f15-0 f11-0 f1-0 f4-0) + (* f14-0 f9-0 f13-0 f4-0) + (* f14-0 f3-0 f5-0 f4-0) + (* f14-0 f11-0 f8-0 f0-0) + (* f10-0 f9-0 f1-0 f12-0) + (* f10-0 f6-0 f13-0 f0-0) + (* f10-0 f11-0 f5-0 f7-0) + (* f2-0 f9-0 f1-0 f4-0) + (* f2-0 f6-0 f8-0 f0-0) + (* f2-0 f3-0 f5-0 f7-0) + ) + (+ (* f15-0 f6-0 f13-0 f4-0) + (* f15-0 f3-0 f1-0 f12-0) + (* f15-0 f11-0 f8-0 f7-0) + (* f14-0 f9-0 f8-0 f12-0) + (* f14-0 f3-0 f13-0 f0-0) + (* f14-0 f11-0 f5-0 f4-0) + (* f10-0 f9-0 f13-0 f7-0) + (* f10-0 f6-0 f5-0 f12-0) + (* f10-0 f11-0 f1-0 f0-0) + (* f2-0 f9-0 f8-0 f7-0) + (* f2-0 f6-0 f5-0 f4-0) + (* f2-0 f3-0 f1-0 f0-0) + ) + ) + ) + ) + +(defun matrix-4x4-inverse-transpose! ((arg0 matrix) (arg1 matrix)) + "Invert and transpose an entire 4x4. I think has no restrictions, other than dst != src. Unused. + The answer is wrong. The determinant function is wrong." + (let ((f0-0 (matrix-4x4-determinant arg1))) + (let ((f9-0 (-> arg1 uvec y)) + (f2-0 (-> arg1 uvec z)) + (f5-0 (-> arg1 uvec w)) + (f3-0 (-> arg1 fvec y)) + (f6-0 (-> arg1 fvec z)) + (f10-0 (-> arg1 fvec w)) + (f4-0 (-> arg1 trans y)) + (f7-0 (-> arg1 trans z)) + (f1-0 (-> arg1 trans w)) + ) + (set! (-> arg0 rvec x) (/ (- (+ (* f9-0 f6-0 f1-0) (* f2-0 f10-0 f4-0) (* f5-0 f3-0 f7-0)) + (+ (* f9-0 f10-0 f7-0) (* f5-0 f6-0 f4-0) (* f2-0 f3-0 f1-0)) + ) + f0-0 + ) + ) + ) + (let ((f9-2 (-> arg1 uvec x)) + (f2-2 (-> arg1 uvec z)) + (f5-2 (-> arg1 uvec w)) + (f3-1 (-> arg1 fvec x)) + (f6-1 (-> arg1 fvec z)) + (f10-1 (-> arg1 fvec w)) + (f4-3 (-> arg1 trans x)) + (f7-2 (-> arg1 trans z)) + (f1-6 (-> arg1 trans w)) + ) + (set! (-> arg0 rvec y) (- (/ (- (+ (* f9-2 f6-1 f1-6) (* f2-2 f10-1 f4-3) (* f5-2 f3-1 f7-2)) + (+ (* f9-2 f10-1 f7-2) (* f5-2 f6-1 f4-3) (* f2-2 f3-1 f1-6)) + ) + f0-0 + ) + ) + ) + ) + (let ((f9-4 (-> arg1 uvec x)) + (f2-4 (-> arg1 uvec y)) + (f5-4 (-> arg1 uvec w)) + (f3-2 (-> arg1 fvec x)) + (f6-2 (-> arg1 fvec y)) + (f10-2 (-> arg1 fvec w)) + (f4-6 (-> arg1 trans x)) + (f7-4 (-> arg1 trans y)) + (f1-13 (-> arg1 trans w)) + ) + (set! (-> arg0 rvec z) (/ (- (+ (* f9-4 f6-2 f1-13) (* f2-4 f10-2 f4-6) (* f5-4 f3-2 f7-4)) + (+ (* f9-4 f10-2 f7-4) (* f5-4 f6-2 f4-6) (* f2-4 f3-2 f1-13)) + ) + f0-0 + ) + ) + ) + (let ((f9-6 (-> arg1 uvec x)) + (f2-6 (-> arg1 uvec y)) + (f5-6 (-> arg1 uvec z)) + (f3-3 (-> arg1 fvec x)) + (f6-3 (-> arg1 fvec y)) + (f10-3 (-> arg1 fvec z)) + (f4-9 (-> arg1 trans x)) + (f7-6 (-> arg1 trans y)) + (f1-19 (-> arg1 trans z)) + ) + (set! (-> arg0 rvec w) (- (/ (- (+ (* f9-6 f6-3 f1-19) (* f2-6 f10-3 f4-9) (* f5-6 f3-3 f7-6)) + (+ (* f9-6 f10-3 f7-6) (* f5-6 f6-3 f4-9) (* f2-6 f3-3 f1-19)) + ) + f0-0 + ) + ) + ) + ) + (let ((f9-8 (-> arg1 rvec y)) + (f2-8 (-> arg1 rvec z)) + (f5-8 (-> arg1 rvec w)) + (f3-4 (-> arg1 fvec y)) + (f6-4 (-> arg1 fvec z)) + (f10-4 (-> arg1 fvec w)) + (f4-12 (-> arg1 trans y)) + (f7-8 (-> arg1 trans z)) + (f1-26 (-> arg1 trans w)) + ) + (set! (-> arg0 uvec x) (- (/ (- (+ (* f9-8 f6-4 f1-26) (* f2-8 f10-4 f4-12) (* f5-8 f3-4 f7-8)) + (+ (* f9-8 f10-4 f7-8) (* f5-8 f6-4 f4-12) (* f2-8 f3-4 f1-26)) + ) + f0-0 + ) + ) + ) + ) + (let ((f9-10 (-> arg1 rvec x)) + (f2-10 (-> arg1 rvec z)) + (f5-10 (-> arg1 rvec w)) + (f3-5 (-> arg1 fvec x)) + (f6-5 (-> arg1 fvec z)) + (f10-5 (-> arg1 fvec w)) + (f4-15 (-> arg1 trans x)) + (f7-10 (-> arg1 trans z)) + (f1-33 (-> arg1 trans w)) + ) + (set! (-> arg0 uvec y) (/ (- (+ (* f9-10 f6-5 f1-33) (* f2-10 f10-5 f4-15) (* f5-10 f3-5 f7-10)) + (+ (* f9-10 f10-5 f7-10) (* f5-10 f6-5 f4-15) (* f2-10 f3-5 f1-33)) + ) + f0-0 + ) + ) + ) + (let ((f9-12 (-> arg1 rvec x)) + (f2-12 (-> arg1 rvec y)) + (f5-12 (-> arg1 rvec w)) + (f3-6 (-> arg1 fvec x)) + (f6-6 (-> arg1 fvec y)) + (f10-6 (-> arg1 fvec w)) + (f4-18 (-> arg1 trans x)) + (f7-12 (-> arg1 trans y)) + (f1-39 (-> arg1 trans w)) + ) + (set! (-> arg0 uvec z) (- (/ (- (+ (* f9-12 f6-6 f1-39) (* f2-12 f10-6 f4-18) (* f5-12 f3-6 f7-12)) + (+ (* f9-12 f10-6 f7-12) (* f5-12 f6-6 f4-18) (* f2-12 f3-6 f1-39)) + ) + f0-0 + ) + ) + ) + ) + (let ((f9-14 (-> arg1 rvec x)) + (f2-14 (-> arg1 rvec y)) + (f5-14 (-> arg1 rvec z)) + (f3-7 (-> arg1 fvec x)) + (f6-7 (-> arg1 fvec y)) + (f10-7 (-> arg1 fvec z)) + (f4-21 (-> arg1 trans x)) + (f7-14 (-> arg1 trans y)) + (f1-46 (-> arg1 trans z)) + ) + (set! (-> arg0 uvec w) (/ (- (+ (* f9-14 f6-7 f1-46) (* f2-14 f10-7 f4-21) (* f5-14 f3-7 f7-14)) + (+ (* f9-14 f10-7 f7-14) (* f5-14 f6-7 f4-21) (* f2-14 f3-7 f1-46)) + ) + f0-0 + ) + ) + ) + (let ((f9-16 (-> arg1 rvec y)) + (f2-16 (-> arg1 rvec z)) + (f5-16 (-> arg1 rvec w)) + (f3-8 (-> arg1 uvec y)) + (f6-8 (-> arg1 uvec z)) + (f10-8 (-> arg1 uvec w)) + (f4-24 (-> arg1 trans y)) + (f7-16 (-> arg1 trans z)) + (f1-52 (-> arg1 trans w)) + ) + (set! (-> arg0 fvec x) (/ (- (+ (* f9-16 f6-8 f1-52) (* f2-16 f10-8 f4-24) (* f5-16 f3-8 f7-16)) + (+ (* f9-16 f10-8 f7-16) (* f5-16 f6-8 f4-24) (* f2-16 f3-8 f1-52)) + ) + f0-0 + ) + ) + ) + (let ((f9-18 (-> arg1 rvec x)) + (f2-18 (-> arg1 rvec z)) + (f5-18 (-> arg1 rvec w)) + (f3-9 (-> arg1 uvec x)) + (f6-9 (-> arg1 uvec z)) + (f10-9 (-> arg1 uvec w)) + (f4-27 (-> arg1 trans x)) + (f7-18 (-> arg1 trans z)) + (f1-58 (-> arg1 trans w)) + ) + (set! (-> arg0 fvec y) (- (/ (- (+ (* f9-18 f6-9 f1-58) (* f2-18 f10-9 f4-27) (* f5-18 f3-9 f7-18)) + (+ (* f9-18 f10-9 f7-18) (* f5-18 f6-9 f4-27) (* f2-18 f3-9 f1-58)) + ) + f0-0 + ) + ) + ) + ) + (let ((f9-20 (-> arg1 rvec x)) + (f2-20 (-> arg1 rvec y)) + (f5-20 (-> arg1 rvec w)) + (f3-10 (-> arg1 uvec x)) + (f6-10 (-> arg1 uvec y)) + (f10-10 (-> arg1 uvec w)) + (f4-30 (-> arg1 trans x)) + (f7-20 (-> arg1 trans y)) + (f1-65 (-> arg1 trans w)) + ) + (set! (-> arg0 fvec z) (/ (- (+ (* f9-20 f6-10 f1-65) (* f2-20 f10-10 f4-30) (* f5-20 f3-10 f7-20)) + (+ (* f9-20 f10-10 f7-20) (* f5-20 f6-10 f4-30) (* f2-20 f3-10 f1-65)) + ) + f0-0 + ) + ) + ) + (let ((f9-22 (-> arg1 rvec x)) + (f2-22 (-> arg1 rvec y)) + (f5-22 (-> arg1 rvec z)) + (f3-11 (-> arg1 uvec x)) + (f6-11 (-> arg1 uvec y)) + (f10-11 (-> arg1 uvec z)) + (f4-33 (-> arg1 trans x)) + (f7-22 (-> arg1 trans y)) + (f1-71 (-> arg1 trans z)) + ) + (set! (-> arg0 fvec w) (- (/ (- (+ (* f9-22 f6-11 f1-71) (* f2-22 f10-11 f4-33) (* f5-22 f3-11 f7-22)) + (+ (* f9-22 f10-11 f7-22) (* f5-22 f6-11 f4-33) (* f2-22 f3-11 f1-71)) + ) + f0-0 + ) + ) + ) + ) + (let ((f9-24 (-> arg1 rvec y)) + (f2-24 (-> arg1 rvec z)) + (f5-24 (-> arg1 rvec w)) + (f3-12 (-> arg1 uvec y)) + (f6-12 (-> arg1 uvec z)) + (f10-12 (-> arg1 uvec w)) + (f4-36 (-> arg1 fvec y)) + (f7-24 (-> arg1 fvec z)) + (f1-78 (-> arg1 fvec w)) + ) + (set! (-> arg0 trans x) (- (/ (- (+ (* f9-24 f6-12 f1-78) (* f2-24 f10-12 f4-36) (* f5-24 f3-12 f7-24)) + (+ (* f9-24 f10-12 f7-24) (* f5-24 f6-12 f4-36) (* f2-24 f3-12 f1-78)) + ) + f0-0 + ) + ) + ) + ) + (let ((f9-26 (-> arg1 rvec x)) + (f2-26 (-> arg1 rvec z)) + (f5-26 (-> arg1 rvec w)) + (f3-13 (-> arg1 uvec x)) + (f6-13 (-> arg1 uvec z)) + (f10-13 (-> arg1 uvec w)) + (f4-39 (-> arg1 fvec x)) + (f7-26 (-> arg1 fvec z)) + (f1-85 (-> arg1 fvec w)) + ) + (set! (-> arg0 trans y) (/ (- (+ (* f9-26 f6-13 f1-85) (* f2-26 f10-13 f4-39) (* f5-26 f3-13 f7-26)) + (+ (* f9-26 f10-13 f7-26) (* f5-26 f6-13 f4-39) (* f2-26 f3-13 f1-85)) + ) + f0-0 + ) + ) + ) + (let ((f9-28 (-> arg1 rvec x)) + (f2-28 (-> arg1 rvec y)) + (f5-28 (-> arg1 rvec w)) + (f3-14 (-> arg1 uvec x)) + (f6-14 (-> arg1 uvec y)) + (f10-14 (-> arg1 uvec w)) + (f4-42 (-> arg1 fvec x)) + (f7-28 (-> arg1 fvec y)) + (f1-91 (-> arg1 fvec w)) + ) + (set! (-> arg0 trans z) (- (/ (- (+ (* f9-28 f6-14 f1-91) (* f2-28 f10-14 f4-42) (* f5-28 f3-14 f7-28)) + (+ (* f9-28 f10-14 f7-28) (* f5-28 f6-14 f4-42) (* f2-28 f3-14 f1-91)) + ) + f0-0 + ) + ) + ) + ) + (let ((f8-60 (-> arg1 rvec x)) + (f1-98 (-> arg1 rvec y)) + (f5-30 (-> arg1 rvec z)) + (f2-30 (-> arg1 uvec x)) + (f6-15 (-> arg1 uvec y)) + (f9-30 (-> arg1 uvec z)) + (f4-45 (-> arg1 fvec x)) + (f7-30 (-> arg1 fvec y)) + (f3-15 (-> arg1 fvec z)) + ) + (set! (-> arg0 trans w) (/ (- (+ (* f8-60 f6-15 f3-15) (* f1-98 f9-30 f4-45) (* f5-30 f2-30 f7-30)) + (+ (* f8-60 f9-30 f7-30) (* f5-30 f6-15 f4-45) (* f1-98 f2-30 f3-15)) + ) + f0-0 + ) + ) + ) + ) + arg0 + ) + +(defun matrix-y-angle ((arg0 matrix)) + "If mat has its upper 3x3 as a rotation, gets the y axis rotation." + (let ((v1-0 (-> arg0 fvec))) + (atan (-> v1-0 x) (-> v1-0 z)) + ) + ) + +(defun matrix->trans ((arg0 matrix) (arg1 vector)) + "Multiply xyz by 1/w." + (rlet ((Q :class vf) + (vf0 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg0 trans quad)) + (.div.vf Q vf0 vf2 :fsf #b11 :ftf #b11) + (.wait.vf) + (.mul.vf.xyz vf2 vf2 Q) + (.nop.vf) + (.nop.vf) + (.mov.vf.w vf2 vf0) + (.svf (&-> arg1 quad) vf2) + arg1 + ) + ) + +(defun matrix<-trans ((arg0 matrix) (arg1 vector)) + "Set the translation." + (set! (-> arg0 trans quad) (-> arg1 quad)) + arg0 + ) + +(defun matrix->scale ((arg0 matrix) (arg1 vector)) + "Get the scale of a matrix." + (set! (-> arg1 x) (vector-length (-> arg0 rvec))) + (set! (-> arg1 y) (vector-length (-> arg0 uvec))) + (set! (-> arg1 z) (vector-length (-> arg0 fvec))) + (set! (-> arg1 w) 1.0) + arg1 + ) + +(defun matrix-remove-scale! ((arg0 matrix) (arg1 matrix) (arg2 vector)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 rvec quad)) + (.lvf vf2 (&-> arg1 uvec quad)) + (.lvf vf3 (&-> arg1 fvec quad)) + (.mul.vf vf4 vf1 vf1) + (.lvf vf7 (&-> arg2 quad)) + (.mul.vf vf5 vf2 vf2) + (.mul.vf vf6 vf3 vf3) + (.mul.x.vf acc vf0 vf4) + (.add.mul.y.vf acc vf0 vf4 acc) + (.add.mul.z.vf vf4 vf0 vf4 acc) + (.mul.x.vf acc vf0 vf5) + (.add.mul.y.vf acc vf0 vf5 acc) + (.add.mul.z.vf vf5 vf0 vf5 acc) + (.isqrt.vf Q vf7 vf4 :fsf #b0 :ftf #b11) + (.mul.x.vf acc vf0 vf6) + (.add.mul.y.vf acc vf0 vf6 acc) + (.add.mul.z.vf vf6 vf0 vf6 acc) + (.wait.vf) + (.mul.vf vf4 vf1 Q) + (.isqrt.vf Q vf7 vf5 :fsf #b1 :ftf #b11) + (.svf (&-> arg0 rvec quad) vf4) + (.lvf vf10 (&-> arg1 trans quad)) + (.svf (&-> arg0 trans quad) vf10) + (.wait.vf) + (.mul.vf vf5 vf2 Q) + (.isqrt.vf Q vf7 vf6 :fsf #b10 :ftf #b11) + (.svf (&-> arg0 uvec quad) vf5) + (.wait.vf) + (.mul.vf vf6 vf3 Q) + (.svf (&-> arg0 fvec quad) vf6) + arg0 + ) + ) + +(defun matrix<-scale ((arg0 matrix) (arg1 vector)) + "Set the scale of a matrix by rescaling." + (matrix-remove-scale! arg0 arg0 arg1) + arg0 + ) + +(defun matrix->quat ((arg0 matrix) (arg1 quaternion)) + "Convert matrix to quaternion, works for matrix with scale. + unlike matrix->quaternion." + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (matrix-remove-scale! s5-0 arg0 (new 'static 'vector :data (new 'static 'array float 4 1.0 1.0 1.0 0.0))) + (vector-reset! (-> s5-0 trans)) + (matrix->quaternion arg1 s5-0) + ) + ) + +(defun matrix<-quat ((arg0 matrix) (arg1 quaternion)) + "Modify the rotation part of a transform." + (let ((s5-0 (matrix->scale arg0 (new 'stack-no-clear 'vector))) + (a1-3 (quaternion->matrix (new 'stack-no-clear 'matrix) arg1)) + ) + (matrix-remove-scale! arg0 a1-3 s5-0) + ) + arg0 + ) + +(defun matrix-extract-rotation! ((arg0 matrix) (arg1 matrix)) + (matrix-remove-scale! arg0 arg1 (new 'static 'vector :data (new 'static 'array float 4 1.0 1.0 1.0 0.0))) + (vector-reset! (-> arg0 trans)) + arg0 + ) + +(defun matrix->transformq ((arg0 transformq) (arg1 matrix)) + "Create a transformq from a matrix. Allowing scale, etc." + (rlet ((Q :class vf) + (vf0 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg1 trans quad)) + (.div.vf Q vf0 vf2 :fsf #b11 :ftf #b11) + (.wait.vf) + (.mul.vf.xyz vf2 vf2 Q) + (.nop.vf) + (.nop.vf) + (.mov.vf.w vf2 vf0) + (.svf (&-> arg0 trans quad) vf2) + (let ((a1-2 + (matrix-remove-scale! + (new 'stack-no-clear 'matrix) + arg1 + (new 'static 'vector :data (new 'static 'array float 4 1.0 1.0 1.0 0.0)) + ) + ) + ) + (matrix->quaternion (the-as quaternion (-> arg0 rot)) a1-2) + ) + (set-vector! + (-> arg0 scale) + (vector-length (-> arg1 rvec)) + (vector-length (-> arg1 uvec)) + (vector-length (-> arg1 fvec)) + 1.0 + ) + arg0 + ) + ) + +(defmethod transform-vectors! matrix ((this _type_) (dst (inline-array vector)) (src (inline-array vector)) (count int)) + "Transform many vectors. This acts like w = 1, even if it isn't. The value of w is copied." + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (acc :class vf) + (v1 :type int) + ) + (init-vf0-vector) + + ;; blez a3, L3 + (when-goto (<= count 0) end) + + ;; lqc2 vf1, 0(a0) + (.lvf vf1 (-> this vector 0)) + + ;; lqc2 vf2, 16(a0) + (.lvf vf2 (-> this vector 1)) + + ;; lqc2 vf3, 32(a0) + (.lvf vf3 (-> this vector 2)) + + ;; lqc2 vf4, 48(a0) + (.lvf vf4 (-> this vector 3)) + + ;; lqc2 vf5, 0(a2) + (.lvf vf5 (-> src 0)) + + ;; lqc2 vf6, 16(a2) + (.lvf vf6 (-> src 1)) + + (label loop-top) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;;vmulaw.xyzw acc, vf4, vf0 + (.mul.w.vf acc vf4 vf0) + + ;; lqc2 vf7, 32(a2) + (.lvf vf7 (-> src 2)) + + ;;vmaddax.xyzw acc, vf1, vf5 + (.add.mul.x.vf acc vf1 vf5 acc) + + ;;lqc2 vf8, 48(a2) + (.lvf vf8 (-> src 3)) + + ;;vmadday.xyzw acc, vf2, vf5 + (.add.mul.y.vf acc vf2 vf5 acc) + + ;;daddiu a2, a2, 64 + ;;(&+! src 64) + (set! src (the (inline-array vector) (+ 64 (the int src)))) + + ;;vmaddz.xyz vf5, vf3, vf5 + (.add.mul.z.vf.xyz vf5 vf3 vf5 acc) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + ;;daddiu v1, a3, -1 + (set! v1 (- count 1)) + + ;;vmulaw.xyzw acc, vf4, vf0 + (.mul.w.vf acc vf4 vf0) + + ;;vmaddax.xyzw acc, vf1, vf6 + (.add.mul.x.vf acc vf1 vf6 acc) + + ;; vmadday.xyzw acc, vf2, vf6 + (.add.mul.y.vf acc vf2 vf6 acc) + + ;; vmaddz.xyz vf6, vf3, vf6 + (.add.mul.z.vf.xyz vf6 vf3 vf6 acc) + + ;;sqc2 vf5, 0(a1) + (.svf (-> dst 0) vf5) + + ;;beq v1, r0, L3 + ;;vmulaw.xyzw acc, vf4, vf0 + (.mul.w.vf acc vf4 vf0) + (when-goto (zero? v1) end) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + ;;vmaddax.xyzw acc, vf1, vf7 + (.add.mul.x.vf acc vf1 vf7 acc) + ;;daddiu v1, v1, -1 + (+! v1 -1) + ;;vmadday.xyzw acc, vf2, vf7 + (.add.mul.y.vf acc vf2 vf7 acc) + ;;lqc2 vf5, 0(a2) + (.lvf vf5 (-> src 0)) + ;;vmaddz.xyz vf7, vf3, vf7 + (.add.mul.z.vf.xyz vf7 vf3 vf7 acc) + ;;sqc2 vf6, 16(a1) + (.svf (-> dst 1) vf6) + + ;;beq v1, r0, L3 + ;;vmulaw.xyzw acc, vf4, vf0 + (.mul.w.vf acc vf4 vf0) + (when-goto (zero? v1) end) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;;vmaddax.xyzw acc, vf1, vf8 + (.add.mul.x.vf acc vf1 vf8 acc) + ;;daddiu v1, v1, -1 + (+! v1 -1) + ;;vmadday.xyzw acc, vf2, vf8 + (.add.mul.y.vf acc vf2 vf8 acc) + ;;lqc2 vf6, 16(a2) + (.lvf vf6 (-> src 1)) + ;;vmaddz.xyz vf8, vf3, vf8 + (.add.mul.z.vf.xyz vf8 vf3 vf8 acc) + ;;sqc2 vf7, 32(a1) + (.svf (-> dst 2) vf7) + + ;;beq v1, r0, L3 + ;;daddiu a1, a1, 64 + ;;(&!+ dst 64) + (set! dst (the (inline-array vector) (+ 64 (the int dst)))) + (when-goto (zero? v1) end) + + ;;daddiu a3, v1, -1 + (set! count (- v1 1)) + ;;sqc2 vf8, -16(a1) + (.svf dst vf8 :offset -16) + (when-goto (not (zero? count)) loop-top) + (label end) + (none) + ) + ) + +(defun matrix-mirror! ((arg0 matrix) (arg1 vector) (arg2 vector)) + "Make a matrix that mirrors. Arguments are unclear." + (let ((f10-0 -2.0) + (f0-0 1.0) + ) + (let* ((f1-0 0.0) + (f9-0 (-> arg2 x)) + (f12-0 (-> arg2 y)) + (f11-0 (-> arg2 z)) + (f6-0 (-> arg1 x)) + (f5-0 (-> arg1 y)) + (f2-0 (-> arg1 z)) + (f3-2 (+ f0-0 (* f10-0 f9-0 f9-0))) + (f4-2 (+ f0-0 (* f10-0 f12-0 f12-0))) + (f7-2 (+ f0-0 (* f10-0 f11-0 f11-0))) + (f8-1 (* f10-0 f9-0 f12-0)) + (f9-2 (* f10-0 f9-0 f11-0)) + (f10-2 (* f10-0 f12-0 f11-0)) + (f11-4 (- f6-0 (+ (* f6-0 f3-2) (* f5-0 f8-1) (* f2-0 f9-2)))) + (f12-6 (- f5-0 (+ (* f6-0 f8-1) (* f5-0 f4-2) (* f2-0 f10-2)))) + (f2-1 (- f2-0 (+ (* f6-0 f9-2) (* f5-0 f10-2) (* f2-0 f7-2)))) + ) + (set! (-> arg0 rvec x) f3-2) + (set! (-> arg0 rvec y) f8-1) + (set! (-> arg0 rvec z) f9-2) + (set! (-> arg0 rvec w) f1-0) + (set! (-> arg0 uvec x) f8-1) + (set! (-> arg0 uvec y) f4-2) + (set! (-> arg0 uvec z) f10-2) + (set! (-> arg0 uvec w) f1-0) + (set! (-> arg0 fvec x) f9-2) + (set! (-> arg0 fvec y) f10-2) + (set! (-> arg0 fvec z) f7-2) + (set! (-> arg0 fvec w) f1-0) + (set! (-> arg0 trans x) f11-4) + (set! (-> arg0 trans y) f12-6) + (set! (-> arg0 trans z) f2-1) + ) + (set! (-> arg0 trans w) f0-0) + ) + arg0 + ) diff --git a/goal_src/jakx/engine/math/quaternion-h.gc b/goal_src/jakx/engine/math/quaternion-h.gc index f642c95452..fc74956f99 100644 --- a/goal_src/jakx/engine/math/quaternion-h.gc +++ b/goal_src/jakx/engine/math/quaternion-h.gc @@ -5,5 +5,35 @@ ;; name in dgo: quaternion-h ;; dgos: ENGINE, GAME +(declare-type quaternion structure) +(define-extern quaternion-normalize! (function quaternion quaternion)) +(define-extern vector-y-angle (function vector float)) +(define-extern matrix->quaternion (function quaternion matrix quaternion)) +(define-extern quaternion->matrix (function matrix quaternion matrix)) + +(defmacro new-stack-quaternion0 () + "Get a stack quaternion that's set to 0. + This is more efficient than (new 'stack 'quaternion) because + this doesn't call the constructor." + `(let ((q (new 'stack-no-clear 'quaternion))) + (set! (-> q quad) (the-as uint128 0)) + q + ) + ) + ;; DECOMP BEGINS +(deftype quaternion (structure) + "Quaternion. Stored in xyzw order." + ((data float 4) + (x float :overlay-at (-> data 0)) + (y float :overlay-at (-> data 1)) + (z float :overlay-at (-> data 2)) + (w float :overlay-at (-> data 3)) + (vec vector :inline :overlay-at (-> data 0)) + (quad uint128 :overlay-at (-> data 0)) + ) + ) + + +(define *unity-quaternion* (new 'static 'quaternion :w 1.0)) diff --git a/goal_src/jakx/engine/math/quaternion.gc b/goal_src/jakx/engine/math/quaternion.gc index d5626c3b36..c6cc56ca15 100644 --- a/goal_src/jakx/engine/math/quaternion.gc +++ b/goal_src/jakx/engine/math/quaternion.gc @@ -7,3 +7,998 @@ ;; DECOMP BEGINS + +(defun quaternion-axis-angle! ((arg0 quaternion) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Construct a quaternion from an axis and angle. The axis should be normalized." + (let ((s5-0 (new 'stack-no-clear 'vector))) + (sincos! s5-0 (/ arg4 2)) + (let ((f0-2 (-> s5-0 x))) + (set! (-> arg0 x) (* arg1 f0-2)) + (set! (-> arg0 y) (* arg2 f0-2)) + (set! (-> arg0 z) (* arg3 f0-2)) + ) + (set! (-> arg0 w) (-> s5-0 y)) + ) + arg0 + ) + +(defun quaternion-vector-angle! ((arg0 quaternion) (arg1 vector) (arg2 float)) + "Construct a quaternion from an axis and angle. The axis should be normalized." + (let ((s5-0 (new 'stack-no-clear 'vector))) + (sincos! s5-0 (/ arg2 2)) + (let ((f0-2 (-> s5-0 x))) + (set! (-> arg0 x) (* (-> arg1 x) f0-2)) + (set! (-> arg0 y) (* (-> arg1 y) f0-2)) + (set! (-> arg0 z) (* (-> arg1 z) f0-2)) + ) + (set! (-> arg0 w) (-> s5-0 y)) + ) + arg0 + ) + +(defun vector-angle<-quaternion! ((arg0 vector) (arg1 quaternion)) + "Convert the quaternion arg1 to axis-angle form and store in arg0 (angle goes in w)" + (let ((f30-0 (/ 1.0 (sqrtf (- 1.0 (square (-> arg1 w)))))) + (f0-3 (* 2.0 (acos-rad (-> arg1 w)))) + ) + (set! (-> arg0 x) (* (-> arg1 x) f30-0)) + (set! (-> arg0 y) (* (-> arg1 y) f30-0)) + (set! (-> arg0 z) (* (-> arg1 z) f30-0)) + (set! (-> arg0 w) f0-3) + ) + arg0 + ) + +(defun quaternion-look-at! ((arg0 quaternion) (arg1 vector) (arg2 vector)) + "Look along arg1, with arg2 as up." + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (vector-cross! (-> s5-0 rvec) arg2 arg1) + (vector-cross! (-> s5-0 uvec) arg1 (-> s5-0 rvec)) + (set! (-> s5-0 fvec quad) (-> arg1 quad)) + (quaternion-normalize! (matrix->quaternion arg0 s5-0)) + ) + ) + +(defun quaternion-zero! ((arg0 quaternion)) + "Set quaternion to all 0's." + (set! (-> arg0 quad) (the-as uint128 0)) + arg0 + ) + +(defun quaternion-identity! ((arg0 quaternion)) + "Set quaternion to 0,0,0,1 (identity)." + (set! (-> arg0 quad) (the-as uint128 0)) + (set! (-> arg0 w) 1.0) + arg0 + ) + +(defun quaternion-i! ((arg0 quaternion)) + "Create unit i quaternion." + (set! (-> arg0 quad) (the-as uint128 0)) + (set! (-> arg0 x) 1.0) + arg0 + ) + +(defun quaternion-j! ((arg0 quaternion)) + "Create unit j quaternion." + (set! (-> arg0 quad) (the-as uint128 0)) + (set! (-> arg0 y) 1.0) + arg0 + ) + +(defun quaternion-k! ((arg0 quaternion)) + "Create unit k quaternion." + (set! (-> arg0 quad) (the-as uint128 0)) + (set! (-> arg0 z) 1.0) + arg0 + ) + +(defun quaternion-copy! ((arg0 quaternion) (arg1 quaternion)) + "Set arg0 = arg1." + (set! (-> arg0 quad) (-> arg1 quad)) + arg0 + ) + +(defun quaternion-set! ((arg0 quaternion) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Set arg0 = [arg1, arg2, arg3, arg4]." + (set! (-> arg0 x) arg1) + (set! (-> arg0 y) arg2) + (set! (-> arg0 z) arg3) + (set! (-> arg0 w) arg4) + arg0 + ) + +(defun quaternion+! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion)) + "Add quaternions as vectors." + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.add.vf vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +(defun quaternion-! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion)) + "Subtract quaternions as vectors." + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.sub.vf vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; ERROR: Bad vector register dependency: vf2 +(defun quaternion-negate! ((arg0 quaternion) (arg1 quaternion)) + "Set arg0 = -arg1." + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.sub.vf vf2 vf2 vf2) + (.sub.vf vf1 vf2 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; ERROR: Bad vector register dependency: vf2 +(defun quaternion-conjugate! ((arg0 quaternion) (arg1 quaternion)) + "Set arg0 to the conjugate of arg1 (negate only ijk). + If arg1 is normalized, this is equivalent to the inverse + NOTE: this gives you the inverse rotation." + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.sub.vf vf2 vf2 vf2) + (.sub.vf.xyz vf2 vf2 vf1) + (.add.vf.w vf2 vf2 vf1) + (.svf (&-> arg0 quad) vf2) + arg0 + ) + ) + +(defun quaternion-float*! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Multiply each element." + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.mov vf2 arg2) + (.mul.x.vf vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +(defun quaternion-float/! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Divide each element." + (let ((f0-1 (/ 1.0 arg2))) + (quaternion-float*! arg0 arg1 f0-1) + ) + arg0 + ) + +(defun quaternion-norm2 ((arg0 quaternion)) + "Get the squared norm of a quaternion." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.mul.vf vf1 vf1 vf1) + (.add.z.vf.w acc vf1 vf1) + (.add.mul.y.vf.w acc vf0 vf1 acc) + (.add.mul.x.vf.w vf1 vf0 vf1 acc) + (.add.w.vf vf1 vf0 vf1) + (.mov v0-0 vf1) + v0-0 + ) + ) + +(defun quaternion-norm ((arg0 quaternion)) + "Get the norm of a quaternion." + (local-vars (v1-1 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.mul.vf vf1 vf1 vf1) + (.add.z.vf.w acc vf1 vf1) + (.add.mul.y.vf.w acc vf0 vf1 acc) + (.add.mul.x.vf.w vf1 vf0 vf1 acc) + (.add.w.vf vf1 vf0 vf1) + (.mov v1-1 vf1) + (sqrtf v1-1) + ) + ) + +(defun quaternion-normalize! ((arg0 quaternion)) + "Normalize a quaternion." + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.mul.vf vf2 vf1 vf1) + (.add.z.vf.w acc vf2 vf2) + (.add.mul.y.vf.w acc vf0 vf2 acc) + (.add.mul.x.vf.w vf2 vf0 vf2 acc) + (.isqrt.vf Q vf0 vf2 :fsf #b11 :ftf #b11) + (.wait.vf) + (.mul.vf vf2 vf1 Q) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf2) + arg0 + ) + ) + +;; ERROR: Bad vector register dependency: vf3 +(defun quaternion-inverse! ((arg0 quaternion) (arg1 quaternion)) + "Invert a quaternion. The inverse will satisfy q * q^-1 = identity, even if q is not normalized. + If your quaternion is normalized, it is faster/more accurate to do quaternion-conjugate!" + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.mul.vf vf2 vf1 vf1) + (.sub.vf vf3 vf3 vf3) + (.add.z.vf.w acc vf2 vf2) + (.add.mul.y.vf.w acc vf0 vf2 acc) + (.add.mul.x.vf.w vf2 vf0 vf2 acc) + (.sub.vf.xyz vf3 vf3 vf1) + (.div.vf Q vf0 vf2 :fsf #b11 :ftf #b11) + (.add.vf.w vf3 vf3 vf1) + (.wait.vf) + (.mul.vf vf3 vf3 Q) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf3) + arg0 + ) + ) + +(defun quaternion-dot ((arg0 quaternion) (arg1 quaternion)) + "Treat quaternions as vectors and take the dot product." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.lvf vf2 (&-> arg1 quad)) + (.mul.vf vf1 vf1 vf2) + (.add.z.vf.w acc vf1 vf1) + (.add.mul.y.vf.w acc vf0 vf1 acc) + (.add.mul.x.vf.w vf1 vf0 vf1 acc) + (.add.w.vf vf1 vf0 vf1) + (.mov v0-0 vf1) + v0-0 + ) + ) + +(defun quaternion*! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion)) + "Real quaternion multiplication." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.sub.vf.w vf4 vf0 vf0) + (.mul.vf vf3 vf1 vf2) + (.outer.product.a.vf acc vf1 vf2) + (.outer.product.b.vf vf4 vf2 vf1 acc) + (.mul.w.vf acc vf1 vf2) + (.add.mul.w.vf acc vf2 vf1 acc) + (.sub.mul.w.vf.w acc vf0 vf3 acc) + (.sub.mul.z.vf.w acc vf0 vf3 acc) + (.sub.mul.y.vf.w acc vf0 vf3 acc) + (.sub.mul.x.vf.w acc vf0 vf3 acc) + (.add.mul.w.vf vf1 vf4 vf0 acc) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +(defun quaternion-right-mult-matrix! ((arg0 matrix) (arg1 quaternion)) + "Place quaternion coefficients into a matrix. + You can convert a quaternion to a matrix by taking the product of this + right-mult and left-mult matrix, but this method is not used. + Instead, quaternion->matrix is a more efficient implementation." + (let ((f3-0 (-> arg1 x)) + (f2-0 (-> arg1 y)) + (f1-0 (-> arg1 z)) + (f0-0 (-> arg1 w)) + ) + (set! (-> arg0 rvec x) f0-0) + (set! (-> arg0 rvec y) f1-0) + (set! (-> arg0 rvec z) (- f2-0)) + (set! (-> arg0 rvec w) f3-0) + (set! (-> arg0 uvec x) (- f1-0)) + (set! (-> arg0 uvec y) f0-0) + (set! (-> arg0 uvec z) f3-0) + (set! (-> arg0 uvec w) f2-0) + (set! (-> arg0 fvec x) f2-0) + (set! (-> arg0 fvec y) (- f3-0)) + (set! (-> arg0 fvec z) f0-0) + (set! (-> arg0 fvec w) f1-0) + (set! (-> arg0 trans x) (- f3-0)) + (set! (-> arg0 trans y) (- f2-0)) + (set! (-> arg0 trans z) (- f1-0)) + (set! (-> arg0 trans w) f0-0) + ) + arg0 + ) + +(defun quaternion-left-mult-matrix! ((arg0 matrix) (arg1 quaternion)) + "Place quaternion coefficients into a matrix. Unused." + (let ((f2-0 (-> arg1 x)) + (f1-0 (-> arg1 y)) + (f0-0 (-> arg1 z)) + ) + (let ((f3-0 (-> arg1 w))) + (set! (-> arg0 rvec x) f2-0) + (set! (-> arg0 rvec y) f3-0) + (set! (-> arg0 rvec z) (- f0-0)) + (set! (-> arg0 rvec w) f1-0) + (set! (-> arg0 uvec x) f1-0) + (set! (-> arg0 uvec y) f0-0) + (set! (-> arg0 uvec z) f3-0) + (set! (-> arg0 uvec w) (- f3-0)) + (set! (-> arg0 fvec x) f0-0) + (set! (-> arg0 fvec y) (- f1-0)) + (set! (-> arg0 fvec z) f2-0) + (set! (-> arg0 fvec w) f3-0) + (set! (-> arg0 trans x) f3-0) + ) + (set! (-> arg0 trans y) (- f2-0)) + (set! (-> arg0 trans z) (- f1-0)) + (set! (-> arg0 trans w) (- f0-0)) + ) + arg0 + ) + +(defun quaternion->matrix ((arg0 matrix) (arg1 quaternion)) + "Convert quaternion to matrix." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.add.vf vf5 vf1 vf1) + (.add.w.vf.x vf2 vf0 vf1) + (.add.z.vf.y vf2 vf0 vf1) + (.sub.y.vf.z vf2 vf0 vf1) + (.sub.w.vf.w vf2 vf0 vf0) + (.sub.z.vf.x vf3 vf0 vf1) + (.add.w.vf.y vf3 vf0 vf1) + (.add.x.vf.z vf3 vf0 vf1) + (.sub.w.vf.w vf3 vf0 vf0) + (.add.y.vf.x vf4 vf0 vf1) + (.sub.x.vf.y vf4 vf0 vf1) + (.add.w.vf.z vf4 vf0 vf1) + (.sub.w.vf.w vf4 vf0 vf0) + (.outer.product.a.vf acc vf5 vf2) + (.outer.product.b.vf vf2 vf2 vf5 acc) + (.outer.product.a.vf acc vf5 vf3) + (.outer.product.b.vf vf3 vf3 vf5 acc) + (.outer.product.a.vf acc vf5 vf4) + (.outer.product.b.vf vf4 vf4 vf5 acc) + (.add.w.vf.x vf2 vf2 vf0) + (.add.w.vf.y vf3 vf3 vf0) + (.add.w.vf.z vf4 vf4 vf0) + (.svf (&-> arg0 trans quad) vf0) + (.svf (&-> arg0 rvec quad) vf2) + (.svf (&-> arg0 uvec quad) vf3) + (.svf (&-> arg0 fvec quad) vf4) + arg0 + ) + ) + +;; ERROR: function was not converted to expressions. Cannot decompile. + +(defun matrix->quaternion ((arg0 quaternion) (arg1 matrix)) + "Convert a rotation matrix to a quaternion." + (let ((f0-2 (+ (-> arg1 rvec x) (-> arg1 uvec y) (-> arg1 fvec z)))) + (cond + ((< 0.0 f0-2) + (let ((f0-4 (sqrtf (+ 1.0 f0-2)))) + (set! (-> arg0 w) (/ f0-4 2)) + (let ((f0-5 (/ 0.5 f0-4))) + (set! (-> arg0 x) (* f0-5 (- (-> arg1 uvec z) (-> arg1 fvec y)))) + (set! (-> arg0 y) (* f0-5 (- (-> arg1 fvec x) (-> arg1 rvec z)))) + (set! (-> arg0 z) (* f0-5 (- (-> arg1 rvec y) (-> arg1 uvec x)))) + ) + ) + ) + (else + (let ((a2-0 0) + (a3-0 1) + (v1-4 2) + ) + (when (< (-> arg1 rvec x) (-> arg1 uvec y)) + (set! a2-0 1) + (set! a3-0 2) + (set! v1-4 0) + ) + (when (< (-> (the-as (pointer float) (+ (+ (* a2-0 4) (* a2-0 16)) (the-as int arg1)))) (-> arg1 fvec z)) + (set! a2-0 2) + (set! a3-0 0) + (set! v1-4 1) + ) + (let ((f0-12 + (sqrtf + (+ (- 1.0 + (+ (-> (the-as (pointer float) (+ (+ (* a3-0 4) (* a3-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* v1-4 4) (* v1-4 16)) (the-as int arg1)))) + ) + ) + (-> (the-as (pointer float) (+ (+ (* a2-0 4) (* a2-0 16)) (the-as int arg1)))) + ) + ) + ) + ) + (set! (-> arg0 vec data a2-0) (/ f0-12 2)) + (if (!= f0-12 0.0) + (set! f0-12 (/ 0.5 f0-12)) + ) + (set! (-> arg0 w) + (* (- (-> (the-as (pointer float) (+ (+ (* v1-4 4) (* a3-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* a3-0 4) (* v1-4 16)) (the-as int arg1)))) + ) + f0-12 + ) + ) + (set! (-> arg0 vec data a3-0) + (* (+ (-> (the-as (pointer float) (+ (+ (* a3-0 4) (* a2-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* a2-0 4) (* a3-0 16)) (the-as int arg1)))) + ) + f0-12 + ) + ) + (set! (-> arg0 vec data v1-4) + (* (+ (-> (the-as (pointer float) (+ (+ (* v1-4 4) (* a2-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* a2-0 4) (* v1-4 16)) (the-as int arg1)))) + ) + f0-12 + ) + ) + ) + ) + ) + ) + ) + arg0 + ) + +(defun matrix-with-scale->quaternion ((arg0 quaternion) (arg1 matrix)) + "Convert a matrix with a rotation and scale into a quaternion (just the rotation)." + (local-vars (a1-4 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (let ((v1-0 (new-stack-matrix0))) + (let* ((f0-1 (vector-dot (-> arg1 rvec) (-> arg1 rvec))) + (f1-1 (vector-dot (-> arg1 uvec) (-> arg1 uvec))) + (f2-1 (vector-dot (-> arg1 fvec) (-> arg1 fvec))) + (f0-3 (/ 1.0 (sqrtf f0-1))) + (f1-3 (/ 1.0 (sqrtf f1-1))) + (f2-3 (/ 1.0 (sqrtf f2-1))) + ) + (.lvf vf1 (&-> arg1 rvec quad)) + (.lvf vf2 (&-> arg1 uvec quad)) + (.lvf vf3 (&-> arg1 fvec quad)) + (.lvf vf4 (&-> arg1 trans quad)) + (let ((a1-1 f0-3)) + (.mov vf5 a1-1) + ) + (let ((a1-2 f1-3)) + (.mov vf6 a1-2) + ) + (let ((a1-3 f2-3)) + (.mov vf7 a1-3) + ) + ) + (.mul.x.vf vf1 vf1 vf5) + (.mul.x.vf vf2 vf2 vf6) + (.mul.x.vf vf3 vf3 vf7) + (.svf (&-> v1-0 rvec quad) vf1) + (.svf (&-> v1-0 uvec quad) vf2) + (.svf (&-> v1-0 fvec quad) vf3) + (.svf (&-> v1-0 trans quad) vf4) + (.mov a1-4 vf4) + (matrix->quaternion arg0 v1-0) + ) + ) + ) + +(defun quaternion-vector-len ((arg0 quaternion)) + "Assuming quaternion is normalized, get the length of the xyz part." + (sqrtf (- 1.0 (square (-> arg0 w)))) + ) + +(defun quaternion-log! ((arg0 quaternion) (arg1 quaternion)) + "Take the log of a quaternion. Unused." + (cond + ((= (-> arg1 w) 0.0) + (set! (-> arg0 x) (* 1.5707963 (-> arg1 x))) + (set! (-> arg0 y) (* 1.5707963 (-> arg1 y))) + (set! (-> arg0 z) (* 1.5707963 (-> arg1 z))) + ) + (else + (let* ((f30-0 (quaternion-vector-len arg1)) + (f0-9 (/ (atan2-rad (-> arg1 w) f30-0) f30-0)) + ) + (set! (-> arg0 x) (* (-> arg1 x) f0-9)) + (set! (-> arg0 y) (* (-> arg1 y) f0-9)) + (set! (-> arg0 z) (* (-> arg1 z) f0-9)) + ) + ) + ) + arg0 + ) + +(defun quaternion-exp! ((arg0 quaternion) (arg1 quaternion)) + "Quaternion exponentiation. Unused." + (let ((f30-0 (vector-length (-> arg1 vec)))) + (cond + ((= f30-0 0.0) + (set! (-> arg0 x) 0.0) + (set! (-> arg0 y) 0.0) + (set! (-> arg0 z) 0.0) + (set! (-> arg0 w) 1.0) + ) + (else + (let ((s5-0 (new 'stack-no-clear 'vector))) + (sincos-rad! s5-0 f30-0) + (let ((f0-6 (/ (-> s5-0 x) f30-0))) + (set! (-> arg0 x) (* (-> arg1 x) f0-6)) + (set! (-> arg0 y) (* (-> arg1 y) f0-6)) + (set! (-> arg0 z) (* (-> arg1 z) f0-6)) + ) + (set! (-> arg0 w) (-> s5-0 y)) + ) + ) + ) + ) + arg0 + ) + +(defun quaternion-slerp! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion) (arg3 float)) + "Real quaternion slerp. Spherical-linear interpolation is a nice way to interpolate + between quaternions." + (local-vars (v1-15 float)) + (rlet ((acc :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (let ((f0-0 (quaternion-dot arg1 arg2)) + (f30-0 1.0) + ) + (when (< f0-0 0.0) + (set! f0-0 (- f0-0)) + (set! f30-0 -1.0) + ) + (cond + ((< (- 1.0 f0-0) 0.0001) + (let ((v1-7 (- 1.0 arg3))) + (.mov vf1 v1-7) + ) + (let ((v1-8 (* arg3 f30-0))) + (.mov vf2 v1-8) + ) + (.lvf vf3 (&-> arg1 quad)) + (.lvf vf4 (&-> arg2 quad)) + (.mul.x.vf acc vf3 vf1) + (.add.mul.x.vf vf3 vf4 vf2 acc) + (.svf (&-> arg0 quad) vf3) + (quaternion-normalize! arg0) + ) + (else + (let* ((f1-6 (sqrtf (- 1.0 (square f0-0)))) + (f0-6 (/ (- f1-6 f0-0) (+ f1-6 f0-0))) + (f28-0 (/ 1.0 f1-6)) + ) + (let ((f0-7 (atan-series-rad f0-6)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s2-0 x) (* (- 1.0 arg3) f0-7)) + (set! (-> s2-0 y) (* arg3 f0-7 f30-0)) + (vector-sin-rad! s2-0 s2-0) + (.lvf vf1 (&-> s2-0 quad)) + ) + (let ((v1-14 f28-0)) + (.mov vf2 v1-14) + ) + ) + (.mul.x.vf vf1 vf1 vf2) + (.lvf vf3 (&-> arg1 quad)) + (.lvf vf4 (&-> arg2 quad)) + (.mul.x.vf acc vf3 vf1) + (.add.mul.y.vf vf3 vf4 vf1 acc) + (.svf (&-> arg0 quad) vf3) + (.mov v1-15 vf3) + ) + ) + ) + arg0 + ) + ) + +(defun quaternion-pseudo-slerp! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion) (arg3 float)) + "This is a bad interpolation between quaternions. It lerps then normalizes. + It will behave extremely poorly for 180 rotations. + It is unused." + (rlet ((acc :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (let ((f1-0 (quaternion-dot arg1 arg2)) + (f0-0 1.0) + ) + (when (< f1-0 0.0) + (- f1-0) + (set! f0-0 -1.0) + ) + (let ((v1-5 (- 1.0 arg3))) + (.mov vf1 v1-5) + ) + (let ((v1-6 (* arg3 f0-0))) + (.mov vf2 v1-6) + ) + ) + (.lvf vf3 (&-> arg1 quad)) + (.lvf vf4 (&-> arg2 quad)) + (.mul.x.vf acc vf3 vf1) + (.add.mul.x.vf vf3 vf4 vf2 acc) + (.svf (&-> arg0 quad) vf3) + (quaternion-normalize! arg0) + arg0 + ) + ) + +(defun quaternion-pseudo-seek ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion) (arg3 float)) + "Seek one quaternion toward another. Not using real slerp, so this is only good if the quaternions + are pretty similar." + (let ((s3-0 (new 'stack-no-clear 'quaternion))) + (let ((s5-0 (new 'stack-no-clear 'quaternion))) + (quaternion-copy! s3-0 arg2) + (if (< (quaternion-dot s3-0 arg1) 0.0) + (quaternion-negate! s3-0 s3-0) + ) + (quaternion-! s5-0 s3-0 arg1) + (let ((f0-1 (quaternion-norm2 s5-0))) + (if (< (square arg3) f0-1) + (quaternion-float*! s5-0 s5-0 (/ arg3 (sqrtf f0-1))) + ) + ) + (quaternion+! s3-0 arg1 s5-0) + ) + (quaternion-normalize! s3-0) + (quaternion-copy! arg0 s3-0) + ) + ) + +(defun quaternion-smooth-seek! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion) (arg3 float)) + "Another hacky rotation interpolation." + (let ((gp-0 (new 'stack-no-clear 'inline-array 'quaternion 2))) + (quaternion-copy! (-> gp-0 0) arg2) + (if (< (quaternion-dot (-> gp-0 0) arg1) 0.0) + (quaternion-negate! (-> gp-0 0) (-> gp-0 0)) + ) + (quaternion-! (-> gp-0 1) (-> gp-0 0) arg1) + (quaternion-float*! (-> gp-0 1) (-> gp-0 1) (fmin 1.0 arg3)) + (quaternion+! (-> gp-0 0) arg1 (-> gp-0 1)) + (quaternion-normalize! (-> gp-0 0)) + (quaternion-copy! arg0 (-> gp-0 0)) + ) + ) + +(defun quaternion-zxy! ((arg0 quaternion) (arg1 vector)) + "Make a quaternion from a sequence of z, x, y axis rotations." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (vector-rad<-vector-deg/2! s4-0 arg1) + (vector-sincos-rad! gp-0 s5-0 s4-0) + (.lvf vf1 (&-> gp-0 quad)) + (.lvf vf2 (&-> s5-0 quad)) + ) + (.mul.x.vf.w vf4 vf0 vf1) + (.add.vf.xyz vf4 vf0 vf2) + (.sub.vf.yz vf4 vf0 vf4) + (.add.vf.xyz vf3 vf0 vf1) + (.mul.x.vf.w vf3 vf0 vf2) + (.outer.product.a.vf acc vf1 vf1) + (.outer.product.b.vf vf6 vf0 vf0 acc) + (.outer.product.a.vf acc vf2 vf2) + (.outer.product.b.vf vf5 vf0 vf0 acc) + (.mul.x.vf.w vf6 vf0 vf6) + (.mul.x.vf.w vf5 vf0 vf5) + (.mul.vf acc vf6 vf4) + (.add.mul.vf vf7 vf5 vf3 acc) + (.svf (&-> arg0 quad) vf7) + arg0 + ) + ) + +(defun vector-x-quaternion! ((arg0 vector) (arg1 quaternion)) + "Get the first row of the rotation matrix for this quaternion." + (let ((s5-0 (new-stack-matrix0))) + (quaternion->matrix s5-0 arg1) + (set! (-> arg0 quad) (-> s5-0 rvec quad)) + ) + arg0 + ) + +(defun vector-y-quaternion! ((arg0 vector) (arg1 quaternion)) + "Get the second row of the rotation matrix for this quaternion." + (let ((s5-0 (new-stack-matrix0))) + (quaternion->matrix s5-0 arg1) + (set! (-> arg0 quad) (-> s5-0 uvec quad)) + ) + arg0 + ) + +(defun vector-z-quaternion! ((arg0 vector) (arg1 quaternion)) + "Get the third row of the rotation matrix for this quaternion." + (let ((s5-0 (new-stack-matrix0))) + (quaternion->matrix s5-0 arg1) + (set! (-> arg0 quad) (-> s5-0 fvec quad)) + ) + arg0 + ) + +(defun quaternion-x-angle ((arg0 quaternion)) + "Get the x rotation angle. Not very efficient." + (let ((v1-1 (vector-y-quaternion! (new 'stack-no-clear 'vector) arg0))) + (atan (-> v1-1 z) (-> v1-1 y)) + ) + ) + +(defun quaternion-y-angle ((arg0 quaternion)) + "Get the y rotation angle. Not very efficient." + (let ((v1-1 (vector-z-quaternion! (new 'stack-no-clear 'vector) arg0))) + (atan (-> v1-1 x) (-> v1-1 z)) + ) + ) + +(defun quaternion-z-angle ((arg0 quaternion)) + "Get the z rotation angle. Not very efficient." + (let ((v1-1 (vector-y-quaternion! (new 'stack-no-clear 'vector) arg0))) + (atan (-> v1-1 x) (-> v1-1 y)) + ) + ) + +(defun quaternion-vector-y-angle ((arg0 quaternion) (arg1 vector)) + "Not sure. Angle between quaternion and axis, projected in xz plane?" + (let ((f30-0 (quaternion-y-angle arg0)) + (f0-2 (atan (-> arg1 x) (-> arg1 z))) + ) + (deg-diff f30-0 f0-2) + ) + ) + +(defun quaternion-rotate-local-x! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along x axis." + (let ((a2-1 (quaternion-vector-angle! + (new-stack-quaternion0) + (new 'static 'vector :data (new 'static 'array float 4 1.0 0.0 0.0 1.0)) + arg2 + ) + ) + ) + (quaternion-normalize! (quaternion*! arg0 arg1 a2-1)) + ) + ) + +(defun quaternion-rotate-local-y! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along y axis." + (let ((a2-1 (quaternion-vector-angle! + (new-stack-quaternion0) + (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0)) + arg2 + ) + ) + ) + (quaternion-normalize! (quaternion*! arg0 arg1 a2-1)) + ) + ) + +(defun quaternion-rotate-local-z! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along z axis." + (let ((a2-1 (quaternion-vector-angle! + (new-stack-quaternion0) + (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 1.0 1.0)) + arg2 + ) + ) + ) + (quaternion-normalize! (quaternion*! arg0 arg1 a2-1)) + ) + ) + +(defun quaternion-rotate-y! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along y axis (right multiply)." + (let ((a1-2 (quaternion-vector-angle! + (new-stack-quaternion0) + (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0)) + arg2 + ) + ) + ) + (quaternion-normalize! (quaternion*! arg0 a1-2 arg1)) + ) + ) + +(defun quaternion-rotate-x! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along x axis (right multiply)." + (let ((a1-3 (quaternion-vector-angle! (new-stack-quaternion0) (vector-x-quaternion! (new-stack-vector0) arg1) arg2)) + ) + (quaternion-normalize! (quaternion*! arg0 a1-3 arg1)) + ) + ) + +(defun quaternion-rotate-z! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along z axis (right multiply)." + (let ((a1-3 (quaternion-vector-angle! (new-stack-quaternion0) (vector-z-quaternion! (new-stack-vector0) arg1) arg2)) + ) + (quaternion-normalize! (quaternion*! arg0 a1-3 arg1)) + ) + ) + +(defun quaternion-delta-y ((arg0 quaternion) (arg1 quaternion)) + "Difference in yaw between two quaternions." + (acos (vector-dot + (vector-z-quaternion! (new 'stack-no-clear 'vector) arg0) + (vector-z-quaternion! (new 'stack-no-clear 'vector) arg1) + ) + ) + ) + +(defun quaternion-rotate-y-to-vector! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion) (arg3 float)) + (let ((s5-0 (new 'stack-no-clear 'quaternion))) + (let ((t9-0 vector-xz-normalize!) + (a0-1 (new 'stack-no-clear 'vector)) + ) + (set! (-> a0-1 x) (-> arg2 x)) + (set! (-> a0-1 y) 0.0) + (set! (-> a0-1 z) (-> arg2 z)) + (set! (-> a0-1 w) 1.0) + (let ((s0-0 (t9-0 a0-1 1.0))) + (quaternion-from-two-vectors-max-angle! + s5-0 + (vector-z-quaternion! (new 'stack-no-clear 'vector) arg1) + s0-0 + arg3 + ) + ) + ) + (quaternion-normalize! (quaternion*! arg0 s5-0 arg1)) + ) + ) + +(defun vector-rotate-around-axis! ((arg0 vector) (arg1 vector) (arg2 float) (arg3 vector)) + "Rotate along y so z-axis points to match another. Use arg3 as the max rotation amount." + (let ((a2-1 (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) arg3 arg2))) + (vector-orient-by-quat! arg0 arg1 a2-1) + ) + ) + +(defun vector-rotate-x! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate vector along x axis." + (vector-rotate-around-axis! arg0 arg1 arg2 *x-vector*) + ) + +(defun vector-rotate-y! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate vector along y axis." + (vector-rotate-around-axis! arg0 arg1 arg2 *y-vector*) + ) + +;; ERROR: function was not converted to expressions. Cannot decompile. + +(defun vector-rotate-z! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate vector along z axis." + (vector-rotate-around-axis! arg0 arg1 arg2 *z-vector*) + ) + +(defun vector-y-angle ((arg0 vector)) + "Get the yaw angle of a vector." + (atan (-> arg0 x) (-> arg0 z)) + ) + +(defun vector-x-angle ((arg0 vector)) + "Get the pitch angle of a vector." + (atan (-> arg0 y) (vector-xz-length arg0)) + ) + +(defun quaternion<-rotate-y-vector ((arg0 quaternion) (arg1 vector)) + "Create a quaternion representing only the yaw of the given vector." + (quaternion-vector-angle! + arg0 + (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0)) + (vector-y-angle arg1) + ) + ) + +(defun-debug quaternion-validate ((arg0 quaternion)) + "Verify that a quaternion is valid, print an error if the length is off by more than 1%.." + (with-pp + (let ((f0-0 (quaternion-norm arg0))) + (when (or (< 1.01 f0-0) (< f0-0 0.99)) + (format #t "WARNING: bad quaternion (magnitude ~F) process is " f0-0) + (if (and pp (type? pp process-tree)) + (format #t "~A~%" (-> pp name)) + (format #t "#f~%") + ) + ) + ) + 0 + (none) + ) + ) + +(defun quaternion-xz-angle ((arg0 quaternion)) + "Yet another function to compute the yaw of a quaternion. This is a particularly inefficient version." + (let ((gp-0 (new 'stack-no-clear 'matrix)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (quaternion->matrix gp-0 arg0) + (set-vector! s5-0 0.0 0.0 1.0 1.0) + (vector-matrix*! s5-0 s5-0 gp-0) + (vector-y-angle s5-0) + ) + ) diff --git a/goal_src/jakx/engine/math/transform-h.gc b/goal_src/jakx/engine/math/transform-h.gc index 32d1cde34d..5fb2af8e38 100644 --- a/goal_src/jakx/engine/math/transform-h.gc +++ b/goal_src/jakx/engine/math/transform-h.gc @@ -7,3 +7,27 @@ ;; DECOMP BEGINS +(deftype transformq (structure) + "Transformation. w components of vectors should be 1.0 +This can represent any rotation, translation, and scaling. +Note that the scaling is applied before rotation +(meaning it scales along the axes of the pre-transformed frame)." + ((trans vector :inline) + (rot vector :inline) + (scale vector :inline) + ) + ) + + +(deftype trsq (basic) + "Like transform, but it's a basic. +Note that the trsq child type overrides this rotation with a quaternion. +usage of the plain trs is very limited, at least in Jak 1." + ((trans vector :inline) + (rot vector :inline) + (scale vector :inline) + ) + (:methods + (new (symbol type) _type_) + ) + ) diff --git a/goal_src/jakx/engine/math/transformq-h.gc b/goal_src/jakx/engine/math/transformq-h.gc index 54b299a77c..175ead7027 100644 --- a/goal_src/jakx/engine/math/transformq-h.gc +++ b/goal_src/jakx/engine/math/transformq-h.gc @@ -7,3 +7,57 @@ ;; DECOMP BEGINS +(deftype trsqv (trsq) + "A transform with: +- type information (child of [[basic]]) +- rotation stored as quaternion +- velocity information. +This is a very commonly used type to represent the position of an in-game object. +The `root` of a process-drawable (the parent 'in-game object' type) is a [[trsqv]]. +Additionally, the collision system uses [[trsqv]] as the parent type for foreground +collision objects ([[collide-shape]], [[collide-shape-moving]]). +As a result, this type has a lot of weird methods and extra stuff hidden in it." + ((pause-adjust-distance meters :offset 4) + (nav-radius meters :offset 8) + (transv vector :inline) + (rotv vector :inline) + (scalev vector :inline) + (dir-targ quaternion :inline) + (angle-change-time time-frame) + (old-y-angle-diff float) + ) + (:methods + (seek-toward-heading-vec! (_type_ vector float time-frame) quaternion) + (set-heading-vec! (_type_ vector) quaternion) + (seek-to-point-toward-point! (_type_ vector float time-frame) quaternion) + (point-toward-point! (_type_ vector) quaternion) + (seek-toward-yaw-angle! (_type_ float float time-frame) quaternion) + (set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion) + (set-roll-to-grav! (_type_ float) quaternion) + (set-roll-to-grav-2! (_type_ float) quaternion) + (rotate-toward-orientation! (_type_ quaternion float float int int float) quaternion) + (set-quaternion! (_type_ quaternion) quaternion) + (set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion) + (point-toward-point-clear-roll-pitch! (_type_ vector) quaternion) + (rot->dir-targ! (_type_) quaternion) + (y-angle (_type_) float) + (global-y-angle-to-point (_type_ vector) float) + (relative-y-angle-to-point (_type_ vector) float) + (roll-relative-to-gravity (_type_) float) + (set-and-limit-velocity (_type_ int vector float) trsqv) + (get-quaternion (_type_) quaternion) + ) + ) + + +(defmethod global-y-angle-to-point ((this trsqv) (arg0 vector)) + "Get the angle in the xz plane from the position of this trsqv to the point arg0 + (ignores our current yaw)." + (vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> this trans))) + ) + +(defmethod relative-y-angle-to-point ((this trsqv) (arg0 vector)) + "Get the y angle between the current orientation and arg0 + (how much we'd have to yaw to point at arg0)." + (deg-diff (y-angle this) (vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> this trans)))) + ) diff --git a/goal_src/jakx/engine/math/trigonometry-h.gc b/goal_src/jakx/engine/math/trigonometry-h.gc index 03f10db4a3..79ea31a6dd 100644 --- a/goal_src/jakx/engine/math/trigonometry-h.gc +++ b/goal_src/jakx/engine/math/trigonometry-h.gc @@ -5,5 +5,20 @@ ;; name in dgo: trigonometry-h ;; dgos: ENGINE, GAME -;; DECOMP BEGINS +(define-extern deg-diff (function float float float)) +(define-extern sin (function float float)) +(define-extern cos (function float float)) +(define-extern acos (function float float)) +(define-extern atan (function float float float)) +(define-extern sincos! (function vector float int)) +(define-extern sincos-rad! (function vector float int)) +(define-extern vector-sin-rad! (function vector vector vector)) +(define-extern vector-sincos-rad! (function vector vector vector int)) +(define-extern vector-rad<-vector-deg! (function vector vector none)) +(define-extern vector-rad<-vector-deg/2! (function vector vector int)) +(define-extern vector-sincos! (function vector vector vector int)) +(define-extern acos-rad (function float float)) +(define-extern atan-series-rad (function float float)) +(define-extern atan2-rad (function float float float)) +;; DECOMP BEGINS diff --git a/goal_src/jakx/engine/math/trigonometry.gc b/goal_src/jakx/engine/math/trigonometry.gc index 559cf06ebf..c711d5696f 100644 --- a/goal_src/jakx/engine/math/trigonometry.gc +++ b/goal_src/jakx/engine/math/trigonometry.gc @@ -5,5 +5,984 @@ ;; name in dgo: trigonometry ;; dgos: ENGINE, GAME +#|@file +The "rotation" unit stores an angle in a float, where 1.0 = 1/65,536 (1/2^16) of a rotation. +Use the ~r format specifier to print rotations as degrees. +In general, functions which use these units will only be accurate to within 1/65,536th of a rotation, +as they often internally convert the float to an integer. These function also handle wrapping +correctly, and will output angles in the range -32768 to 32768 (+/- one half of a rotation) +Functions with these units have deg or nothing special in the name. + +Some functions use radians. These typically have rad in the name, and they don't handle wrapping. +The input must be in the range -pi to pi + +General note on floating point constants: to avoid ambiguity/rounding issues related to printing/parsing, weird +constants are stored as hex. Commonly used constants that are exactly represented (1, 0.5, etc) will appear +normally. +|# + +;; There is a bug in some of the cosine functions that can be fixed by toggling this flag. +(defglobalconstant FIX_COSINE_BUG #f) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Floating Point Constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defconstant ROT_TO_RAD (the-as float #x38c90fda)) +(defconstant PI (the-as float #x40490fda)) +(defconstant MINUS_PI (the-as float #xc0490fda)) +(defconstant PI_OVER_2 (the-as float #x3fc90fda)) +(defconstant TWO_PI (the-as float #x40c90fda)) + +(defmacro unwrap-angle (angle) + `(the float (sar (shl (the int ,angle) 48) 48)) + ) + +(defmacro unwrap-angle-small-angle-fix (angle) + "Same as unwrap angle, but small angles are not rounded to zero." + `(if (< (fabs ,angle) 1.1) + ,angle + (the float (sar (shl (the int ,angle) 48) 48)) + ) + ) + ;; DECOMP BEGINS +(defun radmod ((arg0 float)) + "Wrap arg0 to be within (-pi, pi)." + (let ((f0-1 (+ 3.1415925 arg0))) + (if (< 0.0 f0-1) + (+ -3.1415925 (- f0-1 (* (the float (the int (/ f0-1 6.283185))) 6.283185))) + (+ 3.1415925 (- f0-1 (* (the float (the int (/ f0-1 6.283185))) 6.283185))) + ) + ) + ) + +(defun deg- ((arg0 float) (arg1 float)) + "Compute arg0-arg1, unwrapped, using rotation units. + Result should be in the range (-180, 180)" + (the float (sar (- (shl (the int arg0) 48) (shl (the int arg1) 48)) 48)) + ) + +(defun deg-diff ((arg0 float) (arg1 float)) + "Very similar to the function above, but computes arg1 - arg0 instead." + (the float (sar (- (shl (the int arg1) 48) (shl (the int arg0) 48)) 48)) + ) + +(defun deg-seek ((arg0 float) (arg1 float) (arg2 float)) + "Move in toward target by at most max-diff, using rotation units" + (let ((v1-1 (shl (the int arg0) 48)) + (a0-2 (shl (the int arg1) 48)) + ) + (let* ((a1-2 (shl (the int arg2) 48)) + (a2-1 (- a0-2 v1-1)) + (a3-0 (abs a2-1)) + ) + (set! a0-2 (cond + ((< a3-0 0) + (+ v1-1 a1-2) + ) + ((>= a1-2 a3-0) + (empty) + a0-2 + ) + ((>= a2-1 0) + (+ v1-1 a1-2) + ) + (else + (- v1-1 a1-2) + ) + ) + ) + ) + (the float (sar a0-2 48)) + ) + ) + +(defun deg-seek-smooth ((arg0 float) (arg1 float) (arg2 float) (arg3 float)) + "Step amount of the way from in to target, by at most max-diff, using rotation units" + (let ((f0-1 (* (deg- arg1 arg0) arg3))) + (if (< arg2 (fabs f0-1)) + (set! f0-1 (if (>= f0-1 0.0) + arg2 + (- arg2) + ) + ) + ) + (+ arg0 f0-1) + ) + ) + +(defun deg-lerp-clamp ((arg0 float) (arg1 float) (arg2 float)) + "Map [0, 1] to min-val, max-val, handling wrapping and saturating, using rotation units." + (cond + ((>= 0.0 arg2) + arg0 + ) + ((>= arg2 1.0) + arg1 + ) + (else + (the float (sar (shl (the int (+ arg0 (* arg2 (deg-diff arg0 arg1)))) 48) 48)) + ) + ) + ) + +(define binary-table (new 'static 'boxed-array :type float + 1.0 + 0.5 + 0.25 + 0.125 + 0.0625 + 0.03125 + 0.015625 + 0.0078125 + 0.00390625 + 0.001953125 + 0.0009765625 + 0.00048828125 + 0.00024414062 + 0.00012207031 + 0.000061035156 + 0.000030517578 + 0.000015258789 + 0.0000076293945 + 0.0000038146973 + 0.0000019073486 + 0.0000009536743 + 0.00000047683716 + 0.00000023841858 + 0.00000011920929 + 0.000000059604645 + 0.000000029802322 + 0.000000014901161 + 0.000000007450581 + 0.0000000037252903 + 0.0000000018626451 + 0.0000000009313226 + 0.0000000004656613 + ) + ) + +(define sincos-table (new 'static 'boxed-array :type float + 0.7853982 + 0.4636476 + 0.24497867 + 0.124354996 + 0.06241881 + 0.031239834 + 0.015623729 + 0.007812341 + 0.0039062302 + 0.0019531226 + 0.0009765622 + 0.0004882812 + 0.00024414062 + 0.00012207031 + 0.000061035156 + 0.000030517578 + 0.000015258789 + 0.0000076293945 + 0.0000038146973 + 0.0000019073486 + 0.0000009536743 + 0.00000047683716 + 0.00000023841858 + 0.00000011920929 + 0.000000059604645 + 0.000000029802322 + 0.000000014901161 + 0.000000007450581 + 0.0000000037252903 + 0.0000000018626451 + 0.0000000009313226 + 0.0000000004656613 + ) + ) + +(defun sin ((arg0 float)) + "Compute the sine of an angle in rotation units. Unwraps it." + ;; og:preserve-this + (let ((f2-0 (* 0.000095873795 (unwrap-angle arg0)))) + f2-0 + (let* ((f1-4 (* 0.999998 f2-0)) + (f0-3 (square f2-0)) + (f2-1 (* f2-0 f0-3)) + (f1-5 (+ f1-4 (* -0.16666014 f2-1))) + (f2-2 (* f2-1 f0-3)) + (f1-6 (+ f1-5 (* 0.008326521 f2-2))) + (f2-3 (* f2-2 f0-3)) + (f1-7 (+ f1-6 (* -0.0001956241 f2-3))) + (f0-4 (* f2-3 f0-3)) + ) + (+ f1-7 (* 0.0000023042373 f0-4)) + ) + ) + ) + +(defun sin-rad ((arg0 float)) + "Compute the sine of an angle in radians. + No unwrap is done, should be in -pi, pi" + (local-vars + (f1-0 float) + (f2-0 float) + (f3-0 float) + (f4-0 float) + (f5-0 float) + (f6-0 float) + (f7-0 float) + (f8-0 float) + (f9-0 float) + (f10-0 float) + (f11-0 float) + (acc float) + ) + (set! f1-0 (* arg0 arg0)) + (set! f7-0 (the-as float #x3f7fffde)) + (set! f8-0 (the-as float #xbe2aa8f5)) + (set! f2-0 (* arg0 f1-0)) + (set! f3-0 (* f1-0 f1-0)) + (set! f9-0 (the-as float #x3c086bf6)) + (set! f4-0 (* f2-0 f1-0)) + (set! f5-0 (* f3-0 f2-0)) + (set! f10-0 (the-as float #xb94d2072)) + (set! f6-0 (* f4-0 f3-0)) + (set! f11-0 (the-as float #x361aa27f)) + ;;(.mula.s arg0 f7-0) + (set! acc (* arg0 f7-0)) + ;;(.madda.s f2-0 f8-0) + (set! acc (+ acc (* f2-0 f8-0))) + ;;(.madda.s f4-0 f9-0) + (set! acc (+ acc (* f4-0 f9-0))) + ;;(.madda.s f5-0 f10-0) + (set! acc (+ acc (* f5-0 f10-0))) + ;;(.madd.s f12-0 f6-0 f11-0) + (+ acc (* f6-0 f11-0)) + ) + +(define *sin-poly-vec* + (new 'static 'vector :data (new 'static 'array float 4 -0.16666014 0.008326521 -0.0001956241 0.0000023042373)) + ) + +(define *sin-poly-vec2* (new 'static 'vector :data (new 'static 'array float 4 0.999998 0.0 0.0 0.0))) + +(defun vector-sin-rad! ((arg0 vector) (arg1 vector)) + "Taylor series approximation of sine on all 4 elements in a vector. + Inputs should be in radians, in -pi to pi. + Somehow their coefficients are a little bit off. + Like the first coefficient, which should obviously be 1, is not quite 1." + (rlet ((acc :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.mul.vf vf3 vf1 vf1) + (.lvf vf10 (&-> *sin-poly-vec2* quad)) + (.lvf vf9 (&-> *sin-poly-vec* quad)) + (.mul.vf vf4 vf3 vf1) + (.mul.vf vf5 vf3 vf3) + (.mul.x.vf acc vf1 vf10) + (.mul.vf vf6 vf4 vf3) + (.mul.vf vf7 vf5 vf4) + (.add.mul.x.vf acc vf4 vf9 acc) + (.mul.vf vf8 vf6 vf5) + (.add.mul.y.vf acc vf6 vf9 acc) + (.add.mul.z.vf acc vf7 vf9 acc) + (.add.mul.w.vf vf2 vf8 vf9 acc) + (.svf (&-> arg0 quad) vf2) + arg0 + ) + ) + +(defun cos-rad ((arg0 float)) + "Cosine with taylor series. Input is in radians, in -pi, pi. + - TODO constants" + (local-vars + (f1-0 float) + (f3-0 float) + (f4-0 float) + (f5-0 float) + (f7-0 float) + (f8-0 float) + (f9-0 float) + (f10-0 float) + (f11-0 float) + (acc float) + ) + (set! f1-0 (* arg0 arg0)) + (set! f7-0 1.000000) + (set! f8-0 (the-as float #xbefffd62)) + (set! f3-0 (* f1-0 f1-0)) + (set! f9-0 (the-as float #x3d2a7a28)) + (set! f10-0 (the-as float #xbab2bc31)) + (set! f4-0 (* f3-0 f1-0)) + (set! f5-0 (* f3-0 f3-0)) + (set! f11-0 (the-as float #x37a933eb)) + ;;(.mula.s f7-0 f7-0) + (set! acc (* f7-0 f7-0)) + ;;(.madda.s f8-0 f1-0) + (set! acc (+ acc (* f8-0 f1-0))) + ;;(.madda.s f9-0 f3-0) + (set! acc (+ acc (* f9-0 f3-0))) + ;;(.madda.s f10-0 f4-0) + (set! acc (+ acc (* f10-0 f4-0))) + ;;(.madd.s f12-0 f11-0 f5-0) + (+ acc (* f11-0 f5-0)) + ;;(the-as float f12-0) + ) + +(define *cos-poly-vec* + (new 'static 'vector :data (new 'static 'array float 4 -0.49998003 0.041620404 -0.0013636408 0.000020170546)) + ) + +;; ERROR: Bad vector register dependency: vf14 +(defun vector-sincos-rad! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Compute the sine and cosine of each element of src, storing it in dst-sin and dst-cos. + This is more efficient than separate calls to sin and cos. + Inputs should be radians in -pi to pi." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg2 quad)) + ;; og:preserve-this + ;; (.sub.vf vf14 vf14 vf14) + (.xor.vf vf14 vf14 vf14) + (.lvf vf11 (&-> *sin-poly-vec2* quad)) + (.mul.vf vf2 vf1 vf1) + (.lvf vf10 (&-> *sin-poly-vec* quad)) + (.lvf vf13 (&-> *cos-poly-vec* quad)) + (.mul.x.vf acc vf1 vf11) + (.mul.vf vf3 vf2 vf1) + (.mul.vf vf4 vf2 vf2) + (.mul.vf vf5 vf3 vf2) + (.mul.vf vf6 vf3 vf3) + (.mul.vf vf7 vf4 vf3) + (.mul.vf vf8 vf4 vf4) + (.mul.vf vf9 vf5 vf4) + (.add.mul.x.vf acc vf3 vf10 acc) + (.add.mul.y.vf acc vf5 vf10 acc) + (.add.mul.z.vf acc vf7 vf10 acc) + (.add.mul.w.vf vf12 vf9 vf10 acc) + (.add.w.vf acc vf14 vf0) + (.add.mul.x.vf acc vf2 vf13 acc) + (.add.mul.y.vf acc vf4 vf13 acc) + (.add.mul.z.vf acc vf6 vf13 acc) + (.add.mul.w.vf vf14 vf8 vf13 acc) + (.svf (&-> arg0 quad) vf12) + (.svf (&-> arg1 quad) vf14) + 0 + ) + ) + +;; og:preserve-this +(defmacro sincos-rad-asm (out x) + ;; Compute the sine and cosine of x, store it in the output array + ;; this assembly is shared in two functions. + `(rlet ((f10 :class fpr :type float) ;; coeff 1.0 + (f11 :class fpr :type float) ;; coeff -1/3! + (f12 :class fpr :type float) ;; coeff 1/5! + (f14 :class fpr :type float) ;; coeff -1/7! + (f15 :class fpr :type float) ;; coeff 1/9! + (f1 :class fpr :type float) ;; x + (f2 :class fpr :type float) ;; x^2 + (f3 :class fpr :type float) ;; x^3 + (f4 :class fpr :type float) ;; x^4 + (f5 :class fpr :type float) ;; x^5 + (f6 :class fpr :type float) ;; x^6 + (f7 :class fpr :type float) ;; x^7 + (f8 :class fpr :type float) ;; x^8 + (f9 :class fpr :type float) ;; x^9 + (f21 :class fpr :type float) + (f22 :class fpr :type float) ;; 0 ? + (acc :class fpr :type float) ;; temp + (f16 :class fpr :type float) ;; 1.0 + (f17 :class fpr :type float) ;; cos coeff 1 + (f18 :class fpr :type float) ;; cos coeff 2 + (f19 :class fpr :type float) ;; cos coeff 3 + (f20 :class fpr :type float) ;; cos coeff 4 + ) + ;; lui v1, 16255 + ;; lui a2, -16854 + ;; ori v1, v1, 65502 + ;; mtc1 f1, a1 + (set! f1 ,x) + ;; ori a1, a2, 43253 + ;; sub.s f22, f22, f22 + (set! f22 (the-as float 0)) + ;; lui a2, 15368 + ;; mtc1 f10, v1 + (set! f10 (the-as float #x3F7FFFDE)) ;; almost 1.0 + ;; ori v1, a2, 27638 + ;; mtc1 f11, a1 + (set! f11 (the-as float #xBE2AA8F5)) ;; -0.166, 1/3! + ;; lui a1, -18099 + ;; mul.s f2, f1, f1 + (set! f2 (* f1 f1)) + ;; ori a1, a1, 8306 + ;; mtc1 f12, v1 + (set! f12 (the-as float #x3C086BF6)) ;; 1/5! + ;; lui v1, 13850 + ;; mtc1 f14, a1 + (set! f14 (the-as float #xB94D2072)) ;; 1/7! + ;; ori a1, v1, 41599 + ;; mula.s f1, f10 + (set! acc (* f1 f10)) ;; x * c_1 + ;; lui v1, 16256 + ;; mul.s f3, f2, f1 + (set! f3 (* f2 f1)) ;; x^3 + ;; or v1, v1, r0 + ;; mul.s f4, f2, f2 + (set! f4 (* f2 f2)) ;; x^4 + ;; lui a2, -16641 + ;; mtc1 f15, a1 + (set! f15 (the-as float #x361AA27F)) ;; 1/9! + ;; lui a1, -16641 ;; I think this is a typo... + ;; or a1, a2, a1 ;; this should set the lower 16 bits. + ;; mtc1 f16, v1 + (set! f16 (the-as float #x3f800000)) ;; 1.0 + ;; sll r0, r0, 0 + ;; mtc1 f17, a1 + + ;; it looks like they set the lower 16-bits of the x^2 + ;; coefficient for cosine incorrectly + (#cond + (FIX_COSINE_BUG + ;; the constant used in *cos-poly-vec* + (set! f17 (the-as float #xbefffd62)) + ) + (#t + ;; missing the lower 16 bits. + (set! f17 (the-as float #xBEFF0000)) + ) + ) + + ;; sll r0, r0, 0 + ;; mul.s f5, f3, f2 + (set! f5 (* f3 f2)) + ;; sll r0, r0, 0 + ;; mul.s f6, f3, f3 + (set! f6 (* f3 f3)) + ;; sll r0, r0, 0 + ;; mul.s f7, f4, f3 + (set! f7 (* f4 f3)) + ;; sll r0, r0, 0 + ;; mul.s f8, f4, f4 + (set! f8 (* f4 f4)) + ;; sll r0, r0, 0 + ;; mul.s f9, f5, f4 + (set! f9 (* f5 f4)) + ;; lui v1, 15658 + ;; madda.s f3, f11 + (set! acc (+ acc (* f3 f11))) ;; add x^3 sine term + ;; ori v1, v1, 31272 + ;; madda.s f5, f12 + (set! acc (+ acc (* f5 f12))) ;; add x^5 sine term + ;; lui a1, -17742 + ;; madda.s f7, f14 + (set! acc (+ acc (* f7 f14))) ;; add x^7 sine term + ;; ori a1, a1, 48177 + ;; madd.s f21, f9, f15 + (set! f21 (+ acc (* f9 f15))) ;; add x^9 sine term + ;; lui a2, 14249 + ;; mtc1 f18, v1 + (set! f18 (the-as float #x3D2A7A28)) ;; cos coeff + ;; ori v1, a2, 13291 + ;; mtc1 f19, a1 + (set! f19 (the-as float #xBAB2BC31)) ;; cos coeff + ;; sll r0, r0, 0 + ;; mtc1 f20, v1 + (set! f20 (the-as float #x37A933EB)) + ;; sll r0, r0, 0 + ;; mula.s f16, f16 + (set! acc (* f16 f16)) ;; acc = 1, constant cos term. + ;; sll r0, r0, 0 + ;; madda.s f2, f17 + (set! acc (+ acc (* f2 f17))) + ;; sll r0, r0, 0 + ;; madda.s f4, f18 + (set! acc (+ acc (* f4 f18))) + ;; sll r0, r0, 0 + ;; madda.s f6, f19 + (set! acc (+ acc (* f6 f19))) + ;; sll r0, r0, 0 + ;; madd.s f22, f8, f20 + (set! f22 (+ acc (* f8 f20))) + ;; sll r0, r0, 0 + ;; swc1 f21, 0(a0) + (set! (-> ,out x) f21) + ;; sll r0, r0, 0 + ;; swc1 f22, 4(a0) + (set! (-> ,out y) f22) + ;; or v0, r0, r0 + 0 + ) + ) + +(defun sincos-rad! ((out vector) (x float)) + "Compute the sine and cosine of x, store it in the output array. + Has the cosine bug." + (sincos-rad-asm out x) + ) + +(defun sincos! ((out vector) (x float)) + "Compute the sine and cosine of x, store it in the output array. + The input is in rotation units, and is unwrapped properly. + Also has the cosine bug" + (sincos-rad-asm out (* ROT_TO_RAD (unwrap-angle x))) + ) + +;; WARN: Return type mismatch float vs none. +(defun vector-rad<-vector-deg! ((out vector) (in vector)) + "Convert a vector in rotation units to radians, and unwrap. + Input can be anything, output will be -2pi to pi." + (local-vars (v0-0 float) (v1-1 uint128) (v1-2 uint128) (v1-3 uint128)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (let ((v1-0 #x38c90fda)) + (.lvf vf1 (&-> in quad)) + (.ftoi.vf vf1 vf1) + (.mov vf2 v1-0) + ) + (.mov v1-1 vf1) + (.pw.sll v1-2 v1-1 16) + (.pw.sra v1-3 v1-2 16) + (.mov vf1 v1-3) + (.itof.vf vf1 vf1) + (.mul.x.vf vf1 vf1 vf2) + (.svf (&-> out quad) vf1) + (.mov v0-0 vf1) + (none) + ) + ) + +;; WARN: Return type mismatch float vs int. +(defun vector-rad<-vector-deg/2! ((out vector) (in vector)) + "Divide the input by two, and then convert from rotation units to radians, unwrapping. + Not sure why this really needs to be separate the from previous function..." + (local-vars (v0-0 float) (v1-1 uint128) (v1-2 uint128) (v1-3 uint128)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (let ((v1-0 #x38c90fda)) + (let ((a2-0 #x3f000000)) + (.lvf vf1 (&-> in quad)) + (.mov vf2 a2-0) + ) + (.mul.x.vf vf1 vf1 vf2) + (.ftoi.vf vf1 vf1) + (.mov vf2 v1-0) + ) + (.mov v1-1 vf1) + (.pw.sll v1-2 v1-1 16) + (.pw.sra v1-3 v1-2 16) + (.mov vf1 v1-3) + (.itof.vf vf1 vf1) + (.mul.x.vf vf1 vf1 vf2) + (.svf (&-> out quad) vf1) + (.mov v0-0 vf1) + (the-as int v0-0) + ) + ) + +(defun vector-sincos! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Compute sine and cosine of each element in a vector, in rotation units" + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-rad<-vector-deg! s4-0 arg2) + (vector-sincos-rad! arg0 arg1 s4-0) + ) + ) + +(defun tan-rad ((arg0 float)) + "This function appears to be named wrong and actually operates on rotation units." + (/ (sin arg0) (cos arg0)) + ) + +(defun cos ((arg0 float)) + "Cosine of rotation units." + (sin (+ 16384.0 arg0)) + ) + +(defun tan ((arg0 float)) + "Correctly named tangent of rotation units." + (/ (sin arg0) (cos arg0)) + ) + +(defun atan0 ((arg0 float) (arg1 float)) + "Inverse tangent, to rotation units. y,x order. Does not handle signs correctly. + Do not use this function directly, instead use atan2." + (rlet ((f20 :class fpr :type float) + (f21 :class fpr :type float) + (f1 :class fpr :type float) + (f2 :class fpr :type float) + (f3 :class fpr :type float) + (f4 :class fpr :type float) + (f5 :class fpr :type float) + (f6 :class fpr :type float) + (f7 :class fpr :type float) + (f8 :class fpr :type float) + (f9 :class fpr :type float) + (f10 :class fpr :type float) + (f19 :class fpr :type float) + (f11 :class fpr :type float) + (f12 :class fpr :type float) + (f13 :class fpr :type float) + (f14 :class fpr :type float) + (f15 :class fpr :type float) + (f16 :class fpr :type float) + (f17 :class fpr :type float) + (f18 :class fpr :type float) + (acc :class fpr :type float) + ) + + ;;mtc1 f20, a1 + (set! f20 arg1) + ;;mtc1 f21, a0 + (set! f21 arg0) + ;;sub.s f1, f21, f20 + (set! f1 (- f21 f20)) + ;;add.s f2, f21, f20 + (set! f2 (+ f21 f20)) + ;;div.s f1, f1, f2 + (set! f1 (/ f1 f2)) + ;;lwc1 f19, L132(fp) + (set! f19 (the-as float #x46000000)) + ;;lwc1 f11, L140(fp) + (set! f11 (the-as float #x4622f97c)) + ;;lwc1 f12, L151(fp) + (set! f12 (the-as float #xc55946e1)) + ;;lwc1 f13, L120(fp) + (set! f13 (the-as float #x450207fd)) + ;;lwc1 f14, L126(fp) + (set! f14 (the-as float #xc4b556ce)) + ;;lwc1 f15, L113(fp) + (set! f15 (the-as float #x447b6ca4)) + ;;mul.s f2, f1, f1 + (set! f2 (* f1 f1)) + ;;lwc1 f16, L142(fp) + (set! f16 (the-as float #xc411ca52)) + ;;lwc1 f17, L118(fp) + (set! f17 (the-as float #x43640558)) + ;;mul.s f3, f1, f2 + (set! f3 (* f1 f2)) + ;;mul.s f1, f1, f11 + (set! f1 (* f1 f11)) + ;;mul.s f4, f2, f2 + (set! f4 (* f2 f2)) + ;;lwc1 f18, L141(fp) + (set! f18 (the-as float #xc2292434)) + ;;mul.s f5, f3, f2 + (set! f5 (* f3 f2)) + ;;mul.s f6, f4, f3 + (set! f6 (* f4 f3)) + ;;mul.s f7, f5, f4 + (set! f7 (* f5 f4)) + ;;mul.s f8, f6, f4 + (set! f8 (* f6 f4)) + ;;mul.s f9, f7, f4 + (set! f9 (* f7 f4)) + ;;mul.s f10, f8, f4 + (set! f10 (* f8 f4)) + ;;adda.s f1, f19 + (set! acc (+ f1 f19)) + ;;madda.s f3, f12 + (set! acc (+ acc (* f3 f12))) + + ;;madda.s f5, f13 + (set! acc (+ acc (* f5 f13))) + + ;;madda.s f6, f14 + (set! acc (+ acc (* f6 f14))) + + ;;madda.s f7, f15 + (set! acc (+ acc (* f7 f15))) + + ;;madda.s f8, f16 + (set! acc (+ acc (* f8 f16))) + + ;;madda.s f9, f17 + (set! acc (+ acc (* f9 f17))) + + ;;madd.s f19, f10, f18 + ;;mfc1 v0, f19 + (+ acc (* f10 f18)) + ) + ) + +;; og:preserve-this +(defmacro .adda.s (a b) + `(set! acc (+ ,a ,b)) + ) + +(defmacro .madda.s (a b) + `(set! acc (+ acc (* ,a ,b))) + ) + +(defmacro .madd.s (a b c) + `(set! ,a (+ acc (* ,b ,c))) + ) + +(defun atan-rad ((arg0 float)) + "Inverse tangent in radians." + (atan-series-rad (/ (+ -1.0 arg0) (+ 1.0 arg0))) + ) + +(defun sign-bit ((arg0 int)) + "Return 1 if bit 31 is set, otherwise 0." + ;; originally used 32-bit shift, doesn't really matter. + (logand (shr arg0 31) 1) + + ;(local-vars (v1-1 int)) + ; (let ((v1-0 arg0)) + ; (shift-arith-right-32 v1-1 v1-0 31) + ; ) + ; (logand v1-1 1) + ) + +(defun sign-float ((arg0 float)) + "Return 1 if arg0 is positive or zero, -1 otherwise. + Fast (no branching)." + (let ((a1-0 #xffffffff80000000) + (v1-0 #x3f800000) + ) + (the-as float (logior (logand (the-as uint arg0) (the-as uint a1-0)) v1-0)) + ) + ) + +(defun sign ((arg0 float)) + "Similar to above, but returns 0 if input is 0. + But is more complicated." + (cond + ((< 0.0 arg0) + 1.0 + ) + ((< arg0 0.0) + -1.0 + ) + (else + 0.0 + ) + ) + ) + +(defun atan2-rad ((arg0 float) (arg1 float)) + "Atan for radians." + (cond + ((= arg1 0.0) + (* 1.5707963 (sign arg0)) + ) + ((and (< arg0 0.0) (< arg1 0.0)) + (let ((f30-1 -3.1415925) + (f0-6 (/ arg0 arg1)) + ) + (+ f30-1 (atan-series-rad (/ (+ -1.0 f0-6) (+ 1.0 f0-6)))) + ) + ) + ((< arg0 0.0) + (let ((f0-14 (- (/ arg0 arg1)))) + (- (atan-series-rad (/ (+ -1.0 f0-14) (+ 1.0 f0-14)))) + ) + ) + ((< arg1 0.0) + (let ((f30-2 3.1415925) + (f0-22 (- (/ arg0 arg1))) + ) + (- f30-2 (atan-series-rad (/ (+ -1.0 f0-22) (+ 1.0 f0-22)))) + ) + ) + (else + (let ((f0-28 (/ arg0 arg1))) + (atan-series-rad (/ (+ -1.0 f0-28) (+ 1.0 f0-28))) + ) + ) + ) + ) + +(defun atan ((arg0 float) (arg1 float)) + "Atan for rotation units. Signs behave like atan.." + (cond + ((and (= arg1 0.0) (= arg0 0.0)) + 0.0 + ) + ((and (< arg1 0.0) (< arg0 0.0)) + (+ -32768.0 (atan0 (- arg0) (- arg1))) + ) + ((< arg0 0.0) + (- (atan0 (- arg0) arg1)) + ) + ((< arg1 0.0) + (- 32768.0 (atan0 arg0 (- arg1))) + ) + (else + (atan0 arg0 arg1) + ) + ) + ) + +(defun asin ((arg0 float)) + "Inverse sine, rotation units." + (let ((gp-0 #f)) + 0.0 + (when (< arg0 0.0) + (set! arg0 (- arg0)) + (set! gp-0 #t) + ) + (let ((f0-5 (cond + ((< 1.0 arg0) + 16383.996 + ) + (else + (let ((f0-8 (sqrtf (- 1.0 (square arg0))))) + (atan0 arg0 f0-8) + ) + ) + ) + ) + ) + (if gp-0 + (- f0-5) + f0-5 + ) + ) + ) + ) + +(defun acos ((arg0 float)) + "Inverse cosine. Returns rotation units." + (let ((result (- 16384.000000 (asin arg0)))) + (#when PC_PORT + ;; og:preserve-this to avoid punch glitch: + ;; (note: it might be a better fix to change the global rounding mode, + ;; but it's not super clear to me that the mode picked by PCSX2 is + ;; more accurate than normal in all cases. So, we'll do this for now.) + (when (= result 0.0) + (set! result 0.00000000001) + ) + ) + result + ) + ) + +(defun acos-rad ((arg0 float)) + "Inverse cosine, radians." + (cond + ((>= arg0 0.0) + (let* ((f0-3 (sqrtf (- 1.0 (square arg0)))) + (f0-5 (/ (- f0-3 arg0) (+ f0-3 arg0))) + ) + (atan-series-rad f0-5) + ) + ) + (else + (let* ((f0-8 (sqrtf (- 1.0 (square arg0)))) + (f0-10 (/ (+ f0-8 arg0) (- f0-8 arg0))) + ) + (- 3.1415925 (atan-series-rad f0-10)) + ) + ) + ) + ) + +(defun sinerp ((arg0 float) (arg1 float) (arg2 float)) + "Map amount to min,max using sine. Kinda weird, usually people use cosine." + (lerp arg0 arg1 (sin (* 16384.0 arg2))) + ) + +(defun sinerp-clamp ((arg0 float) (arg1 float) (arg2 float)) + "Like sinerp, but clamp to min,max." + (cond + ((>= 0.0 arg2) + arg0 + ) + ((>= arg2 1.0) + arg1 + ) + (else + (sinerp arg0 arg1 arg2) + ) + ) + ) + +(defun coserp ((arg0 float) (arg1 float) (arg2 float)) + "Weird lerp with cosine (over 90 degrees?)." + (lerp arg0 arg1 (- 1.0 (cos (* 16384.0 arg2)))) + ) + +(defun coserp-clamp ((arg0 float) (arg1 float) (arg2 float)) + "Weird 90 degree lerp with cosine, clamped to min,max." + (cond + ((>= 0.0 arg2) + arg0 + ) + ((>= arg2 1.0) + arg1 + ) + (else + (coserp arg0 arg1 arg2) + ) + ) + ) + +(defun coserp180 ((arg0 float) (arg1 float) (arg2 float)) + "Classic lerp with cosine." + (lerp arg0 arg1 (* 0.5 (- 1.0 (cos (* 32768.0 arg2))))) + ) + +(defun coserp180-clamp ((arg0 float) (arg1 float) (arg2 float)) + "Classic coserp with saturation." + (cond + ((>= 0.0 arg2) + arg0 + ) + ((>= arg2 1.0) + arg1 + ) + (else + (coserp180 arg0 arg1 arg2) + ) + ) + ) + +(defun ease-in-out ((arg0 int) (arg1 int)) + "Weird coserp like mapping from 0 to 1 as progress goes from 0 to total." + (local-vars (v1-0 int)) + (cond + ((>= arg1 arg0) + 1.0 + ) + ((<= arg1 0) + 0.0 + ) + ((begin (set! v1-0 (/ arg0 2)) (< v1-0 arg1)) + (let ((a0-1 (- arg1 arg0))) + (+ 0.5 (* 0.5 (sin (- 16384.0 (/ (* 16384.0 (the float a0-1)) (the float v1-0)))))) + ) + ) + (else + (- 0.5 (* 0.5 (cos (/ (* 16384.0 (the float arg1)) (the float v1-0))))) + ) + ) + ) diff --git a/goal_src/jakx/engine/math/vector-h.gc b/goal_src/jakx/engine/math/vector-h.gc index 27a7deee1e..b823b91e5c 100644 --- a/goal_src/jakx/engine/math/vector-h.gc +++ b/goal_src/jakx/engine/math/vector-h.gc @@ -5,5 +5,637 @@ ;; name in dgo: vector-h ;; dgos: ENGINE, GAME +(define-extern vector-identity! (function vector vector)) +(define-extern vector-cross! (function vector vector vector vector)) +(define-extern vector-float*! (function vector vector float vector)) +(define-extern vector+float*! (function vector vector vector float vector)) +(define-extern vector-negate! (function vector vector vector)) +(define-extern vector-normalize! (function vector float vector)) +(define-extern vector-normalize-copy! (function vector vector float vector)) +(define-extern vector-normalize-ret-len! (function vector float float)) +(define-extern vector-xz-normalize! (function vector float vector)) +(define-extern vector-get-unique! (function vector vector vector)) +(define-extern vector-get-closest-perpendicular! (function vector vector vector vector)) +(define-extern vector-vector-distance (function vector vector float)) +(define-extern vector-vector-distance-squared (function vector vector float)) +(define-extern vector-length (function vector float)) +(define-extern vector-length-squared (function vector float)) +(define-extern vector-xz-length (function vector float)) +(define-extern vector*! (function vector vector vector vector)) + +(defmacro new-stack-vector0 () + "Get a stack vector that's set to 0. + This is more efficient than (new 'stack 'vector) because + this doesn't call the constructor." + `(let ((vec (new 'stack-no-clear 'vector))) + (set! (-> vec quad) (the-as uint128 0)) + vec + ) + ) + +(defmacro set-vector! (v xv yv zv wv) + "Set all fields in a vector" + (with-gensyms (vec) + `(let ((,vec ,v)) + (set! (-> ,vec x) ,xv) + (set! (-> ,vec y) ,yv) + (set! (-> ,vec z) ,zv) + (set! (-> ,vec w) ,wv) + ,vec + )) + ) + +(defmacro set-vector-xyz! (v xv yv zv) + "Set xyz fields in a vector" + (with-gensyms (vec) + `(let ((,vec ,v)) + (set! (-> ,vec x) ,xv) + (set! (-> ,vec y) ,yv) + (set! (-> ,vec z) ,zv) + ,vec + )) + ) + + ;; DECOMP BEGINS +(deftype bit-array (basic) + ((length int32) + (allocated-length int32) + (_pad uint8) + (bytes uint8 :dynamic :overlay-at _pad) + ) + (:methods + (new (symbol type int) _type_) + (get-bit (_type_ int) symbol) + (clear-bit (_type_ int) int) + (set-bit (_type_ int) int) + (clear-all! (_type_) _type_) + ) + ) + + +(defmethod new bit-array ((allocation symbol) (type-to-make type) (arg0 int)) + "Allocate a new bit-array with room arg0 bits." + (let ((v0-0 (object-new allocation type-to-make (+ (/ (logand -8 (+ arg0 7)) 8) -1 (-> type-to-make size))))) + (set! (-> v0-0 length) arg0) + (set! (-> v0-0 allocated-length) arg0) + v0-0 + ) + ) + +(defmethod length ((this bit-array)) + (-> this length) + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this bit-array)) + (the-as int (+ (-> this type size) (/ (logand -8 (+ (-> this allocated-length) 7)) 8))) + ) + +(defmethod get-bit ((this bit-array) (arg0 int)) + "Get the nth bit as a boolean." + (let ((v1-2 (-> this bytes (/ arg0 8)))) + (logtest? v1-2 (ash 1 (logand arg0 7))) + ) + ) + +(defmethod clear-bit ((this bit-array) (arg0 int)) + "Set the nth bit to 0." + (logclear! (-> this bytes (/ arg0 8)) (ash 1 (logand arg0 7))) + 0 + ) + +(defmethod set-bit ((this bit-array) (arg0 int)) + "Set the nth bit to 1." + (logior! (-> this bytes (/ arg0 8)) (ash 1 (logand arg0 7))) + 0 + ) + +(defmethod clear-all! ((this bit-array)) + "Set all bits to 0." + (countdown (v1-2 (/ (logand -8 (+ (-> this allocated-length) 7)) 8)) + (nop!) + (nop!) + (set! (-> this bytes v1-2) (the-as uint 0)) + ) + this + ) + +(deftype vector16ub (structure) + ((data uint8 16) + (quad uint128 :overlay-at (-> data 0)) + ) + ) + + +(deftype vector4ub (structure) + ((data uint8 4) + (x uint8 :overlay-at (-> data 0)) + (y uint8 :overlay-at (-> data 1)) + (z uint8 :overlay-at (-> data 2)) + (w uint8 :overlay-at (-> data 3)) + (clr uint32 :overlay-at (-> data 0)) + ) + :pack-me + ) + + +(deftype vector4b (structure) + ((data int8 4) + (x int8 :overlay-at (-> data 0)) + (y int8 :overlay-at (-> data 1)) + (z int8 :overlay-at (-> data 2)) + (w int8 :overlay-at (-> data 3)) + (clr int32 :overlay-at (-> data 0)) + ) + :pack-me + ) + + +(deftype vector2ub (structure) + ((data uint8 2) + (x uint8 :overlay-at (-> data 0)) + (y uint8 :overlay-at (-> data 1)) + (clr uint16 :overlay-at (-> data 0)) + ) + :pack-me + ) + + +(deftype vector2b (structure) + ((data int8 2) + (x int8 :overlay-at (-> data 0)) + (y int8 :overlay-at (-> data 1)) + (clr int16 :overlay-at (-> data 0)) + ) + ) + + +(deftype vector2h (structure) + ((data int16 2) + (x int16 :overlay-at (-> data 0)) + (y int16 :overlay-at (-> data 1)) + ) + :pack-me + ) + + +(deftype vector2uh (structure) + ((data uint16 2) + (x uint16 :overlay-at (-> data 0)) + (y uint16 :overlay-at (-> data 1)) + (val uint32 :overlay-at (-> data 0)) + ) + :pack-me + ) + + +(deftype vector3h (structure) + ((data int16 3) + (x int16 :overlay-at (-> data 0)) + (y int16 :overlay-at (-> data 1)) + (z int16 :overlay-at (-> data 2)) + ) + ) + + +(deftype vector3uh (structure) + ((data uint16 3) + (x uint16 :overlay-at (-> data 0)) + (y uint16 :overlay-at (-> data 1)) + (z uint16 :overlay-at (-> data 2)) + ) + ) + + +(deftype vector2w (structure) + ((data int32 2) + (x int32 :overlay-at (-> data 0)) + (y int32 :overlay-at (-> data 1)) + ) + ) + + +(deftype vector3w (structure) + ((data int32 3) + (x int32 :overlay-at (-> data 0)) + (y int32 :overlay-at (-> data 1)) + (z int32 :overlay-at (-> data 2)) + ) + ) + + +(deftype vector4w (structure) + ((data int32 4) + (x int32 :overlay-at (-> data 0)) + (y int32 :overlay-at (-> data 1)) + (z int32 :overlay-at (-> data 2)) + (w int32 :overlay-at (-> data 3)) + (dword uint64 2 :overlay-at (-> data 0)) + (quad uint128 :overlay-at (-> data 0)) + ) + ) + + +(deftype vector2 (structure) + ((data float 2) + (x float :overlay-at (-> data 0)) + (y float :overlay-at (-> data 1)) + ) + :allow-misaligned + ) + + +(deftype vector3 (structure) + ((data float 3) + (x float :overlay-at (-> data 0)) + (y float :overlay-at (-> data 1)) + (z float :overlay-at (-> data 2)) + ) + ) + + +(deftype vector4 (structure) + ((data float 4) + (x float :overlay-at (-> data 0)) + (y float :overlay-at (-> data 1)) + (z float :overlay-at (-> data 2)) + (w float :overlay-at (-> data 3)) + (dword uint64 2 :overlay-at (-> data 0)) + (quad uint128 :overlay-at (-> data 0)) + ) + ) + + +(defmethod print ((this vector4w)) + (format #t "#" (-> this x) (-> this y) (-> this z) (-> this w) this) + this + ) + +(deftype vector4w-2 (structure) + ((data int32 8) + (quad uint128 2 :overlay-at (-> data 0)) + (vector vector4w 2 :inline :overlay-at (-> data 0)) + ) + ) + + +(deftype vector4w-3 (structure) + ((data int32 12) + (quad uint128 3 :overlay-at (-> data 0)) + (vector vector4w 3 :inline :overlay-at (-> data 0)) + ) + ) + + +(deftype vector4w-4 (structure) + ((data int32 16) + (quad uint128 4 :overlay-at (-> data 0)) + (vector vector4w 4 :inline :overlay-at (-> data 0)) + ) + ) + + +(deftype vector4h (structure) + ((data int16 4) + (x int16 :overlay-at (-> data 0)) + (y int16 :overlay-at (-> data 1)) + (z int16 :overlay-at (-> data 2)) + (w int16 :overlay-at (-> data 3)) + (long uint64 :overlay-at (-> data 0)) + ) + :pack-me + ) + + +(deftype vector4uh (structure) + ((data uint16 4) + (x uint16 :overlay-at (-> data 0)) + (y uint16 :overlay-at (-> data 1)) + (z uint16 :overlay-at (-> data 2)) + (w uint16 :overlay-at (-> data 3)) + (long uint64 :overlay-at (-> data 0)) + ) + ) + + +(deftype vector8h (structure) + ((data int16 8) + (quad uint128 :overlay-at (-> data 0)) + ) + ) + + +(deftype vector16b (structure) + ((data int8 16) + (quad uint128 :overlay-at (-> data 0)) + ) + ) + + + +(defmethod print ((this vector)) + (format #t "#" (-> this x) (-> this y) (-> this z) (-> this w) this) + this + ) + +(define *null-vector* (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 1.0))) + +(define *identity-vector* (new 'static 'vector :data (new 'static 'array float 4 1.0 1.0 1.0 1.0))) + +(define *x-vector* (new 'static 'vector :data (new 'static 'array float 4 1.0 0.0 0.0 1.0))) + +(define *y-vector* (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0))) + +(define *z-vector* (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 1.0 1.0))) + +(define *up-vector* (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0))) + +(deftype vector4s-3 (structure) + ((data float 12) + (quad uint128 3 :overlay-at (-> data 0)) + (vector vector 3 :inline :overlay-at (-> data 0)) + ) + ) + + +(deftype vector-array (inline-array-class) + ((data vector :inline :dynamic) + ) + ) + + +(set! (-> vector-array heap-base) (the-as uint 16)) + +(deftype rgbaf (vector) + ((r float :overlay-at (-> data 0)) + (g float :overlay-at (-> data 1)) + (b float :overlay-at (-> data 2)) + (a float :overlay-at (-> data 3)) + ) + ) + + +(deftype plane (vector) + ((a float :overlay-at (-> data 0)) + (b float :overlay-at (-> data 1)) + (c float :overlay-at (-> data 2)) + (d float :overlay-at (-> data 3)) + ) + ) + + +(deftype sphere (vector) + ((r float :overlay-at (-> data 3)) + ) + ) + + +(deftype isphere (vec4s) + () + ) + +(deftype box8s (structure) + ((data float 8) + (quad uint128 2 :overlay-at (-> data 0)) + (vector vector 2 :overlay-at (-> data 0)) + (min vector :inline :overlay-at (-> data 0)) + (max vector :inline :overlay-at (-> data 4)) + ) + ) + + +(deftype box8s-array (inline-array-class) + ((data box8s :inline :dynamic) + ) + ) + + +(set! (-> box8s-array heap-base) (the-as uint 32)) + +(deftype vertical-planes (structure) + ((data uint128 4) + ) + ) + + +(deftype vertical-planes-array (basic) + ((length uint32) + (data vertical-planes :inline :dynamic) + ) + ) + + +(deftype qword (structure) + ((data uint32 4) + (byte uint8 16 :overlay-at (-> data 0)) + (hword uint16 8 :overlay-at (-> data 0)) + (word uint32 4 :overlay-at (-> data 0)) + (dword uint64 2 :overlay-at (-> data 0)) + (quad uint128 :overlay-at (-> data 0)) + (vector vector :inline :overlay-at (-> data 0)) + (vector4w vector4w :inline :overlay-at (-> data 0)) + ) + ) + + +(deftype vector3s (structure) + ((data float 3) + (x float :overlay-at (-> data 0)) + (y float :overlay-at (-> data 1)) + (z float :overlay-at (-> data 2)) + ) + :pack-me + ) + + +(defun vector-dot ((a vector) (b vector)) + "Take the dot product of two vectors. +Only does the x, y, z compoments. +Originally handwritten assembly to space out loads and use FPU accumulator" + (declare (inline)) + (let ((result 0.)) + (+! result (* (-> a x) (-> b x))) + (+! result (* (-> a y) (-> b y))) + (+! result (* (-> a z) (-> b z))) + result + ) + ) + +(defun vector-dot-vu ((arg0 vector) (arg1 vector)) + "Take the dot product (xyz only). Using VU0." + (local-vars (v0-0 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg0 quad)) + (.lvf vf2 (&-> arg1 quad)) + (.mul.vf vf1 vf1 vf2) + (.add.y.vf.x vf1 vf1 vf1) + (.add.z.vf.x vf1 vf1 vf1) + (.mov v0-0 vf1) + v0-0 + ) + ) + +(defun vector4-dot ((a vector) (b vector)) + "Take the dot product of two vectors. +Does the x, y, z, and w compoments" + (declare (inline)) + (let ((result 0.)) + (+! result (* (-> a x) (-> b x))) + (+! result (* (-> a y) (-> b y))) + (+! result (* (-> a z) (-> b z))) + (+! result (* (-> a w) (-> b w))) + result + ) + ) + +(defun vector4-dot-vu ((arg0 vector) (arg1 vector)) + "Take the dot product (xyzw). Using VU0." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.lvf vf2 (&-> arg1 quad)) + (.mul.vf vf1 vf1 vf2) + (.add.w.vf.x vf3 vf0 vf0) + (.mul.x.vf.x acc vf3 vf1) + (.add.mul.y.vf.x acc vf3 vf1 acc) + (.add.mul.z.vf.x acc vf3 vf1 acc) + (.add.mul.w.vf.x vf1 vf3 vf1 acc) + (.mov v0-0 vf1) + v0-0 + ) + ) + +(defun vector-xz-dot ((arg0 vector) (arg1 vector)) + "Take the dot product of two vectors. + Only does the x and z compoments. + Originally handwritten assembly to space out loads and use FPU accumulator" + (declare (inline)) + (let ((result 0.)) + (+! result (* (-> arg0 x) (-> arg1 x))) + (+! result (* (-> arg0 z) (-> arg1 z))) + result + ) + ) + +(defun vector+! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Set dst = a + b. The w component of dst is set to 0." + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (.lvf vf4 (&-> arg1 quad)) + (.lvf vf5 (&-> arg2 quad)) + (.mov.vf.w vf6 vf0) + (.add.vf.xyz vf6 vf4 vf5) + (.svf (&-> arg0 quad) vf6) + arg0 + ) + ) + +;; og:preserve-this +(defun vector-! ((dst vector) (a vector) (b vector)) + "Set dst = a - b. The w componenent of dst is set to 0." + (declare (inline)) + (rlet ((vf0 :class vf :reset-here #t) + (vf1 :class vf :reset-here #t) + (vf2 :class vf :reset-here #t) + (vf3 :class vf :reset-here #t)) + ;; load vectors + (.lvf vf2 a) + (.lvf vf3 b) + (init-vf0-vector) + ;; subtract + (.sub.vf vf1 vf2 vf3) + ;; set w = 1 + (.blend.vf.w vf1 vf1 vf0) + ;; store + (.svf dst vf1) + ) + dst + ) + +(defun vector-zero! ((arg0 vector)) + "Set xyzw to 0." + (set! (-> arg0 quad) (the-as uint128 0)) + arg0 + ) + +(defun vector-reset! ((arg0 vector)) + "Set vector to <0,0,0,1>." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (.svf (&-> arg0 quad) vf0) + arg0 + ) + ) + +(defun vector-copy! ((arg0 vector) (arg1 vector)) + "Copy arg1 to arg0." + (set! (-> arg0 quad) (-> arg1 quad)) + arg0 + ) + +(defun vector-xz-! ((arg0 vector) (arg1 vector) (arg2 vector)) + (rlet ((vf0 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + ) + (init-vf0-vector) + (.lvf vf11 (&-> arg1 quad)) + (.lvf vf12 (&-> arg2 quad)) + (.sub.vf.yw vf10 vf0 vf0) + (.sub.vf.xz vf10 vf11 vf12) + (.svf (&-> arg0 quad) vf10) + arg0 + ) + ) + +(defun vector-xz+! ((arg0 vector) (arg1 vector) (arg2 vector)) + (rlet ((vf0 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + ) + (init-vf0-vector) + (.lvf vf11 (&-> arg1 quad)) + (.lvf vf12 (&-> arg2 quad)) + (.sub.vf.yw vf10 vf0 vf0) + (.add.vf.xz vf10 vf11 vf12) + (.svf (&-> arg0 quad) vf10) + arg0 + ) + ) + +(defun vector-vector-project-compute-length! ((arg0 vector) (arg1 vector) (arg2 vector)) + (vector-float*! arg0 arg2 (/ (vector-dot arg1 arg2) (vector-length-squared arg2))) + ) + +(defun vector-vector-perpendicular! ((arg0 vector) (arg1 vector) (arg2 vector)) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (vector-float*! s2-0 arg2 (/ (vector-dot arg1 arg2) (vector-length-squared arg2))) + (vector-! arg0 arg1 s2-0) + ) + ) + +(defun vector-length< ((arg0 vector) (arg1 float)) + (< (vector-length-squared arg0) (square arg1)) + ) + +(defun vector-length> ((arg0 vector) (arg1 float)) + (< (square arg1) (vector-length-squared arg0)) + ) + +(define *zero-vector* (new 'static 'vector)) diff --git a/goal_src/jakx/engine/math/vector.gc b/goal_src/jakx/engine/math/vector.gc index c1f42a4915..0f96fb4f29 100644 --- a/goal_src/jakx/engine/math/vector.gc +++ b/goal_src/jakx/engine/math/vector.gc @@ -7,3 +7,1722 @@ ;; DECOMP BEGINS +(defun vector-cross! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Compute the cross product. The w component is set to junk." + (vector-cross! arg0 arg1 arg2) + ) + +(defun vector-xz-cross! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Compute the cross product of the xz components of inputs." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.add.x.vf.y vf1 vf0 vf0) + (.add.x.vf.y vf2 vf0 vf0) + (.outer.product.a.vf acc vf1 vf2) + (.outer.product.b.vf vf3 vf2 vf1 acc) + (.svf (&-> arg0 quad) vf3) + arg0 + ) + ) + +(defun vector+float! ((arg0 vector) (arg1 vector) (arg2 float)) + "Add float to each component of vector. The w component is set to 1" + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (.mov vf6 arg2) + (.lvf vf4 (&-> arg1 quad)) + (.add.x.vf.w vf5 vf0 vf0) + (.add.x.vf.xyz vf5 vf4 vf6) + (.svf (&-> arg0 quad) vf5) + arg0 + ) + ) + +;; og:preserve-this +(defun vector*! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Elementwise product. Set w = 1." + (declare (inline)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (.lvf vf4 (&-> arg1 quad)) + (.lvf vf5 (&-> arg2 quad)) + (.add.x.vf.w vf6 vf0 vf0) + (.mul.vf.xyz vf6 vf4 vf5) + (.svf (&-> arg0 quad) vf6) + arg0 + ) + ) + +(defun vector+*! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "set arg0 = arg1 + (arg3 * arg2). The w component will be set to 1." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (.mov vf7 arg3) + (.lvf vf5 (&-> arg2 quad)) + (.lvf vf4 (&-> arg1 quad)) + (.add.x.vf.w vf6 vf0 vf0) + (.mul.x.vf.xyz acc vf5 vf7) + (.add.mul.w.vf.xyz vf6 vf4 vf0 acc) + (.svf (&-> arg0 quad) vf6) + arg0 + ) + ) + +(defun vector-*! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Set arg0 = arg1 - (arg3 * arg2). The w component will be set to 1." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (.mov vf7 arg3) + (.lvf vf5 (&-> arg2 quad)) + (.lvf vf4 (&-> arg1 quad)) + (.add.x.vf.w vf6 vf0 vf0) + (.mul.w.vf.xyz acc vf4 vf0) + (.sub.mul.x.vf.xyz vf6 vf5 vf7 acc) + (.svf (&-> arg0 quad) vf6) + arg0 + ) + ) + +(defun vector/! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Set arg0 = arg1 / arg2. The w component will be set to 1. + The implementation is kind of crazy." + (rlet ((Q :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (.lvf vf5 (&-> arg2 quad)) + (.div.vf Q vf0 vf5 :fsf #b11 :ftf #b1) + (.add.x.vf.w vf6 vf0 vf0) + (.lvf vf4 (&-> arg1 quad)) + (let ((v1-0 (/ (-> arg1 x) (-> arg2 x)))) + (.wait.vf) + (.mul.vf.y vf6 vf4 Q) + (.nop.vf) + (.nop.vf) + (.div.vf Q vf0 vf5 :fsf #b11 :ftf #b10) + (.mov vf7 v1-0) + ) + (.add.x.vf.x vf6 vf0 vf7) + (.wait.vf) + (.mul.vf.z vf6 vf4 Q) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf6) + arg0 + ) + ) + +(defun vector-float*! ((arg0 vector) (arg1 vector) (arg2 float)) + "Multiply all values in a vector by arg2. Set w to 1." + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.mov vf2 arg2) + (.add.x.vf.w vf1 vf0 vf0) + (.mul.x.vf.xyz vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +(defun vector-average! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Set arg0 to the average of arg1 and arg2. Set w to 1." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 #x3f000000)) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.mov vf3 v1-0) + ) + (.add.x.vf.w vf4 vf0 vf0) + (.mul.x.vf acc vf1 vf3) + (.add.mul.x.vf.xyz vf4 vf2 vf3 acc) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +(defun vector+float*! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "arg0 = arg1 + arg2 * arg3." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg2 quad)) + (.lvf vf1 (&-> arg1 quad)) + (.mov vf3 arg3) + (.add.x.vf.w vf4 vf0 vf0) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf.xyz vf4 vf1 vf0 acc) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +(defun vector--float*! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Set arg0 = arg1 - (arg2 * arg3). The w component will be set to 1. + Is this different from vector-*!" + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg2 quad)) + (.lvf vf1 (&-> arg1 quad)) + (.mov vf3 arg3) + (.add.x.vf.w vf4 vf0 vf0) + (.mul.w.vf acc vf1 vf0) + (.sub.mul.x.vf.xyz vf4 vf2 vf3 acc) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +(defun vector-min! ((arg0 vector) (arg1 vector) (arg2 vector)) + (set! (-> arg0 x) (fmin (-> arg1 x) (-> arg2 x))) + (set! (-> arg0 y) (fmin (-> arg1 y) (-> arg2 y))) + (set! (-> arg0 z) (fmin (-> arg1 z) (-> arg2 z))) + (set! (-> arg0 w) 1.0) + arg0 + ) + +(defun vector-max! ((arg0 vector) (arg1 vector) (arg2 vector)) + (set! (-> arg0 x) (fmax (-> arg1 x) (-> arg2 x))) + (set! (-> arg0 y) (fmax (-> arg1 y) (-> arg2 y))) + (set! (-> arg0 z) (fmax (-> arg1 z) (-> arg2 z))) + (set! (-> arg0 w) 1.0) + arg0 + ) + +(defun vector-float/! ((arg0 vector) (arg1 vector) (arg2 float)) + "Divide all components by arg2. The w component will be set to 1." + (rlet ((Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.mov vf3 arg2) + (.div.vf Q vf0 vf3 :fsf #b11 :ftf #b0) + (.lvf vf1 (&-> arg1 quad)) + (.add.x.vf.w vf4 vf0 vf0) + (.wait.vf) + (.mul.vf.xyz vf4 vf1 Q) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +(defun vector-negate! ((arg0 vector) (arg1 vector)) + "Negate xyz, set w to 1." + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.sub.vf.xyz vf4 vf0 vf1) + (.add.x.vf.w vf4 vf0 vf0) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +(defun vector-negate-in-place! ((arg0 vector)) + "Negate xyz. Doesn't touch w." + (rlet ((vf0 :class vf) + (vf1 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.sub.vf.xyz vf1 vf0 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +(defun vector= ((arg0 vector) (arg1 vector)) + "Are the two vectors equal? Does not compare the w component. + The implementation is cool." + ;; (label L91) + ;; (set! v0-0 #t) + ;; (set! v1-0 #xffff) + (let* ((v1-0 #xffff) + ;; (set! a0-1 (l.q a0-0)) + (a0-1 (-> arg0 quad)) + ;; (set! v1-1 (sll v1-0 48)) + (v1-1 (shl v1-0 48)) + ;; (set! a1-1 (l.q a1-0)) + (a1-1 (-> arg1 quad)) + (a0-2 (the uint128 0)) + (r0 (the uint128 0)) + ) + ;; (.pceqw a0-2 a0-1 a1-1) + (.pceqw a0-2 a0-1 a1-1) + ;; (.ppach a0-3 r0-0 a0-2) + (.ppach a0-2 r0 a0-2) + ;; (set! v1-2 (logior a0-3 v1-1)) + (set! v1-1 (logior (the int a0-2) v1-1)) + ;; (set! v1-3 (+ v1-2 1)) + ;; will overflow the 64-bit integer if xyz is equal. + (set! v1-1 (+ v1-1 1)) + (zero? v1-1) + ) + ;; (b! (zero? v1-3) L92 (nop!)) + ;; (set! v0-0 #f) + ;; (label L92) + ;; (ret-value v0-0) + ) + +(defun vector-delta ((arg0 vector) (arg1 vector)) + "Sum of the elementwise absolute value of differences." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.lvf vf2 (&-> arg1 quad)) + (.sub.vf vf1 vf2 vf1) + (.abs.vf vf1 vf1) + (.mul.x.vf.w acc vf0 vf1) + (.add.mul.y.vf.w acc vf0 vf1 acc) + (.add.mul.z.vf.w vf3 vf0 vf1 acc) + (.add.w.vf.x vf3 vf0 vf3) + (.mov v0-0 vf3) + v0-0 + ) + ) + +(defun vector-seek! ((arg0 vector) (arg1 vector) (arg2 float)) + "Seek arg0 toward arg1. The arg0 is both read and written. + arg2 is saturated to (0, 1)" + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (.mov vf4 arg2) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg0 quad)) + (.add.x.vf.w vf1 vf0 vf0) + (.sub.x.vf.x vf5 vf0 vf4) + (.sub.vf.xyz vf3 vf1 vf2) + (.min.x.vf.xyz vf3 vf3 vf4) + (.max.x.vf.xyz vf3 vf3 vf5) + (.add.vf.xyz vf1 vf2 vf3) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +(defun vector-smooth-seek! ((arg0 vector) (arg1 vector) (arg2 float)) + "Smoothly seek vec toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a _square_ with side length arg2. + Note that this doesn't project to a circle like the function below..." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (vector-! v1-0 arg1 arg0) + (let ((v0-0 arg0)) + (let ((a1-2 (fmin 1.0 arg2))) + (.mov vf7 a1-2) + ) + (.lvf vf5 (&-> v1-0 quad)) + (.lvf vf4 (&-> arg0 quad)) + (.add.x.vf.w vf6 vf0 vf0) + (.mul.x.vf.xyz acc vf5 vf7) + (.add.mul.w.vf.xyz vf6 vf4 vf0 acc) + (.svf (&-> v0-0 quad) vf6) + v0-0 + ) + ) + ) + ) + +(defun vector-seek-2d-xz-smooth! ((arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + "Smoothly seek vec's x and z components toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a circle of radius max-step. + Doesn't touch y or w." + (let ((f0-1 (- (-> arg1 x) (-> arg0 x))) + (f2-1 (- (-> arg1 z) (-> arg0 z))) + ) + (when (or (!= f0-1 0.0) (!= f2-1 0.0)) + (let* ((f1-5 (* f0-1 arg3)) + (f0-3 (* f2-1 arg3)) + (f2-4 (sqrtf (+ (square f1-5) (square f0-3)))) + ) + (cond + ((>= arg2 f2-4) + (+! (-> arg0 x) f1-5) + (+! (-> arg0 z) f0-3) + ) + (else + (let ((f2-6 (/ arg2 f2-4))) + (+! (-> arg0 x) (* f2-6 f1-5)) + (+! (-> arg0 z) (* f2-6 f0-3)) + ) + ) + ) + ) + ) + ) + arg0 + ) + +(defun vector-seek-2d-yz-smooth! ((arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + "Smoothly seek vec's y and z components toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a circle of radius max-step. + Doesn't touch x or w." + (let ((f0-1 (- (-> arg1 y) (-> arg0 y))) + (f2-1 (- (-> arg1 z) (-> arg0 z))) + ) + (when (or (!= f0-1 0.0) (!= f2-1 0.0)) + (let* ((f1-5 (* f0-1 arg3)) + (f0-3 (* f2-1 arg3)) + (f2-4 (sqrtf (+ (square f1-5) (square f0-3)))) + ) + (cond + ((>= arg2 f2-4) + (+! (-> arg0 y) f1-5) + (+! (-> arg0 z) f0-3) + ) + (else + (let ((f2-6 (/ arg2 f2-4))) + (+! (-> arg0 y) (* f2-6 f1-5)) + (+! (-> arg0 z) (* f2-6 f0-3)) + ) + ) + ) + ) + ) + ) + arg0 + ) + +(defun vector-seek-3d-smooth! ((arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + "Smoothly seek vec's x, y, and z components toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a circle of radius max-step. + Doesn't touch w." + (let ((f0-1 (- (-> arg1 x) (-> arg0 x))) + (f1-2 (- (-> arg1 y) (-> arg0 y))) + (f3-1 (- (-> arg1 z) (-> arg0 z))) + ) + (when (or (!= f0-1 0.0) (!= f1-2 0.0) (!= f3-1 0.0)) + (let* ((f2-6 (* f0-1 arg3)) + (f1-3 (* f1-2 arg3)) + (f0-4 (* f3-1 arg3)) + (f3-5 (sqrtf (+ (square f2-6) (square f1-3) (square f0-4)))) + ) + (cond + ((>= arg2 f3-5) + (+! (-> arg0 x) f2-6) + (+! (-> arg0 y) f1-3) + (+! (-> arg0 z) f0-4) + ) + (else + (let ((f3-7 (/ arg2 f3-5))) + (+! (-> arg0 x) (* f3-7 f2-6)) + (+! (-> arg0 y) (* f3-7 f1-3)) + (+! (-> arg0 z) (* f3-7 f0-4)) + ) + ) + ) + ) + ) + ) + arg0 + ) + +(defun seek-with-smooth ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Move value closer to target. + If we are within deadband, just go straight to target. + If not, try to go alpha*err. If that is a larger step than max-step, limit to max-step" + (let ((f0-1 (- arg1 arg0))) + (cond + ((>= arg4 (fabs f0-1)) + arg1 + ) + (else + (let ((f0-2 (* f0-1 arg3))) + (let ((f1-4 (- arg2))) + (cond + ((< f0-2 f1-4) + (set! f0-2 f1-4) + ) + ((< arg2 f0-2) + (set! f0-2 arg2) + ) + ) + ) + (+ f0-2 arg0) + ) + ) + ) + ) + ) + +(defun vector-identity! ((arg0 vector)) + "Set arg0 to 1, 1, 1, 1." + (set! (-> arg0 x) 1.0) + (set! (-> arg0 y) 1.0) + (set! (-> arg0 z) 1.0) + (set! (-> arg0 w) 1.0) + arg0 + ) + +(defun vector-seconds ((arg0 vector) (arg1 vector)) + "Convert from actual seconds to the seconds unit." + (set! (-> arg0 x) (* 300.0 (-> arg1 x))) + (set! (-> arg0 y) (* 300.0 (-> arg1 y))) + (set! (-> arg0 z) (* 300.0 (-> arg1 z))) + arg0 + ) + +(defun vector-seconds! ((arg0 vector)) + "Convert from actual seconds to seconds, in place." + (set! (-> arg0 x) (* 300.0 (-> arg0 x))) + (set! (-> arg0 y) (* 300.0 (-> arg0 y))) + (set! (-> arg0 z) (* 300.0 (-> arg0 z))) + arg0 + ) + +(defun vector-v! ((arg0 vector)) + "Convert a velocity to a displacement per frame. The velocity should be in X/actual_second. + Uses the current process clock." + (vector-float*! arg0 arg0 (seconds-per-frame)) + arg0 + ) + +(defun vector-v+! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Euler forward step, using the current display time settings." + (vector+float*! arg0 arg1 arg2 (seconds-per-frame)) + arg0 + ) + +(defun vector-v*float+! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Euler forward step, scaling velocity by velocity-scale." + (vector+float*! arg0 arg1 arg2 (* arg3 (seconds-per-frame))) + arg0 + ) + +(defun vector-v++! ((arg0 vector) (arg1 vector)) + "Update position in place, using display's current timing." + (vector+float*! arg0 arg0 arg1 (seconds-per-frame)) + arg0 + ) + +(defun vector-v*float! ((arg0 vector) (arg1 vector) (arg2 float)) + "Go from velocity to delta-p per frame, scaling by scale." + (vector-float*! arg0 arg1 (* arg2 (seconds-per-frame))) + ) + +(defun vector-v*float++! ((arg0 vector) (arg1 vector) (arg2 float)) + "Update position with given velocity, scaled by scale." + (vector+float*! arg0 arg0 arg1 (* arg2 (seconds-per-frame))) + arg0 + ) + +(defun vector-to-ups! ((arg0 vector) (arg1 vector)) + "Go from units per frame to units per second?" + (local-vars (at-0 int)) + (with-pp + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (let ((f0-0 (-> pp clock frames-per-second))) + (.mov at-0 f0-0) + ) + (.mov vf2 at-0) + (.mov.vf.w vf1 vf0) + (.mul.x.vf.xyz vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + ) + +(defun vector-from-ups! ((arg0 vector) (arg1 vector)) + "Go from units per second to units per frame?" + (local-vars (at-0 int)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (let ((f0-0 (seconds-per-frame))) + (.mov at-0 f0-0) + ) + (.mov vf2 at-0) + (.mov.vf.w vf1 vf0) + (.mul.x.vf.xyz vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +(defun vector-length ((arg0 vector)) + "Get the length of the xyz part." + (vector-length arg0) + ) + +(defun vector-length-squared ((arg0 vector)) + "Get the squared length of the xyz part." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.add.w.vf.x vf2 vf0 vf0) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf.x acc vf2 vf1) + (.add.mul.y.vf.x acc vf2 vf1 acc) + (.add.mul.z.vf.x vf1 vf2 vf1 acc) + (.mov v0-0 vf1) + v0-0 + ) + ) + +(defun vector-xz-length-squared ((arg0 vector)) + "Get the length of the xz part, squared." + (+ (* (-> arg0 x) (-> arg0 x)) (* (-> arg0 z) (-> arg0 z))) + ) + +(defun vector-xz-length ((arg0 vector)) + "Get the length of the xz part." + (sqrtf (+ (* (-> arg0 x) (-> arg0 x)) (* (-> arg0 z) (-> arg0 z)))) + ) + +(defun vector-vector-distance ((arg0 vector) (arg1 vector)) + "Subtract the xyz parts and get the norm." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg0 quad)) + (.lvf vf3 (&-> arg1 quad)) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf.w acc vf0 vf1) + (.add.mul.y.vf.w acc vf0 vf1 acc) + (.add.mul.z.vf.w vf1 vf0 vf1 acc) + (.sqrt.vf Q vf1 :ftf #b11) + (.add.w.vf.x vf1 vf0 vf0) + (.wait.vf) + (.mul.vf.x vf1 vf1 Q) + (.nop.vf) + (.nop.vf) + (.mov v0-0 vf1) + v0-0 + ) + ) + +(defun vector-vector-distance-squared ((arg0 vector) (arg1 vector)) + "Squared norm of the difference of the xyz parts." + (local-vars (v0-0 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (.lvf vf2 (&-> arg0 quad)) + (.lvf vf3 (&-> arg1 quad)) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.y.vf.x vf1 vf1 vf1) + (.add.z.vf.x vf1 vf1 vf1) + (.mov v0-0 vf1) + v0-0 + ) + ) + +(defun vector-vector-xz-distance ((arg0 vector) (arg1 vector)) + "Distance on the xz plane." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg0 quad)) + (.lvf vf3 (&-> arg1 quad)) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf.w acc vf0 vf1) + (.add.mul.z.vf.w vf1 vf0 vf1 acc) + (.sqrt.vf Q vf1 :ftf #b11) + (.add.w.vf.x vf1 vf0 vf0) + (.wait.vf) + (.mul.vf.x vf1 vf1 Q) + (.nop.vf) + (.nop.vf) + (.mov v0-0 vf1) + v0-0 + ) + ) + +(defun vector-vector-xy-distance ((arg0 vector) (arg1 vector)) + "distance on the xy plane." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg0 quad)) + (.lvf vf3 (&-> arg1 quad)) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf.w acc vf0 vf1) + (.add.mul.y.vf.w vf1 vf0 vf1 acc) + (.sqrt.vf Q vf1 :ftf #b11) + (.add.w.vf.x vf1 vf0 vf0) + (.wait.vf) + (.mul.vf.x vf1 vf1 Q) + (.nop.vf) + (.nop.vf) + (.mov v0-0 vf1) + v0-0 + ) + ) + +(defun vector-vector-xz-distance-squared ((arg0 vector) (arg1 vector)) + "Distance on the xz plane squared." + (local-vars (v0-0 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (.lvf vf2 (&-> arg0 quad)) + (.lvf vf3 (&-> arg1 quad)) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.z.vf.x vf1 vf1 vf1) + (.mov v0-0 vf1) + v0-0 + ) + ) + +(defun vector-vector-planar-distance ((arg0 vector) (arg1 vector) (arg2 vector)) + (vector-vector-distance + (vector-flatten! (new 'stack-no-clear 'vector) arg0 arg2) + (vector-flatten! (new 'stack-no-clear 'vector) arg1 arg2) + ) + ) + +(defun vector-normalize! ((arg0 vector) (arg1 float)) + "Modify arg0 in place to have length arg1 for its xyz components. The w part is not changed." + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.mul.vf.xyz vf2 vf1 vf1) + (let ((v1-0 arg1)) + (.mov vf3 v1-0) + ) + (.mul.x.vf.w acc vf0 vf2) + (.add.mul.y.vf.w acc vf0 vf2 acc) + (.add.mul.z.vf.w vf2 vf0 vf2 acc) + (.isqrt.vf Q vf3 vf2 :fsf #b0 :ftf #b11) + (.wait.vf) + (.mul.vf.xyz vf1 vf1 Q) + (.nop.vf) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +(defun vector-normalize-ret-len! ((arg0 vector) (arg1 float)) + "Modify arg0 in place to have length arg1 for its xyz components. + The w part isn't changed and the _original_ length is returned." + (local-vars (v1-1 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.mul.vf.xyz vf2 vf1 vf1) + (let ((v1-0 arg1)) + (.mov vf3 v1-0) + ) + (.mul.x.vf.w acc vf0 vf2) + (.add.mul.y.vf.w acc vf0 vf2 acc) + (.add.mul.z.vf.w vf2 vf0 vf2 acc) + (.isqrt.vf Q vf3 vf2 :fsf #b0 :ftf #b11) + (.add.w.vf.x vf2 vf0 vf2) + (.mov v1-1 vf2) + (let ((v0-0 (sqrtf v1-1))) + (.wait.vf) + (.mul.vf.xyz vf1 vf1 Q) + (.nop.vf) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf1) + v0-0 + ) + ) + ) + +(defun vector-normalize-copy! ((arg0 vector) (arg1 vector) (arg2 float)) + "Normalize, but not in place. + This implementation is very good compared to the vector-normalize! one. + The w component is set to 1." + (let ((f0-0 (vector-length arg1))) + (cond + ((= f0-0 0.0) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + (else + (let ((v1-3 (/ arg2 f0-0))) + (set! (-> arg0 x) (* (-> arg1 x) v1-3)) + (set! (-> arg0 y) (* (-> arg1 y) v1-3)) + (set! (-> arg0 z) (* (-> arg1 z) v1-3)) + ) + ) + ) + ) + (set! (-> arg0 w) 1.0) + arg0 + ) + +(defun vector-xz-normalize! ((arg0 vector) (arg1 float)) + "Normalize, xz components only." + (let* ((v1-0 arg0) + (f0-4 (sqrtf (+ (* (-> v1-0 x) (-> v1-0 x)) (* (-> v1-0 z) (-> v1-0 z))))) + ) + (when (!= f0-4 0.0) + (let ((v1-3 (/ arg1 f0-4))) + (set! (-> arg0 x) (* (-> arg0 x) v1-3)) + (set! (-> arg0 z) (* (-> arg0 z) v1-3)) + ) + ) + ) + arg0 + ) + +(defun vector-xz-normalize-copy! ((arg0 vector) (arg1 vector) (arg2 float)) + "Normalize, xz components only." + (let* ((v1-0 arg1) + (f0-4 (sqrtf (+ (* (-> v1-0 x) (-> v1-0 x)) (* (-> v1-0 z) (-> v1-0 z))))) + ) + (cond + ((= f0-4 0.0) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + (else + (let ((v1-3 (/ arg2 f0-4))) + (set! (-> arg0 x) (* (-> arg1 x) v1-3)) + (set! (-> arg0 y) 0.0) + (set! (-> arg0 z) (* (-> arg1 z) v1-3)) + ) + ) + ) + ) + (set! (-> arg0 w) 1.0) + arg0 + ) + +(defun vector-length-max! ((arg0 vector) (arg1 float)) + "Make vector at most arg1 length (xyz only). + If it is larger, project onto sphere. + Doesn't touch w" + (let ((f0-0 (vector-length arg0))) + (when (not (or (= f0-0 0.0) (< f0-0 arg1))) + (let ((f0-1 (/ arg1 f0-0))) + (set! (-> arg0 x) (* (-> arg0 x) f0-1)) + (set! (-> arg0 y) (* (-> arg0 y) f0-1)) + (set! (-> arg0 z) (* (-> arg0 z) f0-1)) + ) + ) + ) + arg0 + ) + +(defun vector-xz-length-max! ((arg0 vector) (arg1 float)) + "Make vector at most arg1 length (xz only). + It it is larger, project onto circle. + Doesn't touch w or y." + (let* ((v1-0 arg0) + (f0-4 (sqrtf (+ (* (-> v1-0 x) (-> v1-0 x)) (* (-> v1-0 z) (-> v1-0 z))))) + ) + (when (not (or (= f0-4 0.0) (< f0-4 arg1))) + (let ((f0-5 (/ arg1 f0-4))) + (set! (-> arg0 x) (* (-> arg0 x) f0-5)) + (set! (-> arg0 z) (* (-> arg0 z) f0-5)) + ) + ) + ) + arg0 + ) + +(defun vector-rotate-around-x! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate a vector around the x axis." + (let* ((f28-0 (- arg2)) + (f30-0 (cos f28-0)) + (f1-0 (sin f28-0)) + (f2-0 (-> arg1 z)) + (f0-1 (-> arg1 y)) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 z) (- (* f2-0 f30-0) (* f0-1 f1-0))) + (set! (-> arg0 y) (+ (* f2-0 f1-0) (* f0-1 f30-0))) + ) + arg0 + ) + +(defun vector-rotate-around-y! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate a vector around the y axis." + (let ((f26-0 (-> arg1 z)) + (f30-0 (-> arg1 x)) + (f28-0 (cos arg2)) + (f0-0 (sin arg2)) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 z) (- (* f26-0 f28-0) (* f30-0 f0-0))) + (set! (-> arg0 x) (+ (* f26-0 f0-0) (* f30-0 f28-0))) + ) + arg0 + ) + +(defun vector-rotate90-around-y! ((arg0 vector) (arg1 vector)) + "Rotate a vector 90 degrees around y." + (set! (-> arg0 quad) (-> arg1 quad)) + (let ((f0-0 (-> arg0 x))) + (set! (-> arg0 x) (- (-> arg1 z))) + (set! (-> arg0 z) f0-0) + ) + arg0 + ) + +(defun vector-rotate-around-z! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate a vector around the z axis." + (let ((f26-0 (-> arg1 x)) + (f30-0 (-> arg1 y)) + (f28-0 (cos arg2)) + (f0-0 (sin arg2)) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 x) (- (* f26-0 f28-0) (* f30-0 f0-0))) + (set! (-> arg0 y) (+ (* f26-0 f0-0) (* f30-0 f28-0))) + ) + arg0 + ) + +(defun rotate-y<-vector+vector ((arg0 vector) (arg1 vector)) + "Get the y rotation between vectors. These should have the same length." + (atan (- (-> arg1 x) (-> arg0 x)) (- (-> arg1 z) (-> arg0 z))) + ) + +(defun rotate-x<-vector+vector ((arg0 vector) (arg1 vector)) + "Get the x rotation between vectors. These should have the same length." + (atan (- (-> arg1 y) (-> arg0 y)) (- (-> arg1 z) (-> arg0 z))) + ) + +(defun rotate-z<-vector+vector ((arg0 vector) (arg1 vector)) + "Get the z rotation between vectors. These should have the same length." + (atan (- (-> arg1 x) (-> arg0 x)) (- (-> arg1 y) (-> arg0 y))) + ) + +(defun rotate-vector-to-vector ((arg0 vector) (arg1 vector) (arg2 vector)) + (let ((gp-0 (new 'stack-no-clear 'quaternion))) + (quaternion-from-two-vectors-max-angle! (the-as quaternion (&-> gp-0 x)) arg0 arg1 (the-as float arg2)) + (vector-orient-by-quat! arg0 arg0 (the-as quaternion (&-> gp-0 x))) + ) + (vector-normalize! arg0 1.0) + ) + +(defun vector-cvt.w.s! ((arg0 vector) (arg1 vector)) + "Convert float to int32. Truncate." + (rlet ((vf1 :class vf)) + (.lvf vf1 (&-> arg1 quad)) + (.ftoi.vf vf1 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +(defun vector-cvt.s.w! ((arg0 vector) (arg1 vector)) + "Convert float to int32." + (rlet ((vf1 :class vf)) + (.lvf vf1 (&-> arg1 quad)) + (.itof.vf vf1 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +(defun rot-zxy-from-vector! ((arg0 vector) (arg1 vector)) + "I think this gives you a vector of euler angles to rotate some unit vector + to arg1." + (let* ((f28-0 (-> arg1 z)) + (f30-0 (-> arg1 x)) + (f0-0 (atan f30-0 f28-0)) + ) + (set! (-> arg0 y) f0-0) + (let* ((f26-0 (- f0-0)) + (f0-4 (- (* f28-0 (cos f26-0)) (* f30-0 (sin f26-0)))) + ) + (set! (-> arg0 x) (atan (- (-> arg1 y)) f0-4)) + ) + ) + (set! (-> arg0 z) 0.0) + arg0 + ) + +(defun rot-zyx-from-vector! ((arg0 vector) (arg1 vector)) + "I think this gives you a vector of euler angles to rotate some unit vector + to arg1." + (let* ((f28-0 (-> arg1 z)) + (f30-0 (- (-> arg1 y))) + (f0-1 (atan f30-0 f28-0)) + ) + (set! (-> arg0 x) f0-1) + (let* ((f26-0 (- f0-1)) + (f0-5 (- (* f28-0 (cos f26-0)) (* f30-0 (sin f26-0)))) + ) + (set! (-> arg0 y) (atan (-> arg1 x) f0-5)) + ) + ) + (set! (-> arg0 z) 0.0) + arg0 + ) + +(defun vector-world-to-local! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 quaternion)) + (vector-! arg0 arg1 arg2) + (vector-inv-orient-by-quat! arg0 arg0 arg3) + ) + +(defun vector-local-to-world! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 quaternion)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (vector-orient-by-quat! arg0 arg1 arg3) + (let ((v0-1 arg0)) + (.lvf vf4 (&-> arg0 quad)) + (.lvf vf5 (&-> arg2 quad)) + (.mov.vf.w vf6 vf0) + (.add.vf.xyz vf6 vf4 vf5) + (.svf (&-> v0-1 quad) vf6) + v0-1 + ) + ) + ) + +(defun vector-lerp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Linearly interpolate between two vectors. Alpha isn't clamped. + w will be set to 1." + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.mov vf4 arg3) + (.add.x.vf.w vf3 vf0 vf0) + (.sub.vf vf2 vf2 vf1) + (.mul.x.vf vf2 vf2 vf4) + (.add.vf.xyz vf3 vf1 vf2) + (.svf (&-> arg0 quad) vf3) + arg0 + ) + ) + +(defun vector-lerp-clamp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Linearly interpolate between two vectors, clamping alpha to 0, 1. + w will be set to 1." + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (cond + ((>= 0.0 arg3) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + ((>= arg3 1.0) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + (else + (let ((v1-3 arg0)) + (let ((f0-2 arg3)) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (let ((a1-1 f0-2)) + (.mov vf4 a1-1) + ) + ) + (.add.x.vf.w vf3 vf0 vf0) + (.sub.vf vf2 vf2 vf1) + (.mul.x.vf vf2 vf2 vf4) + (.add.vf.xyz vf3 vf1 vf2) + (.svf (&-> v1-3 quad) vf3) + ) + ) + ) + arg0 + ) + ) + +(defun vector4-lerp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Interpolate all 4 elements of a vector. Alpha is not clamped." + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.mov vf4 arg3) + (.sub.vf vf2 vf2 vf1) + (.mul.x.vf vf2 vf2 vf4) + (.add.vf vf3 vf1 vf2) + (.svf (&-> arg0 quad) vf3) + arg0 + ) + ) + +(defun vector4-lerp-clamp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Interpolate all 4 elements of a vector. Alpha is clamped to [0, 1]." + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (cond + ((>= 0.0 arg3) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + ((>= arg3 1.0) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + (else + (let ((v1-3 arg0)) + (let ((f0-2 arg3)) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (let ((a1-1 f0-2)) + (.mov vf4 a1-1) + ) + ) + (.sub.vf vf2 vf2 vf1) + (.mul.x.vf vf2 vf2 vf4) + (.add.vf vf3 vf1 vf2) + (.svf (&-> v1-3 quad) vf3) + ) + ) + ) + arg0 + ) + ) + +(defun vector4w-lerp! ((arg0 vector4w) (arg1 vector4w) (arg2 vector4w) (arg3 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.itof.vf vf1 vf1) + (.itof.vf vf2 vf2) + (.mov vf3 arg3) + (.sub.vf vf4 vf2 vf1) + (.mul.w.vf acc vf1 vf0) + (.add.mul.x.vf vf5 vf4 vf3 acc) + (.ftoi.vf vf5 vf5) + (.svf (&-> arg0 quad) vf5) + arg0 + ) + ) + +(defun vector-degi ((arg0 vector) (arg1 vector)) + "Convert a vector (in _rotations_) to degrees units, stored in an int. + Truncates to the nearest _rotation_. + Neither the input or output is a commonly used form. + Unsurprisingly, this strange function is never used." + (local-vars (v1-0 uint128) (v1-1 uint128)) + (rlet ((vf1 :class vf)) + (.lvf vf1 (&-> arg1 quad)) + (.ftoi.vf vf1 vf1) + (.mov v1-0 vf1) + (.pw.sll v1-1 v1-0 16) + (set! (-> arg0 quad) v1-1) + arg0 + ) + ) + +(defun vector-degf ((arg0 vector) (arg1 vector)) + "Convert a vector (in integer degree units) to floating point rotations. + Truncates to the nearest _rotation_. + Like the previous function, this is stupid and unused." + (local-vars (v1-1 uint128)) + (rlet ((vf1 :class vf)) + (let ((v1-0 (-> arg1 quad))) + (.pw.sra v1-1 v1-0 16) + ) + (.mov vf1 v1-1) + (.itof.vf vf1 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +(defun vector-degmod ((arg0 vector) (arg1 vector)) + "This one is actually right. Wraps degrees units (in floats, like they should be) + to +/- half a rotation." + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) + (rlet ((vf1 :class vf)) + (.lvf vf1 (&-> arg1 quad)) + (.ftoi.vf vf1 vf1) + (.mov v1-0 vf1) + (.pw.sll v1-1 v1-0 16) + (.pw.sra v1-2 v1-1 16) + (.mov vf1 v1-2) + (.itof.vf vf1 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; WARN: Return type mismatch float vs none. +(defun vector-deg-diff ((arg0 vector) (arg1 vector) (arg2 vector)) + "Wrapped difference, degrees units. Will have the usual 16-bit accuracy issue." + (local-vars + (v0-0 float) + (v1-0 uint128) + (v1-1 uint128) + (v1-2 uint128) + (v1-3 uint128) + (a1-1 uint128) + (a1-2 uint128) + ) + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.ftoi.vf vf1 vf1) + (.ftoi.vf vf2 vf2) + (.mov a1-1 vf1) + (.mov v1-0 vf2) + (.pw.sll a1-2 a1-1 16) + (.pw.sll v1-1 v1-0 16) + (.psubw v1-2 a1-2 v1-1) + (.pw.sra v1-3 v1-2 16) + (.mov vf1 v1-3) + (.itof.vf vf1 vf1) + (.svf (&-> arg0 quad) vf1) + (.mov v0-0 vf1) + (none) + ) + ) + +(defun vector-deg-lerp-clamp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Apply deg-lerp-clamp to the xyz components of a vector. Sets w = 1." + (cond + ((>= 0.0 arg3) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + ((>= arg3 1.0) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + (else + (set! (-> arg0 x) (deg-lerp-clamp (-> arg1 x) (-> arg2 x) arg3)) + (set! (-> arg0 y) (deg-lerp-clamp (-> arg1 y) (-> arg2 y) arg3)) + (set! (-> arg0 z) (deg-lerp-clamp (-> arg1 z) (-> arg2 z) arg3)) + (set! (-> arg0 w) 1.0) + ) + ) + arg0 + ) + +(defun vector3s-copy! ((arg0 vector) (arg1 vector)) + "Copy a vector3s" + (set! (-> arg0 x) (-> arg1 x)) + (set! (-> arg0 y) (-> arg1 y)) + (set! (-> arg0 z) (-> arg1 z)) + arg0 + ) + +(defun vector3s+! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Add 2 vectors3." + (set! (-> arg0 x) (+ (-> arg1 x) (-> arg2 x))) + (set! (-> arg0 y) (+ (-> arg1 y) (-> arg2 y))) + (set! (-> arg0 z) (+ (-> arg1 z) (-> arg2 z))) + arg0 + ) + +(defun vector3s*float! ((arg0 vector) (arg1 vector) (arg2 float)) + "mult vectors3 by float" + (set! (-> arg0 x) (* (-> arg1 x) arg2)) + (set! (-> arg0 y) (* (-> arg1 y) arg2)) + (set! (-> arg0 z) (* (-> arg1 z) arg2)) + arg0 + ) + +(defun vector3s-! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Subtract 2 vectors3: c = (a - b)." + (set! (-> arg0 x) (- (-> arg1 x) (-> arg2 x))) + (set! (-> arg0 y) (- (-> arg1 y) (-> arg2 y))) + (set! (-> arg0 z) (- (-> arg1 z) (-> arg2 z))) + arg0 + ) + +;; WARN: Return type mismatch float vs none. +(defun vector4-add! ((arg0 vector4) (arg1 vector4) (arg2 vector4)) + "Add 2 vector4s." + (local-vars (v0-0 float)) + (rlet ((vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (.lvf vf5 (&-> arg1 quad)) + (.lvf vf6 (&-> arg2 quad)) + (.add.vf vf4 vf5 vf6) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; WARN: Return type mismatch float vs none. +(defun vector4-sub! ((arg0 vector4) (arg1 vector4) (arg2 vector4)) + "Subtract 2 vector4s." + (local-vars (v0-0 float)) + (rlet ((vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (.lvf vf5 (&-> arg1 quad)) + (.lvf vf6 (&-> arg2 quad)) + (.sub.vf vf4 vf5 vf6) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; WARN: Return type mismatch float vs none. +(defun vector4-mul! ((arg0 vector4) (arg1 vector4) (arg2 vector4)) + "Multiple 2 vector4s." + (local-vars (v0-0 float)) + (rlet ((vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (.lvf vf5 (&-> arg1 quad)) + (.lvf vf6 (&-> arg2 quad)) + (.mul.vf vf4 vf5 vf6) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; WARN: Return type mismatch float vs none. +(defun vector4-scale! ((arg0 vector4) (arg1 vector4) (arg2 float)) + "arg0 = arg1 * arg2." + (local-vars (v0-0 float)) + (rlet ((vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (.mov vf6 arg2) + (.lvf vf5 (&-> arg1 quad)) + (.mul.x.vf vf4 vf5 vf6) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; WARN: Return type mismatch float vs none. +(defun vector4-madd! ((arg0 vector4) (arg1 vector4) (arg2 vector4) (arg3 float)) + "arg0 = arg1 + arg2 * arg3." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (.mov vf7 arg3) + (.lvf vf5 (&-> arg1 quad)) + (.lvf vf6 (&-> arg2 quad)) + (.mul.w.vf acc vf5 vf0) + (.add.mul.x.vf vf4 vf6 vf7 acc) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; WARN: Return type mismatch float vs none. +(defun vector4-msub! ((arg0 vector4) (arg1 vector4) (arg2 vector4) (arg3 float)) + "arg0 = arg1 - arg2 * arg3." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (.mov vf7 arg3) + (.lvf vf5 (&-> arg1 quad)) + (.lvf vf6 (&-> arg2 quad)) + (.mul.w.vf acc vf5 vf0) + (.sub.mul.x.vf vf4 vf6 vf7 acc) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-add! ((arg0 (inline-array vector4)) (arg1 (inline-array vector4)) (arg2 (inline-array vector4)) (arg3 int)) + "Apply vector4-add! to all arrays." + (dotimes (s2-0 arg3) + (vector4-add! (the-as vector4 arg0) (the-as vector4 arg1) (the-as vector4 arg2)) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-sub! ((arg0 (inline-array vector4)) (arg1 (inline-array vector4)) (arg2 (inline-array vector4)) (arg3 int)) + "Apply vector4-sub! to all arrays." + (dotimes (s2-0 arg3) + (vector4-sub! (the-as vector4 arg0) (the-as vector4 arg1) (the-as vector4 arg2)) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-mul! ((arg0 (inline-array vector4)) (arg1 (inline-array vector4)) (arg2 (inline-array vector4)) (arg3 int)) + "Apply vector4-mul! to all arrays." + (dotimes (s2-0 arg3) + (vector4-mul! (the-as vector4 arg0) (the-as vector4 arg1) (the-as vector4 arg2)) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-scale! ((arg0 (inline-array vector4)) (arg1 (inline-array vector4)) (arg2 float) (arg3 int)) + "Apply vector4-scale! to all arrays." + (dotimes (s2-0 arg3) + (vector4-scale! (the-as vector4 arg0) (the-as vector4 arg1) arg2) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-madd! ((arg0 (inline-array vector4)) + (arg1 (inline-array vector4)) + (arg2 (inline-array vector4)) + (arg3 float) + (arg4 int) + ) + "Apply vector4-madd! to all arrays." + (dotimes (s1-0 arg4) + (vector4-madd! (the-as vector4 arg0) (the-as vector4 arg1) (the-as vector4 arg2) arg3) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-msub! ((arg0 (inline-array vector4)) + (arg1 (inline-array vector4)) + (arg2 (inline-array vector4)) + (arg3 float) + (arg4 int) + ) + "Apply vector4-msub! to all arrays." + (dotimes (s1-0 arg4) + (vector4-msub! (the-as vector4 arg0) (the-as vector4 arg1) (the-as vector4 arg2) arg3) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +(defun vector4-array-lerp! ((arg0 (inline-array vector4)) + (arg1 (inline-array vector4)) + (arg2 (inline-array vector4)) + (arg3 float) + (arg4 int) + ) + "Apply vector4-lerp! to all arrays." + (dotimes (s1-0 arg4) + (vector4-lerp! (the-as vector arg0) (the-as vector arg1) (the-as vector arg2) arg3) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + #f + ) + +(defun spheres-overlap? ((arg0 sphere) (arg1 sphere)) + "Do the spheres overlap?" + (local-vars (v1-0 float) (a0-1 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.lvf vf2 (&-> arg1 quad)) + (.sub.vf.xyz vf3 vf1 vf2) + (.mul.vf.xyz vf3 vf3 vf3) + (.add.w.vf.w vf4 vf1 vf2) + (.mul.w.vf.w vf4 vf4 vf4) + (.add.y.vf.x vf3 vf3 vf3) + (.add.z.vf.x vf3 vf3 vf3) + (.add.w.vf.x vf4 vf0 vf4) + (.mov a0-1 vf4) + (.mov v1-0 vf3) + (>= a0-1 v1-0) + ) + ) + +(defun sphere<-vector! ((arg0 sphere) (arg1 vector)) + "Set the position of the sphere to arg1. Does not change the radius." + (let ((f0-0 (-> arg0 r))) + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 r) f0-0) + ) + arg0 + ) + +(defun sphere<-vector+r! ((arg0 sphere) (arg1 vector) (arg2 float)) + "Set the position of the sphere from arg1 and the radius from arg2." + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 r) arg2) + arg0 + ) + +(defun rand-vu-sphere-point! ((arg0 vector) (arg1 float)) + "Get a random point on the sphere at the origin with radius arg1. + The point is on the surface of the sphere." + (set-vector! + arg0 + (rand-vu-float-range -1.0 1.0) + (rand-vu-float-range -1.0 1.0) + (rand-vu-float-range -1.0 1.0) + 1.0 + ) + (vector-normalize! arg0 (rand-vu-float-range 0.0 arg1)) + ) + +(defun rand-vu-sphere-point-uniform! ((arg0 vector) (arg1 float)) + (local-vars (v1-3 float) (f0-5 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + 666.6 + (until (>= 1.0 f0-5) + (set-vector! + arg0 + (rand-vu-float-range -1.0 1.0) + (rand-vu-float-range -1.0 1.0) + (rand-vu-float-range -1.0 1.0) + 1.0 + ) + (.lvf vf1 (&-> arg0 quad)) + (.add.w.vf.x vf2 vf0 vf0) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf.x acc vf2 vf1) + (.add.mul.y.vf.x acc vf2 vf1 acc) + (.add.mul.z.vf.x vf1 vf2 vf1 acc) + (.mov v1-3 vf1) + (set! f0-5 v1-3) + ) + (vector-float*! arg0 arg0 arg1) + ) + ) + +(defmethod print ((this vector2)) + (format #t "#" (-> this x) (-> this y) this) + this + ) + +(defun vector-vector-angle-safe ((arg0 vector) (arg1 vector)) + "Get the angle between two vectors, with some 'safety' applied..." + (let ((f0-1 (vector-dot + (vector-normalize-copy! (new 'stack-no-clear 'vector) arg0 1.0) + (vector-normalize-copy! (new 'stack-no-clear 'vector) arg1 1.0) + ) + ) + ) + (cond + ((>= f0-1 1.0) + 0.0 + ) + ((>= -1.0 f0-1) + 0.017257283 + ) + (else + (acos f0-1) + ) + ) + ) + ) + +(defun vector-get-unique! ((arg0 vector) (arg1 vector)) + (let ((v1-0 0)) + (let ((f0-0 (-> arg1 x))) + (when (< (-> arg1 y) f0-0) + (set! f0-0 (-> arg1 y)) + (set! v1-0 1) + ) + (when (< (-> arg1 z) f0-0) + (-> arg1 z) + (set! v1-0 2) + ) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 data v1-0) 1.0) + ) + arg0 + ) + +(defun vector-get-closest-perpendicular! ((arg0 vector) (arg1 vector) (arg2 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector))) + 0.0 + (let ((f0-2 (vector-dot arg1 arg2))) + (vector-float*! s5-0 arg1 f0-2) + ) + (vector-! s5-0 arg2 s5-0) + (vector-normalize! s5-0 1.0) + (set! (-> arg0 quad) (-> s5-0 quad)) + ) + arg0 + ) diff --git a/goal_src/jakx/engine/nav/nav-mesh-h.gc b/goal_src/jakx/engine/nav/nav-mesh-h.gc index 61fb3a9bd7..e20ee15db4 100644 --- a/goal_src/jakx/engine/nav/nav-mesh-h.gc +++ b/goal_src/jakx/engine/nav/nav-mesh-h.gc @@ -5,5 +5,15 @@ ;; name in dgo: nav-mesh-h ;; dgos: ENGINE, GAME +;; +++nav-mesh-flag +(defenum nav-mesh-flag + :type uint8 + :bitfield #t + (water 0) + (dummy 1) + ) +;; ---nav-mesh-flag + + ;; DECOMP BEGINS diff --git a/goal_src/jakx/engine/net/scert-1-h.gc b/goal_src/jakx/engine/net/scert-1-h.gc index 656f112941..84e62adb9f 100644 --- a/goal_src/jakx/engine/net/scert-1-h.gc +++ b/goal_src/jakx/engine/net/scert-1-h.gc @@ -6,4 +6,3 @@ ;; dgos: ENGINE, GAME ;; DECOMP BEGINS - diff --git a/goal_src/jakx/engine/net/scert-2-h.gc b/goal_src/jakx/engine/net/scert-2-h.gc index 8ef658507e..1433d23994 100644 --- a/goal_src/jakx/engine/net/scert-2-h.gc +++ b/goal_src/jakx/engine/net/scert-2-h.gc @@ -6,4 +6,3 @@ ;; dgos: ENGINE, GAME ;; DECOMP BEGINS - diff --git a/goal_src/jakx/engine/physics/dynamics-h.gc b/goal_src/jakx/engine/physics/dynamics-h.gc index 6735cc37d5..f138ca8dbb 100644 --- a/goal_src/jakx/engine/physics/dynamics-h.gc +++ b/goal_src/jakx/engine/physics/dynamics-h.gc @@ -7,3 +7,52 @@ ;; DECOMP BEGINS +(deftype dynamics (basic) + ((name symbol) + (gravity-max meters) + (gravity-length meters) + (gravity vector :inline) + (gravity-normal vector :inline) + (walk-distance meters) + (run-distance meters) + ) + (:methods + (set-gravity-length (_type_ float) none) + ) + ) + + +(defmethod set-gravity-length ((this dynamics) (arg0 float)) + (set! (-> this gravity-length) arg0) + (vector-float*! (-> this gravity) (-> this gravity-normal) arg0) + 0 + (none) + ) + +(defun time-to-apex ((arg0 float) (arg1 float)) + (the int (/ arg0 (- (/ arg1 300)))) + ) + +(defun time-to-ground ((arg0 float) (arg1 float) (arg2 float)) + (let ((f0-0 0.0) + (v0-0 0) + ) + (while (< (- arg2) f0-0) + (set! arg0 (- arg0 (/ arg1 300))) + (+! f0-0 (/ arg0 300)) + (+! v0-0 1) + ) + v0-0 + ) + ) + +(define *standard-dynamics* (new 'static 'dynamics + :name 'standard + :gravity-max (meters 40) + :gravity-length (meters 60) + :gravity (new 'static 'vector :data (new 'static 'array float 4 0.0 245760.0 0.0 1.0)) + :gravity-normal (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0)) + :walk-distance (meters 2) + :run-distance (meters 5) + ) + ) diff --git a/goal_src/jakx/engine/physics/gravity-h.gc b/goal_src/jakx/engine/physics/gravity-h.gc index ad530cc684..db87413f1b 100644 --- a/goal_src/jakx/engine/physics/gravity-h.gc +++ b/goal_src/jakx/engine/physics/gravity-h.gc @@ -6,4 +6,3 @@ ;; dgos: ENGINE, GAME ;; DECOMP BEGINS - diff --git a/goal_src/jakx/engine/physics/ragdoll-h.gc b/goal_src/jakx/engine/physics/ragdoll-h.gc index 04f3777430..91bb67037d 100644 --- a/goal_src/jakx/engine/physics/ragdoll-h.gc +++ b/goal_src/jakx/engine/physics/ragdoll-h.gc @@ -5,5 +5,211 @@ ;; name in dgo: ragdoll-h ;; dgos: ENGINE, GAME +;; +++ragdoll-joint-flag +(defenum ragdoll-joint-flag + :type uint32 + :bitfield #t + (rjf0 0) + (rjf1 1) + (rjf2 2) + (rjf3 3) + (rjf4 4) + (rjf5 5) + (rjf6 6) + (rjf7 7) + (rjf8 8) + (rjf9 9) + (rjf10 10) + (rjf11 11) + (rjf12 12) + (rjf13 13) + (rjf14 14) + (rjf15 15) + ) +;; ---ragdoll-joint-flag + +;; +++ragdoll-flag +(defenum ragdoll-flag + :type uint32 + :bitfield #t + (rf0 0) + (rf1 1) + (rf2 2) + (rf3 3) + (rf4 4) + (rf5 5) + (rf6 6) + (rf7 7) + (mirror 8) + (rf9 9) + (rf10 10) + (rf11 11) + (rf12 12) + (rf13 13) + (rf14 14) + (rf15 15) + ) +;; ---ragdoll-flag + +(declare-type ragdoll basic) +(declare-type ragdoll-joint structure) +(declare-type ragdoll-proc process) + ;; DECOMP BEGINS +(deftype ragdoll-edit-info (structure) + ((editing symbol) + (current-func uint64) + (analog-func uint64) + (affect uint64) + (single-step uint64) + (collision symbol) + (gravity symbol) + (skel-visible uint64) + (current-joint int8) + (auto-setup-now basic) + (child-stack ragdoll-joint 60) + (child-stack-num int8) + (last-frame time-frame) + (last-frame-dur time-frame) + ) + (:methods + (has-joint? (_type_ ragdoll-joint) symbol) + (ragdoll-edit-info-method-10 (_type_ object ragdoll-joint) symbol) + (fill-child-stack! (_type_ ragdoll) none) + (ragdoll-edit-info-method-12 (_type_) none) + (cycle-joints! (_type_ ragdoll) none) + (ragdoll-edit-info-method-14 (_type_ matrix vector (inline-array ragdoll-joint) ragdoll process-drawable) vector) + (ragdoll-edit-info-method-15 (_type_) none) + (ragdoll-edit-info-method-16 (_type_ ragdoll process-drawable) none) + (ragdoll-edit-info-method-17 (_type_ ragdoll process-drawable) none) + ) + ) + + +(define *ragdoll-edit-info* (the-as ragdoll-edit-info 0)) + +(define *ragdoll-edit-info* (new 'static 'ragdoll-edit-info + :editing #t + :current-func #x9 + :single-step #x2 + :collision #t + :gravity #t + :skel-visible #x1 + ) + ) + +(deftype ragdoll-joint-setup (structure) + ((joint-index int32) + (parent-joint int32) + (joint-type uint64) + (pre-tform vector :inline) + (geo-tform vector :inline) + (axial-slop float) + (max-angle float) + (coll-rad float) + (hit-sound uint16) + ) + ) + + +(deftype ragdoll-setup (structure) + ((orient-tform vector :inline) + (scale vector :inline) + (bg-collide-with collide-spec) + (joint-setup (array ragdoll-joint-setup)) + ) + ) + + +(deftype ragdoll-joint (structure) + ((quat quaternion :inline) + (position vector :inline) + (velocity vector :inline) + (bounce vector :inline) + (old-x vector :inline) + (pre-tform vector :inline) + (geo-tform vector :inline) + (axial-slop float) + (max-angle degrees) + (joint-length float) + (coll-rad float) + (ragdoll-joint-flags ragdoll-joint-flag) + (joint-type uint64) + (joint-index int8) + (parent-joint int8) + (parent-index int8) + (num-children int8) + (old-param0 basic) + (hit-sound sound-name) + (ground-pat pat-surface) + (user0 int32) + (original-speed float) + ) + ) + + +(deftype ragdoll (basic) + ((ragdoll-joints ragdoll-joint 60 :inline) + (num-joints uint8) + (mirror matrix :inline) + (gravity vector :inline) + (gravity-target vector :inline) + (orient-tform vector :inline) + (scale vector :inline) + (stretch-vel float) + (stretch-vel-parallel float) + (compress-vel float) + (compress-vel-parallel float) + (momentum float) + (maximum-stretch float) + (turn-off-start time-frame) + (turn-off-duration time-frame) + (copy-velocity-start time-frame) + (root-offset vector :inline) + (rotate-vel quaternion :inline) + (rotate-adj quaternion :inline) + (rotate-adj-count int8) + (ragdoll-flags ragdoll-flag) + (flex-blend float) + (stable-joints int8) + (ragdoll-joint-remap uint8 100) + (allow-destabilize uint64) + (bg-collide-with uint32) + (water-info water-info :inline) + ) + (:methods + (ragdoll-method-9 (_type_ matrix process-drawable) none) + (ragdoll-method-10 (_type_ process-drawable symbol vector symbol) none) + (turn-off-for-duration! (_type_ time-frame) none) + (get-parent-joint (_type_ (inline-array ragdoll-joint)) ragdoll-joint) + (ragdoll-method-13 (_type_ ragdoll-edit-info ragdoll-joint matrix matrix) none) + (ragdoll-method-14 (_type_ process-drawable ragdoll-joint object matrix) none) + (ragdoll-method-15 (_type_ process-drawable ragdoll-edit-info) none) + (ragdoll-setup! (_type_ process-drawable ragdoll-setup) none) + (ragdoll-method-17 (_type_ process-drawable) none) + (ragdoll-method-18 (_type_) none) + (ragdoll-method-19 (_type_ vector int object matrix) none) + (reset-vec! (_type_ vector) none) + (ragdoll-method-21 (_type_ vector vector float) vector) + (get-max-angle-for-joint-idx (_type_ int) degrees) + (ragdoll-method-23 (_type_ vector vector float symbol) none) + (ragdoll-method-24 (_type_ vector int) none) + (enable-ragdoll! (_type_ process-drawable) none) + ) + ) + + +(deftype ragdoll-proc (process) + ((ragdoll ragdoll) + (last-attack-id uint32) + ) + (:methods + (ragdoll-proc-method-15 () none) + (ragdoll-proc-method-16 () none) + (ragdoll-proc-method-17 () none) + (ragdoll-proc-method-18 () none) + (ragdoll-proc-method-19 () none) + (ragdoll-proc-method-20 () none) + ) + ) diff --git a/goal_src/jakx/engine/process-drawable/process-drawable.gc b/goal_src/jakx/engine/process-drawable/process-drawable.gc index 563ef7797d..4a22269ee2 100644 --- a/goal_src/jakx/engine/process-drawable/process-drawable.gc +++ b/goal_src/jakx/engine/process-drawable/process-drawable.gc @@ -5,5 +5,39 @@ ;; name in dgo: process-drawable ;; dgos: ENGINE, GAME +;; +++attack-mask +(defenum attack-mask + :bitfield #t + :type uint32 + (trans 0) ;; 1 + (vector 1) ;; 2 + (intersection 2) ;; 4 + (attacker 3) ;; 8 + (attack-time 4) ;; 16 + (invinc-time 5) ;; 32 + (mode 6) ;; 64 + (shove-back 7) ;; 128 + (shove-up 8) ;; 256 + (speed 9) ;; 512 + (dist 10) ;; 1024 + (control 11) ;; 2048 + (angle 12) ;; 4096 + (rotate-to 13) ;; 8192 + (prev-state 14) ;; 16384 + (id 15) ;; 32768 + (count 16) ;; hi 1 + (penetrate-using 17) ;; hi 2 + (attacker-velocity 18);; hi 4 + (damage 19) ;; hi 8 + (shield-damage 20) ;; hi16 + (vehicle-damage-factor 21) ;; hi 32 + (vehicle-impulse-factor 22) ;; hi 64 + (knock 23) + (test 24) + (wpn-type 25) + ) +;; ---attack-mask + + ;; DECOMP BEGINS diff --git a/goal_src/jakx/engine/ps2/rpc-h.gc b/goal_src/jakx/engine/ps2/rpc-h.gc index 4e14c60d37..9ab8bb2f94 100644 --- a/goal_src/jakx/engine/ps2/rpc-h.gc +++ b/goal_src/jakx/engine/ps2/rpc-h.gc @@ -7,3 +7,192 @@ ;; DECOMP BEGINS +(deftype rpc-buffer (basic) + "Buffer for storing input/output data for a remote procedure call to the overlord driver on the IOP." + ((elt-size uint32) + (elt-count uint32) + (elt-used uint32) + (busy symbol) + (base pointer) + (data uint8 :dynamic :offset 32) + ) + (:methods + (new (symbol type uint uint) _type_) + ) + ) + + +(defmethod new rpc-buffer ((allocation symbol) (type-to-make type) (elt-size uint) (elt-count uint)) + (let* ((a2-2 (+ (-> type-to-make size) 63 (* (the-as int elt-size) (the-as int elt-count)))) + (v0-0 (object-new allocation type-to-make (the-as int a2-2))) + ) + (set! (-> v0-0 elt-size) elt-size) + (set! (-> v0-0 elt-count) elt-count) + (set! (-> v0-0 elt-used) (the-as uint 0)) + (set! (-> v0-0 busy) #f) + (set! (-> v0-0 base) (logand -64 (&-> v0-0 data 63))) + v0-0 + ) + ) + +(deftype rpc-buffer-pair (basic) + "A double buffer of RPC buffers. This is used to let the game queue up data in one buffer while +the other is being read/written by overlord." + ((buffer rpc-buffer 2) + (current rpc-buffer) + (last-recv-buffer pointer) + (rpc-port int32) + ) + (:methods + (new (symbol type uint uint int) rpc-buffer-pair) + (call (rpc-buffer-pair uint pointer uint) int) + (add-element (rpc-buffer-pair) pointer) + (decrement-elt-used (rpc-buffer-pair) int) + (sync (rpc-buffer-pair symbol) int) + (check-busy (rpc-buffer-pair) symbol) + (pop-last-received (rpc-buffer-pair) pointer) + ) + ) + + +(defmethod new rpc-buffer-pair ((allocation symbol) (type-to-make type) (elt-size uint) (elt-count uint) (rpc-port int)) + (let ((s3-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s3-0 buffer 0) (new 'global 'rpc-buffer elt-size elt-count)) + (set! (-> s3-0 buffer 1) (new 'global 'rpc-buffer elt-size elt-count)) + (set! (-> s3-0 current) (-> s3-0 buffer 0)) + (set! (-> s3-0 last-recv-buffer) (the-as pointer #f)) + (set! (-> s3-0 rpc-port) rpc-port) + s3-0 + ) + ) + +(defmethod sync ((this rpc-buffer-pair) (print-stall-warning symbol)) + "Wait for an in-progress rpc to finish." + (let ((s5-0 (if (= (-> this current) (-> this buffer 0)) + (-> this buffer 1) + (-> this buffer 0) + ) + ) + ) + (when (-> s5-0 busy) + (when (nonzero? (rpc-busy? (-> this rpc-port))) + (if print-stall-warning + (format 0 "STALL: waiting for IOP on RPC port #~D~%" (-> this rpc-port)) + ) + (while (nonzero? (rpc-busy? (-> this rpc-port))) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + ) + ) + (set! (-> s5-0 busy) #f) + (set! (-> s5-0 elt-used) (the-as uint 0)) + 0 + ) + ) + 0 + ) + +(defmethod check-busy ((this rpc-buffer-pair)) + "Check to see if an rpc is in progress." + (let ((gp-0 (if (= (-> this current) (-> this buffer 0)) + (-> this buffer 1) + (-> this buffer 0) + ) + ) + ) + (when (-> gp-0 busy) + (if (nonzero? (rpc-busy? (-> this rpc-port))) + (return #t) + ) + (set! (-> gp-0 busy) #f) + (set! (-> gp-0 elt-used) (the-as uint 0)) + 0 + ) + ) + #f + ) + +(defmethod call ((this rpc-buffer-pair) (fno uint) (recv-buffer pointer) (recv-buffer-size uint)) + "Start an async RPC call. If there is already one in progress, stall and wait for it to finish." + (when (nonzero? (-> this current elt-used)) + (let ((s2-0 (if (= (-> this current) (-> this buffer 0)) + (-> this buffer 1) + (-> this buffer 0) + ) + ) + ) + (when (-> s2-0 busy) + (when (nonzero? (rpc-busy? (-> this rpc-port))) + (format 0 "STALL: waiting for IOP on RPC port #~D~%" (-> this rpc-port)) + (while (nonzero? (rpc-busy? (-> this rpc-port))) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + ) + ) + (set! (-> s2-0 busy) #f) + (set! (-> s2-0 elt-used) (the-as uint 0)) + 0 + ) + (let ((s1-0 (-> this current))) + (rpc-call + (-> this rpc-port) + fno + (the-as uint 1) + (the-as uint (-> s1-0 base)) + (the-as int (* (-> s1-0 elt-size) (-> s1-0 elt-used))) + (the-as uint recv-buffer) + (the-as int recv-buffer-size) + ) + (set! (-> s1-0 busy) #t) + ) + (set! (-> this last-recv-buffer) recv-buffer) + (set! (-> this current) s2-0) + ) + ) + 0 + ) + +(defmethod pop-last-received ((this rpc-buffer-pair)) + "Pop the response from the most recently completed rpc call." + (let ((v0-0 (-> this last-recv-buffer))) + (set! (-> this last-recv-buffer) (the-as pointer #f)) + v0-0 + ) + ) + +(defmethod add-element ((this rpc-buffer-pair)) + "Add an element. If the buffer is full, flush it!" + (let ((v1-0 (-> this current))) + (when (= (-> v1-0 elt-used) (-> v1-0 elt-count)) + (if (= (-> this rpc-port) 1) + (format 0 "WARNING: too many sound commands queued~%") + ) + (call this (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + (set! v1-0 (-> this current)) + ) + (let ((v0-2 (&+ (-> v1-0 base) (* (-> v1-0 elt-used) (-> v1-0 elt-size))))) + (+! (-> v1-0 elt-used) 1) + v0-2 + ) + ) + ) + +(defmethod decrement-elt-used ((this rpc-buffer-pair)) + "Remove the most recently queued element." + (if (> (-> this current elt-used) 0) + (+! (-> this current elt-used) -1) + ) + 0 + ) diff --git a/goal_src/jakx/engine/ps2/timer-h.gc b/goal_src/jakx/engine/ps2/timer-h.gc index 02617058cd..4fc6c67a70 100644 --- a/goal_src/jakx/engine/ps2/timer-h.gc +++ b/goal_src/jakx/engine/ps2/timer-h.gc @@ -5,5 +5,176 @@ ;; name in dgo: timer-h ;; dgos: ENGINE, GAME +#|@file +There are two sources for timing: +- EE TIMER1, used for the frame profiler. There are 9765 counts of this per frame. It gets reset in drawable. +- The "stopwatch" system, used for reading the CPU clock cycle counter, at 300 MHz (32-bit) +|# + +;; The Emotion Engine has 4 hardware timers, timer1 is used as the +(defconstant TIMER0_BANK (the timer-bank #x10000000)) ;; has HOLD register! +(defconstant TIMER1_BANK (the timer-bank #x10000800)) ;; has HOLD register! +(defconstant TIMER2_BANK (the timer-bank #x10001000)) ;; does NOT have HOLD register! +(defconstant TIMER3_BANK (the timer-bank #x10001800)) ;; does NOT have HOLD register! + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; PC Port Timer +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defmacro get-cpu-clock () + "Read the 300 MHz clock." + ;; __read-ee-timer is a 300 MHz timer from the C Kernel. + ;; it's a real timer. + `(the uint (logand #xffffffff (__read-ee-timer))) + ) + +(defmacro get-bus-clock/256 () + "Read the 150 MHz / 256 clock." + ;; 300 MHz / (2^9) + `(the uint (logand #xffffffff (shr (__read-ee-timer) 9))) + ) + +(#when PC_PORT + ;; the bus clock can be reset, which just stores the current count here. + (define *timer-reset-value* (the uint 0)) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Timer HW +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; +++timer-clock-selection +(defenum timer-clock-selection + :type uint8 + (busclk 0) + (busclk/16 1) + (busclk/256 2) + (hblank 3) + ) +;; ---timer-clock-selection + ;; DECOMP BEGINS +(deftype timer-mode (uint32) + "This matches the Tn_MODE register structure of the ps2 EE timers. + Only the lower 32 bits of these registers are usable, and the upper 16 hardwired to zero." + ((clks timer-clock-selection :offset 0 :size 2) + (gate uint8 :offset 2 :size 1) ;; gate function enable + (gats uint8 :offset 3 :size 1) ;; gate selection: 0 = hblank, 1 = vblank + ;; gate mode: + ;; 0: count while gate signal is low + ;; 1: start when gate signal rises + ;; 2: start when gate signal falls + ;; 3: start when gate signal rises/falls + (gatm uint8 :offset 4 :size 2) + (zret uint8 :offset 6 :size 1) ;; zero return: clear counter when equal to reference value + (cue uint8 :offset 7 :size 1) ;; count-up enable + (cmpe uint8 :offset 8 :size 1) ;; compare-interrupt enable + (ovfe uint8 :offset 9 :size 1) ;; overflow-interrupt enable + (equf uint8 :offset 10 :size 1) ;; equal-flag + (ovff uint8 :offset 11 :size 1) ;; overflow-flag + ) + ) + +(deftype timer-bank (structure) + "This matches an EE timer (without a HOLD register, timers 2 and 3). +Each register is 128-bits wide, but only the lower 32-bits are usable, and the upper +16-bits of that are hardwired to zero." + ((count uint32) + (mode timer-mode :offset 16) + (comp uint32 :offset 32) + ) + ) + + +(deftype timer-hold-bank (timer-bank) + "This matches an EE timer (with a HOLD register, timers 0 and 1)." + ((hold uint32 :offset 48) + ) + ) + + +(deftype stopwatch (basic) + "Stopwatches are used to measure CPU clock cycles. +They don't use the timer above, but instead the Count COP0 register, +which counts CPU clock cycles directly." + ((prev-time-elapsed time-frame) + (start-time time-frame) + (begin-level int32) + ) + ) + + +(define *ticks-per-frame* 9765) + +(defun timer-init ((arg0 timer-bank) (arg1 timer-mode)) + "Initiate a timer, start counting at a rate of 1 every 256 bus clocks (BUSCLK: ~147.456MHz)." + (set! (-> arg0 mode) arg1) + (set! (-> arg0 count) (the-as uint 0)) + 0 + ) + +(timer-init + (the-as timer-bank #x10000800) + (new 'static 'timer-mode :clks (timer-clock-selection busclk/256) :cue #x1) + ) + +(deftype sce-cd-clock (structure) + ((stat uint8) + (second uint8) + (minute uint8) + (hour uint8) + (pad uint8) + (day uint8) + (month uint8) + (year uint8) + ) + ) + + +(defun bcd-conv ((arg0 uint)) + "Binary coded decimal to integer" + (+ (* 10 (the-as int (/ (the-as int arg0) 16))) (logand arg0 15)) + ) + +(define *month-days* + (new 'static 'array uint32 12 #x1f #x1c #x1f #x1e #x1f #x1e #x1f #x1f #x1e #x1f #x1e #x1f) + ) + +(defun is-leap ((arg0 uint)) + (or (zero? (mod (the-as int arg0) 400)) (and (not (logtest? arg0 3)) (nonzero? (mod (the-as int arg0) 100)))) + ) + +(defun mdy-to-day ((arg0 int) (arg1 int) (arg2 uint)) + (if (is-leap arg2) + (set! (-> *month-days* 1) (the-as uint 29)) + (set! (-> *month-days* 1) (the-as uint 28)) + ) + (let ((v1-2 (+ arg0 -1)) + (v0-1 (+ arg1 -1)) + ) + (dotimes (a0-4 v1-2) + (+! v0-1 (-> (the-as (pointer int32) (&+ *month-days* (* a0-4 4))))) + ) + v0-1 + ) + ) + +(defun rtclock-to-secs ((arg0 sce-cd-clock)) + (let ((s5-0 0) + (s4-0 (bcd-conv (-> arg0 year))) + ) + (if (< s4-0 2000) + (+! s4-0 2000) + ) + (dotimes (s3-0 (+ s4-0 -1970)) + (+! s5-0 (* #x15180 (mdy-to-day 12 32 (the-as uint (+ s3-0 1970))))) + ) + (+ s5-0 + (* #x15180 (mdy-to-day (bcd-conv (-> arg0 month)) (bcd-conv (-> arg0 day)) (the-as uint s4-0))) + (* 3600 (bcd-conv (-> arg0 hour))) + (* 60 (bcd-conv (-> arg0 minute))) + (bcd-conv (-> arg0 second)) + ) + ) + ) diff --git a/goal_src/jakx/engine/ps2/timer.gc b/goal_src/jakx/engine/ps2/timer.gc index c40c47b78a..7e2c395917 100644 --- a/goal_src/jakx/engine/ps2/timer.gc +++ b/goal_src/jakx/engine/ps2/timer.gc @@ -5,5 +5,261 @@ ;; name in dgo: timer ;; dgos: ENGINE, GAME +(defglobalconstant EE_SECONDS_PER_TICK (/ 1.0 300000000)) ;; 300MHz is a "decent enough" estimate +(defmacro cpu-ticks-to-seconds (ticks) + `(* ,EE_SECONDS_PER_TICK ,ticks) + ) + ;; DECOMP BEGINS +(defun timer-count ((arg0 timer-bank)) + (.sync.l) + (let ((v0-0 (-> arg0 count))) + (.sync.l) + v0-0 + ) + ) + +(defmacro timer1-time () + `(timer-count TIMER1_BANK) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Interrupt Control +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; cop0 status register "interrupt enable" flag +;; if cop0 status is needed anywhere else, move this elsewhere +(defconstant COP0_STATUS_IE (the-as uint #x1)) + +(defun disable-irq () + "Disable all interrupts. Has no effect on PC Port." + (rlet ((status :class gpr :type uint)) + (let ((status-mask (lognot COP0_STATUS_IE))) + (.mfc0 status Status) + (logand! status status-mask) ;; should status-mask be replaced directly? + (.mtc0 Status status) + (.sync.p) + ) + ) + ) + +(defun enable-irq () + "Enable all interrupts. Has no effect on PC Port." + (rlet ((status :class gpr :type uint)) + (.mfc0 status Status) + (logior! status COP0_STATUS_IE) + (.mtc0 Status status) + (.sync.p) + ) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Stopwatch (CPU clock cycle counting) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun stopwatch-init ((this stopwatch)) + "Init a stopwatch." + (set! (-> this begin-level) 0) + (set! (-> this prev-time-elapsed) 0) + ) + + +(defun stopwatch-reset ((this stopwatch)) + "Restart a stopwatch's times." + (set! (-> this prev-time-elapsed) 0) + (when (> (-> this begin-level) 0) + (let ((count 0)) + (.mfc0 count Count) + (#when PC_PORT + (set! count (the int (get-cpu-clock))) + ) + (set! (-> this start-time) count) + ) + ) + ) + +(defun stopwatch-start ((this stopwatch)) + "Start a stopwatch from scratch." + (when (zero? (-> this begin-level)) + (set! (-> this begin-level) 1) + (let ((count 0)) + (.mfc0 count Count) + (#when PC_PORT + (set! count (the int (get-cpu-clock))) + ) + (set! (-> this start-time) count) + ) + ) + ) + +(defun stopwatch-stop ((this stopwatch)) + "Fully stop a stopwatch and save its elapsed time." + (when (> (-> this begin-level) 0) + (set! (-> this begin-level) 0) + (let ((count 0)) + (let ((count 0)) + (.mfc0 count Count) ;; wrong register? a typo in a rlet? who knows. + (#when PC_PORT + (set! count (the int (get-cpu-clock))) + ) + (+! (-> this prev-time-elapsed) (- count (-> this start-time))) + ) + ) + ) + (none) + ) + +(defun stopwatch-begin ((this stopwatch)) + "Begin a stopwatch level, and starts it if it hasn't yet." + (when (zero? (-> this begin-level)) + (let ((count 0)) + (.mfc0 count Count) + (#when PC_PORT + (set! count (the int (get-cpu-clock))) + ) + (set! (-> this start-time) count) + ) + ) + (+! (-> this begin-level) 1) + ) + +(defun stopwatch-end ((this stopwatch)) + "End a stopwatch level. Stops the stopwatch if it's back to level zero. + There is no guard against ending a stopwatch too many times, and a negative level + will cause errors!" + (+! (-> this begin-level) -1) + (when (zero? (-> this begin-level)) + (set! (-> this begin-level) 0) + (let ((count 0)) + (.mfc0 count Count) + (#when PC_PORT + (set! count (the int (get-cpu-clock))) + ) + + (+! (-> this prev-time-elapsed) (- count (-> this start-time))) + ) + ) + (none) + ) + +(defun stopwatch-elapsed-ticks ((this stopwatch)) + "Returns the elapsed time so far (in clock cycles) of a stopwatch." + (let ((elapsed (-> this prev-time-elapsed))) + (when (> (-> this begin-level) 0) + (let ((count 0)) + (.mfc0 count Count) + (#when PC_PORT + (set! count (the int (get-cpu-clock))) + ) + + (+! elapsed (- count (-> this start-time))) + (set! count elapsed) ;; ?? + ) + ) + elapsed + ) + ) + +(defun stopwatch-elapsed-seconds ((arg0 stopwatch)) + (let ((v1-0 (stopwatch-elapsed-ticks arg0))) + (* 0.0000000033333334 (the float v1-0)) + ) + ) + +(defmethod update-rates! ((this clock) (rate float)) + "Recompute all clock values for the given clock ratio (arg0)." + (set! (-> this clock-ratio) rate) + (let ((f0-6 (if (nonzero? *display*) + (* (-> *display* time-factor) (-> *display* dog-ratio) rate) + (* 5.0 rate) + ) + ) + ) + (set! (-> this time-adjust-ratio) (* 0.2 f0-6)) + ) + (set! (-> this seconds-per-frame) (* 0.016666668 (-> this time-adjust-ratio))) + (set! (-> this frames-per-second) (if (= (-> this time-adjust-ratio) 0.0) + 0.0 + (* 60.0 (/ 1.0 (-> this time-adjust-ratio))) + ) + ) + ;; og:preserve-this removed number cast + (let* ((v1-12 (- (-> this frame-counter) (-> this old-frame-counter))) + (f0-14 (the-as float v1-12)) + (f1-9 (* 0.2 (the float v1-12))) + ) + (set-vector! (-> this sparticle-data) f0-14 (* 5.0 f1-9) f1-9 f1-9) + ) + rate + ) + +(defmethod advance-by! ((this clock) (arg0 float)) + "Advance the clock by arg0 timeframes (as a float). + Both counters keep a separate fractional and integer counter." + (the int (+ arg0 (-> this accum))) + (+! (-> this integral-accum) arg0) + (set! (-> this old-integral-frame-counter) (-> this integral-frame-counter)) + (while (>= (-> this integral-accum) (-> *display* time-factor)) + (+! (-> this integral-frame-counter) 1) + (set! (-> this integral-accum) (- (-> this integral-accum) (-> *display* time-factor))) + ) + (let ((v1-7 (the int (+ arg0 (-> this accum))))) + (set! (-> this accum) (- (+ arg0 (-> this accum)) (the float v1-7))) + (set! (-> this old-frame-counter) (-> this frame-counter)) + (+! (-> this frame-counter) v1-7) + ) + (update-rates! this (-> this clock-ratio)) + this + ) + +(defmethod tick! ((this clock)) + "Per-game-frame clock tick forward." + (if (not (logtest? (-> this mask) (-> *kernel-context* prevent-from-run))) + (advance-by! this (* (-> *display* time-factor) (-> *display* dog-ratio) (-> this clock-ratio))) + (set! (-> this sparticle-data x) 0.0) + ) + this + ) + +(defmethod reset! ((this clock)) + "Reset a clock to 1000s, rate of 1." + (set! (-> this frame-counter) (seconds 1000)) + (set! (-> this integral-frame-counter) (seconds 1000)) + (set! (-> this accum) 0.0) + (set! (-> this old-frame-counter) (+ (-> this frame-counter) -1)) + (set! (-> this old-integral-frame-counter) (+ (-> this integral-frame-counter) -1)) + (update-rates! this 1.0) + 0 + (none) + ) + +(defmethod save! ((this clock) (arg0 (pointer uint64))) + "Save a clock's state to a buffer, return bytes used." + (set! (-> arg0 0) (the-as uint (-> this frame-counter))) + (set! (-> arg0 1) (the-as uint (-> this integral-frame-counter))) + 16 + ) + +(defmethod load! ((this clock) (arg0 (pointer uint64))) + "Load a clock's state from a buffer, return bytes used." + (set! (-> this frame-counter) (the-as time-frame (-> arg0 0))) + (set! (-> this integral-frame-counter) (the-as time-frame (-> arg0 1))) + (set! (-> this accum) 0.0) + (set! (-> this integral-accum) 0.0) + (set! (-> this old-frame-counter) (-> this frame-counter)) + (set! (-> this old-integral-frame-counter) (-> this integral-frame-counter)) + 16 + ) + +(defmethod copy! ((this clock) (arg0 clock)) + "Copy the frame counters and ratio from arg0." + (set! (-> this frame-counter) (-> arg0 frame-counter)) + (set! (-> this integral-frame-counter) (-> arg0 integral-frame-counter)) + (set! (-> this accum) (-> arg0 accum)) + (set! (-> this integral-accum) (-> arg0 integral-accum)) + (set! (-> this old-frame-counter) (-> arg0 old-frame-counter)) + (set! (-> this old-integral-frame-counter) (-> arg0 old-integral-frame-counter)) + (set! (-> this clock-ratio) (-> arg0 clock-ratio)) + this + ) diff --git a/goal_src/jakx/engine/ps2/vif-h.gc b/goal_src/jakx/engine/ps2/vif-h.gc index 725d6a411b..8b5324dfb0 100644 --- a/goal_src/jakx/engine/ps2/vif-h.gc +++ b/goal_src/jakx/engine/ps2/vif-h.gc @@ -7,3 +7,59 @@ ;; DECOMP BEGINS +(deftype vif-stat (uint32) + ((vps uint8 :offset 0 :size 2) + (vew uint8 :offset 2 :size 1) + (mrk uint8 :offset 6 :size 1) + (vss uint8 :offset 8 :size 1) + (vfs uint8 :offset 9 :size 1) + (vis uint8 :offset 10 :size 1) + (int uint8 :offset 11 :size 1) + (er0 uint8 :offset 12 :size 1) + (er1 uint8 :offset 13 :size 1) + (fqc uint8 :offset 24 :size 4) + ) + ) + + +(deftype vif-fbrst (uint32) + ((rst uint8 :offset 0 :size 1) + (fbk uint8 :offset 1 :size 1) + (stp uint8 :offset 2 :size 1) + (stc uint8 :offset 3 :size 1) + ) + ) + +(deftype vif-err (uint32) + ((mii uint8 :offset 0 :size 1) + (me0 uint8 :offset 1 :size 1) + (me1 uint8 :offset 2 :size 1) + ) + ) + +(deftype vif-bank (structure) + ((stat uint32) + (fbrst uint32 :offset 16) + (err vif-err :offset 32) + (mark uint32 :offset 48) + (cycle uint32 :offset 64) + (mode uint32 :offset 80) + (num uint32 :offset 96) + (mask uint32 :offset 112) + (code uint32 :offset 128) + (itops uint32 :offset 144) + (base uint32 :offset 160) + (offset uint32 :offset 176) + (tops uint32 :offset 192) + (itop uint32 :offset 208) + (top uint32 :offset 224) + (r0 uint32 :offset 256) + (r1 uint32 :offset 272) + (r2 uint32 :offset 288) + (r3 uint32 :offset 304) + (c0 uint32 :offset 320) + (c1 uint32 :offset 336) + (c2 uint32 :offset 352) + (c3 uint32 :offset 368) + ) + ) diff --git a/goal_src/jakx/engine/ps2/vu1-macros.gc b/goal_src/jakx/engine/ps2/vu1-macros.gc index a77c2dcdc0..b83100daeb 100644 --- a/goal_src/jakx/engine/ps2/vu1-macros.gc +++ b/goal_src/jakx/engine/ps2/vu1-macros.gc @@ -6,4 +6,3 @@ ;; dgos: ENGINE, GAME ;; DECOMP BEGINS - diff --git a/goal_src/jakx/engine/sound/gsound-h.gc b/goal_src/jakx/engine/sound/gsound-h.gc index df46781150..f847e605c1 100644 --- a/goal_src/jakx/engine/sound/gsound-h.gc +++ b/goal_src/jakx/engine/sound/gsound-h.gc @@ -5,5 +5,434 @@ ;; name in dgo: gsound-h ;; dgos: ENGINE, GAME +;; +++sound-bank-mode +(defenum sound-bank-mode + :type uint32 + (none 0) + (unknown 1) + (common 2) + (mode 3) + (full 4) + (half 5) + (halfa 6) + (halfb 7) + (halfc 8) + (virtual 9) + ) +;; ---sound-bank-mode + + +;; +++stream-status +(defenum stream-status + :type uint32 + :bitfield #t + (ss1 1) ;; id-is-playing + (ss4 4) ;; is-playing + (ss6 6) ;; id-is-playing + (ss9 9) + ) +;; ---stream-status + + ;; DECOMP BEGINS +(deftype sound-stream-name (structure) + ((name uint8 48 :offset-assert 0) ;; guessed by decompiler + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +(deftype sound-id (uint32) + () + :flag-assert #x900000004 + ) + +(deftype sound-bank-id (uint32) + () + :flag-assert #x900000004 + ) + +(deftype sound-name (uint128) + ((lo uint64 :offset 0) ;; added to help with cases where they access it by u64. + (hi uint64 :offset 64) + ) + :flag-assert #x900000010 + ) + +(deftype sound-rpc-cmd (structure) + ((rsvd1 uint16 :offset-assert 0) + (command uint16 :offset-assert 2) ;; sound-command + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +(deftype sound-play-params (structure) + ((mask uint8 :offset-assert 0) ;; uint16 + (group uint8 :offset-assert 1) + (volume int16 :offset-assert 2) ;; int32 + (pitch-mod int16 :offset-assert 4) + (bend int16 :offset-assert 6) + (pan int16 :offset-assert 8) + ) + :method-count-assert 9 + :size-assert #xa + :flag-assert #x90000000a + ) + +(deftype sound-rpc-bank-cmd (sound-rpc-cmd) + ((bank-name uint128 :offset-assert 16) ;; sound-name + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +(deftype sound-rpc-test-cmd (sound-rpc-cmd) + ((ee-addr pointer :offset-assert 4) ;; guessed by decompiler + (param0 uint16 :offset-assert 8) + ) + :method-count-assert 9 + :size-assert #xa + :flag-assert #x90000000a + ) + +(deftype sound-rpc-sound-cmd (sound-rpc-cmd) + ((id sound-id :offset-assert 4) ;; guessed by decompiler + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-group-cmd (sound-rpc-cmd) + ((group uint32 :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-load-bank (sound-rpc-bank-cmd) + ((ee-addr pointer :offset-assert 32) ;; guessed by decompiler + (mode uint32 :offset-assert 36) + (priority uint32 :offset-assert 40) + ) + :method-count-assert 9 + :size-assert #x2c + :flag-assert #x90000002c + ) + +(deftype sound-rpc-load-music (sound-rpc-bank-cmd) + () + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +(deftype sound-rpc-unload-bank (sound-rpc-cmd) + ((mode uint32 :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-play (sound-rpc-sound-cmd) + ((name uint128 :offset-assert 16) ;; sound-name + (params sound-play-params :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x2a + :flag-assert #x90000002a + ) + +(deftype sound-rpc-pause-sound (sound-rpc-sound-cmd) + () + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-stop-sound (sound-rpc-sound-cmd) + () + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-continue-sound (sound-rpc-sound-cmd) + () + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-set-param (sound-rpc-sound-cmd) + ((params sound-play-params :inline :offset-assert 16) + (auto-time int32 :offset-assert 28) + (auto-from int32 :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x24 + :flag-assert #x900000024 + ) + +(deftype sound-rpc-set-master-volume (sound-rpc-group-cmd) + ((volume int32 :offset-assert 8) + ) + :method-count-assert 9 + :size-assert #xc + :flag-assert #x90000000c + ) + +(deftype sound-rpc-pause-group (sound-rpc-group-cmd) + () + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-stop-group (sound-rpc-group-cmd) + () + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-continue-group (sound-rpc-group-cmd) + () + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-cancel-dgo (sound-rpc-group-cmd) + ((id uint32 :offset-assert 8) + ) + :method-count-assert 9 + :size-assert #xc + :flag-assert #x90000000c + ) + +(deftype sound-rpc-get-irx-version (sound-rpc-cmd) + ((major uint32 :offset-assert 4) + (minor uint32 :offset-assert 8) + (ee-addr pointer :offset-assert 12) ;; guessed by decompiler + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype sound-rpc-set-language (sound-rpc-cmd) + ((lang uint32 :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-set-stereo-mode (sound-rpc-cmd) + ((mode int32 :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-set-reverb (sound-rpc-cmd) + ((core uint8 :offset-assert 4) + (reverb int32 :offset-assert 8) + (left uint32 :offset-assert 12) + (right uint32 :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x14 + :flag-assert #x900000014 + ) + +(deftype sound-rpc-set-ear-trans (sound-rpc-cmd) + ((ear-trans1 int32 3 :offset-assert 4) ;; guessed by decompiler + (ear-trans0 int32 3 :offset-assert 16) ;; guessed by decompiler + (cam-trans int32 3 :offset-assert 28) ;; guessed by decompiler + (cam-forward int32 3 :offset-assert 40) ;; guessed by decompiler + (cam-left int32 3 :offset-assert 52) ;; guessed by decompiler + (cam-scale int32 :offset-assert 64) + (cam-inverted int32 :offset-assert 68) + ) + :method-count-assert 9 + :size-assert #x48 + :flag-assert #x900000048 + ) + +(deftype sound-rpc-shutdown (sound-rpc-cmd) + () + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +(deftype sound-rpc-set-fps (sound-rpc-cmd) + ((fps uint8 :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x5 + :flag-assert #x900000005 + ) + +(deftype sound-rpc-set-globals (sound-rpc-cmd) + ((cam-inverted uint8 :offset-assert 4) + (music-pitch-mod int16 :offset-assert 6) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(deftype sound-rpc-list-sounds (sound-rpc-cmd) + () + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +(deftype sound-rpc-unload-music (sound-rpc-cmd) + () + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +(deftype sound-rpc-union (structure) + ((data uint32 12 :offset-assert 0) ;; guessed by decompiler + (load-bank sound-rpc-load-bank :offset 0) + (unload-bank sound-rpc-unload-bank :offset 0) + (play sound-rpc-play :offset 0) + (pause-sound sound-rpc-pause-sound :offset 0) + (stop-sound sound-rpc-stop-sound :offset 0) + (continue-sound sound-rpc-continue-sound :offset 0) + (set-param sound-rpc-set-param :offset 0) + (set-master-volume sound-rpc-set-master-volume :offset 0) + (pause-group sound-rpc-pause-group :offset 0) + (stop-group sound-rpc-stop-group :offset 0) + (continue-group sound-rpc-continue-group :offset 0) + (get-irx-version sound-rpc-get-irx-version :offset 0) + (set-language sound-rpc-set-language :offset 0) + (set-reverb sound-rpc-set-reverb :offset 0) + (set-fps sound-rpc-set-fps :offset 0) + (set-globals sound-rpc-set-globals :offset 0) + (shutdown sound-rpc-shutdown :offset 0) + (list-sounds sound-rpc-list-sounds :offset 0) + (unload-music sound-rpc-unload-music :offset 0) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +(deftype sound-info (structure) + ((flags uint32 :offset-assert 0) + (num-instances uint32 :offset-assert 4) + (index uint32 :offset-assert 8) + (name uint128 :offset-assert 16) + (group uint8 :offset-assert 32) + (fo-power float :offset-assert 36) + (fo-min float :offset-assert 40) + (fo-max float :offset-assert 44) + (volume float :offset-assert 48) + (pan float :offset-assert 52) + (priority int8 :offset-assert 56) + (duck-amount float :offset-assert 60) + ) + :method-count-assert 9 + :size-assert #x40 + :flag-assert #x900000040 + ) + +(deftype sound-spec (sound-play-params) + ((auto-time int32 :offset-assert 12) + (auto-from int32 :offset-assert 16) + (info sound-info :offset-assert 20) + (info-index uint32 :offset-assert 24) + (trans vector :inline :offset-assert 32) ;; int32 4 + (flags uint16 :offset-assert 48) + (fo-min float :offset-assert 52) ;; int16 + (fo-max float :offset-assert 56) ;; int16 + (fo-power float :offset-assert 60) + ) + :method-count-assert 9 + :size-assert #x40 + :flag-assert #x900000040 + ) + +(deftype sound-handle (structure) + ((proc uint64 :offset-assert 0) + (flags uint64 :offset-assert 8) + (fader-cur float :offset-assert 16) + (fader-targ float :offset-assert 20) + (dist float :offset-assert 24) + (viewport int8 :offset-assert 28) + (num-instances uint8 :offset-assert 29) + (svc uint8 :offset-assert 30) + (index uint8 :offset-assert 31) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +(deftype sound-instance (sound-spec) + ((last-update uint64 :offset-assert 64) + (joint uint8 :offset-assert 72) + (sh sound-handle :offset-assert 76) + (id uint32 :offset-assert 80) + (pan-angle float :offset-assert 84) + (volumef float :offset-assert 88) + ) + :method-count-assert 9 + :size-assert #x5c + :flag-assert #x90000005c + ) + +;; +++gsound-h:sound-bank-mode +(defenum sound-bank-mode + :type uint32 + (none 0) + (unknown 1) + (common 2) + (mode 3) + (full 4) + (half 5) + (halfa 6) + (halfb 7) + (halfc 8) + (virtual 9) + ) +;; ---gsound-h:sound-bank-mode + +(deftype sound-bank-state (structure) + ((name symbol :offset-assert 0) ;; guessed by decompiler + (mode sound-bank-mode :offset-assert 4) ;; guessed by decompiler + (high basic :offset-assert 8) + (str-name basic :offset-assert 12) + ) + :pack-me + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +;; +++gsound-h:stream-status +(defenum stream-status + :type uint32 + :bitfield #t + (ss1 1) ;; id-is-playing + (ss4 4) ;; is-playing + (ss6 6) ;; id-is-playing + (ss9 9) + ) +;; ---gsound-h:stream-status \ No newline at end of file diff --git a/goal_src/jakx/engine/sound/speech-h.gc b/goal_src/jakx/engine/sound/speech-h.gc index 4df19af789..de1e838aa9 100644 --- a/goal_src/jakx/engine/sound/speech-h.gc +++ b/goal_src/jakx/engine/sound/speech-h.gc @@ -5,5 +5,176 @@ ;; name in dgo: speech-h ;; dgos: ENGINE, GAME +;; +++speech-info-flag +(defenum speech-info-flag + :type uint64 + :bitfield #t + (si0 0) + (si1 1) + (si2 2) + (si3 3) + (si4 4) + (si5 5) + (si6 6) + (si7 7) + (si8 8) + ) +;; ---speech-info-flag + +;; +++speech-type +(defenum speech-type + :type uint8 + (none 0) + (guard-generic-battle 1) + (guard-generic-battle-b 2) + (guard-battle-victory 3) + (guard-battle-victory-b 4) + (guard-change-targets 5) + (guard-change-targets-b 6) + (guard-go-hostile 7) + (guard-go-hostile-b 8) + (guard-hit 9) + (guard-hit-b 10) + (guard-witness-death 11) + (guard-witness-death-b 12) + (guard-chatter 13) + (guard-chatter-b 14) + (guard-chatter-jak 15) + (guard-chatter-jak-b 16) + (guard-bumped-by-jak 17) + (guard-bumped-by-jak-b 18) + (civ-m-ambient 19) + (civ-m-alert 20) + (civ-m-cower 21) + (civ-m-touched-by-player 22) + (civ-m-shot-by-player 23) + (civ-m-avoiding-player-vehicle 24) + (civ-m-hit-by-player-vehicle 25) + (civ-m-player-stealing-vehicle 26) + (civ-f-ambient 27) + (civ-f-alert 28) + (civ-f-cower 29) + (civ-f-touched-by-player 30) + (civ-f-shot-by-player 31) + (civ-f-avoiding-player-vehicle 32) + (civ-f-hit-by-player-vehicle 33) + (race-jak-start 34) + (race-jak-lap 35) + (race-jak-last-lap 36) + (race-jak-hit 37) + (race-jak-got-hit 38) + (race-jak-ambient 39) + (race-jak-pass 40) + (race-jak-jump 41) + (race-jak-win 42) + (race-daxter-start 43) + (race-daxter-lap 44) + (race-daxter-last-lap 45) + (race-daxter-hit 46) + (race-daxter-got-hit 47) + (race-daxter-ambient 48) + (race-daxter-pass 49) + (race-daxter-jump 50) + (race-daxter-win 51) + (race-errol-start 52) + (race-errol-last-lap 53) + (race-errrol-hit 54) + (race-errol-got-hit 55) + (race-errol-ambient 56) + (race-errol-pass 57) + (race-errol-got-passed 58) + (race-errol-win 59) + (race-errol-lose 60) + ) +;; ---speech-type + +;; +++speech-channel-flag +(defenum speech-channel-flag + :type uint8 + :bitfield #t + (disable 0) + ) +;; ---speech-channel-flag + +(define-extern get-task-cup-score (function int int)) + ;; DECOMP BEGINS +(define *music-volume-during-speech* 0.85) + +(define *sfx-volume-during-speech* 1.0) + +(defun pecker-can-speak? () + (or (!= *game-mode* 'adventure) (>= (get-task-cup-score 128) 22)) + ) + +(deftype speech-info-item (structure) + ((name basic) + (flags speech-info-flag) + ) + :pack-me + ) + + +(deftype speech-info (structure) + ((list basic) + (flags speech-info-flag) + ) + (:methods + (speech-info-method-9 () none) + (speech-info-method-10 () none) + (speech-info-method-11 () none) + (speech-info-method-12 () none) + ) + ) + + +(deftype speech-request (structure) + ((handle handle) + (req-time time-frame) + (start-time time-frame) + (name basic) + (speech-type speech-type) + (flags uint8) + (max-delay uint64) + ) + ) + + +(deftype speech-channel (structure) + ((flags speech-channel-flag) + (gui-channel gui-channel) + (delay uint16) + (id sound-id) + (time uint64) + (current-request speech-request) + (requests basic) + (speeches speech-info-item 31) + ) + (:methods + (speech-channel-method-9 () none) + (speech-channel-method-10 () none) + (speech-channel-method-11 () none) + (speech-channel-method-12 () none) + (speech-channel-method-13 () none) + (speech-channel-method-14 () none) + (speech-channel-method-15 () none) + (speech-channel-method-16 () none) + ) + ) + + +(deftype speech-control (structure) + ((channels speech-channel 22 :inline) + ) + (:methods + (speech-control-method-9 () none) + (speech-control-method-10 () none) + (speech-control-method-11 () none) + (speech-control-method-12 () none) + (speech-control-method-13 () none) + (speech-control-method-14 () none) + (speech-control-method-15 () none) + (speech-control-method-16 () none) + ) + ) diff --git a/goal_src/jakx/engine/spatial-hash/actor-hash-h.gc b/goal_src/jakx/engine/spatial-hash/actor-hash-h.gc index 99229e1a49..d62feaa032 100644 --- a/goal_src/jakx/engine/spatial-hash/actor-hash-h.gc +++ b/goal_src/jakx/engine/spatial-hash/actor-hash-h.gc @@ -7,3 +7,6 @@ ;; DECOMP BEGINS +(define *actor-list* (the-as (pointer collide-shape) (malloc 'global 2048))) + +(define *actor-list-length* 0) diff --git a/goal_src/jakx/engine/spatial-hash/collide-hash-h.gc b/goal_src/jakx/engine/spatial-hash/collide-hash-h.gc index 5ef93e7876..36e00b2861 100644 --- a/goal_src/jakx/engine/spatial-hash/collide-hash-h.gc +++ b/goal_src/jakx/engine/spatial-hash/collide-hash-h.gc @@ -7,3 +7,112 @@ ;; DECOMP BEGINS +(define *collide-list-boxes* #f) + +(define *collide-hash-fragments* 0) + +(define *collide-hash-fragments-tfrag* 0) + +(define *collide-hash-fragments-instance* 0) + +(define *already-printed-exeeded-max-cache-tris* #f) + +(deftype collide-hash-scratch (structure) + "Scratchpad memory layout for collide-hash. Bitmask of things that have already been checked" + ((collidable-bits uint128 128) + (poly-bits uint64 2 :overlay-at (-> collidable-bits 0)) + (id-bits uint32 512 :overlay-at (-> collidable-bits 0)) + (tris uint32) + ) + ) + + +(deftype collide-hash-bucket (structure) + "A bucket is a reference to a list of items that intersect a grid cell. +For the broadphase, the items are collide-hash-item (wrapper of collide-hash-fragment). +For the narrowphase, the items are entries in the index list, which contains poly indices." + ((index int16) + (count int16) + ) + ) + + +(deftype collide-hash-item (structure) + "Items that are 'hashed' in the broadphase. Contains unique ID for checking against already-visited-bitmask +and a pointer to the actual collide-hash-fragment, or possibly a TIE." + ((id uint32) + (collidable basic) + ) + :pack-me + ) + + +(deftype collide-hash-poly (structure) + "A polygon in the narrow-phase data. This is just indices into the vertex and PAT tables." + ((data uint8 4) + (vert-index0 uint8 :overlay-at (-> data 0)) + (vert-index1 uint8 :overlay-at (-> data 1)) + (vert-index2 uint8 :overlay-at (-> data 2)) + (pat-index uint8 :overlay-at (-> data 3)) + (word uint32 :overlay-at (-> data 0)) + ) + ) + + +(deftype collide-hash-fragment-stats (structure) + ((num-verts uint16) + (num-polys uint8) + (poly-count uint8) + ) + :pack-me + ) + + +(deftype collide-hash-fragment (drawable) + "A mesh fragment for the Jak2/Jak3 collision system. This is a 'hash' of triangles into a grid +where the 'hash' function is just identity." + ((num-buckets uint16 :overlay-at id) + (num-indices uint16 :offset 6) + (pat-array uint32 :offset 8) + (bucket-array uint32 :offset 12) + (grid-step vector :inline) + (bbox bounding-box :inline) + (bbox4w bounding-box4w :inline) + (axis-scale vector :inline :overlay-at (-> bbox max)) + (avg-extents vector :inline :overlay-at (-> bbox4w min data 0)) + (dimension-array uint32 4 :overlay-at (-> grid-step data 3)) + (stats collide-hash-fragment-stats :inline :overlay-at (-> bbox min data 3)) + (num-verts uint16 :overlay-at (-> bbox min data 3)) + (num-polys uint8 :offset 62) + (poly-count uint8 :offset 63) + (poly-array uint32 :overlay-at (-> bbox max data 3)) + (vert-array uint32 :overlay-at (-> bbox4w min data 3)) + (index-array uint32 :overlay-at (-> bbox4w max data 3)) + ) + ) + + +(deftype collide-hash-fragment-array (array) + "A collection of collide-hash-fragments. These are used by the instanced collision if a single instance +needs more than 1 collide-hash-fragment worth of triangles." + ((fragments collide-hash-fragment :dynamic :offset 16) + ) + ) + + +(deftype collide-hash (drawable) + ((num-ids uint16 :overlay-at id) + (id-count uint16 :offset 6) + (num-buckets uint32 :offset 8) + (qwc-id-bits uint32 :offset 12) + (grid-step vector :inline :overlay-at bsphere) + (bbox bounding-box :inline :offset 32) + (bbox4w bounding-box4w :inline :offset 64) + (axis-scale vector :inline :offset 48) + (avg-extents vector :inline :offset 64) + (bucket-array uint32 :offset 44) + (item-array (inline-array collide-hash-item) :overlay-at (-> axis-scale w)) + (dimension-array uint32 3 :overlay-at (-> avg-extents w)) + (num-items uint32 :offset 92) + ) + ) diff --git a/goal_src/jakx/engine/spatial-hash/spatial-hash-h.gc b/goal_src/jakx/engine/spatial-hash/spatial-hash-h.gc index 549f9d9c9d..0e851437d1 100644 --- a/goal_src/jakx/engine/spatial-hash/spatial-hash-h.gc +++ b/goal_src/jakx/engine/spatial-hash/spatial-hash-h.gc @@ -5,5 +5,119 @@ ;; name in dgo: spatial-hash-h ;; dgos: ENGINE, GAME +(declare-type grid-hash-work structure) + ;; DECOMP BEGINS +(deftype grid-hash-word (uint8) + () + ) + +(deftype grid-hash-box (structure) + "Integer coordinate box for the spatial hash grid." + ((min int8 3) + (max int8 3) + ) + :pack-me + ) + + +(deftype grid-hash (basic) + ((work grid-hash-work) + (search-box grid-hash-box :inline) + (bucket-size int16) + (axis-scale float 3) + (dimension-array int8 3) + (vertical-cell-count int8) + (bucket-array (pointer grid-hash-word)) + (box-min float 3) + (box-max float 3) + (object-count int16) + (bucket-count int16) + (min-cell-size float) + (bucket-memory-size int32) + (mem-bucket-array (pointer grid-hash-word)) + (spr-bucket-array (pointer grid-hash-word)) + (debug-draw symbol) + (use-scratch-ram symbol) + ) + (:methods + (new (symbol type) _type_) + (grid-hash-method-9 () none) + (grid-hash-method-10 () none) + (grid-hash-method-11 () none) + (grid-hash-method-12 () none) + (grid-hash-method-13 () none) + (grid-hash-method-14 () none) + (grid-hash-method-15 () none) + (grid-hash-method-16 () none) + (grid-hash-method-17 () none) + (grid-hash-method-18 () none) + (grid-hash-method-19 () none) + (grid-hash-method-20 () none) + (grid-hash-method-21 () none) + (grid-hash-method-22 () none) + (grid-hash-method-23 () none) + (grid-hash-method-24 () none) + (grid-hash-method-25 () none) + (grid-hash-method-26 () none) + ) + ) + + +(deftype find-nav-sphere-ids-params (structure) + ((bsphere sphere :inline) + (y-threshold float) + (len int16) + (max-len int16) + (mask uint8) + (array (pointer uint8)) + ) + ) + + +(deftype sphere-hash (grid-hash) + "An extension of grid hash that holds spheres inside of the grid." + ((sphere-array (inline-array sphere)) + (max-object-count int16) + (pad int16) + (mem-sphere-array uint32) + (spr-sphere-array uint32) + ) + (:methods + (new (symbol type) _type_) + (sphere-hash-method-27 () none) + (sphere-hash-method-28 () none) + (sphere-hash-method-29 () none) + (sphere-hash-method-30 () none) + (sphere-hash-method-31 () none) + (sphere-hash-method-32 () none) + (sphere-hash-method-33 () none) + (sphere-hash-method-34 () none) + (sphere-hash-method-35 () none) + ) + ) + + +(deftype hash-object-info (structure) + ((object basic) + ) + ) + + +(deftype spatial-hash (sphere-hash) + "An extension of sphere-hash that associates an object with each sphere." + ((object-array (inline-array hash-object-info)) + (mem-object-array (inline-array hash-object-info)) + (spr-object-array (inline-array hash-object-info)) + ) + (:methods + (new (symbol type) _type_) + (spatial-hash-method-36 () none) + (spatial-hash-method-37 () none) + (spatial-hash-method-38 () none) + (spatial-hash-method-39 () none) + (spatial-hash-method-40 () none) + (spatial-hash-method-41 () none) + ) + ) diff --git a/goal_src/jakx/engine/ui/gui-h.gc b/goal_src/jakx/engine/ui/gui-h.gc index 0ed924847c..1a8d3f577c 100644 --- a/goal_src/jakx/engine/ui/gui-h.gc +++ b/goal_src/jakx/engine/ui/gui-h.gc @@ -5,5 +5,138 @@ ;; name in dgo: gui-h ;; dgos: ENGINE, GAME +;; +++gui-action +(defenum gui-action + :type uint8 + :bitfield #f + (none 0) + (queue 1) + (play 2) + (playing 3) + (stop 4) + (stopping 5) + (abort 6) + (hide 7) + (hidden 8) + (fade 9) + ) +;; ---gui-action + +;; +++gui-status +(defenum gui-status + :type uint8 ;; not sure + :bitfield #f + (unknown 0) + (pending 1) + (ready 2) + (active 3) + (hide 4) + (stop 5) + ) +;; ---gui-status + +;; +++gui-channel +(defenum gui-channel + :type uint8 + :bitfield #f + (none 0) + (art-load 16) + (art-load-next 17) + (background 18) + (jak 19) + (daxter 20) + (sig 21) + (ashelin 22) + (beast 23) + (jak-effect-1 24) + (pecker 25) + (jak-effect-2 26) + (gun 27) + (hal 28) + (speech 29) + (guard 30) + (jak-mode 31) + (alert 32) + (citizen 33) + (bbush 34) + (rider 35) + (task 36) + (voice 47) + (movie 64) + (blackout 65) + (query 66) + (message 67) + (notice 68) + (subtitle 69) + (supertitle 70) + (notice-low 71) + (resetter 72) + (progress 73) + (freeze 74) + (subtitle-pc 78) ;; custom + (screen 79) + (hud-upper-right 80) + (hud-upper-left 81) + (hud-lower-right 82) + (hud-lower-left 83) + (hud-lower-left-1 84) + (hud-lower-left-2 85) + (hud-center-right 86) + (hud-center-left 87) + (hud-middle-right 88) + (hud-middle-left 89) + (hud-upper-center 90) + (hud-upper-center-2 91) + (hud-lower-center 92) + (hud-auto-save 93) + (hud-auto-save-message 94) + (hud 95) + (hud-mp-vehicle-main-0 96) + (hud-mp-vehicle-main-1 97) + (hud-mp-player-indicators-0 98) + (hud-mp-player-indicators-1 99) + (hud-mp-race-0 100) + (hud-mp-race-1 101) + (hud-mp-race-2 102) + (hud-mp-race-3 103) + (max 112) + ) +;; ---gui-channel + +;; +++gui-connection-flags +(defenum gui-connection-flags + :type uint8 + :bitfield #t + (gcf0 0) + (gcf1 1) + (fo-curve 2) + (fo-min 3) + (fo-max 4) + (volume 5) + ) +;; ---gui-connection-flags + ;; DECOMP BEGINS +(deftype gui-connection (connection) + ((priority float :overlay-at param0) + (action gui-action :overlay-at param1) + (channel gui-channel :offset 21) + (anim-part uint8 :offset 22) + (flags gui-connection-flags :offset 23) + (name string :overlay-at param2) + (id sound-id :overlay-at param3) + (handle handle :overlay-at next0) + (time-stamp time-frame :overlay-at next1) + (hold-time time-frame) + (fo-min float) + (fo-max float) + (fo-power float) + (fade uint8) + (volume float) + (qw-pad int8 4) + ) + ) + + +;; type gui-control is defined here, but it is unknown to the decompiler diff --git a/goal_src/jakx/engine/ui/hud-h.gc b/goal_src/jakx/engine/ui/hud-h.gc index d08a9e2f08..f928f2e8da 100644 --- a/goal_src/jakx/engine/ui/hud-h.gc +++ b/goal_src/jakx/engine/ui/hud-h.gc @@ -5,5 +5,28 @@ ;; name in dgo: hud-h ;; dgos: ENGINE, GAME +;; +++hud-sprite-flags +(defenum hud-sprite-flags + :type uint16 + :bitfield #t + (hsf0 0) + (hsf1 1) + (hsf2 2) + (hsf3 3) + (hsf4 4) + (hsf5 5) + (hsf6 6) + (hsf7 7) + (hsf8 8) + (hsf9 9) + (hsf10 10) + (hsf11 11) + (hsf12 12) + (hsf13 13) + (hsf14 14) + (hsf15 15) + ) +;; ---hud-sprite-flags + ;; DECOMP BEGINS diff --git a/goal_src/jakx/engine/ui/minimap-h.gc b/goal_src/jakx/engine/ui/minimap-h.gc index 553098be3a..d269ccb462 100644 --- a/goal_src/jakx/engine/ui/minimap-h.gc +++ b/goal_src/jakx/engine/ui/minimap-h.gc @@ -5,5 +5,120 @@ ;; name in dgo: minimap-h ;; dgos: ENGINE, GAME +;; +++minimap-flag +(defenum minimap-flag + :type uint32 + :bitfield #t + (active 0) + (minimap 1) + (fade-in 2) + (fade-out 3) + (task-graph 4) + (flash 5) + (racer 6) + ) +;; ---minimap-flag + + +;; +++minimap-class +(defenum minimap-class + :type uint16 + (none 0) + (racer-0 1) + (racer-1 2) + (racer-2 3) + (racer-3 4) + (racer-4 5) + (racer-5 6) + (racer-6 7) + (raptor 8) + (goal 9) + (red-flag 10) + (blue-flag 11) + (neutral-flag 12) + (success-seeker 13) + (chicken-drone 14) +) +;; ---minimap-class + + ;; DECOMP BEGINS +(deftype minimap-class-node (structure) + ((default-position vector :inline) + (flags minimap-flag) + (name string) + (icon-xy vector2ub :inline) + (class minimap-class) + (scale float) + (color rgba) + ) + (:methods + (minimap-class-node-method-9 (_type_) symbol) + ) + ) + + +(deftype connection-minimap (connection-pers) + ((next connection-minimap :override) + (handle handle :overlay-at update-time) + (position vector :overlay-at (-> param 0)) + (alpha float :overlay-at (-> param 1)) + (flags minimap-flag :overlay-at (-> param 2)) + (class minimap-class-node :overlay-at (-> param 3)) + (node uint16) + (edge-ry int16) + (last-world-pos vector :inline) + ) + ) + + +(deftype engine-minimap (engine-pers) + ((alive-list connection-minimap :override) + (dead-list connection-minimap :override) + ) + ) + + +(deftype minimap-draw-work (structure) + ((buf dma-buffer) + (global-flags uint32) + (draw-pos vector4w :inline) + (mat matrix :inline) + (corner vector 4 :inline) + (vec vector :inline) + (pos vector :inline) + (mid-val float) + ) + ) + + +(deftype minimap (structure) + ((draw-tmpl dma-gif-packet :inline) + (sprite-tmpl dma-gif-packet :inline) + (sprite2-tmpl dma-gif-packet :inline) + (adgif-tmpl dma-gif-packet :inline) + (color vector4w :inline) + (tex-coords bounding-box2 :inline) + (race-corner vector :inline) + (mat matrix :inline) + (tex-offset vector2 :inline) + (race-tex texture) + (race-scale float) + (meters-per-texel float) + (icon-inv-scale float) + (fade float) + (goal-time float) + (engine engine-minimap) + (engine-key uint32) + ) + (:methods + (minimap-method-9 () none) + (minimap-method-10 () none) + (minimap-method-11 () none) + (minimap-method-12 () none) + (minimap-method-13 () none) + (minimap-method-14 () none) + (minimap-method-15 () none) + ) + ) diff --git a/goal_src/jakx/engine/ui/progress/progress-h.gc b/goal_src/jakx/engine/ui/progress/progress-h.gc index 10ad099107..4cb7fb544e 100644 --- a/goal_src/jakx/engine/ui/progress/progress-h.gc +++ b/goal_src/jakx/engine/ui/progress/progress-h.gc @@ -6,4 +6,3 @@ ;; dgos: ENGINE, GAME ;; DECOMP BEGINS - diff --git a/goal_src/jakx/engine/ui/text-h.gc b/goal_src/jakx/engine/ui/text-h.gc index 54a9187fa0..56f9b99d93 100644 --- a/goal_src/jakx/engine/ui/text-h.gc +++ b/goal_src/jakx/engine/ui/text-h.gc @@ -7,3 +7,34 @@ ;; DECOMP BEGINS +(deftype game-text (structure) + ((id text-id) + (text string) + ) + :pack-me + ) + + +(deftype game-text-info (basic) + ((length int32) + (language-id int32) + (group-name string) + (dic-index uint32) + (dic-data uint32) + (text uint32) + (text-data uint32) + ) + (:methods + (game-text-info-method-9 () none) + (game-text-info-method-10 () none) + (game-text-info-method-11 () none) + (game-text-info-method-12 () none) + ) + ) + + +(define *text-group-names* (new 'static 'boxed-array :type string "common")) + +(define *common-text-heap* (new 'global 'kheap)) + +(define *common-text* (the-as game-text-info #f)) diff --git a/goal_src/jakx/engine/util/capture-h.gc b/goal_src/jakx/engine/util/capture-h.gc index c9c7ff8ce0..34dbc006ca 100644 --- a/goal_src/jakx/engine/util/capture-h.gc +++ b/goal_src/jakx/engine/util/capture-h.gc @@ -7,3 +7,61 @@ ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) + +(deftype gs-store-image-packet (structure) + ((vifcode vif-tag 4) + (giftag gif-tag) + (bitbltbuf gs-bitbltbuf) + (bitbltbuf-addr gs-reg64) + (trxpos gs-trxpos) + (trxpos-addr gs-reg64) + (trxreg gs-trxreg) + (trxreg-addr gs-reg64) + (finish uint64) + (finish-addr gs-reg64) + (trxdir gs-trxdir) + (trxdir-addr gs-reg64) + ) + ) + + +(deftype screen-shot-work (structure) + ((count int16) + (size int16) + (name string) + (highres-enable symbol) + (highres-objects-enable symbol) + (hud-enable symbol) + (letterbox-enable symbol) + (debug-enable symbol) + (dir basic) + (dir-checked? symbol) + ) + ) + + +(define *screen-shot-work* (new 'global 'screen-shot-work)) + +(set! (-> *screen-shot-work* count) -1) + +(set! (-> *screen-shot-work* size) -1) + +(set! (-> *screen-shot-work* highres-enable) #f) + +(set! (-> *screen-shot-work* highres-objects-enable) #f) + +(set! (-> *screen-shot-work* hud-enable) #f) + +(set! (-> *screen-shot-work* letterbox-enable) #f) + +(set! (-> *screen-shot-work* debug-enable) #f) + +(set! (-> *screen-shot-work* dir) #f) + +(set! (-> *screen-shot-work* dir-checked?) #f) + +(define *image-name* (new 'global 'string 128 (the-as string #f))) + +(define *capture-tga-buffer* (the-as object #f)) diff --git a/goal_src/jakx/engine/util/profile-h.gc b/goal_src/jakx/engine/util/profile-h.gc index 1681e3b342..ec35eb347d 100644 --- a/goal_src/jakx/engine/util/profile-h.gc +++ b/goal_src/jakx/engine/util/profile-h.gc @@ -5,5 +5,139 @@ ;; name in dgo: profile-h ;; dgos: ENGINE, GAME +(declare-type dma-buffer structure) +(define-extern *display-profile* symbol) +(define-extern *stats-profile-bars* symbol) +(define-extern *display-capture-mode* symbol) + ;; DECOMP BEGINS +(deftype profile-segment (structure) + "Confusingly, this has two uses. Either a single event, or a summary of all events within a category." + ((name symbol) + (start-time int16) + (end-time int16) + (count uint8) + (vu-count uint8) + (depth uint16) + (color rgba) + (code-time uint16 :overlay-at start-time) + (vu-time uint16 :overlay-at end-time) + ) + :allow-misaligned + ) + + +(deftype profile-collapse (structure) + "An array of 'summaries'. Each entry in data is a summary of all events within a category." + ((count int32) + (data profile-segment 48 :inline) + ) + ) + + +(deftype profile-segment-array (basic) + "All profiling data for a frame, stored as a tree of events. There is one for the VU, and one for the EE." + ((count int16) + (depth int8) + (max-depth int8) + (base-time int16) + (segment profile-segment 9) + (data profile-segment 1024 :inline) + ) + (:methods + (get-total-time (_type_) int) + (start-frame! (_type_) none) + (start-segment! (_type_ symbol rgba) none) + (end-segment! (_type_) none) + ) + ) + + +(deftype profile-array (structure) + "The EE and VU profilers, and the drawing code." + ((data profile-segment-array 2) + ) + (:methods + (postprocess-data! (_type_) none) + (draw-bars! (_type_ dma-buffer int) none) + (draw-text! (_type_) none) + ) + ) + + +(defmethod get-total-time ((this profile-segment-array)) + "Get the duration of the top-level event (typically, the whole frame)" + (- (-> this data 0 end-time) (-> this data 0 start-time)) + ) + +(deftype profile-spec (structure) + "Specification for a profile category." + ((name symbol) + (color rgba) + ) + ) + + +(define *profile-gap-color* (new 'static 'rgba :r #x30 :g #x30 :b #x30 :a #x80)) + +(define *profile-all-color* (new 'static 'rgba :r #x55 :g #x55 :b #x55 :a #x80)) + +(define *profile-blit-color* (new 'static 'rgba :r #x20 :g #x20 :b #x80 :a #x80)) + +(define *profile-sky-color* (new 'static 'rgba :r #x20 :g #x80 :b #x20 :a #x80)) + +(define *profile-ocean-color* (new 'static 'rgba :r #x20 :g #x80 :b #x80 :a #x80)) + +(define *profile-tfrag-color* (new 'static 'rgba :r #x80 :g #x20 :b #x80 :a #x80)) + +(define *profile-texture-color* (new 'static 'rgba :r #x80 :g #x80 :b #x20 :a #x80)) + +(define *profile-tie-color* (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)) + +(define *profile-generic-color* (new 'static 'rgba :r #x70 :g #x70 :a #x80)) + +(define *profile-merc-color* (new 'static 'rgba :r #x70 :b #x70 :a #x80)) + +(define *profile-shrubbery-color* (new 'static 'rgba :r #x70 :a #x80)) + +(define *profile-particle-color* (new 'static 'rgba :g #x70 :b #x70 :a #x80)) + +(define *profile-debug-color* (new 'static 'rgba :g #x70 :a #x80)) + +(define *profile-other-color* (new 'static 'rgba :g #x70 :b #x70 :a #x80)) + +(define *profile-joints-color* (new 'static 'rgba :r #x70 :g #x70 :b #x20 :a #x80)) + +(define *profile-draw-hook-color* (new 'static 'rgba :r #x20 :g #x70 :b #x70 :a #x80)) + +(define *profile-background-color* (new 'static 'rgba :r #x60 :g #x60 :b #x40 :a #x80)) + +(define *profile-foreground-color* (new 'static 'rgba :r #x40 :g #x60 :b #x60 :a #x80)) + +(define *profile-bones-color* (new 'static 'rgba :r #x20 :g #x80 :b #x60 :a #x80)) + +(define *profile-actors-color* (new 'static 'rgba :r #x80 :g #x10 :b #x70 :a #x80)) + +(define *profile-collide-color* (new 'static 'rgba :r #x80 :g #x40 :b #x80 :a #x80)) + +(define *profile-nav-color* (new 'static 'rgba :r #x38 :g #x48 :b #x80 :a #x80)) + +(define *profile-camera-color* (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)) + +(define *profile-gs-sync-color* (new 'static 'rgba :r #x70 :g #x70 :b #x70 :a #x80)) + +(when *debug-segment* +(define *profile-array* (new 'debug 'profile-array)) + +(set! (-> *profile-array* data 0) (new 'debug 'profile-segment-array)) + +(set! (-> *profile-array* data 1) (new 'debug 'profile-segment-array)) + +(define *profile-collapse* (new 'debug 'profile-collapse)) + +(define *profile-interrupt-segment* (-> *profile-array* data 1)) + +(define *profile-interrupt-start* #f) + +) diff --git a/goal_src/jakx/engine/util/script-h.gc b/goal_src/jakx/engine/util/script-h.gc index 7a2f26bb8a..4a19c020dd 100644 --- a/goal_src/jakx/engine/util/script-h.gc +++ b/goal_src/jakx/engine/util/script-h.gc @@ -5,5 +5,71 @@ ;; name in dgo: script-h ;; dgos: ENGINE, GAME +(declare-type script-context structure) +(define-extern *syntax-context* script-context) +(define-extern *script-context* script-context) + +(declare-type script-context structure) +(declare-type load-state structure) +(define-extern *load-state* load-state) + +(defmacro script-eval (script &key (key (process->ppointer PP)) &key (proc PP) &key (vector (the-as vector #f))) + `(eval! (new 'stack 'script-context ,key ,proc ,vector) ,script)) + +(define-extern command-get-int (function object int int)) +(define-extern command-get-float (function object float float)) +(define-extern command-get-param (function object object object)) +(define-extern command-get-process (function object process process)) + ;; DECOMP BEGINS +(deftype script-form (structure) + ((name symbol) + (spec pair) + (func (function script-context object)) + ) + :pack-me + (:methods + (script-form-method-9 () none) + ) + ) + + +(deftype script-context (structure) + ((load-state load-state) + (key object) + (process process) + (trans vector) + (side-effect? symbol) + (got-error? symbol) + (expr pair) + (param-count int32) + (param object 16) + (param-type object 16) + ) + (:methods + (new (symbol type object process vector) _type_) + (eval! (_type_ pair) object) + (script-context-method-10 (_type_ object pair) object) + (script-context-method-11 (_type_ pair pair symbol) symbol) + ) + ) + + +;; WARN: Return type mismatch structure vs script-context. +(defmethod new script-context ((allocation symbol) (type-to-make type) (arg0 object) (arg1 process) (arg2 vector)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + (let ((v0-0 (t9-0 allocation v1-1))) + (set! (-> (the-as script-context v0-0) key) arg0) + (set! (-> (the-as script-context v0-0) process) arg1) + (set! (-> (the-as script-context v0-0) load-state) *load-state*) + (set! (-> (the-as script-context v0-0) side-effect?) #t) + (set! (-> (the-as script-context v0-0) got-error?) #f) + (set! (-> (the-as script-context v0-0) trans) arg2) + (the-as script-context v0-0) + ) + ) + ) diff --git a/goal_src/jakx/engine/util/smush-control-h.gc b/goal_src/jakx/engine/util/smush-control-h.gc index 4703ad4bd7..bf2c16ff56 100644 --- a/goal_src/jakx/engine/util/smush-control-h.gc +++ b/goal_src/jakx/engine/util/smush-control-h.gc @@ -7,3 +7,117 @@ ;; DECOMP BEGINS +(deftype smush-control (structure) + "This holds information about the current state of an object's smush." + ((start-time time-frame) + (period float) + (duration float) + (amp float) + (damp-amp float) + (damp-period float) + (ticks float) + ) + (:methods + (set-zero! (_type_) _type_) + (update! (_type_) float) + (get-no-update (_type_) float) + (activate! (_type_ float int int float float clock) _type_) + (nonzero-amplitude? (_type_) symbol) + (die-on-next-update! (_type_) _type_) + ) + ) + + +(defmethod nonzero-amplitude? ((this smush-control)) + "Is the smush currently active?" + (!= (-> this amp) 0.0) + ) + +(defmethod set-zero! ((this smush-control)) + "Reset this [[smush-control]]." + (set! (-> this period) 0.0) + (set! (-> this duration) 0.0) + (set! (-> this amp) 0.0) + (set! (-> this damp-amp) 0.0) + (set! (-> this damp-period) 0.0) + (set! (-> this ticks) 0.0) + this + ) + +(defmethod update! ((this smush-control)) + "Calculate the next smush amplitude and update the smush state." + (cond + ((!= (-> this amp) 0.0) + (let* ((elapsed-time (the float (- (current-time) (-> this start-time)))) + (period (-> this period)) + (f28-0 (- elapsed-time (* (the float (the int (/ elapsed-time period))) period))) + ) + (when (>= (- elapsed-time (-> this ticks)) (-> this period)) + (set! (-> this amp) (* (-> this amp) (-> this damp-amp))) + (set! (-> this period) (* (-> this period) (-> this damp-period))) + (set! (-> this ticks) elapsed-time) + (if (< (-> this damp-period) 0.0) + (set-zero! this) + ) + ) + (if (>= elapsed-time (-> this duration)) + (set-zero! this) + ) + (* (sin (/ (* 65536.0 f28-0) (-> this period))) + (* (-> this amp) (/ (- (-> this duration) elapsed-time) (-> this duration))) + ) + ) + ) + (else + 0.0 + ) + ) + ) + +(defmethod get-no-update ((this smush-control)) + "Get the next amplitude, but do not update the smush state." + (cond + ((!= (-> this amp) 0.0) + (let* ((elapsed-time (the float (- (current-time) (-> this start-time)))) + (period (-> this period)) + (f0-4 (- elapsed-time (* (the float (the int (/ elapsed-time period))) period))) + ) + (* (sin (/ (* 65536.0 f0-4) (-> this period))) + (* (-> this amp) (/ (- (-> this duration) elapsed-time) (-> this duration))) + ) + ) + ) + (else + 0.0 + ) + ) + ) + +(defmethod die-on-next-update! ((this smush-control)) + "Set the dampening period so the smush stops on the next update." + (if (!= (-> this amp) 0.0) + (set! (-> this damp-period) -1.0) + ) + this + ) + +(defmethod activate! ((this smush-control) + (amplitude float) + (period int) + (duration int) + (damp-amplitude float) + (damp-period float) + (clock clock) + ) + "Start the smush with the given parameters." + (when (>= (fabs (/ (-> this amp) 5)) (fabs (get-no-update this))) + (set! (-> this amp) amplitude) + (set! (-> this period) (the float period)) + (set! (-> this duration) (the float duration)) + (set! (-> this damp-amp) damp-amplitude) + (set! (-> this damp-period) damp-period) + (set! (-> this ticks) 0.0) + (set! (-> this start-time) (-> clock frame-counter)) + ) + this + ) diff --git a/goal_src/jakx/engine/util/types-h.gc b/goal_src/jakx/engine/util/types-h.gc index 2705c8f5e0..007dc85da9 100644 --- a/goal_src/jakx/engine/util/types-h.gc +++ b/goal_src/jakx/engine/util/types-h.gc @@ -3,7 +3,130 @@ ;; name: types-h.gc ;; name in dgo: types-h -;; dgos: ENGINE, GAME +;; dgos: GAME + +(defmacro s.w! (location value) + "Utility macro to store a 32-bit value at a given address. Performs _no_ type checking." + `(set! (-> (the-as (pointer uint32) ,location) 0) (the-as uint32 ,value)) + ) + +(defmacro l.wu (location) + "Load an unsigned 32-bit value from a given address. Performs _no_ type checking." + `(-> (the-as (pointer uint32) ,location) 0) + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Common Units +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; in-game durations, distances, and rotations are stored in special formats. +;; these macros/constants convert from literals to the correct format. +;; for example, (meters 4.0) will give you a distance representing 4 in-game meters. + +;; meters are stored as (usually) a float, scaled by 4096. +;; this gives you reasonable accuracy as an integer. +(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. + Returns float." + + ;; we don't have enough constant propagation for the compiler to figure this out. + (cond + ((float? x) + (* METER_LENGTH x) + ) + ((integer? x) + (* METER_LENGTH x) + ) + (#t + `(* METER_LENGTH ,x) + ) + ) + ) + +;; rotations are stored in 65,536ths of a full rotation. +;; like with meters, you get a reasonable accuracy as an integer. +;; additionally, it is a power-of-two, so wrapping rotations can be done +;; quickly by converting to an int, masking, and back to float +(defglobalconstant DEGREES_PER_ROT 65536.0) + +;; this was deg in GOAL +(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 + ) + ) + ) + ) + +(defmacro fsec (x) + "Convert number to seconds unit. + Returns float." + (cond + ((or (integer? x) (float? x)) + (* 1.0 TICKS_PER_SECOND x) + ) + (#t + `(* 1.0 TICKS_PER_SECOND ,x) + ) + ) + ) + ;; DECOMP BEGINS +(deftype basic-reserved (basic) + () + (:methods + (basic-reserved-method-9 () none) + (basic-reserved-method-10 () none) + (basic-reserved-method-11 () none) + (basic-reserved-method-12 () none) + (basic-reserved-method-13 () none) + (basic-reserved-method-14 () none) + (basic-reserved-method-15 () none) + (basic-reserved-method-16 () none) + (basic-reserved-method-17 () none) + (basic-reserved-method-18 () none) + (basic-reserved-method-19 () none) + (basic-reserved-method-20 () none) + (basic-reserved-method-21 () none) + (basic-reserved-method-22 () none) + (basic-reserved-method-23 () none) + (basic-reserved-method-24 () none) + (basic-reserved-method-25 () none) + (basic-reserved-method-26 () none) + (basic-reserved-method-27 () none) + (basic-reserved-method-28 () none) + ) + ) + +(deftype part-id (uint32) + () + ) + +;; og:preserve-this +;; unused, and not supported in the compiler, since the linker would need to link to the type object, which +;; means the type needs to be allocated, and we'd need to know the number of methods. +;; technically, the compiler does support this through the `(type-ref sage-finalboss :method-count 53)` feature, +;; but it seems like too much work to support this in the decompiler for an array that's not even used... +; (new 'static 'boxed-array :type type +; pilot-info +; flut-info +; mech-info +; turret-info +; indax-info +; tube-info +; race-mesh +; ) \ No newline at end of file diff --git a/goal_src/jakx/engine/vehicle/car-info-h.gc b/goal_src/jakx/engine/vehicle/car-info-h.gc index e878a55c4d..2874b36456 100644 --- a/goal_src/jakx/engine/vehicle/car-info-h.gc +++ b/goal_src/jakx/engine/vehicle/car-info-h.gc @@ -5,5 +5,27 @@ ;; name in dgo: car-info-h ;; dgos: ENGINE, GAME +;; +++vehicle-type +(defenum vehicle-type + :type uint8 + (mongoose 0) + (falcon 1) + (wombat 2) + (possum 3) + (bobcat 4) + (cougar 5) + (wolf 6) + (bear 7) + (leopard 8) + (panther 9) + (tiger 10) + (cheetah 11) + (gila 12) + (snake 13) + (daxtermobile 14) +) +;; ---vehicle-type + + ;; DECOMP BEGINS diff --git a/goal_src/jakx/game.gp b/goal_src/jakx/game.gp index 68fbba736c..8e1f6f38a5 100644 --- a/goal_src/jakx/game.gp +++ b/goal_src/jakx/game.gp @@ -84,11 +84,11 @@ ;; DGOs ;;;;;;;;;;;;;;;;;;;;; -(defstep :in "$DECOMP/textures/tpage-dir.txt" - :tool 'tpage-dir - :out '("$OUT/obj/dir-tpages.go") - ) -(hash-table-set! *file-entry-map* "dir-tpages.go" #f) +;; (defstep :in "$DECOMP/textures/tpage-dir.txt" +;; :tool 'tpage-dir +;; :out '("$OUT/obj/dir-tpages.go") +;; ) +;; (hash-table-set! *file-entry-map* "dir-tpages.go" #f) (cgo-file "game.gd" '("$OUT/obj/gcommon.o" "$OUT/obj/gstate.o" "$OUT/obj/gstring.o" "$OUT/obj/gkernel.o")) @@ -96,375 +96,375 @@ ;; the case of a .o appearing in multiple dgos. But, if we depend on the last item in both lists, it ;; works out. -(define common-dep '("$OUT/obj/jakx-init.o")) +(define common-dep '("$OUT/obj/minimap.o")) ;; generated via `scripts/gsrc/skeleton_creation/generate_dgo_proj.py -(cgo-file "clfx.gd" common-dep) -(cgo-file "swx.gd" common-dep) -(cgo-file "cyc.gd" common-dep) -(cgo-file "tpc.gd" common-dep) -(cgo-file "dromett.gd" common-dep) -(cgo-file "ximlev.gd" common-dep) -(cgo-file "pecvl.gd" common-dep) -(cgo-file "dkb.gd" common-dep) -(cgo-file "kcrsclct.gd" common-dep) -(cgo-file "spa.gd" common-dep) -(cgo-file "dockfoot.gd" common-dep) -(cgo-file "sewerw.gd" common-dep) -(cgo-file "thacred.gd" common-dep) -(cgo-file "ashcred.gd" common-dep) -(cgo-file "krass.gd" common-dep) -(cgo-file "jgc.gd" common-dep) -(cgo-file "leopl.gd" common-dep) -(cgo-file "csy.gd" common-dep) -(cgo-file "icefoot.gd" common-dep) -(cgo-file "spx.gd" common-dep) -(cgo-file "peakw.gd" common-dep) -(cgo-file "hva.gd" common-dep) -(cgo-file "icebfoot.gd" common-dep) -(cgo-file "jungtrn.gd" common-dep) -(cgo-file "cyy.gd" common-dep) -(cgo-file "daxlev.gd" common-dep) -(cgo-file "havtours.gd" common-dep) -(cgo-file "icy.gd" common-dep) -(cgo-file "thbvl.gd" common-dep) -(cgo-file "dromdocs.gd" common-dep) -(cgo-file "dke.gd" common-dep) -(cgo-file "clifhunt.gd" common-dep) -(cgo-file "sewfoot.gd" common-dep) -(cgo-file "pkx.gd" common-dep) -(cgo-file "cnspfoot.gd" common-dep) -(cgo-file "dkc.gd" common-dep) -(cgo-file "temptbox.gd" common-dep) -(cgo-file "jgy.gd" common-dep) -(cgo-file "krastbox.gd" common-dep) -(cgo-file "krasfoot.gd" common-dep) -(cgo-file "dsrx.gd" common-dep) -(cgo-file "cyd.gd" common-dep) -(cgo-file "desisles.gd" common-dep) -(cgo-file "razcred.gd" common-dep) -(cgo-file "tpa.gd" common-dep) -(cgo-file "falcl.gd" common-dep) -(cgo-file "cheel.gd" common-dep) -(cgo-file "krattbox.gd" common-dep) -(cgo-file "jungtbox.gd" common-dep) -(cgo-file "sigvl3.gd" common-dep) -(cgo-file "ur8cred.gd" common-dep) -(cgo-file "havenw.gd" common-dep) -(cgo-file "ratlev.gd" common-dep) -(cgo-file "jungfoot.gd" common-dep) -(cgo-file "templew.gd" common-dep) -(cgo-file "klevl2.gd" common-dep) -(cgo-file "spc.gd" common-dep) -(cgo-file "kcrosctf.gd" common-dep) -(cgo-file "cliffart.gd" common-dep) -(cgo-file "swc.gd" common-dep) -(cgo-file "canyonw.gd" common-dep) -(cgo-file "jaklev.gd" common-dep) -(cgo-file "jakcred.gd" common-dep) -(cgo-file "kratourw.gd" common-dep) -(cgo-file "eightb.gd" common-dep) -(cgo-file "swd.gd" common-dep) -(cgo-file "snowtt.gd" common-dep) -(cgo-file "hvtrtt.gd" common-dep) -(cgo-file "coliseus.gd" common-dep) -(cgo-file "pkd.gd" common-dep) -(cgo-file "colart.gd" common-dep) -(cgo-file "possl.gd" common-dep) -(cgo-file "krastrn.gd" common-dep) -(cgo-file "ashvl.gd" common-dep) -(cgo-file "dromew.gd" common-dep) -(cgo-file "hvswtbox.gd" common-dep) -(cgo-file "sigvl.gd" common-dep) -(cgo-file "sparfoot.gd" common-dep) -(cgo-file "sptmtt.gd" common-dep) -(cgo-file "dkx.gd" common-dep) -(cgo-file "hvd.gd" common-dep) -(cgo-file "snw.gd" common-dep) -(cgo-file "brdroom.gd" common-dep) -(cgo-file "icc.gd" common-dep) -(cgo-file "sewers.gd" common-dep) -(cgo-file "garage.gd" common-dep) -(cgo-file "ashvl2.gd" common-dep) -(cgo-file "jkclev.gd" common-dep) -(cgo-file "jakvl.gd" common-dep) -(cgo-file "dra.gd" common-dep) -(cgo-file "kaelev.gd" common-dep) -(cgo-file "thbcred.gd" common-dep) -(cgo-file "thbvl2.gd" common-dep) -(cgo-file "pkb.gd" common-dep) -(cgo-file "spatours.gd" common-dep) -(cgo-file "dkkrtbox.gd" common-dep) -(cgo-file "klecred.gd" common-dep) -(cgo-file "dockstt.gd" common-dep) -(cgo-file "snowtrn2.gd" common-dep) -(cgo-file "icebergs.gd" common-dep) -(cgo-file "cnsptbox.gd" common-dep) -(cgo-file "spe.gd" common-dep) -(cgo-file "swe.gd" common-dep) -(cgo-file "drd.gd" common-dep) -(cgo-file "clf.gd" common-dep) -(cgo-file "thavl.gd" common-dep) -(cgo-file "atl.gd" common-dep) -(cgo-file "tpy.gd" common-dep) -(cgo-file "cye.gd" common-dep) -(cgo-file "snakl.gd" common-dep) -(cgo-file "ashlev.gd" common-dep) -(cgo-file "krx.gd" common-dep) -(cgo-file "jgx.gd" common-dep) -(cgo-file "hvy.gd" common-dep) -(cgo-file "csx.gd" common-dep) -(cgo-file "hve.gd" common-dep) -(cgo-file "jkalev.gd" common-dep) -(cgo-file "canspars.gd" common-dep) -(cgo-file "raycred.gd" common-dep) -(cgo-file "dsi.gd" common-dep) -(cgo-file "icettbox.gd" common-dep) -(cgo-file "spy.gd" common-dep) -(cgo-file "icetrn.gd" common-dep) -(cgo-file "torvl3.gd" common-dep) -(cgo-file "icetourw.gd" common-dep) -(cgo-file "sbwlctf.gd" common-dep) -(cgo-file "jungles.gd" common-dep) -(cgo-file "pka.gd" common-dep) -(cgo-file "dsr.gd" common-dep) -(cgo-file "tpe.gd" common-dep) -(cgo-file "ur8vl.gd" common-dep) -(cgo-file "ica.gd" common-dep) -(cgo-file "icew.gd" common-dep) -(cgo-file "dromtbox.gd" common-dep) -(cgo-file "credits.gd" common-dep) -(cgo-file "sigvl2.gd" common-dep) -(cgo-file "spartems.gd" common-dep) -(cgo-file "dromex.gd" common-dep) -(cgo-file "havnfoot.gd" common-dep) -(cgo-file "icebtbox.gd" common-dep) -(cgo-file "havtfoot.gd" common-dep) -(cgo-file "menumap.gd" common-dep) -(cgo-file "icetbox.gd" common-dep) -(cgo-file "snobart.gd" common-dep) -(cgo-file "eight.gd" common-dep) -(cgo-file "wombl.gd" common-dep) -(cgo-file "desart.gd" common-dep) -(cgo-file "dethrace.gd" common-dep) -(cgo-file "cliftrn.gd" common-dep) -(cgo-file "spb.gd" common-dep) -(cgo-file "desrapt.gd" common-dep) -(cgo-file "kielev.gd" common-dep) -(cgo-file "deshunt.gd" common-dep) -(cgo-file "wolfl.gd" common-dep) -(cgo-file "havntbox.gd" common-dep) -(cgo-file "icx.gd" common-dep) -(cgo-file "razlev.gd" common-dep) -(cgo-file "icett.gd" common-dep) -(cgo-file "icd.gd" common-dep) -(cgo-file "keicred.gd" common-dep) -(cgo-file "hvc.gd" common-dep) -(cgo-file "fmvlev.gd" common-dep) -(cgo-file "hsy.gd" common-dep) -(cgo-file "peclev.gd" common-dep) -(cgo-file "foxl.gd" common-dep) -(cgo-file "pkc.gd" common-dep) -(cgo-file "dromdocw.gd" common-dep) -(cgo-file "drx.gd" common-dep) -(cgo-file "krastt.gd" common-dep) -(cgo-file "desactf.gd" common-dep) -(cgo-file "raceweap.gd" common-dep) -(cgo-file "klevl.gd" common-dep) -(cgo-file "spargusw.gd" common-dep) -(cgo-file "ur8vl2.gd" common-dep) -(cgo-file "daxcred.gd" common-dep) -(cgo-file "tpb.gd" common-dep) -(cgo-file "desarens.gd" common-dep) -(cgo-file "jgf.gd" common-dep) -(cgo-file "col.gd" common-dep) -(cgo-file "hvjgtbox.gd" common-dep) -(cgo-file "gtbvl.gd" common-dep) -(cgo-file "colirev.gd" common-dep) -(cgo-file "temples.gd" common-dep) -(cgo-file "jgg.gd" common-dep) -(cgo-file "peakfoot.gd" common-dep) -(cgo-file "thcvl.gd" common-dep) -(cgo-file "sty.gd" common-dep) -(cgo-file "drdx.gd" common-dep) -(cgo-file "torlev.gd" common-dep) -(cgo-file "turtl.gd" common-dep) -(cgo-file "colictf.gd" common-dep) -(cgo-file "havtourw.gd" common-dep) -(cgo-file "desclct.gd" common-dep) -(cgo-file "jge.gd" common-dep) -(cgo-file "deshunt2.gd" common-dep) -(cgo-file "thcvl2.gd" common-dep) -(cgo-file "swf.gd" common-dep) -(cgo-file "krc.gd" common-dep) -(cgo-file "drone.gd" common-dep) -(cgo-file "dockss.gd" common-dep) -(cgo-file "disleart.gd" common-dep) -(cgo-file "dromfoot.gd" common-dep) -(cgo-file "dockkraw.gd" common-dep) -(cgo-file "jgb.gd" common-dep) -(cgo-file "hsx.gd" common-dep) -(cgo-file "bobcl.gd" common-dep) -(cgo-file "atollctf.gd" common-dep) -(cgo-file "krb.gd" common-dep) -(cgo-file "clifctf.gd" common-dep) -(cgo-file "rayvl2.gd" common-dep) -(cgo-file "hvjgtt.gd" common-dep) -(cgo-file "thavl2.gd" common-dep) -(cgo-file "colx.gd" common-dep) -(cgo-file "jga.gd" common-dep) -(cgo-file "cya.gd" common-dep) -(cgo-file "hvb.gd" common-dep) -(cgo-file "sptrtt.gd" common-dep) -(cgo-file "siglev.gd" common-dep) -(cgo-file "templett.gd" common-dep) -(cgo-file "thccred.gd" common-dep) -(cgo-file "iceptbox.gd" common-dep) -(cgo-file "coliclct.gd" common-dep) -(cgo-file "icbgtt.gd" common-dep) -(cgo-file "torvl2.gd" common-dep) -(cgo-file "peaks.gd" common-dep) -(cgo-file "thalev.gd" common-dep) -(cgo-file "hvx.gd" common-dep) -(cgo-file "thavl3.gd" common-dep) -(cgo-file "peaktbox.gd" common-dep) -(cgo-file "spatourw.gd" common-dep) -(cgo-file "sewtbox.gd" common-dep) -(cgo-file "canfoot.gd" common-dep) -(cgo-file "cnsptt.gd" common-dep) -(cgo-file "havtt.gd" common-dep) -(cgo-file "cliffss.gd" common-dep) -(cgo-file "ibx.gd" common-dep) -(cgo-file "gtbcred.gd" common-dep) -(cgo-file "atoplow.gd" common-dep) -(cgo-file "dkky.gd" common-dep) -(cgo-file "rth.gd" common-dep) -(cgo-file "s2a.gd" common-dep) -(cgo-file "junglett.gd" common-dep) -(cgo-file "jkblev.gd" common-dep) -(cgo-file "krtrtt.gd" common-dep) -(cgo-file "snox.gd" common-dep) -(cgo-file "dkkrtt.gd" common-dep) -(cgo-file "docktbox.gd" common-dep) -(cgo-file "dkkx.gd" common-dep) -(cgo-file "snobowls.gd" common-dep) -(cgo-file "sparguss.gd" common-dep) -(cgo-file "dockkras.gd" common-dep) -(cgo-file "sptmfoot.gd" common-dep) -(cgo-file "mongl.gd" common-dep) -(cgo-file "icepassw.gd" common-dep) -(cgo-file "razvl.gd" common-dep) -(cgo-file "swa.gd" common-dep) -(cgo-file "spd.gd" common-dep) -(cgo-file "peccred.gd" common-dep) -(cgo-file "kcr.gd" common-dep) -(cgo-file "drc.gd" common-dep) -(cgo-file "thbvl3.gd" common-dep) -(cgo-file "cars.gd" common-dep) -(cgo-file "sigcred.gd" common-dep) -(cgo-file "tempfoot.gd" common-dep) -(cgo-file "desrev.gd" common-dep) -(cgo-file "hjngfoot.gd" common-dep) -(cgo-file "dry.gd" common-dep) -(cgo-file "sprgstbx.gd" common-dep) -(cgo-file "ur8lev.gd" common-dep) -(cgo-file "ashvl3.gd" common-dep) -(cgo-file "cyx.gd" common-dep) -(cgo-file "cyb.gd" common-dep) -(cgo-file "kratfoot.gd" common-dep) -(cgo-file "cansparw.gd" common-dep) -(cgo-file "stx.gd" common-dep) -(cgo-file "hvswtt.gd" common-dep) -(cgo-file "havseww.gd" common-dep) -(cgo-file "torcred.gd" common-dep) -(cgo-file "klelev.gd" common-dep) -(cgo-file "gtblev.gd" common-dep) -(cgo-file "daxtl.gd" common-dep) -(cgo-file "sewertt.gd" common-dep) -(cgo-file "dsx.gd" common-dep) -(cgo-file "brdroomf.gd" common-dep) -(cgo-file "havjungs.gd" common-dep) -(cgo-file "spartemw.gd" common-dep) -(cgo-file "bearl.gd" common-dep) -(cgo-file "sno.gd" common-dep) -(cgo-file "s3a.gd" common-dep) -(cgo-file "kcrx.gd" common-dep) -(cgo-file "hjy.gd" common-dep) -(cgo-file "cougl.gd" common-dep) -(cgo-file "peaktt.gd" common-dep) -(cgo-file "dkkrfoot.gd" common-dep) -(cgo-file "spartt.gd" common-dep) -(cgo-file "icpstt.gd" common-dep) -(cgo-file "kcrsplow.gd" common-dep) -(cgo-file "iby.gd" common-dep) -(cgo-file "snwx.gd" common-dep) -(cgo-file "raylev.gd" common-dep) -(cgo-file "havsews.gd" common-dep) -(cgo-file "drdktbox.gd" common-dep) -(cgo-file "ipx.gd" common-dep) -(cgo-file "rayvl.gd" common-dep) -(cgo-file "torvl.gd" common-dep) -(cgo-file "dkd.gd" common-dep) -(cgo-file "rustyh.gd" common-dep) -(cgo-file "ipy.gd" common-dep) -(cgo-file "swb.gd" common-dep) -(cgo-file "icepasss.gd" common-dep) -(cgo-file "atx.gd" common-dep) -(cgo-file "krasw.gd" common-dep) -(cgo-file "spattbox.gd" common-dep) -(cgo-file "drdkfoot.gd" common-dep) -(cgo-file "ictrtt.gd" common-dep) -(cgo-file "pantl.gd" common-dep) -(cgo-file "spatfoot.gd" common-dep) -(cgo-file "kievl.gd" common-dep) -(cgo-file "drdy.gd" common-dep) -(cgo-file "osmlev.gd" common-dep) -(cgo-file "kcrosart.gd" common-dep) -(cgo-file "canyons.gd" common-dep) -(cgo-file "tigel.gd" common-dep) -(cgo-file "drdktt.gd" common-dep) -(cgo-file "thblev.gd" common-dep) -(cgo-file "dislectf.gd" common-dep) -(cgo-file "canyontt.gd" common-dep) -(cgo-file "thcvl3.gd" common-dep) -(cgo-file "junglew.gd" common-dep) -(cgo-file "tarlev.gd" common-dep) -(cgo-file "havens.gd" common-dep) -(cgo-file "kra.gd" common-dep) -(cgo-file "tpd.gd" common-dep) -(cgo-file "jgd.gd" common-dep) -(cgo-file "cantbox.gd" common-dep) -(cgo-file "gilal.gd" common-dep) -(cgo-file "icetours.gd" common-dep) -(cgo-file "snows.gd" common-dep) -(cgo-file "icb.gd" common-dep) -(cgo-file "dromes.gd" common-dep) -(cgo-file "snowfoot.gd" common-dep) -(cgo-file "kcrosss.gd" common-dep) -(cgo-file "snowtbox.gd" common-dep) -(cgo-file "drb.gd" common-dep) -(cgo-file "ices.gd" common-dep) -(cgo-file "dka.gd" common-dep) -(cgo-file "tpx.gd" common-dep) -(cgo-file "ur8vl3.gd" common-dep) -(cgo-file "sptmtbox.gd" common-dep) -(cgo-file "icetfoot.gd" common-dep) -(cgo-file "toadl.gd" common-dep) -(cgo-file "havttbox.gd" common-dep) -(cgo-file "havjungw.gd" common-dep) -(cgo-file "thclev.gd" common-dep) -(cgo-file "atollart.gd" common-dep) -(cgo-file "hjx.gd" common-dep) -(cgo-file "kratours.gd" common-dep) -(cgo-file "menu2.gd" common-dep) -(cgo-file "hvswfoot.gd" common-dep) -(cgo-file "atolls.gd" common-dep) -(cgo-file "garageb.gd" common-dep) -(cgo-file "icepfoot.gd" common-dep) -(cgo-file "docksw.gd" common-dep) -(cgo-file "icebergw.gd" common-dep) -(cgo-file "pke.gd" common-dep) -(cgo-file "kry.gd" common-dep) +;; (cgo-file "clfx.gd" common-dep) +;; (cgo-file "swx.gd" common-dep) +;; (cgo-file "cyc.gd" common-dep) +;; (cgo-file "tpc.gd" common-dep) +;; (cgo-file "dromett.gd" common-dep) +;; (cgo-file "ximlev.gd" common-dep) +;; (cgo-file "pecvl.gd" common-dep) +;; (cgo-file "dkb.gd" common-dep) +;; (cgo-file "kcrsclct.gd" common-dep) +;; (cgo-file "spa.gd" common-dep) +;; (cgo-file "dockfoot.gd" common-dep) +;; (cgo-file "sewerw.gd" common-dep) +;; (cgo-file "thacred.gd" common-dep) +;; (cgo-file "ashcred.gd" common-dep) +;; (cgo-file "krass.gd" common-dep) +;; (cgo-file "jgc.gd" common-dep) +;; (cgo-file "leopl.gd" common-dep) +;; (cgo-file "csy.gd" common-dep) +;; (cgo-file "icefoot.gd" common-dep) +;; (cgo-file "spx.gd" common-dep) +;; (cgo-file "peakw.gd" common-dep) +;; (cgo-file "hva.gd" common-dep) +;; (cgo-file "icebfoot.gd" common-dep) +;; (cgo-file "jungtrn.gd" common-dep) +;; (cgo-file "cyy.gd" common-dep) +;; (cgo-file "daxlev.gd" common-dep) +;; (cgo-file "havtours.gd" common-dep) +;; (cgo-file "icy.gd" common-dep) +;; (cgo-file "thbvl.gd" common-dep) +;; (cgo-file "dromdocs.gd" common-dep) +;; (cgo-file "dke.gd" common-dep) +;; (cgo-file "clifhunt.gd" common-dep) +;; (cgo-file "sewfoot.gd" common-dep) +;; (cgo-file "pkx.gd" common-dep) +;; (cgo-file "cnspfoot.gd" common-dep) +;; (cgo-file "dkc.gd" common-dep) +;; (cgo-file "temptbox.gd" common-dep) +;; (cgo-file "jgy.gd" common-dep) +;; (cgo-file "krastbox.gd" common-dep) +;; (cgo-file "krasfoot.gd" common-dep) +;; (cgo-file "dsrx.gd" common-dep) +;; (cgo-file "cyd.gd" common-dep) +;; (cgo-file "desisles.gd" common-dep) +;; (cgo-file "razcred.gd" common-dep) +;; (cgo-file "tpa.gd" common-dep) +;; (cgo-file "falcl.gd" common-dep) +;; (cgo-file "cheel.gd" common-dep) +;; (cgo-file "krattbox.gd" common-dep) +;; (cgo-file "jungtbox.gd" common-dep) +;; (cgo-file "sigvl3.gd" common-dep) +;; (cgo-file "ur8cred.gd" common-dep) +;; (cgo-file "havenw.gd" common-dep) +;; (cgo-file "ratlev.gd" common-dep) +;; (cgo-file "jungfoot.gd" common-dep) +;; (cgo-file "templew.gd" common-dep) +;; (cgo-file "klevl2.gd" common-dep) +;; (cgo-file "spc.gd" common-dep) +;; (cgo-file "kcrosctf.gd" common-dep) +;; (cgo-file "cliffart.gd" common-dep) +;; (cgo-file "swc.gd" common-dep) +;; (cgo-file "canyonw.gd" common-dep) +;; (cgo-file "jaklev.gd" common-dep) +;; (cgo-file "jakcred.gd" common-dep) +;; (cgo-file "kratourw.gd" common-dep) +;; (cgo-file "eightb.gd" common-dep) +;; (cgo-file "swd.gd" common-dep) +;; (cgo-file "snowtt.gd" common-dep) +;; (cgo-file "hvtrtt.gd" common-dep) +;; (cgo-file "coliseus.gd" common-dep) +;; (cgo-file "pkd.gd" common-dep) +;; (cgo-file "colart.gd" common-dep) +;; (cgo-file "possl.gd" common-dep) +;; (cgo-file "krastrn.gd" common-dep) +;; (cgo-file "ashvl.gd" common-dep) +;; (cgo-file "dromew.gd" common-dep) +;; (cgo-file "hvswtbox.gd" common-dep) +;; (cgo-file "sigvl.gd" common-dep) +;; (cgo-file "sparfoot.gd" common-dep) +;; (cgo-file "sptmtt.gd" common-dep) +;; (cgo-file "dkx.gd" common-dep) +;; (cgo-file "hvd.gd" common-dep) +;; (cgo-file "snw.gd" common-dep) +;; (cgo-file "brdroom.gd" common-dep) +;; (cgo-file "icc.gd" common-dep) +;; (cgo-file "sewers.gd" common-dep) +;; (cgo-file "garage.gd" common-dep) +;; (cgo-file "ashvl2.gd" common-dep) +;; (cgo-file "jkclev.gd" common-dep) +;; (cgo-file "jakvl.gd" common-dep) +;; (cgo-file "dra.gd" common-dep) +;; (cgo-file "kaelev.gd" common-dep) +;; (cgo-file "thbcred.gd" common-dep) +;; (cgo-file "thbvl2.gd" common-dep) +;; (cgo-file "pkb.gd" common-dep) +;; (cgo-file "spatours.gd" common-dep) +;; (cgo-file "dkkrtbox.gd" common-dep) +;; (cgo-file "klecred.gd" common-dep) +;; (cgo-file "dockstt.gd" common-dep) +;; (cgo-file "snowtrn2.gd" common-dep) +;; (cgo-file "icebergs.gd" common-dep) +;; (cgo-file "cnsptbox.gd" common-dep) +;; (cgo-file "spe.gd" common-dep) +;; (cgo-file "swe.gd" common-dep) +;; (cgo-file "drd.gd" common-dep) +;; (cgo-file "clf.gd" common-dep) +;; (cgo-file "thavl.gd" common-dep) +;; (cgo-file "atl.gd" common-dep) +;; (cgo-file "tpy.gd" common-dep) +;; (cgo-file "cye.gd" common-dep) +;; (cgo-file "snakl.gd" common-dep) +;; (cgo-file "ashlev.gd" common-dep) +;; (cgo-file "krx.gd" common-dep) +;; (cgo-file "jgx.gd" common-dep) +;; (cgo-file "hvy.gd" common-dep) +;; (cgo-file "csx.gd" common-dep) +;; (cgo-file "hve.gd" common-dep) +;; (cgo-file "jkalev.gd" common-dep) +;; (cgo-file "canspars.gd" common-dep) +;; (cgo-file "raycred.gd" common-dep) +;; (cgo-file "dsi.gd" common-dep) +;; (cgo-file "icettbox.gd" common-dep) +;; (cgo-file "spy.gd" common-dep) +;; (cgo-file "icetrn.gd" common-dep) +;; (cgo-file "torvl3.gd" common-dep) +;; (cgo-file "icetourw.gd" common-dep) +;; (cgo-file "sbwlctf.gd" common-dep) +;; (cgo-file "jungles.gd" common-dep) +;; (cgo-file "pka.gd" common-dep) +;; (cgo-file "dsr.gd" common-dep) +;; (cgo-file "tpe.gd" common-dep) +;; (cgo-file "ur8vl.gd" common-dep) +;; (cgo-file "ica.gd" common-dep) +;; (cgo-file "icew.gd" common-dep) +;; (cgo-file "dromtbox.gd" common-dep) +;; (cgo-file "credits.gd" common-dep) +;; (cgo-file "sigvl2.gd" common-dep) +;; (cgo-file "spartems.gd" common-dep) +;; (cgo-file "dromex.gd" common-dep) +;; (cgo-file "havnfoot.gd" common-dep) +;; (cgo-file "icebtbox.gd" common-dep) +;; (cgo-file "havtfoot.gd" common-dep) +;; (cgo-file "menumap.gd" common-dep) +;; (cgo-file "icetbox.gd" common-dep) +;; (cgo-file "snobart.gd" common-dep) +;; (cgo-file "eight.gd" common-dep) +;; (cgo-file "wombl.gd" common-dep) +;; (cgo-file "desart.gd" common-dep) +;; (cgo-file "dethrace.gd" common-dep) +;; (cgo-file "cliftrn.gd" common-dep) +;; (cgo-file "spb.gd" common-dep) +;; (cgo-file "desrapt.gd" common-dep) +;; (cgo-file "kielev.gd" common-dep) +;; (cgo-file "deshunt.gd" common-dep) +;; (cgo-file "wolfl.gd" common-dep) +;; (cgo-file "havntbox.gd" common-dep) +;; (cgo-file "icx.gd" common-dep) +;; (cgo-file "razlev.gd" common-dep) +;; (cgo-file "icett.gd" common-dep) +;; (cgo-file "icd.gd" common-dep) +;; (cgo-file "keicred.gd" common-dep) +;; (cgo-file "hvc.gd" common-dep) +;; (cgo-file "fmvlev.gd" common-dep) +;; (cgo-file "hsy.gd" common-dep) +;; (cgo-file "peclev.gd" common-dep) +;; (cgo-file "foxl.gd" common-dep) +;; (cgo-file "pkc.gd" common-dep) +;; (cgo-file "dromdocw.gd" common-dep) +;; (cgo-file "drx.gd" common-dep) +;; (cgo-file "krastt.gd" common-dep) +;; (cgo-file "desactf.gd" common-dep) +;; (cgo-file "raceweap.gd" common-dep) +;; (cgo-file "klevl.gd" common-dep) +;; (cgo-file "spargusw.gd" common-dep) +;; (cgo-file "ur8vl2.gd" common-dep) +;; (cgo-file "daxcred.gd" common-dep) +;; (cgo-file "tpb.gd" common-dep) +;; (cgo-file "desarens.gd" common-dep) +;; (cgo-file "jgf.gd" common-dep) +;; (cgo-file "col.gd" common-dep) +;; (cgo-file "hvjgtbox.gd" common-dep) +;; (cgo-file "gtbvl.gd" common-dep) +;; (cgo-file "colirev.gd" common-dep) +;; (cgo-file "temples.gd" common-dep) +;; (cgo-file "jgg.gd" common-dep) +;; (cgo-file "peakfoot.gd" common-dep) +;; (cgo-file "thcvl.gd" common-dep) +;; (cgo-file "sty.gd" common-dep) +;; (cgo-file "drdx.gd" common-dep) +;; (cgo-file "torlev.gd" common-dep) +;; (cgo-file "turtl.gd" common-dep) +;; (cgo-file "colictf.gd" common-dep) +;; (cgo-file "havtourw.gd" common-dep) +;; (cgo-file "desclct.gd" common-dep) +;; (cgo-file "jge.gd" common-dep) +;; (cgo-file "deshunt2.gd" common-dep) +;; (cgo-file "thcvl2.gd" common-dep) +;; (cgo-file "swf.gd" common-dep) +;; (cgo-file "krc.gd" common-dep) +;; (cgo-file "drone.gd" common-dep) +;; (cgo-file "dockss.gd" common-dep) +;; (cgo-file "disleart.gd" common-dep) +;; (cgo-file "dromfoot.gd" common-dep) +;; (cgo-file "dockkraw.gd" common-dep) +;; (cgo-file "jgb.gd" common-dep) +;; (cgo-file "hsx.gd" common-dep) +;; (cgo-file "bobcl.gd" common-dep) +;; (cgo-file "atollctf.gd" common-dep) +;; (cgo-file "krb.gd" common-dep) +;; (cgo-file "clifctf.gd" common-dep) +;; (cgo-file "rayvl2.gd" common-dep) +;; (cgo-file "hvjgtt.gd" common-dep) +;; (cgo-file "thavl2.gd" common-dep) +;; (cgo-file "colx.gd" common-dep) +;; (cgo-file "jga.gd" common-dep) +;; (cgo-file "cya.gd" common-dep) +;; (cgo-file "hvb.gd" common-dep) +;; (cgo-file "sptrtt.gd" common-dep) +;; (cgo-file "siglev.gd" common-dep) +;; (cgo-file "templett.gd" common-dep) +;; (cgo-file "thccred.gd" common-dep) +;; (cgo-file "iceptbox.gd" common-dep) +;; (cgo-file "coliclct.gd" common-dep) +;; (cgo-file "icbgtt.gd" common-dep) +;; (cgo-file "torvl2.gd" common-dep) +;; (cgo-file "peaks.gd" common-dep) +;; (cgo-file "thalev.gd" common-dep) +;; (cgo-file "hvx.gd" common-dep) +;; (cgo-file "thavl3.gd" common-dep) +;; (cgo-file "peaktbox.gd" common-dep) +;; (cgo-file "spatourw.gd" common-dep) +;; (cgo-file "sewtbox.gd" common-dep) +;; (cgo-file "canfoot.gd" common-dep) +;; (cgo-file "cnsptt.gd" common-dep) +;; (cgo-file "havtt.gd" common-dep) +;; (cgo-file "cliffss.gd" common-dep) +;; (cgo-file "ibx.gd" common-dep) +;; (cgo-file "gtbcred.gd" common-dep) +;; (cgo-file "atoplow.gd" common-dep) +;; (cgo-file "dkky.gd" common-dep) +;; (cgo-file "rth.gd" common-dep) +;; (cgo-file "s2a.gd" common-dep) +;; (cgo-file "junglett.gd" common-dep) +;; (cgo-file "jkblev.gd" common-dep) +;; (cgo-file "krtrtt.gd" common-dep) +;; (cgo-file "snox.gd" common-dep) +;; (cgo-file "dkkrtt.gd" common-dep) +;; (cgo-file "docktbox.gd" common-dep) +;; (cgo-file "dkkx.gd" common-dep) +;; (cgo-file "snobowls.gd" common-dep) +;; (cgo-file "sparguss.gd" common-dep) +;; (cgo-file "dockkras.gd" common-dep) +;; (cgo-file "sptmfoot.gd" common-dep) +;; (cgo-file "mongl.gd" common-dep) +;; (cgo-file "icepassw.gd" common-dep) +;; (cgo-file "razvl.gd" common-dep) +;; (cgo-file "swa.gd" common-dep) +;; (cgo-file "spd.gd" common-dep) +;; (cgo-file "peccred.gd" common-dep) +;; (cgo-file "kcr.gd" common-dep) +;; (cgo-file "drc.gd" common-dep) +;; (cgo-file "thbvl3.gd" common-dep) +;; (cgo-file "cars.gd" common-dep) +;; (cgo-file "sigcred.gd" common-dep) +;; (cgo-file "tempfoot.gd" common-dep) +;; (cgo-file "desrev.gd" common-dep) +;; (cgo-file "hjngfoot.gd" common-dep) +;; (cgo-file "dry.gd" common-dep) +;; (cgo-file "sprgstbx.gd" common-dep) +;; (cgo-file "ur8lev.gd" common-dep) +;; (cgo-file "ashvl3.gd" common-dep) +;; (cgo-file "cyx.gd" common-dep) +;; (cgo-file "cyb.gd" common-dep) +;; (cgo-file "kratfoot.gd" common-dep) +;; (cgo-file "cansparw.gd" common-dep) +;; (cgo-file "stx.gd" common-dep) +;; (cgo-file "hvswtt.gd" common-dep) +;; (cgo-file "havseww.gd" common-dep) +;; (cgo-file "torcred.gd" common-dep) +;; (cgo-file "klelev.gd" common-dep) +;; (cgo-file "gtblev.gd" common-dep) +;; (cgo-file "daxtl.gd" common-dep) +;; (cgo-file "sewertt.gd" common-dep) +;; (cgo-file "dsx.gd" common-dep) +;; (cgo-file "brdroomf.gd" common-dep) +;; (cgo-file "havjungs.gd" common-dep) +;; (cgo-file "spartemw.gd" common-dep) +;; (cgo-file "bearl.gd" common-dep) +;; (cgo-file "sno.gd" common-dep) +;; (cgo-file "s3a.gd" common-dep) +;; (cgo-file "kcrx.gd" common-dep) +;; (cgo-file "hjy.gd" common-dep) +;; (cgo-file "cougl.gd" common-dep) +;; (cgo-file "peaktt.gd" common-dep) +;; (cgo-file "dkkrfoot.gd" common-dep) +;; (cgo-file "spartt.gd" common-dep) +;; (cgo-file "icpstt.gd" common-dep) +;; (cgo-file "kcrsplow.gd" common-dep) +;; (cgo-file "iby.gd" common-dep) +;; (cgo-file "snwx.gd" common-dep) +;; (cgo-file "raylev.gd" common-dep) +;; (cgo-file "havsews.gd" common-dep) +;; (cgo-file "drdktbox.gd" common-dep) +;; (cgo-file "ipx.gd" common-dep) +;; (cgo-file "rayvl.gd" common-dep) +;; (cgo-file "torvl.gd" common-dep) +;; (cgo-file "dkd.gd" common-dep) +;; (cgo-file "rustyh.gd" common-dep) +;; (cgo-file "ipy.gd" common-dep) +;; (cgo-file "swb.gd" common-dep) +;; (cgo-file "icepasss.gd" common-dep) +;; (cgo-file "atx.gd" common-dep) +;; (cgo-file "krasw.gd" common-dep) +;; (cgo-file "spattbox.gd" common-dep) +;; (cgo-file "drdkfoot.gd" common-dep) +;; (cgo-file "ictrtt.gd" common-dep) +;; (cgo-file "pantl.gd" common-dep) +;; (cgo-file "spatfoot.gd" common-dep) +;; (cgo-file "kievl.gd" common-dep) +;; (cgo-file "drdy.gd" common-dep) +;; (cgo-file "osmlev.gd" common-dep) +;; (cgo-file "kcrosart.gd" common-dep) +;; (cgo-file "canyons.gd" common-dep) +;; (cgo-file "tigel.gd" common-dep) +;; (cgo-file "drdktt.gd" common-dep) +;; (cgo-file "thblev.gd" common-dep) +;; (cgo-file "dislectf.gd" common-dep) +;; (cgo-file "canyontt.gd" common-dep) +;; (cgo-file "thcvl3.gd" common-dep) +;; (cgo-file "junglew.gd" common-dep) +;; (cgo-file "tarlev.gd" common-dep) +;; (cgo-file "havens.gd" common-dep) +;; (cgo-file "kra.gd" common-dep) +;; (cgo-file "tpd.gd" common-dep) +;; (cgo-file "jgd.gd" common-dep) +;; (cgo-file "cantbox.gd" common-dep) +;; (cgo-file "gilal.gd" common-dep) +;; (cgo-file "icetours.gd" common-dep) +;; (cgo-file "snows.gd" common-dep) +;; (cgo-file "icb.gd" common-dep) +;; (cgo-file "dromes.gd" common-dep) +;; (cgo-file "snowfoot.gd" common-dep) +;; (cgo-file "kcrosss.gd" common-dep) +;; (cgo-file "snowtbox.gd" common-dep) +;; (cgo-file "drb.gd" common-dep) +;; (cgo-file "ices.gd" common-dep) +;; (cgo-file "dka.gd" common-dep) +;; (cgo-file "tpx.gd" common-dep) +;; (cgo-file "ur8vl3.gd" common-dep) +;; (cgo-file "sptmtbox.gd" common-dep) +;; (cgo-file "icetfoot.gd" common-dep) +;; (cgo-file "toadl.gd" common-dep) +;; (cgo-file "havttbox.gd" common-dep) +;; (cgo-file "havjungw.gd" common-dep) +;; (cgo-file "thclev.gd" common-dep) +;; (cgo-file "atollart.gd" common-dep) +;; (cgo-file "hjx.gd" common-dep) +;; (cgo-file "kratours.gd" common-dep) +;; (cgo-file "menu2.gd" common-dep) +;; (cgo-file "hvswfoot.gd" common-dep) +;; (cgo-file "atolls.gd" common-dep) +;; (cgo-file "garageb.gd" common-dep) +;; (cgo-file "icepfoot.gd" common-dep) +;; (cgo-file "docksw.gd" common-dep) +;; (cgo-file "icebergw.gd" common-dep) +;; (cgo-file "pke.gd" common-dep) +;; (cgo-file "kry.gd" common-dep) ;;;;;;;;;;;;;;;;;;;;;;;;; ;; Example Custom Level @@ -473,15 +473,15 @@ ;; Set up the build system to build the level geometry ;; this path is relative to the custom_levels/jakx folder ;; it should point to the .jsonc file that specifies the level. -(build-custom-level "test-zone") -;; the DGO file -(goal-src "levels/test-zone/test-zone-obs.gc" "process-focusable") -(custom-level-cgo "TSZ.DGO" "test-zone/testzone.gd") +;; (build-custom-level "test-zone") +;; ;; the DGO file +;; (goal-src "levels/test-zone/test-zone-obs.gc" "process-focusable") +;; (custom-level-cgo "TSZ.DGO" "test-zone/testzone.gd") -;; generate the art group for a custom actor. -;; requires a .glb model file in custom_assets/jakx/models/custom_levels -;; to also generate a collide-mesh, add :gen-mesh #t -(build-actor "test-actor" :gen-mesh #t) +;; ;; generate the art group for a custom actor. +;; ;; requires a .glb model file in custom_assets/jakx/models/custom_levels +;; ;; to also generate a collide-mesh, add :gen-mesh #t +;; (build-actor "test-actor" :gen-mesh #t) ;;;;;;;;;;;;;;;;;;;;; ;; ANIMATIONS @@ -499,11 +499,27 @@ (defstep :in "$ISO/RES/TWEAKVAL.MUS" :tool 'copy :out '("$OUT/iso/TWEAKVAL.MUS")) + ;;;;;;;;;;;;;;;;;;;;; ;; Text ;;;;;;;;;;;;;;;;;;;;; -;; TODO +;; (defstep :in "game/assets/jakx/game_text.gp" +;; :tool 'text +;; :out '("$OUT/iso/0COMMON.TXT" +;; "$OUT/iso/1COMMON.TXT" +;; "$OUT/iso/2COMMON.TXT" +;; "$OUT/iso/3COMMON.TXT" +;; "$OUT/iso/4COMMON.TXT" +;; "$OUT/iso/5COMMON.TXT" +;; "$OUT/iso/6COMMON.TXT" +;; "$OUT/iso/7COMMON.TXT") +;; ) + +;; (defstep :in "game/assets/jakx/game_subtitle.gp" +;; :tool 'subtitle-v2 +;; :out '("$OUT/iso/0SUBTIX.TXT") +;; ) ;;;;;;;;;;;;;;;;;;;;; ;; ISO Group @@ -513,21 +529,22 @@ ;; TODO - ensure this is complete (group-list "iso" - `("$OUT/iso/0COMMON.TXT" - "$OUT/iso/1COMMON.TXT" - "$OUT/iso/2COMMON.TXT" - "$OUT/iso/3COMMON.TXT" - "$OUT/iso/4COMMON.TXT" - "$OUT/iso/5COMMON.TXT" - "$OUT/iso/6COMMON.TXT" - "$OUT/iso/7COMMON.TXT" - "$OUT/iso/0SUBTI3.TXT" - "$OUT/iso/VAGDIR.AYB" - "$OUT/iso/TWEAKVAL.MUS" - ,@(reverse *all-vis*) - ,@(reverse *all-str*) - ,@(reverse *all-sbk*) - ,@(reverse *all-vag*) + `( + ;; "$OUT/iso/0COMMON.TXT" + ;; "$OUT/iso/1COMMON.TXT" + ;; "$OUT/iso/2COMMON.TXT" + ;; "$OUT/iso/3COMMON.TXT" + ;; "$OUT/iso/4COMMON.TXT" + ;; "$OUT/iso/5COMMON.TXT" + ;; "$OUT/iso/6COMMON.TXT" + ;; "$OUT/iso/7COMMON.TXT" + ;; "$OUT/iso/0SUBTIX.TXT" + ;; "$OUT/iso/VAGDIR.AYB" + ;; "$OUT/iso/TWEAKVAL.MUS" + ;; ,@(reverse *all-vis*) + ;; ,@(reverse *all-str*) + ;; ,@(reverse *all-sbk*) + ;; ,@(reverse *all-vag*) ,@(reverse *all-cgos*)) ) @@ -540,7 +557,7 @@ "$OUT/iso/5COMMON.TXT" "$OUT/iso/6COMMON.TXT" "$OUT/iso/7COMMON.TXT" - "$OUT/iso/0SUBTI3.TXT" + "$OUT/iso/0SUBTIX.TXT" ) ) @@ -551,7 +568,7 @@ (group "engine" "$OUT/iso/0COMMON.TXT" - "$OUT/iso/0SUBTI3.TXT" + "$OUT/iso/0SUBTIX.TXT" "$OUT/iso/KERNEL.CGO" "$OUT/iso/GAME.CGO" "$OUT/iso/VAGDIR.AYB" diff --git a/goal_src/jakx/kernel-defs.gc b/goal_src/jakx/kernel-defs.gc new file mode 100644 index 0000000000..64675c8b1c --- /dev/null +++ b/goal_src/jakx/kernel-defs.gc @@ -0,0 +1,429 @@ +;; kernel-defs.gc +;; everything defined in the C Kernel / runtime + +;; TODO JAK X - copied from jak3 for now + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; kscheme - InitHeapAndSymbol +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defenum kmalloc-flags + :bitfield #t + (align-16 4) + (align-64 6) + (align-256 8) + (memset 12) + (top 13) + ) + +(defenum link-flag + :bitfield #t + :type int32 + (output-load-msg 0) + (output-load-true-msg 1) + (execute-login 2) + (print-login 3) + (force-debug 4) + (fast-link 5) + ) + + +(defenum language-enum + :type uint8 + (english 0) + (french 1) + (german 2) + (spanish 3) + (italian 4) + (commentary 5) + (japanese 6) + (korean 7) + (russian 8) + (portuguese 9) + (dutch 10) + (uk-english 11) + ;; custom + (finnish 12) + (swedish 13) + (danish 14) + (norwegian 15) + (br-portuguese 16) + (hungarian 17) + (catalan 18) + (icelandic 19) + (polish 20) + (lithuanian 21) + (czech 22) + (croatian 23) + (galician 24) + ) + +(defenum language-enum-s32 + :type int32 + :copy-entries language-enum + ) + +(defenum runtime-exit-status + :type uint32 + (running) + (restart-runtime) + (exit) + (restart-in-debug) + ) + +;; fixed symbols +(define-extern #f symbol) +(define-extern #t symbol) +(define-extern function type) +(define-extern basic type) +(define-extern string type) +(define-extern symbol type) +(define-extern boolean type) +(define-extern type type) +(define-extern object type) +(define-extern link-block type) +(define-extern integer type) +(define-extern sinteger type) +(define-extern uinteger type) +(define-extern binteger type) +(define-extern int8 type) +(define-extern int16 type) +(define-extern int32 type) +(define-extern int64 type) +(define-extern int128 type) +(define-extern uint8 type) +(define-extern uint16 type) +(define-extern uint32 type) +(define-extern uint64 type) +(define-extern uint128 type) +(define-extern float type) +(define-extern process-tree type) +(define-extern process type) +(define-extern thread type) +(define-extern structure type) +(define-extern pair type) +(define-extern pointer type) +(define-extern number type) +(define-extern array type) +(define-extern vu-function type) +(define-extern connectable type) +(define-extern stack-frame type) +(define-extern file-stream type) +(define-extern kheap type) +(define-extern nothing (function none)) +(define-extern delete-basic (function basic none)) +(define-extern static symbol) +(define-extern global kheap) +(define-extern debug kheap) +(define-extern loading-level kheap) ;; not a kheap at boot +(define-extern loading-package kheap) ;; not a kheap at boot +(define-extern process-level-heap kheap) ;; not a kheap at boot +(define-extern stack symbol) +(define-extern scratch symbol) +(define-extern *scratch-top* pointer) +(define-extern zero-func (function int)) + +;; InitHeapAndSymbol +(define-extern _format (function _varargs_ object)) +(define-extern method-set! (function type int object none)) ;; may actually return function. +(define-extern kmemopen (function kheap string none)) +(define-extern kmemclose (function none)) + +(define-extern *enable-method-set* int) + +(define-extern *listener-function* (function object)) +(define-extern *debug-segment* symbol) + +(define-extern dgo-load (function string kheap link-flag int none)) +(define-extern malloc (function symbol int pointer)) +(define-extern loado (function string kheap object)) +(define-extern link (function pointer pointer int kheap int pointer)) + +(declare-type cpad-info basic) +(define-extern cpad-open (function cpad-info int cpad-info)) +(define-extern cpad-get-data (function cpad-info cpad-info)) + +(declare-type mouse-info basic) +(define-extern mouse-get-data (function mouse-info none)) + +(declare-type keybd-info basic) +(define-extern keybd-get-data (function keybd-info none)) + +(defconstant GAME_TERRITORY_SCEA 0) +(defconstant GAME_TERRITORY_SCEE 1) +(defconstant GAME_TERRITORY_SCEI 2) +(defconstant GAME_TERRITORY_SCEK 3) + +(define-extern scf-get-territory (function int)) ;; not actually a scf function... + +(define-extern scf-get-volume "Defined in the kernel" (function int)) +(define-extern scf-get-language "Defined in the kernel" (function language-enum)) +(define-extern scf-get-aspect "Defined in the kernel" (function uint)) +(define-extern scf-get-timeout (function int)) +(define-extern scf-get-inactive-timeout (function int)) +(define-extern kernel-shutdown (function int none)) +(define-extern *boot-video-mode* "Defined in the kernel" int) +(define-extern *kernel-boot-message* symbol) +(define-extern *kernel-symbol-warnings* symbol) +(define-extern *kernel-boot-art-group* string) +(define-extern symbol->string (function symbol string)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; PC Port functions +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defenum pc-renderer-tree-type + (none 0) + (tfrag3 1) + (tie3 2) + (invalid)) + +(defenum pc-collision-mode + (none 0) + (mode 1) + (event 2) + (material 3) + (skip 4) + (skiphide 5)) + +(defenum pc-gfx-hack + (no-tex 0)) + +;; TODO - make a common kernel-defs +(define-extern __read-ee-timer (function uint)) +(define-extern __mem-move (function pointer pointer uint none)) +(define-extern __send-gfx-dma-chain (function object object none)) +(define-extern __pc-texture-upload-now (function object object none)) +(define-extern __pc-texture-relocate (function object object object none)) +(define-extern __pc-get-mips2c (function string function)) +(define-extern __pc-set-levels (function (pointer string) none)) +(define-extern __pc-set-active-levels (function (pointer string) none)) +(define-extern __pc-get-tex-remap (function int int int)) + +;; Input Related Functions +;; TODO - add get current controller index +(define-extern pc-get-controller-count (function int)) +(define-extern pc-get-controller-name (function int string string)) +(deftype bind-assignment-info (structure) + ((port int32) + (device-type int32) + (for-buttons? symbol) + (input-idx int32) + (analog-min-range? symbol))) +(define-extern pc-get-current-bind (function bind-assignment-info string symbol)) +(define-extern pc-waiting-for-bind? (function symbol)) +(define-extern pc-set-waiting-for-bind! (function int symbol symbol int none)) +(define-extern pc-stop-waiting-for-bind! (function none)) +(define-extern pc-get-controller-index (function int int)) +(define-extern pc-set-controller! (function int int none)) +(define-extern pc-get-keyboard-enabled? (function symbol)) +(define-extern pc-set-keyboard-enabled! (function symbol none)) +(define-extern pc-set-mouse-options! (function symbol symbol symbol none)) +(define-extern pc-set-mouse-camera-sens! (function float float none)) +(define-extern pc-current-controller-has-led? (function symbol)) +(define-extern pc-current-controller-has-rumble? (function symbol)) +(define-extern pc-set-controller-led! (function int int int int none)) +(define-extern pc-ignore-background-controller-events! (function symbol none)) +(define-extern pc-reset-bindings-to-defaults! (function int int none)) +(define-extern pc-set-auto-hide-cursor! (function symbol none)) +(define-extern pc-get-pressure-sensitivity-enabled? (function symbol)) +(define-extern pc-set-pressure-sensitivity-enabled! (function symbol none)) +(define-extern pc-get-axis-scale (function float)) +(define-extern pc-set-axis-scale! (function float none)) +(define-extern pc-current-controller-has-pressure-sensitivity? (function symbol)) +(define-extern pc-current-controller-has-trigger-effect-support? (function symbol)) +(define-extern pc-get-trigger-effects-enabled? (function symbol)) +(define-extern pc-set-trigger-effects-enabled! (function symbol none)) +(defenum pc-trigger-effect-option + (left 0) + (right 1) + (both 2)) +(define-extern pc-clear-trigger-effect! (function pc-trigger-effect-option none)) +(define-extern pc-send-trigger-effect-feedback! (function pc-trigger-effect-option int int none)) +(define-extern pc-send-trigger-effect-vibrate! (function pc-trigger-effect-option int int int none)) +(define-extern pc-send-trigger-effect-weapon! (function pc-trigger-effect-option int int int none)) +(define-extern pc-send-trigger-rumble! (function int int int none)) + +;; Display Related Functions +(define-extern pc-get-display-mode (function symbol)) +(define-extern pc-get-active-display-size (function (pointer int64) (pointer int64) none)) +(define-extern pc-get-active-display-refresh-rate (function int)) +(define-extern pc-get-display-count (function int)) +(define-extern pc-get-display-name (function int string symbol)) +(define-extern pc-get-os (function symbol)) +(define-extern pc-get-window-size (function (pointer int64) (pointer int64) none)) +(define-extern pc-get-window-scale (function (pointer float) (pointer float) none)) +(define-extern pc-set-window-size! (function int int none)) +(define-extern pc-get-display-id (function int)) +(define-extern pc-set-display-id! (function int none)) +(define-extern pc-set-display-mode! (function symbol int int none)) +(define-extern pc-get-num-resolutions (function symbol int)) +(define-extern pc-get-resolution (function int symbol (pointer int64) (pointer int64) none)) +(define-extern pc-is-supported-resolution? (function int int symbol)) + +(define-extern pc-set-frame-rate (function int none)) +(define-extern pc-set-vsync (function symbol none)) +(define-extern pc-renderer-tree-set-lod (function pc-renderer-tree-type int none)) +(define-extern pc-set-letterbox (function int int none)) +(define-extern pc-set-collision (function symbol none)) +(define-extern pc-set-collision-wireframe (function symbol none)) +(define-extern pc-get-collision-mask (function pc-collision-mode int symbol)) +(define-extern pc-set-collision-mask (function pc-collision-mode int symbol none)) +(define-extern pc-set-collision-mode (function pc-collision-mode none)) +(declare-type discord-info structure) +(define-extern pc-discord-rpc-update (function discord-info none)) +(define-extern pc-discord-rpc-set (function int none)) +(define-extern pc-init-autosplitter-struct (function none)) +(define-extern pc-filepath-exists? (function string symbol)) +(define-extern pc-mkdir-file-path (function string none)) +(define-extern pc-sound-set-flava-hack (function int none)) +(define-extern pc-sound-set-fade-hack (function int none)) +(define-extern pc-set-window-lock (function symbol none)) +(define-extern pc-set-game-resolution (function int int none)) +(define-extern pc-set-brightness-contrast (function int int none)) +(define-extern pc-set-msaa (function int none)) +(define-extern pc-set-gfx-hack (function pc-gfx-hack symbol none)) +(define-extern pc-get-unix-timestamp (function int)) +(define-extern pc-filter-debug-string? (function string float symbol)) +(define-extern pc-screen-shot (function none)) +(declare-type screen-shot-settings structure) +(define-extern pc-register-screen-shot-settings (function screen-shot-settings none)) +(define-extern pc-treat-pad0-as-pad1 (function symbol none)) +(define-extern pc-is-imgui-visible? (function symbol)) +(define-extern pc-rand (function int)) + +(define-extern pc-encode-utf8-string (function string string none)) + +;; Jak 3 Specific Kernel Definitions +(define *pc-waiting-on-rpc?* symbol) +(define *pc-rpc-error?* symbol) + +(define-extern pc-get-last-rpc-error (function string none)) +(define-extern pc-fetch-external-race-times (function string none)) +(define-extern pc-fetch-external-speedrun-times (function string none)) +(define-extern pc-fetch-external-highscores (function string none)) +(define-extern pc-get-external-race-time (function string int string (pointer float) none)) ;; returns the score and the name in the given string ptr +(define-extern pc-get-external-speedrun-time (function string int string (pointer float) none)) ;; returns the score and the name in the given string ptr +(define-extern pc-get-external-highscore (function string int string (pointer float) none)) ;; returns the score and the name in the given string ptr +(define-extern pc-get-num-external-race-times (function string int)) +(define-extern pc-get-num-external-speedrun-times (function string int)) +(define-extern pc-get-num-external-highscores (function string int)) + +;; Speedrunner Mode Stuff +(define-extern pc-sr-mode-get-practice-entries-amount (function int)) +(define-extern pc-sr-mode-get-practice-entry-name (function int string none)) +(define-extern pc-sr-mode-get-practice-entry-continue-point (function int string none)) +(define-extern pc-sr-mode-get-practice-entry-history-success (function int int)) +(define-extern pc-sr-mode-get-practice-entry-history-attempts (function int int)) +(define-extern pc-sr-mode-get-practice-entry-session-success (function int int)) +(define-extern pc-sr-mode-get-practice-entry-session-attempts (function int int)) +(define-extern pc-sr-mode-get-practice-entry-avg-time (function int string none)) +(define-extern pc-sr-mode-get-practice-entry-fastest-time (function int string none)) +(define-extern pc-sr-mode-record-practice-entry-attempt! (function int symbol (pointer float) symbol)) +(declare-type speedrun-practice-objective structure) +(define-extern pc-sr-mode-init-practice-info! (function int speedrun-practice-objective none)) +;; TODO - a menu to dump out the 3 numbers with a pre-generated name to the file +(define-extern pc-sr-mode-get-custom-category-amount (function int)) +(define-extern pc-sr-mode-get-custom-category-name (function int string none)) +(define-extern pc-sr-mode-get-custom-category-continue-point (function int string none)) +(declare-type speedrun-custom-category structure) +(define-extern pc-sr-mode-init-custom-category-info! (function int speedrun-custom-category none)) +(define-extern pc-sr-mode-dump-new-custom-category (function speedrun-custom-category none)) + +(define-extern file-stream-open (function file-stream string symbol file-stream)) +(define-extern file-stream-close (function file-stream file-stream)) +(define-extern file-stream-length (function file-stream int)) +(define-extern file-stream-seek (function file-stream int int int)) +(define-extern file-stream-read (function file-stream pointer int int)) +(define-extern file-stream-write (function file-stream pointer uint uint)) + +(define-extern reset-path (function none)) + +(define-extern install-handler (function int function int)) +(define-extern flush-cache (function int none)) +(define-extern gs-store-image (function object object object)) +(define-extern sync-path (function int int int)) + +(define-extern kmalloc (function kheap int kmalloc-flags string pointer)) + +(define-extern *kernel-boot-message* symbol) +(define-extern *user* symbol) + +(define-extern new-dynamic-structure (function symbol type int structure)) + +(define-extern rpc-busy? (function int uint)) +(define-extern rpc-call (function int uint uint uint int uint int uint)) +(define-extern string->symbol (function string symbol)) +(define-extern pc-get-unix-timestamp (function int)) + +(define-extern link-begin (function pointer (pointer uint8) int kheap link-flag int)) +(define-extern link-reset (function none)) + +(define-extern kset-language (function language-enum int)) +(define-extern syncv (function int int)) + +(define-extern put-display-env (function object none)) + +;; +++memcard-h:mc-status-code +(defenum mc-status-code + :type uint32 + (busy 0) + (ok 1) + (bad-handle 2) + (format-failed 3) + (internal-error 4) + (write-error 5) + (read-error 6) + (new-game 7) + (no-memory 8) + (no-card 9) + (no-last 10) + (no-format 11) + (no-file 12) + (no-save 13) + (no-space 14) + (bad-version 15) + (no-process 16) + (no-auto-save 17) + ) +;; ---memcard-h:mc-status-code + +(define-extern mc-run (function none)) +(define-extern mc-format (function int mc-status-code)) +(define-extern mc-unformat (function int mc-status-code)) +(define-extern mc-create-file (function int uint mc-status-code)) +(define-extern mc-save (function int int pointer int mc-status-code)) +(define-extern mc-load (function int int pointer mc-status-code)) +(declare-type mc-slot-info structure) +(define-extern mc-sync (function int)) +(define-extern mc-get-slot-info (function int mc-slot-info none)) + +(define-extern mc-check-result (function mc-status-code)) +;; mc-makefile + +(define-extern __pc-get-mips2c (function string function)) + +(define-extern dma-sync (function pointer int int int)) + +(define-extern __pc-texture-upload-now (function object object none)) +(define-extern __pc-texture-relocate (function object object object none)) +(define-extern __pc-set-levels (function (pointer string) none)) +(define-extern __pc-set-active-levels (function (pointer string) none)) + +(define-extern link-resume (function int)) +(define-extern unload (function string none)) + +(define-extern reset-graph (function int int int int none)) + + +;; PC stuff +(defenum pc-prof-event + (begin 0) + (end 1) + (instant 2) + ) +(define-extern pc-prof (function string pc-prof-event none)) + +(define-extern *pc-settings-folder* string) +(define-extern *pc-settings-built-sha* string) + +(define-extern alloc-vagdir-names (function symbol (pointer uint64))) diff --git a/goal_src/jakx/kernel/dgo-h.gc b/goal_src/jakx/kernel/dgo-h.gc index 815cb215de..7fd1f51ca9 100644 --- a/goal_src/jakx/kernel/dgo-h.gc +++ b/goal_src/jakx/kernel/dgo-h.gc @@ -7,3 +7,24 @@ ;; DECOMP BEGINS +(deftype dgo-header (structure) + ((length uint32) + (rootname uint8 60) + ) + ) + + +(deftype dgo-entry (structure) + ((offset uint32) + (length uint32) + ) + ) + + +(deftype dgo-file (basic) + ((num-go-files uint32) + (total-length uint32) + (rsvd uint32) + (data uint8 :dynamic) + ) + ) diff --git a/goal_src/jakx/kernel/gcommon.gc b/goal_src/jakx/kernel/gcommon.gc index f6cb248b32..7454953796 100644 --- a/goal_src/jakx/kernel/gcommon.gc +++ b/goal_src/jakx/kernel/gcommon.gc @@ -5,5 +5,1763 @@ ;; name in dgo: gcommon ;; dgos: KERNEL +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Game constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; disable PS2 only code and enable PC-specific code +(defglobalconstant PC_PORT #t) + +;; whether we're allowed to use more memory than the original game or not +(defglobalconstant BIG_MEMORY #t) +(defglobalconstant PC_BIG_MEMORY (and PC_PORT BIG_MEMORY)) + +;; enables the with-profiler statements, which send profiling data from +;; GOAL code to the frame profiler in C++. +(defglobalconstant PC_PROFILER_ENABLE #t) + +;; pointers larger than this are invalid by valid? +(defconstant END_OF_MEMORY #x8000000) + +(define-extern valid? (function object type string symbol object symbol)) + +;; need to forward declare this, we haven't loaded the string library yet. +(define-extern name= (function object object symbol)) + ;; DECOMP BEGINS +(defun identity ((obj object)) + "The identity function." + obj + ) + +(defun 1/ ((x float)) + "Floating point reciprocal." + (/ 1.0 x) + ) + +(defun + ((a int) (b int)) + "64-bit integer addition." + (+ a b) + ) + +(defun - ((a int) (b int)) + "64-bit integer subraction." + (- a b) + ) + +(defun * ((a int) (b int)) + "32-bit signed integer multiplication." + (* a b) + ) + +(defun / ((a int) (b int)) + "32-bit signed integer division." + (/ a b) + ) + +(defun ash ((x int) (shift-amount int)) + "64-bit arithmetic shift. (sign-extends)" + ;; og:preserve-this + (declare (inline)) + (if (> shift-amount 0) + (shl x shift-amount) + (sar x (- shift-amount)) + ) + ) + +(defun mod ((a int) (b int)) + "32-bit mod." + (mod a b) + ) + +(defun rem ((a int) (b int)) + "32-bit mod (same as mod)." + (mod a b) + ) + +(defun abs ((x int)) + "64-bit integer absolute value." + ;; OpenGOAL doesn't support abs, so we implement it here. + ;; og:preserve-this + (if (> x 0) + x + (- x) + ) + ) + +(defun min ((a int) (b int)) + "64-bit integer minimum." + (if (> a b) b a) ;; og:preserve-this + ) + +(defun max ((a int) (b int)) + "64-bit integer maximum." + (if (> a b) a b) ;; og:preserve-this + ) + +(defun logior ((a int) (b int)) + "64-bit bitwise or." + (logior a b) + ) + +(defun logand ((a int) (b int)) + "64-bit bitwise and." + (logand a b) + ) + +(defun lognor ((a int) (b int)) + "64-bit bitwise not-or." + ;; og:preserve-this + (declare (inline)) + (lognot (logior a b)) + ) + +(defun logxor ((a int) (b int)) + "64-bit bitwise exclusive or." + (logxor a b) + ) + +(defun lognot ((x int)) + "64-bit bitwise not." + (lognot x) + ) + +(defun false-func () + "Returns false." + #f + ) + +(defun true-func () + "Returns true." + #t + ) + +(define format _format) + +(deftype vec4s (uint128) + "Vector of four floats, packed into a 128-bit integer as bitfields. +This behaves like a value type. +This is not the main vector type." + ((x float :offset 0 :size 32) + (y float :offset 32 :size 32) + (z float :offset 64 :size 32) + (w float :offset 96 :size 32) + ) + ) + +;; og:preserve-this +(defmacro print128 (value &key (stream #t)) + "Print a 128-bit value" + `(let ((temp (new 'stack-no-clear 'array 'uint64 2))) + (set! (-> (the (pointer uint128) temp)) ,value) + (format ,stream "#x~16X~16X" (-> temp 1) (-> temp 0)) + ) + ) + +(defmacro make-u128 (upper lower) + "Make a i128 from two 64-bit values." + `(rlet ((result :class i128) + (upper-xmm :class i128) + (lower-xmm :class i128)) + (.mov upper-xmm ,upper) + (.mov lower-xmm ,lower) + (.pcpyld result upper-xmm lower-xmm) + (the-as uint result) + ) + ) + +(defmethod print ((this vec4s)) + (format #t "#" (-> this x) (-> this y) (-> this z) (-> this w) this) + this + ) + +(deftype vector (structure) + "Vector of four floats, stored in a structure. +This behaves like a reference type. +This is the main vector type." + ((data float 4) + (x float :overlay-at (-> data 0)) + (y float :overlay-at (-> data 1)) + (z float :overlay-at (-> data 2)) + (w float :overlay-at (-> data 3)) + (quad uint128 :overlay-at (-> data 0)) + ) + ) + + +(deftype bfloat (basic) + "Boxed (or basic?) float. Just a basic that wraps a single float." + ((data float) + ) + ) + + +(defmethod print ((this bfloat)) + (format #t "~f" (-> this data)) + this + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this type)) + (the-as int (logand (the-as uint #xfffffff0) (+ (* (-> this allocated-length) 4) 43))) + ) + +(defun basic-type? ((obj basic) (typ type)) + "Return if the given basic is a given type. A child of the given type is also acceptable." + (let ((v1-0 (-> obj type)) + (a0-1 object) + ) + (until (= v1-0 a0-1) + (if (= v1-0 typ) + (return #t) + ) + (set! v1-0 (-> v1-0 parent)) + ) + ) + #f + ) + +(defun type-type? ((check-type type) (parent-type type)) + "Return if the first type is the second type, or a child of it." + (let ((v1-0 object)) + (if (= parent-type v1-0) + (return #t) + ) + (until (or (= check-type v1-0) (zero? check-type)) + (if (= check-type parent-type) + (return #t) + ) + (set! check-type (-> check-type parent)) + ) + ) + #f + ) + +(defun type? ((obj object) (desired-type type)) + "Return if the given object is an instance of the given type. + Works on basics, bintegers, or symbols." + (let ((v1-0 object) + (a0-1 (rtype-of obj)) + ) + (if (= desired-type v1-0) + (return #t) + ) + (until (or (= a0-1 v1-0) (zero? a0-1)) + (if (= a0-1 desired-type) + (return #t) + ) + (set! a0-1 (-> a0-1 parent)) + ) + ) + #f + ) + +(defun find-parent-method ((typ type) (method-id int)) + "Find the closest parent type that has a different implementation of the given method and return that method. + If it does not exist, return `nothing` function. + This is used to implement call-parent-method." + (local-vars (v0-0 function)) + (let ((v1-2 (-> typ method-table method-id))) + (until (!= v0-0 v1-2) + (if (= typ object) + (return nothing) + ) + (set! typ (-> typ parent)) + (set! v0-0 (-> typ method-table method-id)) + (if (zero? v0-0) + (return nothing) + ) + ) + ) + v0-0 + ) + +;; og:preserve-this +(defmacro call-parent-method (&rest args) + "Find the first different implementation of the current method in a parent type and call it with these arguments." + `((the (current-method-function-type) (find-parent-method (current-method-type) (current-method-id))) + ,@args) + ) + +(defun ref& ((list object) (idx int)) + "Return the n-th pair in a linked list of pairs. No bounds checking. + If it is the null pair, return #f." + (dotimes (v1-0 idx) + (nop!) + (nop!) + (set! list (cdr list)) + ) + (if (null? list) + #f + list + ) + ) + +(defun ref ((list object) (idx int)) + "Return the n-th item in a proper list. No bounds checking." + (dotimes (v1-0 idx) + (nop!) + (nop!) + (set! list (cdr list)) + ) + (car list) + ) + +(defmethod length ((this pair)) + (local-vars (v0-0 int)) + (cond + ((null? this) + (set! v0-0 0) + ) + (else + (let ((v1-1 (cdr this))) + (set! v0-0 1) + (while (and (not (null? v1-1)) (pair? v1-1)) + (+! v0-0 1) + (set! v1-1 (cdr v1-1)) + ) + ) + ) + ) + v0-0 + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this pair)) + (the-as int (-> pair size)) + ) + +(defun last ((list object)) + "Return the last object in a proper list." + (let ((v0-0 list)) + (while (not (null? (cdr v0-0))) + (nop!) + (nop!) + (set! v0-0 (cdr v0-0)) + ) + v0-0 + ) + ) + +(defun member ((obj-to-find object) (list object)) + "See if the first argument is in the proper list of the second argument. + Checked with simple equality. + If so, return the list starting at the at point (a truthy value). + Otherwise, return #f. + (member 'b '(a b c)) -> (b c d). + (member 'w '(a b c)) -> #f" + (let ((v1-0 list)) + (while (not (or (null? v1-0) (= (car v1-0) obj-to-find))) + (set! v1-0 (cdr v1-0)) + ) + (if (not (null? v1-0)) + v1-0 + ) + ) + ) + +(defun nmember ((obj-to-find basic) (list object)) + "Like member, but membership is checked with the name= function to handle symbols or strings." + (while (not (or (null? list) (name= (car list) obj-to-find))) + (set! list (cdr list)) + ) + (if (not (null? list)) + list + ) + ) + +(defun assoc ((key object) (assoc-list object)) + "Search an association list for given object. Return #f if not found, otherwise the element with matching car. + (assoc 'a '((a . 1) (b . 2) (c . 3))) -> (a . 1) + (assoc 'x '((a . 1) (b . 2) (c . 3))) -> #f" + (let ((v1-0 assoc-list)) + (while (not (or (null? v1-0) (= (car (car v1-0)) key))) + (set! v1-0 (cdr v1-0)) + ) + (if (not (null? v1-0)) + (car v1-0) + ) + ) + ) + +(defun assoce ((key object) (assoc-list object)) + "Like assoc, but supports a special `else` key which is always considered a match." + (let ((v1-0 assoc-list)) + (while (not (or (null? v1-0) (= (car (car v1-0)) key) (= (car (car v1-0)) 'else))) + (set! v1-0 (cdr v1-0)) + ) + (if (not (null? v1-0)) + (car v1-0) + ) + ) + ) + +(defun nassoc ((key string) (assoc-list object)) + "Like assoc, but uses name= instead of = to check equality." + (while (not (or (null? assoc-list) (let ((a1-1 (car (car assoc-list)))) + (if (pair? a1-1) + (nmember key a1-1) + (name= a1-1 key) + ) + ) + ) + ) + (set! assoc-list (cdr assoc-list)) + ) + (if (not (null? assoc-list)) + (car assoc-list) + ) + ) + +(defun nassoce ((key string) (assoc-list object)) + "Like assoce, but uses name= instead of = to check equality." + (while (not (or (null? assoc-list) (let ((s4-0 (car (car assoc-list)))) + (if (pair? s4-0) + (nmember key s4-0) + (or (name= s4-0 key) (= s4-0 'else)) + ) + ) + ) + ) + (set! assoc-list (cdr assoc-list)) + ) + (if (not (null? assoc-list)) + (car assoc-list) + ) + ) + +(defun append! ((list object) (new-obj object)) + "Append the second argument to the end of the list (or empty pair) in the first argument." + (cond + ((null? list) + new-obj + ) + (else + (let ((v1-1 list)) + (while (not (null? (cdr v1-1))) + (nop!) + (nop!) + (set! v1-1 (cdr v1-1)) + ) + (if (not (null? v1-1)) + (set! (cdr v1-1) new-obj) + ) + ) + list + ) + ) + ) + +;; WARN: Return type mismatch object vs pair. +(defun delete! ((obj object) (list object)) + "Remove an element from the given list, return the list." + (the-as pair (cond + ((= obj (car list)) + (cdr list) + ) + (else + (let ((v1-1 list) + (a2-0 (cdr list)) + ) + (while (not (or (null? a2-0) (= (car a2-0) obj))) + (set! v1-1 a2-0) + (set! a2-0 (cdr a2-0)) + ) + (if (not (null? a2-0)) + (set! (cdr v1-1) (cdr a2-0)) + ) + ) + list + ) + ) + ) + ) + +(defun delete-car! ((car-to-match object) (list object)) + "Remove an element from the given list with a matching car. Return the list." + (cond + ((= car-to-match (car (car list))) + (cdr list) + ) + (else + (let ((v1-2 list) + (a2-0 (cdr list)) + ) + (while (not (or (null? a2-0) (= (car (car a2-0)) car-to-match))) + (set! v1-2 a2-0) + (set! a2-0 (cdr a2-0)) + ) + (if (not (null? a2-0)) + (set! (cdr v1-2) (cdr a2-0)) + ) + ) + list + ) + ) + ) + +(defun insert-cons! ((new-obj object) (list object)) + "Update an association list to have the given (key . value) pair. + If a previous value exists, it is deleted first. + This function always allocates a pair through `cons` on the global heap, which can never be freed, + so it should almost never be used at runtime." + (let ((a3-0 (delete-car! (car new-obj) list))) + (cons new-obj a3-0) + ) + ) + +(defun sort ((list pair) (compare-func (function object object object))) + "Sort a list using the given comparision function. + The function can return a #t/#f value, or a positive/negative value. + For example, you could use either `-` or `<` as functions to sort integers." + (let ((s4-0 -1)) + (while (nonzero? s4-0) + (set! s4-0 0) + (let ((s3-0 list)) + (while (not (or (null? (cdr s3-0)) (not (pair? (cdr s3-0))))) + (let* ((s2-0 (car s3-0)) + (s1-0 (car (cdr s3-0))) + (v1-1 (compare-func s2-0 s1-0)) + ) + (when (and (or (not v1-1) (> (the-as int v1-1) 0)) (!= v1-1 #t)) + (+! s4-0 1) + (set! (car s3-0) s1-0) + (set! (car (cdr s3-0)) s2-0) + ) + ) + (set! s3-0 (cdr s3-0)) + ) + ) + ) + ) + list + ) + +(defun string->symbol-debug ((str string)) + "Convert a string to a symbol. The symbol must be known, and this cannot + create a new symbol. (in the PC port, it will still work.) + This is inteded to be used in debug only, and will not trigger a warning. + In debug, this will work for all symbols." + (let ((gp-0 *kernel-symbol-warnings*)) + (set! *kernel-symbol-warnings* #f) + (let ((v0-0 (string->symbol str))) + (set! *kernel-symbol-warnings* gp-0) + v0-0 + ) + ) + ) + +(defun symbol->string-debug ((sym symbol)) + "Get the name of a symbol. This is intended to be used in debug only. + In debug, this will work for all symbols. (In PC port, this works always)" + (let ((gp-0 *kernel-symbol-warnings*)) + (set! *kernel-symbol-warnings* #f) + (let ((v0-0 (symbol->string sym))) + (set! *kernel-symbol-warnings* gp-0) + v0-0 + ) + ) + ) + +;; WARN: Return type mismatch symbol vs int. +(defun symbol->hash ((sym symbol)) + "Convert a symbol to a unique integer value, which is just the symbol's address." + (the-as int sym) + ) + +(defmethod new array ((allocation symbol) (type-to-make type) (arg0 type) (arg1 int)) + (let ((v0-1 (object-new + allocation + type-to-make + (the-as int (+ (-> type-to-make size) (* arg1 (if (type-type? arg0 number) + (the-as int (-> arg0 size)) + 4 + ) + ) + ) + ) + ) + ) + ) + (set! (-> v0-1 allocated-length) arg1) + (set! (-> v0-1 length) arg1) + (set! (-> v0-1 content-type) arg0) + v0-1 + ) + ) + +(defmethod print ((this array)) + (format #t "#(") + (cond + ((type-type? (-> this content-type) integer) + (case (-> this content-type symbol) + (('int32) + (dotimes (s5-0 (-> this length)) + (format + #t + (if (zero? s5-0) + "~D" + " ~D" + ) + (-> (the-as (array int32) this) s5-0) + ) + ) + ) + (('uint32) + (dotimes (s5-1 (-> this length)) + (format + #t + (if (zero? s5-1) + "~D" + " ~D" + ) + (-> (the-as (array uint32) this) s5-1) + ) + ) + ) + (('int64) + (dotimes (s5-2 (-> this length)) + (format + #t + (if (zero? s5-2) + "~D" + " ~D" + ) + (-> (the-as (array int64) this) s5-2) + ) + ) + ) + (('uint64) + (dotimes (s5-3 (-> this length)) + (format + #t + (if (zero? s5-3) + "#x~X" + " #x~X" + ) + (-> (the-as (array uint64) this) s5-3) + ) + ) + ) + (('int8) + (dotimes (s5-4 (-> this length)) + (format + #t + (if (zero? s5-4) + "~D" + " ~D" + ) + (-> (the-as (array int8) this) s5-4) + ) + ) + ) + (('uint8) + (dotimes (s5-5 (-> this length)) + (format + #t + (if (zero? s5-5) + "~D" + " ~D" + ) + (-> (the-as (array uint8) this) s5-5) + ) + ) + ) + (('int16) + (dotimes (s5-6 (-> this length)) + (format + #t + (if (zero? s5-6) + "~D" + " ~D" + ) + (-> (the-as (array int16) this) s5-6) + ) + ) + ) + (('uint16) + (dotimes (s5-7 (-> this length)) + (format + #t + (if (zero? s5-7) + "~D" + " ~D" + ) + (-> (the-as (array uint16) this) s5-7) + ) + ) + ) + (('uint128 'int128) + (dotimes (s5-8 (-> this length)) + (format + #t + (if (zero? s5-8) + "#x~X" + " #x~X" + ) + (-> (the-as (array uint128) this) s5-8) + ) + ) + ) + (else + (dotimes (s5-9 (-> this length)) + (format + #t + (if (zero? s5-9) + "~D" + " ~D" + ) + (-> (the-as (array int32) this) s5-9) + ) + ) + ) + ) + ) + ((= (-> this content-type) float) + (dotimes (s5-10 (-> this length)) + (if (zero? s5-10) + (format #t "~f" (-> (the-as (array float) this) s5-10)) + (format #t " ~f" (-> (the-as (array float) this) s5-10)) + ) + ) + ) + (else + (dotimes (s5-11 (-> this length)) + (if (zero? s5-11) + (format #t "~A" (-> (the-as (array basic) this) s5-11)) + (format #t " ~A" (-> (the-as (array basic) this) s5-11)) + ) + ) + ) + ) + (format #t ")") + this + ) + +;; og:preserve-this +(defmethod inspect ((this array)) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~Tlength: ~D~%" (-> this length)) + (format #t "~Tcontent-type: ~A~%" (-> this content-type)) + (format #t "~Tdata[~D]: @ #x~X~%" (-> this allocated-length) (-> this data)) + (cond + ((and (= (logand (the-as int (-> this content-type)) 7) 4) (type-type? (-> this content-type) integer)) + (case (-> this content-type symbol) + (('int32) + (dotimes (s5-0 (-> this length)) + (format #t "~T [~D] ~D~%" s5-0 (-> (the-as (array int32) this) s5-0)) + ) + ) + (('uint32) + (dotimes (s5-1 (-> this length)) + (format #t "~T [~D] ~D~%" s5-1 (-> (the-as (array uint32) this) s5-1)) + ) + ) + (('int64) + (dotimes (s5-2 (-> this length)) + (format #t "~T [~D] ~D~%" s5-2 (-> (the-as (array int64) this) s5-2)) + ) + ) + (('uint64) + (dotimes (s5-3 (-> this length)) + (format #t "~T [~D] #x~X~%" s5-3 (-> (the-as (array uint64) this) s5-3)) + ) + ) + (('int8) + (dotimes (s5-4 (-> this length)) + (format #t "~T [~D] ~D~%" s5-4 (-> (the-as (array int8) this) s5-4)) + ) + ) + (('uint8) + (dotimes (s5-5 (-> this length)) + (format #t "~T [~D] ~D~%" s5-5 (-> (the-as (array int8) this) s5-5)) + ) + ) + (('int16) + (dotimes (s5-6 (-> this length)) + (format #t "~T [~D] ~D~%" s5-6 (-> (the-as (array int16) this) s5-6)) + ) + ) + (('uint16) + (dotimes (s5-7 (-> this length)) + (format #t "~T [~D] ~D~%" s5-7 (-> (the-as (array uint16) this) s5-7)) + ) + ) + (('int128 'uint128) + (dotimes (s5-8 (-> this length)) + (format #t "~T [~D] #x~X~%" s5-8 (-> (the-as (array uint128) this) s5-8)) + ) + ) + (else + (dotimes (s5-9 (-> this length)) + (format #t "~T [~D] ~D~%" s5-9 (-> (the-as (array int32) this) s5-9)) + ) + ) + ) + ) + ((= (-> this content-type) float) + (dotimes (s5-10 (-> this length)) + (format #t "~T [~D] ~f~%" s5-10 (-> (the-as (array float) this) s5-10)) + ) + ) + (else + (dotimes (s5-11 (-> this length)) + (format #t "~T [~D] ~A~%" s5-11 (-> (the-as (array basic) this) s5-11)) + ) + ) + ) + this + ) + +(defmethod length ((this array)) + (-> this length) + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this array)) + (the-as + int + (+ (-> this type size) (* (-> this allocated-length) (if (type-type? (-> this content-type) number) + (the-as int (-> this content-type size)) + 4 + ) + ) + ) + ) + ) + +;; og:preserve-this +(defun qmem-copy<-! ((dst pointer) (src pointer) (qwc int)) + "Copy memory by quadword (16-bytes). Must by 16-byte aligned, size in 16-byte units. Increasing address copy. Not an optimized version." + (let ((v0-0 dst)) + (countdown (v1-1 (/ (+ qwc 15) 16)) + (set! (-> (the-as (pointer uint128) dst)) (-> (the-as (pointer uint128) src))) + (&+! dst 16) + (&+! src 16) + ) + v0-0 + ) + ) + +(defun quad-copy! ((dst pointer) (src pointer) (qwc int)) + "Optimized memory copy. The original is pretty clever, but this isn't." + (qmem-copy<-! dst src (* qwc 16)) + (none) + ) + +(defun qmem-copy->! ((dst pointer) (src pointer) (qwc int)) + "Copy memory by quadword (16-bytes). Must by 16-byte aligned, size in 16-byte units. Decreasing address copy. Not an optimized version." + (let ((v0-0 dst)) + (let* ((v1-1 (/ (+ qwc 15) 16)) + (a0-1 (&+ dst (* v1-1 16))) + (a1-1 (&+ src (* v1-1 16))) + ) + (while (nonzero? v1-1) + (+! v1-1 -1) + (&+! a0-1 -16) + (&+! a1-1 -16) + (set! (-> (the-as (pointer uint128) a0-1)) (-> (the-as (pointer uint128) a1-1))) + ) + ) + v0-0 + ) + ) + +(defun qmem-clear! ((dst pointer) (qwc int)) + "Clear memory by quadword (16-bytes). Must by 16-byte aligned, size in 16-byte units. Not an optimized version." + (let ((v0-0 dst)) + (dotimes (v1-0 qwc) + (set! (-> (the-as (pointer int128) dst)) (the int128 0)) + (&+! dst 16) + ) + v0-0 + ) + ) + +;; WARN: Using logior on pointers +;; WARN: Using logior on pointers +(defun mem-copy! ((dst pointer) (src pointer) (bytes int)) + (let ((gp-0 dst)) + (let ((s4-0 dst) + (s5-0 src) + ) + (cond + ((not (logtest? (logior s4-0 (the-as uint s5-0)) 15)) + (let* ((v1-2 (/ bytes 16)) + (s2-0 (* v1-2 16)) + (s3-0 (- bytes s2-0)) + ) + (case v1-2 + ((1) + (set! (-> (the-as (pointer uint128) s4-0)) (-> (the-as (pointer uint128) s5-0))) + ) + ((2) + (let ((a0-2 (-> (the-as (pointer uint128) s5-0))) + (v1-4 (-> (the-as (pointer uint128) s5-0) 1)) + ) + (set! (-> (the-as (pointer uint128) s4-0) 0) a0-2) + (set! (-> (the-as (pointer uint128) s4-0) 1) v1-4) + ) + ) + ((3) + (let ((a0-3 (-> (the-as (pointer uint128) s5-0) 0)) + (a1-4 (-> (the-as (pointer uint128) s5-0) 1)) + (v1-5 (-> (the-as (pointer uint128) s5-0) 2)) + ) + (set! (-> (the-as (pointer uint128) s4-0) 0) a0-3) + (set! (-> (the-as (pointer uint128) s4-0) 1) a1-4) + (set! (-> (the-as (pointer uint128) s4-0) 2) v1-5) + ) + ) + ((4) + (let ((a0-4 (-> (the-as (pointer uint128) s5-0) 0)) + (a1-6 (-> (the-as (pointer uint128) s5-0) 1)) + (a2-1 (-> (the-as (pointer uint128) s5-0) 2)) + (v1-6 (-> (the-as (pointer uint128) s5-0) 3)) + ) + (set! (-> (the-as (pointer uint128) s4-0) 0) a0-4) + (set! (-> (the-as (pointer uint128) s4-0) 1) a1-6) + (set! (-> (the-as (pointer uint128) s4-0) 2) a2-1) + (set! (-> (the-as (pointer uint128) s4-0) 3) v1-6) + ) + ) + ((5) + (let ((a0-5 (-> (the-as (pointer uint128) s5-0) 0)) + (a1-8 (-> (the-as (pointer uint128) s5-0) 1)) + (a2-2 (-> (the-as (pointer uint128) s5-0) 2)) + (a3-0 (-> (the-as (pointer uint128) s5-0) 3)) + (v1-7 (-> (the-as (pointer uint128) s5-0) 4)) + ) + (set! (-> (the-as (pointer uint128) s4-0) 0) a0-5) + (set! (-> (the-as (pointer uint128) s4-0) 1) a1-8) + (set! (-> (the-as (pointer uint128) s4-0) 2) a2-2) + (set! (-> (the-as (pointer uint128) s4-0) 3) a3-0) + (set! (-> (the-as (pointer uint128) s4-0) 4) v1-7) + ) + ) + ((6) + (let ((a0-6 (-> (the-as (pointer uint128) s5-0) 0)) + (a1-10 (-> (the-as (pointer uint128) s5-0) 1)) + (a2-3 (-> (the-as (pointer uint128) s5-0) 2)) + (a3-1 (-> (the-as (pointer uint128) s5-0) 3)) + (t0-0 (-> (the-as (pointer uint128) s5-0) 4)) + (v1-8 (-> (the-as (pointer uint128) s5-0) 5)) + ) + (set! (-> (the-as (pointer uint128) s4-0) 0) a0-6) + (set! (-> (the-as (pointer uint128) s4-0) 1) a1-10) + (set! (-> (the-as (pointer uint128) s4-0) 2) a2-3) + (set! (-> (the-as (pointer uint128) s4-0) 3) a3-1) + (set! (-> (the-as (pointer uint128) s4-0) 4) t0-0) + (set! (-> (the-as (pointer uint128) s4-0) 5) v1-8) + ) + ) + (else + (quad-copy! s4-0 s5-0 v1-2) + ) + ) + (let ((v1-10 (&+ s4-0 s2-0)) + (a0-8 (&+ s5-0 s2-0)) + ) + (dotimes (a1-12 s3-0) + (set! (-> (the-as (pointer uint8) v1-10)) (-> (the-as (pointer uint8) a0-8))) + (&+! v1-10 1) + (&+! a0-8 1) + ) + ) + ) + ) + (else + (dotimes (v1-13 bytes) + (set! (-> (the-as (pointer uint8) s4-0)) (-> (the-as (pointer uint8) s5-0))) + (&+! s4-0 1) + (&+! s5-0 1) + ) + ) + ) + ) + gp-0 + ) + ) + +(defun mem-clear! ((arg0 pointer) (arg1 int)) + "Basic memory clear. Size in 1-byte units. Not an optimized version." + (let ((v1-0 arg0)) + (while (> arg1 0) + (set! (-> (the-as (pointer int8) v1-0)) 0) + (&+! v1-0 1) + (set! arg1 (+ arg1 -1)) + ) + ) + #f + ) + +(defun mem-set32! ((dst pointer) (word-count int) (value int)) + "Set memory to the given 32-bit value, repeated n times. (like C memset, but setting int32_t instead of char). + Not an optimized implementation. Must be 4-byte aligned." + (let ((v0-0 dst)) + (dotimes (v1-0 word-count) + (set! (-> (the-as (pointer int32) dst)) value) + (&+! dst 4) + (nop!) + ) + v0-0 + ) + ) + +(defun mem-or! ((dst pointer) (src pointer) (bytes int)) + "Set the destiation to `dest = dest | src`. Size in bytes. Not an optimized version." + (let ((v0-0 dst)) + (dotimes (v1-0 bytes) + (logior! (-> (the-as (pointer uint8) dst)) (-> (the-as (pointer uint8) src))) + (&+! dst 1) + (&+! src 1) + ) + v0-0 + ) + ) + +(deftype inline-array-class (basic) + "Base class for basic inline arrays. +The stride is stored in the heap-base of the inline-array-class child class." + ((length int32) + (allocated-length int32) + (_data uint8 :dynamic :offset 16) + ) + (:methods + (new (symbol type int) _type_) + (push-back (_type_ object) int) + (inline-array-class-method-10 () none) + (clear-1 (_type_) symbol) + (clear-2 (_type_) int) + (pop-front (_type_ int) pointer) + ) + ) + + +(deftype inline-array-class-uint64 (inline-array-class) + "Specialization of inline-array-class for uint64. It's unclear why +this would be preferred over a normal (array uint64), since both store data the same way." + ((data uint64 :dynamic :offset 16) + ) + ) + + +(deftype inline-array-class-uint32 (inline-array-class) + "Specialization of inline-array-class for uint32. It's unclear why this would be preferred +over a normal (array uint32), since both store data the same way." + ((data uint32 :dynamic :offset 16) + ) + ) + + +(defmethod new inline-array-class ((allocation symbol) (type-to-make type) (count int)) + (let ((v0-0 (object-new + allocation + type-to-make + (the-as int (+ (-> type-to-make size) (* (the-as uint count) (-> type-to-make heap-base)))) + ) + ) + ) + (when (nonzero? v0-0) + (set! (-> v0-0 length) count) + (set! (-> v0-0 allocated-length) count) + ) + v0-0 + ) + ) + +(defmethod length ((this inline-array-class)) + (-> this length) + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this inline-array-class)) + (the-as int (+ (-> this type size) (* (-> this allocated-length) (the-as int (-> this type heap-base))))) + ) + +(defmethod push-back ((object-to-insert inline-array-class) (arg0 object)) + "Copy object to the end, then increment length. No bounds check." + (let ((s5-0 (-> object-to-insert length))) + (let ((a2-0 (-> object-to-insert type heap-base))) + (mem-copy! + (the-as + pointer + (+ (+ (* s5-0 (the-as int (-> object-to-insert type heap-base))) -4 (-> object-to-insert type size)) + (the-as int object-to-insert) + ) + ) + (the-as pointer arg0) + (the-as int a2-0) + ) + ) + (+! (-> object-to-insert length) 1) + s5-0 + ) + ) + +(defmethod push-back ((this inline-array-class-uint32) (arg0 object)) + "Copy object to the end, then increment length. No bounds check." + (let ((v0-0 (-> this length))) + (-> this type heap-base) + (set! (-> (the-as + (pointer int32) + (+ (+ (* v0-0 (the-as int (-> this type heap-base))) -4 (-> this type size)) (the-as int this)) + ) + ) + (the-as int32 arg0) + ) + (+! (-> this length) 1) + v0-0 + ) + ) + +(defmethod push-back ((this inline-array-class-uint64) (arg0 object)) + "Copy object to the end, then increment length. No bounds check." + (let ((v0-0 (-> this length))) + (-> this type heap-base) + (set! (-> (the-as + (pointer int64) + (+ (+ (* v0-0 (the-as int (-> this type heap-base))) -4 (-> this type size)) (the-as int this)) + ) + ) + (the-as int64 arg0) + ) + (+! (-> this length) 1) + v0-0 + ) + ) + +(defmethod pop-front ((this inline-array-class) (arg0 int)) + "Remove first object by copying last object to the front, then decrement length." + (+! (-> this length) -1) + (+ (-> this length) -1) + (let ((a2-0 (-> this type heap-base)) + (t9-0 mem-copy!) + (v1-10 (+ (+ (* (the-as uint arg0) (-> this type heap-base)) -4 (-> this type size)) (the-as uint this))) + (a1-4 (-> this type heap-base)) + ) + (t9-0 + (the-as pointer v1-10) + (the-as pointer (+ (+ (* (-> this length) (the-as int a1-4)) -4 (-> this type size)) (the-as int this))) + (the-as int a2-0) + ) + ) + ) + +;; WARN: Return type mismatch uint vs pointer. +(defmethod pop-front ((this inline-array-class-uint64) (arg0 int)) + "Remove first object by copying last object to the front, then decrement length." + (+! (-> this length) -1) + (+ (-> this length) -1) + (-> this type heap-base) + (let* ((v1-7 (-> this type heap-base)) + (v0-0 (-> (the-as + (pointer uint64) + (+ (+ (* (-> this length) (the-as int v1-7)) -4 (-> this type size)) (the-as int this)) + ) + ) + ) + ) + (set! (-> (the-as + (pointer uint64) + (+ (+ (* (the-as uint arg0) (-> this type heap-base)) -4 (-> this type size)) (the-as uint this)) + ) + ) + v0-0 + ) + (the-as pointer v0-0) + ) + ) + +;; WARN: Return type mismatch uint vs pointer. +(defmethod pop-front ((this inline-array-class-uint32) (arg0 int)) + "Remove first object by copying last object to the front, then decrement length." + (+! (-> this length) -1) + (+ (-> this length) -1) + (-> this type heap-base) + (let* ((v1-7 (-> this type heap-base)) + (v0-0 (-> (the-as + (pointer uint32) + (+ (+ (* (-> this length) (the-as int v1-7)) -4 (-> this type size)) (the-as int this)) + ) + ) + ) + ) + (set! (-> (the-as + (pointer uint32) + (+ (+ (* (the-as uint arg0) (-> this type heap-base)) -4 (-> this type size)) (the-as uint this)) + ) + ) + v0-0 + ) + (the-as pointer v0-0) + ) + ) + +(defmethod clear-2 ((this inline-array-class)) + "Set length to 0" + (set! (-> this length) 0) + 0 + ) + +(defmethod clear-1 ((this inline-array-class)) + "Set length to 0, return #t." + (set! (-> this length) 0) + #t + ) + +(deftype int32-array (inline-array-class) + ((data int32 :inline :dynamic) + ) + ) + + +(set! (-> int32-array heap-base) (the-as uint 4)) + +;; og:preserve-this +(defun-recursive fact int ((x int)) + (if (= x 1) + 1 + (* x (fact (+ x -1)))) + ) + +(define *print-column* (the-as binteger 0)) + +(defun print ((obj object)) + "Print any boxed object (symbol, pair, basic, binteger) to #t (the REPL). No newline." + ((method-of-type (rtype-of obj) print) obj) + ) + +(defun printl ((obj object)) + "Print any boxed object (symbol, pair, basic, binteger) to #t (the REPL), followed by a newline." + (let ((a0-1 obj)) + ((method-of-type (rtype-of a0-1) print) a0-1) + ) + (format #t "~%") + obj + ) + +(defun inspect ((obj object)) + "Inspect any boxed object (symbol, pair, basic, binteger) to #t (the REPL)." + ((method-of-type (rtype-of obj) inspect) obj) + ) + +(defun-debug mem-print ((ptr (pointer uint32)) (word-count int)) + "Print out data in memory in hex." + (dotimes (s4-0 (/ word-count 4)) + (format + 0 + "~X: ~X ~X ~X ~X~%" + (&-> ptr (* s4-0 4)) + (-> ptr (* s4-0 4)) + (-> ptr (+ (* s4-0 4) 1)) + (-> ptr (+ (* s4-0 4) 2)) + (-> ptr (+ (* s4-0 4) 3)) + ) + ) + #f + ) + +(define *trace-list* '()) + +(defun print-tree-bitmask ((mask int) (count int)) + "Print out ASCII-art tree structure, from a bitmask of nesting levels." + (dotimes (s4-0 count) + (if (not (logtest? mask 1)) + (format #t " ") + (format #t "| ") + ) + (set! mask (shr mask 1)) + ) + #f + ) + +;; ERROR: Unsupported inline assembly instruction kind - [mtdab a1] +;; ERROR: Unsupported inline assembly instruction kind - [mtdabm a2] +(defun breakpoint-range-set! ((arg0 uint) (arg1 uint) (arg2 uint)) + "Unsupported function to set a CPU breakpoint." + (break!) ;; og:preserve-this + ; (.mtc0 Debug arg0) + ; (.mtdab arg1) + ; (.mtdabm arg2) + 0 + ) + +(defmacro start-of-symbol-table () + "Get the address for the start of the symbol table." + `(rlet ((st :reg r14 :reset-here #t :type uint)) + (the uint (- st 32768)) + ) + ) + +(defmacro end-of-symbol-table () + "Get the address of the end of the symbol table." + `(rlet ((st :reg r14 :reset-here #t :type uint)) + (the uint (+ st 32768)) + ) + ) + +;; ERROR: Unsupported inline assembly instruction kind - [daddu v1, v1, s7] +;; ERROR: Unsupported inline assembly instruction kind - [daddu v1, v1, s7] +;; ERROR: Unsupported inline assembly instruction kind - [daddu v1, v1, s7] +;; ERROR: Unsupported inline assembly instruction kind - [daddu v1, v1, s7] +(defun valid? ((obj object) (expected-type type) (err-msg-str string) (allow-false symbol) (err-msg-dest object)) + ;; og:preserve-this + ;; cleaned up significantly. + ;; (local-vars (v1-11 int) (v1-26 int) (v1-56 int) (v1-60 int) (s7-0 none)) + (let ((v1-1 + (and (>= (the-as uint obj) (start-of-symbol-table)) (< (the-as uint obj) END_OF_MEMORY)) + ) + ) + (cond + ((not expected-type) + (cond + ((logtest? (the-as int obj) 3) + (if err-msg-str + (format err-msg-dest "ERROR: object #x~X ~S is not a valid object (misaligned)~%" obj err-msg-str) + ) + #f + ) + ((not v1-1) + (if err-msg-str + (format err-msg-dest "ERROR: object #x~X ~S is not a valid object (bad address)~%" obj err-msg-str) + ) + #f + ) + (else + #t + ) + ) + ) + ((and allow-false (not obj)) + #t + ) + ((= expected-type structure) + (cond + ((logtest? (the-as int obj) 15) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%" + obj + err-msg-str + expected-type + ) + ) + #f + ) + ((or (not v1-1) (< (the-as uint obj) (end-of-symbol-table))) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%" + obj + err-msg-str + expected-type + ) + ) + #f + ) + (else + #t + ) + ) + ) + ((= expected-type pair) + (cond + ((not (pair? obj)) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%" + obj + err-msg-str + expected-type + ) + ) + #f + ) + ((not v1-1) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%" + obj + err-msg-str + expected-type + ) + ) + #f + ) + (else + #t + ) + ) + ) + ((= expected-type binteger) + (cond + ((not (logtest? (the-as int obj) 7)) + #t + ) + (else + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%" + obj + err-msg-str + expected-type + ) + ) + #f + ) + ) + ) + ((or (= expected-type symbol) (= expected-type boolean)) + (cond + ((not (logtest? (the-as int obj) 1)) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%" + obj + err-msg-str + expected-type + ) + ) + #f + ) + ((or (not v1-1) (< (the-as int obj) (start-of-symbol-table)) (>= (the-as int obj) (end-of-symbol-table))) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%" + obj + err-msg-str + expected-type + ) + ) + #f + ) + (else + #t + ) + ) + ) + ((!= (logand (the-as int obj) 7) 4) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%" + obj + err-msg-str + expected-type + ) + ) + #f + ) + ((not v1-1) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%" + obj + err-msg-str + expected-type + ) + ) + #f + ) + ((and (= expected-type type) (!= (rtype-of obj) type)) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (invalid type #x~X)~%" + obj + err-msg-str + expected-type + (rtype-of obj) + ) + ) + #f + ) + ((and (!= expected-type type) (not (valid? (rtype-of obj) type (the-as string #f) #t 0))) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (invalid type #x~X)~%" + obj + err-msg-str + expected-type + (rtype-of obj) + ) + ) + #f + ) + ((not (type? obj expected-type)) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (is type '~A' instead)~%" + obj + err-msg-str + expected-type + (rtype-of obj) + ) + ) + #f + ) + ((= expected-type symbol) + (cond + ((>= (the-as uint obj) (end-of-symbol-table)) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (not in symbol table)~%" + obj + err-msg-str + expected-type + ) + ) + #f + ) + (else + #t + ) + ) + ) + ((< (the-as uint obj) (end-of-symbol-table)) + (if err-msg-str + (format + err-msg-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (inside symbol table)~%" + obj + err-msg-str + expected-type + ) + ) + #f + ) + (else + #t + ) + ) + ) + ) + +(defun atoi ((arg0 pointer)) + (local-vars (a1-6 symbol)) + (let ((v0-0 0)) + (let ((v1-0 #f)) + (when (= (-> (the-as (pointer uint8) arg0)) 45) + (set! arg0 (&+ arg0 1)) + (set! v1-0 #t) + ) + (until a1-6 + (let ((a1-4 (* 10 v0-0))) + (set! v0-0 (the-as int (+ (-> (the-as (pointer uint8) arg0)) -48 a1-4))) + ) + (&+! arg0 1) + (set! a1-6 (or (>= (-> (the-as (pointer uint8) arg0)) (the-as uint 58)) + (< (-> (the-as (pointer uint8) arg0)) (the-as uint 48)) + ) + ) + ) + (if v1-0 + (set! v0-0 (- v0-0)) + ) + ) + v0-0 + ) + ) + +(defun atoi-string ((arg0 string)) + (atoi (-> arg0 data)) + ) + +;; WARN: new jak 2 until loop case, check carefully +(defun atoi-better ((arg0 pointer)) + (until #f + (if (zero? (-> (the-as (pointer uint8) arg0))) + (return (the-as int #f)) + ) + (if (and (>= (-> (the-as (pointer uint8) arg0)) (the-as uint 48)) + (< (-> (the-as (pointer uint8) arg0)) (the-as uint 58)) + ) + (return (atoi arg0)) + ) + (set! arg0 (&+ arg0 1)) + ) + #f + (the-as int #f) + ) + +(defun itoa ((arg0 int) (arg1 pointer)) + (when (< arg0 0) + (set! arg0 (- arg0)) + (set! (-> (the-as (pointer int8) arg1)) 45) + (set! arg1 (&+ arg1 1)) + ) + (let ((v1-5 10)) + (while (>= arg0 v1-5) + (set! v1-5 (* 10 v1-5)) + ) + (let ((v1-6 (/ v1-5 10))) + (while (> v1-6 0) + (set! (-> (the-as (pointer int8) arg1)) (+ (mod (/ arg0 v1-6) 10) 48)) + (&+! arg1 1) + (set! v1-6 (/ v1-6 10)) + ) + ) + ) + (set! (-> (the-as (pointer int8) arg1)) 0) + 0 + 0 + ) + +(defun x8toi ((arg0 pointer)) + (let ((v1-0 arg0) + (v0-0 0) + ) + (dotimes (a0-1 8) + (let ((a1-1 (+ (-> (the-as (pointer int8) v1-0)) -48))) + (if (< 10 a1-1) + (+! a1-1 -7) + ) + (if (< 10 a1-1) + (+! a1-1 -32) + ) + (set! v0-0 (+ (* v0-0 16) a1-1)) + ) + (&+! v1-0 1) + ) + v0-0 + ) + ) + +;;;;;;;;;;;;;;;;;;;; +;; Profiler Macros +;;;;;;;;;;;;;;;;;;;; + + +(defmacro profiler-instant-event (name) + "Record an 'instant' event in the profile. + This can be used however you'd like, but there should be a + 'ROOT' event logged every now and then (like once per frame) + when no timed events are in progress, to allow the profiler + to correctly recover the event stack." + `(#when PC_PROFILER_ENABLE + (pc-prof ,name (pc-prof-event instant)) + ) + ) + +(defmacro profiler-start-event (name) + "Start a timed event with the given name." + `(#when PC_PROFILER_ENABLE + (pc-prof ,name (pc-prof-event begin)) + ) + ) + +(defmacro profiler-end-event () + "End the most recently started event that hasn't been stopped yet. + It is up to you to correctly balance the starts/ends, otherwise + the profiling data will be corrupted." + `(#when PC_PROFILER_ENABLE + (pc-prof "" (pc-prof-event end)) + ) + ) + +(defmacro with-pc-profiler (name &rest body) + "Execute the body in a named profiler block. + Do not `return` or `go` from inside this block, + otherwise the end will be skipped." + `(#if PC_PROFILER_ENABLE + (begin + (pc-prof ,name (pc-prof-event begin)) + ,@body + (pc-prof ,name (pc-prof-event end)) + ) + (begin + ,@body + ) + ) + ) + +;;;;;;;;;;;;;;;;;;;;;;;; +;; Decompiler Macros +;;;;;;;;;;;;;;;;;;;;;;;; + +;; inserted by the decompiler for assembly branches. +(defmacro b! (pred destination &key (delay '()) &key (likely-delay '())) + "Branch!" + ;; evaluate the predicate + `(let ((should-branch ,pred)) + ;; normal delay slot: + ,delay + (when should-branch + ,likely-delay + (goto ,destination) + ) + ) + ) + +;; the decompiler may fail to recognize setting fields of a 128-bit bitfield +;; and will rely on this macro: +(defmacro copy-and-set-field (original field-name field-value) + `(let ((temp-copy ,original)) + (set! (-> temp-copy ,field-name) ,field-value) + temp-copy + ) + ) + +;; inserted by the decompiler if a c->goal bool conversion can't be compacted into a single +;; expression. +(defmacro cmove-#f-zero (dest condition src) + `(if (zero? ,condition) + (set! ,dest #f) + (set! ,dest ,src) + ) + ) + +(defmacro cmove-#f-nonzero (dest condition src) + `(if (zero? ,condition) + (set! ,dest ,src) + (set! ,dest #f) + ) + ) + +(defmacro empty-form () + `(none) + ) + +(defmacro sext32 (in) + `(sar (shl ,in 32) 32) + ) + +(defmacro .sra (result in sa) + `(set! ,result (sext32 (sar (logand #xffffffff (the-as int ,in)) ,sa))) + ) + +(defmacro l32-false-check (in) + `(- (logand #xffffffff (the-as uint ,in)) (the-as uint #f)) + ) + +;;;;;;;;;;;;;;;;;;;;;;; +;; PC Port asm macros +;;;;;;;;;;;;;;;;;;;;;;; +(#when PC_PORT + ;; SYNC is an EE instruction that waits for various memory access and DMA to be completed + ;; DMA will be instant in the PC port, so these are no longer necessary + (fake-asm .sync.l) + (fake-asm .sync.p) + ;; Copies the contents of a cop0 (system control) register to a gpr + (fake-asm .mfc0 dest src) + ;; Copies the contents of a gpr to a cop0 (system control) register + (fake-asm .mtc0 dest src) + ;; Move to perf counter register + (fake-asm .mtpc src dest) + ;; Move from perf counter register + (fake-asm .mfpc dest src) + ) diff --git a/goal_src/jakx/kernel/gkernel-h.gc b/goal_src/jakx/kernel/gkernel-h.gc index 768c7378a3..589ab72cc0 100644 --- a/goal_src/jakx/kernel/gkernel-h.gc +++ b/goal_src/jakx/kernel/gkernel-h.gc @@ -5,5 +5,706 @@ ;; name in dgo: gkernel-h ;; dgos: KERNEL +;; Note: this file has a lot of manual edits. + +(defglobalconstant KERNEL_DEBUG #t) + +(defconstant *kernel-major-version* 2) +(defconstant *kernel-minor-version* 0) + +(defconstant DPROCESS_STACK_SIZE (#if PC_PORT #x10000 #x3800)) +(defconstant PROCESS_STACK_SIZE (#if PC_PORT #x8000 #x1c00)) + +(#if PC_BIG_MEMORY + (defconstant PROCESS_HEAP_MULT 4) ;; 4x actors + (defconstant PROCESS_HEAP_MULT 1) + ) +(defconstant PROCESS_HEAP_SIZE (* PROCESS_HEAP_MULT 1240 1024)) +(defconstant PROCESS_HEAP_MAX (* PROCESS_HEAP_MULT 768)) + +(defconstant *tab-size* (the binteger 8)) +(defconstant *gtype-basic-offset* 4) + +(defconstant *scratch-memory-top* (the pointer #x70004000)) + +(declare-type process-tree basic) +(declare-type process process-tree) +(declare-type res-lump basic) +(declare-type entity res-lump) +(declare-type entity-actor entity) +(declare-type dead-pool basic) +(declare-type level basic) +(declare-type state basic) +(declare-type event-message-block structure) +(declare-type stack-frame basic) +(declare-type cpu-thread basic) + +;; +++gkernel-h:process-mask +(defenum process-mask + :type uint32 + :bitfield #t + (execute 0) + (freeze 1) + (pause 2) + (menu 3) + (progress 4) + (actor-pause 5) + (sleep 6) + (sleep-code 7) + (process-tree 8) + (heap-shrunk 9) + (going 10) + (kernel-run 11) + (no-kill 12) + (movie 13) + (dark-effect 14) + (target 15) + + (sidekick 16) + (crate 17) + (collectable 18) + (enemy 19) + (camera 20) + (platform 21) + (ambient 22) + (entity 23) + (projectile 24) + (bot 25) + (death 26) + (vehicle 27) + (network 28) + ) +;; ---gkernel-h:process-mask + ;; DECOMP BEGINS +(deftype kernel-context (basic) + ((prevent-from-run process-mask) + (require-for-run process-mask) + (allow-to-run process-mask) + (next-pid int32) + (fast-stack-top pointer) + (current-process process) + (relocating-process basic) + (relocating-min int32) + (relocating-max int32) + (relocating-offset int32) + (relocating-level level) + (low-memory-message symbol) + (login-object basic) + (login-art-group basic) + (login-level-index int32) + ) + ) + + +(deftype time-frame (int64) + () + ) + +;; times are stored in 300ths of a second. +;; this divides evenly into frames at both 50 and 60 fps. +;; typically these are stored as integers as more precision is not useful. +;; an unsigned 32-bit integer can store about 150 days +(defglobalconstant TICKS_PER_SECOND 300) ;; 5 t/frame @ 60fps, 6 t/frame @ 50fps + +;; this was usec in GOAL +(defmacro seconds (x) + "Convert number to seconds unit. + Returns uint." + (cond + ((integer? x) + (* TICKS_PER_SECOND x) + ) + ((float? x) + (* 1 (* 1.0 x TICKS_PER_SECOND)) + ) + (#t + `(the uint (* TICKS_PER_SECOND ,x)) + ) + ) + ) + +;; Each clock counts in 3 different ways: +;; +;; 1). A "frame counter", which, confusingly, doesn't count frames. +;; It counts elapsed time, in 1/300ths of a second. +;; This counts in real-time, even if the game is lagging. +;; +;; 2). A "integral-frame-counter", which counts the number of vsyncs. +;; This doens't count the number of frames the game actually manages to draw, +;; just the number of vsyncs. It counts at different rates in NTSC/PAL. +;; NOTE: changing clock-ratio will make this count faster/slower. This only counts real +;; vsyncs if clock-ratio is 1.0. +;; +;; 3). The "time ratio", which adjusts based on the actual achieved framerate. +;; Unlike the others, this isn't a incrementing counter, but instead ratios: +;; time-adjust-ratio, frames-per-second, seconds-per-frame. +;; +;; For the most part, users should just adjust per-frame values by time-adjust-ratio, and this will +;; compensate for pal/ntsc, lag, and clock-ratio scaling. +;; +;; The clock won't tick if its process-mask is prevent-from-run in the kernel. +;; A clock can change the rate it runs at with clock-ratio. +;; Note: both integral-frame-counter and seconds-per-frame/frames-per-second are affected by +;; clock-ratio, which is somewhat weird. +;; Changing clock-ratio will make integral-frame-counter not count actual vsyncs + +(deftype clock (basic) + ((index int16) + (ref-count uint16) + (mask process-mask) + (clock-ratio float) + (accum float) + (integral-accum float) + (frame-counter time-frame) + (old-frame-counter time-frame) + (integral-frame-counter time-frame) + (old-integral-frame-counter time-frame) + (sparticle-data vector :inline) + (seconds-per-frame float) + (frames-per-second float) + (time-adjust-ratio float) + ) + (:methods + (new (symbol type int) _type_) + (update-rates! (_type_ float) float) + (advance-by! (_type_ float) clock) + (tick! (_type_) clock) + (save! (_type_ (pointer uint64)) int) + (load! (_type_ (pointer uint64)) int) + (copy! (_type_ clock) clock) + (reset! (_type_) none) + (frame-mask-2 (_type_ int) symbol) + (frame-mask-4 (_type_ int) symbol) + (frame-mask-8 (_type_ int) symbol) + (frame-mask-16 (_type_ int) symbol) + (frame-mask-32 (_type_ int) symbol) + (frame-mask-64 (_type_ int) symbol) + (frame-mask-128 (_type_ int) symbol) + (frame-mask-256 (_type_ int) symbol) + ) + ) + + +(defmethod frame-mask-2 ((this clock) (xor-val int)) + "Check if the frame count, xored with `xor-val` has its lowest bit set" + (not (logtest? (logxor xor-val (-> this integral-frame-counter)) 1)) + ) + +(defmethod frame-mask-4 ((this clock) (xor-val int)) + "Check if the frame count, xored with `xor-val` has any of its lowest 2 bits set" + (not (logtest? (logxor xor-val (-> this integral-frame-counter)) 3)) + ) + +(defmethod frame-mask-8 ((this clock) (xor-val int)) + "Check if the frame count, xored with `xor-val` has any of its lowest 3 bits set" + (not (logtest? (logxor xor-val (-> this integral-frame-counter)) 7)) + ) + +(defmethod frame-mask-16 ((this clock) (xor-val int)) + "Check if the frame count, xored with `xor-val` has any of its lowest 4 bits set" + (not (logtest? (logxor xor-val (-> this integral-frame-counter)) 15)) + ) + +(defmethod frame-mask-32 ((this clock) (xor-val int)) + "Check if the frame count, xored with `xor-val` has any of its lowest 5 bits set" + (not (logtest? (logxor xor-val (-> this integral-frame-counter)) 31)) + ) + +(defmethod frame-mask-64 ((this clock) (xor-val int)) + "Check if the frame count, xored with `xor-val` has any of its lowest 6 bits set" + (not (logtest? (logxor xor-val (-> this integral-frame-counter)) 63)) + ) + +(defmethod frame-mask-128 ((this clock) (xor-val int)) + "Check if the frame count, xored with `xor-val` has any of its lowest 7 bits set" + (not (logtest? (logxor xor-val (-> this integral-frame-counter)) 127)) + ) + +(defmethod frame-mask-256 ((this clock) (xor-val int)) + "Check if the frame count, xored with `xor-val` has any of its lowest 8 bits set" + (not (logtest? (logxor xor-val (-> this integral-frame-counter)) 255)) + ) + +(defmethod new clock ((allocation symbol) (type-to-make type) (index int)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> gp-0 index) index) + (set! (-> gp-0 frame-counter) (seconds 1000)) + (set! (-> gp-0 integral-frame-counter) (seconds 1000)) + (set! (-> gp-0 old-frame-counter) (+ (-> gp-0 frame-counter) -1)) + (set! (-> gp-0 old-integral-frame-counter) (+ (-> gp-0 integral-frame-counter) -1)) + (update-rates! gp-0 1.0) + gp-0 + ) + ) + +;; The basic node used to organize processes into a tree. +;; The process types themselves are children of the process-tree type +;; Typically, each instance of a game object is a process. +(declare-type view basic) +(deftype process-tree (basic) + ((name string :offset-assert 4) + (mask process-mask :offset-assert 8) + (clock clock :offset-assert 12) ;; guessed by decompiler + (view view :offset-assert 16) + (parent (pointer process-tree) :offset-assert 20) ;; guessed by decompiler + (brother (pointer process-tree) :offset-assert 24) ;; guessed by decompiler + (child (pointer process-tree) :offset-assert 28) ;; guessed by decompiler + (ppointer (pointer process) :offset-assert 32) + (self process-tree :offset-assert 36) + (profile-ticks uint32 :offset-assert 40) + ) + :method-count-assert 15 + :size-assert #x2c + :flag-assert #xf0000002c + :no-runtime-type + (:methods + (new "Allocate a process-tree with the kernel clock." (symbol type string) _type_) ;; 0 + (activate "Move a process from dead to active, moving it to the given tree." (_type_ process-tree string pointer) process-tree) ;; 9 + (deactivate "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." (_type_) none) ;; 10 + (init-from-entity! (_type_ entity-actor) object) ;; 11 + (run-logic? "Should this process be run? Checked by execute-process-tree." (_type_) symbol) ;; 12 + (process-tree-method-13 () none) ;; 13 + (process-tree-method-14 () none) + ) + ) + +(deftype thread (basic) + ((name symbol) + (process process) + (previous thread) + (suspend-hook (function cpu-thread none)) + (resume-hook (function cpu-thread none)) + (pc pointer) + (sp pointer) + (stack-top pointer) + (stack-size int32) + ) + (:methods + (stack-size-set! (_type_ int) none) + (thread-suspend (_type_) none) + (thread-resume (_type_) none) + ) + ) + + +(deftype cpu-thread (thread) + ((rreg uint64 7) + (freg float 8) + (stack uint8 :dynamic) + ) + (:methods + (new (symbol type process symbol int pointer) _type_) + ) + ) + +(deftype process (process-tree) + ((self process :override) + (pool dead-pool) + (status symbol :offset-assert 48) ;; guessed by decompiler + (pid int32) + (main-thread cpu-thread :offset-assert 56) ;; guessed by decompiler + (top-thread cpu-thread :offset-assert 60) ;; guessed by decompiler + (entity entity-actor :offset-assert 64) ;; guessed by decompiler + (level level :offset-assert 68) ;; guessed by decompiler + (state state :offset-assert 72) ;; guessed by decompiler + (prev-state state :offset-assert 76) ;; guessed by decompiler + (next-state state :offset-assert 80) ;; guessed by decompiler + (state-stack (array state) :offset-assert 84) ;; guessed by decompiler + (trans-hook function :offset-assert 88) ;; guessed by decompiler + (post-hook function :offset-assert 92) ;; guessed by decompiler + (event-hook (function process int symbol event-message-block object) :offset-assert 96) ;; guessed by decompiler + (allocated-length int32 :offset-assert 100) + (heap-base pointer :offset 112) ;; guessed by decompiler + (heap-top pointer :offset-assert 116) ;; guessed by decompiler + (heap-cur pointer :offset-assert 120) ;; guessed by decompiler + (stack-frame-top stack-frame :offset-assert 124) ;; guessed by decompiler + (connection-list connectable :inline :offset-assert 128) + (stack uint8 :dynamic :offset-assert 144) ;; guessed by decompiler + ) + :method-count-assert 15 + :size-assert #x90 + :flag-assert #xf00000090 + (:methods + (new "Allocate a process, set up process heap, self/ppointer, clock." (symbol type string int) _type_) ;; 0 + ) + (:states + dead-state ;; 10 + ) + ) + +(deftype dead-pool (process-tree) + () + (:methods + (new (symbol type int int string) _type_) + (get-process (_type_ type int object) process) + (return-process (_type_ process) none) + ) + ) + + +(deftype dead-pool-heap-rec (structure) + ((process process) + (prev dead-pool-heap-rec) + (next dead-pool-heap-rec) + ) + :pack-me + ) + + +(deftype dead-pool-heap (dead-pool) + ((allocated-length int32) + (compact-time uint32) + (compact-count-targ uint32) + (compact-count uint32) + (fill-percent float) + (first-gap dead-pool-heap-rec) + (first-shrink dead-pool-heap-rec) + (heap kheap :inline) + (alive-list dead-pool-heap-rec :inline) + (last dead-pool-heap-rec :overlay-at (-> alive-list prev)) + (dead-list dead-pool-heap-rec :inline) + (process-list dead-pool-heap-rec :dynamic) + ) + (:methods + (new "Allocate and initialize a dead-pool-heap." (symbol type string int int) _type_) ;; 0 + (init "Allocate memory for processes and init records." (_type_ symbol int) none) ;; 16 + (compact "Relocate process in memory to remove gaps, increasing free memory for this dead-pool-heap." (dead-pool-heap int) none) ;; 17 + (shrink-heap "Shrink the heap of a process, allowing the dead pool heap to later reclaim the memory during a compact." (dead-pool-heap process) dead-pool-heap) ;; 18 + (churn "Relocate process in memory, to trigger memory bugs related to process relocation." (dead-pool-heap int) none) ;; 19 + (memory-used "Get the total memory used. Memory in between processes that is not used by a process is considered used." (_type_) int) ;; 20 + (memory-total "Get the total size of the heap for processes." (_type_) int) ;; 21 + (memory-free "Get the size of the unused part of the heap." (dead-pool-heap) int) ;; 22 + (compact-time "Get the compaction time (never set)." (dead-pool-heap) uint) ;; 23 + (gap-size "Get the size of the gap (possibly zero) after the given process. Use #f for the gap at the start of the pool memory." (dead-pool-heap dead-pool-heap-rec) int) ;; 24 + (gap-location "Get pointer to gap (possibly zero size) after the given process" (dead-pool-heap dead-pool-heap-rec) pointer) ;; 25 + (find-gap "Find the first process with a nonzero gap after it, after the given process." (dead-pool-heap dead-pool-heap-rec) dead-pool-heap-rec) ;; 26 + (find-gap-by-size "Find the first gap with a size at least this big" (dead-pool-heap int) dead-pool-heap-rec) ;; 27 + ) + ) + +(deftype stack-frame (basic) + ((name symbol) + (next stack-frame) + ) + ) + +(deftype catch-frame (stack-frame) + ((sp int32) + (ra int32) + (freg float 10) + (rreg uint128 7) + ) + (:methods + (new (symbol type symbol function (pointer uint64)) object) + ) + ) + + +(deftype protect-frame (stack-frame) + ((exit (function object)) + ) + (:methods + (new (symbol type (function object)) protect-frame) + ) + ) + + +(deftype handle (uint64) + ((process (pointer process) :offset 0 :size 32) + (pid int32 :offset 32 :size 32) + (u64 uint64 :offset 0 :size 64) + ) + ) + + +(deftype handle-wrapper (structure) + ((handle uint64) + ) + ) + +(defmacro handle->process (handle) + "Convert a handle to a process. If the process no longer exists, returns #f." + `(let ((the-handle (the-as handle ,handle))) + (if (-> the-handle process) ;; if we don't point to a process, kernel sets this to #f + (let ((proc (-> (-> the-handle process)))) + (if (= (-> the-handle pid) (-> proc pid)) ;; make sure it's the same process + proc + ) + ) + ) + ) + ) + +(defmacro ppointer->process (ppointer) + "convert a (pointer process) to a process." + ;; this uses the self field, which seems to always just get set to the object. + ;; confirmed in Jak 1 that using self here is useless, not sure... + `(let ((the-pp ,ppointer)) + (if the-pp (-> the-pp 0 self)) + ) + ) + +(defmacro process->ppointer (proc) + "safely get a (pointer process) from a process, returning #f if invalid." + `(let ((the-proc ,proc)) + (if the-proc (-> the-proc ppointer)) + ) + ) + +(defmacro ppointer->handle (pproc) + "convert a ppointer to a handle. assumes the ppointer is valid." + `(let ((the-process (the-as (pointer process) ,pproc))) + (new 'static 'handle :process the-process :pid (if the-process (-> the-process 0 pid))) + ) + ) + +(defmacro process->handle (proc) + "convert a process to a handle. if proc is #f, returns a #f handle." + `(ppointer->handle (process->ppointer (the-as process ,proc))) + ) + + +(defmethod print ((this handle)) + (if (nonzero? this) + (format #t "#" (handle->process this) (-> this pid)) + (format #t "#") + ) + this + ) + +(deftype state (protect-frame) + ((parent state) + (code function) + (trans (function object)) + (post function) + (enter function) + (event (function process int symbol event-message-block object)) + ) + (:methods + (new (symbol type symbol function (function object) function (function object) (function process int symbol event-message-block object)) _type_) + ) + ) + + +(deftype event-message-block (structure) + ((to-handle uint64) + (to (pointer process) :overlay-at to-handle) + (from-handle uint64) + (from (pointer process) :overlay-at from-handle) + (param uint64 6) + (message symbol) + (num-params int32) + ) + ) + + +(deftype event-message-block-array (inline-array-class) + ((data event-message-block :dynamic) + ) + (:methods + (send-all! (_type_) none) + ) + ) + + +(set! (-> event-message-block-array heap-base) (the-as uint 80)) + +(deftype sql-result (array) + ((sql-data object :dynamic :offset 16) + ) + (:methods + (new (symbol type int) _type_) + ) + ) + +(defmethod new sql-result ((allocation symbol) (type-to-make type) (num-elts int)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* num-elts 4)))))) + (set! (-> v0-0 allocated-length) num-elts) + (set! (-> v0-0 content-type) (the-as type 'error)) + v0-0 + ) + ) + +(defmethod print ((this sql-result)) + (format #t "#(~A" (-> this content-type)) + (dotimes (s5-0 (-> this length)) + (format #t " ~A" (-> this sql-data s5-0)) + ) + (format #t ")") + this + ) + +(define *sql-result* (the-as sql-result #f)) + +(define-extern *collapse-quote* symbol) + +(defmacro defbehavior (name process-type bindings &rest body) + "define a new behavior. This is simply a function where self is bound to the process register, + which is assumed to have type process-type." + (if (and + (> (length body) 1) ;; more than one thing in function + (string? (first body)) ;; first thing is a string + ) + ;; then it's a docstring and we ignore it. + `(define ,name (lambda :name ,name :behavior ,process-type ,bindings ,@(cdr body))) + ;; otherwise don't ignore it. + `(define ,name (lambda :name ,name :behavior ,process-type ,bindings ,@body)) + ) + ) + +(defmacro process-stack-used (proc) + "get how much stack the top thread of a process has used." + `(- (the int (-> ,proc top-thread stack-top)) + (the int (-> ,proc top-thread sp)) + ) + ) + +(defmacro process-stack-size (proc) + "get how much stack the top thread of a process has" + `(-> ,proc top-thread stack-size) + ) + +(defmacro process-heap-used (proc) + "get how much heap a process has used." + `(- (-> ,proc allocated-length) + (- (the int (-> ,proc heap-top)) + (the int (-> ,proc heap-cur)) + ) + ) + ) + +(defmacro process-heap-size (proc) + "get how much heap a process has" + `(the int (-> ,proc allocated-length)) + ) + +(defmacro break () + "crash the game by dividing by 0." + `(/ 0 0) + ) + +(defmacro with-pp (&rest body) + "execute the body with pp bound to the current process register." + `(rlet ((pp :reg r13 :reset-here #t :type process)) + ,@body) + ) + +(defconstant PP (with-pp pp)) + +(defmacro process-mask? (mask enum-value) + "Are any of the given bits set in the process mask?" + `(!= 0 (logand ,mask (process-mask ,enum-value))) + ) + +(defmacro process-mask-set! (mask &rest enum-value) + "Set the given bits in the process mask" + `(logior! ,mask (process-mask ,@enum-value)) + ) + +(defmacro process-mask-clear! (mask &rest enum-value) + "Clear the given bits in the process mask." + `(logclear! ,mask (process-mask ,@enum-value)) + ) + +(defmacro suspend () + "suspend the current process, to be resumed on the next frame." + `(rlet ((pp :reg r13 :reset-here #t)) + ;; debug check for stack overflow here, where we can easily print the process name. + (#when (or KERNEL_DEBUG) + (rlet ((sp :reg rsp :reset-here #t :type int) + (off :reg r15 :type uint)) + (let* ((sp-goal (- sp off)) + (stack-top-goal (-> (the process pp) top-thread stack-top)) + (stack-used (&- stack-top-goal sp-goal)) + (stack-size (-> (the process pp) top-thread stack-size)) + ) + (when (> stack-used stack-size) + (format 0 "ERROR: suspend called without enough stack in proc:~%~A~%Stack: ~D/~D~%" pp stack-used stack-size) + ) + ) + ) + ) + ;; set to the current thread + (set! pp (-> (the process pp) top-thread)) + ;; call the suspend hook (put nothing as the argument) + ((-> (the cpu-thread pp) suspend-hook) (the cpu-thread 0)) + ;; the kernel will set pp (possibly to a new value, if we've been relocated) on resume. + ) + ) + +(defmacro process-deactivate () + "deactivate (kill) the current process" + `(rlet ((pp :reg r13 :reset-here #t :type process)) + (deactivate pp) + ) + ) + +;; Some assembly functions in GOAL are ported to C++, then accessed from GOAL using these mips2c macros. +(defmacro def-mips2c (name type) + "Define a mips2c object (typically a function)." + `(begin + (define-extern ,name ,type) + (set! ,name (the-as ,type (__pc-get-mips2c ,(symbol->string name)))) + ) + ) + +(defmacro defmethod-mips2c (name method-id method-type) + "Define a mips2c method." + `(method-set! ,method-type ,method-id (__pc-get-mips2c ,name)) + ) + +(defmacro kheap-alloc (heap size) + "allocate space for a kheap" + `(let ((heap ,heap) (size ,size)) + (set! (-> heap base) (malloc 'global size)) + (set! (-> heap current) (-> heap base)) + (set! (-> heap top-base) (&+ (-> heap base) size)) + (set! (-> heap top) (-> heap top-base)) + ) + ) + +(defmacro kheap-reset (heap) + "reset the kheap, so you can use its memory again" + `(let ((heap ,heap)) + (set! (-> heap current) (-> heap base)) + ) + ) + +(defmacro scratchpad-object (type &key (offset 0)) + "Access an object on the scratchpad." + `(the-as ,type (&+ *fake-scratchpad-data* ,offset)) + ) + +(defmacro scratchpad-ptr (type &key (offset 0)) + "Create a pointer to an object on the scratchpad." + `(the-as (pointer ,type) (&+ *fake-scratchpad-data* ,offset)) + ) + +(defmacro current-time () + `(-> PP clock frame-counter) + ) + +(defmacro seconds-per-frame () + `(-> PP clock seconds-per-frame) + ) + +(defmacro seconds-per-frame-high-fps () + "Macro for assuming a 16.6 ms frame time at higher frame rates." + `(if (= (get-video-mode) 'custom) + 0.016666668 + (-> PP clock seconds-per-frame) + ) + ) + +(defmacro set-time! (time) + `(set! ,time (current-time)) + ) + +(defmacro time-elapsed? (time duration) + `(>= (- (current-time) ,time) ,duration) + ) + +(defmacro suspend-for (time &rest body) + `(let ((time (current-time))) (until (time-elapsed? time ,time) ,@body (suspend)))) \ No newline at end of file diff --git a/goal_src/jakx/kernel/gkernel.gc b/goal_src/jakx/kernel/gkernel.gc index 0f60f426f3..14a3e5ca7d 100644 --- a/goal_src/jakx/kernel/gkernel.gc +++ b/goal_src/jakx/kernel/gkernel.gc @@ -5,5 +5,2404 @@ ;; name in dgo: gkernel ;; dgos: KERNEL -;; DECOMP BEGINS +;; TODO - right now this is entirely copied from jak3 +;; This file has a large number of differences from the original. + +;; This is the GOAL kernel, which is responsible for handling processes. + +(define-extern *kernel-clock* clock) +(define-extern *debug-dead-pool* dead-pool-heap) +(define-extern *null-process* process) +(define-extern *vis-boot* symbol) +(define-extern *listener-process* process) +(define-extern *active-pool* process-tree) +(define-extern *default-level* level) + +(define-extern change-parent (function process-tree process-tree process-tree)) +(define-extern search-process-tree (function process-tree (function process-tree object) process)) +(define-extern iterate-process-tree (function process-tree (function object object) kernel-context object)) +(define-extern execute-process-tree (function process-tree (function object object) kernel-context object)) +(define-extern inspect-process-tree (function process-tree int int symbol process-tree)) +(define-extern process-disconnect (function process int)) + +;; DECOMP BEGINS +(define *use-old-listener-print* #f) +(define *kernel-version* (the binteger (logior (ash *kernel-major-version* 16) *kernel-minor-version*))) +(define *irx-version* (the-as binteger #x200000)) + +(define *kernel-boot-mode* 'listener) +(define *kernel-boot-level* #f) + +(define *deci-count* 0) + +(define *last-loado-length* 0) +(define *last-loado-global-usage* 0) +(define *last-loado-debug-usage* 0) + +;;;;;;;;;;;;;;;;;;;; +;; relocate method +;;;;;;;;;;;;;;;;;;;; + +;; All children of process, and all objects allocated on a process heap should support a +;; `relocate` method. This method is used by the kernel to move the process (and its heap) +;; in memory. For this reason, `relocate` is a method available on all objects. + +(defmethod relocate ((this object) (offset int)) + "Most general relocate method." + this + ) + + +;;;;;;;;;;;;;;;;;;; +;; package system +;;;;;;;;;;;;;;;;;;; + +;; simple system to load packages by name. Currently, package loading is done at boot, +;; by the C Kernel, before the GOAL kernel is running. However, this GOAL version can load +;; kernel packages as well, if the C Kernel is started without DiskBoot set, for example. + +;; currently loaded packages. +(define *kernel-packages* '()) + +(defun load-package ((package-name string) (heap kheap)) + "If not already loaded, do a blocking dgo-load to load the given CGO." + (when (not (nmember package-name *kernel-packages*)) + (kmemopen global package-name) + (dgo-load + package-name + heap + (link-flag output-load-msg output-load-true-msg execute-login print-login) + #x200000 + ) + (set! *kernel-packages* (cons package-name *kernel-packages*)) + (kmemclose) + *kernel-packages* + ) + ) + +(defun unload-package ((package-name string)) + "Mark a package as unloaded. Does not actually unload." + (let ((v1-0 (nmember package-name *kernel-packages*))) + (if v1-0 + (set! *kernel-packages* (delete! (car v1-0) *kernel-packages*)) + ) + ) + *kernel-packages* + ) + + +;;;;;;;;;;;;;;; +;; context +;;;;;;;;;;;;;;; + +;; The context stores the relatively simple state of the kernel. + +(define *kernel-context* (new 'static 'kernel-context + :prevent-from-run (process-mask execute sleep) + :next-pid 3 + :current-process #f + :relocating-process #f + :low-memory-message #t + ) + ) + +;; The stack for running user code. +(define *canary-1* (the-as (pointer uint64) (malloc 'global 8))) +(define *dram-stack* (the-as (pointer uint8) (malloc 'global DPROCESS_STACK_SIZE))) +(define *canary-2* (the-as (pointer uint64) (malloc 'global 8))) +(defconstant *kernel-dram-stack* (&+ *dram-stack* DPROCESS_STACK_SIZE)) + +;; The kernel can also run code using the scratchpad as the stack. +;; This is only possible for processes that don't use the scratchpad otherwise. +(set! (-> *kernel-context* fast-stack-top) (the-as pointer #x70004000)) + +(define *null-kernel-context* (new 'static 'kernel-context)) + +;;;;;;;;;;;;;;;;;;;;;;; +;; PC Port Scratchpad +;;;;;;;;;;;;;;;;;;;;;;; + +;; the playstation 2 had 16 kB of very fast memory called the "scratchpad". It was as fast as the L1 cache. +;; It was mapped at address 0x7000000. We provide a "fake" scratchpad. There are a few hacks here: +;; - we define a macro to check if an address is "in scratch" or not. The game uses this check. +;; - we make sure the scratchpad is 64 kB aligned. There is some fancy double-buffer toggling code that +;; relies on bit patterns in the address, and the base address must be 64 kB aligned. +;; - the scratchpad size is increased to 64 kB, to increase the maximum stack size. + +;; og:preserve-this +;; DECOMP DEVIATION +(#cond + (PC_PORT + (define *canary-4* (the-as (pointer uint64) (malloc 'global 8))) + ;; we'll create a fake scratchpad: + ;; make sure the scratchpad is 64kb aligned, and make it 32 kB so we can big stacks on it. + ;; some (partially buggy) code in generic tie relies on 64 kB alignment. + (define *fake-scratchpad-size* (* 128 1024)) + (let* ((mem (new 'global 'array 'uint8 (* 2 *fake-scratchpad-size*))) + ) + (define *fake-scratchpad-alloc* mem) + (define *fake-scratchpad-data* (the pointer (align-n mem *fake-scratchpad-size*))) + ) + + ;; use the same memory for the scratchpad stacks. + ;; defining it as a separate thing so we can split them for debugging stack corruption easily. + (define *fake-scratchpad-stack* *fake-scratchpad-data*) + (define *canary-3* (the-as (pointer uint64) (malloc 'global 8))) + + (defmacro scratchpad-start () + "Get the start of the scratchpad. At least 64kB aligned." + '*fake-scratchpad-data* + ) + (defmacro scratchpad-end () + "Get the start of the scratchpad. At least 64kB aligned." + `(&+ (scratchpad-start) *fake-scratchpad-size*) + ) + ) + (else + (defmacro scratchpad-start () + #x70000000 + ) + (defmacro scratchpad-end () + "Get the start of the scratchpad. At least 64kB aligned." + `(&+ (scratchpad-start) (* 16 1024)) + ) + ) + ) + +(defmacro in-scratchpad? (x) + "Is the given address in the scratchpad?" + `(and + (>= (the-as int ,x) (scratchpad-start)) + (<= (the-as int ,x) (scratchpad-end)) + ) + ) + +;;;;;;;;;;; +;; thread +;;;;;;;;;;; + +;; A "GOAL" thread comes in two varieties: +;; A "temporary" thread, for running a single function, which returns immediately. +;; in this case, the thread is basically a helper structure to handle the kernel -> user code switch. +;; A "main" thread, for running the main code of a process. +;; in this case, the thread is responsible for suspending and resuming this process's code. +;; GOAL main threads do cooperative multi-tasking. + +(defmethod delete ((this thread)) + "Clean up a temporary thread. This should only be called on a temporary thread." + (when (= this (-> this process main-thread)) + (break!) ;; abort if we delete a main thread. + 0 + ) + ;; restore previous thread. + (set! (-> this process top-thread) (the-as cpu-thread (-> this previous))) + 0 + (none) + ) + +(defmethod print ((this thread)) + (format + #t + "#<~A ~S of ~S pc: #x~X @ #x~X>" + (-> this type) + (-> this name) + (-> this process name) + (-> this pc) + this + ) + this + ) + +(defmethod stack-size-set! ((this thread) (size-bytes int)) + "Adjust the size of the stack that can be stored during a suspend. Must be called before any process allocations." + (let ((a2-0 (-> this process))) + (cond + ((!= this (-> a2-0 main-thread)) + (format 0 "ERROR: illegal attempt change stack size of ~A when the main-thread is not the top-thread.~%" a2-0) + ) + ((= (-> this stack-size) size-bytes) + ) + ((= (-> a2-0 heap-cur) (+ (+ (-> this stack-size) -4 (-> this type size)) (the-as int this))) + (set! (-> a2-0 heap-cur) (the-as pointer (+ (+ size-bytes -4 (-> this type size)) (the-as int this)))) + (set! (-> this stack-size) size-bytes) + ) + (else + (format 0 "ERROR: illegal attempt change stack size of ~A after more heap allocation has occured.~%" a2-0) + ) + ) + ) + 0 + (none) + ) + +(defmethod new cpu-thread ((allocation symbol) (type-to-make type) (proc process) (name symbol) (stack-size int) (stack-top pointer)) + "Allocate a thread. If there is already a top-thread for this process, assume this is a temporary thread, and allocate on the bottom of the stack." + (let ((v0-0 (cond + ((-> proc top-thread) + ;; stash this at the "bottom" of the stack. They finally fixed this for jak 3! + ;; for non-scratch stacks, it's actually at the bottom now. + ;; for scratch stacks, it's still halfway down... but maybe this lets you use the + ;; first ~8 kB of scratch still? + (+ (+ (if (in-scratchpad? stack-top) ;; (logtest? #x70000000 stack-top) + (- PROCESS_STACK_SIZE ) ;; -7168 + (- DPROCESS_STACK_SIZE) ;; -14336 + ) + 4 + ) + (the-as int stack-top) + ) + ) + (else + (let ((v1-6 (logand -16 (&+ (-> proc heap-cur) 15)))) + (set! (-> proc heap-cur) (&+ (&+ v1-6 (-> type-to-make size)) stack-size)) + (&+ v1-6 4) + ) + ) + ) + ) + ) + (set! (-> (the-as cpu-thread v0-0) type) type-to-make) + (set! (-> (the-as cpu-thread v0-0) name) name) + (set! (-> (the-as cpu-thread v0-0) process) proc) + (set! (-> (the-as cpu-thread v0-0) sp) stack-top) + (set! (-> (the-as cpu-thread v0-0) stack-top) stack-top) + (set! (-> (the-as cpu-thread v0-0) previous) (-> proc top-thread)) + (set! (-> proc top-thread) (the-as cpu-thread v0-0)) + (set! (-> (the-as cpu-thread v0-0) suspend-hook) (method-of-object (the-as cpu-thread v0-0) thread-suspend)) + (set! (-> (the-as cpu-thread v0-0) resume-hook) (method-of-object (the-as cpu-thread v0-0) thread-resume)) + (set! (-> (the-as cpu-thread v0-0) stack-size) stack-size) + (the-as cpu-thread v0-0) + ) + ) + +(defmethod asize-of ((this cpu-thread)) + (the-as int (+ (-> this type size) (-> this stack-size))) + ) + +(defbehavior remove-exit process () + "Remove the top stack frame. If you have no other stack frames, you can use this before a `go` + to skip the `exit` of the state you are currently in." + (if (-> self stack-frame-top) + (set! (-> self stack-frame-top) (-> self stack-frame-top next)) + ) + 0 + (none) + ) + +(defun-debug stream<-process-mask ((arg0 object) (arg1 process-mask)) + "Print out the process-mask as a human readable string." + (bit-enum->string process-mask arg1 arg0) + arg1 + ) + +(define *master-mode* 'game) +(define *pause-lock* #f) + +(defmethod print ((this process-tree)) + (format #t "#<~A ~S @ #x~X>" (-> this type) (-> this name) this) + this + ) + +(defmethod new process-tree ((allocation symbol) (type-to-make type) (name string)) + "Allocate a process-tree with the kernel clock." + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 name) name) + (set! (-> v0-0 mask) (process-mask process-tree)) + (set! (-> v0-0 clock) *kernel-clock*) + (+! (-> v0-0 clock ref-count) 1) + (set! (-> v0-0 parent) (the-as (pointer process-tree) #f)) + (set! (-> v0-0 brother) (the-as (pointer process-tree) #f)) + (set! (-> v0-0 child) (the-as (pointer process-tree) #f)) + (set! (-> v0-0 self) v0-0) + (set! (-> v0-0 ppointer) (the-as (pointer process) (&-> v0-0 self))) + v0-0 + ) + ) + +(defmethod inspect ((this process-tree)) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~Tname: ~S~%" (-> this name)) + (format #t "~1Tmask: #x~X : (process-mask " (-> this mask)) + (stream<-process-mask #t (-> this mask)) + (format #t ")~%") + (format #t "~Tclock: ~A~%" (-> this clock)) + (format #t "~Tparent: ~A~%" (ppointer->process (-> this parent))) + (format #t "~Tbrother: ~A~%" (ppointer->process (-> this brother))) + (format #t "~Tchild: ~A~%" (ppointer->process (-> this child))) + this + ) + +(defmethod new process ((allocation symbol) (type-to-make type) (name string) (process-heap-size int)) + "Allocate a process, set up process heap, self/ppointer, clock." + (let ((v0-0 (if (logtest? (the-as int allocation) 1) + (object-new allocation type-to-make (the-as int (+ (-> process size) process-heap-size))) + (+ (the-as int allocation) 4) + ) + ) + ) + (set! (-> (the-as process v0-0) name) name) + (set! (-> (the-as process v0-0) clock) *kernel-clock*) + (+! (-> (the-as process v0-0) clock ref-count) 1) + (set! (-> (the-as process v0-0) status) 'dead) + (set! (-> (the-as process v0-0) pid) 0) + (set! (-> (the-as process v0-0) pool) #f) + (set! (-> (the-as process v0-0) allocated-length) process-heap-size) + (set! (-> (the-as process v0-0) top-thread) #f) + (set! (-> (the-as process v0-0) main-thread) #f) + (let ((v1-9 (-> (the-as process v0-0) stack))) + (set! (-> (the-as process v0-0) heap-cur) v1-9) + (set! (-> (the-as process v0-0) heap-base) v1-9) + ) + (set! (-> (the-as process v0-0) heap-top) + (&-> (the-as process v0-0) stack (-> (the-as process v0-0) allocated-length)) + ) + (set! (-> (the-as process v0-0) stack-frame-top) (the-as stack-frame (-> (the-as process v0-0) heap-top))) + (set! (-> (the-as process v0-0) stack-frame-top) #f) + (set! (-> (the-as process v0-0) state) #f) + (set! (-> (the-as process v0-0) next-state) #f) + (set! (-> (the-as process v0-0) prev-state) #f) + (set! (-> (the-as process v0-0) state-stack) #f) + (set! (-> (the-as process v0-0) entity) #f) + (set! (-> (the-as process v0-0) level) #f) + (set! (-> (the-as process v0-0) trans-hook) #f) + (set! (-> (the-as process v0-0) post-hook) #f) + (set! (-> (the-as process v0-0) event-hook) #f) + (set! (-> (the-as process v0-0) parent) (the-as (pointer process-tree) #f)) + (set! (-> (the-as process v0-0) brother) (the-as (pointer process-tree) #f)) + (set! (-> (the-as process v0-0) child) (the-as (pointer process-tree) #f)) + (set! (-> (the-as process v0-0) self) (the-as process v0-0)) + (set! (-> (the-as process v0-0) ppointer) (&-> (the-as process v0-0) self)) + (the-as process v0-0) + ) + ) + +(defun inspect-process-heap ((proc process)) + "Call the inspect method on every object in the process heap." + (let ((s5-0 (the-as object (&+ (-> proc heap-base) 4)))) + (while (< (the-as int s5-0) (the-as int (-> proc heap-cur))) + (inspect (the-as basic s5-0)) + (set! s5-0 (&+ (the-as pointer s5-0) (logand -16 (+ (asize-of (the-as basic s5-0)) 15)))) + ) + ) + #f + ) + +(defmethod inspect ((this process)) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~Tname: ~S~%" (-> this name)) + (format #t "~1Tmask: #x~X : (process-mask " (-> this mask)) + (stream<-process-mask #t (-> this mask)) + (format #t ")~%") + (format #t "~Tclock: ~A~%" (-> this clock)) + (format #t "~Tstatus: ~A~%" (-> this status)) + (format #t "~Tmain-thread: ~A~%" (-> this main-thread)) + (format #t "~Ttop-thread: ~A~%" (-> this top-thread)) + (format #t "~Tentity: ~A~%" (-> this entity)) + (format #t "~Tlevel: ~A~%" (-> this level)) + (format #t "~Tstate: ~A~%" (-> this state)) + (format #t "~Tprev-state: ~A~%" (-> this prev-state)) + (format #t "~Tnext-state: ~A~%" (-> this next-state)) + (format #t "~Tstate-stack: ~A~%" (-> this state-stack)) + (format #t "~Ttrans-hook: ~A~%" (-> this trans-hook)) + (format #t "~Tpost-hook: ~A~%" (-> this post-hook)) + (format #t "~Tevent-hook: ~A~%" (-> this event-hook)) + (format #t "~Tparent: ~A~%" (ppointer->process (-> this parent))) + (format #t "~Tbrother: ~A~%" (ppointer->process (-> this brother))) + (format #t "~Tchild: ~A~%" (ppointer->process (-> this child))) + (format #t "~Tconnection-list: ~`connectable`P~%" (-> this connection-list)) + (format #t "~Tstack-frame-top: ~A~%" (-> this stack-frame-top)) + (format #t "~Theap-base: #x~X~%" (-> this heap-base)) + (format #t "~Theap-top: #x~X~%" (-> this heap-top)) + (format #t "~Theap-cur: #x~X~%" (-> this heap-cur)) + (let ((s5-0 *print-column*)) + ;; og:preserve-this + (set! *print-column* (+ *print-column* *tab-size*)) + (format #t "----~%") + (inspect-process-heap this) + (format #t "----~%") + (set! *print-column* s5-0) + ) + (format #t "~Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~Tstack[~D] @ #x~X~%" (-> this allocated-length) (-> this stack)) + this + ) + +(defmethod asize-of ((this process)) + (the-as int (+ (-> process size) (-> this allocated-length))) + ) + +(defmethod print ((this process)) + (cond + ((and (-> this top-thread) (!= (-> this status) 'dead)) + (format #t "#<~A ~S ~A :state ~S " (-> this type) (-> this name) (-> this status) (if (-> this state) + (-> this state name) + ) + ) + (format + #t + ":stack ~D/~D :heap ~D/~D @ #x~X>" + (&- (-> this top-thread stack-top) (the-as uint (-> this top-thread sp))) + (-> this main-thread stack-size) + (- (-> this allocated-length) (&- (-> this heap-top) (the-as uint (-> this heap-cur)))) + (-> this allocated-length) + this + ) + ) + (else + (format + #t + "#<~A ~S ~A :state ~S @ #x~X" + (-> this type) + (-> this name) + (-> this status) + (if (-> this state) + (-> this state name) + ) + this + ) + ) + ) + this + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Context Suspend And Resume - Kernel +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; the following functions are used for going from the kernel to threads and back. +;; saved registers: rbx, rbp, r10, r11, r12 + +;; DANGER - THE KERNEL DOES NOT SAVE ITS FLOATING POINT CONTEXT!!!! + +;; we use this to store a GOAL pointer to the kernel's stack pointer when executing user code. +;; to get back to the kernel, we use this global symbol. +(define-extern *kernel-sp* pointer) + +(defun return-from-thread () + "Context switch to the saved kernel context now. + This is intended to be jumped to with the ret instruction (return trampoline) + at the end of a normal function, so this should preserve rax. + To make sure this happens, all ops should be asm ops and we should have no + GOAL expressions." + (declare (asm-func none) + ;; (print-asm) + ) + (rlet ((sp :reg rsp :type uint) + (off :reg r15 :type uint) + (s0 :reg rbx :type uint) + (s1 :reg rbp :type uint) + (s2 :reg r10 :type uint) + (s3 :reg r11 :type uint) + (s4 :reg r12 :type uint) + ) + ;; get the kernel stack pointer as a GOAL pointer (won't use a temp reg) + (.load-sym :sext #f sp *kernel-sp*) + ;; convert it back to a real pointer + (.add sp off) + + ;; restore saved registers... + ;; without coloring system because this is "cheating" and modifying saved registers without backing up. + (.pop :color #f s4) + (.pop :color #f s3) + (.pop :color #f s2) + (.pop :color #f s1) + (.pop :color #f s0) + ;; return to the kernel function that called the user code + ;; rax should still contain the return value. + (.ret) + ) + ) + +(defun return-from-thread-dead () + "Like return from thread, but we clean up our process with deactivate first. + The return register is not preserved here, instead we return the value of deactivate" + (declare (asm-func none) + ;; (print-asm) + ) + (rlet ((pp :reg r13 :type process) + (sp :reg rsp :type uint) + (off :reg r15 :type uint) + (s0 :reg rbx :type uint) + (s1 :reg rbp :type uint) + (s2 :reg r10 :type uint) + (s3 :reg r11 :type uint) + (s4 :reg r12 :type uint) + ) + + ;; first call the deactivate method. + (deactivate pp) + ;; get the kernel stack pointer as a GOAL pointer + (.load-sym :sext #f sp *kernel-sp*) + ;; convert it back to a real pointer + (.add sp off) + + ;; restore saved registers... + ;; without coloring system because this is "cheating". + (.pop :color #f s4) + (.pop :color #f s3) + (.pop :color #f s2) + (.pop :color #f s1) + (.pop :color #f s0) + ;; return to the kernel function that called the user code + (.ret) + ) + ) + +(defmacro abandon-thread () + ;; abandon this one too. + ;; NOTE - this is different from GOAL. + ;; GOAL installs this as the return address for this function and returns normally. + ;; but we don't because I don't have an easy way to find where to stick this. + ;; I can't see how this makes a difference, as all non-main threads seem + ;; temporary, but if this turns out to be false, we will need to change this. + `(rlet ((temp) + (off :reg r15 :type uint :reset-here #t)) + (.mov temp return-from-thread) ;; could probably just call this... + (.add temp off) + (.push temp) + (.ret) + ) + ) + +(defun reset-and-call ((this thread) (func function)) + "Make the given thread the top thread, reset the stack, and call the function. + Sets up a return trampoline so when the function returns it will return to the + kernel context. Will NOT deactivate on return, so this is intended for temporary threads. + NOTE: this should only be done from the kernel, running on the + kernel's stack." + (declare (asm-func object) + ) + + (rlet ((pp :reg r13 :type process) + (sp :reg rsp :type uint) + (off :reg r15 :type uint) + (s0 :reg rbx :type uint) + (s1 :reg rbp :type uint) + (s2 :reg r10 :type uint) + (s3 :reg r11 :type uint) + (s4 :reg r12 :type uint) + (temp :reg rax :type uint) + ) + + ;; set up the process pointer + (set! pp (-> this process)) + ;; mark the process as running and set its top thread + (set! (-> pp status) 'running) + (set! (-> pp top-thread) (the cpu-thread this)) + + ;; save the current kernel regs + (.push :color #f s0) + (.push :color #f s1) + (.push :color #f s2) + (.push :color #f s3) + (.push :color #f s4) + + ;; make rsp a GOAL pointer + (.sub sp off) + ;; and store it + (set! *kernel-sp* (the pointer sp)) ;; todo, asm form here? + + ;; setup the rsp for the new thread + (set! sp (the uint (-> this stack-top))) + (.add sp off) + + ;; push the return trampoline to the stack for the user code to return to + (set! temp (the uint return-from-thread)) + (.add temp off) + (.push temp) ;; stack now 16 + 8 aligned + ;; and call the function! + (.add func off) + (.jr func) + ) + ) + +(defmethod thread-suspend ((unused cpu-thread)) + "Suspend the thread and return to the kernel." + + (declare (asm-func none)) + + ;; we begin this function with the thread object in pp. + ;; not sure why we do this, maybe at one point suspending didn't clobber + ;; temp registers? + (rlet ((this :reg r13 :type cpu-thread) + (temp :reg rax :type uint) + (off :reg r15 :type uint) + (sp :reg rsp :type uint) + (s0 :reg rbx :type uint) + (s1 :reg rbp :type uint) + (s2 :reg r10 :type uint) + (s3 :reg r11 :type uint) + (s4 :reg r12 :type uint) + + (xmm8 :reg xmm8 :class fpr) + (xmm9 :reg xmm9 :class fpr) + (xmm10 :reg xmm10 :class fpr) + (xmm11 :reg xmm11 :class fpr) + (xmm12 :reg xmm12 :class fpr) + (xmm13 :reg xmm13 :class fpr) + (xmm14 :reg xmm14 :class fpr) + (xmm15 :reg xmm15 :class fpr) + ) + + ;; get the return address pushed by "call" in the suspend. + (.pop temp) + ;; convert to a GOAL address + (.sub temp off) + ;; store return address in thread + (set! (-> this pc) (the pointer temp)) + + ;; convert our stack pointer to a GOAL address + (.sub sp off) + ;; store in thread. + (set! (-> this sp) (the pointer sp)) + + ;; back up registers + (.mov :color #f temp s0) + (set! (-> this rreg 0) temp) + (.mov :color #f temp s1) + (set! (-> this rreg 1) temp) + (.mov :color #f temp s2) + (set! (-> this rreg 2) temp) + (.mov :color #f temp s3) + (set! (-> this rreg 3) temp) + (.mov :color #f temp s4) + (set! (-> this rreg 4) temp) + + ;; back up fprs + (.mov :color #f temp xmm8) + (set! (-> this freg 0) (the-as float temp)) + (.mov :color #f temp xmm9) + (set! (-> this freg 1) (the-as float temp)) + (.mov :color #f temp xmm10) + (set! (-> this freg 2) (the-as float temp)) + (.mov :color #f temp xmm11) + (set! (-> this freg 3) (the-as float temp)) + (.mov :color #f temp xmm12) + (set! (-> this freg 4) (the-as float temp)) + (.mov :color #f temp xmm13) + (set! (-> this freg 5) (the-as float temp)) + (.mov :color #f temp xmm14) + (set! (-> this freg 6) (the-as float temp)) + (.mov :color #f temp xmm15) + (set! (-> this freg 7) (the-as float temp)) + + ;; get our process + (let ((proc (-> this process))) + (when (> (process-stack-used proc) (-> this stack-size)) + (break) ;; too much stack has been used and we can't suspend! + ;; if you hit this, try with DEBUG_PRINT_SUSPEND_FAIL set to #t (see gkernel-h.gc) + ;; it will print more info before reaching here. + ) + + ;; mark the process as suspended and copy the stack + (set! (-> proc status) 'suspended) + (let ((cur (the (pointer uint64) (-> this stack-top))) + (save (&+ (the (pointer uint64) (-> this stack)) (-> this stack-size))) + ) + (while (> (the int cur) (the int sp)) + (set! cur (the (pointer uint64) (&- cur 8))) + (set! save (the (pointer uint64) (&- save 8))) + (set! (-> save) (-> cur)) + ) + ) + ) + + ;; actually setting pp to 0 + (set! this (the cpu-thread 0)) + + ;; get the kernel stack pointer as a GOAL pointer + (.load-sym :sext #f sp *kernel-sp*) + ;; convert it back to a real pointer + (.add sp off) + + ;; restore saved registers... + ;; without coloring system because this is "cheating". + (.pop :color #f s4) + (.pop :color #f s3) + (.pop :color #f s2) + (.pop :color #f s1) + (.pop :color #f s0) + ;; return to the kernel function that called the user code + (.ret) + ) + (none) + ) + +(defmethod thread-resume ((thread-to-resume cpu-thread)) + "Resume a suspended thread. Call this from the kernel only. + This is also used to start a thread initialized with set-to-run. + As a result of MIPS/x86 differences, there is a hack for this." + (declare (asm-func none) + ;;(print-asm) + ) + + (rlet ((this :reg r13 :type cpu-thread) + (temp :reg rax :type uint) + (off :reg r15 :type uint) + (sp :reg rsp :type uint) + (s0 :reg rbx :type uint) + (s1 :reg rbp :type uint) + (s2 :reg r10 :type uint) + (s3 :reg r11 :type uint) + (s4 :reg r12 :type uint) + (a4 :reg r8 :type uint) + (a5 :reg r9 :type uint) + + (temp-float :reg xmm0 :class fpr) + (xmm8 :reg xmm8 :class fpr) + (xmm9 :reg xmm9 :class fpr) + (xmm10 :reg xmm10 :class fpr) + (xmm11 :reg xmm11 :class fpr) + (xmm12 :reg xmm12 :class fpr) + (xmm13 :reg xmm13 :class fpr) + (xmm14 :reg xmm14 :class fpr) + (xmm15 :reg xmm15 :class fpr) + ) + + ;; save the current kernel regs + (.push :color #f s0) + (.push :color #f s1) + (.push :color #f s2) + (.push :color #f s3) + (.push :color #f s4) + + ;; make rsp a GOAL pointer + (.sub sp off) + ;; and store it + (set! *kernel-sp* (the pointer sp)) ;; todo, asm form here? + + ;; temp, stash thread in process-pointer + (set! this thread-to-resume) + + ;; set stack pointer for the thread. leave it as a GOAL pointer for now.. + (set! sp (the uint (-> this sp))) + + ;; restore the stack (sp is a GOAL pointer) + (let ((cur (the (pointer uint64) (-> this stack-top))) + (restore (&+ (the (pointer uint64) (-> this stack)) (-> this stack-size))) + ) + (while (> (the int cur) (the int sp)) + (set! cur (the (pointer uint64) (&- cur 8))) + (set! restore (the (pointer uint64) (&- restore 8))) + (set! (-> cur) (-> restore)) + ) + ) + + ;; offset sp after we're done using it as a GOAL pointer. + (.add sp off) + + ;; setup process + (set! (-> (-> this process) top-thread) this) + (set! (-> (-> this process) status) 'running) + + ;; restore reg + (set! temp (-> this rreg 0)) + (.mov :color #f s0 temp) + (set! temp (-> this rreg 1)) + (.mov :color #f s1 temp) + (set! temp (-> this rreg 2)) + (.mov :color #f s2 temp) + (set! temp (-> this rreg 3)) + (.mov :color #f s3 temp) + (set! temp (-> this rreg 4)) + (.mov :color #f s4 temp) + (set! temp-float (-> this freg 0)) + (.mov :color #f xmm8 temp-float) + (set! temp-float (-> this freg 1)) + (.mov :color #f xmm9 temp-float) + (set! temp-float (-> this freg 2)) + (.mov :color #f xmm10 temp-float) + (set! temp-float (-> this freg 3)) + (.mov :color #f xmm11 temp-float) + (set! temp-float (-> this freg 4)) + (.mov :color #f xmm12 temp-float) + (set! temp-float (-> this freg 5)) + (.mov :color #f xmm13 temp-float) + (set! temp-float (-> this freg 6)) + (.mov :color #f xmm14 temp-float) + (set! temp-float (-> this freg 7)) + (.mov :color #f xmm15 temp-float) + + ;; hack for set-to-run-bootstrap. The set-to-run-bootstrap in MIPS + ;; expects to receive 7 values from the cpu thread's rregs. + ;; usually rreg holds saved registers, but on the first resume after + ;; a set-to-run, they hold arguments, and set-to-run-bootstrap copies them. + + ;; We only have 5 saved regs, so we need to cheat and directly pass + ;; two values in other registers + ;; so we load the a4/a5 argument registers with rreg 5 and rreg 6 + ;; In the case where we are doing a normal resume, the + ;; compiler should assume that these registers are overwritten anyway. + (set! temp (-> this rreg 5)) + (.mov a4 temp) + (set! temp (-> this rreg 6)) + (.mov a5 temp) + + ;; get the resume address + (set! temp (the uint (-> this pc))) + (.add temp off) + + ;; setup the process + (set! this (the cpu-thread (-> this process))) + ;; resume! + (.jr temp) + (.add a4 a4) + (.add a5 a5) + ) + (none) + ) + +(defmethod new dead-pool ((allocation symbol) (type-to-make type) (num-proc int) (process-size int) (name string)) + "Allocate a dead pool and set up dead processes" + (let ((s3-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s3-0 name) name) + (set! (-> s3-0 mask) (process-mask process-tree)) + (set! (-> s3-0 parent) (the-as (pointer process-tree) #f)) + (set! (-> s3-0 brother) (the-as (pointer process-tree) #f)) + (set! (-> s3-0 child) (the-as (pointer process-tree) #f)) + (set! (-> s3-0 self) s3-0) + (set! (-> s3-0 ppointer) (the-as (pointer process) (&-> s3-0 self))) + (dotimes (s2-1 num-proc) + (let ((s1-0 (-> s3-0 child)) + (v1-5 ((method-of-type process new) allocation process "dead" process-size)) + ) + (set! (-> s3-0 child) (process->ppointer v1-5)) + (set! (-> v1-5 parent) (process->ppointer (the-as process s3-0))) + (set! (-> v1-5 pool) s3-0) + (set! (-> v1-5 brother) s1-0) + ) + ) + s3-0 + ) + ) + +(defmethod get-process ((this dead-pool) (proc-type type) (proc-size int) (unk object)) + "Allocate a process from the pool, or #f if it fails." + (let ((s4-0 (the-as object (-> this child)))) + (when (and (not (the-as (pointer process-tree) s4-0)) *debug-segment* (!= this *debug-dead-pool*)) + (set! s4-0 (get-process *debug-dead-pool* proc-type proc-size unk)) + (if (the-as process s4-0) + (format + 0 + "WARNING: ~A ~A had to be allocated from the debug pool, because ~A was empty.~%" + proc-type + #f ;; bug! (ppointer->process (the-as process s4-0)) + (-> this name) + ) + ) + (break!) ;; bug in original game with process vs pointer process. + ) + (cond + (s4-0 + (set! (-> (the-as (pointer process) s4-0) 0 type) proc-type) + (-> (the-as (pointer process) s4-0) 0) + ) + (else + (format + 0 + "WARNING: ~A ~A could not be allocated, because ~A was empty.~%" + proc-type + (ppointer->process (the-as (pointer process) s4-0)) + (-> this name) + ) + (the-as process #f) + ) + ) + ) + ) + +(defmethod return-process ((this dead-pool) (proc process)) + "Return a process to the pool." + (change-parent proc this) + 0 + (none) + ) + +(defmethod new dead-pool-heap ((allocation symbol) (type-to-make type) (name string) (max-num-proc int) (heap-size int)) + "Allocate and initialize a dead-pool-heap." + (let ((s2-0 (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* 12 max-num-proc)))))) + (set! (-> s2-0 name) name) + (set! (-> s2-0 mask) (process-mask process-tree)) + (set! (-> s2-0 allocated-length) max-num-proc) + (set! (-> s2-0 parent) (the-as (pointer process-tree) #f)) + (set! (-> s2-0 brother) (the-as (pointer process-tree) #f)) + (set! (-> s2-0 child) (the-as (pointer process-tree) #f)) + (set! (-> s2-0 self) s2-0) + (set! (-> s2-0 ppointer) (the-as (pointer process) (&-> s2-0 self))) + (init s2-0 allocation heap-size) + s2-0 + ) + ) + +(defmethod init ((this dead-pool-heap) (allocation symbol) (heap-size int)) + "Allocate memory for processes and init records." + (countdown (v1-0 (-> this allocated-length)) + (let ((a0-4 (-> this process-list v1-0))) + (set! (-> a0-4 process) *null-process*) + (set! (-> a0-4 next) (-> this process-list (+ v1-0 1))) + ) + ) + (set! (-> this dead-list next) (the-as dead-pool-heap-rec (-> this process-list))) + (set! (-> this alive-list process) #f) + (set! (-> this process-list (+ (-> this allocated-length) -1) next) #f) + (set! (-> this alive-list prev) (-> this alive-list)) + (set! (-> this alive-list next) #f) + (set! (-> this alive-list process) #f) + (set! (-> this first-gap) (-> this alive-list)) + (set! (-> this first-shrink) #f) + (cond + ((zero? heap-size) + (set! (-> this heap base) (the-as pointer 0)) + (set! (-> this heap current) (the-as pointer 0)) + (set! (-> this heap top) (the-as pointer 0)) + (set! (-> this heap top-base) (the-as pointer 0)) + 0 + ) + (else + (set! (-> this heap base) (malloc allocation heap-size)) + (set! (-> this heap current) (-> this heap base)) + (set! (-> this heap top) (&+ (-> this heap base) heap-size)) + (set! (-> this heap top-base) (-> this heap top)) + ) + ) + (none) + ) + +(defmethod gap-location ((this dead-pool-heap) (rec dead-pool-heap-rec)) + "Get pointer to gap (possibly zero size) after the given process" + (the-as + pointer + (if (-> rec process) + (+ (+ (-> rec process allocated-length) -4 (-> process size)) (the-as int (-> rec process))) + (-> this heap base) + ) + ) + ) + +(defmethod gap-size ((this dead-pool-heap) (first-rec dead-pool-heap-rec)) + "Get the size of the gap (possibly zero) after the given process. Use #f for the gap at the start of the pool memory." + (cond + ((-> first-rec process) + (let ((v1-3 + (&+ (&+ (the-as pointer (-> first-rec process)) (-> process size)) (-> first-rec process allocated-length)) + ) + ) + (if (-> first-rec next) + (&- (the-as pointer (-> first-rec next process)) (the-as uint v1-3)) + (&- (-> this heap top) (the-as uint (&+ v1-3 4))) + ) + ) + ) + ((-> first-rec next) + (&- (the-as pointer (-> first-rec next process)) (the-as uint (&+ (-> this heap base) 4))) + ) + (else + (&- (-> this heap top) (the-as uint (-> this heap base))) + ) + ) + ) + +(defmethod find-gap ((this dead-pool-heap) (first-rec dead-pool-heap-rec)) + "Find the first process with a nonzero gap after it, after the given process." + (while (and (-> first-rec next) (zero? (gap-size this first-rec))) + (set! first-rec (-> first-rec next)) + ) + first-rec + ) + +(defmethod inspect ((this dead-pool-heap)) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~Tname: ~A~%" (-> this name)) + (format #t "~1Tmask: #x~X : (process-mask " (-> this mask)) + (stream<-process-mask #t (-> this mask)) + (format #t ")~%") + (format #t "~Tparent: #x~X~%" (-> this parent)) + (format #t "~Tbrother: #x~X~%" (-> this brother)) + (format #t "~Tchild: #x~X~%" (-> this child)) + (format #t "~Tppointer: #x~X~%" (-> this ppointer)) + (format #t "~Tself: ~A~%" (-> this self)) + (format #t "~Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~Theap: #~%" (-> this heap)) + (format #t "~Tfirst-gap: #~%" (-> this first-gap)) + (format #t "~Tfirst-shrink: #~%" (-> this first-shrink)) + (format #t "~Talive-list: #~%" (-> this alive-list)) + (format #t "~Tlast: #~%" (-> this alive-list prev)) + (format #t "~Tdead-list: #~%" (-> this dead-list)) + (let* ((s5-0 (&- (-> this heap top) (the-as uint (-> this heap base)))) + (v1-3 (if (-> this alive-list prev) + (gap-size this (-> this alive-list prev)) + s5-0 + ) + ) + ) + (format #t "~Tprocess-list[0] @ #x~X ~D/~D bytes used~%" (-> this process-list) (- s5-0 v1-3) s5-0) + ) + (let ((s5-1 (-> this alive-list)) + (s4-0 0) + ) + (while s5-1 + (if (-> s5-1 process) + (format #t "~T [~3D] # ~A~%" s4-0 s5-1 (-> s5-1 process)) + ) + (let ((s3-0 (gap-size this s5-1))) + (if (nonzero? s3-0) + (format #t "~T gap: ~D bytes @ #x~X~%" s3-0 (gap-location this s5-1)) + ) + ) + (set! s5-1 (-> s5-1 next)) + (+! s4-0 1) + ) + ) + this + ) + +(defmethod asize-of ((this dead-pool-heap)) + (the-as int (+ (-> this type size) (* 12 (-> this allocated-length)))) + ) + +(defmethod memory-used ((this dead-pool-heap)) + "Get the total memory used. Memory in between processes that is not used by a process is considered used." + (if (-> this alive-list prev) + (- (memory-total this) (gap-size this (-> this alive-list prev))) + 0 + ) + ) + +(defmethod memory-total ((this dead-pool-heap)) + "Get the total size of the heap for processes." + (&- (-> this heap top) (the-as uint (-> this heap base))) + ) + +(defmethod memory-free ((this dead-pool-heap)) + "Get the size of the unused part of the heap." + (let ((v1-0 (-> this heap top))) + (if (-> this alive-list prev) + (gap-size this (-> this alive-list prev)) + (&- v1-0 (the-as uint (-> this heap base))) + ) + ) + ) + +(defmethod compact-time ((this dead-pool-heap)) + "Get the compaction time (never set)." + (-> this compact-time) + ) + +(defmethod find-gap-by-size ((this dead-pool-heap) (size int)) + "Find the first gap with a size at least this big" + (let ((gp-0 (-> this first-gap))) + (while (and gp-0 (< (gap-size this gp-0) size)) + (set! gp-0 (-> gp-0 next)) + ) + gp-0 + ) + ) + +(defmethod get-process ((this dead-pool-heap) (proc-type type) (proc-size int) (unk object)) + "Allocate a process from the pool, or #f if it fails." + (let ((s3-0 (-> this dead-list next)) + (s4-0 (the-as process #f)) + ) + (let ((s1-0 (find-gap-by-size this (the-as int (+ (-> process size) proc-size))))) + (cond + ((and s3-0 s1-0 (nonzero? (-> this heap base))) + (set! (-> this dead-list next) (-> s3-0 next)) + (let ((v1-6 (-> s1-0 next))) + (set! (-> s1-0 next) s3-0) + (set! (-> s3-0 next) v1-6) + (if v1-6 + (set! (-> v1-6 prev) s3-0) + ) + ) + (set! (-> s3-0 prev) s1-0) + (if (= s1-0 (-> this alive-list prev)) + (set! (-> this alive-list prev) s3-0) + ) + (let ((a0-5 (gap-location this s1-0))) + (set! s4-0 ((method-of-type process new) (the-as symbol a0-5) process "process" proc-size)) + ) + (set! (-> s3-0 process) s4-0) + (set! (-> s4-0 ppointer) (&-> s3-0 process)) + (if (= (-> this first-gap) s1-0) + (set! (-> this first-gap) (find-gap this s3-0)) + ) + (if (or (not (-> this first-shrink)) (< (the-as int s4-0) (the-as int (-> this first-shrink process)))) + (set! (-> this first-shrink) s3-0) + ) + (set! (-> s4-0 parent) (-> this ppointer)) + (set! (-> s4-0 pool) this) + (set! (-> this child) (&-> s3-0 process)) + ) + (else + (when (and *debug-segment* (!= this *debug-dead-pool*)) + (set! s4-0 (get-process *debug-dead-pool* proc-type proc-size unk)) + (if (and s4-0 *vis-boot*) + (format + 0 + "WARNING: ~A ~A had to be allocated from the debug pool, because ~A was empty.~%" + proc-type + s4-0 + (-> this name) + ) + ) + 0 + ) + ) + ) + ) + (if s4-0 + (set! (-> s4-0 type) proc-type) + (format 0 "WARNING: ~A ~A could not be allocated, because ~A was empty.~%" proc-type s4-0 (-> this name)) + ) + s4-0 + ) + ) + +(defmethod return-process ((this dead-pool-heap) (proc process)) + "Return a process to the pool." + (if (!= this (-> proc pool)) + (format 0 "ERROR: process ~A does not belong to dead-pool-heap ~A.~%" proc this) + ) + (change-parent proc this) + (set! (-> this child) (the-as (pointer process-tree) #f)) + (let ((s5-1 (-> proc ppointer))) + (if (or (= (-> this first-gap) s5-1) (< (the-as int (gap-location this (the-as dead-pool-heap-rec s5-1))) + (the-as int (gap-location this (-> this first-gap))) + ) + ) + (set! (-> this first-gap) (the-as dead-pool-heap-rec (-> s5-1 1))) + ) + (when (= (-> this first-shrink) s5-1) + (set! (-> this first-shrink) (the-as dead-pool-heap-rec (-> s5-1 1))) + (if (not (-> this first-shrink process)) + (set! (-> this first-shrink) #f) + ) + ) + (set! (-> s5-1 1 clock) (the-as clock (-> s5-1 2))) + (if (-> s5-1 2) + (set! (-> s5-1 2 mask) (the-as process-mask (-> s5-1 1))) + (set! (-> this alive-list prev) (the-as dead-pool-heap-rec (-> s5-1 1))) + ) + (set! (-> s5-1 2) (the-as process (-> this dead-list next))) + (set! (-> this dead-list next) (the-as dead-pool-heap-rec s5-1)) + (set! (-> s5-1 0) *null-process*) + ) + 0 + (none) + ) + +(defmethod shrink-heap ((this dead-pool-heap) (proc process)) + "Shrink the heap of a process, allowing the dead pool heap to later reclaim the memory during a compact." + (when proc + (let ((s5-0 (-> proc ppointer))) + (when (not (or (logtest? (-> proc mask) (process-mask heap-shrunk)) + (and (not (-> proc next-state)) (not (-> proc state))) + ) + ) + (set! (-> proc allocated-length) (&- (-> proc heap-cur) (the-as uint (-> proc stack)))) + (set! (-> proc heap-top) (&-> proc stack (-> proc allocated-length))) + (if (< (the-as int proc) (the-as int (gap-location this (-> this first-gap)))) + (set! (-> this first-gap) (find-gap this (the-as dead-pool-heap-rec s5-0))) + ) + (logior! (-> proc mask) (process-mask heap-shrunk)) + ) + (if (= (-> this first-shrink) s5-0) + (set! (-> this first-shrink) (the-as dead-pool-heap-rec (-> s5-0 2))) + ) + ) + ) + this + ) + +(define-extern *nk-dead-pool* dead-pool-heap) + +(defmethod compact ((this dead-pool-heap) (compact-count int)) + "Relocate process in memory to remove gaps, increasing free memory for this dead-pool-heap." + (if (zero? (-> this heap base)) + (return 0) + ) + (let* ((s4-0 (memory-free this)) + (v1-5 (memory-total this)) + (f0-2 (/ (the float s4-0) (the float v1-5))) + ) + (cond + ((< f0-2 0.1) + (set! compact-count 1000) + (if (and *debug-segment* (-> *kernel-context* low-memory-message)) + (format + *stdcon* + "~3LLow Actor Memory (free ~,,0fK/~,,0fK)~0L~%" + (* 0.0009765625 (the float (memory-free *nk-dead-pool*))) + (* 0.0009765625 (the float (memory-total *nk-dead-pool*))) + ) + ) + ) + ((< f0-2 0.2) + (set! compact-count (* compact-count 4)) + ) + ((< f0-2 0.3) + (set! compact-count (* compact-count 2)) + ) + ) + ) + (set! (-> this compact-count-targ) (the-as uint compact-count)) + (set! (-> this compact-count) (the-as uint 0)) + (while (nonzero? compact-count) + (+! compact-count -1) + (let ((v1-25 (-> this first-shrink))) + (when (not v1-25) + (set! v1-25 (-> this alive-list next)) + (set! (-> this first-shrink) v1-25) + ) + (if v1-25 + (shrink-heap this (-> v1-25 process)) + ) + ) + (let ((s4-2 (-> this first-gap))) + (when (-> s4-2 next) + (let ((s3-1 (-> s4-2 next process)) + (s2-1 (gap-size this s4-2)) + ) + (when (nonzero? s2-1) + (when (< s2-1 0) + (break!) + 0 + ) + (shrink-heap this s3-1) + (relocate s3-1 (- s2-1)) + (set! (-> this first-gap) (find-gap this s4-2)) + (+! (-> this compact-count) 1) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod churn ((this dead-pool-heap) (count int)) + "Relocate process in memory, to trigger memory bugs related to process relocation." + (while (nonzero? count) + (+! count -1) + (let ((s4-0 (-> this alive-list next))) + (when s4-0 + (if (or (= (-> this first-gap) s4-0) + (< (the-as int (gap-location this s4-0)) (the-as int (gap-location this (-> this first-gap)))) + ) + (set! (-> this first-gap) (-> s4-0 prev)) + ) + (when (= (-> this first-shrink) s4-0) + (set! (-> this first-shrink) (-> s4-0 prev)) + (if (not (-> this first-shrink process)) + (set! (-> this first-shrink) #f) + ) + ) + (set! (-> s4-0 prev next) (-> s4-0 next)) + (if (-> s4-0 next) + (set! (-> s4-0 next prev) (-> s4-0 prev)) + (set! (-> this alive-list prev) (-> s4-0 prev)) + ) + (let ((a1-3 (-> this alive-list prev))) + (let ((v1-19 (-> a1-3 next))) + (set! (-> a1-3 next) s4-0) + (set! (-> s4-0 next) v1-19) + (if v1-19 + (set! (-> v1-19 prev) s4-0) + ) + ) + (set! (-> s4-0 prev) a1-3) + (set! (-> this alive-list prev) s4-0) + (set! (-> s4-0 process) + (relocate (-> s4-0 process) (&- (gap-location this a1-3) (the-as uint (&-> (-> s4-0 process) type)))) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defun method-state ((typ type) (state-name symbol)) + "Get a virtual state from this type by name." + (dotimes (v1-0 (the-as int (-> typ allocated-length))) + (let ((a2-2 (the-as basic (-> typ method-table v1-0)))) + (if (and (nonzero? (the-as function a2-2)) + (= (-> (the-as function a2-2) type) state) + (= (-> (the-as state a2-2) name) state-name) + ) + (return (the-as state a2-2)) + ) + ) + ) + (the-as state #f) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Process Searching and Iterating +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define *global-search-name* (the-as basic #f)) +(define *global-search-count* 0) + +(defun process-by-name ((process-name string) (tree process-tree)) + "Find the first process with the given name in the process-tree." + (set! *global-search-name* process-name) + (search-process-tree + tree + (lambda ((arg0 process)) (string= (-> arg0 name) (the-as string *global-search-name*))) + ) + ) + +(defun process-not-name ((name string) (tree process-tree)) + "Find the first process without the given name in the process-tree." + (set! *global-search-name* name) + (search-process-tree + tree + (lambda ((arg0 process)) (not (string= (-> arg0 name) (the-as string *global-search-name*)))) + ) + ) + +(defun process-count ((tree process-tree)) + "Count the number of processes in the given process-tree." + (set! *global-search-count* 0) + (iterate-process-tree + tree + (lambda ((arg0 process)) (set! *global-search-count* (+ *global-search-count* 1)) #t) + *null-kernel-context* + ) + *global-search-count* + ) + +(defun kill-by-name ((name string) (tree process-tree)) + "Kill all processes with the given name." + (local-vars (a0-1 process)) + (while (begin (set! a0-1 (process-by-name name tree)) a0-1) + (deactivate a0-1) + ) + #f + ) + +(defun kill-by-type ((typ type) (tree process-tree)) + "Kill all processes with the given type." + (local-vars (a0-1 process)) + (set! *global-search-name* typ) + (while (begin + (set! a0-1 (search-process-tree tree (lambda ((arg0 process)) (= (-> arg0 type) *global-search-name*)))) + a0-1 + ) + (deactivate a0-1) + ) + #f + ) + +(defun kill-not-name ((name string) (tree process-tree)) + "Kill all processes, except ones with the given name." + (local-vars (a0-1 process)) + (while (begin (set! a0-1 (process-not-name name tree)) a0-1) + (deactivate a0-1) + ) + #f + ) + +(defun kill-not-type ((typ type) (tree process-tree)) + "Kill all processes, except ones with the exact type." + (local-vars (a0-1 process)) + (set! *global-search-name* typ) + (while (begin + (set! a0-1 (search-process-tree tree (lambda ((arg0 process)) (!= (-> arg0 type) *global-search-name*)))) + a0-1 + ) + (deactivate a0-1) + ) + #f + ) + +(defun kill-by-type-inherited ((typ type) (tree process-tree)) + "Kill all processes, except ones that inherit from the given type." + (local-vars (a0-1 process)) + (set! *global-search-name* typ) + (while (begin + (set! a0-1 + (search-process-tree tree (lambda ((arg0 process)) (type? arg0 (the-as type *global-search-name*)))) + ) + a0-1 + ) + (deactivate a0-1) + ) + #f + ) + +(defmethod run-logic? ((this process-tree)) + "Should this process be run? Checked by execute-process-tree." + #f + ) + +(defmethod run-logic? ((this process)) + "Should this process be run? Checked by execute-process-tree." + #t + ) + +(defun iterate-process-tree ((tree process-tree) (callback (function object object)) (context kernel-context)) + "Call a function on each not-dead process in the tree." + (let ((s4-0 (or (logtest? (-> tree mask) (process-mask process-tree)) (callback tree)))) + (cond + ((= s4-0 'dead) + ) + (else + (let ((v1-4 (-> tree child))) + (while v1-4 + (let ((s3-1 (-> v1-4 0 brother))) + (iterate-process-tree (-> v1-4 0) callback context) + (set! v1-4 s3-1) + ) + ) + ) + ) + ) + s4-0 + ) + ) + +(defun execute-process-tree ((tree process-tree) (callback (function object object)) (context kernel-context)) + "Iterate over all process, calling the run callback on each, if they should run." + (logclear! (-> tree mask) (process-mask kernel-run)) + (let ((s3-0 (or (logtest? (-> tree mask) (process-mask process-tree)) + (not (and (not (logtest? (-> context prevent-from-run) (-> tree mask))) (run-logic? tree))) + (begin (logior! (-> tree mask) (process-mask kernel-run)) (callback tree)) + ) + ) + ) + (cond + ((= s3-0 'dead) + ) + (else + (let ((v1-12 (-> tree child))) + (while v1-12 + (let ((s4-1 (-> v1-12 0 brother))) + (execute-process-tree (-> v1-12 0) callback context) + (set! v1-12 s4-1) + ) + ) + ) + ) + ) + s3-0 + ) + ) + +(defun search-process-tree ((tree process-tree) (callback (function process-tree object))) + "Return the first function in the process-tree which the callback returns #t on." + (when (not (logtest? (-> tree mask) (process-mask process-tree))) + (if (callback tree) + (return (the-as process tree)) + ) + ) + (let ((v1-5 (-> tree child))) + (while v1-5 + (let ((s5-1 (-> v1-5 0 brother))) + (let ((v1-6 (search-process-tree (-> v1-5 0) callback))) + (if v1-6 + (return v1-6) + ) + ) + (set! v1-5 s5-1) + ) + ) + ) + (the-as process #f) + ) + +(defun kernel-dispatcher () + "Run the GOAL kernel! Runs the function from the listener (if there is one), then all processes" + + (profiler-instant-event "ROOT") + + (when *listener-function* + (set! *enable-method-set* (+ *enable-method-set* 1)) + (let ((t1-0 (reset-and-call (-> *listener-process* main-thread) *listener-function*))) + ;; changed here. + (if *use-old-listener-print* + (format #t "~D~%" t1-0 t1-0 t1-0) + (format #t "~D #x~X ~F ~A~%" t1-0 t1-0 t1-0 t1-0) + ) + ) + (set! *listener-function* #f) + (set! *enable-method-set* (+ *enable-method-set* -1)) + 0 + ) + (execute-process-tree + *active-pool* + (lambda ((arg0 process)) + ;; (+! (-> *canary-1*) 1) + ;; (+! (-> *canary-2*) 1) + ;; (+! (-> *canary-3*) 1) + ;; (+! (-> *canary-4*) 1) + (let ((s5-0 *kernel-context*)) + (case (-> arg0 status) + (('waiting-to-run 'suspended) + (set! (-> s5-0 current-process) arg0) + (cond + ((logtest? (-> arg0 mask) (process-mask pause)) + (set! *stdcon* *stdcon1*) + (set! *debug-draw-pauseable* #t) + ) + (else + (set! *stdcon* *stdcon0*) + (set! *debug-draw-pauseable* #f) + ) + ) + ;; run the trans function. + ;; (format 0 "Trans | Proc ~A | C1: ~X C2: ~X C3: ~X C4: ~X~%" (-> arg0 name) (-> *canary-1*) (-> *canary-2*) (-> *canary-3*) (-> *canary-4*)) + (when (-> arg0 trans-hook) + (let ((s4-0 (new 'process 'cpu-thread arg0 'trans 256 (-> arg0 main-thread stack-top)))) + (reset-and-call s4-0 (-> arg0 trans-hook)) + (delete s4-0) + ) + (when (= (-> arg0 status) 'dead) + (set! (-> s5-0 current-process) #f) + (return 'dead) + ) + ) + ;; run the main thread! + ;; (format 0 "Code | Proc ~A | C1: ~X C2: ~X C3: ~X C4: ~X~%" (-> arg0 name) (-> *canary-1*) (-> *canary-2*) (-> *canary-3*) (-> *canary-4*)) + (if (logtest? (-> arg0 mask) (process-mask sleep-code)) + (set! (-> arg0 status) 'suspended) + ((-> arg0 main-thread resume-hook) (-> arg0 main-thread)) + ) + ;; (format 0 "Finished Code | Proc ~A | C1: ~X C2: ~X C3: ~X C4: ~X~%" (-> arg0 name) (-> *canary-1*) (-> *canary-2*) (-> *canary-3*) (-> *canary-4*)) + (cond + ((= (-> arg0 status) 'dead) + (set! (-> s5-0 current-process) #f) + 'dead + ) + (else + ;; run post. + ;; NOTE: post always runs on the dram stack, so you can use ja-post and use the scratchpad for anims. + (when (-> arg0 post-hook) + ;; (format 0 "Post | Proc ~A | C1: ~X C2: ~X C3: ~X C4: ~X~%" (-> arg0 name) (-> *canary-1*) (-> *canary-2*) (-> *canary-3*) (-> *canary-4*)) + (let ((s4-1 (new 'process 'cpu-thread arg0 'post 256 *kernel-dram-stack*))) + (reset-and-call s4-1 (-> arg0 post-hook)) + (delete s4-1) + ) + ;; (format 0 "Finished Post | Proc ~A | C1: ~X C2: ~X C3: ~X C4: ~X~%" (-> arg0 name) (-> *canary-1*) (-> *canary-2*) (-> *canary-3*) (-> *canary-4*)) + (when (= (-> arg0 status) 'dead) + (set! (-> s5-0 current-process) #f) + (return 'dead) + ) + (set! (-> arg0 status) 'suspended) + ) + (set! (-> s5-0 current-process) #f) + #f + ) + ) + ) + (('dead) + 'dead + ) + ) + ) + ) + *kernel-context* + ) + ) + +(defun sync-dispatcher () + "Run the REPL function." + (let ((t9-0 *listener-function*)) + (when t9-0 + (set! *listener-function* #f) + (t9-0) + #f + ) + ) + ) + +(defun inspect-process-tree ((tree process-tree) (depth int) (mask int) (detail symbol)) + "Display a tree-view of a process-tree." + (print-tree-bitmask mask depth) + (cond + (detail + (format #t "__________________~%") + (format + #t + "~S~A~%" + (if (zero? depth) + "" + "+---" + ) + tree + ) + (let ((s2-0 *print-column*)) + (set! *print-column* (the-as binteger (* (* depth 4) 8))) + (inspect tree) + (set! *print-column* s2-0) + ) + ) + (else + (format + #t + "~S~A~%" + (if (zero? depth) + "" + "+---" + ) + tree + ) + ) + ) + (let ((s2-1 (-> tree child))) + (while s2-1 + (inspect-process-tree + (-> s2-1 0) + (+ depth 1) + (if (not (-> s2-1 0 brother)) + mask + (logior mask (ash 1 (+ depth 1))) + ) + detail + ) + (set! s2-1 (-> s2-1 0 brother)) + ) + ) + tree + ) + +(defmacro set-u128-as-u64! (dst src) + `(set! (-> (the (pointer uint64) (& ,dst))) + ,src + ) + ) + +(defmacro set-u64-from-u128! (dst src) + `(set! ,dst (-> (the (pointer uint64) (& ,src)))) + ) + +(defmacro the-super-u64-fucntion (func) + `(the-as (function uint uint uint uint uint uint object) ,func) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Stack Frame Stuff +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; The GOAL kernel supports dynamic throw and catch. +;; The catch frames are managed per process (you can't throw to a frame outside your process) +;; But otherwise it is fully dynamic. + +(defmethod new catch-frame ((allocation symbol) (type-to-make type) (name symbol) (func function) (param-block (pointer uint64))) + "Run func in a catch frame with the given 8 parameters. + The return value is the result of the function. + The allocation must be an address. + Unlike the original, this only works on the first six parameters, but I think this doesn't matter." + (declare (asm-func object) + (allow-saved-regs) ;; very dangerous! + ) + + (rlet ((pp :reg r13 :type process) + (temp :reg rax :type uint) + (off :reg r15 :type uint) + (sp :reg rsp :type uint) + (s0 :reg rbx :type uint) + (s1 :reg rbp :type uint) + (s2 :reg r10 :type (pointer uint64)) + (s3 :reg r11 :type uint) + (s4 :reg r12 :type uint) + + (xmm8 :reg xmm8 :class fpr) + (xmm9 :reg xmm9 :class fpr) + (xmm10 :reg xmm10 :class fpr) + (xmm11 :reg xmm11 :class fpr) + (xmm12 :reg xmm12 :class fpr) + (xmm13 :reg xmm13 :class fpr) + (xmm14 :reg xmm14 :class fpr) + (xmm15 :reg xmm15 :class fpr) + ) + + ;; we treat the allocation as an address. + (let ((this (the catch-frame (&+ (the pointer allocation) *gtype-basic-offset*)))) + ;; setup catch frame + (set! (-> this type) type-to-make) + (set! (-> this name) name) + ;; get the return address (the compiler won't touch the stack because we're an asm-func) + (.pop temp) + (.push temp) + ;; make it a GOAL address so it fits in 32 bits + (.sub temp off) + ;; store it + (set! (-> this ra) (the int temp)) + + ;; todo, do we need a stack offset here? + ;; remember the stack pointer + (set! temp sp) + (.sub temp off) + (set! (-> this sp) (the int temp)) + + ;; back up registers we care about + (.mov :color #f temp s0) + (set-u128-as-u64! (-> this rreg 0) temp) + (.mov :color #f temp s1) + (set-u128-as-u64! (-> this rreg 1) temp) + (.mov :color #f temp s2) + (set-u128-as-u64! (-> this rreg 2) temp) + (.mov :color #f temp s3) + (set-u128-as-u64! (-> this rreg 3) temp) + (.mov :color #f temp s4) + (set-u128-as-u64! (-> this rreg 4) temp) + + (.mov :color #f temp xmm8) + (set! (-> this freg 0) (the-as float temp)) + (.mov :color #f temp xmm9) + (set! (-> this freg 1) (the-as float temp)) + (.mov :color #f temp xmm10) + (set! (-> this freg 2) (the-as float temp)) + (.mov :color #f temp xmm11) + (set! (-> this freg 3) (the-as float temp)) + (.mov :color #f temp xmm12) + (set! (-> this freg 4) (the-as float temp)) + (.mov :color #f temp xmm13) + (set! (-> this freg 5) (the-as float temp)) + (.mov :color #f temp xmm14) + (set! (-> this freg 6) (the-as float temp)) + (.mov :color #f temp xmm15) + (set! (-> this freg 7) (the-as float temp)) + + ;; push this stack frame + (set! (-> this next) (-> pp stack-frame-top)) + (set! (-> pp stack-frame-top) this) + + ;; help coloring, it isn't smart enough to realize it's "safe" to use these registers. + (.push :color #f s3) + (.push :color #f s2) + (.push :color #f s2) + (set! s3 (the uint func)) + (set! s2 param-block) + + ;; todo - are we aligned correctly here? + (let ((ret ((the-super-u64-fucntion s3) + (-> s2 0) + (-> s2 1) + (-> s2 2) + (-> s2 3) + (-> s2 4) + (-> s2 5) + )) + ) + (.pop :color #f s2) + (.pop :color #f s2) + (.pop :color #f s3) + (set! (-> pp stack-frame-top) (-> pp stack-frame-top next)) + (.ret) + (the object ret) + ) + ) + ) + ) + +(defun throw-dispatch ((this catch-frame) value) + "Throw the given value to the catch frame. + Only can throw a 64-bit value. The original could throw 128 bits." + (declare (asm-func none)) + + (rlet ((pp :reg r13 :type process) + (temp :reg rax :type uint) + (off :reg r15 :type uint) + (sp :reg rsp :type uint) + (s0 :reg rbx :type uint) + (s1 :reg rbp :type uint) + (s2 :reg r10 :type (pointer uint64)) + (s3 :reg r11 :type uint) + (s4 :reg r12 :type uint) + + (temp-float :reg xmm0 :class fpr) + (xmm8 :reg xmm8 :class fpr) + (xmm9 :reg xmm9 :class fpr) + (xmm10 :reg xmm10 :class fpr) + (xmm11 :reg xmm11 :class fpr) + (xmm12 :reg xmm12 :class fpr) + (xmm13 :reg xmm13 :class fpr) + (xmm14 :reg xmm14 :class fpr) + (xmm15 :reg xmm15 :class fpr) + ) + + ;; pop everything we threw past + (set! (-> pp stack-frame-top) (-> this next)) + + ;; restore regs we care about. + (set-u64-from-u128! temp (-> this rreg 0)) + (.mov :color #f s0 temp) + (set-u64-from-u128! temp (-> this rreg 1)) + (.mov :color #f s1 temp) + (set-u64-from-u128! temp (-> this rreg 2)) + (.mov :color #f s2 temp) + (set-u64-from-u128! temp (-> this rreg 3)) + (.mov :color #f s3 temp) + (set-u64-from-u128! temp (-> this rreg 4)) + (.mov :color #f s4 temp) + + (set! temp-float (-> this freg 0)) + (.mov :color #f xmm8 temp-float) + (set! temp-float (-> this freg 1)) + (.mov :color #f xmm9 temp-float) + (set! temp-float (-> this freg 2)) + (.mov :color #f xmm10 temp-float) + (set! temp-float (-> this freg 3)) + (.mov :color #f xmm11 temp-float) + (set! temp-float (-> this freg 4)) + (.mov :color #f xmm12 temp-float) + (set! temp-float (-> this freg 5)) + (.mov :color #f xmm13 temp-float) + (set! temp-float (-> this freg 6)) + (.mov :color #f xmm14 temp-float) + (set! temp-float (-> this freg 7)) + (.mov :color #f xmm15 temp-float) + + ;; set stack pointer + (set! sp (the uint (-> this sp))) + (.add sp off) + + ;; overwrite our return address + (.pop temp) + (set! temp (the uint (-> this ra))) + (.add temp off) + (.push temp) + + ;; load the return register + (.mov temp value) + (.ret) + ) + ) + +(defun throw ((name symbol) value) + "Dynamic throw." + (rlet ((pp :reg r13 :type process)) + (let ((cur (-> pp stack-frame-top))) + (while cur + (when (and (eq? (-> cur name) name) (eq? (-> cur type) catch-frame)) + ;; match! + + (throw-dispatch (the catch-frame cur) value) + ) + + (if (eq? (-> cur type) protect-frame) + ;; call the cleanup function + ((-> (the protect-frame cur) exit)) + ) + (set! cur (-> cur next)) + ) + ) + ) + (format 0 "ERROR: throw could not find tag ~A~%" name) + (break) + ) + +(defmethod new protect-frame ((stack-addr symbol) (type-to-make type) (exit-func (function object))) + "Allocate and set up a protect-frame. This _must_ be used on the stack." + (with-pp + (let ((v0-0 (the-as object (+ (the-as int stack-addr) 4)))) + (set! (-> (the-as protect-frame v0-0) type) type-to-make) + (set! (-> (the-as protect-frame v0-0) name) 'protect-frame) + (set! (-> (the-as protect-frame v0-0) exit) exit-func) + (set! (-> (the-as protect-frame v0-0) next) (-> pp stack-frame-top)) + (set! (-> pp stack-frame-top) (the-as protect-frame v0-0)) + (the-as protect-frame v0-0) + ) + ) + ) + +(defun previous-brother ((tree process-tree)) + "Get the process before this one, at this level." + (let ((v1-0 (-> tree parent))) + (when v1-0 + (let ((v1-2 (-> v1-0 0 child))) + (if (= v1-2 tree) + (return (the-as object #f)) + ) + (while v1-2 + (if (= (-> v1-2 0 brother) tree) + (return (the-as object v1-2)) + ) + (set! v1-2 (-> v1-2 0 brother)) + ) + ) + (the-as (pointer process-tree) #f) + ) + ) + ) + +(defun change-parent ((proc-to-change process-tree) (new-parent process-tree)) + "Reparent a process." + (let ((a2-0 (-> proc-to-change parent))) + (when a2-0 + (let ((v1-2 (-> a2-0 0 child))) + (cond + ((= (ppointer->process v1-2) proc-to-change) + (set! (-> a2-0 0 child) (-> proc-to-change brother)) + ) + (else + (while (!= (ppointer->process (-> v1-2 0 brother)) proc-to-change) + (nop!) + (nop!) + (nop!) + (set! v1-2 (-> v1-2 0 brother)) + ) + (set! (-> v1-2 0 brother) (-> proc-to-change brother)) + ) + ) + ) + ) + ) + (set! (-> proc-to-change parent) (-> new-parent ppointer)) + (set! (-> proc-to-change brother) (-> new-parent child)) + (set! (-> new-parent child) (-> proc-to-change ppointer)) + proc-to-change + ) + +(defun change-brother ((arg0 process-tree) (arg1 process-tree)) + "Unused, and wrong." + (when (and arg0 (!= (-> arg0 brother) arg1) (!= arg0 arg1)) + (let ((a2-1 (-> arg0 parent))) + (when a2-1 + (let ((t0-0 (-> a2-1 0 child)) + (a3-1 (the-as (pointer process-tree) #f)) + (v1-4 (the-as (pointer process-tree) #f)) + ) + (if (= (ppointer->process t0-0) arg0) + (set! a3-1 a2-1) + ) + (if (= (ppointer->process t0-0) arg1) + (set! v1-4 a2-1) + ) + (while (and (-> t0-0 0 brother) (or (not a3-1) (not v1-4))) + (if (= (-> (ppointer->process t0-0) brother) arg1) + (set! v1-4 t0-0) + ) + (if (= (-> (ppointer->process t0-0) brother) arg0) + (set! a3-1 t0-0) + ) + (set! t0-0 (-> t0-0 0 brother)) + ) + (cond + ((or (not a3-1) (not v1-4)) + (return 0) + ) + ((= a3-1 a2-1) + (set! (-> a3-1 5) (the-as process-tree (-> arg0 brother))) + ) + (else + (set! (-> a3-1 4) (the-as process-tree (-> arg0 brother))) + ) + ) + (cond + ((= v1-4 a2-1) + (set! (-> arg0 brother) (the-as (pointer process-tree) (-> v1-4 5))) + (set! (-> v1-4 5) (the-as process-tree (-> arg0 ppointer))) + ) + (else + (set! (-> arg0 brother) (the-as (pointer process-tree) (-> v1-4 4))) + (set! (-> v1-4 4) (the-as process-tree (-> arg0 ppointer))) + ) + ) + ) + ) + ) + ) + arg0 + ) + +(defun change-to-last-brother ((proc process-tree)) + "Move this process to the end of its brother list." + (when (and (-> proc brother) (-> proc parent)) + (let* ((a1-0 (-> proc parent)) + (v1-4 (-> a1-0 0 child)) + ) + (cond + ((= (-> v1-4 0) proc) + (set! (-> a1-0 0 child) (-> proc brother)) + ) + (else + (while (!= (-> v1-4 0 brother 0) proc) + (nop!) + (nop!) + (nop!) + (nop!) + (set! v1-4 (-> v1-4 0 brother)) + ) + (set! (-> v1-4 0 brother) (-> proc brother)) + ) + ) + (while (-> v1-4 0 brother) + (nop!) + (nop!) + (nop!) + (nop!) + (set! v1-4 (-> v1-4 0 brother)) + ) + (set! (-> v1-4 0 brother) (-> proc ppointer)) + ) + (set! (-> proc brother) (the-as (pointer process-tree) #f)) + ) + proc + ) + +(defmethod activate ((this process) (active-tree process-tree) (name string) (stack-pointer pointer)) + "Move a process from dead to active, moving it to the given tree." + + ;; if we got the scratchpad stack, move to the fake scratchpad. + (#when PC_PORT + (when (= stack-pointer *scratch-memory-top*) + (set! stack-pointer (scratchpad-end)) + ) + ) + (set! (-> this mask) + (logclear (-> active-tree mask) (process-mask sleep sleep-code process-tree heap-shrunk)) + ) + (+! (-> this clock ref-count) -1) + (+! (-> active-tree clock ref-count) 1) + (set! (-> this clock) (-> active-tree clock)) + (set! (-> this status) 'ready) + (let ((v1-11 (-> *kernel-context* next-pid))) + (set! (-> this pid) v1-11) + (set! (-> *kernel-context* next-pid) (+ v1-11 1)) + ) + (set! (-> this top-thread) #f) + (set! (-> this main-thread) #f) + (set! (-> this name) name) + (let ((v1-16 (&-> this stack (-> this type heap-base)))) + (set! (-> this heap-cur) v1-16) + (set! (-> this heap-base) v1-16) + ) + (set! (-> this stack-frame-top) #f) + (mem-set32! (-> this stack) (the-as int (shr (-> this type heap-base) 2)) 0) + (set! (-> this trans-hook) #f) + (set! (-> this post-hook) #f) + (set! (-> this event-hook) #f) + (set! (-> this state) #f) + (set! (-> this next-state) #f) + (set! (-> this prev-state) #f) + (set! (-> this state-stack) #f) + (cond + ((logtest? (-> active-tree mask) (process-mask process-tree)) + (set! (-> this entity) #f) + (set! (-> this level) *default-level*) + ) + (else + (set! (-> this entity) (-> (the-as process active-tree) entity)) + (set! (-> this level) (-> (the-as process active-tree) level)) + ) + ) + (set! (-> this connection-list next1) #f) + (set! (-> this connection-list prev1) #f) + (set! (-> this main-thread) (new 'process 'cpu-thread this 'code 256 stack-pointer)) + (change-parent this active-tree) + ) + +(defun run-function-in-process ((this process) (func function) a0 a1 a2 a3 a4 a5) + "Switch to the given process and run the function. This is used to initialize a process. + The function will run until it attempts to change state. At the first attempt to change state, + this function will return. The idea is that you use this when you want to initialize a process NOW. + This will then return the value of the function you called!" + (when (zero? func) + (format 0 "attempting to run nullptr function!~%") + (break!) + ) + (rlet ((pp :reg r13 :type process)) + + (let ((param-array (new 'stack-no-clear 'array 'uint64 6)) + ) + ;; copy params to the stack. + + (set! (-> param-array 0) (the uint64 a0)) + (set! (-> param-array 1) (the uint64 a1)) + (set! (-> param-array 2) (the uint64 a2)) + (set! (-> param-array 3) (the uint64 a3)) + (set! (-> param-array 4) (the uint64 a4)) + (set! (-> param-array 5) (the uint64 a5)) + + (let* ((old-pp pp) + (func-val (begin + ;; set the process + (set! pp this) + ;; set us as initializing + (set! (-> pp status) 'initialize) + ;; run! + (the object (new 'stack 'catch-frame 'initialize func param-array)) + ))) + ;; the function returned, either through a throw or through actually returning. + ;; the status will give us a clue of what happened. + (case (-> pp status) + (('initialize) + ;; we returned and didn't change status. + (set! (-> pp status) 'initialize-dead) + ;; this means we died, and we should be deactivated. + (deactivate pp) + ) + (('initialize-go) + ;; we returned with a (suspend) or (go) ? not sure + ;; either way, we're ready for next time! + (set! (-> pp status) 'waiting-to-run) + (when (eq? (-> pp pool type) dead-pool-heap) + ;; we can shrink the heap now. + (shrink-heap (the dead-pool-heap (-> pp pool)) pp) + ) + ) + (('dead) + ;; died in init, this is fine. + ) + (else + (format 0 "GOT UNKNOWN INIT: ~A~%" (-> pp status)) + ) + ) + ;; restore the old pp + (set! pp old-pp) + func-val + ) + ) + ) + ) + +(defun set-to-run-bootstrap () + "This function is a clever hack. + To reset a thread to running a new function, we stash the arguments as saved registers. + These are then restored by thread-resume on the next run of the kernel. + This stub remaps these saved registers to argument registers. + It also creates a return trampoline to return-from-thread-dead, so if the main thread returns, the + process is properly cleaned up by deactivate." + (declare (asm-func none) + ;;(print-asm) + ) + + (rlet ((s0 :reg rbx :type uint) + (s1 :reg rbp :type uint) + (s2 :reg r10 :type uint) + (s3 :reg r11 :type uint) + (s4 :reg r12 :type uint) + (a0 :reg rdi :type uint) ; ok + (a1 :reg rsi :type uint) ; ok + (a2 :reg rdx :type uint) ; ok + (a3 :reg rcx :type uint) ; ok + (off :reg r15 :type uint) + (a4 :reg r8 :type uint) + (a5 :reg r9 :type uint) + (temp :reg rax) + ) + + + (.mov temp return-from-thread-dead) + (.add temp off) + (.push temp) + + ;; stack is 16 + 8 aligned now + + (.mov :color #f a0 s1) + (.mov :color #f a1 s2) + (.mov :color #f a2 s3) + (.mov :color #f a3 s4) + + (.add :color #f s0 off) + (.jr :color #f s0) + + (.add a4 a4) + (.add a5 a5) + ) + ) + +;; definition for function set-to-run +(defun set-to-run ((thread cpu-thread) (func function) a0 a1 a2 a3 a4 a5) + "Set the given thread to call the given function with the given arguments next time it resumes. + Only for main threads. + Once the function returns, the process deactivates." + (let ((proc (-> thread process))) + (set! (-> proc status) 'waiting-to-run) + + ;; we store arguments and the function to call in saved registers + (set! (-> thread rreg 0) (the uint func)) + (set! (-> thread rreg 1) (the uint a0)) + (set! (-> thread rreg 2) (the uint a1)) + (set! (-> thread rreg 3) (the uint a2)) + (set! (-> thread rreg 4) (the uint a3)) + (set! (-> thread rreg 5) (the uint a4)) + (set! (-> thread rreg 6) (the uint a5)) + + ;; and have the thread first call set-to-run-bootstrap, which will properly call + ;; the function with the arguments and install a return trampoline for + ;; deactivating and returning to the kernel on return. + (set! (-> thread pc) (the pointer set-to-run-bootstrap)) + ;; reset sp. + (set! (-> thread sp) (-> thread stack-top)) + ) + ) + +;; definition for method 10 of type process-tree +;; WARN: Return type mismatch int vs none. +(defmethod deactivate ((this process-tree)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + 0 + (none) + ) + +;; The defstate macro isn't defined yet, so we do it manually. +(define dead-state + (the (state process) (new 'static 'state + :name 'dead-state + :next #f + ;; og:preserve-this added parent + :parent #f + :exit #f + :code #f + :trans #f + :post #f + :enter #f + :event #f))) +(set! (-> dead-state code) (the (function object :behavior process) nothing)) + +(define entity-deactivate-handler (the-as (function process entity-actor none) nothing)) + +(defmethod deactivate ((this process)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (with-pp + (when (!= (-> this status) 'dead) + (set! (-> this next-state) dead-state) + (if (-> this entity) + (entity-deactivate-handler this (-> this entity)) + ) + (let ((s5-0 pp)) + (set! pp this) + (let ((s4-0 (-> pp stack-frame-top))) + (while (the-as protect-frame s4-0) + (case (-> s4-0 type) + ((protect-frame state) + ((-> (the-as protect-frame s4-0) exit)) + ) + ) + (set! s4-0 (-> (the-as protect-frame s4-0) next)) + ) + ) + (set! pp s5-0) + ) + (if (nonzero? process-disconnect) ;; added zero check. + (process-disconnect this) + ) + (let ((v1-12 (-> this child))) + (while v1-12 + (let ((s5-1 (-> v1-12 0 brother))) + (deactivate (-> v1-12 0)) + (set! v1-12 s5-1) + ) + ) + ) + (return-process (-> this pool) this) + (+! (-> this clock ref-count) -1) + (set! (-> this state) #f) + (set! (-> this next-state) #f) + (set! (-> this prev-state) #f) + (set! (-> this state-stack) #f) + (set! (-> this entity) #f) + (set! (-> this pid) 0) + (cond + ((= (-> *kernel-context* current-process) this) + (set! (-> this status) 'dead) + (abandon-thread) + ) + ((= (-> this status) 'initialize) + (set! (-> this status) 'dead) + (throw 'initialize #f) + ) + ) + (set! (-> this status) 'dead) + ) + 0 + (none) + ) + ) + +;; failed to figure out what this is: +(kmemopen global "process-buffers") + +(define *kernel-clock* (new 'static 'clock)) +(define *vis-boot* #f) +(define *null-process* (new 'global 'process "null" 16)) + +(let ((v0-45 (new 'global 'process "listener" 2048))) + (set! *listener-process* v0-45) + (let ((gp-0 v0-45)) + (set! (-> gp-0 status) 'ready) + (set! (-> gp-0 pid) 1) + (set! (-> gp-0 main-thread) (new 'process 'cpu-thread gp-0 'main 256 *kernel-dram-stack*)) + ) + ) + +(define *16k-dead-pool* (new + 'global + 'dead-pool + (if *debug-segment* + 1 + 0 + ) + #x4000 + "*16k-dead-pool*" + ) + ) + +(define *8k-dead-pool* (new 'global 'dead-pool 4 #x2800 "*8k-dead-pool*")) +(define *4k-dead-pool* (new 'global 'dead-pool 4 4096 "*4k-dead-pool*")) +(define *target-dead-pool* (new 'global 'dead-pool 1 #x16800 "*target-dead-pool*")) +(define *camera-dead-pool* (new 'global 'dead-pool 7 4096 "*camera-dead-pool*")) +(define *camera-master-dead-pool* (new 'global 'dead-pool 1 8192 "*camera-master-dead-pool*")) +(when *debug-segment* +(define *debug-dead-pool* (new 'debug 'dead-pool-heap "*debug-dead-pool*" 768 #x100000)) + +) +(define *nk-dead-pool* (new 'global 'dead-pool-heap "*nk-dead-pool*" PROCESS_HEAP_MAX PROCESS_HEAP_SIZE)) +(define *default-dead-pool* (the-as dead-pool *nk-dead-pool*)) +(define *pickup-dead-pool* (the-as dead-pool *nk-dead-pool*)) +(define *dead-pool-list* '(*4k-dead-pool* + *8k-dead-pool* + *16k-dead-pool* + *nk-dead-pool* + *target-dead-pool* + *camera-dead-pool* + *camera-master-dead-pool* + ) + ) + + +(define *active-pool* (new 'global 'process-tree "active-pool")) + +(change-parent (define *display-pool* (new 'global 'process-tree "display-pool")) *active-pool*) + +;; og:preserve-this added pc pool +(#when PC_PORT +(change-parent (define *pc-pool* (new 'global 'process-tree "pc-pool")) *active-pool*) +(set! (-> *pc-pool* mask) (process-mask freeze pause menu progress process-tree))) + +(change-parent (define *camera-pool* (new 'global 'process-tree "camera-pool")) *active-pool*) +(set! (-> *camera-pool* mask) (process-mask freeze pause menu progress process-tree camera)) + +(change-parent (define *target-pool* (new 'global 'process-tree "target-pool")) *active-pool*) +(set! (-> *target-pool* mask) (process-mask freeze pause menu progress process-tree)) + +(change-parent (define *entity-pool* (new 'global 'process-tree "entity-pool")) *active-pool*) +(set! (-> *entity-pool* mask) (process-mask freeze pause menu progress process-tree entity)) + +(change-parent (define *mid-pool* (new 'global 'process-tree "mid-pool")) *active-pool*) + +(change-parent (define *pusher-pool* (new 'global 'process-tree "pusher-pool")) *active-pool*) +(set! (-> *pusher-pool* mask) (process-mask freeze pause menu progress process-tree entity)) + +(change-parent (define *bg-pool* (new 'global 'process-tree "bg-pool")) *active-pool*) +(set! (-> *bg-pool* mask) (process-mask freeze pause menu progress process-tree)) + +(change-parent (define *default-pool* (new 'global 'process-tree "default-pool")) *active-pool*) +(set! (-> *default-pool* mask) (process-mask freeze pause menu progress process-tree)) + +(kmemclose) + + +(defmacro ps (&key (detail #f)) + `(inspect-process-tree *active-pool* 0 0 ,detail) + ) + +(format 0 "Jak X kernel loaded!~%") diff --git a/goal_src/jakx/kernel/gstate.gc b/goal_src/jakx/kernel/gstate.gc index d5e1a8c40f..a52f953d2b 100644 --- a/goal_src/jakx/kernel/gstate.gc +++ b/goal_src/jakx/kernel/gstate.gc @@ -5,5 +5,275 @@ ;; name in dgo: gstate ;; dgos: KERNEL +(defmacro go (next-state &rest args) + "Change the state of the current process. + This will only return if this is called within the post thread. + Otherwise, execution stops here and the kernel will run the next state next time." + `(with-pp + (go-hook pp ,next-state ,@args) + ) + ) + +(defmacro process-spawn-function (proc-type func &key (from *default-dead-pool*) &key (to *default-pool*) &key (name #f) &key (stack-size #x4000) &key (stack *scratch-memory-top*) &rest args) + "Start a new process that runs a function on its main thread. + Returns a pointer to the new process (or #f? on error). + Note that the extra jak 3 arg is so far always 1 (checked in decompiler)" + + (with-gensyms (new-proc) + `(let ((,new-proc (the-as ,proc-type (get-process ,from ,proc-type ,stack-size 1)))) + (when ,new-proc + ((method-of-type ,proc-type activate) ,new-proc ,to ,(if name name `(symbol->string ',proc-type)) ,stack) + (run-next-time-in-process ,new-proc ,func ,@args) + (the (pointer ,proc-type) (-> ,new-proc ppointer)) + ) + ) + ) + ) + +(defmacro process-spawn (proc-type &key (init #f) + &key (from *default-dead-pool*) + &key (to *default-pool*) + &key (name #f) + &key (stack-size #x4000) + &key (stack *scratch-memory-top*) + &key (unk 1) + &key (runtime #f) + &rest args) + "Start a new process and run an init function on it. + Returns a pointer to the new process, or #f (or is it 0?) if something goes wrong." + (with-gensyms (new-proc) + `(let ((,new-proc (the-as ,(if runtime 'process proc-type) (get-process ,from ,proc-type ,stack-size ,unk)))) + (when ,new-proc + ((method-of-type ,(if runtime 'process proc-type) activate) ,new-proc ,to ,(if name name `(symbol->string ',proc-type)) ,stack) + (run-now-in-process ,new-proc ,(if init init (string->symbol (fmt #f "{}-init-by-other" proc-type))) ,@args) + (the (pointer ,(if runtime 'process proc-type)) (-> ,new-proc ppointer)) + ) + ) + ) + ) + +(defmacro go-virtual (state-name &key (proc self) &rest args) + "Same as go, but use a virtual state." + `(go (method-of-object ,proc ,state-name) ,@args) + ) + +(defmacro go-process (proc next-state &rest args) + "Make another process go." + `(with-pp + (protect (pp) + (set! pp ,proc) + (go-hook pp ,next-state ,@args) + ) + ) + ) + +;; run the given function in a process right now. +;; will return to here when: +;; - you return +;; - you deactivate +;; - you go +;; - you throw to 'initialize +(defmacro run-now-in-process (proc func &rest args) + "Run a function in another process right now." + `((the (function _varargs_ object) run-function-in-process) + ,proc ,func ,@args + ) + ) + +;; sets the main thread of the given process to run the given thing. +;; this resets the main thread stack back to the top +(defmacro run-next-time-in-process (proc func &rest args) + "Set up a process to run a function the next time it is scheduled." + `((the (function _varargs_ object) set-to-run) + (-> ,proc main-thread) ,func ,@args + ) + ) + + +;; use a compile-time list to keep track of the type of an anonymous behavior. +(seval (define *defstate-type-stack* '())) +(desfun def-state-check-behavior (beh-form beh-type) + "check if code block is an anonymous behavior. needed for anonymous behaviors on defstate." + + (when (and (pair? beh-form) (eq? (first beh-form) 'behavior)) + (push! *defstate-type-stack* beh-type) + ) + ) +(defmacro clear-def-state-stack () + (set! *defstate-type-stack* '()) + `(none) + ) + +;; set when inside a defstate. +(seval (define *defstate-current-type* #f)) +(seval (define *defstate-current-state-name* #f)) + +;; *no-state* is just used for the compiler to know whether a handler was actually set or not +(defmacro defstate (state-name parents + &key (virtual #f) + &key (parent #f) + &key (event *no-state*) + &key (enter *no-state*) + &key (trans *no-state*) + &key (exit *no-state*) + &key (code *no-state*) + &key (post *no-state*) + &rest body + ) + "Define a new state!" + + (with-gensyms (new-state) + (let ((defstate-type (first parents)) + (docstring "")) + (when (and (> (length body) 1) (string? (first body))) + (set! docstring (first body))) + (when (not (null? *defstate-type-stack*)) + (fmt #t "*defstate-type-stack* leaked! An error probably happened in a previous defstate. stack is: {}" + *defstate-type-stack*) + ) + (set! *defstate-type-stack* '()) + (when virtual + (set! *defstate-current-type* defstate-type) + (set! *defstate-current-state-name* state-name) + ) + ;; check for default handlers + (let ((default-handlers (assoc defstate-type *default-state-handlers*))) + (when default-handlers + ;;(fmt #t "found default-handlers for {}: {}\n" defstate-type default-handlers) + ;; event + (set! default-handlers (cadr default-handlers)) + (when (and (eq? event '*no-state*) (car default-handlers)) + (set! event (car default-handlers))) + ;; enter + (set! default-handlers (cdr default-handlers)) + (when (and (eq? enter '*no-state*) (car default-handlers)) + (set! enter (car default-handlers))) + ;; trans + (set! default-handlers (cdr default-handlers)) + (when (and (eq? trans '*no-state*) (car default-handlers)) + (set! trans (car default-handlers))) + ;; exit + (set! default-handlers (cdr default-handlers)) + (when (and (eq? exit '*no-state*) (car default-handlers)) + (set! exit (car default-handlers))) + ;; code + (set! default-handlers (cdr default-handlers)) + (when (and (eq? code '*no-state*) (car default-handlers)) + (set! code (car default-handlers))) + ;; post + (set! default-handlers (cdr default-handlers)) + (when (and (eq? post '*no-state*) (car default-handlers)) + (set! post (car default-handlers))) + + (set! default-handlers (cdr default-handlers)) + ) + ) + (def-state-check-behavior event defstate-type) + (def-state-check-behavior enter defstate-type) + (def-state-check-behavior trans defstate-type) + (def-state-check-behavior exit defstate-type) + (def-state-check-behavior code defstate-type) + (def-state-check-behavior post defstate-type) + `(let ((,new-state (new 'static 'state + :name (quote ,state-name) + :next #f + :exit #f + :code #f + :trans #f + :post #f + :enter #f + :event #f + ) + )) + ;; the compiler will set the fields of the given state and define the symbol. + ;; This way it can check the individual function types, make sure they make sense, and create + ;; a state with the appropriate type. + ,(cond + ((and virtual parent) + `(begin + (inherit-state ,new-state ,(if (pair? parent) `(method-of-type ,(car parent) ,(cadr parent)) `(the state ,parent))) + (set! (-> ,new-state parent) ,(if (pair? parent) `(method-of-type ,(car parent) ,(cadr parent)) `(the state ,parent))) + (define-virtual-state-hook ,state-name ,defstate-type ,new-state ,docstring ,(eq? virtual 'override) :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) + ) + ) + (virtual + `(begin + (set! (-> ,new-state parent) #f) + (define-virtual-state-hook ,state-name ,defstate-type ,new-state ,docstring ,(eq? virtual 'override) :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) + ) + ) + (parent + `(begin + (inherit-state ,new-state (the state ,parent)) + (set! (-> ,new-state parent) (the state ,parent)) + (define-state-hook ,state-name ,defstate-type ,new-state ,docstring :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) + ) + ) + (#t + `(begin + (set! (-> ,new-state parent) #f) + (define-state-hook ,state-name ,defstate-type ,new-state ,docstring :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) + ) + ) + ) + ) + ) + ) + ) + +(defmacro find-parent-state () + "Find the first different implementation of the current virtual state above this one." + (when (or (not *defstate-current-type*) + (not *defstate-current-state-name*)) + (error "use of find-parent-state outside of a defstate.") + ) + `(cast-to-method-type + ,*defstate-current-type* + ,*defstate-current-state-name* + (find-parent-method ,*defstate-current-type* (method-id-of-type ,*defstate-current-type* ,*defstate-current-state-name*)) + ) + ) + +(defmacro call-parent-state-handler (handler &key (type (function none)) &rest args) + "Call the parent handler for this state." + `(let ((handler (-> (find-parent-state) ,handler))) + (if handler ((the ,type handler) ,@args)) + ) + ) + +(defmacro behavior (bindings &rest body) + "Define an anonymous behavior for a process state. This may only be used inside a defstate!" + + (let ((behavior-type (first *defstate-type-stack*))) + (pop! *defstate-type-stack*) + `(lambda :behavior ,behavior-type ,bindings ,@body) + ) + ) + +;; set the default handler functions for a process's state handlers +(seval (define *default-state-handlers* '())) +(defmacro defstatehandler (proc + &key (event #f) + &key (enter #f) + &key (trans #f) + &key (exit #f) + &key (code #f) + &key (post #f)) + (let ((old (assoc proc *default-state-handlers*)) + (new (list proc (list event enter trans exit code post)))) + (if (not old) + (append!! *default-state-handlers* new) ;; add new set of default handlers + (dolist (hnd *default-state-handlers*) ;; replace old handlers with new ones + (when (eq? (car hnd) old) + (set-car! hnd new) + ) + ) + ) + ) + `(none) + ) + +(define-extern enter-state (function object object object object object object object)) + ;; DECOMP BEGINS diff --git a/goal_src/jakx/kernel/gstring-h.gc b/goal_src/jakx/kernel/gstring-h.gc index 2f025d2d94..48c4f5e942 100644 --- a/goal_src/jakx/kernel/gstring-h.gc +++ b/goal_src/jakx/kernel/gstring-h.gc @@ -5,5 +5,55 @@ ;; name in dgo: gstring-h ;; dgos: KERNEL +(define-extern *string-tmp-str* string) +(define-extern *temp-string* string) +(define-extern *stdcon0* string) +(define-extern *stdcon1* string) +(define-extern *stdcon* string) +(define-extern *debug-draw-pauseable* symbol) +(define-extern string= (function string string symbol)) + ;; DECOMP BEGINS +(defun strlen ((arg0 pointer)) + (let ((v1-0 arg0) + (v0-0 0) + ) + (while (nonzero? (-> (the-as (pointer int8) v1-0))) + (+! v0-0 1) + (&+! v1-0 1) + ) + v0-0 + ) + ) + +(defun strncmp ((arg0 pointer) (arg1 pointer) (arg2 int)) + (let ((v1-0 arg0) + (a0-1 arg1) + ) + (while (nonzero? arg2) + (if (!= (-> (the-as (pointer int8) v1-0)) (-> (the-as (pointer int8) a0-1))) + (return #f) + ) + (if (zero? (-> (the-as (pointer int8) v1-0))) + (return #t) + ) + (set! arg2 (+ arg2 -1)) + (&+! v1-0 1) + (&+! a0-1 1) + ) + ) + #t + ) + +(defun strstr ((arg0 pointer) (arg1 pointer)) + (let ((s4-0 (strlen arg1))) + (while (nonzero? (-> (the-as (pointer int8) arg0))) + (if (strncmp arg0 arg1 s4-0) + (return arg0) + ) + (&+! arg0 1) + ) + ) + (the-as pointer #f) + ) diff --git a/goal_src/jakx/kernel/gstring.gc b/goal_src/jakx/kernel/gstring.gc index 83b45d85d3..07a0180392 100644 --- a/goal_src/jakx/kernel/gstring.gc +++ b/goal_src/jakx/kernel/gstring.gc @@ -7,3 +7,822 @@ ;; DECOMP BEGINS +(defmethod length ((this string)) + (let ((v1-0 (-> this data))) + (while (nonzero? (-> v1-0 0)) + (nop!) + (nop!) + (nop!) + (set! v1-0 (&-> v1-0 1)) + ) + (&- v1-0 (the-as uint (-> this data))) + ) + ) + +(defmethod asize-of ((this string)) + (+ (-> this allocated-length) 1 (-> string size)) + ) + +(defun copy-string<-string ((arg0 string) (arg1 string)) + "Copy a string. No bounds check. Writes null terminator." + (let ((v1-0 (-> arg0 data))) + (let ((a1-1 (-> arg1 data))) + (while (nonzero? (-> a1-1 0)) + (set! (-> v1-0 0) (-> a1-1 0)) + (set! v1-0 (&-> v1-0 1)) + (set! a1-1 (&-> a1-1 1)) + ) + ) + (set! (-> v1-0 0) (the-as uint 0)) + ) + arg0 + ) + +(defmethod new string ((allocation symbol) (type-to-make type) (arg0 int) (arg1 string)) + (cond + (arg1 + (let* ((s2-1 (max (length arg1) arg0)) + (a0-4 (object-new allocation type-to-make (+ s2-1 1 (-> type-to-make size)))) + ) + (set! (-> a0-4 allocated-length) s2-1) + (copy-string<-string a0-4 arg1) + ) + ) + (else + (let ((v0-2 (object-new allocation type-to-make (+ arg0 1 (-> type-to-make size))))) + (set! (-> v0-2 allocated-length) arg0) + v0-2 + ) + ) + ) + ) + +;; WARN: Return type mismatch object vs string. +(defun to-upper ((arg0 string)) + (the-as string (if (and (>= (the-as uint arg0) (the-as uint 97)) (>= (the-as uint 122) (the-as uint arg0))) + (&-> (the-as (pointer uint8) arg0) -32) + arg0 + ) + ) + ) + +(defun string= ((arg0 string) (arg1 string)) + (let ((a2-0 (-> arg0 data)) + (v1-0 (-> arg1 data)) + ) + (if (or (zero? arg0) (zero? arg1)) + (return #f) + ) + (while (and (nonzero? (-> a2-0 0)) (nonzero? (-> v1-0 0))) + (if (!= (-> a2-0 0) (-> v1-0 0)) + (return #f) + ) + (set! a2-0 (&-> a2-0 1)) + (set! v1-0 (&-> v1-0 1)) + ) + (and (zero? (-> a2-0 0)) (zero? (-> v1-0 0))) + ) + ) + +(defun nocase-string= ((arg0 string) (arg1 string)) + (let ((s5-0 (-> arg0 data)) + (gp-0 (-> arg1 data)) + ) + (if (or (zero? arg0) (zero? arg1)) + (return #f) + ) + (while (and (nonzero? (-> s5-0 0)) (nonzero? (-> gp-0 0))) + (if (!= (to-upper (the-as string (-> s5-0 0))) (to-upper (the-as string (-> gp-0 0)))) + (return #f) + ) + (set! s5-0 (&-> s5-0 1)) + (set! gp-0 (&-> gp-0 1)) + ) + (and (zero? (-> s5-0 0)) (zero? (-> gp-0 0))) + ) + ) + +(defun string-prefix= ((arg0 string) (arg1 string)) + "Check if a string starts with a given string." + (let ((v1-0 (-> arg0 data))) + (let ((a2-0 (-> arg1 data))) + (if (or (zero? arg0) (zero? arg1)) + (return #f) + ) + (while (and (nonzero? (-> v1-0 0)) (nonzero? (-> a2-0 0))) + (if (!= (-> v1-0 0) (-> a2-0 0)) + (return #f) + ) + (set! v1-0 (&-> v1-0 1)) + (set! a2-0 (&-> a2-0 1)) + ) + ) + (zero? (-> v1-0 0)) + ) + ) + +(defun charp-prefix= ((arg0 (pointer uint8)) (arg1 (pointer uint8))) + "Check if a c-string starts with a given c-string." + (while (and (nonzero? (-> arg0 0)) (nonzero? (-> arg1 0))) + (if (!= (-> arg0 0) (-> arg1 0)) + (return #f) + ) + (set! arg0 (&-> arg0 1)) + (set! arg1 (&-> arg1 1)) + ) + (zero? (-> arg0 0)) + ) + +(defun string-suffix= ((arg0 string) (arg1 string)) + "Check if a string ends with a given string." + (let ((s5-0 (-> arg0 data)) + (gp-0 (-> arg1 data)) + ) + (if (or (zero? arg0) (zero? arg1)) + (return #f) + ) + (let ((s4-0 (length arg0)) + (v1-5 (length arg1)) + ) + (if (< s4-0 v1-5) + (return #f) + ) + (let ((v1-7 (&+ s5-0 (- s4-0 v1-5)))) + (while (and (nonzero? (-> v1-7 0)) (nonzero? (-> gp-0 0))) + (if (!= (-> v1-7 0) (-> gp-0 0)) + (return #f) + ) + (set! v1-7 (&-> v1-7 1)) + (set! gp-0 (&-> gp-0 1)) + ) + (zero? (-> v1-7 0)) + ) + ) + ) + ) + +(defun string-position ((arg0 string) (arg1 string)) + "Find the point where a string occurs in another. If it doesn't, return -1." + (let ((s5-0 0) + (s4-0 (-> arg1 data)) + ) + (while (nonzero? (-> s4-0 0)) + (if (charp-prefix= (-> arg0 data) s4-0) + (return s5-0) + ) + (+! s5-0 1) + (set! s4-0 (&-> s4-0 1)) + ) + ) + -1 + ) + +(defun string-charp= ((arg0 string) (arg1 (pointer uint8))) + "Check if a string is equal to a c-string." + (let ((v1-0 (-> arg0 data))) + (while (and (nonzero? (-> v1-0 0)) (nonzero? (-> arg1 0))) + (if (!= (-> v1-0 0) (-> arg1 0)) + (return #f) + ) + (set! v1-0 (&-> v1-0 1)) + (set! arg1 (&-> arg1 1)) + ) + (and (zero? (-> v1-0 0)) (zero? (-> arg1 0))) + ) + ) + +(defun name= ((arg0 object) (arg1 object)) + "Do arg0 and arg1 have the same name? + This can use either strings or symbols" + (cond + ((= arg0 arg1) + ;; Either same symbols, or same string objects, fast check pass! + #t) + ((and (= (rtype-of arg0) string) (= (rtype-of arg1) string)) + (string= (the-as string arg0) (the-as string arg1)) + ) + ((and (= (rtype-of arg0) string) (= (rtype-of arg1) symbol)) + (string= (the-as string arg0) (symbol->string (the symbol arg1))) + ) + ((and (= (rtype-of arg1) string) (= (rtype-of arg0) symbol)) + (string= (the-as string arg1) (symbol->string (the symbol arg0))) + ) + ;; no need to check symbol - symbol, that would have passed the first check. + ) + ) + +(defun copyn-string<-charp ((arg0 string) (arg1 (pointer uint8)) (arg2 int)) + "Copy part of a c-string to a string. Writes null terminator after num-chars." + (let ((v1-0 (-> arg0 data))) + (dotimes (a3-0 arg2) + (set! (-> v1-0 0) (-> arg1 0)) + (set! v1-0 (&-> v1-0 1)) + (set! arg1 (&-> arg1 1)) + ) + (set! (-> v1-0 0) (the-as uint 0)) + ) + arg0 + ) + +(defun string<-charp ((arg0 string) (arg1 (pointer uint8))) + "Copy a c-string to a string. Writes the null terminator." + (let ((v1-0 (-> arg0 data))) + (while (nonzero? (-> arg1 0)) + (set! (-> v1-0 0) (-> arg1 0)) + (set! v1-0 (&-> v1-0 1)) + (set! arg1 (&-> arg1 1)) + ) + (set! (-> v1-0 0) (the-as uint 0)) + ) + arg0 + ) + +(defun charp<-string ((arg0 (pointer uint8)) (arg1 string)) + "Copy a string to a c-string. Writes the null terminator." + (let ((v1-0 (-> arg1 data))) + (while (nonzero? (-> v1-0 0)) + (set! (-> arg0 0) (-> v1-0 0)) + (set! arg0 (&-> arg0 1)) + (set! v1-0 (&-> v1-0 1)) + ) + ) + (set! (-> arg0 0) (the-as uint 0)) + 0 + ) + +(defun copyn-charp<-string ((arg0 (pointer uint8)) (arg1 string) (arg2 int)) + "Copy part of a string to a c-string. Writes null terminator, repeatedly, to reach the given length. + If the source is longer than the length, the null terminator is still included." + (let ((v1-0 (-> arg1 data))) + (while (and (nonzero? (-> v1-0 0)) (< 1 arg2)) + (set! (-> arg0 0) (-> v1-0 0)) + (set! arg0 (&-> arg0 1)) + (set! v1-0 (&-> v1-0 1)) + (set! arg2 (+ arg2 -1)) + ) + ) + (while (> arg2 0) + (set! (-> arg0 0) (the-as uint 0)) + (set! arg0 (&-> arg0 1)) + (set! arg2 (+ arg2 -1)) + ) + 0 + (none) + ) + +(defun copy-charp<-charp ((arg0 (pointer uint8)) (arg1 (pointer uint8))) + "C-string copy, writes null terminator." + (while (nonzero? (-> arg1 0)) + (set! (-> arg0 0) (-> arg1 0)) + (set! arg0 (&-> arg0 1)) + (set! arg1 (&-> arg1 1)) + ) + (set! (-> arg0 0) (the-as uint 0)) + arg0 + ) + +(defun cat-string<-string ((arg0 string) (arg1 string)) + "Append a string to another." + (let ((v1-0 (-> arg0 data))) + (let ((a1-1 (-> arg1 data))) + (while (nonzero? (-> v1-0 0)) + (nop!) + (nop!) + (nop!) + (set! v1-0 (&-> v1-0 1)) + ) + (while (nonzero? (-> a1-1 0)) + (set! (-> v1-0 0) (-> a1-1 0)) + (set! v1-0 (&-> v1-0 1)) + (set! a1-1 (&-> a1-1 1)) + ) + ) + (set! (-> v1-0 0) (the-as uint 0)) + ) + arg0 + ) + +(defun catn-string<-charp ((arg0 string) (arg1 (pointer uint8)) (arg2 int)) + "Append part of a string to another. Writes null terminator." + (let ((v1-0 (-> arg0 data))) + (while (nonzero? (-> v1-0 0)) + (nop!) + (nop!) + (nop!) + (set! v1-0 (&-> v1-0 1)) + ) + (dotimes (a3-2 arg2) + (set! (-> v1-0 0) (-> arg1 0)) + (set! v1-0 (&-> v1-0 1)) + (set! arg1 (&-> arg1 1)) + ) + (set! (-> v1-0 0) (the-as uint 0)) + ) + arg0 + ) + +(defun cat-string<-string_to_charp ((arg0 string) (arg1 string) (arg2 (pointer uint8))) + "Append part of a string to another, up to the given pointer." + (let ((v1-0 (-> arg1 data)) + (v0-0 (-> arg0 data)) + ) + (while (nonzero? (-> v0-0 0)) + (nop!) + (nop!) + (nop!) + (set! v0-0 (&-> v0-0 1)) + ) + (while (and (>= (the-as int arg2) (the-as int v1-0)) (nonzero? (-> v1-0 0))) + (set! (-> v0-0 0) (-> v1-0 0)) + (set! v0-0 (&-> v0-0 1)) + (set! v1-0 (&-> v1-0 1)) + ) + (set! (-> v0-0 0) (the-as uint 0)) + v0-0 + ) + ) + +(defun append-character-to-string ((arg0 string) (arg1 uint8)) + "Append a single character to a string. Writes null terminator after." + (let ((v1-0 (-> arg0 data))) + (while (nonzero? (-> v1-0 0)) + (nop!) + (nop!) + (nop!) + (set! v1-0 (&-> v1-0 1)) + ) + (set! (-> v1-0 0) (the-as uint arg1)) + (set! (-> v1-0 1) (the-as uint 0)) + ) + 0 + 0 + ) + +(defun charp-basename ((arg0 (pointer uint8))) + "Strip the directory and suffix from a c-string." + (let ((v1-0 arg0)) + (while (nonzero? (-> v1-0 0)) + (set! v1-0 (&-> v1-0 1)) + ) + (while (< (the-as int arg0) (the-as int v1-0)) + (set! v1-0 (&-> v1-0 -1)) + (if (or (= (-> v1-0 0) 47) (= (-> v1-0 0) 92)) + (return (&-> v1-0 1)) + ) + ) + ) + arg0 + ) + +(defun clear ((arg0 string)) + "Set string to the empty string." + (set! (-> arg0 data 0) (the-as uint 0)) + arg0 + ) + +(defun string arg0 data v1-4) (-> arg1 data v1-4)) + (return #t) + ) + ((< (-> arg1 data v1-4) (-> arg0 data v1-4)) + (return #f) + ) + ) + ) + ) + #f + ) + +(defun string>? ((arg0 string) (arg1 string)) + "Slightly incorrect ordering of strings." + (let ((s4-1 (min (length arg0) (length arg1)))) + (dotimes (v1-4 s4-1) + (cond + ((< (-> arg0 data v1-4) (-> arg1 data v1-4)) + (return #f) + ) + ((< (-> arg1 data v1-4) (-> arg0 data v1-4)) + (return #t) + ) + ) + ) + ) + #f + ) + +(defun string<=? ((arg0 string) (arg1 string)) + "Slightly incorrect ordering of strings." + (let ((s4-1 (min (length arg0) (length arg1)))) + (dotimes (v1-4 s4-1) + (cond + ((< (-> arg0 data v1-4) (-> arg1 data v1-4)) + (return #t) + ) + ((< (-> arg1 data v1-4) (-> arg0 data v1-4)) + (return #f) + ) + ) + ) + ) + #t + ) + +(defun string>=? ((arg0 string) (arg1 string)) + "Slightly incorrect ordering of strings." + (let ((s4-1 (min (length arg0) (length arg1)))) + (dotimes (v1-4 s4-1) + (cond + ((< (-> arg0 data v1-4) (-> arg1 data v1-4)) + (return #f) + ) + ((< (-> arg1 data v1-4) (-> arg0 data v1-4)) + (return #t) + ) + ) + ) + ) + #t + ) + +(define *string-tmp-str* (new 'global 'string 128 (the-as string #f))) + +(defun string-skip-to-char ((arg0 (pointer uint8)) (arg1 uint)) + "Advance to the given character." + (while (and (nonzero? (-> arg0 0)) (!= (-> arg0 0) arg1)) + (set! arg0 (&-> arg0 1)) + ) + arg0 + ) + +(defun string-cat-to-last-char ((arg0 string) (arg1 string) (arg2 uint)) + "Append append-str to end of base-str, up to the last occurance of char" + (let ((s4-0 (&-> (the-as (pointer uint8) arg1) 3))) + (let ((v1-0 (string-skip-to-char (-> arg1 data) arg2))) + (when (= (-> v1-0 0) arg2) + (until (!= (-> v1-0 0) arg2) + (set! s4-0 v1-0) + (set! v1-0 (string-skip-to-char (&-> v1-0 1) arg2)) + ) + ) + ) + (cat-string<-string_to_charp arg0 arg1 s4-0) + ) + ) + +(defun string-skip-whitespace ((arg0 (pointer uint8))) + "Jump over whitespace chars." + (while (and (nonzero? (-> arg0 0)) (or (= (-> arg0 0) 32) (= (-> arg0 0) 9) (= (-> arg0 0) 13) (= (-> arg0 0) 10))) + (set! arg0 (&-> arg0 1)) + ) + arg0 + ) + +(defun string-suck-up! ((arg0 string) (arg1 (pointer uint8))) + "Move the string forward so the pointer is now at the beginning." + (when (!= arg1 (-> arg0 data)) + (let ((v1-2 (-> arg0 data))) + (while (nonzero? (-> arg1 0)) + (set! (-> v1-2 0) (-> arg1 0)) + (set! v1-2 (&-> v1-2 1)) + (set! arg1 (&-> arg1 1)) + ) + (set! (-> v1-2 0) (the-as uint 0)) + ) + 0 + ) + #f + ) + +(defun string-strip-leading-whitespace! ((arg0 string)) + "Strip leading whitespace." + (let ((a1-0 (string-skip-whitespace (-> arg0 data)))) + (string-suck-up! arg0 a1-0) + ) + #f + ) + +(defun string-strip-trailing-whitespace! ((arg0 string)) + "String trailing whitespace." + (when (nonzero? (length arg0)) + (let ((v1-6 (&+ (-> arg0 data) (+ (length arg0) -1)))) + (while (and (>= (the-as int v1-6) (the-as int (-> arg0 data))) + (or (= (-> v1-6 0) 32) (= (-> v1-6 0) 9) (= (-> v1-6 0) 13) (= (-> v1-6 0) 10)) + ) + (set! v1-6 (&-> v1-6 -1)) + ) + (set! (-> v1-6 1) (the-as uint 0)) + ) + 0 + ) + #f + ) + +(defun string-strip-whitespace! ((arg0 string)) + "Strip whitespace from the beginning and end of a string" + (string-strip-trailing-whitespace! arg0) + (string-strip-leading-whitespace! arg0) + #f + ) + +;; WARN: Return type mismatch string vs none. +(defun string-upcase ((arg0 string) (arg1 string) (arg2 symbol)) + "Uppercase characters. If convert-dash is set, - will be uppercased to _" + (let* ((a0-1 (-> arg0 data)) + (t0-0 (the-as int (-> a0-1 0))) + (a3-0 1) + (v1-0 0) + ) + (while (nonzero? (the-as uint t0-0)) + (cond + ((and (>= (the-as uint t0-0) (the-as uint 97)) (>= (the-as uint 122) (the-as uint t0-0))) + (set! t0-0 (the-as int (+ (the-as uint t0-0) -32))) + ) + ((and arg2 (= (the-as uint t0-0) 45)) + (set! t0-0 95) + ) + ) + (set! (-> arg1 data v1-0) (the-as uint t0-0)) + (set! t0-0 (the-as int (-> a0-1 a3-0))) + (+! a3-0 1) + (+! v1-0 1) + ) + (set! (-> arg1 data v1-0) (the-as uint 0)) + ) + 0 + (none) + ) + +(defun string-get-arg!! ((arg0 string) (arg1 string)) + (let ((s4-0 (string-skip-whitespace (-> arg1 data)))) + (cond + ((= (-> s4-0 0) 34) + (let ((s4-1 (&-> s4-0 1))) + (let ((v1-3 s4-1)) + (while (and (nonzero? (-> s4-1 0)) (!= (-> s4-1 0) 34)) + (set! s4-1 (&-> s4-1 1)) + ) + (copyn-string<-charp arg0 v1-3 (&- s4-1 (the-as uint v1-3))) + ) + (if (= (-> s4-1 0) 34) + (set! s4-1 (&-> s4-1 1)) + ) + (let ((a1-3 (string-skip-whitespace s4-1))) + (string-suck-up! arg1 a1-3) + ) + ) + (return #t) + ) + ((nonzero? (-> s4-0 0)) + (let ((v1-11 s4-0)) + (while (and (nonzero? (-> s4-0 0)) (!= (-> s4-0 0) 32) (!= (-> s4-0 0) 9) (!= (-> s4-0 0) 13) (!= (-> s4-0 0) 10)) + (set! s4-0 (&-> s4-0 1)) + ) + (copyn-string<-charp arg0 v1-11 (&- s4-0 (the-as uint v1-11))) + ) + (let ((a1-9 (string-skip-whitespace s4-0))) + (string-suck-up! arg1 a1-9) + ) + (return #t) + ) + ) + ) + #f + ) + +(defun string->int ((arg0 string)) + "Convert string to int." + (let ((a0-1 (-> arg0 data)) + (v0-0 0) + (v1-0 #f) + ) + (cond + ((= (-> a0-1 0) 35) + (let ((a0-2 (&-> a0-1 1))) + (cond + ((or (= (-> a0-2 0) 120) (= (-> a0-2 0) 88)) + (let ((a0-3 (&-> a0-2 1))) + (when (= (-> a0-3 1) 45) + (set! v1-0 #t) + (set! a0-3 (&-> a0-3 1)) + ) + (while (or (and (>= (-> a0-3 0) (the-as uint 48)) (>= (the-as uint 57) (-> a0-3 0))) + (and (>= (-> a0-3 0) (the-as uint 65)) (>= (the-as uint 70) (-> a0-3 0))) + (and (>= (-> a0-3 0) (the-as uint 97)) (>= (the-as uint 102) (-> a0-3 0))) + ) + (cond + ((and (>= (-> a0-3 0) (the-as uint 65)) (>= (the-as uint 70) (-> a0-3 0))) + (set! v0-0 (the-as int (+ (-> a0-3 0) -55 (* v0-0 16)))) + ) + ((and (>= (-> a0-3 0) (the-as uint 97)) (>= (the-as uint 102) (-> a0-3 0))) + (set! v0-0 (the-as int (+ (-> a0-3 0) -87 (* v0-0 16)))) + ) + (else + (set! v0-0 (the-as int (+ (-> a0-3 0) -48 (* v0-0 16)))) + ) + ) + (set! a0-3 (&-> a0-3 1)) + ) + ) + ) + ((or (= (-> a0-2 0) 98) (= (-> a0-2 0) 66)) + (let ((a0-4 (&-> a0-2 1))) + (while (and (>= (-> a0-4 0) (the-as uint 48)) (>= (the-as uint 49) (-> a0-4 0))) + (set! v0-0 (the-as int (+ (-> a0-4 0) -48 (* v0-0 2)))) + (set! a0-4 (&-> a0-4 1)) + ) + ) + ) + ) + ) + ) + (else + (when (= (-> a0-1 1) 45) + (set! v1-0 #t) + (set! a0-1 (&-> a0-1 1)) + ) + (while (and (>= (-> a0-1 0) (the-as uint 48)) (>= (the-as uint 57) (-> a0-1 0))) + (set! v0-0 (the-as int (+ (-> a0-1 0) -48 (* 10 v0-0)))) + (set! a0-1 (&-> a0-1 1)) + ) + ) + ) + (cond + (v1-0 + (- v0-0) + ) + (else + (empty) + v0-0 + ) + ) + ) + ) + +(defun string->float ((arg0 string)) + "Convert string to float. Finally implemented!" + (let ((a0-1 (-> arg0 data)) + (f0-0 0.0) + (v1-0 #f) + ) + (when (= (-> a0-1 0) 45) + (set! v1-0 #t) + (set! a0-1 (&-> a0-1 1)) + ) + (while (and (>= (-> a0-1 0) (the-as uint 48)) (>= (the-as uint 57) (-> a0-1 0))) + (set! f0-0 (+ (* 10.0 f0-0) (the float (+ (-> a0-1 0) -48)))) + (set! a0-1 (&-> a0-1 1)) + ) + (when (= (-> a0-1 0) 46) + (set! a0-1 (&-> a0-1 1)) + (let ((a2-4 #xf4240) + (a1-12 0) + ) + (while (and (>= (-> a0-1 0) (the-as uint 48)) (>= (the-as uint 57) (-> a0-1 0))) + (+! a1-12 (* (+ (-> a0-1 0) -48) (the-as uint a2-4))) + (set! a2-4 (/ a2-4 10)) + (set! a0-1 (&-> a0-1 1)) + ) + (+! f0-0 (* 0.0000001 (the float a1-12))) + ) + ) + (when (= (-> a0-1 0) 101) + (let ((a1-16 (&-> a0-1 1)) + (f1-5 0.0) + (a0-2 #f) + ) + (cond + ((= (-> a1-16 0) 45) + (set! a0-2 #t) + (set! a1-16 (&-> a1-16 1)) + ) + ((= (-> a1-16 0) 43) + (set! a1-16 (&-> a1-16 1)) + ) + ) + (while (and (>= (-> a1-16 0) (the-as uint 48)) (>= (the-as uint 57) (-> a1-16 0))) + (set! f1-5 (+ (* 10.0 f1-5) (the float (+ (-> a1-16 0) -48)))) + (set! a1-16 (&-> a1-16 1)) + ) + (when (!= f1-5 0.0) + (let ((f2-6 1.0)) + (cond + (a0-2 + (dotimes (a0-3 (the int f1-5)) + (set! f2-6 (/ f2-6 10)) + (nop!) + (nop!) + ) + ) + (else + (dotimes (a0-6 (the int f1-5)) + (set! f2-6 (* 10.0 f2-6)) + (nop!) + (nop!) + ) + ) + ) + (set! f0-0 (* f0-0 f2-6)) + ) + ) + ) + ) + (if v1-0 + (- f0-0) + f0-0 + ) + ) + ) + +(defun string-get-int32!! ((arg0 (pointer int32)) (arg1 string)) + (cond + ((string-get-arg!! *string-tmp-str* arg1) + (set! (-> arg0 0) (string->int *string-tmp-str*)) + #t + ) + (else + #f + ) + ) + ) + +(defun string-get-float!! ((arg0 (pointer float)) (arg1 string)) + (cond + ((string-get-arg!! *string-tmp-str* arg1) + (set! (-> arg0 0) (string->float *string-tmp-str*)) + #t + ) + (else + #f + ) + ) + ) + +(defun string-get-flag!! ((arg0 (pointer symbol)) (arg1 string) (arg2 string) (arg3 string)) + (cond + ((string-get-arg!! *string-tmp-str* arg1) + (cond + ((or (string= *string-tmp-str* arg2) (string= *string-tmp-str* arg3)) + (set! (-> arg0 0) (string= *string-tmp-str* arg2)) + #t + ) + (else + #f + ) + ) + ) + (else + #f + ) + ) + ) + +(defun string-word-wrap ((arg0 string) (arg1 int)) + "Wrap lines to specified width." + (let ((v1-0 (-> arg0 data))) + (label cfg-1) + (let ((a2-0 0) + (a0-1 0) + ) + (b! #t cfg-6 :delay (nop!)) + (label cfg-2) + (b! (zero? (-> v1-0 a2-0)) cfg-11 :delay (nop!)) + (if (= (-> v1-0 a2-0) 32) + (set! a0-1 a2-0) + ) + (+! a2-0 1) + (label cfg-6) + (b! (< a2-0 arg1) cfg-2) + (if (zero? a0-1) + (set! a0-1 a2-0) + ) + (set! (-> v1-0 a0-1) (the-as uint 10)) + (&+! v1-0 (+ a0-1 1)) + ) + ) + (goto cfg-1) + (label cfg-11) + 0 + (none) + ) + +(kmemopen global "gstring-globals") + +(define *debug-draw-pauseable* #f) + +(define *stdcon0* (new 'global 'string #x4000 (the-as string #f))) + +(define *stdcon1* (new 'global 'string #x4000 (the-as string #f))) + +(define *null* (new 'global 'string 0 (the-as string #f))) + +(define *stdcon* *stdcon0*) + +(define *stdebug* *stdcon1*) + +(define *temp-string* (new 'global 'string 2048 (the-as string #f))) + +(kmemclose) diff --git a/goal_src/jakx/levels/city/common/trail-h.gc b/goal_src/jakx/levels/city/common/trail-h.gc index fa1fba3fdc..1d32135252 100644 --- a/goal_src/jakx/levels/city/common/trail-h.gc +++ b/goal_src/jakx/levels/city/common/trail-h.gc @@ -5,5 +5,201 @@ ;; name in dgo: trail-h ;; dgos: ENGINE, GAME +;; +++trail-node-flag +(defenum trail-node-flag + :type uint8 + :bitfield #t + (tnf0 0) ;; unused?? + (tnf1 1) + (tnf2 2) + ) +;; ---trail-node-flag + + +;; +++conn-flag +(defenum conn-flag + :type uint8 + :bitfield #t + (cf0 0) + (cf1 1) + (cf2 2) + (cf3 3) + (cf4 4) + (cf5 5) + (cf6 6) + ) +;; ---conn-flag + + +(declare-type trail-graph basic) + ;; DECOMP BEGINS +(deftype trail-node (structure) + ((next-id int16) + (prev-id int16) + (parent-id int16) + (x int16) + (y int16) + (z int16) + (first-conn uint16) + (cost-from-start uint16) + (cost-to-goal uint16) + (flags trail-node-flag) + (conn-count uint8) + ) + :pack-me + (:methods + (get-dist-score (_type_ vector) uint) + (debug-draw (_type_ int) symbol) + (get-position (_type_ vector) vector) + ) + ) + + +(deftype trail-visgroup (structure) + ((first-node uint16) + (node-count uint8) + (pad uint8) + ) + ) + + +(deftype trail-blocker (structure) + ((plane plane :inline) + (center vector :inline) + (radius-squared float :overlay-at (-> center data 3)) + ) + ) + + +(deftype trail-conn (structure) + ((head-id uint16) + (tail-id uint16) + (flags conn-flag) + (visgroup-id uint8) + (cost uint16) + ) + :pack-me + (:methods + (debug-draw (_type_ trail-graph int) none) + ) + ) + + +(deftype trail-conn-hash-cell (structure) + ((first-conn uint16) + (conn-count uint8) + (pov-count uint8) + (first-pov uint16) + ) + :pack-me + ) + + +(deftype trail-conn-search (structure) + ((best-conn-id int32) + (best-dist float) + (src-pos vector) + (conn-pos vector) + (debug-cells-searched int32) + (debug-conns-searched int32) + (bounds bounding-box4w :inline) + (cell-quads qword 2 :inline) + (conn-quads qword 7 :inline) + (cell-bits vector16ub 2 :inline :overlay-at cell-quads) + (conn-bits vector16ub 2 :inline :overlay-at conn-quads) + ) + ) + + +(deftype trail-conn-hash (basic) + ((cell-width meters) + (origin vector :inline) + (cell (inline-array trail-conn-hash-cell)) + (conn-ids (pointer uint16)) + ) + ) + + +(deftype trail-cached-search-info (structure) + ((goal-conn-id int16) + (orig-goal-pos vector :inline) + (conn-goal-pos vector :inline) + ) + ) + + +(deftype trail-cached-start-pov (structure) + ((last-updated time-frame) + (pov-can-see-start uint64) + (next-node-id int32) + (start-pos vector :inline) + ) + ) + + +(deftype trail-graph (basic) + ((mode uint8) + (search-id uint32) + (open-head-id int16) + (goal-conn-id int16) + (goal-node-id int16) + (over-under-thresh float) + (over-under-above-too-low float) + (over-under-below-too-high float) + (pov-node-count uint16) + (node-count uint16) + (conn-count uint16) + (blocker-count uint16) + (conn-mask uint8) + (node (inline-array trail-node)) + (conn (inline-array trail-conn)) + (blocker (inline-array trail-blocker)) + (conn-ids (pointer uint16)) + (visgroup (inline-array trail-conn-hash-cell)) + (visnode-ids (pointer uint16)) + (conn-hash trail-conn-hash) + (cell-pov-bit-arrays (pointer uint64)) + (pov-can-see-goal uint64) + (cached-start-pov trail-cached-start-pov :inline) + (orig-start-pos vector :inline) + (orig-goal-pos vector :inline) + (conn-start-pos vector :inline) + (conn-goal-pos vector :inline) + (open-quads qword 6 :inline) + (closed-quads qword 6 :inline) + (open-bits vector16ub 2 :inline :overlay-at open-quads) + (closed-bits vector16ub 2 :inline :overlay-at closed-quads) + ) + (:methods + (trail-graph-method-9 (_type_ int) int) + (trail-graph-method-10 (_type_ int) symbol) + (trail-graph-method-11 (_type_ int int) trail-node) + (trail-graph-method-12 (_type_ trail-node vector) symbol) + (trail-graph-method-13 (_type_ vector vector) symbol) + (debug-draw (_type_) symbol) + (trail-graph-method-15 (_type_ int) symbol) + (trail-graph-method-16 (_type_ int (pointer uint16) vector vector rgba float) symbol) + (trail-graph-method-17 (_type_ vector vector) int) + (trail-graph-method-18 (_type_ vector) int) + (trail-graph-method-19 (_type_) none) + (trail-graph-method-20 (_type_ uint vector) vector) + (trail-graph-method-21 (_type_ (pointer uint16) int (pointer int32) (pointer float)) int) + (trail-graph-method-22 (_type_ int int) symbol) + (trail-graph-method-23 (_type_) symbol) + (trail-graph-method-24 (_type_ uint vector int int) symbol) + (trail-graph-method-25 (_type_ int) int) + (trail-graph-method-26 (_type_) int) + (trail-graph-method-27 (_type_) int) + (trail-graph-method-28 (_type_ trail-conn-search int int) symbol) + (trail-graph-method-29 (_type_ vector vector trail-cached-search-info) int) + (trail-graph-method-30 (_type_) int) + (trail-graph-method-31 (_type_ int) none) + (trail-graph-method-32 (_type_) uint) + (trail-graph-method-33 (_type_ int) symbol) + ) + ) + + +(define *trail-graph* (the-as trail-graph #f)) diff --git a/goal_src/jakx/lib/project-lib.gp b/goal_src/jakx/lib/project-lib.gp new file mode 100644 index 0000000000..5e4dfb168b --- /dev/null +++ b/goal_src/jakx/lib/project-lib.gp @@ -0,0 +1,263 @@ +;;-*-Lisp-*- + +;; TODO extract most of this into a common lib that isn't so game dependent + +;;;;;;;;;;;;;;;;;;;;;;; +;; Build system macros +;;;;;;;;;;;;;;;;;;;;;;; + +(defun gc-file->o-file (filename) + "Get the name of the object file for the given GOAL (*.gc) source file." + (string-append "$OUT/obj/" (stem filename) ".o") + ) + +(defmacro goal-src (src-file &rest deps) + "Add a GOAL source file with the given dependencies" + `(let ((output-file ,(gc-file->o-file src-file))) + (set! *all-gc* (cons output-file *all-gc*)) + (defstep :in ,(string-append "goal_src/jakx/" src-file) + ;; use goal compiler + :tool 'goalc + ;; will output the obj file + :out (list output-file) + ;; dependencies are the obj files + :dep '(,@(apply gc-file->o-file deps)) + ) + ) + ) + +(defun make-src-sequence-elt (current previous prefix) + "Helper for goal-src-sequence" + `(let ((output-file ,(gc-file->o-file current))) + (set! *all-gc* (cons output-file *all-gc*)) + (defstep :in ,(string-append "goal_src/jakx/" prefix current) + :tool 'goalc + :out (list output-file) + :dep '(,(gc-file->o-file previous)) + ) + ) + ) + +(defun make-src-sequence-elt-jak1 (current previous prefix) + "Helper for goal-src-sequence" + `(let ((output-file ,(gc-file->o-file current))) + (set! *all-gc* (cons output-file *all-gc*)) + (defstep :in ,(string-append "goal_src/jak1/" prefix current) + :tool 'goalc + :out (list output-file) + :dep '(,(gc-file->o-file previous)) + ) + ) + ) + +;; TODO - deps should probably just treated as a proper list to refactor duplication +(defmacro goal-src-sequence (prefix &key (deps '()) &rest sequence) + "Add a sequence of GOAL files (each depending on the previous) in the given directory, + with all depending on the given deps." + (let* ((first-thing `(goal-src ,(string-append prefix (first sequence)) ,@deps)) + (result (cons first-thing '())) + (iter result)) + + (let ((prev (first sequence)) + (in-iter (rest sequence))) + + (while (not (null? in-iter)) + ;; (fmt #t "{} dep on {}\n" (first in-iter) prev) + (let* ((cur-src-file (first in-iter)) + ;; grotesque temp hack + (next (if (or (eq? "pc/pckernel-h.gc" cur-src-file) + (eq? "pc/pckernel-common.gc" cur-src-file) + (eq? "pc/debug/pc-debug-common.gc" cur-src-file)) + (make-src-sequence-elt-jak1 cur-src-file prev prefix) + (make-src-sequence-elt cur-src-file prev prefix)))) + (set-cdr! iter (cons next '())) + (set! iter (cdr iter)) + ) + + (set! prev (car in-iter)) + (set! in-iter (cdr in-iter)) + ) + ) + + `(begin ,@result) + ) + ) + +(defun cgo (output-name desc-file-name) + "Add a CGO with the given output name (in $OUT/iso) and input name (in goal_src/jakx/dgos)" + (let ((out-name (string-append "$OUT/iso/" output-name))) + (defstep :in (string-append "goal_src/jakx/dgos/" desc-file-name) + :tool 'dgo + :out `(,out-name) + ) + (set! *all-cgos* (cons out-name *all-cgos*)) + ) + ) + +(defun tpage-name (id) + "Get the name of the tpage obj file with the given id" + (fmt #f "tpage-{}.go" id) + ) + +(defmacro copy-texture (tpage-id) + "Copy a texture from the game, using the given tpage ID" + (let* ((path (string-append "$DECOMP/raw_obj/" (tpage-name tpage-id)))) + `(defstep :in ,path + :tool 'copy + :out '(,(string-append "$OUT/obj/" (tpage-name tpage-id)))))) + +(defmacro copy-textures (&rest ids) + `(begin + ,@(apply (lambda (x) `(copy-texture ,x)) ids) + ) + ) + +(defmacro copy-obj (name) + (let* ((path (string-append "$DECOMP/raw_obj/" name))) + `(defstep :in ,path + :tool 'copy + :out '(,(string-append "$OUT/obj/" name))))) + +(defmacro copy-objs (&rest gos) + `(begin + ,@(apply (lambda (x) `(copy-obj ,x)) gos) + ) + ) + +(defmacro group (name &rest stuff) + `(defstep :in "" + :tool 'group + :out '(,(string-append "GROUP:" name)) + :dep '(,@stuff)) + ) + +(defun group-list (name stuff) + (defstep :in "" + :tool 'group + :out `(,(string-append "GROUP:" name)) + :dep stuff) + ) + + +(defun copy-iso-file (name subdir ext) + (let* ((path (string-append "$ISO/" subdir name ext)) + (out-name (string-append "$OUT/iso/" name ext))) + (defstep :in path + :tool 'copy + :out `(,out-name)) + out-name)) + +(defmacro copy-strs (&rest strs) + `(begin ,@(apply (lambda (x) `(set! *all-str* (cons (copy-iso-file ,x "STR/" ".STR") *all-str*))) strs))) + +(defmacro copy-sbk-files (&rest files) + `(begin ,@(apply (lambda (x) `(set! *all-sbk* (cons (copy-iso-file ,x "SBK/" ".SBK") *all-sbk*))) files))) + +(defmacro copy-mus-files (&rest files) + `(begin ,@(apply (lambda (x) `(set! *all-mus* (cons (copy-iso-file ,x "MUS/" ".MUS") *all-mus*))) files))) + +(defmacro copy-vag-files (&rest files) + `(begin ,@(apply (lambda (x) `(set! *all-vag* (cons (copy-iso-file "VAGWAD" "VAG/" (string-append "." ,x)) *all-vag*))) files))) + +(defmacro copy-screen-files (&rest files) + `(begin ,@(apply (lambda (x) `(set! *all-screens* (cons (copy-iso-file "SCREEN1" "RES/" (string-append "." ,x)) *all-screens*))) files))) + +(defun reverse-list (list) + (let ((new-list '()) + (curr-elt list)) + (while (not (null? curr-elt)) + (set! new-list (cons (car curr-elt) new-list)) + (set! curr-elt (cdr curr-elt))) + new-list)) + +(defmacro cgo-file (dgo-file-name deps &key (bsp-file-name #f)) + ;; First read in the DGO file, it has pretty much everything we need + (let ((dgo-data (car (read-data-file (string-append "goal_src/jakx/dgos/" dgo-file-name))))) + ;; Get the name of the DGO + (let ((dgo-name (car dgo-data)) + (files (cadr dgo-data)) + (gsrc-seq-args '()) + (textures '()) + (objs '())) + ;; create the dgo step + (cgo dgo-name dgo-file-name) + ;; Now we iterate through the list of files, skipping ones we've already processed + ;; and creating steps for the ones that are new! + (while (not (null? files)) + (let ((file-name (car files))) + ;; Check to see if we've already handled this file + (when (not (car (hash-table-try-ref *file-entry-map* file-name))) + ;; Depending on the type of file, generate the appropriate steps + (cond + ((and (string-ends-with? file-name ".o") + (neq? file-name bsp-file-name) + ) + ;; build up a list of all gsrc files needing to be compiled + (let ((base-name (symbol->string (first (string-split file-name "."))))) + (cond + ;; hardcoded cases to grab from jak1... really dont want to copy-paste these all the time! + ((or (eq? base-name "pckernel-h") + (eq? base-name "pckernel-common") + (eq? base-name "pc-debug-common")) + (let ((old-path (get-gsrc-folder)) + (gsrc-path (begin (set-gsrc-folder! "goal_src/jak1") + (get-gsrc-path base-name)))) + (set! gsrc-seq-args (cons gsrc-path gsrc-seq-args)) + (set-gsrc-folder! old-path) + ) + ) + (#t + (let ((gsrc-path (get-gsrc-path base-name))) + (set! gsrc-seq-args (cons gsrc-path gsrc-seq-args))) + ) + )) + ) + ((string-starts-with? file-name "tpage-") + ;; copy textures + (let ((tpage-id (second (string-split (symbol->string (first (string-split file-name "."))) "-")))) + (set! textures (cons tpage-id textures)))) + ((or (string-ends-with? file-name ".go") + (eq? file-name bsp-file-name) + ) + ;; copy art files + (set! objs (cons file-name objs)))) + ;; Update the map so this file isn't processed again + (hash-table-set! *file-entry-map* file-name #f))) + (set! files (cdr files))) + ;; TODO - need an `append`!, reverse lists by re-cons'ing them for now + (set! gsrc-seq-args (reverse-list gsrc-seq-args)) + (set! textures (reverse-list textures)) + (set! objs (reverse-list objs)) + `(begin + ;; macros can't return nothing, so these macros assume they will be given a non-empty list + (when (not (null? '(,@gsrc-seq-args))) + (goal-src-sequence "" :deps ,(eval deps) ,@gsrc-seq-args)) + (when (not (null? '(,@textures))) + (copy-textures ,@textures)) + (when (not (null? '(,@objs))) + (copy-objs ,@objs))) + ) + )) + +(defun custom-level-cgo (output-name desc-file-name) + "Add a CGO with the given output name (in $OUT/iso) and input name (in custom_assets/jakx/levels/)" + (let ((out-name (string-append "$OUT/iso/" output-name))) + (defstep :in (string-append "custom_assets/jakx/levels/" desc-file-name) + :tool 'dgo + :out `(,out-name) + ) + (set! *all-cgos* (cons out-name *all-cgos*)) + ) + ) + +(defmacro build-custom-level (name &key (force-run #f) &key (gen-fr3 #t)) + (let* ((path (string-append "custom_assets/jakx/levels/" name "/" name ".jsonc"))) + `(defstep :in '(,path ,(symbol->string force-run) ,(symbol->string gen-fr3)) + :tool 'build-level3 + :out '(,(string-append "$OUT/obj/" name ".go"))))) + +(defmacro build-actor (name &key (gen-mesh #f) &key (force-run #f) &key (texture-bucket 0)) + (let* ((path (string-append "custom_assets/jakx/models/custom_levels/" name ".glb"))) + `(defstep :in '(,path ,(symbol->string gen-mesh) ,(symbol->string force-run) ,(if (integer? texture-bucket) (int->string texture-bucket) (symbol->string texture-bucket))) + :tool 'build-actor3 + :out '(,(string-append "$OUT/obj/" name "-ag.go"))))) \ No newline at end of file diff --git a/goalc/emitter/ObjectGenerator.cpp b/goalc/emitter/ObjectGenerator.cpp index b77f37f2ea..9f1ffc5142 100644 --- a/goalc/emitter/ObjectGenerator.cpp +++ b/goalc/emitter/ObjectGenerator.cpp @@ -496,6 +496,7 @@ void ObjectGenerator::emit_link_type_pointer(int seg, const TypeSystem* ts) { break; case GameVersion::Jak2: case GameVersion::Jak3: // jak3 opengoal uses same format as jak2 for code. + case GameVersion::JakX: // TODO JAK X - hopefully this is the same // the linker/intern_type functions do the +3. out.push_back(ts->get_type_method_count(rec.first) / 4); break; diff --git a/scripts/gsrc/build-decomp-plan.py b/scripts/gsrc/build-decomp-plan.py new file mode 100644 index 0000000000..1ecdaf3351 --- /dev/null +++ b/scripts/gsrc/build-decomp-plan.py @@ -0,0 +1,25 @@ +import json + +with open("./matching-functions.json") as f: + target_analysis = json.load(f) + +with open("../../goal_src/jakx/build/all_objs.json") as f: + target_build_order = json.load(f) + +# We want a list of files, in the build order, that either: +# - are header files (easy) +# - have matching code with jak3 (easy) + +plan = [] +for file_info in target_build_order: + file_name = file_info[0] + if file_name.endswith("-h") or ( + file_name in target_analysis and len(target_analysis[file_name]) > 0 + ): + if file_name in target_analysis and len(target_analysis[file_name]) > 0: + plan.append({"name": file_name, "matching": target_analysis[file_name]}) + else: + plan.append({"name": file_name, "matching": []}) + +with open("./decomp-plan.json", "w") as f: + json.dump(plan, f) diff --git a/scripts/gsrc/copy-common-naming.py b/scripts/gsrc/copy-common-naming.py deleted file mode 100644 index 360e8f01b0..0000000000 --- a/scripts/gsrc/copy-common-naming.py +++ /dev/null @@ -1,191 +0,0 @@ -# The goal of this script is fairly straight forward -# Given a object file name, decompile it for both jak 2 and jak 3 WITHOUT variable casts -# Get all function definitions and compare the function bodies. -# - if the function bodies are the same, copy the variables from whichever game has them defined to the other -# - also, if it's a function and a docstring exists on one side but not the other, copy the docstring to the other side's all-types file - -import argparse -import glob -import json -import os - -from utils import decompile_file, is_file_in_game - - -parser = argparse.ArgumentParser("copy-common-naming") -parser.add_argument("--file", help="The name of the file", type=str) -parser.add_argument("--decompiler", help="The path to the decompiler", type=str) -parser.add_argument("--update-names-from-refs", help="The decomp config version", action='store_true') -args = parser.parse_args() - -def find_all_function_defs(lines): - store = {} - in_function_def = False - in_docstring = False - passed_potential_docstring = False - current_function_name = None - for line in lines: - if line.startswith("; .function") and "top-level" not in line: - current_function_name = line.split(".function")[1].strip() - store[current_function_name] = { - "docstring": [], - "definition": [], - } - passed_potential_docstring = False - in_docstring = False - continue - if current_function_name is not None and line.startswith(";;-*-OpenGOAL-Start-*-"): - in_function_def = True - continue - if current_function_name is not None and line.startswith(";;-*-OpenGOAL-End-*-"): - in_function_def = False - continue - if line.strip() == "": - continue - if in_function_def: - if not passed_potential_docstring and line.strip().startswith("\""): - in_docstring = True - if in_docstring: - store[current_function_name]["docstring"].append(line.strip()) - if line.strip().endswith("\""): - in_docstring = False - else: - store[current_function_name]["definition"].append(line) - if len(store[current_function_name]["definition"]) > 1 and line.startswith(" "): - passed_potential_docstring = True - return store - -def get_var_casts_for_game(game_name): - return json.load(open("./decompiler/config/{}/ntsc_v1/var_names.jsonc".format(game_name), "r")) - -def save_var_casts_for_game(game_name, casts): - with open("./decompiler/config/{}/ntsc_v1/var_names.jsonc".format(game_name), "w") as f: - json.dump(casts, f, indent=2) - -def get_all_types_for_game(game_name): - return open("./decompiler/config/{}/all-types.gc".format(game_name), "r").readlines() - -jak2_alltypes = get_all_types_for_game("jak2") -jak3_alltypes = get_all_types_for_game("jak3") - -file_stats = "" - -def update_file_var_name_casts(file_name, modify_alltypes): - global file_stats - # Check if the file exists in both games - if not is_file_in_game("jak3", file_name) or not is_file_in_game("jak2", file_name): - print("File not found in both games") - return - - # Decompile the file for both games - decompile_file(args.decompiler, "jak3/jak3_config.jsonc", "ntsc_v1", "[\"{}\"]".format(file_name), True) - decompile_file(args.decompiler, "jak2/jak2_config.jsonc", "ntsc_v1", "[\"{}\"]".format(file_name), True) - - # Go grab the contents of each file - jak2_file_contents = open("./decompiler_out/jak2/{}_ir2.asm".format(file_name), "r").readlines() - jak3_file_contents = open("./decompiler_out/jak3/{}_ir2.asm".format(file_name), "r").readlines() - - # Read in the function definitions for each file to find which ones match - - jak2_function_defs = find_all_function_defs(jak2_file_contents) - jak3_function_defs = find_all_function_defs(jak3_file_contents) - - # print(jak2_function_defs["vector-xz-cross!"]) - # print() - # print(jak3_function_defs["vector-xz-cross!"]) - - # Compare functions to see which ones are eligible - matching_func_names = [] - for func_name in jak2_function_defs: - if func_name in jak3_function_defs and jak2_function_defs[func_name]["definition"] == jak3_function_defs[func_name]["definition"]: - matching_func_names.append(func_name) - - # print(matching_func_names) - file_stats = file_stats + "Found {} matching functions in {}\n".format(len(matching_func_names), file_name) - - # Go grab the var casts for each game - jak2_var_casts = get_var_casts_for_game("jak2") - jak3_var_casts = get_var_casts_for_game("jak3") - - # For each eligible matching function, copy over the var casts - # The assumption is if it exists in jak 3 it's better (done more recently) so we use that - # else, use jak 2's if it exists - for func_name in matching_func_names: - if func_name in jak3_var_casts: - jak2_var_casts[func_name] = jak3_var_casts[func_name] - elif func_name in jak2_var_casts: - jak3_var_casts[func_name] = jak2_var_casts[func_name] - - save_var_casts_for_game("jak2", jak2_var_casts) - save_var_casts_for_game("jak3", jak3_var_casts) - - # Automatically copy docstrings for functions (methods are way to annoying to do with hack scripts now) - if modify_alltypes: - for func_name in matching_func_names: - if func_name.startswith("("): - continue - # handle the case where the jak 3 version has a docstring, but jak 2 does not - if len(jak3_function_defs[func_name]["docstring"]) != 0 and len(jak2_function_defs[func_name]["docstring"]) == 0: - for line_no, line in enumerate(jak2_alltypes): - line = jak2_alltypes[line_no] - if line.startswith("(define-extern {}".format(func_name)): - jak2_alltypes[line_no] = line.replace("(define-extern {} ".format(func_name), "(define-extern {}\n {}\n ".format(func_name, "\n ".join(jak3_function_defs[func_name]["docstring"]))) - break - # handle the case where jak 2 has a docstring but jak 3 does not - elif len(jak2_function_defs[func_name]["docstring"]) != 0 and len(jak3_function_defs[func_name]["docstring"]) == 0: - for line_no, line in enumerate(jak3_alltypes): - line = jak3_alltypes[line_no] - if line.startswith("(define-extern {}".format(func_name)): - jak3_alltypes[line_no] = line.replace("(define-extern {} ".format(func_name), "(define-extern {}\n {}\n ".format(func_name, "\n ".join(jak2_function_defs[func_name]["docstring"]))) - break - -if args.update_names_from_refs: - reference_test_files = glob.glob("./test/decompiler/reference/jak3/**/*_REF.gc", recursive=True) - for file_no, reference_test_file in enumerate(reference_test_files): - file_name = os.path.basename(reference_test_file).split("_REF.gc")[0] - print("({}/{}) Checking Var Name Casts for {}...".format(file_no+1, len(reference_test_files), file_name)) - update_file_var_name_casts(file_name, False) -else: - update_file_var_name_casts(args.file, True) - -print(file_stats) - -def get_type_docstrings_from_alltypes(lines): - store = {} - awaiting_next_docstring = True - current_type_name = None - for line in lines: - if line.startswith("(deftype"): - current_type_name = line.split("deftype ")[1].split("(")[0].strip() - awaiting_next_docstring = False - store[current_type_name] = [] - continue - if line.strip().startswith("(") and not line.strip().endswith("\""): - awaiting_next_docstring = True - continue - if not awaiting_next_docstring: - store[current_type_name].append(line.strip()) - return store - -jak2_type_docs = get_type_docstrings_from_alltypes(jak2_alltypes) -jak3_type_docs = get_type_docstrings_from_alltypes(jak3_alltypes) - -# If a docstring exists in jak3 but not in jak2, copy it back -new_jak2_alltypes = [] -for line_no, line in enumerate(jak2_alltypes): - line = jak2_alltypes[line_no] - new_jak2_alltypes.append(line) - if line.startswith("(deftype "): - current_type_name = line.split("deftype ")[1].split("(")[0].strip() - if current_type_name in jak3_type_docs and len(jak2_type_docs[current_type_name]) == 0: - for docstring_line in jak3_type_docs[current_type_name]: - new_jak2_alltypes.append(" " + docstring_line + "\n") -jak2_alltypes = new_jak2_alltypes - -# Save all-types -def get_all_types_for_game(game_name, lines): - with open("./decompiler/config/{}/all-types.gc".format(game_name), "w") as f: - f.writelines(lines) - -get_all_types_for_game("jak2", jak2_alltypes) -get_all_types_for_game("jak3", jak3_alltypes) diff --git a/scripts/gsrc/copy-identical-decomp.py b/scripts/gsrc/copy-identical-decomp.py new file mode 100644 index 0000000000..7740c8610f --- /dev/null +++ b/scripts/gsrc/copy-identical-decomp.py @@ -0,0 +1,26 @@ +import json + +with open("../../decompiler_out/jak3/_func_metadata.json") as f: + other_analysis = json.load(f) + +with open("../../decompiler_out/jakx/_func_metadata.json") as f: + target_analysis = json.load(f) + +matching_results = {} +total_func_count = 0 + +for file, functions in target_analysis.items(): + total_func_count = total_func_count + len(functions) + if file not in other_analysis: + continue + matching_results[file] = {} + other_funcs = other_analysis[file] + for func, hash in functions.items(): + if func in other_funcs and hash == other_funcs[func]: + print(f"{file}:{func} is the same") + matching_results[file][func] = True + +print(total_func_count) + +with open("./matching-functions.json", "w+") as f: + f.write(json.dumps(matching_results)) diff --git a/scripts/gsrc/iteratively-copy-decomp.py b/scripts/gsrc/iteratively-copy-decomp.py new file mode 100644 index 0000000000..61b2320dfd --- /dev/null +++ b/scripts/gsrc/iteratively-copy-decomp.py @@ -0,0 +1,121 @@ +import json +import os +import subprocess +from multiprocessing import process + +# TODO NOW after doing this, we will decomp the entire game, and copy over any files that are done / have no errors +# then make sure to enable offline tests + +processed_file_list = [] +if os.path.isfile("./process-file-list.json"): + with open("./process-file-list.json") as f: + processed_file_list = json.load(f) + +target_game = "jakx" +other_game = "jak3" + + +def copy_casts(file, function): + # anonymous_function_types.jsonc + if "anon-function" in function: + print("do the anonymous functions yourself") + # label_types.jsonc (if top level is the same) + # if "top-level-login" in function: + # with open( + # f"../../decompiler/config/{other_game}/ntsc_v1/label_types.jsonc" + # ) as f: + # other_casts = json.load(f) + # if file in other_casts: + # with open( + # f"../../decompiler/config/{target_game}/ntsc_v1/label_types.jsonc", "w" + # ) as f: + # target_casts = json.load(f) + # target_casts[file] = other_casts[file] + # json.dump(target_casts, f) + # stack_structures.jsonc + with open( + f"../../decompiler/config/{other_game}/ntsc_v1/stack_structures.jsonc" + ) as f: + other_casts = json.load(f) + if function in other_casts: + path = f"../../decompiler/config/{target_game}/ntsc_v1/stack_structures.jsonc" + with open(path) as f: + target_casts = json.load(f) + target_casts[function] = other_casts[function] + with open(path, "w") as f: + json.dump(target_casts, f, indent=2) + # type_casts.jsonc + with open(f"../../decompiler/config/{other_game}/ntsc_v1/type_casts.jsonc") as f: + other_casts = json.load(f) + if function in other_casts: + path = f"../../decompiler/config/{target_game}/ntsc_v1/type_casts.jsonc" + with open(path) as f: + target_casts = json.load(f) + target_casts[function] = other_casts[function] + with open(path, "w") as f: + json.dump(target_casts, f, indent=2) + # var_names.jsonc + with open(f"../../decompiler/config/{other_game}/ntsc_v1/var_names.jsonc") as f: + other_casts = json.load(f) + if function in other_casts: + path = f"../../decompiler/config/{target_game}/ntsc_v1/var_names.jsonc" + with open(path) as f: + target_casts = json.load(f) + target_casts[function] = other_casts[function] + with open(path, "w") as f: + json.dump(target_casts, f, indent=2) + + +def process_entry(file, matching_funcs): + print(f"Processing [{file}]") + # clean decomp folder + subprocess.run( + ["task", "decomp-clean"], # or your command + cwd="../../", # working directory + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + for func_name, is_matching in matching_funcs.items(): + # copy all casts for all related functions + print(f"- {func_name}") + copy_casts(file, func_name) + # then decompile the file + env = os.environ.copy() + env["FILE"] = file + subprocess.run( + ["task", "decomp-file"], # or your command + env=env, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + cwd="../../", # working directory + ) + # then the user can view it and compare + + +def main(): + with open("./matching-functions.json", "r") as f: + matching_func_info = json.load(f) + + for file, matching_funcs in matching_func_info.items(): + if len(matching_funcs) == 0: + continue + process_entry(file, matching_funcs) + while True: + process_entry(file, matching_funcs) + user_input = input("[n]ext / [r]erun: ").strip().lower() + if user_input == "n": + processed_file_list.append(file) + break + elif user_input == "r": + continue + else: + print("Invalid input. Use 'n' or 'r'.") + + +if __name__ == "__main__": + try: + main() + with open("./process-file-list.json") as f: + json.dump(processed_file_list, f) + except KeyboardInterrupt: + print("\nExiting.") diff --git a/scripts/gsrc/update-files-from-decomp-plan.py b/scripts/gsrc/update-files-from-decomp-plan.py new file mode 100644 index 0000000000..1457a30547 --- /dev/null +++ b/scripts/gsrc/update-files-from-decomp-plan.py @@ -0,0 +1,54 @@ +import json +import os +import subprocess +import shutil + +# assume this is available/importable +from utils import get_ref_path_from_filename + +BASE_DIR = "./" +OUT_DIR = os.path.join(BASE_DIR, "decompiler_out", "jakx") +REF_BASE = os.path.join(BASE_DIR, "test", "decompiler", "reference") + + +def run_decomp(name: str): + env = os.environ.copy() + env["FILE"] = name + env["GAME"] = "jakx" + + subprocess.run( + ["task", "decomp-file"], + env=env, + cwd=BASE_DIR, + check=True, + ) + + +def copy_to_ref(name: str): + src = os.path.join(OUT_DIR, f"{name}_disasm.gc") + + if not os.path.exists(src): + return # or raise + + ref_path = get_ref_path_from_filename("jakx", name, REF_BASE) + + # ensure directory exists + os.makedirs(os.path.dirname(ref_path), exist_ok=True) + + # enforce renamed filename + dst = os.path.join(os.path.dirname(ref_path), f"{name}_REF.gc") + + shutil.copyfile(src, dst) + + +with open("./scripts/gsrc/decomp-plan.json", "r") as f: + data = json.load(f) + +for entry in data: + name = entry.get("name") + done = entry.get("done") + + if done and name: + run_decomp(name) + copy_to_ref(name) + # exit(1) diff --git a/scripts/gsrc/utils.py b/scripts/gsrc/utils.py index 72a4f94f58..3c02ff9227 100644 --- a/scripts/gsrc/utils.py +++ b/scripts/gsrc/utils.py @@ -5,79 +5,96 @@ import subprocess jak1_files = None jak2_files = None jak3_files = None +jakx_files = None + +with open("./goal_src/jak1/build/all_objs.json", "r") as f: + jak1_files = json.load(f) +with open("./goal_src/jak2/build/all_objs.json", "r") as f: + jak2_files = json.load(f) +with open("./goal_src/jak3/build/all_objs.json", "r") as f: + jak3_files = json.load(f) +with open("./goal_src/jakx/build/all_objs.json", "r") as f: + jakx_files = json.load(f) -with open('./goal_src/jak1/build/all_objs.json', 'r') as f: - jak1_files = json.load(f) -with open('./goal_src/jak2/build/all_objs.json', 'r') as f: - jak2_files = json.load(f) -with open('./goal_src/jak3/build/all_objs.json', 'r') as f: - jak3_files = json.load(f) def get_file_list(game_name): - match game_name: - case "jak1": - return jak1_files - case "jak2": - return jak2_files - case "jak3": - return jak3_files + match game_name: + case "jak1": + return jak1_files + case "jak2": + return jak2_files + case "jak3": + return jak3_files + case "jakx": + return jakx_files + def is_file_in_game(game_name, file_name): - file_list = get_file_list(game_name) - for f in file_list: - if f[2] != 3 and f[2] != 5: - continue - if f[0] == file_name: - return True - return False + file_list = get_file_list(game_name) + for f in file_list: + if f[2] != 3 and f[2] != 5: + continue + if f[0] == file_name: + return True + return False + def get_gsrc_path_from_filename(game_name, file_name): - file_list = get_file_list(game_name) - src_path = "" - for f in file_list: - if f[2] != 3 and f[2] != 5: - continue - if f[0] == file_name: - src_path = f[4] - break - path = "./goal_src/{}/{}/{}.gc".format(game_name, src_path, file_name) - if not os.path.exists(path): - print("couldn't find {} in /goal_src/{}!".format(file_name, game_name)) - exit(1) - return path + file_list = get_file_list(game_name) + src_path = "" + for f in file_list: + if f[2] != 3 and f[2] != 5: + continue + if f[0] == file_name: + src_path = f[4] + break + path = "./goal_src/{}/{}/{}.gc".format(game_name, src_path, file_name) + if not os.path.exists(path): + print("couldn't find {} in /goal_src/{}!".format(file_name, game_name)) + exit(1) + return path + def get_alltypes_path_from_game(game_name): - return "./decompiler/config/{}/all-types.gc".format(game_name) + return "./decompiler/config/{}/all-types.gc".format(game_name) + def get_ref_path_from_filename(game_name, file_name, ref_folder): - file_list = get_file_list(game_name) - src_path = "" - for f in file_list: - if f[2] != 3 and f[2] != 5: - continue - if f[0] == file_name: - src_path = f[4] - break - if src_path == "": - print("couldn't determine ref path for {}:{}!".format(game_name, file_name)) - exit(1) - path = os.path.join(ref_folder, game_name, src_path, "{}_REF.gc".format(file_name)) - return path + file_list = get_file_list(game_name) + src_path = "" + for f in file_list: + if f[2] != 3 and f[2] != 5: + continue + if f[0] == file_name: + src_path = f[4] + break + if src_path == "": + print("couldn't determine ref path for {}:{}!".format(game_name, file_name)) + exit(1) + path = os.path.join(ref_folder, game_name, src_path, "{}_REF.gc".format(file_name)) + return path -def decompile_file(decompiler_path, decompiler_config, game_version, file_names, omit_var_casts=False): - decompiler_args = '{{"levels_extract": false, "process_art_groups": false, "decompile_code": true, "allowed_objects": {}}}'.format(file_names) - if omit_var_casts: - decompiler_args = '{{"levels_extract": false, "process_art_groups": false, "decompile_code": true, "ignore_var_name_casts": true, "allowed_objects": {}}}'.format(file_names) - subprocess.run( - [ - decompiler_path, - "./decompiler/config/{}".format(decompiler_config), - "./iso_data", - "./decompiler_out", - "--version", - game_version, - "--config-override", - decompiler_args, - ], - stdout = subprocess.DEVNULL -) + +def decompile_file( + decompiler_path, decompiler_config, game_version, file_names, omit_var_casts=False +): + decompiler_args = '{{"levels_extract": false, "process_art_groups": false, "decompile_code": true, "allowed_objects": {}}}'.format( + file_names + ) + if omit_var_casts: + decompiler_args = '{{"levels_extract": false, "process_art_groups": false, "decompile_code": true, "ignore_var_name_casts": true, "allowed_objects": {}}}'.format( + file_names + ) + subprocess.run( + [ + decompiler_path, + "./decompiler/config/{}".format(decompiler_config), + "./iso_data", + "./decompiler_out", + "--version", + game_version, + "--config-override", + decompiler_args, + ], + stdout=subprocess.DEVNULL, + ) diff --git a/test/decompiler/reference/jakx/decompiler-macros.gc b/test/decompiler/reference/jakx/decompiler-macros.gc new file mode 100644 index 0000000000..a913e937f9 --- /dev/null +++ b/test/decompiler/reference/jakx/decompiler-macros.gc @@ -0,0 +1,1766 @@ +;; This file should contain an implementation for all macros that the decompiler uses in its output. + +(defmacro init-vf0-vector () + "Initializes the VF0 vector which is a constant vector in the VU set to <0,0,0,1>" + `(.lvf vf0 (new 'static 'vector :x 0.0 :y 0.0 :z 0.0 :w 1.0)) + ) + +(defmacro new-stack-vector0 () + "Get a stack vector that's set to 0. + This is more efficient than (new 'stack 'vector) because + this doesn't call the constructor." + `(let ((vec (new 'stack-no-clear 'vector))) + (set! (-> vec quad) (the-as uint128 0)) + vec + ) + ) + +(defmacro set-vector! (v xv yv zv wv) + "Set all fields in a vector" + (with-gensyms (vec) + `(let ((,vec ,v)) + (set! (-> ,vec x) ,xv) + (set! (-> ,vec y) ,yv) + (set! (-> ,vec z) ,zv) + (set! (-> ,vec w) ,wv) + ,vec + )) + ) + +(defmacro new-stack-quaternion0 () + "Get a stack quaternion that's set to 0. + This is more efficient than (new 'stack 'quaternion) because + this doesn't call the constructor." + `(let ((q (new 'stack-no-clear 'quaternion))) + (set! (-> q quad) (the-as uint128 0)) + q + ) + ) + +(defmacro new-stack-matrix0 () + "Get a new matrix on the stack that's set to zero." + `(let ((mat (new 'stack-no-clear 'matrix))) + (set! (-> mat quad 0) (the-as uint128 0)) + (set! (-> mat quad 1) (the-as uint128 0)) + (set! (-> mat quad 2) (the-as uint128 0)) + (set! (-> mat quad 3) (the-as uint128 0)) + mat + ) + ) + + +(defmacro with-pp (&rest body) + "execute the body with pp bound to the current process register." + `(rlet ((pp :reg r13 :reset-here #t :type process)) + ,@body) + ) + +(defconstant PP (with-pp pp)) + +(defmacro current-time () + `(-> PP clock frame-counter) + ) + +(defmacro seconds-per-frame () + `(-> PP clock seconds-per-frame) + ) + +(defmacro make-u128 (upper lower) + `(rlet ((result :class i128) + (upper-xmm :class i128) + (lower-xmm :class i128)) + (.mov upper-xmm ,upper) + (.mov lower-xmm ,lower) + (.pcpyld result upper-xmm lower-xmm) + (the uint result) + ) + ) + +(defmacro handle->process (handle) + "Convert a handle to a process. If the process no longer exists, returns #f." + `(let ((the-handle (the-as handle ,handle))) + (if (-> the-handle process) ;; if we don't point to a process, kernel sets this to #f + (let ((proc (-> (-> the-handle process)))) + (if (= (-> the-handle pid) (-> proc pid)) ;; make sure it's the same process + proc + ) + ) + ) + ) + ) + +(defmacro ppointer->process (ppointer) + "convert a (pointer process) to a process." + ;; this uses the self field, which seems to always just get set to the object. + ;; confirmed in Jak 1 that using self here is useless, not sure... + `(let ((the-pp ,ppointer)) + (if the-pp (-> the-pp 0 self)) + ) + ) + +(defmacro defbehavior (name process-type bindings &rest body) + "define a new behavior. This is simply a function where self is bound to the process register, + which is assumed to have type process-type." + (if (and + (> (length body) 1) ;; more than one thing in function + (string? (first body)) ;; first thing is a string + ) + ;; then it's a docstring and we ignore it. + `(define ,name (lambda :name ,name :behavior ,process-type ,bindings ,@(cdr body))) + ;; otherwise don't ignore it. + `(define ,name (lambda :name ,name :behavior ,process-type ,bindings ,@body)) + ) + ) + +(defmacro process->ppointer (proc) + "safely get a (pointer process) from a process, returning #f if invalid." + `(let ((the-proc ,proc)) + (if the-proc (-> the-proc ppointer)) + ) + ) + +(defmacro ppointer->handle (pproc) + `(let ((the-process (the-as (pointer process) ,pproc))) + (new 'static 'handle :process the-process :pid (-> the-process 0 pid)) + ) + ) + +(defmacro process->handle (proc) + "convert a process to a handle. if proc is #f, returns a #f handle." + `(ppointer->handle (process->ppointer (the-as process ,proc))) + ) + +;; use a compile-time list to keep track of the type of an anonymous behavior. +(seval (define *defstate-type-stack* '())) +(desfun def-state-check-behavior (beh-form beh-type) + "check if code block is an anonymous behavior. needed for anonymous behaviors on defstate." + + (when (and (pair? beh-form) (eq? (first beh-form) 'behavior)) + (push! *defstate-type-stack* beh-type) + ) + ) +(defmacro clear-def-state-stack () + (set! *defstate-type-stack* '()) + `(none) + ) + +;; set when inside a defstate. +(seval (define *defstate-current-type* #f)) +(seval (define *defstate-current-state-name* #f)) + +;; *no-state* is just used for the compiler to know whether a handler was actually set or not +(defmacro defstate (state-name parents + &key (virtual #f) + &key (parent #f) + &key (event *no-state*) + &key (enter *no-state*) + &key (trans *no-state*) + &key (exit *no-state*) + &key (code *no-state*) + &key (post *no-state*) + &rest body + ) + "Define a new state!" + + (with-gensyms (new-state) + (let ((defstate-type (first parents)) + (docstring "")) + (when (and (> (length body) 1) (string? (first body))) + (set! docstring (first body))) + (when (not (null? *defstate-type-stack*)) + (fmt #t "*defstate-type-stack* leaked! An error probably happened in a previous defstate. stack is: {}" + *defstate-type-stack*) + ) + (set! *defstate-type-stack* '()) + (when virtual + (set! *defstate-current-type* defstate-type) + (set! *defstate-current-state-name* state-name) + ) + ;; check for default handlers + (let ((default-handlers (assoc defstate-type *default-state-handlers*))) + (when default-handlers + ;;(fmt #t "found default-handlers for {}: {}\n" defstate-type default-handlers) + ;; event + (set! default-handlers (cadr default-handlers)) + (when (and (eq? event '*no-state*) (car default-handlers)) + (set! event (car default-handlers))) + ;; enter + (set! default-handlers (cdr default-handlers)) + (when (and (eq? enter '*no-state*) (car default-handlers)) + (set! enter (car default-handlers))) + ;; trans + (set! default-handlers (cdr default-handlers)) + (when (and (eq? trans '*no-state*) (car default-handlers)) + (set! trans (car default-handlers))) + ;; exit + (set! default-handlers (cdr default-handlers)) + (when (and (eq? exit '*no-state*) (car default-handlers)) + (set! exit (car default-handlers))) + ;; code + (set! default-handlers (cdr default-handlers)) + (when (and (eq? code '*no-state*) (car default-handlers)) + (set! code (car default-handlers))) + ;; post + (set! default-handlers (cdr default-handlers)) + (when (and (eq? post '*no-state*) (car default-handlers)) + (set! post (car default-handlers))) + + (set! default-handlers (cdr default-handlers)) + ) + ) + (def-state-check-behavior event defstate-type) + (def-state-check-behavior enter defstate-type) + (def-state-check-behavior trans defstate-type) + (def-state-check-behavior exit defstate-type) + (def-state-check-behavior code defstate-type) + (def-state-check-behavior post defstate-type) + `(let ((,new-state (new 'static 'state + :name (quote ,state-name) + :next #f + :exit #f + :code #f + :trans #f + :post #f + :enter #f + :event #f + ) + )) + ;; the compiler will set the fields of the given state and define the symbol. + ;; This way it can check the individual function types, make sure they make sense, and create + ;; a state with the appropriate type. + ,(cond + ((and virtual parent) + `(begin + (inherit-state ,new-state ,(if (pair? parent) `(method-of-type ,(car parent) ,(cadr parent)) `(the state ,parent))) + (set! (-> ,new-state parent) ,(if (pair? parent) `(method-of-type ,(car parent) ,(cadr parent)) `(the state ,parent))) + (define-virtual-state-hook ,state-name ,defstate-type ,new-state ,docstring ,(eq? virtual 'override) :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) + ) + ) + (virtual + `(begin + (set! (-> ,new-state parent) #f) + (define-virtual-state-hook ,state-name ,defstate-type ,new-state ,docstring ,(eq? virtual 'override) :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) + ) + ) + (parent + `(begin + (inherit-state ,new-state (the state ,parent)) + (set! (-> ,new-state parent) (the state ,parent)) + (define-state-hook ,state-name ,defstate-type ,new-state ,docstring :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) + ) + ) + (#t + `(begin + (set! (-> ,new-state parent) #f) + (define-state-hook ,state-name ,defstate-type ,new-state ,docstring :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) + ) + ) + ) + ) + ) + ) + ) + + +(defmacro find-parent-state () + "Find the first different implementation of the current virtual state above this one." + (when (or (not *defstate-current-type*) + (not *defstate-current-state-name*)) + (error "use of find-parent-state outside of a defstate.") + ) + `(cast-to-method-type + ,*defstate-current-type* + ,*defstate-current-state-name* + (find-parent-method ,*defstate-current-type* (method-id-of-type ,*defstate-current-type* ,*defstate-current-state-name*)) + ) + ) + +(defmacro call-parent-state-handler (handler &key (type (function none)) &rest args) + "Call the parent handler for this state." + `(let ((handler (-> (find-parent-state) ,handler))) + (if handler ((the ,type handler) ,@args)) + ) + ) + +(defmacro call-parent-method (&rest args) + "Find the first different implementation of the current method in a parent type and call it with these arguments." + `((the (current-method-function-type) (find-parent-method (current-method-type) (current-method-id))) + ,@args) + ) + + +(defmacro behavior (bindings &rest body) + "Define an anonymous behavior for a process state. This may only be used inside a defstate!" + + (let ((behavior-type (first *defstate-type-stack*))) + (pop! *defstate-type-stack*) + `(lambda :behavior ,behavior-type ,bindings ,@body) + ) + ) + +;; set the default handler functions for a process's state handlers +(seval (define *default-state-handlers* '())) +(defmacro defstatehandler (proc + &key (event #f) + &key (enter #f) + &key (trans #f) + &key (exit #f) + &key (code #f) + &key (post #f)) + (let ((old (assoc proc *default-state-handlers*)) + (new (list proc (list event enter trans exit code post)))) + (if (not old) + (append!! *default-state-handlers* new) ;; add new set of default handlers + (dolist (hnd *default-state-handlers*) ;; replace old handlers with new ones + (when (eq? (car hnd) old) + (set-car! hnd new) + ) + ) + ) + ) + `(none) + ) + +(defmacro b! (pred destination &key (delay '()) &key (likely-delay '())) + "Branch!" + ;; evaluate the predicate + `(let ((should-branch ,pred)) + ;; normal delay slot: + ,delay + (when should-branch + ,likely-delay + (goto ,destination) + ) + ) + ) + +;; meters are stored as (usually) a float, scaled by 4096. +;; this gives you reasonable accuracy as an integer. +(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. + Returns float." + + ;; we don't have enough constant propagation for the compiler to figure this out. + (cond + ((float? x) + (* METER_LENGTH x) + ) + ((integer? x) + (* METER_LENGTH x) + ) + (#t + `(* METER_LENGTH ,x) + ) + ) + ) + +;; rotations are stored in 65,536ths of a full rotation. +;; like with meters, you get a reasonable accuracy as an integer. +;; additionally, it is a power-of-two, so wrapping rotations can be done +;; quickly by converting to an int, masking, and back to float +(defglobalconstant DEGREES_PER_ROT 65536.0) + +;; this was deg in GOAL +(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 + ) + ) + ) + ) + +;; times are stored in 300ths of a second. +;; this divides evenly into frames at both 50 and 60 fps. +;; typically these are stored as integers as more precision is not useful. +;; an unsigned 32-bit integer can store about 150 days +(defglobalconstant TICKS_PER_SECOND 300) ;; 5 t/frame @ 60fps, 6 t/frame @ 50fps + +;; this was usec in GOAL +(defmacro seconds (x) + "Convert number to seconds unit. + Returns uint." + (cond + ((integer? x) + (* TICKS_PER_SECOND x) + ) + ((float? x) + (* 1 (* 1.0 x TICKS_PER_SECOND)) + ) + (#t + `(the uint (* TICKS_PER_SECOND ,x)) + ) + ) + ) + +(defmacro fsec (x) + "Convert number to seconds unit. + Returns float." + (cond + ((or (integer? x) (float? x)) + (* 1.0 TICKS_PER_SECOND x) + ) + (#t + `(* 1.0 TICKS_PER_SECOND ,x) + ) + ) + ) + +(fake-asm .sync.l) +(fake-asm .sync.p) +(fake-asm .mfc0 dest src) +(fake-asm .mtc0 dest src) +(fake-asm .mtpc dest src) +(fake-asm .mfpc dest src) +(fake-asm .mtdab src) +(fake-asm .mtdabm src) + +(defmacro suspend () + '(none) + ) + +(defmacro empty-form () + '(none) + ) + +(defmacro .sync.l () + `(none)) + +(defmacro seek! (place target rate) + "Macro to use seek in-place. place is the base, and where the result is stored." + `(set! ,place (seek ,place ,target ,rate)) + ) + +(defmacro seekl! (place target rate) + "Macro to use seekl in-place. place is the base, and where the result is stored." + `(set! ,place (seekl ,place ,target ,rate)) + ) + +;; pad +(defmacro cpad-pressed (pad-idx) + `(-> *cpad-list* cpads ,pad-idx button0-rel 0) + ) + +(defmacro cpad-hold (pad-idx) + `(-> *cpad-list* cpads ,pad-idx button0-abs 0) + ) + +(defmacro cpad-pressed? (pad-idx &rest buttons) + `(logtest? (cpad-pressed ,pad-idx) (pad-buttons ,@buttons)) + ) + +(defmacro cpad-hold? (pad-idx &rest buttons) + `(logtest? (cpad-hold ,pad-idx) (pad-buttons ,@buttons)) + ) + +(defmacro mouse-pressed () + `(-> *mouse* button0-rel 0) + ) + +(defmacro mouse-hold () + `(-> *mouse* button0-abs 0) + ) + +(defmacro mouse-pressed? (&rest buttons) + `(logtest? (mouse-pressed) (mouse-buttons ,@buttons)) + ) + +(defmacro mouse-hold? (&rest buttons) + `(logtest? (mouse-hold) (mouse-buttons ,@buttons)) + ) + +(defmacro gs-reg-list (&rest reg-ids) + "Generate a giftag register descriptor list from reg-ids." + + (let ((reg-count (length reg-ids))) + (when (> (length reg-ids) 16) + (ferror "too many regs passed to gs-reg-list") + ) + (let ((list-to-splice '()) + (cur-lst reg-ids) + (i -1)) + + ;; this is questionable. + (while (and (not (null? cur-lst)) (< i 15)) + (push! list-to-splice (cons 'gif-reg-id (cons (car cur-lst) '()))) + (push! list-to-splice (string->symbol-format ":regs{}" (inc! i))) + (pop! cur-lst) + ) + + `(new 'static 'gif-tag-regs + ,@list-to-splice + ) + ) + #| ;; the opengoal compiler does not have enough constant propagation for this for now + (let ((i -1)) + + `(the-as gif-tag-regs (logior ,@(apply (lambda (x) + `(shl (the-as uint (gif-reg-id ,x)) ,(* 4 (inc! i))) + ) reg-ids) + )) + + )|# + ) + ) + +(defmacro dma-buffer-add-base-type (buf pkt dma-type &rest body) + "Base macro for adding stuff to a dma-buffer. Don't use this directly!" + + (with-gensyms (dma-buf) + `(let* ((,dma-buf ,buf) + (,pkt (the-as ,dma-type (-> ,dma-buf base)))) + + ,@body + + (set! (-> ,dma-buf base) (&+ (the-as pointer ,pkt) (size-of ,dma-type))) + + ) + ) + ) + +(defmacro dma-buffer-add-base-data (buf data-type forms) + "Base macro for adding data words to a dma-buffer. + Each form in forms is converted into data-type and added to the buffer. NO TYPE CHECKING is performed, so be careful!" + + (with-gensyms (dma-buf ptr) + `(let* ((,dma-buf ,buf) + (,ptr (the-as (pointer ,data-type) (-> ,dma-buf base)))) + + ,@(apply-i (lambda (x i) `(set! (-> ,ptr ,i) (the-as ,data-type ,x))) forms) + + (set! (-> ,dma-buf base) (&+ (the-as pointer ,ptr) (* ,(length forms) (size-of ,data-type)))) + + ) + ) + ) + + +(defmacro dma-buffer-add-cnt-vif2 (buf qwc vif0 vif1) + "Add a dma-packet to a dma-buffer. + The packet is made up of a 'cnt' DMAtag (transfer qwc qwords of data after the tag and continue from after that point) + and includes two vif-tags for vifcode, or something else if needed." + + (with-gensyms (pkt) + `(dma-buffer-add-base-type ,buf ,pkt dma-packet + + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc ,qwc)) + + (set! (-> ,pkt vif0) ,vif0) + (set! (-> ,pkt vif1) ,vif1) + + ) + ) + ) + +(defmacro dma-buffer-add-ref-vif2 (buf qwc addr vif0 vif1) + "Add a dma-packet to a dma-buffer. + The packet is made up of a 'cnt' DMAtag (transfer qwc qwords of data at addr and continue from after the tag) + and includes two vif-tags for vifcode, or something else if needed." + + (with-gensyms (pkt) + `(dma-buffer-add-base-type ,buf ,pkt dma-packet + + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id ref) :qwc ,qwc :addr (the-as int ,addr))) + + (set! (-> ,pkt vif0) ,vif0) + (set! (-> ,pkt vif1) ,vif1) + + ) + ) + ) + +(defmacro dma-buffer-add-ret (buf) + "Add a dma-packet to a dma-buffer. This packet simply does a DMA 'return' " + + (with-gensyms (pkt) + `(dma-buffer-add-base-type ,buf ,pkt dma-packet + + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id ret) :qwc 0)) + + (set! (-> ,pkt vif0) (new 'static 'vif-tag :cmd (vif-cmd nop))) + (set! (-> ,pkt vif1) (new 'static 'vif-tag :cmd (vif-cmd nop))) + + ) + ) + ) + +(defmacro dma-buffer-add-gif-tag (buf giftag gifregs) + "Add a giftag to a dma-buffer." + + (with-gensyms (pkt) + `(dma-buffer-add-base-type ,buf ,pkt gs-gif-tag + + (set! (-> ,pkt tag) ,giftag) + + (set! (-> ,pkt regs) ,gifregs) + + ) + ) + ) + +(defmacro dma-buffer-add-uint64 (buf &rest body) + "Add 64-bit words to a dma-buffer. See dma-buffer-add-base-data" + + `(dma-buffer-add-base-data ,buf uint64 ,body) + ) + +(defmacro dma-buffer-add-uint128 (buf &rest body) + "Add 128-bit words to a dma-buffer. See dma-buffer-add-base-data" + + `(dma-buffer-add-base-data ,buf uint128 ,body) + ) + +(defmacro dma-buffer-add-gs-set-flusha (buf &rest reg-list) + "Add a gif cnt dma packet to a dma-buffer for setting GS registers. Up to 16 can be set at once. + The packet runs the flusha command which waits for GIF transfer to end and VU1 microprogram to stop. + reg-list is a list of pairs where the car is the register name and the cadr is the value to be set for that register." + + (let ((reg-count (length reg-list)) + (qwc (+ (length reg-list) 1)) + (reg-names (apply first reg-list)) + (reg-datas (apply second reg-list)) + ) + `(begin + ;; dma tag + (dma-buffer-add-cnt-vif2 ,buf ,qwc + (new 'static 'vif-tag :cmd (vif-cmd flusha)) + (new 'static 'vif-tag :cmd (vif-cmd direct) :imm ,qwc) + ) + + ;; gif tag for editing gs regs + (dma-buffer-add-gif-tag ,buf (new 'static 'gif-tag64 :nloop 1 :eop 1 :nreg ,reg-count) + (gs-reg-list a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d) + ) + + ;; gs regs + (dma-buffer-add-uint64 ,buf + ,@(apply2 (lambda (x) x) (lambda (x) `(gs-reg64 ,x)) reg-datas reg-names) + ) + ) + ) + ) + +(defmacro dma-buffer-add-gs-set (buf &rest reg-list) + "Add a gif cnt dma packet to a dma-buffer for setting GS registers. Up to 16 can be set at once. + reg-list is a list of pairs where the car is the register name and the cadr is the value to be set for that register." + + (let ((reg-count (length reg-list)) + (qwc (+ (length reg-list) 1)) + (reg-names (apply first reg-list)) + (reg-datas (apply second reg-list)) + ) + `(begin + ;; dma tag + (dma-buffer-add-cnt-vif2 ,buf ,qwc + (new 'static 'vif-tag :cmd (vif-cmd nop)) + (new 'static 'vif-tag :cmd (vif-cmd direct) :imm ,qwc) + ) + + ;; gif tag for editing gs regs + (dma-buffer-add-gif-tag ,buf (new 'static 'gif-tag64 :nloop 1 :eop 1 :nreg ,reg-count) + (gs-reg-list a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d) + ) + + ;; gs regs + (dma-buffer-add-uint64 ,buf + ,@(apply2 (lambda (x) x) (lambda (x) `(gs-reg64 ,x)) reg-datas reg-names) + ) + ) + ) + ) + +(defmacro with-dma-bucket (bindings &rest body) + "Start a new dma-bucket in body that will be finished at the end. + The bindings are the dma-buffer, dma-bucket and bucket-id respectively." + + (let ((buf (first bindings)) + (bucket (second bindings)) + (bucket-id (third bindings)) + ) + + (with-gensyms (buf-start bucket-edge pkt) + `(let ((,buf-start (-> ,buf base))) + + ,@body + + ;; we end the chain with a next. The bucket system will patch the next chain to this, + ;; and then patch all the buckets togehter before sending the DMA. + (let ((,bucket-edge (the (pointer dma-tag) (-> ,buf base)))) + (let ((,pkt (the-as dma-packet (-> ,buf base)))) + + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> ,pkt vif0) (new 'static 'vif-tag :cmd (vif-cmd nop))) + (set! (-> ,pkt vif1) (new 'static 'vif-tag :cmd (vif-cmd nop))) + + (set! (-> ,buf base) (&+ (the-as pointer ,pkt) (size-of dma-packet))) + + ) + (dma-bucket-insert-tag ,bucket ,bucket-id + ,buf-start ;; the first thing in this chain, bucket will patch previous to this + ,bucket-edge ;; end of this chain (ptr to next tag) + ) + ) + ) + ) + + ) + ) + +(defmacro with-dma-buffer-add-bucket (bindings &key (bucket-group (-> (current-frame) bucket-group)) &rest body) + "Bind a dma-buffer to a variable and use it on a block to allow adding things to a new bucket. + usage: (with-dma-buffer-add-bucket ((buffer-name buffer) bucket-id) &rest body) + example: (with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf)) (bucket-id debug-no-zbuf)) ...)" + + `(let ((,(caar bindings) ,(cadar bindings))) + (with-dma-bucket (,(caar bindings) ,bucket-group ,(cadr bindings)) + ,@body + ) + ) + ) + +(defmacro def-mips2c (name type) + "Define a mips2c object (typically a function)." + `(begin + (define-extern ,name ,type) + (set! ,name (the-as ,type (__pc-get-mips2c ,(symbol->string name)))) + ) + ) + +(defmacro copy-and-set-field (original field-name field-value) + `(let ((temp-copy ,original)) + (set! (-> temp-copy ,field-name) ,field-value) + temp-copy + ) + ) + +(defmacro res-lump-data (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (time -1000000000.0)) + "Helper macro to get data from a res-lump without interpolation." + `(the-as ,type ((method-of-type res-lump get-property-data) + ,lump + ,name + 'interp + ,time + (the-as pointer #f) + ,tag-ptr + *res-static-buf* + ) + ) + ) + +(defmacro res-lump-data-exact (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (time 0.0)) + "Helper macro to get start of data from a res-lump." + `(the-as ,type ((method-of-type res-lump get-property-data) + ,lump + ,name + 'exact + ,time + (the-as pointer #f) + ,tag-ptr + *res-static-buf* + ) + ) + ) + +(defmacro res-lump-struct (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (time -1000000000.0)) + `(the-as ,type ((method-of-type res-lump get-property-struct) + ,lump + ,name + 'interp + ,time + (the-as structure #f) + ,tag-ptr + *res-static-buf* + ) + ) + ) + +(defmacro res-lump-struct-exact (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (time 0.0)) + `(the-as ,type ((method-of-type res-lump get-property-struct) + ,lump + ,name + 'exact + ,time + (the-as structure #f) + ,tag-ptr + *res-static-buf* + ) + ) + ) + +(defmacro res-lump-value (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (default (the-as uint128 0)) &key (time -1000000000.0)) + "Helper macro to get a value from a res-lump with no interpolation." + `(the-as ,type ((method-of-type res-lump get-property-value) + ,lump + ,name + 'interp + ,time + ,default + ,tag-ptr + *res-static-buf* + ) + ) + ) + +(defmacro res-lump-float (lump name &key (tag-ptr (the-as (pointer res-tag) #f)) &key (default 0.0) &key (time -1000000000.0)) + "Helper macro to get a float from a res-lump with no interpolation." + `((method-of-type res-lump get-property-value-float) + ,lump + ,name + 'interp + ,time + ,default + ,tag-ptr + *res-static-buf* + ) + ) + +;; cause the current process to change state +(defmacro go (next-state &rest args) + `(with-pp + (go-hook pp ,next-state ,@args) + ) + ) + +(defmacro go-virtual (state-name &key (proc self) &rest args) + "Change the current process to the virtual state of the given process." + `(go (method-of-object ,proc ,state-name) ,@args) + ) + +;; run the given function in a process right now. +;; will return to here when: +;; - you return +;; - you deactivate +;; - you go +;; - you throw to 'initialize +(defmacro run-now-in-process (proc func &rest args) + `((the (function _varargs_ object) run-function-in-process) + ,proc ,func ,@args + ) + ) + +;; sets the main thread of the given process to run the given thing. +;; this resets the main thread stack back to the top +(defmacro run-next-time-in-process (proc func &rest args) + `((the (function _varargs_ object) set-to-run) + (-> ,proc main-thread) ,func ,@args + ) + ) + +(defmacro send-event (proc msg &key (from (with-pp pp)) &rest params) + "Send an event to a process. This should be used over send-event-function" + + `(let ((event-data (new 'stack-no-clear 'event-message-block))) + (set! (-> event-data from) (process->ppointer ,from)) + (set! (-> event-data num-params) ,(length params)) + (set! (-> event-data message) ,msg) + ,@(apply-i (lambda (x i) `(set! (-> event-data param ,i) (the-as uint ,x))) params) + (send-event-function ,proc event-data) + ) + ) + +(defmacro setting-control-func! (func s &rest args) + (let ((argb #f) + (argi 0) + (argf 0.0) + (setting (cadr s))) + (cond + (#t + (set! argb (car args)) + (set! argf (cadr args)) + (set! argi (caddr args)) + ) + ) + `(,func *setting-control* (with-pp pp) ,s ,argb ,argf ,argi) + ) + ) + +(defmacro add-setting! (s &rest args) + `(setting-control-func! add-setting ,s ,@args) + ) +(defmacro set-setting! (s &rest args) + `(setting-control-func! set-setting ,s ,@args) + ) +(defmacro remove-setting! (s) + `(remove-setting *setting-control* (with-pp pp) ,s) + ) + +(defmacro static-sound-name (str) + "Convert a string constant to a static sound-name." + + ;; all this is done at compile-time so we can come up with 2 + ;; 64-bit constants to use + (when (> (string-length str) 16) + (error "static-sound-name got a string that is too long") + ) + (let ((lo-val 0) + (hi-val 0) + ) + (dotimes (i (string-length str)) + (if (>= i 8) + (+! hi-val (ash (string-ref str i) (* 8 (- i 8)))) + (+! lo-val (ash (string-ref str i) (* 8 i))) + ) + ) + `(new 'static 'sound-name :lo ,lo-val :hi ,hi-val) + ) + ) + +;; TODO change macro back once sound-group is figured out for jak 3 +(defmacro sound-play (name &key (id (new-sound-id)) + &key (vol 100.0) &key (pitch 0) &key (bend 0) + &key (group sfx) + &key (position #t)) + `(sound-play-by-name (static-sound-name ,name) ,id (the int (* (/ 1024.0 100.0) ,vol)) (the int (* 1524.0 ,pitch)) ,bend (sound-group) ,position)) + +(defmacro sound-vol (vol) + "convert to sound volume units" + (if (number? vol) + (* 1 (/ (* vol 1024) 100)) + `(the int (/ (* ,vol 1024) 100)) + ) + ) + +(defmacro static-sound-spec (name &key (num 1.0) &key (group 1) + &key (volume #f) + &key (pitch-mod 0) + &key (fo-min 0) &key (fo-max 0) + &key (fo-curve 0) + &key (mask ())) + (let ((snd-mask mask) + (snd-volume 100.0)) + (when (nonzero? fo-max) (cons! snd-mask 'fo-max)) + (when (nonzero? fo-min) (cons! snd-mask 'fo-min)) + (when (nonzero? fo-curve) (cons! snd-mask 'fo-curve)) + (when (nonzero? pitch-mod) (cons! snd-mask 'pitch)) + (when volume (cons! snd-mask 'volume) (set! snd-volume volume)) + `(new 'static 'sound-spec + :sound-name (static-sound-name ,name) + :num ,num + :group ,group + :volume (sound-vol ,snd-volume) + :pitch-mod ,pitch-mod + :fo-min ,fo-min + :fo-max ,fo-max + :fo-curve ,fo-curve + :mask (sound-mask ,@snd-mask) + )) + ) + +(defmacro time-elapsed? (time duration) + `(>= (- (current-time) ,time) ,duration) + ) + +(defmacro set-time! (time) + `(set! ,time (current-time)) + ) + +(defmacro suspend-for (time &rest body) + `(let ((time (current-time))) (until (time-elapsed? time ,time) ,@body (suspend)))) + +(defconstant *scratch-memory-top* (the pointer #x70004000)) +(defconstant DPROCESS_STACK_SIZE #x8000) + +(defconstant *kernel-dram-stack* (&+ *dram-stack* DPROCESS_STACK_SIZE)) + +(defmacro process-spawn-function (proc-type func &key (from *default-dead-pool*) &key (to *default-pool*) &key (name #f) &key (stack-size #x4000) &key (stack *scratch-memory-top*) &rest args) + "Start a new process that runs a function on its main thread. + Returns a pointer to the new process (or #f? on error)." + + (with-gensyms (new-proc) + `(let ((,new-proc (the-as ,proc-type (get-process ,from ,proc-type ,stack-size 1)))) + (when ,new-proc + ((method-of-type ,proc-type activate) ,new-proc ,to ,(if name name `(symbol->string (-> ,proc-type symbol))) ,stack) + (run-next-time-in-process ,new-proc ,func ,@args) + (the (pointer ,proc-type) (-> ,new-proc ppointer)) + ) + ) + ) + ) + +(defmacro process-spawn (proc-type &key (init #f) + &key (from *default-dead-pool*) + &key (to *default-pool*) + &key (name #f) + &key (stack-size #x4000) + &key (stack *scratch-memory-top*) + &key (unk 1) + &rest args) + "Start a new process and run an init function on it. + Returns a pointer to the new process, or #f (or is it 0?) if something goes wrong." + + (with-gensyms (new-proc) + `(let ((,new-proc (the-as ,proc-type (get-process ,from ,proc-type ,stack-size ,unk)))) + (when ,new-proc + ((method-of-type ,proc-type activate) ,new-proc ,to ,(if name name `(symbol->string ',proc-type)) ,stack) + (run-now-in-process ,new-proc ,(if init init (string->symbol (fmt #f "{}-init-by-other" proc-type))) ,@args) + (the (pointer ,proc-type) (-> ,new-proc ppointer)) + ) + ) + ) + ) + +;; look up the index of an art element in an art group. +(desfun art-elt-index (ag-name elt-name) + (if (number? elt-name) + elt-name + (let ((ag-info (hash-table-try-ref *art-info* (symbol->string ag-name)))) + (if (not (car ag-info)) + (error (symbol->string ag-name)) + (let ((elt-info (hash-table-try-ref (cdr ag-info) (symbol->string elt-name)))) + (if (not (car elt-info)) + (error (symbol->string ag-name)) + (cadr (cdr elt-info))) + ) + ) + ) + ) + ) + +(defmacro joint-node-index (jg-name name) + (let ((jg-info (hash-table-try-ref *jg-info* (symbol->string jg-name)))) + (if (not (car jg-info)) + -1 + (let ((joint-node (hash-table-try-ref (cdr jg-info) (if (integer? name) (int->string name) (symbol->string name))))) + (if (not (car joint-node)) + -1 + (cadr (cdr joint-node))) + ) + ) + ) + ) + +(defmacro joint-node (jg name) + `(-> self node-list data (joint-node-index ,jg ,name)) + ) + +(defmacro static-spherem (x y z r) + "creates a static vector using meters where the w component is used as sphere radius. for a 'real' sphere use static-bspherem." + `(new 'static 'vector :x (meters ,x) :y (meters ,y) :z (meters ,z) :w (meters ,r)) + ) + +(defmacro static-bspherem (x y z r) + `(new 'static 'sphere :x (meters ,x) :y (meters ,y) :z (meters ,z) :w (meters ,r)) + ) + +(defmacro static-cloth-params (ag-name args) + `(let ((parms (new 'static 'cloth-params))) + ,@(apply (lambda (x) (if (and (eq? (car x) 'mesh) (not (integer? (cadr x)))) + `(set! (-> parms ,(car x)) ,(art-elt-index ag-name (cadr x))) + `(set! (-> parms ,(car x)) ,(cadr x)) + )) args) + parms + ) + ) + +(defglobalconstant ART_GROUP_FILE_VERSION 8) + +(defmacro defskelgroup (name ag-name joint-geom joint-anim lods + &key (shadow 0) + &key bounds + &key (longest-edge 0.0) + &key (texture-level 0) + &key (sort 0) + &key (version ART_GROUP_FILE_VERSION) ;; do NOT use this! + &key (origin-joint-index 0) + &key (shadow-joint-index 0) + &key (light-index 0) + &key (global-effects 0) + &key (clothing ()) + ) + "Define a new static skeleton-group." + `(let ((skel (new 'static 'skeleton-group + :name ,(symbol->string name) + :extra #f + :info #f + :art-group-name ,(symbol->string ag-name) + :bounds ,bounds + :longest-edge ,longest-edge + :texture-level ,texture-level + :version ,version + :shadow ,(art-elt-index (string->symbol-format "{}-ag" ag-name) shadow) + :shadow-joint-index ,shadow-joint-index + :origin-joint-index ,origin-joint-index + :max-lod ,(- (length lods) 1) + :sort ,sort + :light-index ,light-index + :global-effects ,global-effects + :clothing #f + ))) + + ;; set cloth params array if present + (when ,(neq? clothing '()) + (set! (-> skel clothing) (new 'static 'boxed-array :type cloth-params :length 0 :allocated-length ,(length clothing))) + ,@(apply-i (lambda (x i) + `(set! (-> skel clothing ,i) (static-cloth-params ,(string->symbol-format "{}-ag" ag-name) ,x))) clothing) + (set! (-> skel clothing length) ,(length clothing)) + ) + + ;; set joint geometry and joint bones + (set! (-> skel jgeo) ,(art-elt-index (string->symbol-format "{}-ag" ag-name) joint-geom)) + (set! (-> skel janim) ,(art-elt-index (string->symbol-format "{}-ag" ag-name) joint-anim)) + + ;; set lods + ,@(apply-i (lambda (x i) + `(begin + (set! (-> skel mgeo ,i) ,(art-elt-index (string->symbol-format "{}-ag" ag-name) (car x))) + (set! (-> skel lod-dist ,i) ,(cadr x)) + ) + ) lods) + + ;; define skel group + (define ,name skel) + ;; add to level + (add-to-loading-level ,name) + ) + ) + +(defmacro get-art-by-name (this name type) + "Helper macro for casting the result of get-art-by-name-method. Generated by decompiler." + `(the-as ,type (get-art-by-name-method ,this ,name ,type)) + ) + +(defmacro vftoi15.xyzw (dst src) + "convert to 17.15 integer. This does the multiply while the number is still + a float. This will have issues for very large floats, but it seems like this + is how PCSX2 does it as well, so maybe it's right? + NOTE: this is the only version of the instruction used in Jak 1, so we + don't need to worry about masks." + + `(begin + (rlet ((temp :class vf)) + (set! temp 32768.0) + (.mul.x.vf temp ,src temp) + (.ftoi.vf ,dst temp) + ) + ) + ) + +(defmacro ja-group (&key (chan 0)) + "get the frame group for self. default channel is 0, the base channel. returns #f if no frame group." + `(if (> (-> self skel active-channels) ,chan) + (-> self skel root-channel ,chan frame-group)) + ) + +(defmacro ja-group? (group &key (chan 0)) + "is self in this frame group on this channel? default is channel 0, which is the base channel." + `(= (ja-group) ,group) + ) + +(defmacro focus-test? (pfoc &rest status) + `(logtest? (-> (the process-focusable ,pfoc) focus-status) (focus-status ,@status))) + +(defmacro ja (&key (chan 0) + &key (group! #f) + &key (num! #f) + &key (param0 #f) + &key (param1 #f) + &key (param2 #f) + &key (num-func #f) + &key (frame-num #f) + &key (frame-interp0 #f) + &key (frame-interp1 #f) + &key (dist #f) + &key (eval? #t) + ) + "set various joint anim parameters for self and eval them. + you can use this for playing animations! + chan = the channel to modify. defaults to 0 (base channel). this is usually what you want. + group! = when not #f, set this as the new frame-group. defaults to #f + num! = set the frame playback function. this is what determines what frame an animation is at. funcs below. + #f = no func will be set, and there wont be a frame eval. + num-func = sets the num-func field for the channel. this lets you change the function with eval'ing. + param0 = 1st parameter for the playback function. ONLY USE THESE WITH num-func !! + param1 = 2nd parameter for the playback function. ONLY USE THESE WITH num-func !! + param2 = 3rd parameter for the playback function. ONLY USE THESE WITH num-func !! + frame-num = set the frame-num field. + frame-interp0 = set the first value of the frame-interp array. + frame-interp1 = set the second value of the frame-interp array. + dist = set the dist field. + available num! functions: + - (+!) = advance anim. + - (-!) = reverse anim. + - (identity num) = play 'num' frame. + - (seek! target speed) = animate towards frame target at a speed. + speed is optional and defaults to 1.0 when not provided. + target is optional and defaults to the last frame of the animation. + if you want to set the speed, you therefore must also set the target. + target can be max (no quote), which is just the same as the default value. + - (loop! speed) = loop animation at a speed. default speed is 1.0 when not provided. + - (chan channel) = copy frame from another channel. + - min = the start of the animation. + - max = the end of the animation. + - zero = frame zero. + " + + (let* ((num-args (if (pair? num!) (cdr num!) '())) + (num! (if (pair? num!) (car num!) num!)) + (nf (cond + ((or (eq? num! 'identity) + (eq? num! 'min) + (eq? num! 'max) + (eq? num! 'zero)) + 'num-func-identity) + ((eq? num! 'none) 'num-func-none) + ((eq? num! '+!) 'num-func-+!) + ((eq? num! '-!) 'num-func--!) + ((eq? num! 'seek!) 'num-func-seek!) + ((eq? num! 'loop!) 'num-func-loop!) + ((eq? num! 'blend-in!) 'num-func-blend-in!) + ((eq? num! 'chan) 'num-func-chan) + )) + (p0 (if param0 param0 + (cond + ((eq? num! 'chan) `(the float ,(car num-args))) + ((eq? num! '+!) (if (null? num-args) 1.0 (car num-args))) + ((eq? num! '-!) (if (null? num-args) 1.0 (car num-args))) + ((eq? num! 'loop!) (if (null? num-args) 1.0 (if (eq? 'max (car num-args)) + (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + ) + (car num-args)))) + ((eq? num! 'seek!) (if (or (null? num-args) (eq? (car num-args) 'max)) + (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + ) + (car num-args))) + ))) + (p1 (if param1 param1 + (cond + ((eq? num! 'seek!) (if (or (null? num-args) (null? (cdr num-args))) 1.0 (cadr num-args))) + ))) + (p2 (if param2 param2 + (cond + ((eq? num! 'seek!) (if (or (null? num-args) (null? (cdr num-args))) 1.0 (cadr num-args))) + ))) + (frame-num (cond + ((eq? 'max frame-num) (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + )) + ((eq? 'zero frame-num) 0) + (#t frame-num))) + (frame-group (if (or p0 p1 frame-num (not nf)) group! #f)) + ) + `(let ((ja-ch (-> self skel root-channel ,chan))) + ,(if frame-interp0 `(set! (-> ja-ch frame-interp 0) ,frame-interp0) `(none)) + ,(if frame-interp1 `(set! (-> ja-ch frame-interp 1) ,frame-interp1) `(none)) + ,(if dist `(set! (-> ja-ch dist) ,dist) `(none)) + ,(if frame-group `(set! (-> ja-ch frame-group) (the art-joint-anim ,frame-group)) `(none)) + ,(if p0 `(set! (-> ja-ch param 0) ,p0) `(none)) + ,(if p1 `(set! (-> ja-ch param 1) ,p1) `(none)) + ,(if p2 `(set! (-> ja-ch param 2) ,p2) `(none)) + ,(if num-func `(set! (-> ja-ch num-func) ,num-func) `(none)) + ,(if frame-num `(set! (-> ja-ch frame-num) ,frame-num) `(none)) + ,(if nf + `(,(if eval? 'joint-control-channel-group-eval! 'joint-control-channel-group!) + ja-ch (the art-joint-anim ,group!) ,nf) + `(none)) + ,(cond + ((eq? num! 'min) `(set! (-> ja-ch frame-num) 0.0)) + ((eq? num! 'max) (if group! + `(set! (-> ja-ch frame-num) (the float (1- (-> (the art-joint-anim ,group!) frames num-frames)))) + `(set! (-> ja-ch frame-num) (the float (1- (-> ja-ch frame-group frames num-frames)))) + )) + ((and (eq? num! 'identity) (not (null? num-args))) `(set! (-> ja-ch frame-num) ,(car num-args))) + (#t `(none)) + ) + )) + ) + +(defmacro ja-no-eval (&key (chan 0) + &key (group! #f) + &key (num! #f) + &key (param0 #f) + &key (param1 #f) + &key (param2 #f) + &key (num-func #f) + &key (frame-num #f) + &key (frame-interp0 #f) + &key (frame-interp1 #f) + &key (dist #f) + ) + `(ja :eval? #f :chan ,chan :group! ,group! :num! ,num! :param0 ,param0 :param1 ,param1 :param2 ,param2 :num-func ,num-func :frame-num ,frame-num :frame-interp0 ,frame-interp0 :frame-interp1 ,frame-interp1 :dist ,dist) + ) + +(defmacro script-eval (script &key (key (process->ppointer PP)) &key (proc PP) &key (vector (the-as vector #f))) + `(eval! (new 'stack 'script-context ,key ,proc ,vector) ,script)) + +(defmacro sp-item (launcher + &key (fade-after 0.0) + &key (falloff-to 0.0) + &key (flags ()) + &key (period 0) + &key (length 0) + &key (offset 0) + &key (hour-mask 0) + &key (binding 0) + ) + `(new 'static 'sparticle-group-item + :launcher ,launcher + :fade-after ,fade-after + :falloff-to ,falloff-to + :flags (sp-group-item-flag ,@flags) + :period ,period + :length ,length + :offset ,offset + :hour-mask ,hour-mask + :binding ,binding + ) + ) + +(defmacro defpartgroup (name &key id &key parts &key (duration 3000) &key (linger-duration 1500) &key (flags ()) &key bounds + &key (rotate (0.0 0.0 0.0)) &key (scale (1.0 1.0 1.0))) + "define a new part group. defines a constant with the name of the group with the ID as its value" + `(begin + ; (defconstant ,name ,id) + (set! (-> *part-group-id-table* ,id) + (new 'static 'sparticle-launch-group + :duration ,duration + :linger-duration ,linger-duration + :flags (sp-group-flag ,@flags) + :bounds ,bounds + :name ,(symbol->string name) + :length ,(length parts) + :launcher (new 'static 'inline-array sparticle-group-item ,(length parts) ,@parts) + :rotate-x ,(car rotate) + :rotate-y ,(cadr rotate) + :rotate-z ,(caddr rotate) + :scale-x ,(car scale) + :scale-y ,(cadr scale) + :scale-z ,(caddr scale) + ) + ) + ) + ) + +(desfun param-float? (p) + (or (float? p) (and (pair? p) (eq? 'meters (car p))) (and (pair? p) (eq? 'degrees (car p)))) + ) + +(desfun param-int? (p) + (or (integer? p) (and (pair? p) (eq? 'seconds (car p)))) + ) + +(desfun param-symbol? (p) + (and (pair? p) (eq? 'quote (car p))) + ) + +(seval (begin +(define *sparticle-fields* (make-string-hash-table)) +(doenum (name val 'sp-field-id) + (hash-table-set! + *sparticle-fields* + (if (string-starts-with? (symbol->string name) "spt-") + (string->symbol (string-substr (symbol->string name) 4 0)) + name) + (list + val name (member name '(spt-vel-x + spt-vel-y + spt-vel-z + spt-scalevel-x + spt-scalevel-y + spt-rotvel-x + spt-rotvel-y + spt-rotvel-z + spt-fade-r + spt-fade-g + spt-fade-b + spt-fade-a + spt-accel-x + spt-accel-y + spt-accel-z)) + ) + ) + ) +;; you cannot define these fields ever. +(define *sparticle-fields-banned* '(misc-fields-start + misc-fields-end + sprite-fields-start + sprite-fields-end + cpu-fields-start + cpu-fields-end + launch-fields-start + launch-fields-end + end + )) +)) + +;; the last field ID defined, to make sure that fields are defined in order. +(seval (define *last-field-id* -1)) + +(desfun process-init-spec (x) + (let* ((head (symbol->string (car x))) + (params (cdr x)) + (field-name (string->symbol (string-substr head 1 0))) + (field-lookup (hash-table-try-ref *sparticle-fields* field-name)) + (field (cdr field-lookup)) + (store? (member ':store params)) + (param-count (if store? (1- (length params)) (length params))) + ) + (when (not (car field-lookup)) + (fmt #t "unknown sparticle field {}\n" x)) + (when (neq? (string-ref head 0) #\:) + (fmt #t "invalid sparticle field {}\n" x)) + ; (when (member field-name *sparticle-fields-banned*) + ; (fmt #t "you cannot use sparticle field {}\n" field-name)) + (let ((field-id (car field)) + (field-enum-name (cadr field)) + (vel? (and #f (caddr field))) + (param0 (and (>= param-count 1) (first params))) + (param1 (and (>= param-count 2) (second params))) + (param2 (and (>= param-count 3) (third params)))) + (when (>= *last-field-id* field-id) + (fmt #t "field {} must come after field {}, not before\n" field-name (car (nth *last-field-id* *sparticle-fields*))) + ) + (set! *last-field-id* field-id) + (cond + ((eq? field-name 'flags) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :initial-value (sp-cpuinfo-flag ,@param0) :random-mult 1) + ) + ((eq? field-name 'texture) + (if (eq? (car param0) 'new) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :tex ,param0 :flags (sp-flag int)) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :tex ,(string->symbol-format "{}-{}" (car param0) (cadr param0)) :flags (sp-flag int)) + ) + ) + ((eq? field-name 'next-launcher) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :initial-value ,param0 :flags (sp-flag launcher)) + ) + ((eq? field-name 'sound) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :sound ,param0 :flags (sp-flag object)) + ) + ((and (= 2 param-count) (symbol? param0) (eq? param0 ':copy)) + (let* ((other-field-lookup (hash-table-try-ref *sparticle-fields* (cadr (member ':copy params)))) + (other-field (cdr other-field-lookup)) + (other-field-id (car other-field))) + (when (>= other-field-id field-id) + (fmt #t "warning copying to sparticle field {} from {} - you can only copy from fields before this one!\n" field-name (cadr other-field)) ) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :flags (sp-flag copy-from-other) + :initial-value ,(- other-field-id field-id) :random-mult 1) + ) + ) + ((and (= 2 param-count) (symbol? param0) (eq? param0 ':data)) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :flags (sp-flag object) + :object ,(cadr (member ':data params))) + ) + ((and (= 1 param-count) (param-symbol? param0)) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :flags (sp-flag symbol) + :sym ,param0) + ) + ((and (= 1 param-count) (param-float? param0)) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :flags (sp-flag ,(if store? 'float-store 'float)) + :initial-valuef ,(if vel? `(/ ,param0 60.0) param0) + :random-rangef 0.0 + :random-multf 1.0) + ) + ((and (= 2 param-count) (param-float? param0) (param-float? param1)) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :flags (sp-flag ,(if store? 'float-store 'float)) + :initial-valuef ,(if vel? `(/ ,param0 60.0) param0) + :random-rangef ,(if vel? `(/ ,param1 60.0) param1) + :random-multf 1.0) + ) + ((and (= 3 param-count) (param-float? param0) (param-float? param1) (param-float? param2)) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :flags (sp-flag ,(if store? 'float-store 'float)) + :initial-valuef ,(if vel? `(/ ,param0 60.0) param0) + :random-rangef ,param1 + :random-multf ,(if vel? `(/ ,param2 60.0) param2)) + ) + ((and (= 3 param-count) (param-float? param0) (param-int? param1) (param-float? param2)) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :flags (sp-flag float-int-rand) + :initial-valuef ,(if vel? `(/ ,param0 60.0) param0) + :random-range ,param1 + :random-multf ,(if vel? `(/ ,param2 60.0) param2)) + ) + ((and (= 1 param-count) (param-int? param0)) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :flags (sp-flag int) + :initial-value ,param0 + :random-range 0 + :random-mult 1) + ) + ((and (= 2 param-count) (param-int? param0) (param-int? param1)) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :flags (sp-flag int) + :initial-value ,param0 + :random-range ,param1 + :random-mult 1) + ) + ((and (= 3 param-count) (param-int? param0) (param-int? param1) (param-int? param2)) + `(new 'static 'sp-field-init-spec :field (sp-field-id ,field-enum-name) :flags (sp-flag int) + :initial-value ,param0 + :random-range ,param1 + :random-mult ,param2) + ) + (#t + `(new 'static 'sp-field-init-spec :field (sp-field-id spt-end)) + ) + ) + ) + ) + ) + +(defmacro defpart (id &key (init-specs ())) + "define a new sparticle-launcher" + (begin + (set! *last-field-id* -1) + `(set! (-> *part-id-table* ,id) + (new 'static 'sparticle-launcher + :init-specs (new 'static 'inline-array sp-field-init-spec ,(1+ (length init-specs)) + ,@(apply process-init-spec init-specs) + (new 'static 'sp-field-init-spec :field (sp-field-id spt-end)) + ))) + ) + ) + +(defmacro static-attack-info (&key (mask ()) args) + (let ((mask-actual mask)) + (dolist (it args) + (when (not (member (caar it) mask-actual)) + (cons! mask-actual (caar it)) + ) + ) + `(let ((atk (new 'static 'attack-info :mask (attack-mask ,@mask-actual)))) + ,@(apply (lambda (x) (if (or (eq? (car x) 'vector) + (eq? (car x) 'intersection) + (eq? (car x) 'attacker-velocity)) + `(vector-copy! (-> atk ,(car x)) ,(cadr x)) + `(set! (-> atk ,(car x)) ,(cadr x)) + )) args) + atk) + ) + ) + +(defmacro new-attack-id () + "generate a new attack-id" + `(1+! (-> *game-info* attack-id)) + ) + +;; inserted by the decompiler if a c->goal bool conversion can't be compacted into a single +;; expression. +(defmacro cmove-#f-zero (dest condition src) + `(if (zero? ,condition) + (set! ,dest #f) + (set! ,dest ,src) + ) + ) + +(defmacro cmove-#f-nonzero (dest condition src) + `(if (zero? ,condition) + (set! ,dest ,src) + (set! ,dest #f) + ) + ) + +(defmacro launch-particles (&key (system *sp-particle-system-2d*) + particle + origin + &key (launch-state (the-as sparticle-launch-state #f)) + &key (launch-control (the-as sparticle-launch-control #f)) + &key (rate 1.0) + &key (origin-is-matrix #f)) + (if origin-is-matrix + `(sp-launch-particles-var + ,system + ,particle + (the matrix ,origin) + ,launch-state + ,launch-control + ,rate #|(if (= (get-video-mode) 'custom) (/ (-> *display* time-factor) 5.0) ,rate)|#) + `(begin + (vector-copy! (-> *launch-matrix* trans) (the vector ,origin)) + (sp-launch-particles-var + ,system + ,particle + *launch-matrix* + ,launch-state + ,launch-control + ,rate #|(if (= (get-video-mode) 'custom) (/ (-> *display* time-factor) 5.0) ,rate)|#) + ) + ) + ) + +(defmacro current-frame () + `(-> *display* frames (-> *display* on-screen)) + ) + +(defmacro vftoi4.xyzw (dst src) + "convert to 28.4 integer. This does the multiply while the number is still + a float. This will have issues for very large floats, but it seems like this + is how PCSX2 does it as well, so maybe it's right? + NOTE: this is the only version of the instruction used in Jak 1, so we + don't need to worry about masks." + + `(begin + (rlet ((temp :class vf)) + (set! temp 16.0) + (.mul.x.vf temp ,src temp) + (.ftoi.vf ,dst temp) + ) + ) + ) + +(defmacro defmethod-mips2c (name method-id method-type) + "Define a mips2c method." + `(method-set! ,method-type ,method-id (__pc-get-mips2c ,name)) + ) + +(defconstant GIF_REGS_ALL_AD + (new 'static 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id a+d) + :regs2 (gif-reg-id a+d) + :regs3 (gif-reg-id a+d) + :regs4 (gif-reg-id a+d) + :regs5 (gif-reg-id a+d) + :regs6 (gif-reg-id a+d) + :regs7 (gif-reg-id a+d) + :regs8 (gif-reg-id a+d) + :regs9 (gif-reg-id a+d) + :regs10 (gif-reg-id a+d) + :regs11 (gif-reg-id a+d) + :regs12 (gif-reg-id a+d) + :regs13 (gif-reg-id a+d) + :regs14 (gif-reg-id a+d) + :regs15 (gif-reg-id a+d) + ) + ) + +(defmacro .movz (result value check original) + `(if (= ,check 0) + (set! ,result (the-as int ,value)) + (set! ,result (the-as int ,original)) + ) + ) + +(defmacro get-texture (name tpage) + `(lookup-texture-by-id ,(string->symbol-format "{}-{}" name tpage)) + ) + +(defmacro vitof12.xyzw (dst src) + "convert from a 20.12 integer. This does the multiply while the number is still + a float. This will have issues for very large floats, but it seems like this + is how PCSX2 does it as well, so maybe it's right? + NOTE: this is the only version of the instruction used in Jak 1, so we + don't need to worry about masks." + +`(begin + (rlet ((temp :class vf)) + (.itof.vf ,dst ,src) + (set! temp 0.000244140625) + (.mul.x.vf ,dst ,dst temp) + ) + ) +) + +(defmacro set-part-tracker-params (type group duration callback userdata target mat-joint subsample-num) + `(case ,type + ((part-tracker) + (set! (-> *part-tracker-params-default* group) ,group) + (set! (-> *part-tracker-params-default* duration) ,duration) + (set! (-> *part-tracker-params-default* callback) ,callback) + (set! (-> *part-tracker-params-default* userdata) ,userdata) + (set! (-> *part-tracker-params-default* target) ,target) + (set! (-> *part-tracker-params-default* mat-joint) ,mat-joint) + ) + (else + (set! (-> *part-tracker-subsampler-params-default* group) ,group) + (set! (-> *part-tracker-subsampler-params-default* duration) ,duration) + (set! (-> *part-tracker-subsampler-params-default* callback) ,callback) + (set! (-> *part-tracker-subsampler-params-default* userdata) ,userdata) + (set! (-> *part-tracker-subsampler-params-default* target) ,target) + (set! (-> *part-tracker-subsampler-params-default* mat-joint) ,mat-joint) + (set! (-> *part-tracker-subsampler-params-default* subsample-num) ,subsample-num) + ) + ) + ) + +(defmacro part-tracker-spawn (type &key (group #f) + &key (to #f) + &key (name #f) + &key (stack-size #x4000) + &key (stack *scratch-memory-top*) + &key (unk 0) + &key (duration (seconds 0)) + &key (callback #f) + &key (userdata (the uint #f)) + &key (target #f) + &key (mat-joint *launch-matrix*) + &key (subsample-num 1.0)) + "Specialized `process-spawn` macro for [[part-tracker]]s. + Returns a pointer to the new process, or #f (or is it 0?) if something goes wrong." + (with-gensyms (new-tracker) + `(let ((,new-tracker (the-as ,type (get-process *default-dead-pool* ,type ,stack-size ,unk)))) + (when ,new-tracker + ((method-of-type ,type activate) ,new-tracker ,to ,(if name name `(symbol->string (quote ,type))) ,stack) + (set-part-tracker-params ,type ,group ,duration ,callback ,userdata ,target ,mat-joint ,subsample-num) + (run-now-in-process ,new-tracker + (if (= ,type part-tracker) part-tracker-init part-tracker-subsampler-init) + (if (= ,type part-tracker) *part-tracker-params-default* *part-tracker-subsampler-params-default*)) + (the (pointer ,type) (-> ,new-tracker ppointer)) + ) + ) + ) + ) + +(defmacro .sll (result in sa) + `(set! ,result (sext32 (the-as int (shl (logand ,in #xffffffff) ,sa)))) + ) + +(defmacro vftoi12.xyzw (dst src) + "convert to 20.12 integer. This does the multiply while the number is still + a float. This will have issues for very large floats, but it seems like this + is how PCSX2 does it as well, so maybe it's right? + NOTE: this is the only version of the instruction used in Jak 1, so we + don't need to worry about masks." + `(begin + (rlet ((temp :class vf)) + (set! temp 4096.0) + (.mul.x.vf temp ,src temp) + (.ftoi.vf ,dst temp) + ) + ) + ) + +(defmacro vitof15.xyzw (dst src) + "convert from a 17.15 integer. This does the multiply while the number is still + a float. This will have issues for very large floats, but it seems like this + is how PCSX2 does it as well, so maybe it's right? + NOTE: this is the only version of the instruction used in Jak 1, so we + don't need to worry about masks." + +`(begin + (rlet ((temp :class vf)) + (.itof.vf ,dst ,src) + (set! temp 0.000030517578125) + (.mul.x.vf ,dst ,dst temp) + ) + ) +) + +(defmacro as-type (this type) + (with-gensyms (obj) + `(the ,type (let ((,obj ,this)) + (if (type? ,obj ,type) + ,obj + ) + ) + ) + ) + ) + +(defmacro square (x) + `(* ,x ,x) + ) + +(import "goal_src/jak3/engine/data/tpages.gc") +(import "goal_src/jak3/engine/data/textures.gc") \ No newline at end of file diff --git a/test/decompiler/reference/jakx/engine/ambient/ambient-h_REF.gc b/test/decompiler/reference/jakx/engine/ambient/ambient-h_REF.gc new file mode 100644 index 0000000000..b85a0a96a5 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/ambient/ambient-h_REF.gc @@ -0,0 +1,2204 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type talker-speech-class +(deftype talker-speech-class (structure) + "Contains metadata about a voice line or hint text being played/displayed. +In the talker state, there's a pos-state and neg-state. +Calling yes-play! adjusts the pos-state and no-play! adjusts the neg-state. +Playback is only allowed if the pos-state is less than or equal to pos +and neg-state is greater than or equal to neg. +" + ((name string) + (channel gui-channel) + (flags talker-flags) + (speech uint16) + (text-duration uint16) + (delay uint16) + (pos uint16) + (neg uint16) + (text-message text-id) + (on-close pair) + (camera string) + ) + :pack-me + (:methods + (should-play? (_type_) symbol) + (mark-played! (_type_) none) + (reset-state! (_type_) none) + (yes-play! (_type_ int) none) + (no-play! (_type_ int) none) + ) + ) + +;; definition for method 3 of type talker-speech-class +(defmethod inspect ((this talker-speech-class)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'talker-speech-class) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tchannel: ~D~%" (-> this channel)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tspeech: ~D~%" (-> this speech)) + (format #t "~1Ttext-duration: ~D~%" (-> this text-duration)) + (format #t "~1Tdelay: ~D~%" (-> this delay)) + (format #t "~1Tpos: ~D~%" (-> this pos)) + (format #t "~1Tneg: ~D~%" (-> this neg)) + (format #t "~1Ttext-message: ~D~%" (-> this text-message)) + (format #t "~1Ton-close: ~A~%" (-> this on-close)) + (format #t "~1Tcamera: ~A~%" (-> this camera)) + (label cfg-4) + this + ) + +;; definition of type talker +(deftype talker (process) + ((trans vector :inline) + (message talker-speech-class) + (total-time time-frame) + (total-off-time time-frame) + (start-time time-frame) + (state-time time-frame) + (voicebox handle) + (voice-id sound-id) + (message-id sound-id) + (region region) + (interp float) + (save? symbol) + (grab? symbol) + ) + (:state-methods + idle + active + exit + ) + (:methods + (draw-text (_type_) none) + ) + ) + +;; definition for method 3 of type talker +(defmethod inspect ((this talker)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Ttrans: ~`vector`P~%" (-> this stack)) + (format #t "~2Tmessage: #~%" (-> this message)) + (format #t "~2Ttotal-time: ~D~%" (-> this total-time)) + (format #t "~2Ttotal-off-time: ~D~%" (-> this total-off-time)) + (format #t "~2Tstart-time: ~D~%" (-> this start-time)) + (format #t "~2Tstate-time: ~D~%" (-> this state-time)) + (format #t "~2Tvoicebox: ~D~%" (-> this voicebox)) + (format #t "~2Tvoice-id: ~D~%" (-> this voice-id)) + (format #t "~2Tmessage-id: ~D~%" (-> this message-id)) + (format #t "~2Tregion: #~%" (-> this region)) + (format #t "~2Tinterp: ~f~%" (-> this interp)) + (format #t "~2Tsave?: ~A~%" (-> this save?)) + (format #t "~2Tgrab?: ~A~%" (-> this grab?)) + (label cfg-4) + this + ) + +;; definition for symbol *talker-speech*, type (inline-array talker-speech-class) +(define *talker-speech* (new 'static 'inline-array talker-speech-class 233 + (new 'static 'talker-speech-class :name "none") + (new 'static 'talker-speech-class + :name "intro01" + :channel (gui-channel notice) + :flags (talker-flags fade-in) + :speech #x1 + :text-duration (seconds 3.5) + :neg #x1 + :text-message (text-id text-id-341) + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "intro01e" + :channel (gui-channel notice) + :flags (talker-flags fade-in) + :speech #x2 + :text-duration (seconds 3.5) + :neg #x1 + :text-message (text-id text-id-342) + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "intro01j" + :channel (gui-channel notice) + :flags (talker-flags fade-in) + :speech #x3 + :text-duration (seconds 3.5) + :neg #x1 + :text-message (text-id text-id-344) + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "intro01k" + :channel (gui-channel notice) + :flags (talker-flags fade-in) + :speech #x4 + :text-duration (seconds 3.5) + :neg #x1 + :text-message (text-id text-id-343) + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "intro03" + :channel (gui-channel notice-low) + :speech #x5 + :text-duration (seconds 5) + :neg #x1 + :text-message (text-id text-id-522) + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "won1" + :channel (gui-channel alert) + :speech #x6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit101r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit102r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x8 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit103r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x9 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit104r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xa + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit105r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xb + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit106r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xc + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit107r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xd + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit108r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xe + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit109r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #xf + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit110r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x10 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit111r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x11 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit112r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x12 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit113r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x13 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit114r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x14 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit115r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x15 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit116r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x16 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit117r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x17 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit118r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x18 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit119r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x19 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit120r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit121r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit122r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit123r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit124r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit125r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x1f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit126r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x20 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit127r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x21 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit128r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x22 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit129r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x23 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit130r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x24 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit131r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x25 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit132r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x26 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit133r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x27 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit134r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x28 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit135r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x29 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit136r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit137r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit138r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit139r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit140r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit141r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x2f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit142r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x30 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit143r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x31 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit144r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x32 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit145r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x33 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit146r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x34 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit147r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x35 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit148r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x36 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit149r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x37 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit150r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x38 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit151r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x39 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit152r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit153r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit154r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit155r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit156r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit157r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x3f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit158r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x40 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit159r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x41 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit160r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x42 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit161r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x43 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit162r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x44 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit163r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x45 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit164r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x46 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit165r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x47 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit166r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x48 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit167r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x49 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit168r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit169r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit170r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit171r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit175r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit176r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x4f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit177r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x50 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit178r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x51 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit179r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x52 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit180r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x53 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit181r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x54 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit182r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x55 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit183r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x56 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit184r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x57 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit185r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x58 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit186r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x59 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit187r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit188r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit189r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit190r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit191r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit192r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x5f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit193r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x60 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit194r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x61 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit195r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x62 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit196r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x63 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit197r" + :channel (gui-channel daxter) + :flags (talker-flags play-only-once reduce-volume) + :speech #x64 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit198r" + :channel (gui-channel daxter) + :flags (talker-flags play-only-once reduce-volume) + :speech #x65 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit199r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x66 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit200r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x67 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keit201r" + :channel (gui-channel daxter) + :flags (talker-flags reduce-volume) + :speech #x68 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "train1" + :channel (gui-channel daxter) + :speech #x69 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "train2" + :channel (gui-channel daxter) + :speech #x6a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "award1" + :channel (gui-channel alert) + :speech #x6b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak011r" + :channel (gui-channel speech) + :speech #x6c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak012r" + :channel (gui-channel speech) + :speech #x6d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak020r" + :channel (gui-channel speech) + :speech #x6e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak021r" + :channel (gui-channel speech) + :speech #x6f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak022r" + :channel (gui-channel speech) + :speech #x70 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "miz003r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume) + :speech #x71 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb583" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x72 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb584" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x73 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec586" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x74 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb585" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x75 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb590" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x76 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec591" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x77 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb586" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x78 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec587" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x79 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb587" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec588" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb588" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec589" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec585" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb598" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x7f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb596" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x80 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec598" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x81 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb600" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x82 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb591" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x83 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec592" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x84 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec603" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x85 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb615" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x86 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec599" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x87 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb610" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x88 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec593" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x89 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec596" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb607" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec613" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb609" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb616" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb602" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x8f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb604" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x90 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec597" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x91 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb589" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x92 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec590" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x93 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec611" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x94 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb597" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x95 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb599" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x96 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb601" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x97 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb611" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x98 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec605" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x99 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb603" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9a + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb605" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9b + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb606" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9c + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec612" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9d + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb608" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9e + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb612" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #x9f + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb617" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa0 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb614" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa1 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec594" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa2 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec595" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa3 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec601" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa4 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec602" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa5 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec614" + :channel (gui-channel speech) + :flags (talker-flags play-only-once) + :speech #xa6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "dax012" + :channel (gui-channel daxter) + :flags (talker-flags play-only-once) + :speech #xa7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "dax013" + :channel (gui-channel daxter) + :flags (talker-flags play-only-once) + :speech #xa8 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "dax014" + :channel (gui-channel daxter) + :flags (talker-flags play-only-once) + :speech #xa9 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb011" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xaa + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb012" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xab + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb013" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xac + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb015" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xad + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb017" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xae + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb018" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xaf + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb019" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb0 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb020" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb1 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb021" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb2 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb022" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb3 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb023" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb4 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb024" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb5 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb025" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb026" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb027" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb8 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb028" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xb9 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb029" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xba + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb030" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xbb + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb031" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xbc + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb032" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xbd + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb033" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xbe + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb034" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xbf + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb035" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc0 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb036" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc1 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb037" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc2 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb038" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc3 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb039" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc4 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb040" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc5 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb041" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb042" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb043" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc8 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb044" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xc9 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb045" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xca + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb046" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xcb + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb047" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xcc + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb048" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xcd + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb049" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xce + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb050" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xcf + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb051" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd0 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb052" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd1 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb053" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd2 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb054" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd3 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb055" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd4 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb056" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd5 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb014" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb016" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb057" + :channel (gui-channel speech) + :flags (talker-flags long-timeout) + :speech #xd8 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "awardcar" + :channel (gui-channel alert) + :flags (talker-flags reduce-volume long-timeout) + :speech #xd9 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "raz140r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xda + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "klev115r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xdb + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "keir235r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xdc + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "tar104r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xdd + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "sig109r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xde + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "UR86101r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xdf + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "kaed109r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe0 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "rayn107r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe1 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "rat109r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe2 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak205r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe3 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "jak226r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe4 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "dax175r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe5 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "gtb273r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe6 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "pec327r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe7 + :neg #x1 + :on-close #f + :camera #f + ) + (new 'static 'talker-speech-class + :name "xim101r" + :channel (gui-channel speech) + :flags (talker-flags reduce-volume long-timeout) + :speech #xe8 + :neg #x1 + :on-close #f + :camera #f + ) + ) + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/anim/joint-h_REF.gc b/test/decompiler/reference/jakx/engine/anim/joint-h_REF.gc new file mode 100644 index 0000000000..1fff74e2f7 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/anim/joint-h_REF.gc @@ -0,0 +1,340 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type joint-control-channel +(deftype joint-control-channel (structure) + "A single animation channel that controls a number of joints. +Multiple channels are used to blend animations together." + ((parent joint-control) + (frame-group art-joint-anim) + (frame-num float) + (dist meters) + (num-func (function joint-control-channel float float float float)) + (param float 3) + (frame-interp float 2) + (inspector-amount uint8) + (command joint-control-command) + (group-sub-index int8) + (group-size int8) + (eval-time uint32) + ) + ) + +;; definition for method 3 of type joint-control-channel +(defmethod inspect ((this joint-control-channel)) + (when (not this) + (set! this this) + (goto cfg-23) + ) + (format #t "[~8x] ~A~%" this 'joint-control-channel) + (format #t "~1Tparent: ~A~%" (-> this parent)) + (format #t "~1Tframe-group: ~A~%" (-> this frame-group)) + (format #t "~1Tframe-num: ~f~%" (-> this frame-num)) + (format #t "~1Tdist: (meters ~m)~%" (-> this dist)) + (format #t "~1Tnum-func: ~A~%" (-> this num-func)) + (format #t "~1Tparam[3] @ #x~X~%" (-> this param)) + (dotimes (s5-0 3) + (format #t "~T [~D]~1Tparam: ~`float`P~%" s5-0 (-> this param s5-0)) + ) + (format #t "~1Tframe-interp[2] @ #x~X~%" (-> this frame-interp)) + (dotimes (s5-1 2) + (format #t "~T [~D]~1Tframe-interp: ~`float`P~%" s5-1 (-> this frame-interp s5-1)) + ) + (format #t "~1Tinspector-amount: ~D~%" (-> this inspector-amount)) + (let ((t9-11 format) + (a0-12 #t) + (a1-11 "~1Tcommand: #x~X : ~S~%") + (a2-11 (-> this command)) + (v1-10 (-> this command)) + ) + (t9-11 a0-12 a1-11 a2-11 (cond + ((= v1-10 (joint-control-command stack1)) + "stack1" + ) + ((= v1-10 (joint-control-command push)) + "push" + ) + ((= v1-10 (joint-control-command blend)) + "blend" + ) + ((= v1-10 (joint-control-command push1)) + "push1" + ) + ((= v1-10 (joint-control-command float)) + "float" + ) + ((= v1-10 (joint-control-command stack)) + "stack" + ) + (else + "*unknown*" + ) + ) + ) + ) + (format #t "~1Tgroup-sub-index: ~D~%" (-> this group-sub-index)) + (format #t "~1Tgroup-size: ~D~%" (-> this group-size)) + (format #t "~1Teval-time: ~D~%" (-> this eval-time)) + (label cfg-23) + this + ) + +;; definition of type top-anim-joint-control +(deftype top-anim-joint-control (basic) + ((process (pointer process-drawable)) + (interp-select uint64 2) + (base-anim basic) + (base-anim-speed float) + (base-anim-blend float) + (interp float) + (frame-group art-joint-anim) + (frame-group-push art-joint-anim) + (frame-num float) + (frame-targ art-joint-anim) + (frame-speed float) + (frame-blend float) + (frame-cur-blend float) + (frame-start float) + (frame-post-blend float) + (frame-post-end float) + (frame-push-time time-frame) + (frame-post-put-away basic) + (update-time time-frame) + ) + (:methods + (new (symbol type process-drawable) _type_) + (reset (_type_) none) + (update (_type_) none) + (get-channel (_type_ int) joint-control-channel) + (push-anim-to-targ (_type_ art-joint-anim float int int float float symbol) none) + ) + ) + +;; definition for method 3 of type top-anim-joint-control +(defmethod inspect ((this top-anim-joint-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tprocess: #x~X~%" (-> this process)) + (format #t "~1Tinterp-select[2] @ #x~X~%" (-> this interp-select)) + (format #t "~1Tbase-anim: ~A~%" (-> this base-anim)) + (format #t "~1Tbase-anim-speed: ~f~%" (-> this base-anim-speed)) + (format #t "~1Tbase-anim-blend: ~f~%" (-> this base-anim-blend)) + (format #t "~1Tinterp: ~f~%" (-> this interp)) + (format #t "~1Tframe-group: ~A~%" (-> this frame-group)) + (format #t "~1Tframe-group-push: ~A~%" (-> this frame-group-push)) + (format #t "~1Tframe-num: ~f~%" (-> this frame-num)) + (format #t "~1Tframe-targ: ~A~%" (-> this frame-targ)) + (format #t "~1Tframe-speed: ~f~%" (-> this frame-speed)) + (format #t "~1Tframe-blend: ~f~%" (-> this frame-blend)) + (format #t "~1Tframe-cur-blend: ~f~%" (-> this frame-cur-blend)) + (format #t "~1Tframe-start: ~f~%" (-> this frame-start)) + (format #t "~1Tframe-post-blend: ~f~%" (-> this frame-post-blend)) + (format #t "~1Tframe-post-end: ~f~%" (-> this frame-post-end)) + (format #t "~1Tframe-push-time: ~D~%" (-> this frame-push-time)) + (format #t "~1Tframe-post-put-away: ~A~%" (-> this frame-post-put-away)) + (format #t "~1Tupdate-time: ~D~%" (-> this update-time)) + (label cfg-4) + this + ) + +;; definition of type joint-control +(deftype joint-control (basic) + "Every [[process-drawable]] has a [[joint-control]] that handles all the animation channels." + ((status joint-control-status) + (allocated-length uint8) + (active-channels uint8) + (root-channel (inline-array joint-control-channel) :offset 16) + (blend-index uint8) + (active-frame-interp uint8) + (float-channels uint8) + (generate-frame-function (function joint-anim-frame int joint-control int)) + (prebind-function (function joint-anim-frame int joint-control int)) + (postbind-function (function draw-control cspace-array joint-control none)) + (effect effect-control) + (interp-select int64 2) + (top-anim top-anim-joint-control) + (override (array float)) + (channel joint-control-channel :inline :dynamic) + ) + (:methods + (new (symbol type int) _type_) + (current-cycle-distance (_type_) float) + (update-anim-data (_type_) none) + (debug-print-channels (_type_ symbol) int) + (joint-control-method-12 (_type_ int) joint-control-channel) + ) + ) + +;; definition for method 3 of type joint-control +(defmethod inspect ((this joint-control)) + (when (not this) + (set! this this) + (goto cfg-32) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tstatus: #x~X : (joint-control-status " (-> this status)) + (let ((s5-0 (-> this status))) + (if (= (logand s5-0 (joint-control-status blend-shape)) (joint-control-status blend-shape)) + (format #t "blend-shape ") + ) + (if (= (logand s5-0 (joint-control-status valid-spooled-frame)) (joint-control-status valid-spooled-frame)) + (format #t "valid-spooled-frame ") + ) + (if (= (logand s5-0 (joint-control-status no-joint-callbacks)) (joint-control-status no-joint-callbacks)) + (format #t "no-joint-callbacks ") + ) + (if (= (logand s5-0 (joint-control-status spooling-not-last-block)) + (joint-control-status spooling-not-last-block) + ) + (format #t "spooling-not-last-block ") + ) + (if (= (logand s5-0 (joint-control-status eye-anim)) (joint-control-status eye-anim)) + (format #t "eye-anim ") + ) + (if (= (logand s5-0 (joint-control-status math-when-off-screen)) (joint-control-status math-when-off-screen)) + (format #t "math-when-off-screen ") + ) + (if (= (logand s5-0 (joint-control-status sync-math)) (joint-control-status sync-math)) + (format #t "sync-math ") + ) + (if (= (logand s5-0 (joint-control-status eye-anim-valid)) (joint-control-status eye-anim-valid)) + (format #t "eye-anim-valid ") + ) + (if (= (logand s5-0 (joint-control-status blend-shape-valid)) (joint-control-status blend-shape-valid)) + (format #t "blend-shape-valid ") + ) + (if (= (logand s5-0 (joint-control-status force-math)) (joint-control-status force-math)) + (format #t "force-math ") + ) + (if (= (logand s5-0 (joint-control-status spooling)) (joint-control-status spooling)) + (format #t "spooling ") + ) + ) + (format #t ")~%") + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tactive-channels: ~D~%" (-> this active-channels)) + (format #t "~1Troot-channel: #x~X~%" (-> this root-channel)) + (format #t "~1Tblend-index: ~D~%" (-> this blend-index)) + (format #t "~1Tactive-frame-interp: ~D~%" (-> this active-frame-interp)) + (format #t "~1Tfloat-channels: ~D~%" (-> this float-channels)) + (format #t "~1Tgenerate-frame-function: ~A~%" (-> this generate-frame-function)) + (format #t "~1Tprebind-function: ~A~%" (-> this prebind-function)) + (format #t "~1Tpostbind-function: ~A~%" (-> this postbind-function)) + (format #t "~1Teffect: ~A~%" (-> this effect)) + (format #t "~1Tinterp-select[2] @ #x~X~%" (-> this interp-select)) + (dotimes (s5-1 2) + (format #t "~T [~D]~1Tinterp-select: ~D~%" s5-1 (-> this interp-select s5-1)) + ) + (format #t "~1Ttop-anim: ~A~%" (-> this top-anim)) + (format #t "~1Toverride: ~A~%" (-> this override)) + (format #t "~1Tchannel[0] @ #x~X~%" (-> this channel)) + (dotimes (s5-2 (the-as int (-> this active-channels))) + (format #t "~T [~D]~1Tchannel: ~`joint-control-channel`P~%" s5-2 (-> this channel s5-2)) + ) + (label cfg-32) + this + ) + +;; definition of type matrix-stack +(deftype matrix-stack (structure) + ((top matrix) + (data matrix 24 :inline) + ) + ) + +;; definition for method 3 of type matrix-stack +(defmethod inspect ((this matrix-stack)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'matrix-stack) + (format #t "~1Ttop: #~%" (-> this top)) + (format #t "~1Tdata[24] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type channel-upload-info +(deftype channel-upload-info (structure) + "Information about an upload of animation data to a single joint channel." + ((fixed joint-anim-compressed-fixed) + (fixed-qwc int32) + (frame joint-anim-compressed-frame) + (frame-qwc int32) + (amount float) + (interp float) + ) + :pack-me + ) + +;; definition for method 3 of type channel-upload-info +(defmethod inspect ((this channel-upload-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'channel-upload-info) + (format #t "~1Tfixed: #~%" (-> this fixed)) + (format #t "~1Tfixed-qwc: ~D~%" (-> this fixed-qwc)) + (format #t "~1Tframe: #~%" (-> this frame)) + (format #t "~1Tframe-qwc: ~D~%" (-> this frame-qwc)) + (format #t "~1Tamount: ~f~%" (-> this amount)) + (format #t "~1Tinterp: ~f~%" (-> this interp)) + (label cfg-4) + this + ) + +;; definition of type joint-work +(deftype joint-work (structure) + ((temp-mtx matrix :inline) + (joint-stack matrix-stack :inline) + (fix-jmp-table (function none) 16) + (frm-jmp-table (function none) 16) + (pair-jmp-table (function none) 16) + (uploads channel-upload-info 24 :inline) + (num-uploads int32) + (mtx-acc matrix 2 :inline) + (tq-acc transformq 100 :inline) + (jacp-hdr joint-anim-compressed-hdr :inline) + (fixed-data joint-anim-compressed-fixed :inline) + (frame-data joint-anim-compressed-frame 2 :inline) + (flatten-array float 576 :overlay-at mtx-acc) + (flattened vector 24 :inline :overlay-at mtx-acc) + ) + ) + +;; definition for method 3 of type joint-work +(defmethod inspect ((this joint-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'joint-work) + (format #t "~1Ttemp-mtx: #~%" (-> this temp-mtx)) + (format #t "~1Tjoint-stack: #~%" (-> this joint-stack)) + (format #t "~1Tfix-jmp-table[16] @ #x~X~%" (-> this fix-jmp-table)) + (format #t "~1Tfrm-jmp-table[16] @ #x~X~%" (-> this frm-jmp-table)) + (format #t "~1Tpair-jmp-table[16] @ #x~X~%" (-> this pair-jmp-table)) + (format #t "~1Tuploads[24] @ #x~X~%" (-> this uploads)) + (format #t "~1Tnum-uploads: ~D~%" (-> this num-uploads)) + (format #t "~1Tmtx-acc[2] @ #x~X~%" (-> this mtx-acc)) + (format #t "~1Ttq-acc[100] @ #x~X~%" (-> this tq-acc)) + (format #t "~1Tjacp-hdr: #~%" (-> this jacp-hdr)) + (format #t "~1Tfixed-data: #~%" (-> this fixed-data)) + (format #t "~1Tframe-data[2] @ #x~X~%" (-> this frame-data)) + (format #t "~1Tflatten-array[576] @ #x~X~%" (-> this mtx-acc)) + (format #t "~1Tflattened[24] @ #x~X~%" (-> this mtx-acc)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/anim/joint-mod-h_REF.gc b/test/decompiler/reference/jakx/engine/anim/joint-mod-h_REF.gc new file mode 100644 index 0000000000..253c40f62c --- /dev/null +++ b/test/decompiler/reference/jakx/engine/anim/joint-mod-h_REF.gc @@ -0,0 +1,993 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type joint-mod +(deftype joint-mod (basic) + "Utility to modify a joint transform from code, rather than just getting it from animation. +This is used to make jak look toward an enemy, for example." + ((mode joint-mod-mode) + (process process-drawable) + (joint cspace) + (target vector :inline) + (twist vector :inline) + (twist-max vector :inline) + (extra-twist degrees :overlay-at (-> twist data 2)) + (track-mode track-mode :overlay-at (-> twist data 3)) + (look-at-count uint16 :offset 46) + (twist-range-x meters :overlay-at (-> twist-max data 2)) + (twist-range-y meters :overlay-at (-> twist-max data 3)) + (twist-speed-x float) + (twist-speed-y float) + (trans vector :inline) + (smushy-old float :overlay-at (-> trans data 0)) + (smushy-off float :overlay-at (-> trans data 1)) + (smushyv float :overlay-at (-> trans data 2)) + (quat quaternion :inline) + (scale vector :inline) + (notice-time time-frame) + (flex-blend float) + (blend float) + (old-blend float) + (max-dist meters) + (ignore-angle degrees) + (up uint8) + (nose uint8) + (ear uint8) + (base-joint uint8) + (base-nose uint8) + (shutting-down? symbol) + (parented-scale? symbol) + ) + (:methods + (new (symbol type joint-mod-mode process-drawable int) _type_) + (mode-set! (_type_ joint-mod-mode) none) + (target-set! (_type_ vector) none) + (look-at! (_type_ vector symbol process) none) + (reset-blend! (_type_) _type_) + (twist-set! (_type_ float float float) vector) + (trs-set! (_type_ vector quaternion vector) none) + (shut-down (_type_) none) + ) + ) + +;; definition for method 3 of type joint-mod +(defmethod inspect ((this joint-mod)) + (when (not this) + (set! this this) + (goto cfg-18) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tmode: ~D~%" (-> this mode)) + (format #t "~1Tprocess: ~A~%" (-> this process)) + (format #t "~1Tjoint: #~%" (-> this joint)) + (format #t "~1Ttarget: ~`vector`P~%" (-> this target)) + (format #t "~1Ttwist: ~`vector`P~%" (-> this twist)) + (format #t "~1Ttwist-max: ~`vector`P~%" (-> this twist-max)) + (format #t "~1Textra-twist: (deg ~r)~%" (-> this twist z)) + (format #t "~1Ttrack-mode: #x~X : (track-mode " (-> this track-mode)) + (let ((s5-0 (-> this track-mode))) + (if (= (logand s5-0 (track-mode track-on)) (track-mode track-on)) + (format #t "track-on ") + ) + (if (= (logand s5-0 (track-mode no-rotate)) (track-mode no-rotate)) + (format #t "no-rotate ") + ) + (if (= (logand s5-0 (track-mode lock-on)) (track-mode lock-on)) + (format #t "lock-on ") + ) + (if (= (logand s5-0 (track-mode no-scale)) (track-mode no-scale)) + (format #t "no-scale ") + ) + (if (= (logand s5-0 (track-mode track-x)) (track-mode track-x)) + (format #t "track-x ") + ) + (if (= (logand s5-0 (track-mode track-y)) (track-mode track-y)) + (format #t "track-y ") + ) + (if (= (logand s5-0 (track-mode no-trans)) (track-mode no-trans)) + (format #t "no-trans ") + ) + ) + (format #t ")~%") + (format #t "~1Tlook-at-count: ~D~%" (-> this look-at-count)) + (format #t "~1Ttwist-range-x: (meters ~m)~%" (-> this twist-max z)) + (format #t "~1Ttwist-range-y: (meters ~m)~%" (-> this twist-max w)) + (format #t "~1Ttwist-speed-x: ~f~%" (-> this twist-speed-x)) + (format #t "~1Ttwist-speed-y: ~f~%" (-> this twist-speed-y)) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Tsmushy-old: ~f~%" (-> this trans x)) + (format #t "~1Tsmushy-off: ~f~%" (-> this trans y)) + (format #t "~1Tsmushyv: ~f~%" (-> this trans z)) + (format #t "~1Tquat: ~`quaternion`P~%" (-> this quat)) + (format #t "~1Tscale: ~`vector`P~%" (-> this scale)) + (format #t "~1Tnotice-time: ~D~%" (-> this notice-time)) + (format #t "~1Tflex-blend: ~f~%" (-> this flex-blend)) + (format #t "~1Tblend: ~f~%" (-> this blend)) + (format #t "~1Told-blend: ~f~%" (-> this old-blend)) + (format #t "~1Tmax-dist: (meters ~m)~%" (-> this max-dist)) + (format #t "~1Tignore-angle: (deg ~r)~%" (-> this ignore-angle)) + (format #t "~1Tup: ~D~%" (-> this up)) + (format #t "~1Tnose: ~D~%" (-> this nose)) + (format #t "~1Tear: ~D~%" (-> this ear)) + (format #t "~1Tbase-joint: ~D~%" (-> this base-joint)) + (format #t "~1Tbase-nose: ~D~%" (-> this base-nose)) + (format #t "~1Tshutting-down?: ~A~%" (-> this shutting-down?)) + (format #t "~1Tparented-scale?: ~A~%" (-> this parented-scale?)) + (label cfg-18) + this + ) + +;; definition of type try-to-look-at-info +(deftype try-to-look-at-info (basic) + ((who handle) + (horz float) + (vert float) + ) + ) + +;; definition for method 3 of type try-to-look-at-info +(defmethod inspect ((this try-to-look-at-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Twho: ~D~%" (-> this who)) + (format #t "~1Thorz: ~f~%" (-> this horz)) + (format #t "~1Tvert: ~f~%" (-> this vert)) + (label cfg-4) + this + ) + +;; definition (debug) for function joint-mod-debug-draw +;; WARN: Return type mismatch int vs none. +(defun-debug joint-mod-debug-draw ((arg0 joint-mod)) + (add-debug-matrix #t (bucket-id bucket785) (-> arg0 joint bone transform) (meters 2)) + 0 + (none) + ) + +;; definition for method 12 of type joint-mod +(defmethod reset-blend! ((this joint-mod)) + "Set the blend to 0." + (set! (-> this blend) 0.0) + this + ) + +;; definition of type joint-mod-spinner +(deftype joint-mod-spinner (basic) + "Control a joint by just spinning it around an axis." + ((spin-axis vector :inline) + (angle float) + (spin-rate float) + (enable symbol) + ) + (:methods + (new (symbol type process-drawable int vector float) _type_) + ) + ) + +;; definition for method 3 of type joint-mod-spinner +(defmethod inspect ((this joint-mod-spinner)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tspin-axis: #~%" (-> this spin-axis)) + (format #t "~1Tangle: ~f~%" (-> this angle)) + (format #t "~1Tspin-rate: ~f~%" (-> this spin-rate)) + (format #t "~1Tenable: ~A~%" (-> this enable)) + (label cfg-4) + this + ) + +;; definition for function joint-mod-spinner-callback +(defun joint-mod-spinner-callback ((arg0 cspace) (arg1 transformq)) + (let ((gp-0 (the-as joint-mod-spinner (-> arg0 param1)))) + (when (-> gp-0 enable) + (let ((f30-0 + (the float (sar (shl (the int (+ (-> gp-0 angle) (* (-> gp-0 spin-rate) (seconds-per-frame)))) 48) 48)) + ) + ) + (quaternion-vector-angle! (the-as quaternion (-> arg1 rot)) (-> gp-0 spin-axis) f30-0) + (set! (-> gp-0 angle) f30-0) + ) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (none) + ) + +;; definition for method 0 of type joint-mod-spinner +;; INFO: Used lq/sq +(defmethod new joint-mod-spinner ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 vector) (arg3 float)) + "Create and attach a joint-mod-spinner to a joint." + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 spin-axis quad) (-> arg2 quad)) + (set! (-> v0-0 spin-rate) arg3) + (set! (-> v0-0 enable) #t) + (set! (-> v0-0 angle) 0.0) + (let ((a0-3 (-> arg0 node-list data arg1))) + (set! (-> a0-3 param0) joint-mod-spinner-callback) + (set! (-> a0-3 param1) v0-0) + ) + v0-0 + ) + ) + +;; definition of type joint-mod-base +(deftype joint-mod-base (structure) + "Base type for most joint-mods" + ((flags joint-mod-base-flags) + (node-index int16) + (proc (pointer process-drawable)) + (callback (function cspace transformq none)) + ) + (:methods + (init (_type_ process-drawable uint joint-mod-base-flags) none) + (attach-callback (_type_) none) + (remove-callback (_type_) none) + ) + ) + +;; definition for method 3 of type joint-mod-base +(defmethod inspect ((this joint-mod-base)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'joint-mod-base) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnode-index: ~D~%" (-> this node-index)) + (format #t "~1Tproc: #x~X~%" (-> this proc)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (label cfg-4) + this + ) + +;; definition for method 10 of type joint-mod-base +;; WARN: Return type mismatch int vs none. +(defmethod attach-callback ((this joint-mod-base)) + "Take control of the specified joint by modifying the cspace callback." + (when (> (-> this node-index) 0) + (let ((a1-3 (-> this proc 0 node-list data (-> this node-index)))) + (set! (-> a1-3 param0) (-> this callback)) + (set! (-> a1-3 param1) (the-as basic this)) + ) + (logior! (-> this flags) (joint-mod-base-flags attached)) + ) + 0 + (none) + ) + +;; definition for method 11 of type joint-mod-base +;; WARN: Return type mismatch int vs none. +(defmethod remove-callback ((this joint-mod-base)) + "Remove this callback and set param0 to #f to use the default (animated joint)" + (if (> (-> this node-index) 0) + (set! (-> this proc 0 node-list data (-> this node-index) param0) #f) + ) + (logclear! (-> this flags) (joint-mod-base-flags attached)) + 0 + (none) + ) + +;; definition for method 9 of type joint-mod-base +;; WARN: Return type mismatch int vs none. +(defmethod init ((this joint-mod-base) (arg0 process-drawable) (arg1 uint) (arg2 joint-mod-base-flags)) + "Set up this joint-mod to modify the given joint of the given process. Will attach automatically if attached flag is set." + (set! (-> this flags) arg2) + (set! (-> this node-index) (the-as int arg1)) + (set! (-> this proc) (the-as (pointer process-drawable) (process->ppointer arg0))) + (if (logtest? arg2 (joint-mod-base-flags attached)) + (attach-callback this) + ) + 0 + (none) + ) + +;; definition of type joint-mod-rotate-local +(deftype joint-mod-rotate-local (joint-mod-base) + ((rotation quaternion :inline) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +;; definition for method 3 of type joint-mod-rotate-local +(defmethod inspect ((this joint-mod-rotate-local)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'joint-mod-rotate-local) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnode-index: ~D~%" (-> this node-index)) + (format #t "~1Tproc: #x~X~%" (-> this proc)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (format #t "~1Trotation: #~%" (-> this rotation)) + (label cfg-4) + this + ) + +;; definition for function joint-mod-rotate-local-callback +(defun joint-mod-rotate-local-callback ((arg0 cspace) (arg1 transformq)) + (let ((v1-0 (the-as joint-mod-rotate-local (-> arg0 param1)))) + (quaternion*! (the-as quaternion (-> arg1 rot)) (the-as quaternion (-> arg1 rot)) (-> v1-0 rotation)) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (none) + ) + +;; definition for method 9 of type joint-mod-rotate-local +(defmethod init ((this joint-mod-rotate-local) (arg0 process-drawable) (arg1 uint) (arg2 joint-mod-base-flags)) + "Set up this joint-mod to modify the given joint of the given process. Will attach automatically if attached flag is set." + (set! (-> this callback) joint-mod-rotate-local-callback) + (quaternion-identity! (-> this rotation)) + ((method-of-type joint-mod-base init) this arg0 arg1 arg2) + (none) + ) + +;; definition of type joint-mod-trans-rot-local +(deftype joint-mod-trans-rot-local (joint-mod-base) + ((trans vector :inline) + (rot quaternion :inline) + ) + ) + +;; definition for method 3 of type joint-mod-trans-rot-local +(defmethod inspect ((this joint-mod-trans-rot-local)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'joint-mod-trans-rot-local) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnode-index: ~D~%" (-> this node-index)) + (format #t "~1Tproc: #x~X~%" (-> this proc)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (format #t "~1Ttrans: #~%" (-> this trans)) + (format #t "~1Trot: #~%" (-> this rot)) + (label cfg-4) + this + ) + +;; definition for function joint-mod-trans-rot-local-callback +(defun joint-mod-trans-rot-local-callback ((arg0 cspace) (arg1 transformq)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 (the-as joint-mod-trans-rot-local (-> arg0 param1)))) + (let ((a2-0 (-> arg1 trans))) + (let ((a0-1 (-> arg1 trans)) + (a1-1 (-> v1-0 trans)) + ) + (.lvf vf4 (&-> a0-1 quad)) + (.lvf vf5 (&-> a1-1 quad)) + ) + (.mov.vf.w vf6 vf0) + (.add.vf.xyz vf6 vf4 vf5) + (.svf (&-> a2-0 quad) vf6) + ) + (quaternion*! (the-as quaternion (-> arg1 rot)) (the-as quaternion (-> arg1 rot)) (-> v1-0 rot)) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (none) + ) + ) + +;; definition for method 9 of type joint-mod-trans-rot-local +(defmethod init ((this joint-mod-trans-rot-local) (arg0 process-drawable) (arg1 uint) (arg2 joint-mod-base-flags)) + "Set up this joint-mod to modify the given joint of the given process. Will attach automatically if attached flag is set." + (set! (-> this callback) joint-mod-trans-rot-local-callback) + (vector-reset! (-> this trans)) + (quaternion-identity! (-> this rot)) + ((method-of-type joint-mod-base init) this arg0 arg1 arg2) + (none) + ) + +;; definition of type joint-mod-rotate-world +(deftype joint-mod-rotate-world (joint-mod-base) + "Add an additional rotation to a joint (right multiply)" + ((rotation quaternion :inline) + ) + ) + +;; definition for method 3 of type joint-mod-rotate-world +(defmethod inspect ((this joint-mod-rotate-world)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'joint-mod-rotate-world) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnode-index: ~D~%" (-> this node-index)) + (format #t "~1Tproc: #x~X~%" (-> this proc)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (format #t "~1Trotation: #~%" (-> this rotation)) + (label cfg-4) + this + ) + +;; definition for function vector<-cspace2! +(defun vector<-cspace2! ((output-vec vector) (input-cspace cspace)) + (rlet ((Q :class vf) + (vf0 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> (-> input-cspace bone) transform trans quad)) + (.div.vf Q vf0 vf2 :fsf #b11 :ftf #b11) + (.wait.vf) + (.mul.vf.xyz vf2 vf2 Q) + (.nop.vf) + (.nop.vf) + (.mov.vf.w vf2 vf0) + (.svf (&-> output-vec quad) vf2) + output-vec + ) + ) + +;; definition for function joint-mod-rotate-world-callback +;; INFO: Used lq/sq +;; WARN: Return type mismatch matrix vs none. +(defun joint-mod-rotate-world-callback ((bone-cspace cspace) (joint-transform transformq)) + (let ((s3-0 (the-as joint-mod-rotate-world (-> bone-cspace param1)))) + (cspace<-parented-transformq-joint! bone-cspace joint-transform) + (let ((s4-0 (vector<-cspace2! (new 'stack-no-clear 'vector) bone-cspace))) + (quaternion*! + (the-as quaternion (-> joint-transform rot)) + (the-as quaternion (-> joint-transform rot)) + (-> s3-0 rotation) + ) + (set! (-> joint-transform trans quad) (-> s4-0 quad)) + ) + ) + (cspace<-transformq! bone-cspace joint-transform) + (none) + ) + +;; definition for method 9 of type joint-mod-rotate-world +(defmethod init ((this joint-mod-rotate-world) (arg0 process-drawable) (arg1 uint) (arg2 joint-mod-base-flags)) + "Set up this joint-mod to modify the given joint of the given process. Will attach automatically if attached flag is set." + (set! (-> this callback) joint-mod-rotate-world-callback) + (quaternion-identity! (-> this rotation)) + ((method-of-type joint-mod-base init) this arg0 arg1 arg2) + (none) + ) + +;; definition of type joint-mod-set-local +(deftype joint-mod-set-local (joint-mod-base) + "Override the trans, quat, and scale of the joint transform. The component to override is selected by the flag." + ((transform transformq :inline) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +;; definition for method 3 of type joint-mod-set-local +(defmethod inspect ((this joint-mod-set-local)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'joint-mod-set-local) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnode-index: ~D~%" (-> this node-index)) + (format #t "~1Tproc: #x~X~%" (-> this proc)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (format #t "~1Ttransform: #~%" (-> this transform)) + (label cfg-4) + this + ) + +;; definition for function joint-mod-set-local-callback +;; INFO: Used lq/sq +(defun joint-mod-set-local-callback ((bone-cspace cspace) (joint-transform transformq)) + (let ((v1-0 (the-as joint-mod-set-local (-> bone-cspace param1)))) + (if (not (logtest? (-> v1-0 flags) (joint-mod-base-flags trans))) + (set! (-> v1-0 transform trans quad) (-> joint-transform trans quad)) + ) + (if (not (logtest? (-> v1-0 flags) (joint-mod-base-flags quat))) + (set! (-> v1-0 transform rot quad) (-> joint-transform rot quad)) + ) + (if (not (logtest? (-> v1-0 flags) (joint-mod-base-flags scale))) + (set! (-> v1-0 transform scale quad) (-> joint-transform scale quad)) + ) + (cspace<-parented-transformq-joint! bone-cspace (-> v1-0 transform)) + ) + (none) + ) + +;; definition for method 9 of type joint-mod-set-local +(defmethod init ((this joint-mod-set-local) (arg0 process-drawable) (arg1 uint) (arg2 joint-mod-base-flags)) + "Set up this joint-mod to modify the given joint of the given process. Will attach automatically if attached flag is set." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (set! (-> this callback) joint-mod-set-local-callback) + (.svf (&-> (-> this transform) trans quad) vf0) + (quaternion-identity! (the-as quaternion (-> this transform rot))) + (vector-identity! (-> this transform scale)) + ((method-of-type joint-mod-base init) this arg0 arg1 arg2) + (none) + ) + ) + +;; definition of type joint-mod-add-local +(deftype joint-mod-add-local (joint-mod-base) + "Add to the trans, rotate the quat, and multiply the scale of the joint transform. The components can be selected by the flag. +Unlike jak 2, this actually multiplies the scale, instead of adding." + ((transform transformq :inline) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +;; definition for method 3 of type joint-mod-add-local +(defmethod inspect ((this joint-mod-add-local)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'joint-mod-add-local) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnode-index: ~D~%" (-> this node-index)) + (format #t "~1Tproc: #x~X~%" (-> this proc)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (format #t "~1Ttransform: #~%" (-> this transform)) + (label cfg-4) + this + ) + +;; definition for function joint-mod-add-local-callback +(defun joint-mod-add-local-callback ((arg0 cspace) (arg1 transformq)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (the-as joint-mod-add-local (-> arg0 param1)))) + (when (logtest? (-> s4-0 flags) (joint-mod-base-flags trans)) + (let ((a1-1 (-> arg1 trans))) + (let ((v1-3 (-> arg1 trans)) + (a0-1 (-> s4-0 transform)) + ) + (.lvf vf4 (&-> v1-3 quad)) + (.lvf vf5 (&-> a0-1 trans quad)) + ) + (.mov.vf.w vf6 vf0) + (.add.vf.xyz vf6 vf4 vf5) + (.svf (&-> a1-1 quad) vf6) + ) + ) + (when (logtest? (-> s4-0 flags) (joint-mod-base-flags quat)) + (quaternion*! + (the-as quaternion (-> arg1 rot)) + (the-as quaternion (-> arg1 rot)) + (the-as quaternion (-> s4-0 transform rot)) + ) + (quaternion-normalize! (the-as quaternion (-> arg1 rot))) + ) + (if (logtest? (-> s4-0 flags) (joint-mod-base-flags scale)) + (vector*! (-> arg1 scale) (-> arg1 scale) (-> s4-0 transform scale)) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (none) + ) + ) + +;; definition for method 9 of type joint-mod-add-local +(defmethod init ((this joint-mod-add-local) (arg0 process-drawable) (arg1 uint) (arg2 joint-mod-base-flags)) + "Set up this joint-mod to modify the given joint of the given process. Will attach automatically if attached flag is set." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (set! (-> this callback) joint-mod-add-local-callback) + (.svf (&-> (-> this transform) trans quad) vf0) + (quaternion-identity! (the-as quaternion (-> this transform rot))) + (set-vector! (-> this transform scale) 1.0 1.0 1.0 1.0) + ((method-of-type joint-mod-base init) this arg0 arg1 arg2) + (none) + ) + ) + +;; definition of type joint-mod-set-world +(deftype joint-mod-set-world (joint-mod-base) + "Directly overwrite the _bone_ transform (ignoring the parent entirely). +This does not pay attention to the flags." + ((transform transformq :inline) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +;; definition for method 3 of type joint-mod-set-world +(defmethod inspect ((this joint-mod-set-world)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'joint-mod-set-world) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnode-index: ~D~%" (-> this node-index)) + (format #t "~1Tproc: #x~X~%" (-> this proc)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (format #t "~1Ttransform: #~%" (-> this transform)) + (label cfg-4) + this + ) + +;; definition for function joint-mod-set-world-callback +;; WARN: Return type mismatch matrix vs none. +(defun joint-mod-set-world-callback ((bone-cspace cspace) (joint-trasnform transformq)) + (let ((v1-0 (the-as joint-mod-set-local (-> bone-cspace param1)))) + (cspace<-transformq! bone-cspace (-> v1-0 transform)) + ) + (none) + ) + +;; definition for method 9 of type joint-mod-set-world +(defmethod init ((this joint-mod-set-world) (arg0 process-drawable) (arg1 uint) (arg2 joint-mod-base-flags)) + "Set up this joint-mod to modify the given joint of the given process. Will attach automatically if attached flag is set." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (set! (-> this callback) joint-mod-set-world-callback) + (.svf (&-> (-> this transform) trans quad) vf0) + (quaternion-identity! (the-as quaternion (-> this transform rot))) + (vector-identity! (-> this transform scale)) + ((method-of-type joint-mod-base init) this arg0 arg1 arg2) + (none) + ) + ) + +;; definition of type joint-mod-set-world-no-trans +(deftype joint-mod-set-world-no-trans (joint-mod-base) + "Set the rotation and scale of the _bone_ directly to the values from this transform. +The translation is kept from the result of the normal parented value." + ((transform transformq :inline) + ) + ) + +;; definition for method 3 of type joint-mod-set-world-no-trans +(defmethod inspect ((this joint-mod-set-world-no-trans)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'joint-mod-set-world-no-trans) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnode-index: ~D~%" (-> this node-index)) + (format #t "~1Tproc: #x~X~%" (-> this proc)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (format #t "~1Ttransform: #~%" (-> this transform)) + (label cfg-4) + this + ) + +;; definition for function joint-mod-set-world-no-trans-callback +;; INFO: Used lq/sq +;; WARN: Return type mismatch vector vs none. +(defun joint-mod-set-world-no-trans-callback ((bone-cspace cspace) (joint-transform transformq)) + (let ((s4-0 (the-as joint-mod-set-world-no-trans (-> bone-cspace param1))) + (gp-0 (new 'stack-no-clear 'matrix)) + ) + (cspace<-parented-transformq-joint! bone-cspace joint-transform) + (matrix<-transformq! gp-0 (-> s4-0 transform)) + (set! (-> bone-cspace bone transform rvec quad) (-> gp-0 rvec quad)) + (set! (-> bone-cspace bone transform uvec quad) (-> gp-0 uvec quad)) + (set! (-> bone-cspace bone transform fvec quad) (-> gp-0 fvec quad)) + ) + (none) + ) + +;; definition for method 9 of type joint-mod-set-world-no-trans +(defmethod init ((this joint-mod-set-world-no-trans) (arg0 process-drawable) (arg1 uint) (arg2 joint-mod-base-flags)) + "Set up this joint-mod to modify the given joint of the given process. Will attach automatically if attached flag is set." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (set! (-> this callback) joint-mod-set-world-no-trans-callback) + (.svf (&-> (-> this transform) trans quad) vf0) + (quaternion-identity! (the-as quaternion (-> this transform rot))) + (vector-identity! (-> this transform scale)) + ((method-of-type joint-mod-base init) this arg0 arg1 arg2) + (none) + ) + ) + +;; definition of type joint-mod-blend-local +(deftype joint-mod-blend-local (joint-mod-base) + "Blend the _joint_ transform between this transform and the animated one. +Then, apply the normal parented transform." + ((transform transformq :inline) + (blend-transform transformq :inline) + (blend float) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +;; definition for method 3 of type joint-mod-blend-local +(defmethod inspect ((this joint-mod-blend-local)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'joint-mod-blend-local) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnode-index: ~D~%" (-> this node-index)) + (format #t "~1Tproc: #x~X~%" (-> this proc)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (format #t "~1Ttransform: #~%" (-> this transform)) + (format #t "~1Tblend-transform: #~%" (-> this blend-transform)) + (format #t "~1Tblend: ~f~%" (-> this blend)) + (label cfg-4) + this + ) + +;; definition for function joint-mod-blend-local-callback +(defun joint-mod-blend-local-callback ((bone-cspace cspace) (joint-transform transformq)) + (let ((gp-0 (the-as joint-mod-blend-local (-> bone-cspace param1)))) + (vector-lerp! + (-> gp-0 blend-transform trans) + (-> joint-transform trans) + (-> gp-0 transform trans) + (-> gp-0 blend) + ) + (vector-lerp! + (-> gp-0 blend-transform scale) + (-> joint-transform scale) + (-> gp-0 transform scale) + (-> gp-0 blend) + ) + (quaternion-slerp! + (the-as quaternion (-> gp-0 blend-transform rot)) + (the-as quaternion (-> joint-transform rot)) + (the-as quaternion (-> gp-0 transform rot)) + (-> gp-0 blend) + ) + (cspace<-parented-transformq-joint! bone-cspace (-> gp-0 blend-transform)) + ) + (none) + ) + +;; definition for method 9 of type joint-mod-blend-local +(defmethod init ((this joint-mod-blend-local) (arg0 process-drawable) (arg1 uint) (arg2 joint-mod-base-flags)) + "Set up this joint-mod to modify the given joint of the given process. Will attach automatically if attached flag is set." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (set! (-> this callback) joint-mod-blend-local-callback) + (.svf (&-> (-> this transform) trans quad) vf0) + (quaternion-identity! (the-as quaternion (-> this transform rot))) + (vector-identity! (-> this transform scale)) + (set! (-> this blend) 0.0) + ((method-of-type joint-mod-base init) this arg0 arg1 arg2) + (none) + ) + ) + +;; definition of type joint-mod-blend-world +(deftype joint-mod-blend-world (joint-mod-base) + "Blend the _bone_ transform between this one and the animated one." + ((transform transformq :inline) + (blend-transform transformq :inline) + (blend float) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +;; definition for method 3 of type joint-mod-blend-world +(defmethod inspect ((this joint-mod-blend-world)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'joint-mod-blend-world) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnode-index: ~D~%" (-> this node-index)) + (format #t "~1Tproc: #x~X~%" (-> this proc)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (format #t "~1Ttransform: #~%" (-> this transform)) + (format #t "~1Tblend-transform: #~%" (-> this blend-transform)) + (format #t "~1Tblend: ~f~%" (-> this blend)) + (label cfg-4) + this + ) + +;; definition for function joint-mod-blend-world-callback +;; WARN: Return type mismatch matrix vs none. +(defun joint-mod-blend-world-callback ((bone-cspace cspace) (joint-transform transformq)) + (let ((gp-0 (the-as joint-mod-blend-world (-> bone-cspace param1)))) + (let ((f30-0 (if (logtest? (-> gp-0 flags) (joint-mod-base-flags trans)) + (-> gp-0 blend) + 0.0 + ) + ) + (f28-0 (if (logtest? (-> gp-0 flags) (joint-mod-base-flags quat)) + (-> gp-0 blend) + 0.0 + ) + ) + (f26-0 (if (logtest? (-> gp-0 flags) (joint-mod-base-flags scale)) + (-> gp-0 blend) + 0.0 + ) + ) + (s3-0 (new 'stack-no-clear 'joint-mod-blend-world-work)) + ) + (if (= (-> bone-cspace parent bone scale w) 0.0) + (matrix<-transformq! (-> s3-0 mat1) joint-transform) + (matrix<-parented-transformq! (-> s3-0 mat1) joint-transform (-> bone-cspace parent bone scale)) + ) + (matrix*! (-> s3-0 mat2) (-> s3-0 mat1) (-> bone-cspace parent bone transform)) + (set-vector! + (-> s3-0 vec) + (vector-length (-> s3-0 mat2 rvec)) + (vector-length (-> s3-0 mat2 uvec)) + (vector-length (-> s3-0 mat2 fvec)) + 1.0 + ) + (vector*! (-> gp-0 blend-transform scale) (-> s3-0 vec) (-> joint-transform scale)) + (vector-lerp! (-> gp-0 blend-transform trans) (-> s3-0 mat2 trans) (-> gp-0 transform trans) f30-0) + (vector-lerp! (-> gp-0 blend-transform scale) (-> gp-0 blend-transform scale) (-> gp-0 transform scale) f26-0) + (quaternion-slerp! + (the-as quaternion (-> gp-0 blend-transform rot)) + (matrix->quat (-> s3-0 mat2) (-> s3-0 quat)) + (the-as quaternion (-> gp-0 transform rot)) + f28-0 + ) + ) + (cspace<-transformq! bone-cspace (-> gp-0 blend-transform)) + ) + (none) + ) + +;; definition for method 9 of type joint-mod-blend-world +(defmethod init ((this joint-mod-blend-world) (arg0 process-drawable) (arg1 uint) (arg2 joint-mod-base-flags)) + "Set up this joint-mod to modify the given joint of the given process. Will attach automatically if attached flag is set." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (set! (-> this callback) joint-mod-blend-world-callback) + (.svf (&-> (-> this transform) trans quad) vf0) + (quaternion-identity! (the-as quaternion (-> this transform rot))) + (vector-identity! (-> this transform scale)) + (set! (-> this blend) 0.0) + ((method-of-type joint-mod-base init) this arg0 arg1 arg2) + (none) + ) + ) + +;; definition of type joint-mod-ik +(deftype joint-mod-ik (basic) + ((flags joint-mod-ik-flags) + (elbow-pole-vector-axis int8) + (elbow-rotation-axis int8) + (elbow-node int8) + (process process-drawable) + (callback (function joint-mod-ik matrix matrix vector object)) + (handle-pos vector :inline) + (hand-dist float) + (blend float) + ) + (:methods + (new (symbol type) _type_) + (joint-mod-ik-method-9 () none) + (joint-mod-ik-method-10 () none) + ) + ) + +;; definition for method 3 of type joint-mod-ik +(defmethod inspect ((this joint-mod-ik)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Telbow-pole-vector-axis: ~D~%" (-> this elbow-pole-vector-axis)) + (format #t "~1Telbow-rotation-axis: ~D~%" (-> this elbow-rotation-axis)) + (format #t "~1Telbow-node: ~D~%" (-> this elbow-node)) + (format #t "~1Tprocess: ~A~%" (-> this process)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (format #t "~1Thandle-pos: #~%" (-> this handle-pos)) + (format #t "~1Thand-dist: ~f~%" (-> this hand-dist)) + (format #t "~1Tblend: ~f~%" (-> this blend)) + (label cfg-4) + this + ) + +;; definition of type ik-limb-setup +(deftype ik-limb-setup (structure) + ((elbow-index int32) + (hand-dist float) + ) + ) + +;; definition for method 3 of type ik-limb-setup +(defmethod inspect ((this ik-limb-setup)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ik-limb-setup) + (format #t "~1Telbow-index: ~D~%" (-> this elbow-index)) + (format #t "~1Thand-dist: ~f~%" (-> this hand-dist)) + (label cfg-4) + this + ) + +;; definition of type joint-mod-polar-look-at +(deftype joint-mod-polar-look-at (basic) + ((flags joint-mod-polar-flags) + (ear int8) + (up int8) + (nose int8) + (polar-internal-tilt-max float) + (polar-internal-radius float) + (polar-external-tilt-max float) + (polar-external-radius float) + (upward-tilt float) + (downward-tilt float) + (forward-twist float) + (backward-twist float) + (target vector :inline) + (blend-duration time-frame) + (blend-start-time time-frame) + (blend-start-value float) + (blend-max float) + ) + (:methods + (initialize (_type_ process-drawable int) none) + (set-target! (_type_ vector) none) + (set-both-targets! (_type_ joint-mod-polar-look-at vector) none) + (blend-on! (_type_ time-frame float symbol) none) + (blend-to-off! (_type_ time-frame symbol) none) + (get-start-blend! (_type_) float) + ) + ) + +;; definition for method 3 of type joint-mod-polar-look-at +(defmethod inspect ((this joint-mod-polar-look-at)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tear: ~D~%" (-> this ear)) + (format #t "~1Tup: ~D~%" (-> this up)) + (format #t "~1Tnose: ~D~%" (-> this nose)) + (format #t "~1Tpolar-internal-tilt-max: ~f~%" (-> this polar-internal-tilt-max)) + (format #t "~1Tpolar-internal-radius: ~f~%" (-> this polar-internal-radius)) + (format #t "~1Tpolar-external-tilt-max: ~f~%" (-> this polar-external-tilt-max)) + (format #t "~1Tpolar-external-radius: ~f~%" (-> this polar-external-radius)) + (format #t "~1Tupward-tilt: ~f~%" (-> this upward-tilt)) + (format #t "~1Tdownward-tilt: ~f~%" (-> this downward-tilt)) + (format #t "~1Tforward-twist: ~f~%" (-> this forward-twist)) + (format #t "~1Tbackward-twist: ~f~%" (-> this backward-twist)) + (format #t "~1Ttarget: #~%" (-> this target)) + (format #t "~1Tblend-duration: ~D~%" (-> this blend-duration)) + (format #t "~1Tblend-start-time: ~D~%" (-> this blend-start-time)) + (format #t "~1Tblend-start-value: ~f~%" (-> this blend-start-value)) + (format #t "~1Tblend-max: ~f~%" (-> this blend-max)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/anim/mspace-h_REF.gc b/test/decompiler/reference/jakx/engine/anim/mspace-h_REF.gc new file mode 100644 index 0000000000..6b5f6c5bca --- /dev/null +++ b/test/decompiler/reference/jakx/engine/anim/mspace-h_REF.gc @@ -0,0 +1,185 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type joint +(deftype joint (basic) + "A joint from an animated skeleton. This defines the graph of the skeleton, and also the bind pose +used for the mesh data. The joints are shared between all instances of the same model." + ((name basic) + (number int32) + (parent joint) + (bind-pose matrix :inline) + ) + ) + +;; definition for method 3 of type joint +(defmethod inspect ((this joint)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tnumber: ~D~%" (-> this number)) + (format #t "~1Tparent: ~A~%" (-> this parent)) + (format #t "~1Tbind-pose: #~%" (-> this bind-pose)) + (label cfg-4) + this + ) + +;; definition of type bone-cache +(deftype bone-cache (structure) + "Unused type. Existed in Jak 1, but wasn't used there." + ((bone-matrix uint32) + (parent-matrix uint32) + (dummy uint32) + (frame uint32) + ) + ) + +;; definition for method 3 of type bone-cache +(defmethod inspect ((this bone-cache)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bone-cache) + (format #t "~1Tbone-matrix: ~D~%" (-> this bone-matrix)) + (format #t "~1Tparent-matrix: ~D~%" (-> this parent-matrix)) + (format #t "~1Tdummy: ~D~%" (-> this dummy)) + (format #t "~1Tframe: ~D~%" (-> this frame)) + (label cfg-4) + this + ) + +;; definition of type bone +(deftype bone (structure) + "The location and scale of a bone in an animated skeleton. Each instance of a skeleton +has its own copy of the bones. This data is used for collision checking or other gameplay math, +but, despite the name, isn't directly used in rendering." + ((transform matrix :inline) + (position vector :inline :overlay-at (-> transform data 12)) + (scale vector :inline) + ) + ) + +;; definition for method 3 of type bone +(defmethod inspect ((this bone)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bone) + (format #t "~1Ttransform: #~%" (-> this transform)) + (format #t "~1Tposition: #~%" (-> this transform trans)) + (format #t "~1Tscale: #~%" (-> this scale)) + (label cfg-4) + this + ) + +;; definition of type skeleton +(deftype skeleton (inline-array-class) + "Skeleton is an array of bones for the entire character. The bones are stored in an inline array so they can be +easily dma'd to the scratchpad later." + ((bones bone :inline :dynamic) + ) + ) + +;; definition for method 3 of type skeleton +(defmethod inspect ((this skeleton)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this bones)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> skeleton heap-base) (the-as uint 80)) + +;; definition of type cspace +(deftype cspace (structure) + "A cspace describes how to control a bone. It contains a reference to the joint, bone, and a callback function. +The callback function is used to take the joint transforms out of the joint animation, then update the bone." + ((parent cspace) + (joint joint) + (joint-num int16) + (geo drawable) + (bone bone) + (param0 (function cspace transformq none)) + (param1 basic) + (param2 basic) + ) + (:methods + (new (symbol type drawable) _type_) + (reset-and-assign-geo! (_type_ drawable) _type_) + ) + ) + +;; definition for method 3 of type cspace +(defmethod inspect ((this cspace)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cspace) + (format #t "~1Tparent: #~%" (-> this parent)) + (format #t "~1Tjoint: ~A~%" (-> this joint)) + (format #t "~1Tjoint-num: ~D~%" (-> this joint-num)) + (format #t "~1Tgeo: ~A~%" (-> this geo)) + (format #t "~1Tbone: #~%" (-> this bone)) + (format #t "~1Tparam0: ~A~%" (-> this param0)) + (format #t "~1Tparam1: ~A~%" (-> this param1)) + (format #t "~1Tparam2: ~A~%" (-> this param2)) + (label cfg-4) + this + ) + +;; definition of type cspace-array +(deftype cspace-array (inline-array-class) + ((data cspace :inline :dynamic) + ) + ) + +;; definition for method 3 of type cspace-array +(defmethod inspect ((this cspace-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> cspace-array heap-base) (the-as uint 32)) + +;; definition for method 2 of type cspace +(defmethod print ((this cspace)) + (format + #t + "#" + (if (-> this joint) + (-> this joint name) + "nojoint" + ) + this + ) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/camera/cam-debug-h_REF.gc b/test/decompiler/reference/jakx/engine/camera/cam-debug-h_REF.gc new file mode 100644 index 0000000000..9f58c5b09d --- /dev/null +++ b/test/decompiler/reference/jakx/engine/camera/cam-debug-h_REF.gc @@ -0,0 +1,140 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) + +;; definition for symbol *redline-table*, type (pointer float) +(define *redline-table* (the-as (pointer float) (malloc 'debug 1600))) + +;; definition for symbol *redline-index*, type int +(define *redline-index* 0) + +;; definition for function float-save-redline +;; WARN: Return type mismatch int vs none. +(defun float-save-redline ((arg0 float)) + (set! (-> *redline-table* *redline-index*) arg0) + (set! *redline-index* (+ *redline-index* 1)) + (when (>= *redline-index* 400) + (set! *redline-index* 0) + 0 + ) + (none) + ) + +;; definition for function float-lookup-redline +(defun float-lookup-redline ((arg0 float)) + (let ((a0-3 (mod (+ (the int arg0) -1 *redline-index*) 400))) + (-> *redline-table* a0-3) + ) + ) + +;; definition for symbol *blueline-table*, type (pointer float) +(define *blueline-table* (the-as (pointer float) (malloc 'debug 1600))) + +;; definition for symbol *blueline-index*, type int +(define *blueline-index* 0) + +;; definition for function float-save-blueline +;; WARN: Return type mismatch int vs none. +(defun float-save-blueline ((arg0 float)) + (set! (-> *blueline-table* *blueline-index*) arg0) + (set! *blueline-index* (+ *blueline-index* 1)) + (when (>= *blueline-index* 400) + (set! *blueline-index* 0) + 0 + ) + (none) + ) + +;; definition for function float-lookup-blueline +(defun float-lookup-blueline ((arg0 float)) + (let ((a0-3 (mod (+ (the int arg0) -1 *blueline-index*) 400))) + (-> *blueline-table* a0-3) + ) + ) + +;; definition for symbol *greenline-table*, type (pointer float) +(define *greenline-table* (the-as (pointer float) (malloc 'debug 1600))) + +;; definition for symbol *greenline-index*, type int +(define *greenline-index* 0) + +;; definition for function float-save-greenline +;; WARN: Return type mismatch int vs none. +(defun float-save-greenline ((arg0 float)) + (set! (-> *greenline-table* *greenline-index*) arg0) + (set! *greenline-index* (+ *greenline-index* 1)) + (when (>= *greenline-index* 400) + (set! *greenline-index* 0) + 0 + ) + (none) + ) + +;; definition for function float-lookup-greenline +(defun float-lookup-greenline ((arg0 float)) + (let ((a0-3 (mod (+ (the int arg0) -1 *greenline-index*) 400))) + (-> *greenline-table* a0-3) + ) + ) + +;; definition for symbol *yellowline-table*, type (pointer float) +(define *yellowline-table* (the-as (pointer float) (malloc 'debug 1600))) + +;; definition for symbol *yellowline-index*, type int +(define *yellowline-index* 0) + +;; definition for function float-save-yellowline +;; WARN: Return type mismatch int vs none. +(defun float-save-yellowline ((arg0 float)) + (set! (-> *yellowline-table* *yellowline-index*) arg0) + (set! *yellowline-index* (+ *yellowline-index* 1)) + (when (>= *yellowline-index* 400) + (set! *yellowline-index* 0) + 0 + ) + (none) + ) + +;; definition for function float-lookup-yellowline +(defun float-lookup-yellowline ((arg0 float)) + (let ((a0-3 (mod (+ (the int arg0) -1 *yellowline-index*) 400))) + (-> *yellowline-table* a0-3) + ) + ) + +;; definition for symbol *timeplot-table*, type (pointer float) +(define *timeplot-table* (the-as (pointer float) (malloc 'debug 1600))) + +;; definition for symbol *timeplot-index*, type int +(define *timeplot-index* 0) + +;; definition for function float-save-timeplot +;; WARN: Return type mismatch int vs none. +(defun float-save-timeplot ((arg0 float)) + (set! (-> *timeplot-table* *timeplot-index*) arg0) + (set! *timeplot-index* (+ *timeplot-index* 1)) + (when (>= *timeplot-index* 400) + (set! *timeplot-index* 0) + 0 + ) + (none) + ) + +;; definition for function float-lookup-timeplot +(defun float-lookup-timeplot ((arg0 float)) + (let ((a0-3 (mod (+ (the int arg0) -1 *timeplot-index*) 400))) + (-> *timeplot-table* a0-3) + ) + ) + +;; definition (perm) for symbol *cam-layout*, type symbol +(define-perm *cam-layout* symbol #f) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/camera/cam-interface-h_REF.gc b/test/decompiler/reference/jakx/engine/camera/cam-interface-h_REF.gc new file mode 100644 index 0000000000..c606680078 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/camera/cam-interface-h_REF.gc @@ -0,0 +1,12 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition (perm) for symbol *camera-init-mat*, type matrix +(define-perm *camera-init-mat* matrix #f) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/camera/cam-update-h_REF.gc b/test/decompiler/reference/jakx/engine/camera/cam-update-h_REF.gc new file mode 100644 index 0000000000..34e4d4ba5f --- /dev/null +++ b/test/decompiler/reference/jakx/engine/camera/cam-update-h_REF.gc @@ -0,0 +1,54 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *external-cam-options*, type external-cam-option +(define *external-cam-options* (the-as external-cam-option 0)) + +;; definition for symbol *external-cam-mode*, type symbol +(define *external-cam-mode* #f) + +;; failed to figure out what this is: +(when (or (not *camera-look-through-other*) (zero? *camera-look-through-other*)) + (set! *camera-look-through-other* 0) + 0 + ) + +;; definition (perm) for symbol *camera-other-fov*, type bfloat +(define-perm *camera-other-fov* bfloat (new 'static 'bfloat :data 11650.845)) + +;; definition (perm) for symbol *camera-other-trans*, type vector +(define-perm *camera-other-trans* vector (vector-reset! (new 'global 'vector))) + +;; definition (perm) for symbol *camera-other-matrix*, type matrix +(define-perm *camera-other-matrix* matrix (matrix-identity! (new 'global 'matrix))) + +;; definition (perm) for symbol *camera-smush-control*, type smush-control +(define-perm *camera-smush-control* smush-control (set-zero! (new 'global 'smush-control))) + +;; definition (perm) for symbol *camera-smush-control-horizontal*, type smush-control +(define-perm *camera-smush-control-horizontal* smush-control (set-zero! (new 'global 'smush-control))) + +;; definition (perm) for symbol *camera-smush-control-into*, type smush-control +(define-perm *camera-smush-control-into* smush-control (set-zero! (new 'global 'smush-control))) + +;; definition (perm) for symbol *camera-smush-control-2*, type smush-control +(define-perm *camera-smush-control-2* smush-control (set-zero! (new 'global 'smush-control))) + +;; definition (perm) for symbol *camera-smush-control-horizontal-2*, type smush-control +(define-perm *camera-smush-control-horizontal-2* smush-control (set-zero! (new 'global 'smush-control))) + +;; definition (perm) for symbol *camera-smush-control-into-2*, type smush-control +(define-perm *camera-smush-control-into-2* smush-control (set-zero! (new 'global 'smush-control))) + +;; definition (perm) for symbol *camera-other-root*, type vector +(define-perm *camera-other-root* vector (vector-reset! (new 'global 'vector))) + +;; definition for symbol *fix-visible-level-mask*, type int +(define *fix-visible-level-mask* 6) + +;; definition for symbol *manual-sample-point*, type symbol +(define *manual-sample-point* #f) + + + + diff --git a/test/decompiler/reference/jakx/engine/camera/camera-defs-h_REF.gc b/test/decompiler/reference/jakx/engine/camera/camera-defs-h_REF.gc new file mode 100644 index 0000000000..cc07c15a35 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/camera/camera-defs-h_REF.gc @@ -0,0 +1,104 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type camera-bank +(deftype camera-bank (basic) + ((collide-move-rad float) + (joypad uint32) + (min-detectable-velocity float) + (attack-timeout time-frame) + (default-string-max-y meters) + (default-string-min-y meters) + (default-string-max-z meters) + (default-string-min-z meters) + (default-string-push-z meters) + (default-tilt-adjust degrees) + ) + ) + +;; definition for method 3 of type camera-bank +(defmethod inspect ((this camera-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tcollide-move-rad: ~f~%" (-> this collide-move-rad)) + (format #t "~1Tjoypad: ~D~%" (-> this joypad)) + (format #t "~1Tmin-detectable-velocity: ~f~%" (-> this min-detectable-velocity)) + (format #t "~1Tattack-timeout: ~D~%" (-> this attack-timeout)) + (format #t "~1Tdefault-string-max-y: (meters ~m)~%" (-> this default-string-max-y)) + (format #t "~1Tdefault-string-min-y: (meters ~m)~%" (-> this default-string-min-y)) + (format #t "~1Tdefault-string-max-z: (meters ~m)~%" (-> this default-string-max-z)) + (format #t "~1Tdefault-string-min-z: (meters ~m)~%" (-> this default-string-min-z)) + (format #t "~1Tdefault-string-push-z: (meters ~m)~%" (-> this default-string-push-z)) + (format #t "~1Tdefault-tilt-adjust: (deg ~r)~%" (-> this default-tilt-adjust)) + (label cfg-4) + this + ) + +;; definition for symbol *CAMERA-bank*, type camera-bank +(define *CAMERA-bank* (new 'static 'camera-bank + :collide-move-rad 1638.4 + :min-detectable-velocity 40.96 + :attack-timeout (seconds 0.25) + :default-string-max-y (meters 3) + :default-string-min-y (meters 1) + :default-string-max-z (meters 12.5) + :default-string-min-z (meters 5) + :default-string-push-z (meters 10) + :default-tilt-adjust (degrees -6.5000005) + ) + ) + +;; definition of type camera-master-bank +(deftype camera-master-bank (basic) + ((onscreen-head-height meters) + (onscreen-foot-height meters) + (target-height meters) + (up-move-to-pitch-ratio-in-air float) + (down-move-to-pitch-ratio-in-air float) + (up-move-to-pitch-on-ground float) + (down-move-to-pitch-on-ground float) + (pitch-off-blend float) + ) + ) + +;; definition for method 3 of type camera-master-bank +(defmethod inspect ((this camera-master-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tonscreen-head-height: (meters ~m)~%" (-> this onscreen-head-height)) + (format #t "~1Tonscreen-foot-height: (meters ~m)~%" (-> this onscreen-foot-height)) + (format #t "~1Ttarget-height: (meters ~m)~%" (-> this target-height)) + (format #t "~1Tup-move-to-pitch-ratio-in-air: ~f~%" (-> this up-move-to-pitch-ratio-in-air)) + (format #t "~1Tdown-move-to-pitch-ratio-in-air: ~f~%" (-> this down-move-to-pitch-ratio-in-air)) + (format #t "~1Tup-move-to-pitch-on-ground: ~f~%" (-> this up-move-to-pitch-on-ground)) + (format #t "~1Tdown-move-to-pitch-on-ground: ~f~%" (-> this down-move-to-pitch-on-ground)) + (format #t "~1Tpitch-off-blend: ~f~%" (-> this pitch-off-blend)) + (label cfg-4) + this + ) + +;; definition for symbol *CAMERA_MASTER-bank*, type camera-master-bank +(define *CAMERA_MASTER-bank* (new 'static 'camera-master-bank + :onscreen-head-height (meters 2.65) + :onscreen-foot-height (meters -0.5) + :target-height (meters 2.15) + :up-move-to-pitch-ratio-in-air 1.0 + :down-move-to-pitch-ratio-in-air 0.5 + :up-move-to-pitch-on-ground 0.9 + :down-move-to-pitch-on-ground 0.9 + :pitch-off-blend 0.5 + ) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/camera/camera-h_REF.gc b/test/decompiler/reference/jakx/engine/camera/camera-h_REF.gc new file mode 100644 index 0000000000..b56accf3c9 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/camera/camera-h_REF.gc @@ -0,0 +1,716 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type cam-index +(deftype cam-index (structure) + ((flags cam-index-options) + (vec vector 2 :inline) + ) + (:methods + (cam-index-method-9 (_type_ symbol entity vector curve) symbol) + (cam-index-method-10 (_type_ vector) float) + ) + ) + +;; definition for method 3 of type cam-index +(defmethod inspect ((this cam-index)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cam-index) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tvec[2] @ #x~X~%" (-> this vec)) + (label cfg-4) + this + ) + +;; definition of type tracking-point +(deftype tracking-point (structure) + ((position vector :inline) + (direction vector :inline) + (tp-length float) + (next int32) + (incarnation int32) + ) + ) + +;; definition for method 3 of type tracking-point +(defmethod inspect ((this tracking-point)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tracking-point) + (format #t "~1Tposition: #~%" (-> this position)) + (format #t "~1Tdirection: #~%" (-> this direction)) + (format #t "~1Ttp-length: ~f~%" (-> this tp-length)) + (format #t "~1Tnext: ~D~%" (-> this next)) + (format #t "~1Tincarnation: ~D~%" (-> this incarnation)) + (label cfg-4) + this + ) + +;; definition of type tracking-spline-sampler +(deftype tracking-spline-sampler (structure) + ((cur-pt int32) + (partial-pt float) + ) + ) + +;; definition for method 3 of type tracking-spline-sampler +(defmethod inspect ((this tracking-spline-sampler)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tracking-spline-sampler) + (format #t "~1Tcur-pt: ~D~%" (-> this cur-pt)) + (format #t "~1Tpartial-pt: ~f~%" (-> this partial-pt)) + (label cfg-4) + this + ) + +;; definition of type tracking-spline +(deftype tracking-spline (structure) + ((point tracking-point 32 :inline) + (summed-len float) + (free-point int32) + (used-point int32) + (partial-point float) + (end-point int32) + (next-to-last-point int32) + (max-move float) + (sample-len float) + (used-count int32) + (old-position vector :inline) + (debug-old-position vector :inline) + (debug-out-position vector :inline) + (debug-last-point int32) + ) + (:methods + (tracking-spline-method-9 (_type_) none) + (tracking-spline-method-10 (_type_ vector) none) + (debug-point-info (_type_ int) none) + (debug-all-points (_type_) none) + (tracking-spline-method-13 (_type_ int) none) + (tracking-spline-method-14 (_type_ tracking-spline-sampler) none) + (tracking-spline-method-15 (_type_) none) + (tracking-spline-method-16 (_type_ float) none) + (tracking-spline-method-17 (_type_ vector float float symbol) int) + (tracking-spline-method-18 (_type_ float vector vector tracking-spline-sampler) vector) + (tracking-spline-method-19 (_type_ float vector vector tracking-spline-sampler) vector) + (tracking-spline-method-20 (_type_ vector int) none) + (tracking-spline-method-21 (_type_ vector float float float float vector) vector) + (tracking-spline-method-22 (_type_ float) symbol) + (debug-draw-spline (_type_) none) + ) + ) + +;; definition for method 3 of type tracking-spline +(defmethod inspect ((this tracking-spline)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tracking-spline) + (format #t "~1Tpoint[32] @ #x~X~%" (-> this point)) + (format #t "~1Tsummed-len: ~f~%" (-> this summed-len)) + (format #t "~1Tfree-point: ~D~%" (-> this free-point)) + (format #t "~1Tused-point: ~D~%" (-> this used-point)) + (format #t "~1Tpartial-point: ~f~%" (-> this partial-point)) + (format #t "~1Tend-point: ~D~%" (-> this end-point)) + (format #t "~1Tnext-to-last-point: ~D~%" (-> this next-to-last-point)) + (format #t "~1Tmax-move: ~f~%" (-> this max-move)) + (format #t "~1Tsample-len: ~f~%" (-> this sample-len)) + (format #t "~1Tused-count: ~D~%" (-> this used-count)) + (format #t "~1Told-position: #~%" (-> this old-position)) + (format #t "~1Tdebug-old-position: #~%" (-> this debug-old-position)) + (format #t "~1Tdebug-out-position: #~%" (-> this debug-out-position)) + (format #t "~1Tdebug-last-point: ~D~%" (-> this debug-last-point)) + (label cfg-4) + this + ) + +;; definition of type cam-float-seeker +(deftype cam-float-seeker (structure) + ((target float) + (value float) + (vel float) + (accel float) + (max-vel float) + (max-partial float) + ) + :pack-me + (:methods + (init (_type_ float float float float) none) + (copy-to (_type_ _type_) none) + (update! (_type_ float) none) + (jump-to-target! (_type_ float) float) + ) + ) + +;; definition for method 3 of type cam-float-seeker +(defmethod inspect ((this cam-float-seeker)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cam-float-seeker) + (format #t "~1Ttarget: ~f~%" (-> this target)) + (format #t "~1Tvalue: ~f~%" (-> this value)) + (format #t "~1Tvel: ~f~%" (-> this vel)) + (format #t "~1Taccel: ~f~%" (-> this accel)) + (format #t "~1Tmax-vel: ~f~%" (-> this max-vel)) + (format #t "~1Tmax-partial: ~f~%" (-> this max-partial)) + (label cfg-4) + this + ) + +;; definition for method 9 of type cam-float-seeker +;; WARN: Return type mismatch int vs none. +(defmethod init ((this cam-float-seeker) (arg0 float) (arg1 float) (arg2 float) (arg3 float)) + (set! (-> this target) arg0) + (set! (-> this value) arg0) + (set! (-> this vel) 0.0) + (set! (-> this accel) arg1) + (set! (-> this max-vel) arg2) + (set! (-> this max-partial) arg3) + 0 + (none) + ) + +;; definition for method 10 of type cam-float-seeker +;; WARN: Return type mismatch int vs none. +(defmethod copy-to ((this cam-float-seeker) (arg0 cam-float-seeker)) + (set! (-> this target) (-> arg0 target)) + (set! (-> this value) (-> arg0 value)) + (set! (-> this vel) (-> arg0 vel)) + (set! (-> this accel) (-> arg0 accel)) + (set! (-> this max-vel) (-> arg0 max-vel)) + (set! (-> this max-partial) (-> arg0 max-partial)) + 0 + (none) + ) + +;; definition for method 11 of type cam-float-seeker +;; WARN: Return type mismatch int vs none. +(defmethod update! ((this cam-float-seeker) (arg0 float)) + 0.0 + 0.0 + (let ((f0-2 (-> *display* dog-ratio))) + 0.0 + (while (< 0.001 f0-2) + (let ((f1-2 (if (< 1.0 f0-2) + 1.0 + f0-2 + ) + ) + ) + (set! f0-2 (+ -1.0 f0-2)) + (let* ((f3-2 (- (+ (-> this target) arg0) (-> this value))) + (f2-4 (* (-> this max-partial) (fabs f3-2))) + ) + (let ((f3-3 (* f3-2 (-> this accel)))) + (+! (-> this vel) f3-3) + ) + (let ((f3-6 (fabs (-> this vel))) + (f2-5 (fmin f2-4 (-> this max-vel))) + ) + (if (< f2-5 f3-6) + (set! (-> this vel) (* (-> this vel) (/ f2-5 f3-6))) + ) + ) + ) + (let ((f1-3 (* (-> this vel) f1-2))) + (+! (-> this value) f1-3) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type cam-float-seeker +(defmethod jump-to-target! ((this cam-float-seeker) (arg0 float)) + (set! (-> this value) (+ (-> this target) arg0)) + (set! (-> this vel) 0.0) + 0.0 + ) + +;; definition of type cam-vector-seeker +(deftype cam-vector-seeker (structure) + ((target vector :inline) + (value vector :inline) + (vel vector :inline) + (accel float) + (max-vel float) + (max-partial float) + ) + (:methods + (init (_type_ vector float float float) none) + (update! (_type_ vector) none) + ) + ) + +;; definition for method 3 of type cam-vector-seeker +(defmethod inspect ((this cam-vector-seeker)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cam-vector-seeker) + (format #t "~1Ttarget: #~%" (-> this target)) + (format #t "~1Tvalue: #~%" (-> this value)) + (format #t "~1Tvel: #~%" (-> this vel)) + (format #t "~1Taccel: ~f~%" (-> this accel)) + (format #t "~1Tmax-vel: ~f~%" (-> this max-vel)) + (format #t "~1Tmax-partial: ~f~%" (-> this max-partial)) + (label cfg-4) + this + ) + +;; definition for method 9 of type cam-vector-seeker +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod init ((this cam-vector-seeker) (arg0 vector) (arg1 float) (arg2 float) (arg3 float)) + (cond + (arg0 + (set! (-> this target quad) (-> arg0 quad)) + (set! (-> this value quad) (-> arg0 quad)) + ) + (else + (vector-reset! (-> this target)) + (vector-reset! (-> this value)) + ) + ) + (vector-reset! (-> this vel)) + (set! (-> this accel) arg1) + (set! (-> this max-vel) arg2) + (set! (-> this max-partial) arg3) + 0 + (none) + ) + +;; definition for method 10 of type cam-vector-seeker +;; WARN: Return type mismatch int vs none. +(defmethod update! ((this cam-vector-seeker) (arg0 vector)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 (new 'stack-no-clear 'vector))) + 0.0 + (let ((f0-1 (-> *display* dog-ratio))) + 0.0 + (while (< 0.001 f0-1) + (let ((f1-2 (if (< 1.0 f0-1) + 1.0 + f0-1 + ) + ) + ) + (set! f0-1 (+ -1.0 f0-1)) + (cond + (arg0 + (let ((t0-0 v1-0)) + (let ((a2-6 (-> this target)) + (a3-0 arg0) + ) + (.lvf vf4 (&-> a2-6 quad)) + (.lvf vf5 (&-> a3-0 quad)) + ) + (.mov.vf.w vf6 vf0) + (.add.vf.xyz vf6 vf4 vf5) + (.svf (&-> t0-0 quad) vf6) + ) + (vector-! v1-0 v1-0 (-> this value)) + ) + (else + (vector-! v1-0 (-> this target) (-> this value)) + ) + ) + (let ((f2-2 (* (-> this max-partial) (vector-length v1-0)))) + (vector-float*! v1-0 v1-0 (-> this accel)) + (let ((t0-5 (-> this vel))) + (let ((a2-13 (-> this vel)) + (a3-4 v1-0) + ) + (.lvf vf4 (&-> a2-13 quad)) + (.lvf vf5 (&-> a3-4 quad)) + ) + (.mov.vf.w vf6 vf0) + (.add.vf.xyz vf6 vf4 vf5) + (.svf (&-> t0-5 quad) vf6) + ) + (let ((f3-2 (vector-length (-> this vel))) + (f2-3 (fmin f2-2 (-> this max-vel))) + ) + (if (< f2-3 f3-2) + (vector-float*! (-> this vel) (-> this vel) (/ f2-3 f3-2)) + ) + ) + ) + (vector-float*! v1-0 (-> this vel) f1-2) + ) + (let ((t0-6 (-> this value))) + (let ((a2-21 (-> this value)) + (a3-7 v1-0) + ) + (.lvf vf4 (&-> a2-21 quad)) + (.lvf vf5 (&-> a3-7 quad)) + ) + (.mov.vf.w vf6 vf0) + (.add.vf.xyz vf6 vf4 vf5) + (.svf (&-> t0-6 quad) vf6) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition of type cam-rotation-tracker +(deftype cam-rotation-tracker (structure) + ((inv-mat matrix :inline) + (no-follow basic) + (follow-pt vector :inline) + (follow-off vector :inline) + (follow-blend float) + (tilt-adjust cam-float-seeker :inline) + (point-of-interest-blend cam-float-seeker :inline) + (underwater-blend cam-float-seeker :inline) + (looking-at vector :inline) + (looking-interesting vector :inline) + (old-cam-trans vector :inline) + (follow-height-extra cam-float-seeker :inline) + ) + ) + +;; definition for method 3 of type cam-rotation-tracker +(defmethod inspect ((this cam-rotation-tracker)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cam-rotation-tracker) + (format #t "~1Tinv-mat: ~`matrix`P~%" (-> this inv-mat)) + (format #t "~1Tno-follow: ~A~%" (-> this no-follow)) + (format #t "~1Tfollow-pt: ~`vector`P~%" (-> this follow-pt)) + (format #t "~1Tfollow-off: ~`vector`P~%" (-> this follow-off)) + (format #t "~1Tfollow-blend: ~f~%" (-> this follow-blend)) + (format #t "~1Ttilt-adjust: #~%" (-> this tilt-adjust)) + (format #t "~1Tpoint-of-interest-blend: #~%" (-> this point-of-interest-blend)) + (format #t "~1Tunderwater-blend: #~%" (-> this underwater-blend)) + (format #t "~1Tlooking-at: ~`vector`P~%" (-> this looking-at)) + (format #t "~1Tlooking-interesting: ~`vector`P~%" (-> this looking-interesting)) + (format #t "~1Told-cam-trans: ~`vector`P~%" (-> this old-cam-trans)) + (format #t "~1Tfollow-height-extra: #~%" (-> this follow-height-extra)) + (label cfg-4) + this + ) + +;; definition of type camera-combiner +(deftype camera-combiner (process) + ((trans vector :inline) + (inv-camera-rot matrix :inline) + (fov float) + (interp-val float) + (interp-step float) + (dist-from-src float) + (dist-from-dest float) + (flip-control-axis vector :inline) + (velocity vector :inline) + (tracking-status uint64) + (tracking-options int32) + (tracking cam-rotation-tracker :inline) + (fast-rot basic) + ) + (:states + cam-combiner-active + ) + ) + +;; definition for method 3 of type camera-combiner +(defmethod inspect ((this camera-combiner)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Ttrans: ~`vector`P~%" (-> this stack)) + (format #t "~2Tinv-camera-rot: ~`matrix`P~%" (-> this inv-camera-rot)) + (format #t "~2Tfov: ~f~%" (-> this fov)) + (format #t "~2Tinterp-val: ~f~%" (-> this interp-val)) + (format #t "~2Tinterp-step: ~f~%" (-> this interp-step)) + (format #t "~2Tdist-from-src: ~f~%" (-> this dist-from-src)) + (format #t "~2Tdist-from-dest: ~f~%" (-> this dist-from-dest)) + (format #t "~2Tflip-control-axis: #~%" (-> this flip-control-axis)) + (format #t "~2Tvelocity: #~%" (-> this velocity)) + (format #t "~2Ttracking-status: ~D~%" (-> this tracking-status)) + (format #t "~2Ttracking-options: ~D~%" (-> this tracking-options)) + (format #t "~2Ttracking: #~%" (-> this tracking)) + (format #t "~2Tfast-rot: ~A~%" (-> this fast-rot)) + (label cfg-4) + this + ) + +;; definition of type camera-slave +(deftype camera-slave (process) + ((trans vector :inline) + (fov float) + (fov0 float) + (fov1 float) + (fov-index cam-index :inline) + (tracking cam-rotation-tracker :inline) + (view-off-param float) + (view-off vector :inline) + (joystick-saved-view-off vector :inline) + (min-z-override float) + (view-flat vector :inline) + (string-vel-dir uint32) + (string-trans vector :inline) + (position-spline tracking-spline :inline) + (pivot-pt vector :inline) + (pivot-rad float) + (circular-follow vector :inline) + (max-angle-offset float) + (max-angle-curr float) + (options cam-slave-options-u32) + (cam-entity entity) + (butt-timer time-frame) + (butt-seek basic) + (butt-vector vector :inline) + (velocity vector :inline) + (desired-pos vector :inline) + (time-dist-too-far uint32) + (los-state slave-los-state) + (good-point vector :inline) + (los-tgt-spline-pt int32) + (los-tgt-spline-pt-incarnation int32) + (los-last-pos vector :inline) + (intro-curve curve :inline) + (intro-offset vector :inline) + (intro-t float) + (intro-t-step float) + (outro-exit-value float) + (spline-exists symbol) + (spline-curve curve :inline) + (spline-offset vector :inline) + (index cam-index :inline) + (saved-pt vector :inline) + (spline-tt float) + (spline-follow-dist float) + (enter-has-run symbol) + (blend-from-type camera-blend-from-type) + (blend-to-type camera-blend-to-type) + (have-phony-joystick basic) + (phony-joystick-x float) + (phony-joystick-y float) + (string-min-val vector :inline) + (string-max-val vector :inline) + (string-val-locked basic) + (relative-position vector :inline) + (string-relative basic) + (slope-adjust cam-float-seeker :inline) + (slope-quat quaternion :inline) + (vehicle-up vector :inline) + (vehicle-at vector :inline) + (intro-handle uint64) + (slow-mo-sound-id uint32) + ) + ) + +;; definition for method 3 of type camera-slave +(defmethod inspect ((this camera-slave)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Ttrans: ~`vector`P~%" (-> this stack)) + (format #t "~2Tfov: ~f~%" (-> this fov)) + (format #t "~2Tfov0: ~f~%" (-> this fov0)) + (format #t "~2Tfov1: ~f~%" (-> this fov1)) + (format #t "~2Tfov-index: #~%" (-> this fov-index)) + (format #t "~2Ttracking: #~%" (-> this tracking)) + (format #t "~2Tview-off-param: ~f~%" (-> this view-off-param)) + (format #t "~2Tview-off: ~`vector`P~%" (-> this view-off)) + (format #t "~2Tjoystick-saved-view-off: ~`vector`P~%" (-> this joystick-saved-view-off)) + (format #t "~2Tmin-z-override: ~f~%" (-> this min-z-override)) + (format #t "~2Tview-flat: ~`vector`P~%" (-> this view-flat)) + (format #t "~2Tstring-vel-dir: ~D~%" (-> this string-vel-dir)) + (format #t "~2Tstring-trans: ~`vector`P~%" (-> this string-trans)) + (format #t "~2Tposition-spline: #~%" (-> this position-spline)) + (format #t "~2Tpivot-pt: ~`vector`P~%" (-> this pivot-pt)) + (format #t "~2Tpivot-rad: ~f~%" (-> this pivot-rad)) + (format #t "~2Tcircular-follow: #~%" (-> this circular-follow)) + (format #t "~2Tmax-angle-offset: ~f~%" (-> this max-angle-offset)) + (format #t "~2Tmax-angle-curr: ~f~%" (-> this max-angle-curr)) + (format #t "~2Toptions: ~D~%" (-> this options)) + (format #t "~2Tcam-entity: ~A~%" (-> this cam-entity)) + (format #t "~2Tbutt-timer: ~D~%" (-> this butt-timer)) + (format #t "~2Tbutt-seek: ~A~%" (-> this butt-seek)) + (format #t "~2Tbutt-vector: ~`vector`P~%" (-> this butt-vector)) + (format #t "~2Tvelocity: ~`vector`P~%" (-> this velocity)) + (format #t "~2Tdesired-pos: ~`vector`P~%" (-> this desired-pos)) + (format #t "~2Ttime-dist-too-far: ~D~%" (-> this time-dist-too-far)) + (format #t "~2Tlos-state: ~D~%" (-> this los-state)) + (format #t "~2Tgood-point: ~`vector`P~%" (-> this good-point)) + (format #t "~2Tlos-tgt-spline-pt: ~D~%" (-> this los-tgt-spline-pt)) + (format #t "~2Tlos-tgt-spline-pt-incarnation: ~D~%" (-> this los-tgt-spline-pt-incarnation)) + (format #t "~2Tlos-last-pos: ~`vector`P~%" (-> this los-last-pos)) + (format #t "~2Tintro-curve: #~%" (-> this intro-curve)) + (format #t "~2Tintro-offset: #~%" (-> this intro-offset)) + (format #t "~2Tintro-t: ~f~%" (-> this intro-t)) + (format #t "~2Tintro-t-step: ~f~%" (-> this intro-t-step)) + (format #t "~2Toutro-exit-value: ~f~%" (-> this outro-exit-value)) + (format #t "~2Tspline-exists: ~A~%" (-> this spline-exists)) + (format #t "~2Tspline-curve: #~%" (-> this spline-curve)) + (format #t "~2Tspline-offset: #~%" (-> this spline-offset)) + (format #t "~2Tindex: #~%" (-> this index)) + (format #t "~2Tsaved-pt: #~%" (-> this saved-pt)) + (format #t "~2Tspline-tt: ~f~%" (-> this spline-tt)) + (format #t "~2Tspline-follow-dist: ~f~%" (-> this spline-follow-dist)) + (format #t "~2Tenter-has-run: ~A~%" (-> this enter-has-run)) + (format #t "~2Tblend-from-type: ~D~%" (-> this blend-from-type)) + (format #t "~2Tblend-to-type: ~D~%" (-> this blend-to-type)) + (format #t "~2Thave-phony-joystick: ~A~%" (-> this have-phony-joystick)) + (format #t "~2Tphony-joystick-x: ~f~%" (-> this phony-joystick-x)) + (format #t "~2Tphony-joystick-y: ~f~%" (-> this phony-joystick-y)) + (format #t "~2Tstring-min-val: #~%" (-> this string-min-val)) + (format #t "~2Tstring-max-val: #~%" (-> this string-max-val)) + (format #t "~2Tstring-val-locked: ~A~%" (-> this string-val-locked)) + (format #t "~2Trelative-position: #~%" (-> this relative-position)) + (format #t "~2Tstring-relative: ~A~%" (-> this string-relative)) + (format #t "~2Tslope-adjust: #~%" (-> this slope-adjust)) + (format #t "~2Tslope-quat: #~%" (-> this slope-quat)) + (format #t "~2Tvehicle-up: #~%" (-> this vehicle-up)) + (format #t "~2Tvehicle-at: #~%" (-> this vehicle-at)) + (format #t "~2Tintro-handle: ~D~%" (-> this intro-handle)) + (format #t "~2Tslow-mo-sound-id: ~D~%" (-> this slow-mo-sound-id)) + (label cfg-4) + this + ) + +;; definition of type camera-master +(deftype camera-master (process) + ((master-options cam-master-options-u32) + (settings cam-setting-data) + (slave (pointer camera-slave)) + (decel (pointer camera-slave)) + (slave-options cam-slave-options-u32) + (view-off-param-save float) + (changer uint32) + (string-min cam-vector-seeker :inline) + (string-max cam-vector-seeker :inline) + (string-push-z float) + (local-down vector :inline) + (focus focus :inline) + (being-attacked symbol) + (attack-start uint64) + (on-ground symbol) + (under-water int32) + (on-pole symbol) + (tgt-rot-mat matrix :inline) + (tgt-face-mat matrix :inline) + (tpos-old vector :inline) + (tpos-curr vector :inline) + (tpos-old-adj vector :inline) + (tpos-curr-adj vector :inline) + (tpos-tgt vector :inline) + (upspeed float) + (pitch-off vector :inline) + (target-spline tracking-spline :inline) + (ease-from vector :inline) + (ease-t float) + (ease-step float) + (ease-to vector :inline) + (outro-curve curve :inline) + (outro-t float) + (outro-t-step float) + (outro-exit-value float) + (water-drip-time uint64) + (water-drip sparticle-launch-control) + (water-drip-mult float) + (water-drip-speed float) + (interest-dist float) + ) + (:methods + (camera-master-method-15 () none) + (camera-master-method-16 () none) + (camera-master-method-17 () none) + ) + (:states + cam-master-active + ) + ) + +;; definition for method 3 of type camera-master +(defmethod inspect ((this camera-master)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Tmaster-options: ~D~%" (-> this master-options)) + (format #t "~2Tsettings: #~%" (-> this settings)) + (format #t "~2Tslave: #x~X~%" (-> this slave)) + (format #t "~2Tdecel: #x~X~%" (-> this decel)) + (format #t "~2Tslave-options: ~D~%" (-> this slave-options)) + (format #t "~2Tview-off-param-save: ~f~%" (-> this view-off-param-save)) + (format #t "~2Tchanger: #x~X~%" (-> this changer)) + (format #t "~2Tstring-min: #~%" (-> this string-min)) + (format #t "~2Tstring-max: #~%" (-> this string-max)) + (format #t "~2Tstring-push-z: ~f~%" (-> this string-push-z)) + (format #t "~2Tlocal-down: ~`vector`P~%" (-> this local-down)) + (format #t "~2Tfocus: #~%" (-> this focus)) + (format #t "~2Tbeing-attacked: ~A~%" (-> this being-attacked)) + (format #t "~2Tattack-start: ~D~%" (-> this attack-start)) + (format #t "~2Ton-ground: ~A~%" (-> this on-ground)) + (format #t "~2Tunder-water: ~D~%" (-> this under-water)) + (format #t "~2Ton-pole: ~A~%" (-> this on-pole)) + (format #t "~2Ttgt-rot-mat: ~`matrix`P~%" (-> this tgt-rot-mat)) + (format #t "~2Ttgt-face-mat: ~`matrix`P~%" (-> this tgt-face-mat)) + (format #t "~2Ttpos-old: ~`vector`P~%" (-> this tpos-old)) + (format #t "~2Ttpos-curr: ~`vector`P~%" (-> this tpos-curr)) + (format #t "~2Ttpos-old-adj: ~`vector`P~%" (-> this tpos-old-adj)) + (format #t "~2Ttpos-curr-adj: ~`vector`P~%" (-> this tpos-curr-adj)) + (format #t "~2Ttpos-tgt: ~`vector`P~%" (-> this tpos-tgt)) + (format #t "~2Tupspeed: ~f~%" (-> this upspeed)) + (format #t "~2Tpitch-off: ~`vector`P~%" (-> this pitch-off)) + (format #t "~2Ttarget-spline: #~%" (-> this target-spline)) + (format #t "~2Tease-from: #~%" (-> this ease-from)) + (format #t "~2Tease-t: ~f~%" (-> this ease-t)) + (format #t "~2Tease-step: ~f~%" (-> this ease-step)) + (format #t "~2Tease-to: #~%" (-> this ease-to)) + (format #t "~2Toutro-curve: #~%" (-> this outro-curve)) + (format #t "~2Toutro-t: ~f~%" (-> this outro-t)) + (format #t "~2Toutro-t-step: ~f~%" (-> this outro-t-step)) + (format #t "~2Toutro-exit-value: ~f~%" (-> this outro-exit-value)) + (format #t "~2Twater-drip-time: ~D~%" (-> this water-drip-time)) + (format #t "~2Twater-drip: ~A~%" (-> this water-drip)) + (format #t "~2Twater-drip-mult: ~f~%" (-> this water-drip-mult)) + (format #t "~2Twater-drip-speed: ~f~%" (-> this water-drip-speed)) + (format #t "~2Tinterest-dist: ~f~%" (-> this interest-dist)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/camera/pov-camera-h_REF.gc b/test/decompiler/reference/jakx/engine/camera/pov-camera-h_REF.gc new file mode 100644 index 0000000000..d67f2daa14 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/camera/pov-camera-h_REF.gc @@ -0,0 +1,55 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type pov-camera +(deftype pov-camera (process-drawable) + ((flags pov-camera-flag) + (debounce-start-time time-frame) + (notify-handle handle) + (anim-name string) + (command-list pair) + (mask-to-clear process-mask) + (music-volume-movie float) + (sfx-volume-movie float) + ) + (:methods + (pov-camera-method-50 () none) + (pov-camera-method-51 () none) + (pov-camera-method-52 () none) + (pov-camera-method-53 () none) + (pov-camera-method-54 () none) + (pov-camera-method-55 () none) + (pov-camera-method-56 () none) + (pov-camera-method-57 () none) + (pov-camera-method-58 () none) + (pov-camera-method-59 () none) + ) + ) + +;; definition for method 3 of type pov-camera +(defmethod inspect ((this pov-camera)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Tflags: ~D~%" (-> this flags)) + (format #t "~2Tdebounce-start-time: ~D~%" (-> this debounce-start-time)) + (format #t "~2Tnotify-handle: ~D~%" (-> this notify-handle)) + (format #t "~2Tanim-name: ~A~%" (-> this anim-name)) + (format #t "~2Tcommand-list: ~A~%" (-> this command-list)) + (format #t "~2Tmask-to-clear: ~D~%" (-> this mask-to-clear)) + (format #t "~2Tmusic-volume-movie: ~f~%" (-> this music-volume-movie)) + (format #t "~2Tsfx-volume-movie: ~f~%" (-> this sfx-volume-movie)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/collide/collide-cache-h_REF.gc b/test/decompiler/reference/jakx/engine/collide/collide-cache-h_REF.gc new file mode 100644 index 0000000000..5405d3ceac --- /dev/null +++ b/test/decompiler/reference/jakx/engine/collide/collide-cache-h_REF.gc @@ -0,0 +1,275 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type collide-puss-sphere +(deftype collide-puss-sphere (structure) + "A query sphere from the user for the porbe-using-spheres query. +This is used internally by the collide-cache implementation." + ((bsphere sphere :inline) + (bbox4w bounding-box4w :inline) + ) + ) + +;; definition for method 3 of type collide-puss-sphere +(defmethod inspect ((this collide-puss-sphere)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-puss-sphere) + (format #t "~1Tbsphere: #~%" (-> this bsphere)) + (format #t "~1Tbbox4w: #~%" (-> this bbox4w)) + (label cfg-4) + this + ) + +;; definition of type collide-puss-work +(deftype collide-puss-work (structure) + "Scratchpad memory map for probe-using-spheres query." + ((closest-pt vector :inline) + (tri-normal vector :inline) + (tri-bbox4w bounding-box4w :inline) + (spheres-bbox4w bounding-box4w :inline) + (spheres collide-puss-sphere 64 :inline) + ) + (:methods + (check-mesh-prim-against-spheres (_type_ collide-cache-prim collide-using-spheres-params) symbol) + (check-sphere-prim-against-spheres (_type_ collide-cache-prim collide-using-spheres-params) symbol) + ) + ) + +;; definition for method 3 of type collide-puss-work +(defmethod inspect ((this collide-puss-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-puss-work) + (format #t "~1Tclosest-pt: #~%" (-> this closest-pt)) + (format #t "~1Ttri-normal: #~%" (-> this tri-normal)) + (format #t "~1Ttri-bbox4w: #~%" (-> this tri-bbox4w)) + (format #t "~1Tspheres-bbox4w: #~%" (-> this spheres-bbox4w)) + (format #t "~1Tspheres[64] @ #x~X~%" (-> this spheres)) + (label cfg-4) + this + ) + +;; definition of type collide-cache-tri +(deftype collide-cache-tri (structure) + "A single triangle inside the collision cache. +Contains a reference back to the source object (like a collide-shape or water-control), and the prim itself." + ((vertex vector 3 :inline) + (extra-quad uint8 16) + (pat pat-surface :overlay-at (-> extra-quad 0)) + (collide-ptr basic :overlay-at (-> extra-quad 4)) + (prim-index uint16 :overlay-at (-> extra-quad 8)) + (user16 uint16 :overlay-at (-> extra-quad 10)) + (user32 uint32 :overlay-at (-> extra-quad 12)) + (clear-flags uint128 :overlay-at (-> extra-quad 0)) + ) + ) + +;; definition for method 3 of type collide-cache-tri +(defmethod inspect ((this collide-cache-tri)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-cache-tri) + (format #t "~1Tvertex[3] @ #x~X~%" (-> this vertex)) + (format #t "~1Textra-quad[16] @ #x~X~%" (-> this extra-quad)) + (format #t "~1Tpat: ~D~%" (-> this pat)) + (format #t "~1Tcollide-ptr: ~A~%" (-> this collide-ptr)) + (format #t "~1Tprim-index: ~D~%" (-> this prim-index)) + (format #t "~1Tuser16: ~D~%" (-> this user16)) + (format #t "~1Tuser32: ~D~%" (-> this user32)) + (label cfg-4) + this + ) + +;; definition of type collide-cache-prim +(deftype collide-cache-prim (structure) + "A primitive inside the collide-cache. +This can represent a sphere, a triangle mesh, or a group of other primitives within a bounding sphere." + ((prim-core collide-prim-core :inline) + (extra-quad uint8 16) + (ccache collide-cache :overlay-at (-> extra-quad 0)) + (prim collide-shape-prim :overlay-at (-> extra-quad 4)) + (first-tri uint16 :overlay-at (-> extra-quad 8)) + (num-tris uint16 :overlay-at (-> extra-quad 10)) + (extra basic :overlay-at (-> extra-quad 12)) + (world-sphere vector :inline :overlay-at (-> prim-core world-sphere)) + (collide-as collide-spec :overlay-at (-> prim-core collide-as)) + (action collide-action :overlay-at (-> prim-core action)) + (prim-type prim-type :overlay-at (-> prim-core prim-type)) + ) + (:methods + (resolve-moving-sphere-tri (_type_ collide-query sphere vector float collide-action) float) + (resolve-moving-sphere-sphere (_type_ collide-query sphere vector float collide-action) float) + ) + ) + +;; definition for method 3 of type collide-cache-prim +(defmethod inspect ((this collide-cache-prim)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-cache-prim) + (format #t "~1Tprim-core: #~%" (-> this prim-core)) + (format #t "~1Textra-quad[16] @ #x~X~%" (-> this extra-quad)) + (format #t "~1Tccache: ~A~%" (-> this ccache)) + (format #t "~1Tprim: ~A~%" (-> this prim)) + (format #t "~1Tfirst-tri: ~D~%" (-> this first-tri)) + (format #t "~1Tnum-tris: ~D~%" (-> this num-tris)) + (format #t "~1Textra: ~A~%" (-> this extra)) + (format #t "~1Tworld-sphere: ~`vector`P~%" (-> this prim-core)) + (format #t "~1Tcollide-as: ~D~%" (-> this prim-core collide-as)) + (format #t "~1Taction: ~D~%" (-> this prim-core action)) + (format #t "~1Tprim-type: ~D~%" (-> this prim-core prim-type)) + (label cfg-4) + this + ) + +;; definition of type collide-cache +(deftype collide-cache (basic) + "The collide-cache is a structure to accelerate collision queries. +In particular, it helps with queries where you don't know what you might hit. +It can detect collision with the background geometry, foreground dynamic collision shapes (spheres and meshes), and water. +To use it, it must first be 'filled' with geometry. Then you can manually inspect the geometry, or use one of the queries. +The supported queries are 'line-sphere' (raycast) and 'spheres' (check if intersecting anything). +It is not useful for ollision queries against a specific foreground object, like 'am I on top of platform X right now?'." + ((num-tris int32) + (max-tris int32) + (num-prims int32) + (max-prims int32) + (ignore-mask pat-surface) + (ignore-processes process 2) + (collide-box bounding-box :inline) + (collide-box4w bounding-box4w :inline) + (collide-with collide-spec) + (unused uint32 3) + (prims collide-cache-prim 4) + (tris collide-cache-tri) + ) + (:methods + (new (symbol type int int) _type_) + (collide-cache-method-9 () none) + (collide-cache-method-10 () none) + (collide-cache-method-11 () none) + (collide-cache-method-12 () none) + (collide-cache-method-13 () none) + (collide-cache-method-14 () none) + (collide-cache-method-15 () none) + (collide-cache-method-16 () none) + (collide-cache-method-17 () none) + (collide-cache-method-18 () none) + (collide-cache-method-19 () none) + (collide-cache-method-20 () none) + (collide-cache-method-21 () none) + (collide-cache-method-22 () none) + (collide-cache-method-23 () none) + (collide-cache-method-24 () none) + (collide-cache-method-25 () none) + (collide-cache-method-26 () none) + (collide-cache-method-27 () none) + ) + ) + +;; definition for method 3 of type collide-cache +(defmethod inspect ((this collide-cache)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tnum-tris: ~D~%" (-> this num-tris)) + (format #t "~1Tmax-tris: ~D~%" (-> this max-tris)) + (format #t "~1Tnum-prims: ~D~%" (-> this num-prims)) + (format #t "~1Tmax-prims: ~D~%" (-> this max-prims)) + (format #t "~1Tignore-mask: ~D~%" (-> this ignore-mask)) + (format #t "~1Tignore-processes[2] @ #x~X~%" (-> this ignore-processes)) + (format #t "~1Tcollide-box: #~%" (-> this collide-box)) + (format #t "~1Tcollide-box4w: #~%" (-> this collide-box4w)) + (format #t "~1Tcollide-with: ~D~%" (-> this collide-with)) + (format #t "~1Tunused: ~D~%" (-> this unused 0)) + (format #t "~1Tprims: #x~X~%" (-> this prims 0)) + (format #t "~1Ttris: #x~X~%" (-> this tris)) + (label cfg-4) + this + ) + +;; definition of type collide-list-item +(deftype collide-list-item (structure) + "Entry on the broad-phase collision list. +Can represent instanced collision, as a TIE instance, or a single non-instanced mesh fragment." + ((mesh instance-tie) + (inst basic) + ) + :pack-me + ) + +;; definition for method 3 of type collide-list-item +(defmethod inspect ((this collide-list-item)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-list-item) + (format #t "~1Tmesh: ~A~%" (-> this mesh)) + (format #t "~1Tinst: ~A~%" (-> this inst)) + (label cfg-4) + this + ) + +;; definition of type collide-list +(deftype collide-list (structure) + "List of items returned by the broad-phase collision query." + ((num-items int32) + (items collide-list-item 256 :inline :offset 16) + ) + ) + +;; definition for method 3 of type collide-list +(defmethod inspect ((this collide-list)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-list) + (format #t "~1Tnum-items: ~D~%" (-> this num-items)) + (format #t "~1Titems[256] @ #x~X~%" (-> this items)) + (label cfg-4) + this + ) + +;; definition for method 0 of type collide-cache +(defmethod new collide-cache ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int)) + (let* ((s3-0 (logand -16 (+ (-> type-to-make size) 19))) + (gp-0 (* 48 arg0)) + (v1-3 (* (+ arg1 1) 64)) + (v0-0 (object-new allocation type-to-make (the-as int (+ s3-0 gp-0 v1-3)))) + ) + (set! (-> v0-0 max-tris) arg1) + (set! (-> v0-0 max-prims) arg0) + (set! (-> v0-0 prims 0) (the-as collide-cache-prim (logand -16 (+ (+ s3-0 15) (the-as uint v0-0))))) + (set! (-> v0-0 tris) (the-as collide-cache-tri (+ (the-as uint (-> v0-0 prims 0)) gp-0))) + v0-0 + ) + ) + +;; failed to figure out what this is: +(kmemopen global "collide-cache-buffers") + +;; definition (perm) for symbol *collide-cache*, type collide-cache +(define-perm *collide-cache* collide-cache (new 'global 'collide-cache 100 460)) + +;; definition (perm) for symbol *collide-list*, type collide-list +(define-perm *collide-list* collide-list (new 'global 'collide-list)) + +;; failed to figure out what this is: +(kmemclose) + + + + diff --git a/test/decompiler/reference/jakx/engine/collide/collide-frag-h_REF.gc b/test/decompiler/reference/jakx/engine/collide/collide-frag-h_REF.gc new file mode 100644 index 0000000000..6102fcdec8 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/collide/collide-frag-h_REF.gc @@ -0,0 +1,119 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type collide-frag-vertex +(deftype collide-frag-vertex (vector) + () + ) + +;; definition for method 3 of type collide-frag-vertex +;; INFO: Used lq/sq +(defmethod inspect ((this collide-frag-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-frag-vertex) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tz: ~f~%" (-> this z)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (label cfg-4) + this + ) + +;; definition of type collide-frag-mesh +(deftype collide-frag-mesh (basic) + "Unused Jak 1 background collision mesh fragment." + ((packed-data uint32) + (pat-array uint32) + (strip-data-len uint16) + (poly-count uint16) + (base-trans vector4w :inline) + (vertex-count uint8 :overlay-at (-> base-trans data 3)) + (vertex-data-qwc uint8 :offset 29) + (total-qwc uint8 :offset 30) + (unused uint8 :offset 31) + ) + ) + +;; definition for method 3 of type collide-frag-mesh +(defmethod inspect ((this collide-frag-mesh)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tpacked-data: #x~X~%" (-> this packed-data)) + (format #t "~1Tpat-array: #x~X~%" (-> this pat-array)) + (format #t "~1Tstrip-data-len: ~D~%" (-> this strip-data-len)) + (format #t "~1Tpoly-count: ~D~%" (-> this poly-count)) + (format #t "~1Tbase-trans: #~%" (-> this base-trans)) + (format #t "~1Tvertex-count: ~D~%" (-> this vertex-count)) + (format #t "~1Tvertex-data-qwc: ~D~%" (-> this vertex-data-qwc)) + (format #t "~1Ttotal-qwc: ~D~%" (-> this total-qwc)) + (format #t "~1Tunused: ~D~%" (-> this unused)) + (label cfg-4) + this + ) + +;; definition of type collide-fragment +(deftype collide-fragment (drawable) + "Unused Jak 1 background collision drawable tree node." + ((mesh collide-frag-mesh :offset 8) + (collide-new basic :offset 12) + ) + ) + +;; definition for method 3 of type collide-fragment +(defmethod inspect ((this collide-fragment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tmesh: ~A~%" (-> this mesh)) + (format #t "~1Tcollide-new: ~A~%" (-> this collide-new)) + (label cfg-4) + this + ) + +;; definition of type drawable-inline-array-collide-fragment +(deftype drawable-inline-array-collide-fragment (drawable-inline-array) + "Unused Jak 1 background collision drawable tree inline-array class." + ((data collide-fragment 1 :inline) + (pad uint32) + ) + ) + +;; definition for method 3 of type drawable-inline-array-collide-fragment +(defmethod inspect ((this drawable-inline-array-collide-fragment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tdata[1] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type drawable-tree-collide-fragment +(deftype drawable-tree-collide-fragment (drawable-tree) + "Unused jak 1 background collision data." + () + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/collide/collide-func-h_REF.gc b/test/decompiler/reference/jakx/engine/collide/collide-func-h_REF.gc new file mode 100644 index 0000000000..8e4b1f21d4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/collide/collide-func-h_REF.gc @@ -0,0 +1,9 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/collide/collide-h_REF.gc b/test/decompiler/reference/jakx/engine/collide/collide-h_REF.gc new file mode 100644 index 0000000000..a643780bbd --- /dev/null +++ b/test/decompiler/reference/jakx/engine/collide/collide-h_REF.gc @@ -0,0 +1,109 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type collide-query +(deftype collide-query (structure) + "Very general collision-query structure. The meaning is different depending on where it used. +This has both inputs from the user, and collision results." + ((best-other-tri collide-tri-result :inline) + (best-my-tri collide-tri-result :inline :overlay-at best-other-tri) + (ignore-processes process-tree 2) + (ignore-process0 process-tree :overlay-at (-> ignore-processes 0)) + (ignore-process1 process-tree :overlay-at (-> ignore-processes 1)) + (ignore-pat pat-surface) + (ignore-pat-s32 int32 :overlay-at ignore-pat) + (collide-with collide-spec) + (collide-with-s32 int32 :overlay-at collide-with) + (overlay-params uint32 3 :offset 112) + (bbox bounding-box :inline) + (bbox4w bounding-box4w :inline) + (bsphere sphere :inline) + (start-pos vector :inline) + (move-dist vector :inline) + (rlength vector :inline) + (exit-planes plane 2 :inline) + (radius float :overlay-at (-> exit-planes 0 data 3)) + (inv-mat matrix :inline :offset 288) + (spheres (inline-array sphere) :overlay-at (-> overlay-params 0)) + (num-spheres uint32 :overlay-at (-> overlay-params 1)) + (solid-only symbol :overlay-at (-> overlay-params 2)) + (best-dist float :overlay-at spheres) + (best-other-prim collide-shape-prim :overlay-at num-spheres) + (best-my-prim collide-shape-prim :overlay-at solid-only) + (move-vec vector :inline :overlay-at move-dist) + (best-u float :overlay-at best-dist) + (action-mask collide-action :offset 352) + (local-box4w bounding-box4w :inline) + (search-box bounding-box4w :inline) + (search-vector vector4w :inline) + (instance-mat matrix :inline) + (instance-ptr basic) + (x-addr uint32) + (x-step uint32) + (y-addr uint32) + (y-step uint32) + (z-addr uint32) + (z-step uint32) + ) + ) + +;; definition for method 3 of type collide-query +(defmethod inspect ((this collide-query)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-query) + (format #t "~1Tbest-other-tri: #~%" (-> this best-other-tri)) + (format #t "~1Tbest-my-tri: #~%" (-> this best-other-tri)) + (format #t "~1Tignore-processes[2] @ #x~X~%" (-> this ignore-processes)) + (format #t "~1Tignore-process0: ~A~%" (-> this ignore-process0)) + (format #t "~1Tignore-process1: ~A~%" (-> this ignore-process1)) + (format #t "~1Tignore-pat: ~D~%" (-> this ignore-pat)) + (format #t "~1Tcollide-with: ~D~%" (-> this collide-with)) + (format #t "~1Toverlay-params[3] @ #x~X~%" (&-> this best-dist)) + (format #t "~1Tbbox: #~%" (-> this bbox)) + (format #t "~1Tbbox4w: #~%" (-> this bbox4w)) + (format #t "~1Tbsphere: #~%" (-> this bsphere)) + (format #t "~1Tstart-pos: #~%" (-> this start-pos)) + (format #t "~1Tmove-dist: #~%" (-> this move-dist)) + (format #t "~1Trlength: #~%" (-> this rlength)) + (format #t "~1Texit-planes[2] @ #x~X~%" (-> this exit-planes)) + (format #t "~1Tradius: ~f~%" (-> this radius)) + (format #t "~1Tinv-mat: #~%" (-> this inv-mat)) + (format #t "~1Tfinal-pos: #~%" (-> this rlength)) + (format #t "~1Tspheres: #x~X~%" (-> this best-dist)) + (format #t "~1Tnum-spheres: ~D~%" (-> this best-other-prim)) + (format #t "~1Tsolid-only: ~A~%" (-> this best-my-prim)) + (format #t "~1Tbest-dist: ~f~%" (-> this best-dist)) + (format #t "~1Tbest-other-prim: ~A~%" (-> this best-other-prim)) + (format #t "~1Tbest-my-prim: ~A~%" (-> this best-my-prim)) + (format #t "~1Tmove-vec: #~%" (-> this move-dist)) + (format #t "~1Tbest-u: ~f~%" (-> this best-dist)) + (format #t "~1Taction-mask: ~D~%" (-> this action-mask)) + (format #t "~1Tnav-mesh: ~A~%" (-> this best-other-prim)) + (format #t "~1Tbest-ccache-prim: #~%" (-> this best-other-prim)) + (format #t "~1Tlocal-box4w: #~%" (-> this local-box4w)) + (format #t "~1Tsearch-box: #~%" (-> this search-box)) + (format #t "~1Tsearch-vector: #~%" (-> this search-vector)) + (format #t "~1Tinstance-mat: #~%" (-> this instance-mat)) + (format #t "~1Tinstance-ptr: ~A~%" (-> this instance-ptr)) + (format #t "~1Tx-addr: ~D~%" (-> this x-addr)) + (format #t "~1Tx-step: ~D~%" (-> this x-step)) + (format #t "~1Ty-addr: ~D~%" (-> this y-addr)) + (format #t "~1Ty-step: ~D~%" (-> this y-step)) + (format #t "~1Tz-addr: ~D~%" (-> this z-addr)) + (format #t "~1Tz-step: ~D~%" (-> this z-step)) + (label cfg-4) + this + ) + +;; definition for symbol *collide-test-flag*, type symbol +(define *collide-test-flag* #f) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/collide/collide-mesh-h_REF.gc b/test/decompiler/reference/jakx/engine/collide/collide-mesh-h_REF.gc new file mode 100644 index 0000000000..82053f92c4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/collide/collide-mesh-h_REF.gc @@ -0,0 +1,198 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type collide-tri-result +(deftype collide-tri-result (structure) + "A triangle result of a collision." + ((vertex vector 3 :inline) + (intersect vector :inline) + (normal vector :inline) + (pat pat-surface) + (collide-ptr basic) + ) + ) + +;; definition for method 3 of type collide-tri-result +(defmethod inspect ((this collide-tri-result)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-tri-result) + (format #t "~1Tvertex[3] @ #x~X~%" (-> this vertex)) + (format #t "~1Tintersect: ~`vector`P~%" (-> this intersect)) + (format #t "~1Tnormal: ~`vector`P~%" (-> this normal)) + (format #t "~1Tpat: ~D~%" (-> this pat)) + (format #t "~1Tcollide-ptr: ~A~%" (-> this collide-ptr)) + (label cfg-4) + this + ) + +;; definition of type collide-mesh-tri +(deftype collide-mesh-tri (structure) + "A triangle for foreground collision meshes." + ((vertex-index uint8 3) + (unused uint8) + (pat pat-surface) + ) + :pack-me + ) + +;; definition for method 3 of type collide-mesh-tri +(defmethod inspect ((this collide-mesh-tri)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-mesh-tri) + (format #t "~1Tvertex-index[3] @ #x~X~%" (-> this vertex-index)) + (format #t "~1Tunused: ~D~%" (-> this unused)) + (format #t "~1Tpat: ~D~%" (-> this pat)) + (label cfg-4) + this + ) + +;; definition of type collide-mesh +(deftype collide-mesh (basic) + "A collision mesh for foreground objects, +bound to the joint specified by `joint-id`." + ((joint-id int32) + (num-tris uint32) + (num-verts uint32) + (vertex-data (inline-array vector)) + (tris collide-mesh-tri 1 :inline :offset 32) + ) + (:methods + (debug-draw-tris (_type_ process-drawable int) none) + (overlap-test (_type_ collide-mesh-cache-tri vector) symbol) + (should-push-away-test (_type_ collide-mesh-cache-tri collide-tri-result vector float) float) + (sphere-on-platform-test (_type_ collide-mesh-cache-tri collide-tri-result vector float) float) + (unpack-mesh-to-cache! (_type_ (inline-array collide-mesh-cache-tri) matrix) none) + (collide-mesh-math-1 (_type_ object object) none) + (collide-mesh-math-2 (_type_ object object object) none) + ) + ) + +;; definition for method 3 of type collide-mesh +(defmethod inspect ((this collide-mesh)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tjoint-id: ~D~%" (-> this joint-id)) + (format #t "~1Tnum-tris: ~D~%" (-> this num-tris)) + (format #t "~1Tnum-verts: ~D~%" (-> this num-verts)) + (format #t "~1Tvertex-data: #x~X~%" (-> this vertex-data)) + (format #t "~1Ttris[1] @ #x~X~%" (-> this tris)) + (label cfg-4) + this + ) + +;; definition of type collide-mesh-cache-tri +(deftype collide-mesh-cache-tri (structure) + "A triangle stored in the foreground mesh collide cache." + ((vertex vector 3 :inline) + (normal vector :inline) + (bbox4w bounding-box4w :inline) + (pat pat-surface :overlay-at (-> normal data 3)) + ) + ) + +;; definition for method 3 of type collide-mesh-cache-tri +(defmethod inspect ((this collide-mesh-cache-tri)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-mesh-cache-tri) + (format #t "~1Tvertex[3] @ #x~X~%" (-> this vertex)) + (format #t "~1Tnormal: ~`vector`P~%" (-> this normal)) + (format #t "~1Tbbox4w: #~%" (-> this bbox4w)) + (format #t "~1Tpat: ~D~%" (-> this pat)) + (label cfg-4) + this + ) + +;; definition of type collide-mesh-cache-entry +(deftype collide-mesh-cache-entry (structure) + "A foreground mesh collide cache entry." + ((mat matrix :inline) + (tris collide-mesh-cache-tri :inline :dynamic) + ) + ) + +;; definition for method 3 of type collide-mesh-cache-entry +(defmethod inspect ((this collide-mesh-cache-entry)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-mesh-cache-entry) + (format #t "~1Tmat: #~%" (-> this mat)) + (format #t "~1Ttris[0] @ #x~X~%" (-> this tris)) + (label cfg-4) + this + ) + +;; definition of type collide-mesh-cache +(deftype collide-mesh-cache (basic) + "A collide cache for foreground meshes." + ((used-size uint32) + (max-size uint32) + (id uint32) + (data uint8 48000) + ) + (:methods + (populate-for-prim-mesh (_type_ collide-shape-prim-mesh) collide-mesh-cache-entry) + (is-id? (_type_ int) symbol) + (next-id! (_type_) uint) + (allocate! (_type_ int) collide-mesh-cache-entry) + ) + ) + +;; definition for method 3 of type collide-mesh-cache +(defmethod inspect ((this collide-mesh-cache)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tused-size: ~D~%" (-> this used-size)) + (format #t "~1Tmax-size: ~D~%" (-> this max-size)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tdata[48000] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition for method 11 of type collide-mesh-cache +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 10 of type collide-mesh-cache +(defmethod is-id? ((this collide-mesh-cache) (id int)) + "Does this cache have the given ID?" + (= (-> this id) id) + ) + +;; failed to figure out what this is: +(kmemopen global "collide-mesh-cache") + +;; definition (perm) for symbol *collide-mesh-cache*, type collide-mesh-cache +(define-perm *collide-mesh-cache* collide-mesh-cache (new 'global 'collide-mesh-cache)) + +;; failed to figure out what this is: +(set! (-> *collide-mesh-cache* id) (the-as uint 1)) + +;; failed to figure out what this is: +(set! (-> *collide-mesh-cache* used-size) (the-as uint 0)) + +;; failed to figure out what this is: +(set! (-> *collide-mesh-cache* max-size) (the-as uint #xbb80)) + +;; failed to figure out what this is: +(kmemclose) + + + + diff --git a/test/decompiler/reference/jakx/engine/collide/collide-shape-h_REF.gc b/test/decompiler/reference/jakx/engine/collide/collide-shape-h_REF.gc new file mode 100644 index 0000000000..0d26bf260f --- /dev/null +++ b/test/decompiler/reference/jakx/engine/collide/collide-shape-h_REF.gc @@ -0,0 +1,1660 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type collide-rider +(deftype collide-rider (structure) + "Something that rides a moving object." + ((rider-handle handle) + (sticky-prim collide-shape-prim) + (prim-ry float) + (rider-local-pos vector :inline) + ) + ) + +;; definition for method 3 of type collide-rider +(defmethod inspect ((this collide-rider)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-rider) + (format #t "~1Trider-handle: ~D~%" (-> this rider-handle)) + (format #t "~1Tsticky-prim: ~A~%" (-> this sticky-prim)) + (format #t "~1Tprim-ry: ~f~%" (-> this prim-ry)) + (format #t "~1Trider-local-pos: #~%" (-> this rider-local-pos)) + (label cfg-4) + this + ) + +;; definition of type collide-rider-pool +(deftype collide-rider-pool (basic) + "A pool containing all the riders of an object." + ((alloc-count int32) + (riders collide-rider 20 :inline) + ) + (:methods + (add-rider (_type_ handle) collide-rider) + (prepare (_type_) none) + ) + ) + +;; definition for method 3 of type collide-rider-pool +(defmethod inspect ((this collide-rider-pool)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Talloc-count: ~D~%" (-> this alloc-count)) + (format #t "~1Triders[20] @ #x~X~%" (-> this riders)) + (label cfg-4) + this + ) + +;; definition for method 10 of type collide-rider-pool +;; WARN: Return type mismatch int vs none. +(defmethod prepare ((this collide-rider-pool)) + "Gets this pool ready to be used to allow allocations. This should be called once at the start of every frame." + (set! (-> this alloc-count) 0) + 0 + (none) + ) + +;; definition of type pull-rider-info +(deftype pull-rider-info (structure) + ((rider collide-rider) + (rider-cshape collide-shape-moving) + (rider-delta-ry float) + (rider-dest vector :inline) + ) + ) + +;; definition for method 3 of type pull-rider-info +(defmethod inspect ((this pull-rider-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'pull-rider-info) + (format #t "~1Trider: #~%" (-> this rider)) + (format #t "~1Trider-cshape: ~A~%" (-> this rider-cshape)) + (format #t "~1Trider-delta-ry: ~f~%" (-> this rider-delta-ry)) + (format #t "~1Trider-dest: #~%" (-> this rider-dest)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(kmemopen global "collide-lists") + +;; definition for symbol *collide-hit-by-player-list*, type engine +(define *collide-hit-by-player-list* (new 'global 'engine 'collide-hit-by-player-list 640 connection)) + +;; definition for symbol *collide-hit-by-others-list*, type engine +(define *collide-hit-by-others-list* (new 'global 'engine 'collide-hit-by-others-list 768 connection)) + +;; definition for symbol *collide-player-list*, type engine +(define *collide-player-list* (new 'global 'engine 'collide-player-list 32 connection)) + +;; failed to figure out what this is: +(kmemclose) + +;; definition of type overlaps-others-params +(deftype overlaps-others-params (structure) + ((options overlaps-others-options) + (collide-with-filter collide-spec) + (tlist touching-list) + (filtered-root-collide-with collide-spec) + (filtered-child-collide-with collide-spec) + (filtered-other-collide-as collide-spec) + ) + ) + +;; definition for method 3 of type overlaps-others-params +(defmethod inspect ((this overlaps-others-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'overlaps-others-params) + (format #t "~1Toptions: ~D~%" (-> this options)) + (format #t "~1Tcollide-with-filter: ~D~%" (-> this collide-with-filter)) + (format #t "~1Ttlist: ~A~%" (-> this tlist)) + (format #t "~1Tfiltered-root-collide-with: ~D~%" (-> this filtered-root-collide-with)) + (format #t "~1Tfiltered-child-collide-with: ~D~%" (-> this filtered-child-collide-with)) + (format #t "~1Tfiltered-other-collide-as: ~D~%" (-> this filtered-other-collide-as)) + (label cfg-4) + this + ) + +;; definition of type move-above-ground-params +(deftype move-above-ground-params (structure) + ((gnd-collide-with collide-spec) + (popup float) + (dont-move-if-overlaps? symbol) + (hover-if-no-ground? symbol) + (overlaps-params overlaps-others-params :inline) + (new-pos vector :inline) + (old-gspot-pos vector :inline) + (old-gspot-normal vector :inline) + (pat pat-surface) + (on-ground? symbol) + (do-move? symbol) + ) + ) + +;; definition for method 3 of type move-above-ground-params +(defmethod inspect ((this move-above-ground-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'move-above-ground-params) + (format #t "~1Tgnd-collide-with: ~D~%" (-> this gnd-collide-with)) + (format #t "~1Tpopup: ~f~%" (-> this popup)) + (format #t "~1Tdont-move-if-overlaps?: ~A~%" (-> this dont-move-if-overlaps?)) + (format #t "~1Thover-if-no-ground?: ~A~%" (-> this hover-if-no-ground?)) + (format #t "~1Toverlaps-params: #~%" (-> this overlaps-params)) + (format #t "~1Tnew-pos: #~%" (-> this new-pos)) + (format #t "~1Told-gspot-pos: #~%" (-> this old-gspot-pos)) + (format #t "~1Told-gspot-normal: #~%" (-> this old-gspot-normal)) + (format #t "~1Tpat: ~D~%" (-> this pat)) + (format #t "~1Ton-ground?: ~A~%" (-> this on-ground?)) + (format #t "~1Tdo-move?: ~A~%" (-> this do-move?)) + (label cfg-4) + this + ) + +;; definition of type collide-prim-core +(deftype collide-prim-core (structure) + "Collide primitives use this to store their world sphere and their collision flags." + ((world-sphere vector :inline) + (collide-as collide-spec) + (collide-with collide-spec) + (action collide-action) + (prim-type int8) + (unused1 uint8 3) + (quad uint128 2 :overlay-at (-> world-sphere data 0)) + ) + ) + +;; definition for method 3 of type collide-prim-core +(defmethod inspect ((this collide-prim-core)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-prim-core) + (format #t "~1Tworld-sphere: ~`vector`P~%" (-> this world-sphere)) + (format #t "~1Tcollide-as: ~D~%" (-> this collide-as)) + (format #t "~1Tcollide-with: ~D~%" (-> this collide-with)) + (format #t "~1Taction: ~D~%" (-> this action)) + (format #t "~1Tprim-type: ~D~%" (-> this prim-type)) + (format #t "~1Tunused1[3] @ #x~X~%" (-> this unused1)) + (format #t "~1Tquad[2] @ #x~X~%" (-> this world-sphere)) + (label cfg-4) + this + ) + +;; definition of type collide-shape-prim +(deftype collide-shape-prim (basic) + "Base class for collide primitives." + ((cshape collide-shape) + (prim-id uint32) + (transform-index int8) + (unused2 int8 3) + (prim-core collide-prim-core :inline :offset 16) + (local-sphere vector :inline :offset 48) + (specific uint8 16 :offset 64) + (world-sphere vector :inline :overlay-at (-> prim-core quad 0)) + (collide-as collide-spec :overlay-at (-> prim-core quad 1)) + (collide-with collide-spec :offset 36) + (action collide-action :offset 40) + (prim-type int8 :offset 44) + (radius meters :overlay-at (-> local-sphere w)) + ) + (:methods + (new (symbol type collide-shape uint int) _type_) + (debug-draw (_type_) none) + (add-fg-prim-using-box (_type_ collide-cache) none) + (add-fg-prim-using-line-sphere (_type_ collide-cache object) none) + (overlaps-others-test (_type_ overlaps-others-params collide-shape-prim) symbol) + (overlaps-others-group (_type_ overlaps-others-params collide-shape-prim-group) symbol) + (collide-shape-prim-method-14 () none) + (collide-with-collide-cache-prim-mesh (_type_ collide-query collide-cache-prim) none) + (collide-with-collide-cache-prim-sphere (_type_ collide-query collide-cache-prim) none) + (on-platform-test (_type_ collide-shape-prim collide-query float) none) + (should-push-away-test (_type_ collide-shape-prim collide-query) none) + (should-push-away-a-group-test (_type_ collide-shape-prim-group collide-query) none) + ) + ) + +;; definition for method 3 of type collide-shape-prim +(defmethod inspect ((this collide-shape-prim)) + (when (not this) + (set! this this) + (goto cfg-150) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tcshape: ~A~%" (-> this cshape)) + (format #t "~1Tprim-id: #x~X~%" (-> this prim-id)) + (format #t "~1Ttransform-index: ~D~%" (-> this transform-index)) + (format #t "~1Tunused2[3] @ #x~X~%" (-> this unused2)) + (format #t "~1Tprim-core: #~%" (-> this prim-core)) + (format #t "~1Tlocal-sphere: ~`vector`P~%" (-> this local-sphere)) + (format #t "~1Tspecific[16] @ #x~X~%" (-> this specific)) + (format #t "~1Tworld-sphere: ~`vector`P~%" (-> this prim-core)) + (format #t "~1Tcollide-as: #x~X : (collide-spec " (-> this prim-core collide-as)) + (let ((s5-0 (-> this prim-core collide-as))) + (if (= (logand (collide-spec special-obstacle) s5-0) (collide-spec special-obstacle)) + (format #t "special-obstacle ") + ) + (if (= (logand (collide-spec bot-targetable) s5-0) (collide-spec bot-targetable)) + (format #t "bot-targetable ") + ) + (if (= (logand (collide-spec coliseum-ball) s5-0) (collide-spec coliseum-ball)) + (format #t "coliseum-ball ") + ) + (if (= (logand s5-0 (collide-spec collectable)) (collide-spec collectable)) + (format #t "collectable ") + ) + (if (= (logand s5-0 (collide-spec projectile)) (collide-spec projectile)) + (format #t "projectile ") + ) + (if (= (logand (collide-spec obstacle-for-jak) s5-0) (collide-spec obstacle-for-jak)) + (format #t "obstacle-for-jak ") + ) + (if (= (logand s5-0 (collide-spec bot)) (collide-spec bot)) + (format #t "bot ") + ) + (if (= (logand s5-0 (collide-spec blocking-plane)) (collide-spec blocking-plane)) + (format #t "blocking-plane ") + ) + (if (= (logand s5-0 (collide-spec enemy)) (collide-spec enemy)) + (format #t "enemy ") + ) + (if (= (logand s5-0 (collide-spec hit-by-player-list)) (collide-spec hit-by-player-list)) + (format #t "hit-by-player-list ") + ) + (if (= (logand s5-0 (collide-spec obstacle)) (collide-spec obstacle)) + (format #t "obstacle ") + ) + (if (= (logand s5-0 (collide-spec water)) (collide-spec water)) + (format #t "water ") + ) + (if (= (logand s5-0 (collide-spec civilian)) (collide-spec civilian)) + (format #t "civilian ") + ) + (if (= (logand (collide-spec vehicle-sphere-no-probe) s5-0) (collide-spec vehicle-sphere-no-probe)) + (format #t "vehicle-sphere-no-probe ") + ) + (if (= (logand (collide-spec shield) s5-0) (collide-spec shield)) + (format #t "shield ") + ) + (if (= (logand s5-0 (collide-spec player-list)) (collide-spec player-list)) + (format #t "player-list ") + ) + (if (= (logand s5-0 (collide-spec backgnd)) (collide-spec backgnd)) + (format #t "backgnd ") + ) + (if (= (logand s5-0 (collide-spec vehicle-debris)) (collide-spec vehicle-debris)) + (format #t "vehicle-debris ") + ) + (if (= (logand s5-0 (collide-spec jak)) (collide-spec jak)) + (format #t "jak ") + ) + (if (= (logand (collide-spec impenetrable-obj) s5-0) (collide-spec impenetrable-obj)) + (format #t "impenetrable-obj ") + ) + (if (= (logand (collide-spec pusher) s5-0) (collide-spec pusher)) + (format #t "pusher ") + ) + (if (= (logand (collide-spec los-blocker) s5-0) (collide-spec los-blocker)) + (format #t "los-blocker ") + ) + (if (= (logand (collide-spec jak-vulnerable) s5-0) (collide-spec jak-vulnerable)) + (format #t "jak-vulnerable ") + ) + (if (= (logand (collide-spec camera-blocker) s5-0) (collide-spec camera-blocker)) + (format #t "camera-blocker ") + ) + (if (= (logand s5-0 (collide-spec hit-by-others-list)) (collide-spec hit-by-others-list)) + (format #t "hit-by-others-list ") + ) + (if (= (logand s5-0 (collide-spec crate)) (collide-spec crate)) + (format #t "crate ") + ) + (if (= (logand (collide-spec nav-mesh) s5-0) (collide-spec nav-mesh)) + (format #t "nav-mesh ") + ) + (if (= (logand s5-0 (collide-spec vehicle-sphere)) (collide-spec vehicle-sphere)) + (format #t "vehicle-sphere ") + ) + ) + (format #t ")~%") + (format #t "~1Tcollide-with: #x~X : (collide-spec " (-> this prim-core collide-with)) + (let ((s5-1 (-> this prim-core collide-with))) + (if (= (logand (collide-spec special-obstacle) s5-1) (collide-spec special-obstacle)) + (format #t "special-obstacle ") + ) + (if (= (logand (collide-spec bot-targetable) s5-1) (collide-spec bot-targetable)) + (format #t "bot-targetable ") + ) + (if (= (logand (collide-spec coliseum-ball) s5-1) (collide-spec coliseum-ball)) + (format #t "coliseum-ball ") + ) + (if (= (logand s5-1 (collide-spec collectable)) (collide-spec collectable)) + (format #t "collectable ") + ) + (if (= (logand s5-1 (collide-spec projectile)) (collide-spec projectile)) + (format #t "projectile ") + ) + (if (= (logand (collide-spec obstacle-for-jak) s5-1) (collide-spec obstacle-for-jak)) + (format #t "obstacle-for-jak ") + ) + (if (= (logand s5-1 (collide-spec bot)) (collide-spec bot)) + (format #t "bot ") + ) + (if (= (logand s5-1 (collide-spec blocking-plane)) (collide-spec blocking-plane)) + (format #t "blocking-plane ") + ) + (if (= (logand s5-1 (collide-spec enemy)) (collide-spec enemy)) + (format #t "enemy ") + ) + (if (= (logand s5-1 (collide-spec hit-by-player-list)) (collide-spec hit-by-player-list)) + (format #t "hit-by-player-list ") + ) + (if (= (logand s5-1 (collide-spec obstacle)) (collide-spec obstacle)) + (format #t "obstacle ") + ) + (if (= (logand s5-1 (collide-spec water)) (collide-spec water)) + (format #t "water ") + ) + (if (= (logand s5-1 (collide-spec civilian)) (collide-spec civilian)) + (format #t "civilian ") + ) + (if (= (logand (collide-spec vehicle-sphere-no-probe) s5-1) (collide-spec vehicle-sphere-no-probe)) + (format #t "vehicle-sphere-no-probe ") + ) + (if (= (logand (collide-spec shield) s5-1) (collide-spec shield)) + (format #t "shield ") + ) + (if (= (logand s5-1 (collide-spec player-list)) (collide-spec player-list)) + (format #t "player-list ") + ) + (if (= (logand s5-1 (collide-spec backgnd)) (collide-spec backgnd)) + (format #t "backgnd ") + ) + (if (= (logand s5-1 (collide-spec vehicle-debris)) (collide-spec vehicle-debris)) + (format #t "vehicle-debris ") + ) + (if (= (logand s5-1 (collide-spec jak)) (collide-spec jak)) + (format #t "jak ") + ) + (if (= (logand (collide-spec impenetrable-obj) s5-1) (collide-spec impenetrable-obj)) + (format #t "impenetrable-obj ") + ) + (if (= (logand (collide-spec pusher) s5-1) (collide-spec pusher)) + (format #t "pusher ") + ) + (if (= (logand (collide-spec los-blocker) s5-1) (collide-spec los-blocker)) + (format #t "los-blocker ") + ) + (if (= (logand (collide-spec jak-vulnerable) s5-1) (collide-spec jak-vulnerable)) + (format #t "jak-vulnerable ") + ) + (if (= (logand (collide-spec camera-blocker) s5-1) (collide-spec camera-blocker)) + (format #t "camera-blocker ") + ) + (if (= (logand s5-1 (collide-spec hit-by-others-list)) (collide-spec hit-by-others-list)) + (format #t "hit-by-others-list ") + ) + (if (= (logand s5-1 (collide-spec crate)) (collide-spec crate)) + (format #t "crate ") + ) + (if (= (logand (collide-spec nav-mesh) s5-1) (collide-spec nav-mesh)) + (format #t "nav-mesh ") + ) + (if (= (logand s5-1 (collide-spec vehicle-sphere)) (collide-spec vehicle-sphere)) + (format #t "vehicle-sphere ") + ) + ) + (format #t ")~%") + (format #t "~1Taction: #x~X : (collide-action " (-> this prim-core action)) + (let ((s5-2 (-> this prim-core action))) + (if (= (logand s5-2 (collide-action deadly)) (collide-action deadly)) + (format #t "deadly ") + ) + (if (= (logand s5-2 (collide-action rideable)) (collide-action rideable)) + (format #t "rideable ") + ) + (if (= (logand s5-2 (collide-action can-ride)) (collide-action can-ride)) + (format #t "can-ride ") + ) + (if (= (logand s5-2 (collide-action persistent-attack)) (collide-action persistent-attack)) + (format #t "persistent-attack ") + ) + (if (= (logand (collide-action nav-sphere) s5-2) (collide-action nav-sphere)) + (format #t "nav-sphere ") + ) + (if (= (logand s5-2 (collide-action block-turn-around)) (collide-action block-turn-around)) + (format #t "block-turn-around ") + ) + (if (= (logand s5-2 (collide-action pull-rider-can-collide)) (collide-action pull-rider-can-collide)) + (format #t "pull-rider-can-collide ") + ) + (if (= (logand s5-2 (collide-action no-standon)) (collide-action no-standon)) + (format #t "no-standon ") + ) + (if (= (logand s5-2 (collide-action dont-push-away)) (collide-action dont-push-away)) + (format #t "dont-push-away ") + ) + (if (= (logand s5-2 (collide-action check-stuck)) (collide-action check-stuck)) + (format #t "check-stuck ") + ) + (if (= (logand s5-2 (collide-action no-smack)) (collide-action no-smack)) + (format #t "no-smack ") + ) + (if (= (logand s5-2 (collide-action semi-solid)) (collide-action semi-solid)) + (format #t "semi-solid ") + ) + (if (= (logand s5-2 (collide-action edge-grabbed)) (collide-action edge-grabbed)) + (format #t "edge-grabbed ") + ) + (if (= (logand s5-2 (collide-action stuck-wall-escape)) (collide-action stuck-wall-escape)) + (format #t "stuck-wall-escape ") + ) + (if (= (logand s5-2 (collide-action check-edge)) (collide-action check-edge)) + (format #t "check-edge ") + ) + (if (= (logand s5-2 (collide-action no-normal-reset)) (collide-action no-normal-reset)) + (format #t "no-normal-reset ") + ) + (if (= (logand s5-2 (collide-action solid)) (collide-action solid)) + (format #t "solid ") + ) + ) + (format #t ")~%") + (format #t "~1Tprim-type: ~D~%" (-> this prim-core prim-type)) + (format #t "~1Tradius: (meters ~m)~%" (-> this local-sphere w)) + (label cfg-150) + this + ) + +;; definition of type collide-shape-prim-sphere +(deftype collide-shape-prim-sphere (collide-shape-prim) + "A sphere primitive for collide shapes." + ((pat pat-surface :overlay-at (-> specific 0)) + (nav-radius float :overlay-at (-> specific 4)) + (line-sphere-count int8 :overlay-at (-> specific 8)) + (line-sphere-prim-id int8 :overlay-at (-> specific 9)) + ) + (:methods + (new (symbol type collide-shape uint) _type_) + ) + ) + +;; definition for method 3 of type collide-shape-prim-sphere +(defmethod inspect ((this collide-shape-prim-sphere)) + (when (not this) + (set! this this) + (goto cfg-150) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tcshape: ~A~%" (-> this cshape)) + (format #t "~1Tprim-id: #x~X~%" (-> this prim-id)) + (format #t "~1Ttransform-index: ~D~%" (-> this transform-index)) + (format #t "~1Tunused2[3] @ #x~X~%" (-> this unused2)) + (format #t "~1Tprim-core: #~%" (-> this prim-core)) + (format #t "~1Tlocal-sphere: ~`vector`P~%" (-> this local-sphere)) + (format #t "~1Tspecific[16] @ #x~X~%" (&-> this pat)) + (format #t "~1Tworld-sphere: ~`vector`P~%" (-> this prim-core)) + (format #t "~1Tcollide-as: #x~X : (collide-spec " (-> this prim-core collide-as)) + (let ((s5-0 (-> this prim-core collide-as))) + (if (= (logand (collide-spec special-obstacle) s5-0) (collide-spec special-obstacle)) + (format #t "special-obstacle ") + ) + (if (= (logand (collide-spec bot-targetable) s5-0) (collide-spec bot-targetable)) + (format #t "bot-targetable ") + ) + (if (= (logand (collide-spec coliseum-ball) s5-0) (collide-spec coliseum-ball)) + (format #t "coliseum-ball ") + ) + (if (= (logand s5-0 (collide-spec collectable)) (collide-spec collectable)) + (format #t "collectable ") + ) + (if (= (logand s5-0 (collide-spec projectile)) (collide-spec projectile)) + (format #t "projectile ") + ) + (if (= (logand (collide-spec obstacle-for-jak) s5-0) (collide-spec obstacle-for-jak)) + (format #t "obstacle-for-jak ") + ) + (if (= (logand s5-0 (collide-spec bot)) (collide-spec bot)) + (format #t "bot ") + ) + (if (= (logand s5-0 (collide-spec blocking-plane)) (collide-spec blocking-plane)) + (format #t "blocking-plane ") + ) + (if (= (logand s5-0 (collide-spec enemy)) (collide-spec enemy)) + (format #t "enemy ") + ) + (if (= (logand s5-0 (collide-spec hit-by-player-list)) (collide-spec hit-by-player-list)) + (format #t "hit-by-player-list ") + ) + (if (= (logand s5-0 (collide-spec obstacle)) (collide-spec obstacle)) + (format #t "obstacle ") + ) + (if (= (logand s5-0 (collide-spec water)) (collide-spec water)) + (format #t "water ") + ) + (if (= (logand s5-0 (collide-spec civilian)) (collide-spec civilian)) + (format #t "civilian ") + ) + (if (= (logand (collide-spec vehicle-sphere-no-probe) s5-0) (collide-spec vehicle-sphere-no-probe)) + (format #t "vehicle-sphere-no-probe ") + ) + (if (= (logand (collide-spec shield) s5-0) (collide-spec shield)) + (format #t "shield ") + ) + (if (= (logand s5-0 (collide-spec player-list)) (collide-spec player-list)) + (format #t "player-list ") + ) + (if (= (logand s5-0 (collide-spec backgnd)) (collide-spec backgnd)) + (format #t "backgnd ") + ) + (if (= (logand s5-0 (collide-spec vehicle-debris)) (collide-spec vehicle-debris)) + (format #t "vehicle-debris ") + ) + (if (= (logand s5-0 (collide-spec jak)) (collide-spec jak)) + (format #t "jak ") + ) + (if (= (logand (collide-spec impenetrable-obj) s5-0) (collide-spec impenetrable-obj)) + (format #t "impenetrable-obj ") + ) + (if (= (logand (collide-spec pusher) s5-0) (collide-spec pusher)) + (format #t "pusher ") + ) + (if (= (logand (collide-spec los-blocker) s5-0) (collide-spec los-blocker)) + (format #t "los-blocker ") + ) + (if (= (logand (collide-spec jak-vulnerable) s5-0) (collide-spec jak-vulnerable)) + (format #t "jak-vulnerable ") + ) + (if (= (logand (collide-spec camera-blocker) s5-0) (collide-spec camera-blocker)) + (format #t "camera-blocker ") + ) + (if (= (logand s5-0 (collide-spec hit-by-others-list)) (collide-spec hit-by-others-list)) + (format #t "hit-by-others-list ") + ) + (if (= (logand s5-0 (collide-spec crate)) (collide-spec crate)) + (format #t "crate ") + ) + (if (= (logand (collide-spec nav-mesh) s5-0) (collide-spec nav-mesh)) + (format #t "nav-mesh ") + ) + (if (= (logand s5-0 (collide-spec vehicle-sphere)) (collide-spec vehicle-sphere)) + (format #t "vehicle-sphere ") + ) + ) + (format #t ")~%") + (format #t "~1Tcollide-with: #x~X : (collide-spec " (-> this prim-core collide-with)) + (let ((s5-1 (-> this prim-core collide-with))) + (if (= (logand (collide-spec special-obstacle) s5-1) (collide-spec special-obstacle)) + (format #t "special-obstacle ") + ) + (if (= (logand (collide-spec bot-targetable) s5-1) (collide-spec bot-targetable)) + (format #t "bot-targetable ") + ) + (if (= (logand (collide-spec coliseum-ball) s5-1) (collide-spec coliseum-ball)) + (format #t "coliseum-ball ") + ) + (if (= (logand s5-1 (collide-spec collectable)) (collide-spec collectable)) + (format #t "collectable ") + ) + (if (= (logand s5-1 (collide-spec projectile)) (collide-spec projectile)) + (format #t "projectile ") + ) + (if (= (logand (collide-spec obstacle-for-jak) s5-1) (collide-spec obstacle-for-jak)) + (format #t "obstacle-for-jak ") + ) + (if (= (logand s5-1 (collide-spec bot)) (collide-spec bot)) + (format #t "bot ") + ) + (if (= (logand s5-1 (collide-spec blocking-plane)) (collide-spec blocking-plane)) + (format #t "blocking-plane ") + ) + (if (= (logand s5-1 (collide-spec enemy)) (collide-spec enemy)) + (format #t "enemy ") + ) + (if (= (logand s5-1 (collide-spec hit-by-player-list)) (collide-spec hit-by-player-list)) + (format #t "hit-by-player-list ") + ) + (if (= (logand s5-1 (collide-spec obstacle)) (collide-spec obstacle)) + (format #t "obstacle ") + ) + (if (= (logand s5-1 (collide-spec water)) (collide-spec water)) + (format #t "water ") + ) + (if (= (logand s5-1 (collide-spec civilian)) (collide-spec civilian)) + (format #t "civilian ") + ) + (if (= (logand (collide-spec vehicle-sphere-no-probe) s5-1) (collide-spec vehicle-sphere-no-probe)) + (format #t "vehicle-sphere-no-probe ") + ) + (if (= (logand (collide-spec shield) s5-1) (collide-spec shield)) + (format #t "shield ") + ) + (if (= (logand s5-1 (collide-spec player-list)) (collide-spec player-list)) + (format #t "player-list ") + ) + (if (= (logand s5-1 (collide-spec backgnd)) (collide-spec backgnd)) + (format #t "backgnd ") + ) + (if (= (logand s5-1 (collide-spec vehicle-debris)) (collide-spec vehicle-debris)) + (format #t "vehicle-debris ") + ) + (if (= (logand s5-1 (collide-spec jak)) (collide-spec jak)) + (format #t "jak ") + ) + (if (= (logand (collide-spec impenetrable-obj) s5-1) (collide-spec impenetrable-obj)) + (format #t "impenetrable-obj ") + ) + (if (= (logand (collide-spec pusher) s5-1) (collide-spec pusher)) + (format #t "pusher ") + ) + (if (= (logand (collide-spec los-blocker) s5-1) (collide-spec los-blocker)) + (format #t "los-blocker ") + ) + (if (= (logand (collide-spec jak-vulnerable) s5-1) (collide-spec jak-vulnerable)) + (format #t "jak-vulnerable ") + ) + (if (= (logand (collide-spec camera-blocker) s5-1) (collide-spec camera-blocker)) + (format #t "camera-blocker ") + ) + (if (= (logand s5-1 (collide-spec hit-by-others-list)) (collide-spec hit-by-others-list)) + (format #t "hit-by-others-list ") + ) + (if (= (logand s5-1 (collide-spec crate)) (collide-spec crate)) + (format #t "crate ") + ) + (if (= (logand (collide-spec nav-mesh) s5-1) (collide-spec nav-mesh)) + (format #t "nav-mesh ") + ) + (if (= (logand s5-1 (collide-spec vehicle-sphere)) (collide-spec vehicle-sphere)) + (format #t "vehicle-sphere ") + ) + ) + (format #t ")~%") + (format #t "~1Taction: #x~X : (collide-action " (-> this prim-core action)) + (let ((s5-2 (-> this prim-core action))) + (if (= (logand s5-2 (collide-action deadly)) (collide-action deadly)) + (format #t "deadly ") + ) + (if (= (logand s5-2 (collide-action rideable)) (collide-action rideable)) + (format #t "rideable ") + ) + (if (= (logand s5-2 (collide-action can-ride)) (collide-action can-ride)) + (format #t "can-ride ") + ) + (if (= (logand s5-2 (collide-action persistent-attack)) (collide-action persistent-attack)) + (format #t "persistent-attack ") + ) + (if (= (logand (collide-action nav-sphere) s5-2) (collide-action nav-sphere)) + (format #t "nav-sphere ") + ) + (if (= (logand s5-2 (collide-action block-turn-around)) (collide-action block-turn-around)) + (format #t "block-turn-around ") + ) + (if (= (logand s5-2 (collide-action pull-rider-can-collide)) (collide-action pull-rider-can-collide)) + (format #t "pull-rider-can-collide ") + ) + (if (= (logand s5-2 (collide-action no-standon)) (collide-action no-standon)) + (format #t "no-standon ") + ) + (if (= (logand s5-2 (collide-action dont-push-away)) (collide-action dont-push-away)) + (format #t "dont-push-away ") + ) + (if (= (logand s5-2 (collide-action check-stuck)) (collide-action check-stuck)) + (format #t "check-stuck ") + ) + (if (= (logand s5-2 (collide-action no-smack)) (collide-action no-smack)) + (format #t "no-smack ") + ) + (if (= (logand s5-2 (collide-action semi-solid)) (collide-action semi-solid)) + (format #t "semi-solid ") + ) + (if (= (logand s5-2 (collide-action edge-grabbed)) (collide-action edge-grabbed)) + (format #t "edge-grabbed ") + ) + (if (= (logand s5-2 (collide-action stuck-wall-escape)) (collide-action stuck-wall-escape)) + (format #t "stuck-wall-escape ") + ) + (if (= (logand s5-2 (collide-action check-edge)) (collide-action check-edge)) + (format #t "check-edge ") + ) + (if (= (logand s5-2 (collide-action no-normal-reset)) (collide-action no-normal-reset)) + (format #t "no-normal-reset ") + ) + (if (= (logand s5-2 (collide-action solid)) (collide-action solid)) + (format #t "solid ") + ) + ) + (format #t ")~%") + (format #t "~1Tprim-type: ~D~%" (-> this prim-core prim-type)) + (format #t "~1Tradius: (meters ~m)~%" (-> this local-sphere w)) + (format #t "~1Tpat: ~D~%" (-> this pat)) + (format #t "~1Tnav-radius: ~f~%" (-> this nav-radius)) + (format #t "~1Tline-sphere-count: ~D~%" (-> this line-sphere-count)) + (format #t "~1Tline-sphere-prim-id: ~D~%" (-> this line-sphere-prim-id)) + (label cfg-150) + this + ) + +;; definition of type collide-shape-prim-mesh +(deftype collide-shape-prim-mesh (collide-shape-prim) + "A mesh primitive for collide shapes." + ((mesh collide-mesh :overlay-at (-> specific 0)) + (mesh-id int32 :overlay-at (-> specific 4)) + (mesh-cache-id uint32 :overlay-at (-> specific 8)) + (mesh-cache-entry collide-mesh-cache-entry :overlay-at (-> specific 12)) + ) + (:methods + (new (symbol type collide-shape uint uint) _type_) + ) + ) + +;; definition for method 3 of type collide-shape-prim-mesh +(defmethod inspect ((this collide-shape-prim-mesh)) + (when (not this) + (set! this this) + (goto cfg-150) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tcshape: ~A~%" (-> this cshape)) + (format #t "~1Tprim-id: #x~X~%" (-> this prim-id)) + (format #t "~1Ttransform-index: ~D~%" (-> this transform-index)) + (format #t "~1Tunused2[3] @ #x~X~%" (-> this unused2)) + (format #t "~1Tprim-core: #~%" (-> this prim-core)) + (format #t "~1Tlocal-sphere: ~`vector`P~%" (-> this local-sphere)) + (format #t "~1Tspecific[16] @ #x~X~%" (&-> this mesh)) + (format #t "~1Tworld-sphere: ~`vector`P~%" (-> this prim-core)) + (format #t "~1Tcollide-as: #x~X : (collide-spec " (-> this prim-core collide-as)) + (let ((s5-0 (-> this prim-core collide-as))) + (if (= (logand (collide-spec special-obstacle) s5-0) (collide-spec special-obstacle)) + (format #t "special-obstacle ") + ) + (if (= (logand (collide-spec bot-targetable) s5-0) (collide-spec bot-targetable)) + (format #t "bot-targetable ") + ) + (if (= (logand (collide-spec coliseum-ball) s5-0) (collide-spec coliseum-ball)) + (format #t "coliseum-ball ") + ) + (if (= (logand s5-0 (collide-spec collectable)) (collide-spec collectable)) + (format #t "collectable ") + ) + (if (= (logand s5-0 (collide-spec projectile)) (collide-spec projectile)) + (format #t "projectile ") + ) + (if (= (logand (collide-spec obstacle-for-jak) s5-0) (collide-spec obstacle-for-jak)) + (format #t "obstacle-for-jak ") + ) + (if (= (logand s5-0 (collide-spec bot)) (collide-spec bot)) + (format #t "bot ") + ) + (if (= (logand s5-0 (collide-spec blocking-plane)) (collide-spec blocking-plane)) + (format #t "blocking-plane ") + ) + (if (= (logand s5-0 (collide-spec enemy)) (collide-spec enemy)) + (format #t "enemy ") + ) + (if (= (logand s5-0 (collide-spec hit-by-player-list)) (collide-spec hit-by-player-list)) + (format #t "hit-by-player-list ") + ) + (if (= (logand s5-0 (collide-spec obstacle)) (collide-spec obstacle)) + (format #t "obstacle ") + ) + (if (= (logand s5-0 (collide-spec water)) (collide-spec water)) + (format #t "water ") + ) + (if (= (logand s5-0 (collide-spec civilian)) (collide-spec civilian)) + (format #t "civilian ") + ) + (if (= (logand (collide-spec vehicle-sphere-no-probe) s5-0) (collide-spec vehicle-sphere-no-probe)) + (format #t "vehicle-sphere-no-probe ") + ) + (if (= (logand (collide-spec shield) s5-0) (collide-spec shield)) + (format #t "shield ") + ) + (if (= (logand s5-0 (collide-spec player-list)) (collide-spec player-list)) + (format #t "player-list ") + ) + (if (= (logand s5-0 (collide-spec backgnd)) (collide-spec backgnd)) + (format #t "backgnd ") + ) + (if (= (logand s5-0 (collide-spec vehicle-debris)) (collide-spec vehicle-debris)) + (format #t "vehicle-debris ") + ) + (if (= (logand s5-0 (collide-spec jak)) (collide-spec jak)) + (format #t "jak ") + ) + (if (= (logand (collide-spec impenetrable-obj) s5-0) (collide-spec impenetrable-obj)) + (format #t "impenetrable-obj ") + ) + (if (= (logand (collide-spec pusher) s5-0) (collide-spec pusher)) + (format #t "pusher ") + ) + (if (= (logand (collide-spec los-blocker) s5-0) (collide-spec los-blocker)) + (format #t "los-blocker ") + ) + (if (= (logand (collide-spec jak-vulnerable) s5-0) (collide-spec jak-vulnerable)) + (format #t "jak-vulnerable ") + ) + (if (= (logand (collide-spec camera-blocker) s5-0) (collide-spec camera-blocker)) + (format #t "camera-blocker ") + ) + (if (= (logand s5-0 (collide-spec hit-by-others-list)) (collide-spec hit-by-others-list)) + (format #t "hit-by-others-list ") + ) + (if (= (logand s5-0 (collide-spec crate)) (collide-spec crate)) + (format #t "crate ") + ) + (if (= (logand (collide-spec nav-mesh) s5-0) (collide-spec nav-mesh)) + (format #t "nav-mesh ") + ) + (if (= (logand s5-0 (collide-spec vehicle-sphere)) (collide-spec vehicle-sphere)) + (format #t "vehicle-sphere ") + ) + ) + (format #t ")~%") + (format #t "~1Tcollide-with: #x~X : (collide-spec " (-> this prim-core collide-with)) + (let ((s5-1 (-> this prim-core collide-with))) + (if (= (logand (collide-spec special-obstacle) s5-1) (collide-spec special-obstacle)) + (format #t "special-obstacle ") + ) + (if (= (logand (collide-spec bot-targetable) s5-1) (collide-spec bot-targetable)) + (format #t "bot-targetable ") + ) + (if (= (logand (collide-spec coliseum-ball) s5-1) (collide-spec coliseum-ball)) + (format #t "coliseum-ball ") + ) + (if (= (logand s5-1 (collide-spec collectable)) (collide-spec collectable)) + (format #t "collectable ") + ) + (if (= (logand s5-1 (collide-spec projectile)) (collide-spec projectile)) + (format #t "projectile ") + ) + (if (= (logand (collide-spec obstacle-for-jak) s5-1) (collide-spec obstacle-for-jak)) + (format #t "obstacle-for-jak ") + ) + (if (= (logand s5-1 (collide-spec bot)) (collide-spec bot)) + (format #t "bot ") + ) + (if (= (logand s5-1 (collide-spec blocking-plane)) (collide-spec blocking-plane)) + (format #t "blocking-plane ") + ) + (if (= (logand s5-1 (collide-spec enemy)) (collide-spec enemy)) + (format #t "enemy ") + ) + (if (= (logand s5-1 (collide-spec hit-by-player-list)) (collide-spec hit-by-player-list)) + (format #t "hit-by-player-list ") + ) + (if (= (logand s5-1 (collide-spec obstacle)) (collide-spec obstacle)) + (format #t "obstacle ") + ) + (if (= (logand s5-1 (collide-spec water)) (collide-spec water)) + (format #t "water ") + ) + (if (= (logand s5-1 (collide-spec civilian)) (collide-spec civilian)) + (format #t "civilian ") + ) + (if (= (logand (collide-spec vehicle-sphere-no-probe) s5-1) (collide-spec vehicle-sphere-no-probe)) + (format #t "vehicle-sphere-no-probe ") + ) + (if (= (logand (collide-spec shield) s5-1) (collide-spec shield)) + (format #t "shield ") + ) + (if (= (logand s5-1 (collide-spec player-list)) (collide-spec player-list)) + (format #t "player-list ") + ) + (if (= (logand s5-1 (collide-spec backgnd)) (collide-spec backgnd)) + (format #t "backgnd ") + ) + (if (= (logand s5-1 (collide-spec vehicle-debris)) (collide-spec vehicle-debris)) + (format #t "vehicle-debris ") + ) + (if (= (logand s5-1 (collide-spec jak)) (collide-spec jak)) + (format #t "jak ") + ) + (if (= (logand (collide-spec impenetrable-obj) s5-1) (collide-spec impenetrable-obj)) + (format #t "impenetrable-obj ") + ) + (if (= (logand (collide-spec pusher) s5-1) (collide-spec pusher)) + (format #t "pusher ") + ) + (if (= (logand (collide-spec los-blocker) s5-1) (collide-spec los-blocker)) + (format #t "los-blocker ") + ) + (if (= (logand (collide-spec jak-vulnerable) s5-1) (collide-spec jak-vulnerable)) + (format #t "jak-vulnerable ") + ) + (if (= (logand (collide-spec camera-blocker) s5-1) (collide-spec camera-blocker)) + (format #t "camera-blocker ") + ) + (if (= (logand s5-1 (collide-spec hit-by-others-list)) (collide-spec hit-by-others-list)) + (format #t "hit-by-others-list ") + ) + (if (= (logand s5-1 (collide-spec crate)) (collide-spec crate)) + (format #t "crate ") + ) + (if (= (logand (collide-spec nav-mesh) s5-1) (collide-spec nav-mesh)) + (format #t "nav-mesh ") + ) + (if (= (logand s5-1 (collide-spec vehicle-sphere)) (collide-spec vehicle-sphere)) + (format #t "vehicle-sphere ") + ) + ) + (format #t ")~%") + (format #t "~1Taction: #x~X : (collide-action " (-> this prim-core action)) + (let ((s5-2 (-> this prim-core action))) + (if (= (logand s5-2 (collide-action deadly)) (collide-action deadly)) + (format #t "deadly ") + ) + (if (= (logand s5-2 (collide-action rideable)) (collide-action rideable)) + (format #t "rideable ") + ) + (if (= (logand s5-2 (collide-action can-ride)) (collide-action can-ride)) + (format #t "can-ride ") + ) + (if (= (logand s5-2 (collide-action persistent-attack)) (collide-action persistent-attack)) + (format #t "persistent-attack ") + ) + (if (= (logand (collide-action nav-sphere) s5-2) (collide-action nav-sphere)) + (format #t "nav-sphere ") + ) + (if (= (logand s5-2 (collide-action block-turn-around)) (collide-action block-turn-around)) + (format #t "block-turn-around ") + ) + (if (= (logand s5-2 (collide-action pull-rider-can-collide)) (collide-action pull-rider-can-collide)) + (format #t "pull-rider-can-collide ") + ) + (if (= (logand s5-2 (collide-action no-standon)) (collide-action no-standon)) + (format #t "no-standon ") + ) + (if (= (logand s5-2 (collide-action dont-push-away)) (collide-action dont-push-away)) + (format #t "dont-push-away ") + ) + (if (= (logand s5-2 (collide-action check-stuck)) (collide-action check-stuck)) + (format #t "check-stuck ") + ) + (if (= (logand s5-2 (collide-action no-smack)) (collide-action no-smack)) + (format #t "no-smack ") + ) + (if (= (logand s5-2 (collide-action semi-solid)) (collide-action semi-solid)) + (format #t "semi-solid ") + ) + (if (= (logand s5-2 (collide-action edge-grabbed)) (collide-action edge-grabbed)) + (format #t "edge-grabbed ") + ) + (if (= (logand s5-2 (collide-action stuck-wall-escape)) (collide-action stuck-wall-escape)) + (format #t "stuck-wall-escape ") + ) + (if (= (logand s5-2 (collide-action check-edge)) (collide-action check-edge)) + (format #t "check-edge ") + ) + (if (= (logand s5-2 (collide-action no-normal-reset)) (collide-action no-normal-reset)) + (format #t "no-normal-reset ") + ) + (if (= (logand s5-2 (collide-action solid)) (collide-action solid)) + (format #t "solid ") + ) + ) + (format #t ")~%") + (format #t "~1Tprim-type: ~D~%" (-> this prim-core prim-type)) + (format #t "~1Tradius: (meters ~m)~%" (-> this local-sphere w)) + (format #t "~1Tmesh: ~A~%" (-> this mesh)) + (format #t "~1Tmesh-id: ~D~%" (-> this mesh-id)) + (format #t "~1Tmesh-cache-id: ~D~%" (-> this mesh-cache-id)) + (format #t "~1Tmesh-cache-entry: #~%" (-> this mesh-cache-entry)) + (label cfg-150) + this + ) + +;; definition of type collide-shape-prim-group +(deftype collide-shape-prim-group (collide-shape-prim) + "A group of collide primitives." + ((num-children uint8 :overlay-at (-> specific 0)) + (num-alloc-children uint8 :overlay-at (-> specific 1)) + (child (inline-array collide-shape-prim) :overlay-at (-> specific 4)) + ) + (:methods + (new (symbol type collide-shape uint int) _type_) + ) + ) + +;; definition for method 3 of type collide-shape-prim-group +(defmethod inspect ((this collide-shape-prim-group)) + (when (not this) + (set! this this) + (goto cfg-150) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tcshape: ~A~%" (-> this cshape)) + (format #t "~1Tprim-id: #x~X~%" (-> this prim-id)) + (format #t "~1Ttransform-index: ~D~%" (-> this transform-index)) + (format #t "~1Tunused2[3] @ #x~X~%" (-> this unused2)) + (format #t "~1Tprim-core: #~%" (-> this prim-core)) + (format #t "~1Tlocal-sphere: ~`vector`P~%" (-> this local-sphere)) + (format #t "~1Tspecific[16] @ #x~X~%" (&-> this num-children)) + (format #t "~1Tworld-sphere: ~`vector`P~%" (-> this prim-core)) + (format #t "~1Tcollide-as: #x~X : (collide-spec " (-> this prim-core collide-as)) + (let ((s5-0 (-> this prim-core collide-as))) + (if (= (logand (collide-spec special-obstacle) s5-0) (collide-spec special-obstacle)) + (format #t "special-obstacle ") + ) + (if (= (logand (collide-spec bot-targetable) s5-0) (collide-spec bot-targetable)) + (format #t "bot-targetable ") + ) + (if (= (logand (collide-spec coliseum-ball) s5-0) (collide-spec coliseum-ball)) + (format #t "coliseum-ball ") + ) + (if (= (logand s5-0 (collide-spec collectable)) (collide-spec collectable)) + (format #t "collectable ") + ) + (if (= (logand s5-0 (collide-spec projectile)) (collide-spec projectile)) + (format #t "projectile ") + ) + (if (= (logand (collide-spec obstacle-for-jak) s5-0) (collide-spec obstacle-for-jak)) + (format #t "obstacle-for-jak ") + ) + (if (= (logand s5-0 (collide-spec bot)) (collide-spec bot)) + (format #t "bot ") + ) + (if (= (logand s5-0 (collide-spec blocking-plane)) (collide-spec blocking-plane)) + (format #t "blocking-plane ") + ) + (if (= (logand s5-0 (collide-spec enemy)) (collide-spec enemy)) + (format #t "enemy ") + ) + (if (= (logand s5-0 (collide-spec hit-by-player-list)) (collide-spec hit-by-player-list)) + (format #t "hit-by-player-list ") + ) + (if (= (logand s5-0 (collide-spec obstacle)) (collide-spec obstacle)) + (format #t "obstacle ") + ) + (if (= (logand s5-0 (collide-spec water)) (collide-spec water)) + (format #t "water ") + ) + (if (= (logand s5-0 (collide-spec civilian)) (collide-spec civilian)) + (format #t "civilian ") + ) + (if (= (logand (collide-spec vehicle-sphere-no-probe) s5-0) (collide-spec vehicle-sphere-no-probe)) + (format #t "vehicle-sphere-no-probe ") + ) + (if (= (logand (collide-spec shield) s5-0) (collide-spec shield)) + (format #t "shield ") + ) + (if (= (logand s5-0 (collide-spec player-list)) (collide-spec player-list)) + (format #t "player-list ") + ) + (if (= (logand s5-0 (collide-spec backgnd)) (collide-spec backgnd)) + (format #t "backgnd ") + ) + (if (= (logand s5-0 (collide-spec vehicle-debris)) (collide-spec vehicle-debris)) + (format #t "vehicle-debris ") + ) + (if (= (logand s5-0 (collide-spec jak)) (collide-spec jak)) + (format #t "jak ") + ) + (if (= (logand (collide-spec impenetrable-obj) s5-0) (collide-spec impenetrable-obj)) + (format #t "impenetrable-obj ") + ) + (if (= (logand (collide-spec pusher) s5-0) (collide-spec pusher)) + (format #t "pusher ") + ) + (if (= (logand (collide-spec los-blocker) s5-0) (collide-spec los-blocker)) + (format #t "los-blocker ") + ) + (if (= (logand (collide-spec jak-vulnerable) s5-0) (collide-spec jak-vulnerable)) + (format #t "jak-vulnerable ") + ) + (if (= (logand (collide-spec camera-blocker) s5-0) (collide-spec camera-blocker)) + (format #t "camera-blocker ") + ) + (if (= (logand s5-0 (collide-spec hit-by-others-list)) (collide-spec hit-by-others-list)) + (format #t "hit-by-others-list ") + ) + (if (= (logand s5-0 (collide-spec crate)) (collide-spec crate)) + (format #t "crate ") + ) + (if (= (logand (collide-spec nav-mesh) s5-0) (collide-spec nav-mesh)) + (format #t "nav-mesh ") + ) + (if (= (logand s5-0 (collide-spec vehicle-sphere)) (collide-spec vehicle-sphere)) + (format #t "vehicle-sphere ") + ) + ) + (format #t ")~%") + (format #t "~1Tcollide-with: #x~X : (collide-spec " (-> this prim-core collide-with)) + (let ((s5-1 (-> this prim-core collide-with))) + (if (= (logand (collide-spec special-obstacle) s5-1) (collide-spec special-obstacle)) + (format #t "special-obstacle ") + ) + (if (= (logand (collide-spec bot-targetable) s5-1) (collide-spec bot-targetable)) + (format #t "bot-targetable ") + ) + (if (= (logand (collide-spec coliseum-ball) s5-1) (collide-spec coliseum-ball)) + (format #t "coliseum-ball ") + ) + (if (= (logand s5-1 (collide-spec collectable)) (collide-spec collectable)) + (format #t "collectable ") + ) + (if (= (logand s5-1 (collide-spec projectile)) (collide-spec projectile)) + (format #t "projectile ") + ) + (if (= (logand (collide-spec obstacle-for-jak) s5-1) (collide-spec obstacle-for-jak)) + (format #t "obstacle-for-jak ") + ) + (if (= (logand s5-1 (collide-spec bot)) (collide-spec bot)) + (format #t "bot ") + ) + (if (= (logand s5-1 (collide-spec blocking-plane)) (collide-spec blocking-plane)) + (format #t "blocking-plane ") + ) + (if (= (logand s5-1 (collide-spec enemy)) (collide-spec enemy)) + (format #t "enemy ") + ) + (if (= (logand s5-1 (collide-spec hit-by-player-list)) (collide-spec hit-by-player-list)) + (format #t "hit-by-player-list ") + ) + (if (= (logand s5-1 (collide-spec obstacle)) (collide-spec obstacle)) + (format #t "obstacle ") + ) + (if (= (logand s5-1 (collide-spec water)) (collide-spec water)) + (format #t "water ") + ) + (if (= (logand s5-1 (collide-spec civilian)) (collide-spec civilian)) + (format #t "civilian ") + ) + (if (= (logand (collide-spec vehicle-sphere-no-probe) s5-1) (collide-spec vehicle-sphere-no-probe)) + (format #t "vehicle-sphere-no-probe ") + ) + (if (= (logand (collide-spec shield) s5-1) (collide-spec shield)) + (format #t "shield ") + ) + (if (= (logand s5-1 (collide-spec player-list)) (collide-spec player-list)) + (format #t "player-list ") + ) + (if (= (logand s5-1 (collide-spec backgnd)) (collide-spec backgnd)) + (format #t "backgnd ") + ) + (if (= (logand s5-1 (collide-spec vehicle-debris)) (collide-spec vehicle-debris)) + (format #t "vehicle-debris ") + ) + (if (= (logand s5-1 (collide-spec jak)) (collide-spec jak)) + (format #t "jak ") + ) + (if (= (logand (collide-spec impenetrable-obj) s5-1) (collide-spec impenetrable-obj)) + (format #t "impenetrable-obj ") + ) + (if (= (logand (collide-spec pusher) s5-1) (collide-spec pusher)) + (format #t "pusher ") + ) + (if (= (logand (collide-spec los-blocker) s5-1) (collide-spec los-blocker)) + (format #t "los-blocker ") + ) + (if (= (logand (collide-spec jak-vulnerable) s5-1) (collide-spec jak-vulnerable)) + (format #t "jak-vulnerable ") + ) + (if (= (logand (collide-spec camera-blocker) s5-1) (collide-spec camera-blocker)) + (format #t "camera-blocker ") + ) + (if (= (logand s5-1 (collide-spec hit-by-others-list)) (collide-spec hit-by-others-list)) + (format #t "hit-by-others-list ") + ) + (if (= (logand s5-1 (collide-spec crate)) (collide-spec crate)) + (format #t "crate ") + ) + (if (= (logand (collide-spec nav-mesh) s5-1) (collide-spec nav-mesh)) + (format #t "nav-mesh ") + ) + (if (= (logand s5-1 (collide-spec vehicle-sphere)) (collide-spec vehicle-sphere)) + (format #t "vehicle-sphere ") + ) + ) + (format #t ")~%") + (format #t "~1Taction: #x~X : (collide-action " (-> this prim-core action)) + (let ((s5-2 (-> this prim-core action))) + (if (= (logand s5-2 (collide-action deadly)) (collide-action deadly)) + (format #t "deadly ") + ) + (if (= (logand s5-2 (collide-action rideable)) (collide-action rideable)) + (format #t "rideable ") + ) + (if (= (logand s5-2 (collide-action can-ride)) (collide-action can-ride)) + (format #t "can-ride ") + ) + (if (= (logand s5-2 (collide-action persistent-attack)) (collide-action persistent-attack)) + (format #t "persistent-attack ") + ) + (if (= (logand (collide-action nav-sphere) s5-2) (collide-action nav-sphere)) + (format #t "nav-sphere ") + ) + (if (= (logand s5-2 (collide-action block-turn-around)) (collide-action block-turn-around)) + (format #t "block-turn-around ") + ) + (if (= (logand s5-2 (collide-action pull-rider-can-collide)) (collide-action pull-rider-can-collide)) + (format #t "pull-rider-can-collide ") + ) + (if (= (logand s5-2 (collide-action no-standon)) (collide-action no-standon)) + (format #t "no-standon ") + ) + (if (= (logand s5-2 (collide-action dont-push-away)) (collide-action dont-push-away)) + (format #t "dont-push-away ") + ) + (if (= (logand s5-2 (collide-action check-stuck)) (collide-action check-stuck)) + (format #t "check-stuck ") + ) + (if (= (logand s5-2 (collide-action no-smack)) (collide-action no-smack)) + (format #t "no-smack ") + ) + (if (= (logand s5-2 (collide-action semi-solid)) (collide-action semi-solid)) + (format #t "semi-solid ") + ) + (if (= (logand s5-2 (collide-action edge-grabbed)) (collide-action edge-grabbed)) + (format #t "edge-grabbed ") + ) + (if (= (logand s5-2 (collide-action stuck-wall-escape)) (collide-action stuck-wall-escape)) + (format #t "stuck-wall-escape ") + ) + (if (= (logand s5-2 (collide-action check-edge)) (collide-action check-edge)) + (format #t "check-edge ") + ) + (if (= (logand s5-2 (collide-action no-normal-reset)) (collide-action no-normal-reset)) + (format #t "no-normal-reset ") + ) + (if (= (logand s5-2 (collide-action solid)) (collide-action solid)) + (format #t "solid ") + ) + ) + (format #t ")~%") + (format #t "~1Tprim-type: ~D~%" (-> this prim-core prim-type)) + (format #t "~1Tradius: (meters ~m)~%" (-> this local-sphere w)) + (format #t "~1Tnum-children: ~D~%" (-> this num-children)) + (format #t "~1Tnum-alloc-children: ~D~%" (-> this num-alloc-children)) + (format #t "~1Tchild: #x~X~%" (-> this child)) + (label cfg-150) + this + ) + +;; definition of type collide-shape +(deftype collide-shape (trsqv) + "The parent of all of an object's collide primitives. +Most [[process-drawable]]s have a [[collide-shape]] that represents their root transform." + ((actor-hash-index int16 :offset 12) + (process process-drawable) + (max-iteration-count uint8) + (nav-flags nav-flags) + (total-prims uint8) + (num-riders uint8) + (pat-ignore-mask pat-surface) + (event-self symbol :offset 152) + (event-other symbol) + (root-prim collide-shape-prim) + (riders (inline-array collide-rider)) + (penetrate-using penetrate) + (penetrated-by penetrate) + (backup-collide-as collide-spec) + (backup-collide-with collide-spec) + (event-priority uint8 :offset 192) + (rider-max-momentum float) + ) + (:methods + (new (symbol type process-drawable collide-list-enum) _type_) + (move-by-vector! (_type_ vector) none) + (move-to-point! (_type_ vector) none) + (debug-draw (_type_) none) + (fill-cache-for-shape (_type_ float collide-query) none) + (fill-cache-integrate-and-collide (_type_ vector collide-query meters) none) + (find-prim-by-id (_type_ uint) collide-shape-prim) + (find-prim-by-id-logtest (_type_ uint) collide-shape-prim) + (detect-riders! (_type_) symbol) + (build-bounding-box-for-shape (_type_ bounding-box float collide-spec) symbol) + (integrate-and-collide! (_type_ vector) none) + (find-collision-meshes (_type_) none) + (on-platform (_type_ collide-shape collide-query) symbol) + (find-overlapping-shapes (_type_ overlaps-others-params) symbol) + (shove-to-closest-point-on-path (_type_ attack-info float) vector) + (should-push-away (_type_ collide-shape collide-query) symbol) + (pull-rider! (_type_ pull-rider-info) none) + (pull-riders! (_type_) symbol) + (do-push-aways (_type_) collide-spec) + (update-transforms (_type_) none) + (set-collide-with! (_type_ collide-spec) none) + (set-collide-as! (_type_ collide-spec) none) + (modify-collide-as! (_type_ int collide-spec collide-spec) none) + (send-shoves (_type_ process touching-shapes-entry float float float) symbol) + (above-ground? (_type_ collide-query vector collide-spec float float float) symbol) + (water-info-init! (_type_ water-info collide-action) water-info) + (iterate-prims (_type_ (function collide-shape-prim none)) none) + (pusher-init (_type_) none) + ) + ) + +;; definition for method 3 of type collide-shape +(defmethod inspect ((this collide-shape)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Trot: ~`vector`P~%" (-> this rot)) + (format #t "~1Tscale: ~`vector`P~%" (-> this scale)) + (format #t "~1Tpause-adjust-distance: (meters ~m)~%" (-> this pause-adjust-distance)) + (format #t "~1Tnav-radius: (meters ~m)~%" (-> this nav-radius)) + (format #t "~1Ttransv: ~`vector`P~%" (-> this transv)) + (format #t "~1Trotv: ~`vector`P~%" (-> this rotv)) + (format #t "~1Tscalev: ~`vector`P~%" (-> this scalev)) + (format #t "~1Tdir-targ: #~%" (-> this dir-targ)) + (format #t "~1Tangle-change-time: ~D~%" (-> this angle-change-time)) + (format #t "~1Told-y-angle-diff: ~f~%" (-> this old-y-angle-diff)) + (format #t "~1Tactor-hash-index: ~D~%" (-> this actor-hash-index)) + (format #t "~1Tprocess: ~A~%" (-> this process)) + (format #t "~1Tmax-iteration-count: ~D~%" (-> this max-iteration-count)) + (format #t "~1Tnav-flags: ~D~%" (-> this nav-flags)) + (format #t "~1Ttotal-prims: ~D~%" (-> this total-prims)) + (format #t "~1Tnum-riders: ~D~%" (-> this num-riders)) + (format #t "~1Tevent-self: ~A~%" (-> this event-self)) + (format #t "~1Tevent-other: ~A~%" (-> this event-other)) + (format #t "~1Troot-prim: ~A~%" (-> this root-prim)) + (format #t "~1Triders: #x~X~%" (-> this riders)) + (format #t "~1Tpenetrate-using: #x~X : (penetrate " (-> this penetrate-using)) + (penetrate->string (-> this penetrate-using)) + (format #t ")~%") + (format #t "~1Tpenetrated-by: #x~X : (penetrate " (-> this penetrated-by)) + (penetrate->string (-> this penetrated-by)) + (format #t ")~%") + (format #t "~1Tevent-priority: ~D~%" (-> this event-priority)) + (format #t "~1Trider-max-momentum: ~f~%" (-> this rider-max-momentum)) + (label cfg-4) + this + ) + +;; definition of type collide-shape-moving +(deftype collide-shape-moving (collide-shape) + "A [[collide-shape]] for moving objects." + ((rider-time uint64) + (rider-last-move vector :inline) + (trans-old vector :inline) + (poly-pat pat-surface :offset 272) + (cur-pat pat-surface) + (ground-pat pat-surface) + (status uint64) + (reaction (function control-info collide-query vector vector collide-status) :offset 316) + (no-reaction (function collide-shape-moving collide-query vector vector object)) + (local-normal vector :inline) + (surface-normal vector :inline) + (poly-normal vector :inline) + (ground-poly-normal vector :inline) + (gspot-pos vector :inline) + (gspot-normal vector :inline) + (ground-touch-point vector :inline) + (ground-impact-vel meters) + (surface-angle float) + (poly-angle float) + (touch-angle float) + (coverage float) + (dynam dynamics) + ) + (:methods + (new (symbol type process-drawable collide-list-enum) _type_) + (collide-shape-moving-method-55 () none) + (collide-shape-moving-method-56 () none) + (collide-shape-moving-method-57 () none) + (collide-shape-moving-method-58 () none) + (collide-shape-moving-method-59 () none) + (collide-shape-moving-method-60 () none) + (collide-shape-moving-method-61 () none) + (collide-shape-moving-method-62 () none) + (collide-shape-moving-method-63 () none) + (collide-shape-moving-method-64 () none) + (collide-shape-moving-method-65 () none) + (collide-shape-moving-method-66 () none) + ) + ) + +;; definition for method 3 of type collide-shape-moving +(defmethod inspect ((this collide-shape-moving)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Trot: ~`vector`P~%" (-> this rot)) + (format #t "~1Tscale: ~`vector`P~%" (-> this scale)) + (format #t "~1Tpause-adjust-distance: (meters ~m)~%" (-> this pause-adjust-distance)) + (format #t "~1Tnav-radius: (meters ~m)~%" (-> this nav-radius)) + (format #t "~1Ttransv: ~`vector`P~%" (-> this transv)) + (format #t "~1Trotv: ~`vector`P~%" (-> this rotv)) + (format #t "~1Tscalev: ~`vector`P~%" (-> this scalev)) + (format #t "~1Tdir-targ: #~%" (-> this dir-targ)) + (format #t "~1Tangle-change-time: ~D~%" (-> this angle-change-time)) + (format #t "~1Told-y-angle-diff: ~f~%" (-> this old-y-angle-diff)) + (format #t "~1Tactor-hash-index: ~D~%" (-> this actor-hash-index)) + (format #t "~1Tprocess: ~A~%" (-> this process)) + (format #t "~1Tmax-iteration-count: ~D~%" (-> this max-iteration-count)) + (format #t "~1Tnav-flags: ~D~%" (-> this nav-flags)) + (format #t "~1Ttotal-prims: ~D~%" (-> this total-prims)) + (format #t "~1Tnum-riders: ~D~%" (-> this num-riders)) + (format #t "~1Tevent-self: ~A~%" (-> this event-self)) + (format #t "~1Tevent-other: ~A~%" (-> this event-other)) + (format #t "~1Troot-prim: ~A~%" (-> this root-prim)) + (format #t "~1Triders: #x~X~%" (-> this riders)) + (format #t "~1Tpenetrate-using: #x~X : (penetrate " (-> this penetrate-using)) + (penetrate->string (-> this penetrate-using)) + (format #t ")~%") + (format #t "~1Tpenetrated-by: #x~X : (penetrate " (-> this penetrated-by)) + (penetrate->string (-> this penetrated-by)) + (format #t ")~%") + (format #t "~1Tevent-priority: ~D~%" (-> this event-priority)) + (format #t "~1Trider-max-momentum: ~f~%" (-> this rider-max-momentum)) + (format #t "~1Trider-time: ~D~%" (-> this rider-time)) + (format #t "~1Trider-last-move: ~`vector`P~%" (-> this rider-last-move)) + (format #t "~1Ttrans-old: ~`vector`P~%" (-> this trans-old)) + (format #t "~1Tpoly-pat: #x~X~%" (-> this poly-pat)) + (format #t "~1Tcur-pat: #x~X~%" (-> this cur-pat)) + (format #t "~1Tground-pat: #x~X~%" (-> this ground-pat)) + (format #t "~1Tstatus: ~D~%" (-> this status)) + (format #t "~1Treaction: ~A~%" (-> this reaction)) + (format #t "~1Tno-reaction: ~A~%" (-> this no-reaction)) + (format #t "~1Tlocal-normal: ~`vector`P~%" (-> this local-normal)) + (format #t "~1Tsurface-normal: ~`vector`P~%" (-> this surface-normal)) + (format #t "~1Tpoly-normal: ~`vector`P~%" (-> this poly-normal)) + (format #t "~1Tground-poly-normal: ~`vector`P~%" (-> this ground-poly-normal)) + (format #t "~1Tgspot-pos: ~`vector`P~%" (-> this gspot-pos)) + (format #t "~1Tgspot-normal: ~`vector`P~%" (-> this gspot-normal)) + (format #t "~1Tground-touch-point: ~`vector`P~%" (-> this ground-touch-point)) + (format #t "~1Tground-impact-vel: (meters ~m)~%" (-> this ground-impact-vel)) + (format #t "~1Tsurface-angle: ~f~%" (-> this surface-angle)) + (format #t "~1Tpoly-angle: ~f~%" (-> this poly-angle)) + (format #t "~1Ttouch-angle: ~f~%" (-> this touch-angle)) + (format #t "~1Tcoverage: ~f~%" (-> this coverage)) + (format #t "~1Tdynam: ~A~%" (-> this dynam)) + (label cfg-4) + this + ) + +;; definition for method 0 of type collide-shape-prim +(defmethod new collide-shape-prim ((allocation symbol) (type-to-make type) (arg0 collide-shape) (arg1 uint) (arg2 int)) + (let ((v0-0 (object-new allocation type-to-make arg2))) + (set! (-> v0-0 cshape) arg0) + (set! (-> v0-0 prim-id) arg1) + (set! (-> v0-0 prim-core action) (collide-action)) + (set! (-> v0-0 prim-core collide-as) (collide-spec)) + (set! (-> v0-0 prim-core collide-with) (collide-spec)) + (set! (-> v0-0 transform-index) -2) + (set! (-> v0-0 prim-core prim-type) -2) + v0-0 + ) + ) + +;; definition for method 0 of type collide-shape-prim-sphere +;; WARN: Return type mismatch collide-shape-prim vs collide-shape-prim-sphere. +(defmethod new collide-shape-prim-sphere ((allocation symbol) (type-to-make type) (arg0 collide-shape) (arg1 uint)) + (let ((v0-0 ((method-of-type collide-shape-prim new) allocation type-to-make arg0 arg1 80))) + (set! (-> (the-as collide-shape-prim-sphere v0-0) pat) + (new 'static 'pat-surface :mode (pat-mode obstacle) :material (pat-material stone)) + ) + (set! (-> (the-as collide-shape-prim-sphere v0-0) prim-core prim-type) -1) + (the-as collide-shape-prim-sphere v0-0) + ) + ) + +;; definition for method 0 of type collide-shape-prim-mesh +;; WARN: Return type mismatch collide-shape-prim vs collide-shape-prim-mesh. +(defmethod new collide-shape-prim-mesh ((allocation symbol) (type-to-make type) (arg0 collide-shape) (arg1 uint) (arg2 uint)) + (let ((v0-0 ((method-of-type collide-shape-prim new) allocation type-to-make arg0 arg2 80))) + (set! (-> (the-as collide-shape-prim-mesh v0-0) mesh) #f) + (set! (-> (the-as collide-shape-prim-mesh v0-0) mesh-id) (the-as int arg1)) + (set! (-> (the-as collide-shape-prim-mesh v0-0) mesh-cache-id) (the-as uint 0)) + (set! (-> (the-as collide-shape-prim-mesh v0-0) prim-core prim-type) 1) + (the-as collide-shape-prim-mesh v0-0) + ) + ) + +;; definition for method 0 of type collide-shape-prim-group +;; WARN: Return type mismatch collide-shape-prim vs collide-shape-prim-group. +(defmethod new collide-shape-prim-group ((allocation symbol) (type-to-make type) (arg0 collide-shape) (arg1 uint) (arg2 int)) + (let ((v0-0 ((method-of-type collide-shape-prim new) allocation type-to-make arg0 (the-as uint arg2) 80))) + (set! (-> (the-as collide-shape-prim-group v0-0) num-children) arg1) + (set! (-> (the-as collide-shape-prim-group v0-0) num-alloc-children) arg1) + (set! (-> (the-as collide-shape-prim-group v0-0) prim-core prim-type) 0) + (set! (-> (the-as collide-shape-prim-group v0-0) child) + (the-as (inline-array collide-shape-prim) (&+ (the-as collide-shape-prim-group v0-0) 80)) + ) + (the-as collide-shape-prim-group v0-0) + ) + ) + +;; definition for method 4 of type collide-shape-prim-group +;; WARN: Return type mismatch uint vs int. +(defmethod length ((this collide-shape-prim-group)) + (the-as int (-> this num-children)) + ) + +;; definition for method 0 of type collide-shape +(defmethod new collide-shape ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 collide-list-enum)) + (let ((s5-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s5-0 actor-hash-index) -1) + (set! (-> s5-0 process) arg0) + (set! (-> s5-0 max-iteration-count) (the-as uint 1)) + (set! (-> s5-0 nav-flags) (nav-flags has-root-sphere)) + (set! (-> s5-0 event-self) #f) + (set! (-> s5-0 event-other) #f) + (set! (-> s5-0 riders) (the-as (inline-array collide-rider) #f)) + (set! (-> s5-0 root-prim) #f) + (set! (-> s5-0 penetrate-using) (penetrate)) + (set! (-> s5-0 penetrated-by) (penetrate)) + (set! (-> s5-0 event-priority) (the-as uint 0)) + (set! (-> s5-0 rider-max-momentum) 409600.0) + (case (-> arg0 type symbol) + (('camera) + (set! (-> s5-0 pat-ignore-mask) + (new 'static 'pat-surface :nocamera #x1 :nogrind #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + ) + (('target) + (set! (-> s5-0 pat-ignore-mask) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :board #x1)) + ) + (else + (set! (-> s5-0 pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + ) + ) + (set! (-> s5-0 trans w) 1.0) + (quaternion-identity! (the-as quaternion (-> s5-0 rot))) + (vector-identity! (-> s5-0 scale)) + (cond + ((= arg1 (collide-list-enum hit-by-player)) + (add-connection *collide-hit-by-player-list* arg0 #f s5-0 #f #f) + ) + ((= arg1 (collide-list-enum usually-hit-by-player)) + (add-connection *collide-hit-by-others-list* arg0 #f s5-0 #f #f) + ) + ((= arg1 (collide-list-enum hit-by-others)) + (add-connection *collide-player-list* arg0 #f s5-0 #f #f) + ) + (else + (format 0 "Unsupported collide-list-enum in collide-shape constructor!~%") + ) + ) + s5-0 + ) + ) + +;; definition for method 0 of type collide-shape-moving +;; INFO: Used lq/sq +(defmethod new collide-shape-moving ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 collide-list-enum)) + (let ((v0-0 ((method-of-type collide-shape new) allocation type-to-make arg0 arg1))) + (set! (-> (the-as collide-shape-moving v0-0) gspot-pos y) -40959590.0) + (set! (-> (the-as collide-shape-moving v0-0) gspot-normal quad) (-> *y-vector* quad)) + (the-as collide-shape-moving v0-0) + ) + ) + +;; definition for symbol *collide-shape-prim-backgnd*, type collide-shape-prim-mesh +(define *collide-shape-prim-backgnd* + (new 'static 'collide-shape-prim-mesh + :cshape #f + :prim-core (new 'static 'collide-prim-core + :world-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :collide-as (collide-spec backgnd) + :action (collide-action solid) + :prim-type 2 + ) + :local-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :mesh #f + ) + ) + +;; definition for symbol *collide-shape-prim-water*, type collide-shape-prim-mesh +(define *collide-shape-prim-water* + (new 'static 'collide-shape-prim-mesh + :cshape #f + :prim-core (new 'static 'collide-prim-core + :world-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :collide-as (collide-spec water) + :action (collide-action solid) + :prim-type 2 + ) + :local-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :mesh #f + ) + ) + +;; definition for symbol *collide-shape-prim-nav-mesh*, type collide-shape-prim-mesh +(define *collide-shape-prim-nav-mesh* + (new 'static 'collide-shape-prim-mesh + :cshape #f + :prim-core (new 'static 'collide-prim-core + :world-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :collide-as (collide-spec nav-mesh) + :action (collide-action solid) + :prim-type 2 + ) + :local-sphere (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 0.0 204800000.0)) + :mesh #f + ) + ) + +;; definition (perm) for symbol *collide-rider-pool*, type collide-rider-pool +(define-perm *collide-rider-pool* collide-rider-pool (new 'global 'collide-rider-pool)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/collide/collide-touch-h_REF.gc b/test/decompiler/reference/jakx/engine/collide/collide-touch-h_REF.gc new file mode 100644 index 0000000000..7dacba3ff9 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/collide/collide-touch-h_REF.gc @@ -0,0 +1,237 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type touching-prim +(deftype touching-prim (structure) + "A collide primitive that's touching another. +Potentially also stores the triangle that is involved." + ((cprim collide-shape-prim) + (has-tri? symbol) + (tri collide-tri-result :inline) + ) + ) + +;; definition for method 3 of type touching-prim +(defmethod inspect ((this touching-prim)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'touching-prim) + (format #t "~1Tcprim: ~A~%" (-> this cprim)) + (format #t "~1Thas-tri?: ~A~%" (-> this has-tri?)) + (format #t "~1Ttri: #~%" (-> this tri)) + (label cfg-4) + this + ) + +;; definition of type touching-prims-entry +(deftype touching-prims-entry (structure) + "A record of two primitives touching." + ((next touching-prims-entry) + (prev touching-prims-entry) + (allocated? symbol) + (u float) + (prim1 touching-prim :inline) + (prim2 touching-prim :inline) + ) + (:methods + (touching-prims-entry-method-9 (_type_ vector) vector) + (get-middle-of-bsphere-overlap (_type_ vector) vector) + (get-touched-prim (_type_ collide-shape touching-shapes-entry) collide-shape-prim) + (get-touched-tri (_type_ collide-shape touching-shapes-entry) collide-tri-result) + ) + ) + +;; definition for method 3 of type touching-prims-entry +(defmethod inspect ((this touching-prims-entry)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'touching-prims-entry) + (format #t "~1Tnext: #~%" (-> this next)) + (format #t "~1Tprev: #~%" (-> this prev)) + (format #t "~1Tallocated?: ~A~%" (-> this allocated?)) + (format #t "~1Tu: ~f~%" (-> this u)) + (format #t "~1Tprim1: #~%" (-> this prim1)) + (format #t "~1Tprim2: #~%" (-> this prim2)) + (label cfg-4) + this + ) + +;; definition of type touching-prims-entry-pool +(deftype touching-prims-entry-pool (structure) + "A pool of up to 64 touching prim records." + ((head touching-prims-entry) + (nodes touching-prims-entry 64 :inline) + ) + (:methods + (new (symbol type) _type_) + (alloc-node (_type_) touching-prims-entry) + (get-free-node-count (_type_) int) + (init-list! (_type_) none) + (free-node (_type_ touching-prims-entry) touching-prims-entry) + ) + ) + +;; definition for method 3 of type touching-prims-entry-pool +(defmethod inspect ((this touching-prims-entry-pool)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'touching-prims-entry-pool) + (format #t "~1Thead: #~%" (-> this head)) + (format #t "~1Tnodes[64] @ #x~X~%" (-> this nodes)) + (label cfg-4) + this + ) + +;; definition for method 11 of type touching-prims-entry-pool +;; WARN: Return type mismatch int vs none. +(defmethod init-list! ((this touching-prims-entry-pool)) + (let ((prev (the-as touching-prims-entry #f))) + (let ((current (the-as touching-prims-entry (-> this nodes)))) + (set! (-> this head) current) + (countdown (a0-1 64) + (set! (-> current prev) prev) + (let ((next (&+ current 240))) + (set! (-> current next) (the-as touching-prims-entry next)) + (set! (-> current allocated?) #f) + (set! prev current) + (set! current (the-as touching-prims-entry next)) + ) + ) + ) + (set! (-> prev next) #f) + ) + 0 + (none) + ) + +;; definition for method 0 of type touching-prims-entry-pool +;; WARN: Return type mismatch structure vs touching-prims-entry-pool. +(defmethod new touching-prims-entry-pool ((allocation symbol) (type-to-make type)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + (let ((gp-0 (t9-0 allocation v1-1))) + ((method-of-type touching-prims-entry-pool init-list!) (the-as touching-prims-entry-pool gp-0)) + (the-as touching-prims-entry-pool gp-0) + ) + ) + ) + +;; definition of type touching-shapes-entry +(deftype touching-shapes-entry (structure) + "A record of two collide shapes touching, +storing a record of the primitives involved." + ((cshape1 collide-shape) + (cshape2 collide-shape) + (resolve-u int8) + (head touching-prims-entry) + (handle1 handle) + (handle2 handle) + ) + :pack-me + (:methods + (get-head (_type_) touching-prims-entry) + (get-next (_type_ touching-shapes-entry) touching-prims-entry) + (get-touched-shape (_type_ collide-shape) collide-shape) + (prims-touching? (_type_ collide-shape uint) touching-prims-entry) + (prims-touching-action? (_type_ collide-shape collide-action collide-action) basic) + (free-touching-prims-list (_type_) none) + ) + ) + +;; definition for method 3 of type touching-shapes-entry +(defmethod inspect ((this touching-shapes-entry)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'touching-shapes-entry) + (format #t "~1Tcshape1: ~A~%" (-> this cshape1)) + (format #t "~1Tcshape2: ~A~%" (-> this cshape2)) + (format #t "~1Tresolve-u: ~D~%" (-> this resolve-u)) + (format #t "~1Thead: #~%" (-> this head)) + (format #t "~1Thandle1: ~D~%" (-> this handle1)) + (format #t "~1Thandle2: ~D~%" (-> this handle2)) + (label cfg-4) + this + ) + +;; definition of type touching-list +(deftype touching-list (structure) + "Contains a record of touching collide shape pairs." + ((num-touching-shapes int32) + (resolve-u int8) + (touching-shapes touching-shapes-entry 32 :inline) + ) + (:methods + (new (symbol type) _type_) + (add-touching-prims (_type_ collide-shape-prim collide-shape-prim float collide-tri-result collide-tri-result) none) + (free-nodes (_type_) none) + (update-from-step-size (_type_ float) none) + (send-events-for-touching-shapes (_type_) none) + (get-shapes-entry (_type_ collide-shape collide-shape) touching-shapes-entry) + ) + ) + +;; definition for method 3 of type touching-list +(defmethod inspect ((this touching-list)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'touching-list) + (format #t "~1Tnum-touching-shapes: ~D~%" (-> this num-touching-shapes)) + (format #t "~1Tresolve-u: ~D~%" (-> this resolve-u)) + (format #t "~1Ttouching-shapes[32] @ #x~X~%" (-> this touching-shapes)) + (label cfg-4) + this + ) + +;; definition for method 0 of type touching-list +;; WARN: Return type mismatch structure vs touching-list. +(defmethod new touching-list ((allocation symbol) (type-to-make type)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + (let ((v0-0 (t9-0 allocation v1-1))) + (set! (-> (the-as touching-list v0-0) num-touching-shapes) 0) + (set! (-> (the-as touching-list v0-0) resolve-u) 0) + (the-as touching-list v0-0) + ) + ) + ) + +;; definition for method 9 of type touching-shapes-entry +(defmethod get-head ((this touching-shapes-entry)) + (-> this head) + ) + +;; definition for method 10 of type touching-shapes-entry +;; WARN: Return type mismatch collide-shape vs touching-prims-entry. +(defmethod get-next ((this touching-shapes-entry) (arg0 touching-shapes-entry)) + (the-as touching-prims-entry (-> arg0 cshape1)) + ) + +;; failed to figure out what this is: +(kmemopen global "collide-touching-lists") + +;; definition (perm) for symbol *touching-prims-entry-pool*, type touching-prims-entry-pool +(define-perm *touching-prims-entry-pool* touching-prims-entry-pool (new 'global 'touching-prims-entry-pool)) + +;; definition (perm) for symbol *touching-list*, type touching-list +(define-perm *touching-list* touching-list (new 'global 'touching-list)) + +;; failed to figure out what this is: +(kmemclose) + + + + diff --git a/test/decompiler/reference/jakx/engine/collide/find-nearest-h_REF.gc b/test/decompiler/reference/jakx/engine/collide/find-nearest-h_REF.gc new file mode 100644 index 0000000000..c2f8422431 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/collide/find-nearest-h_REF.gc @@ -0,0 +1,58 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *HACK-find-nearest-focusable-ignore*, type symbol +(define *HACK-find-nearest-focusable-ignore* #f) + +;; definition of type find-sorted-targets-params +(deftype find-sorted-targets-params (structure) + ((near-point vector :inline) + (in-dir vector :inline) + (reject-team int8) + (min-dist float) + (max-dist float) + (inv-slope-dist float) + (reject-inside-dist float) + (min-angle-cos float) + (max-angle-cos float) + (inv-slope-ang float) + (required-flags uint32) + (priority-flags uint32) + (weights vector :inline) + (validate basic) + (validator-params basic) + ) + ) + +;; definition for method 3 of type find-sorted-targets-params +(defmethod inspect ((this find-sorted-targets-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'find-sorted-targets-params) + (format #t "~1Tnear-point: #~%" (-> this near-point)) + (format #t "~1Tin-dir: #~%" (-> this in-dir)) + (format #t "~1Treject-team: ~D~%" (-> this reject-team)) + (format #t "~1Tmin-dist: ~f~%" (-> this min-dist)) + (format #t "~1Tmax-dist: ~f~%" (-> this max-dist)) + (format #t "~1Tinv-slope-dist: ~f~%" (-> this inv-slope-dist)) + (format #t "~1Treject-inside-dist: ~f~%" (-> this reject-inside-dist)) + (format #t "~1Tmin-angle-cos: ~f~%" (-> this min-angle-cos)) + (format #t "~1Tmax-angle-cos: ~f~%" (-> this max-angle-cos)) + (format #t "~1Tinv-slope-ang: ~f~%" (-> this inv-slope-ang)) + (format #t "~1Trequired-flags: ~D~%" (-> this required-flags)) + (format #t "~1Tpriority-flags: ~D~%" (-> this priority-flags)) + (format #t "~1Tweights: #~%" (-> this weights)) + (format #t "~1Tvalidate: ~A~%" (-> this validate)) + (format #t "~1Tvalidator-params: ~A~%" (-> this validator-params)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/collide/pat-h_REF.gc b/test/decompiler/reference/jakx/engine/collide/pat-h_REF.gc new file mode 100644 index 0000000000..b42de1a782 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/collide/pat-h_REF.gc @@ -0,0 +1,314 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type pat-surface +(deftype pat-surface (uint32) + ((skip uint8 :offset 0 :size 7) + (mode pat-mode :offset 7 :size 3) + (material pat-material :offset 10 :size 6) + (camera uint8 :offset 16 :size 1) + (event pat-event :offset 18 :size 6) + (skip2 uint8 :offset 24 :size 5) + (noentity uint8 :offset 0 :size 1) + (nocamera uint8 :offset 1 :size 1) + (noedge uint8 :offset 2 :size 1) + (nogrind uint8 :offset 3 :size 1) + (nojak uint8 :offset 4 :size 1) + (noboard uint8 :offset 5 :size 1) + (nopilot uint8 :offset 6 :size 1) + (probe uint8 :offset 24 :size 1) + (nomech uint8 :offset 25 :size 1) + (noproj uint8 :offset 26 :size 1) + (noendlessfall uint8 :offset 27 :size 1) + (noprobe uint8 :offset 28 :size 1) + (nolineofsight uint8 :offset 16 :size 1) + (board uint8 :offset 4 :size 1) + ) + ) + +;; definition for method 3 of type pat-surface +(defmethod inspect ((this pat-surface)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'pat-surface) + (format #t "~1Tskip: ~D~%" (-> this skip)) + (format #t "~1Tmode: ~D~%" (-> this mode)) + (format #t "~1Tmaterial: ~D~%" (-> this material)) + (format #t "~1Tcamera: ~D~%" (-> this camera)) + (format #t "~1Tevent: ~D~%" (-> this event)) + (format #t "~1Tskip2: ~D~%" (-> this skip2)) + (format #t "~1Tnoentity: ~D~%" (-> this noentity)) + (format #t "~1Tnocamera: ~D~%" (-> this nocamera)) + (format #t "~1Tnohighspeed: ~D~%" (-> this noedge)) + (format #t "~1Tnolowspeed: ~D~%" (-> this nogrind)) + (format #t "~1Tdriving: ~D~%" (-> this nojak)) + (format #t "~1Tnodriving: ~D~%" (-> this noboard)) + (format #t "~1Tnopilot: ~D~%" (-> this nopilot)) + (format #t "~1Tprobe: ~D~%" (-> this probe)) + (format #t "~1Tnomech: ~D~%" (-> this nomech)) + (format #t "~1Tnoproj: ~D~%" (-> this noproj)) + (format #t "~1Tnoendlessfall: ~D~%" (-> this noendlessfall)) + (format #t "~1Tnoprobe: ~D~%" (-> this noprobe)) + (format #t "~1Tnolineofsight: ~D~%" (-> this camera)) + (label cfg-4) + this + ) + +;; definition (debug) for function pat-material->string +(defun-debug pat-material->string ((arg0 pat-surface)) + (case (-> arg0 material) + (((pat-material deepsnow)) + "deepsnow" + ) + (((pat-material neutral)) + "neutral" + ) + (((pat-material carpet)) + "carpet" + ) + (((pat-material shmetal)) + "shmetal" + ) + (((pat-material grmetal)) + "grmetal" + ) + (((pat-material lava)) + "lava" + ) + (((pat-material crmetal)) + "crmetal" + ) + (((pat-material pcmetal)) + "pcmetal" + ) + (((pat-material grass)) + "grass" + ) + (((pat-material snow)) + "snow" + ) + (((pat-material swamp)) + "swamp" + ) + (((pat-material stone)) + "stone" + ) + (((pat-material hotcoals)) + "hotcoals" + ) + (((pat-material unknown)) + "unknown" + ) + (((pat-material dirt)) + "dirt" + ) + (((pat-material dmaker)) + "dmaker" + ) + (((pat-material tube)) + "tube" + ) + (((pat-material forest)) + "forest" + ) + (((pat-material stopproj)) + "stopproj" + ) + (((pat-material invisible)) + "invisible" + ) + (((pat-material forcefield)) + "forcefield" + ) + (((pat-material tar)) + "tar" + ) + (((pat-material straw)) + "straw" + ) + (((pat-material wood)) + "wood" + ) + (((pat-material quicksand)) + "quicksand" + ) + (((pat-material squish)) + "squish" + ) + (((pat-material ice)) + "ice" + ) + (((pat-material rotate)) + "rotate" + ) + (((pat-material crwood)) + "crwood" + ) + (((pat-material waterbottom)) + "waterbottom" + ) + (((pat-material hdwood)) + "hdwood" + ) + (((pat-material sand)) + "sand" + ) + (((pat-material gravel)) + "gravel" + ) + (((pat-material metal)) + "metal" + ) + (else + "*unknown*" + ) + ) + ) + +;; definition (debug) for function pat-mode->string +(defun-debug pat-mode->string ((arg0 pat-surface)) + (case (-> arg0 mode) + (((pat-mode wall)) + "wall" + ) + (((pat-mode halfpipe)) + "halfpipe" + ) + (((pat-mode obstacle)) + "obstacle" + ) + (((pat-mode ground)) + "ground" + ) + (else + "*unknown*" + ) + ) + ) + +;; definition (debug) for function pat-event->string +(defun-debug pat-event->string ((arg0 pat-surface)) + (case (-> arg0 event) + (((pat-event nodamage)) + "nodamage" + ) + (((pat-event e09)) + "e09" + ) + (((pat-event deadly)) + "deadly" + ) + (((pat-event e02)) + "e02" + ) + (((pat-event e08)) + "e08" + ) + (((pat-event slippery)) + "slippery" + ) + (((pat-event e11)) + "e11" + ) + (((pat-event e01)) + "e01" + ) + (((pat-event e17)) + "e17" + ) + (((pat-event e07)) + "e07" + ) + (((pat-event e10)) + "e10" + ) + (((pat-event e16)) + "e16" + ) + (((pat-event e06)) + "e06" + ) + (((pat-event e15)) + "e15" + ) + (((pat-event e05)) + "e05" + ) + (((pat-event none)) + "none" + ) + (((pat-event e14)) + "e14" + ) + (((pat-event e04)) + "e04" + ) + (((pat-event e13)) + "e13" + ) + (((pat-event e03)) + "e03" + ) + (else + "*unknown*" + ) + ) + ) + +;; definition of type pat-mode-info +(deftype pat-mode-info (structure) + ((name string) + (wall-angle float) + (color rgba) + (hilite-color rgba) + ) + ) + +;; definition for method 3 of type pat-mode-info +(defmethod inspect ((this pat-mode-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'pat-mode-info) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Twall-angle: ~f~%" (-> this wall-angle)) + (format #t "~1Tcolor: ~D~%" (-> this color)) + (format #t "~1Thilite-color: ~D~%" (-> this hilite-color)) + (label cfg-4) + this + ) + +;; definition for symbol *pat-mode-info*, type (inline-array pat-mode-info) +(define *pat-mode-info* (new 'static 'inline-array pat-mode-info 4 + (new 'static 'pat-mode-info + :name "ground" + :wall-angle 0.2 + :color (new 'static 'rgba :r #x7f :a #x40) + :hilite-color (new 'static 'rgba :r #xff :a #x80) + ) + (new 'static 'pat-mode-info + :name "wall" + :wall-angle 2.0 + :color (new 'static 'rgba :b #x7f :a #x40) + :hilite-color (new 'static 'rgba :b #xff :a #x80) + ) + (new 'static 'pat-mode-info + :name "obstacle" + :wall-angle 0.82 + :color (new 'static 'rgba :r #x7f :b #x7f :a #x40) + :hilite-color (new 'static 'rgba :r #xff :b #xff :a #x80) + ) + (new 'static 'pat-mode-info + :name "halfpipe" + :wall-angle -2.0 + :color (new 'static 'rgba :r #x7f :g #x7f :a #x40) + :hilite-color (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) + +;; failed to figure out what this is: +0 diff --git a/test/decompiler/reference/jakx/engine/common-obs/cloth-art-h_REF.gc b/test/decompiler/reference/jakx/engine/common-obs/cloth-art-h_REF.gc new file mode 100644 index 0000000000..bff04fc0f9 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/common-obs/cloth-art-h_REF.gc @@ -0,0 +1,279 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type cloth-pt +(deftype cloth-pt (structure) + ((pt vector :inline) + (u float) + (v float) + ) + ) + +;; definition for method 3 of type cloth-pt +(defmethod inspect ((this cloth-pt)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cloth-pt) + (format #t "~1Tpt: #~%" (-> this pt)) + (format #t "~1Tu: ~f~%" (-> this u)) + (format #t "~1Tv: ~f~%" (-> this v)) + (label cfg-4) + this + ) + +;; definition of type anchor-transform +(deftype anchor-transform (structure) + ((offset vector :inline) + (joint-name string) + (joint int16) + (constraint-index int16) + ) + ) + +;; definition for method 3 of type anchor-transform +(defmethod inspect ((this anchor-transform)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'anchor-transform) + (format #t "~1Toffset: #~%" (-> this offset)) + (format #t "~1Tjoint-name: ~A~%" (-> this joint-name)) + (format #t "~1Tjoint: ~D~%" (-> this joint)) + (format #t "~1Tconstraint-index: ~D~%" (-> this constraint-index)) + (label cfg-4) + this + ) + +;; definition of type sphere-transform +(deftype sphere-transform (structure) + ((offset vector :inline) + (joint-name string) + (radius float) + (joint int16) + ) + ) + +;; definition for method 3 of type sphere-transform +(defmethod inspect ((this sphere-transform)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sphere-transform) + (format #t "~1Toffset: #~%" (-> this offset)) + (format #t "~1Tjoint-name: ~A~%" (-> this joint-name)) + (format #t "~1Tradius: ~f~%" (-> this radius)) + (format #t "~1Tjoint: ~D~%" (-> this joint)) + (label cfg-4) + this + ) + +;; definition of type disc-transform +(deftype disc-transform (structure) + ((offset vector :inline) + (normal vector :inline) + (joint-name basic) + (radius float) + (joint int16) + (start-particle-index int16) + (end-particle-index int16) + ) + ) + +;; definition for method 3 of type disc-transform +(defmethod inspect ((this disc-transform)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'disc-transform) + (format #t "~1Toffset: #~%" (-> this offset)) + (format #t "~1Tnormal: #~%" (-> this normal)) + (format #t "~1Tjoint-name: ~A~%" (-> this joint-name)) + (format #t "~1Tradius: ~f~%" (-> this radius)) + (format #t "~1Tjoint: ~D~%" (-> this joint)) + (format #t "~1Tstart-particle-index: ~D~%" (-> this start-particle-index)) + (format #t "~1Tend-particle-index: ~D~%" (-> this end-particle-index)) + (label cfg-4) + this + ) + +;; definition of type anchor-transform-array +(deftype anchor-transform-array (inline-array-class) + ((data anchor-transform :dynamic) + ) + ) + +;; definition for method 3 of type anchor-transform-array +(defmethod inspect ((this anchor-transform-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> anchor-transform-array heap-base) (the-as uint 32)) + +;; definition of type sphere-transform-array +(deftype sphere-transform-array (inline-array-class) + ((data sphere-transform :dynamic) + ) + ) + +;; definition for method 3 of type sphere-transform-array +(defmethod inspect ((this sphere-transform-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> sphere-transform-array heap-base) (the-as uint 32)) + +;; definition of type disc-transform-array +(deftype disc-transform-array (inline-array-class) + ((data disc-transform :dynamic) + ) + ) + +;; definition for method 3 of type disc-transform-array +(defmethod inspect ((this disc-transform-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> disc-transform-array heap-base) (the-as uint 48)) + +;; definition of type cloth-thickness-array +(deftype cloth-thickness-array (inline-array-class) + ((data uint8 :dynamic) + ) + ) + +;; definition for method 3 of type cloth-thickness-array +(defmethod inspect ((this cloth-thickness-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> cloth-thickness-array heap-base) (the-as uint 1)) + +;; definition of type cloth-params +(deftype cloth-params (structure) + ((mesh int16) + (gravity-constant meters) + (wind-constant float) + (cloth-width uint16) + (num-sphere-constraints uint16) + (num-disc-constraints uint16) + (num-anchor-points uint16) + (flags cloth-flag) + (tex-name string) + (tex-name2 string) + (tex-name3 string) + (alt-tex-name string) + (alt-tex-name2 string) + (alt-tex-name3 string) + (cloth-thickness float) + (initial-xform int16) + (drag float) + (ball-collision-radius meters) + (num-iterations int8) + (timestep-frequency int8) + (secret-disable game-secrets) + ) + ) + +;; definition for method 3 of type cloth-params +(defmethod inspect ((this cloth-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cloth-params) + (format #t "~1Tmesh: ~D~%" (-> this mesh)) + (format #t "~1Tgravity-constant: ~f~%" (-> this gravity-constant)) + (format #t "~1Twind-constant: ~f~%" (-> this wind-constant)) + (format #t "~1Tcloth-width: ~D~%" (-> this cloth-width)) + (format #t "~1Tnum-sphere-constraints: ~D~%" (-> this num-sphere-constraints)) + (format #t "~1Tnum-disc-constraints: ~D~%" (-> this num-disc-constraints)) + (format #t "~1Tnum-anchor-points: ~D~%" (-> this num-anchor-points)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Ttex-name: ~A~%" (-> this tex-name)) + (format #t "~1Ttex-name2: ~A~%" (-> this tex-name2)) + (format #t "~1Ttex-name3: ~A~%" (-> this tex-name3)) + (format #t "~1Talt-tex-name: ~A~%" (-> this alt-tex-name)) + (format #t "~1Talt-tex-name2: ~A~%" (-> this alt-tex-name2)) + (format #t "~1Talt-tex-name3: ~A~%" (-> this alt-tex-name3)) + (format #t "~1Tcloth-thickness: ~f~%" (-> this cloth-thickness)) + (format #t "~1Tinitial-xform: ~D~%" (-> this initial-xform)) + (format #t "~1Tdrag: ~f~%" (-> this drag)) + (format #t "~1Tball-collision-radius: ~f~%" (-> this ball-collision-radius)) + (format #t "~1Tnum-iterations: ~D~%" (-> this num-iterations)) + (format #t "~1Ttimestep-frequency: ~D~%" (-> this timestep-frequency)) + (format #t "~1Tsecret-disable: ~D~%" (-> this secret-disable)) + (label cfg-4) + this + ) + +;; definition of type cloth-base +(deftype cloth-base (basic) + () + (:methods + (update! (_type_) int) + (setup-from-params! (_type_ cloth-params handle) int) + ) + ) + +;; definition for method 3 of type cloth-base +(defmethod inspect ((this cloth-base)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/common-obs/generic-obs-h_REF.gc b/test/decompiler/reference/jakx/engine/common-obs/generic-obs-h_REF.gc new file mode 100644 index 0000000000..3e16b4a3f7 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/common-obs/generic-obs-h_REF.gc @@ -0,0 +1,718 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type manipy +(deftype manipy (process-drawable) + ((new-trans-hook (function none)) + (cur-trans-hook (function none)) + (cur-event-hook (function none)) + (new-joint-anim art-joint-anim) + (new-joint-anim-blend uint64) + (new-joint-anim-frame float) + (anim-mode symbol) + (cur-grab-handle uint64) + (cur-target-handle uint64) + (old-grab-pos vector :inline) + (joint joint-mod 4) + (new-post-hook (function none)) + (cur-post-hook (function none)) + (clone-copy-trans symbol) + (shadow-backup shadow-geo) + (draw? symbol) + (userdata uint64) + (prefix basic) + (shadow-volume-joint int32) + (speed float) + (user-uint64 uint64 4) + (options manipy-options) + ) + (:methods + (manipy-method-50 () none) + ) + ) + +;; definition for method 3 of type manipy +(defmethod inspect ((this manipy)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Tnew-trans-hook: ~A~%" (-> this new-trans-hook)) + (format #t "~2Tcur-trans-hook: ~A~%" (-> this cur-trans-hook)) + (format #t "~2Tcur-event-hook: ~A~%" (-> this cur-event-hook)) + (format #t "~2Tnew-joint-anim: ~A~%" (-> this new-joint-anim)) + (format #t "~2Tnew-joint-anim-blend: ~D~%" (-> this new-joint-anim-blend)) + (format #t "~2Tnew-joint-anim-frame: ~f~%" (-> this new-joint-anim-frame)) + (format #t "~2Tanim-mode: ~A~%" (-> this anim-mode)) + (format #t "~2Tcur-grab-handle: ~D~%" (-> this cur-grab-handle)) + (format #t "~2Tcur-target-handle: ~D~%" (-> this cur-target-handle)) + (format #t "~2Told-grab-pos: ~`vector`P~%" (-> this old-grab-pos)) + (format #t "~2Tjoint[4] @ #x~X~%" (-> this joint)) + (format #t "~2Tnew-post-hook: ~A~%" (-> this new-post-hook)) + (format #t "~2Tcur-post-hook: ~A~%" (-> this cur-post-hook)) + (format #t "~2Tclone-copy-trans: ~A~%" (-> this clone-copy-trans)) + (format #t "~2Tshadow-backup: ~A~%" (-> this shadow-backup)) + (format #t "~2Tdraw?: ~A~%" (-> this draw?)) + (format #t "~2Tuserdata: ~A~%" (-> this userdata)) + (format #t "~2Tprefix: ~A~%" (-> this prefix)) + (format #t "~2Tshadow-volume-joint: ~D~%" (-> this shadow-volume-joint)) + (format #t "~2Tspeed: ~f~%" (-> this speed)) + (format #t "~2Tuser-uint64[4] @ #x~X~%" (-> this user-uint64)) + (format #t "~2Toptions: ~D~%" (-> this options)) + (label cfg-4) + this + ) + +;; definition of type part-spawner +(deftype part-spawner (process) + "A process that spawns a specified particle group." + ((root trsqv) + (part sparticle-launch-control) + (path path-control) + (sound ambient-sound) + (sound-extra ambient-sound) + (mode (pointer sparticle-launch-group)) + (enable symbol) + (path-pos float) + (path-speed float) + (last-velocity vector :inline) + (radius meters) + (world-sphere sphere :inline) + ) + (:methods + (part-spawner-method-15 () none) + (part-spawner-method-16 () none) + ) + ) + +;; definition for method 3 of type part-spawner +(defmethod inspect ((this part-spawner)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Troot: ~A~%" (-> this root)) + (format #t "~2Tpart: ~A~%" (-> this part)) + (format #t "~2Tpath: ~A~%" (-> this path)) + (format #t "~2Tsound: ~A~%" (-> this sound)) + (format #t "~2Tsound-extra: ~A~%" (-> this sound-extra)) + (format #t "~2Tmode: #x~X~%" (-> this mode)) + (format #t "~2Tenable: ~A~%" (-> this enable)) + (format #t "~2Tpath-pos: ~f~%" (-> this path-pos)) + (format #t "~2Tpath-speed: ~f~%" (-> this path-speed)) + (format #t "~2Tlast-velocity: #~%" (-> this last-velocity)) + (format #t "~2Tradius: (meters ~m)~%" (-> this radius)) + (format #t "~2Tworld-sphere: #~%" (-> this world-sphere)) + (label cfg-4) + this + ) + +;; definition of type part-tracker +(deftype part-tracker (process) + ((root trsqv) + (mat matrix :inline) + (offset vector :inline) + (local-offset vector :inline) + (userdata uint64) + (user-time time-frame 2) + (user-vector vector :inline) + (user-handle uint32 2 :offset 320) + (part sparticle-launch-control) + (callback (function part-tracker vector)) + (linger-callback (function part-tracker vector)) + (duration uint64) + (linger-duration uint64) + (state-time uint64) + (target uint64) + (target-joint int32) + ) + (:methods + (part-tracker-method-15 () none) + (part-tracker-method-16 () none) + (part-tracker-method-17 () none) + (part-tracker-method-18 () none) + ) + ) + +;; definition for method 3 of type part-tracker +(defmethod inspect ((this part-tracker)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Troot: ~A~%" (-> this root)) + (format #t "~2Tmat: #~%" (-> this mat)) + (format #t "~2Toffset: ~`vector`P~%" (-> this offset)) + (format #t "~2Tlocal-offset: ~`vector`P~%" (-> this local-offset)) + (format #t "~2Tuserdata: ~A~%" (-> this userdata)) + (format #t "~2Tuser-time[2] @ #x~X~%" (-> this user-time)) + (format #t "~2Tuser-vector: ~`vector`P~%" (-> this user-vector)) + (format #t "~2Tuser-handle[2] @ #x~X~%" (-> this user-handle)) + (format #t "~2Tpart: ~A~%" (-> this part)) + (format #t "~2Tcallback: ~A~%" (-> this callback)) + (format #t "~2Tlinger-callback: ~A~%" (-> this linger-callback)) + (format #t "~2Tduration: ~D~%" (-> this duration)) + (format #t "~2Tlinger-duration: ~D~%" (-> this linger-duration)) + (format #t "~2Tstate-time: ~D~%" (-> this state-time)) + (format #t "~2Ttarget: ~D~%" (-> this target)) + (format #t "~2Ttarget-joint: ~D~%" (-> this target-joint)) + (label cfg-4) + this + ) + +;; definition of type part-tracker-init-params +(deftype part-tracker-init-params (structure) + ((local-offset vector :inline) + (userdata uint64) + (duration uint32) + (local-space-param int32 :offset 28) + (group sparticle-launch-group) + (callback (function part-tracker vector)) + (local-space-callback basic) + (target process-drawable) + (mat-joint object) + (subsampler-num float) + ) + ) + +;; definition for method 3 of type part-tracker-init-params +(defmethod inspect ((this part-tracker-init-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'part-tracker-init-params) + (format #t "~1Tlocal-offset: #~%" (-> this local-offset)) + (format #t "~1Tuserdata: ~A~%" (-> this userdata)) + (format #t "~1Tduration: ~D~%" (-> this duration)) + (format #t "~1Tlocal-space-param: ~D~%" (-> this local-space-param)) + (format #t "~1Tgroup: ~A~%" (-> this group)) + (format #t "~1Tcallback: ~A~%" (-> this callback)) + (format #t "~1Tlocal-space-callback: ~A~%" (-> this local-space-callback)) + (format #t "~1Ttarget: ~A~%" (-> this target)) + (format #t "~1Tmat-joint: ~A~%" (-> this mat-joint)) + (format #t "~1Tsubsampler-num: ~f~%" (-> this subsampler-num)) + (label cfg-4) + this + ) + +;; definition of type part-tracker-subsampler +(deftype part-tracker-subsampler (part-tracker) + ((subsampler sparticle-subsampler) + ) + ) + +;; definition for method 3 of type part-tracker-subsampler +(defmethod inspect ((this part-tracker-subsampler)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type part-tracker inspect))) + (t9-0 this) + ) + (format #t "~2Tsubsampler: ~A~%" (-> this subsampler)) + (label cfg-4) + this + ) + +;; definition of type lightning-tracker +(deftype lightning-tracker (process) + ((root trsqv) + (lightning lightning-control) + (callback (function lightning-tracker none)) + (duration uint64) + (start-time uint64) + (offset0 vector :inline) + (offset1 vector :inline) + (target0 uint64) + (target1 uint64) + (target-joint0 int32) + (target-joint1 int32) + (sound sound-id) + (userdata uint64) + (user-time time-frame 2) + (user-vector vector :inline) + (user-handle handle 2 :offset 304) + ) + (:methods + (lightning-tracker-method-15 () none) + (lightning-tracker-method-16 () none) + (lightning-tracker-method-17 () none) + ) + ) + +;; definition for method 3 of type lightning-tracker +(defmethod inspect ((this lightning-tracker)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Troot: ~A~%" (-> this root)) + (format #t "~2Tlightning: ~A~%" (-> this lightning)) + (format #t "~2Tcallback: ~A~%" (-> this callback)) + (format #t "~2Tduration: ~D~%" (-> this duration)) + (format #t "~2Tstart-time: ~D~%" (-> this start-time)) + (format #t "~2Toffset0: ~`vector`P~%" (-> this offset0)) + (format #t "~2Toffset1: ~`vector`P~%" (-> this offset1)) + (format #t "~2Ttarget0: ~D~%" (-> this target0)) + (format #t "~2Ttarget1: ~D~%" (-> this target1)) + (format #t "~2Ttarget-joint0: ~D~%" (-> this target-joint0)) + (format #t "~2Ttarget-joint1: ~D~%" (-> this target-joint1)) + (format #t "~2Tsound: ~D~%" (-> this sound)) + (format #t "~2Tuserdata: ~A~%" (-> this userdata)) + (format #t "~2Tuser-time[2] @ #x~X~%" (-> this user-time)) + (format #t "~2Tuser-vector: ~`vector`P~%" (-> this user-vector)) + (format #t "~2Tuser-handle[2] @ #x~X~%" (-> this user-handle)) + (label cfg-4) + this + ) + +;; definition of type touch-tracker +(deftype touch-tracker (process-drawable) + ((duration uint64) + (target uint64) + (event symbol) + (run-function (function object)) + (callback (function touch-tracker none)) + (event-mode symbol) + ) + (:methods + (touch-tracker-method-50 () none) + ) + ) + +;; definition for method 3 of type touch-tracker +(defmethod inspect ((this touch-tracker)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Tduration: ~D~%" (-> this duration)) + (format #t "~2Ttarget: ~D~%" (-> this target)) + (format #t "~2Tevent: ~A~%" (-> this event)) + (format #t "~2Trun-function: ~A~%" (-> this run-function)) + (format #t "~2Tcallback: ~A~%" (-> this callback)) + (format #t "~2Tevent-mode: ~A~%" (-> this event-mode)) + (label cfg-4) + this + ) + +;; definition of type gui-query +(deftype gui-query (structure) + ((x-position int32) + (y-position int32) + (message string) + (decision symbol) + (only-allow-cancel symbol) + (no-msg string) + (message-space int32) + ) + (:methods + (gui-query-method-9 () none) + (gui-query-method-10 () none) + ) + ) + +;; definition for method 3 of type gui-query +(defmethod inspect ((this gui-query)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gui-query) + (format #t "~1Tx-position: ~D~%" (-> this x-position)) + (format #t "~1Ty-position: ~D~%" (-> this y-position)) + (format #t "~1Tmessage: ~A~%" (-> this message)) + (format #t "~1Tdecision: ~A~%" (-> this decision)) + (format #t "~1Tonly-allow-cancel: ~A~%" (-> this only-allow-cancel)) + (format #t "~1Tno-msg: ~A~%" (-> this no-msg)) + (format #t "~1Tmessage-space: ~D~%" (-> this message-space)) + (label cfg-4) + this + ) + +;; definition of type othercam +(deftype othercam (process) + ((hand uint64) + (old-global-mask process-mask) + (mask-to-clear process-mask) + (cam-joint-index int32) + (old-pos vector :inline) + (old-mat-z vector :inline) + (had-valid-frame symbol) + (border-value basic) + (die? symbol) + (survive-anim-end? symbol) + (spooling? symbol) + (fov float) + ) + (:states + othercam-running + ) + ) + +;; definition for method 3 of type othercam +(defmethod inspect ((this othercam)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Thand: ~D~%" (-> this hand)) + (format #t "~2Told-global-mask: ~D~%" (-> this old-global-mask)) + (format #t "~2Tmask-to-clear: ~D~%" (-> this mask-to-clear)) + (format #t "~2Tcam-joint-index: ~D~%" (-> this cam-joint-index)) + (format #t "~2Told-pos: #~%" (-> this old-pos)) + (format #t "~2Told-mat-z: #~%" (-> this old-mat-z)) + (format #t "~2Thad-valid-frame: ~A~%" (-> this had-valid-frame)) + (format #t "~2Tborder-value: ~A~%" (-> this border-value)) + (format #t "~2Tdie?: ~A~%" (-> this die?)) + (format #t "~2Tsurvive-anim-end?: ~A~%" (-> this survive-anim-end?)) + (format #t "~2Tspooling?: ~A~%" (-> this spooling?)) + (format #t "~2Tfov: ~f~%" (-> this fov)) + (label cfg-4) + this + ) + +;; definition of type explosion-init-params +(deftype explosion-init-params (structure) + ((spawn-point vector :inline) + (spawn-quat quaternion :inline) + (radius float) + (scale float) + (group sparticle-launch-group) + (group-on-kill basic) + (collide-with collide-spec) + (collide-lof-check? basic) + (damage float) + (damage-scale float) + (vehicle-damage-factor float) + (vehicle-impulse-factor float) + (velocity vector :inline) + (ignore-proc uint64) + (attacker uint64) + (wpn-type int8) + ) + ) + +;; definition for method 3 of type explosion-init-params +(defmethod inspect ((this explosion-init-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'explosion-init-params) + (format #t "~1Tspawn-point: #~%" (-> this spawn-point)) + (format #t "~1Tspawn-quat: #~%" (-> this spawn-quat)) + (format #t "~1Tradius: ~f~%" (-> this radius)) + (format #t "~1Tscale: ~f~%" (-> this scale)) + (format #t "~1Tgroup: ~A~%" (-> this group)) + (format #t "~1Tgroup-on-kill: ~A~%" (-> this group-on-kill)) + (format #t "~1Tcollide-with: ~D~%" (-> this collide-with)) + (format #t "~1Tcollide-lof-check?: ~A~%" (-> this collide-lof-check?)) + (format #t "~1Tdamage: ~f~%" (-> this damage)) + (format #t "~1Tdamage-scale: ~f~%" (-> this damage-scale)) + (format #t "~1Tvehicle-damage-factor: ~f~%" (-> this vehicle-damage-factor)) + (format #t "~1Tvehicle-impulse-factor: ~f~%" (-> this vehicle-impulse-factor)) + (format #t "~1Tvelocity: #~%" (-> this velocity)) + (format #t "~1Tignore-proc: ~D~%" (-> this ignore-proc)) + (format #t "~1Tattacker: ~D~%" (-> this attacker)) + (format #t "~1Twpn-type: ~D~%" (-> this wpn-type)) + (label cfg-4) + this + ) + +;; definition of type explosion +(deftype explosion (process-drawable) + ((start-time uint64) + (duration uint32) + (linger-duration uint32) + (attack-id uint32) + (mat matrix :inline) + (params explosion-init-params :inline) + (killed-someone? basic) + (spawn-proc uint64) + (spawn-type basic) + ) + (:methods + (explosion-method-50 () none) + (explosion-method-51 () none) + (explosion-method-52 () none) + ) + ) + +;; definition for method 3 of type explosion +(defmethod inspect ((this explosion)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Tstart-time: ~D~%" (-> this start-time)) + (format #t "~2Tduration: ~D~%" (-> this duration)) + (format #t "~2Tlinger-duration: ~D~%" (-> this linger-duration)) + (format #t "~2Tattack-id: ~D~%" (-> this attack-id)) + (format #t "~2Tmat: #~%" (-> this mat)) + (format #t "~2Tparams: #~%" (-> this params)) + (format #t "~2Tkilled-someone?: ~A~%" (-> this killed-someone?)) + (format #t "~2Tspawn-proc: ~D~%" (-> this spawn-proc)) + (format #t "~2Tspawn-type: ~A~%" (-> this spawn-type)) + (label cfg-4) + this + ) + +;; definition of type process-hidden +(deftype process-hidden (process) + () + (:state-methods + die + ) + ) + +;; definition for method 3 of type process-hidden +(defmethod inspect ((this process-hidden)) + (when (not this) + (set! this this) + (goto cfg-62) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tmask: #x~X : (process-mask " (-> this mask)) + (let ((s5-0 (-> this mask))) + (if (= (logand s5-0 (process-mask process-tree)) (process-mask process-tree)) + (format #t "process-tree ") + ) + (if (= (logand (process-mask network) s5-0) (process-mask network)) + (format #t "network ") + ) + (if (= (logand s5-0 (process-mask target)) (process-mask target)) + (format #t "target ") + ) + (if (= (logand (process-mask collectable) s5-0) (process-mask collectable)) + (format #t "collectable ") + ) + (if (= (logand (process-mask projectile) s5-0) (process-mask projectile)) + (format #t "projectile ") + ) + (if (= (logand s5-0 (process-mask sleep-code)) (process-mask sleep-code)) + (format #t "sleep-code ") + ) + (if (= (logand s5-0 (process-mask actor-pause)) (process-mask actor-pause)) + (format #t "actor-pause ") + ) + (if (= (logand (process-mask bot) s5-0) (process-mask bot)) + (format #t "bot ") + ) + (if (= (logand (process-mask vehicle) s5-0) (process-mask vehicle)) + (format #t "vehicle ") + ) + (if (= (logand (process-mask enemy) s5-0) (process-mask enemy)) + (format #t "enemy ") + ) + (if (= (logand (process-mask entity) s5-0) (process-mask entity)) + (format #t "entity ") + ) + (if (= (logand s5-0 (process-mask heap-shrunk)) (process-mask heap-shrunk)) + (format #t "heap-shrunk ") + ) + (if (= (logand (process-mask sidekick) s5-0) (process-mask sidekick)) + (format #t "sidekick ") + ) + (if (= (logand s5-0 (process-mask going)) (process-mask going)) + (format #t "going ") + ) + (if (= (logand s5-0 (process-mask execute)) (process-mask execute)) + (format #t "execute ") + ) + (if (= (logand (process-mask death) s5-0) (process-mask death)) + (format #t "death ") + ) + (if (= (logand s5-0 (process-mask no-kill)) (process-mask no-kill)) + (format #t "no-kill ") + ) + (if (= (logand (process-mask platform) s5-0) (process-mask platform)) + (format #t "platform ") + ) + (if (= (logand s5-0 (process-mask freeze)) (process-mask freeze)) + (format #t "freeze ") + ) + (if (= (logand s5-0 (process-mask sleep)) (process-mask sleep)) + (format #t "sleep ") + ) + (if (= (logand s5-0 (process-mask progress)) (process-mask progress)) + (format #t "progress ") + ) + (if (= (logand s5-0 (process-mask menu)) (process-mask menu)) + (format #t "menu ") + ) + (if (= (logand (process-mask camera) s5-0) (process-mask camera)) + (format #t "camera ") + ) + (if (= (logand (process-mask ambient) s5-0) (process-mask ambient)) + (format #t "ambient ") + ) + (if (= (logand s5-0 (process-mask dark-effect)) (process-mask dark-effect)) + (format #t "dark-effect ") + ) + (if (= (logand (process-mask crate) s5-0) (process-mask crate)) + (format #t "crate ") + ) + (if (= (logand s5-0 (process-mask kernel-run)) (process-mask kernel-run)) + (format #t "kernel-run ") + ) + (if (= (logand s5-0 (process-mask movie)) (process-mask movie)) + (format #t "movie ") + ) + (if (= (logand s5-0 (process-mask pause)) (process-mask pause)) + (format #t "pause ") + ) + ) + (format #t ")~%") + (format #t "~1Tclock: ~A~%" (-> this clock)) + (format #t "~1Tview: ~A~%" (-> this view)) + (format #t "~1Tparent: #x~X~%" (-> this parent)) + (format #t "~1Tbrother: #x~X~%" (-> this brother)) + (format #t "~1Tchild: #x~X~%" (-> this child)) + (format #t "~1Tppointer: #x~X~%" (-> this ppointer)) + (format #t "~1Tself: ~A~%" (-> this self)) + (format #t "~1Tprofile-ticks: ~D~%" (-> this profile-ticks)) + (format #t "~1Tpool: ~A~%" (-> this pool)) + (format #t "~1Tstatus: ~A~%" (-> this status)) + (format #t "~1Tpid: ~D~%" (-> this pid)) + (format #t "~1Tmain-thread: ~A~%" (-> this main-thread)) + (format #t "~1Ttop-thread: ~A~%" (-> this top-thread)) + (format #t "~1Tentity: ~A~%" (-> this entity)) + (format #t "~1Tlevel: ~A~%" (-> this level)) + (format #t "~1Tstate: ~A~%" (-> this state)) + (format #t "~1Tprev-state: ~A~%" (-> this prev-state)) + (format #t "~1Tnext-state: ~A~%" (-> this next-state)) + (format #t "~1Tstate-stack: ~A~%" (-> this state-stack)) + (format #t "~1Ttrans-hook: ~A~%" (-> this trans-hook)) + (format #t "~1Tpost-hook: ~A~%" (-> this post-hook)) + (format #t "~1Tevent-hook: ~A~%" (-> this event-hook)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Theap-base: #x~X~%" (-> this heap-base)) + (format #t "~1Theap-top: #x~X~%" (-> this heap-top)) + (format #t "~1Theap-cur: #x~X~%" (-> this heap-cur)) + (format #t "~1Tstack-frame-top: ~A~%" (-> this stack-frame-top)) + (format #t "~1Theap: #~%" (&-> this heap-base)) + (format #t "~1Tconnection-list: ~`connectable`P~%" (-> this connection-list)) + (format #t "~1Tstack[0] @ #x~X~%" (-> this stack)) + (label cfg-62) + this + ) + +;; definition of type simple-prim +(deftype simple-prim (process-drawable) + ((strip prim-strip) + ) + (:methods + (simple-prim-method-50 () none) + (simple-prim-method-51 () none) + (simple-prim-method-52 () none) + (simple-prim-method-53 () none) + (simple-prim-method-54 () none) + (simple-prim-method-55 () none) + ) + ) + +;; definition for method 3 of type simple-prim +(defmethod inspect ((this simple-prim)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Tstrip: ~A~%" (-> this strip)) + (label cfg-4) + this + ) + +;; definition for symbol *simple-prim-additive*, type gs-alpha +(define *simple-prim-additive* (new 'static 'gs-alpha :b #x2 :d #x1)) + +;; definition for symbol *simple-prim-alpha-blend*, type gs-alpha +(define *simple-prim-alpha-blend* (new 'static 'gs-alpha :b #x1 :d #x1)) + +;; definition for symbol *simple-prim-subtractive*, type gs-alpha +(define *simple-prim-subtractive* (new 'static 'gs-alpha :a #x2 :d #x1)) + +;; definition of type task-arrow-params +(deftype task-arrow-params (structure) + ((flags task-arrow-flags) + (map-icon uint16) + (pos vector :inline) + (quat quaternion :inline) + (color uint32) + ) + ) + +;; definition for method 3 of type task-arrow-params +(defmethod inspect ((this task-arrow-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'task-arrow-params) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tmap-icon: ~D~%" (-> this map-icon)) + (format #t "~1Tpos: #~%" (-> this pos)) + (format #t "~1Tquat: #~%" (-> this quat)) + (format #t "~1Tcolor: ~D~%" (-> this color)) + (label cfg-4) + this + ) + +;; definition of type external-camera-controller +(deftype external-camera-controller (process) + ((pause-time uint64) + (blur symbol) + ) + (:state-methods + active + ) + ) + +;; definition for method 3 of type external-camera-controller +(defmethod inspect ((this external-camera-controller)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Tpause-time: ~D~%" (-> this pause-time)) + (format #t "~2Tblur: ~A~%" (-> this blur)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/common-obs/matrix-compose_REF.gc b/test/decompiler/reference/jakx/engine/common-obs/matrix-compose_REF.gc new file mode 100644 index 0000000000..71cd9bb716 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/common-obs/matrix-compose_REF.gc @@ -0,0 +1,132 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function matrix-fur-compose +;; INFO: Used lq/sq +(defun matrix-fur-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 rvec quad) (-> arg3 quad)) + (set! (-> arg0 uvec quad) (-> arg2 quad)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + arg0 + ) + +;; definition for function matrix-fu-compose +;; INFO: Used lq/sq +(defun matrix-fu-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (set! (-> arg0 uvec quad) (-> arg2 quad)) + (vector-cross! (-> arg0 rvec) arg2 arg1) + arg0 + ) + +;; definition for function matrix-fr-compose +;; INFO: Used lq/sq +(defun matrix-fr-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (set! (-> arg0 rvec quad) (-> arg2 quad)) + (vector-cross! (-> arg0 uvec) arg1 arg2) + arg0 + ) + +;; definition for function matrix-ur-compose +;; INFO: Used lq/sq +(defun matrix-ur-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 rvec quad) (-> arg2 quad)) + (set! (-> arg0 uvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 fvec) arg1 arg2) + arg0 + ) + +;; definition for function matrix-f-u-compose +;; INFO: Used lq/sq +(defun matrix-f-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 rvec) arg2 arg1) + (vector-normalize! (-> arg0 rvec) 1.0) + (vector-cross! (-> arg0 uvec) arg1 (-> arg0 rvec)) + arg0 + ) + +;; definition for function matrix-f-r-compose +;; INFO: Used lq/sq +(defun matrix-f-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 uvec) arg1 arg2) + (vector-normalize! (-> arg0 uvec) 1.0) + (vector-cross! (-> arg0 rvec) (-> arg0 uvec) arg1) + arg0 + ) + +;; definition for function matrix-u-f-compose +;; INFO: Used lq/sq +(defun matrix-u-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 uvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 rvec) arg1 arg2) + (vector-normalize! (-> arg0 rvec) 1.0) + (vector-cross! (-> arg0 fvec) (-> arg0 rvec) arg1) + arg0 + ) + +;; definition for function matrix-u-r-compose +;; INFO: Used lq/sq +(defun matrix-u-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 uvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 fvec) arg2 arg1) + (vector-normalize! (-> arg0 fvec) 1.0) + (vector-cross! (-> arg0 rvec) arg1 (-> arg0 fvec)) + arg0 + ) + +;; definition for function matrix-r-f-compose +;; INFO: Used lq/sq +(defun matrix-r-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 rvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 uvec) arg2 arg1) + (vector-normalize! (-> arg0 uvec) 1.0) + (vector-cross! (-> arg0 fvec) arg1 (-> arg0 uvec)) + arg0 + ) + +;; definition for function matrix-r-u-compose +;; INFO: Used lq/sq +(defun matrix-r-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 rvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 fvec) arg1 arg2) + (vector-normalize! (-> arg0 fvec) 1.0) + (vector-cross! (-> arg0 uvec) (-> arg0 fvec) arg1) + arg0 + ) + +;; definition for function matrix-f-compose +;; INFO: Used lq/sq +(defun matrix-f-compose ((arg0 matrix) (arg1 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (let ((a2-0 (vector-get-unique! (new 'stack-no-clear 'vector) arg1))) + (matrix-f-u-compose arg0 arg1 a2-0) + ) + arg0 + ) + +;; definition for function matrix-u-compose +;; INFO: Used lq/sq +(defun matrix-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 uvec quad) (-> arg1 quad)) + (let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1))) + (matrix-u-f-compose arg0 arg1 a2-1) + ) + arg0 + ) + +;; definition for function matrix-r-compose +;; INFO: Used lq/sq +(defun matrix-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 rvec quad) (-> arg1 quad)) + (let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1))) + (matrix-r-f-compose arg0 arg1 a2-1 arg3) + ) + arg0 + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/common-obs/projectile-h_REF.gc b/test/decompiler/reference/jakx/engine/common-obs/projectile-h_REF.gc new file mode 100644 index 0000000000..7a7c630bcc --- /dev/null +++ b/test/decompiler/reference/jakx/engine/common-obs/projectile-h_REF.gc @@ -0,0 +1,207 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type projectile +(deftype projectile (process-drawable) + ((starting-pos vector :inline) + (starting-dir vector :inline) + (target-pos vector :inline) + (base-target-pos vector :inline) + (pre-move-transv vector :inline) + (timeout time-frame) + (spawn-time time-frame) + (options projectile-options) + (last-target handle) + (notify-handle handle) + (owner-handle handle) + (ignore-handle handle) + (update-velocity (function projectile none)) + (move (function projectile none)) + (pick-target (function projectile none)) + (max-speed float) + (old-dist float 16) + (old-dist-count int32) + (hits int32) + (max-hits int32) + (tween float) + (attack-mode symbol) + (attack-id uint32) + (damage float) + (vehicle-damage-factor float) + (vehicle-impulse-factor float) + (charge-level float) + (sound-id sound-id) + (stop-speed meters) + (invinc-time time-frame) + (desired-target handle) + (desired-target-pos vector :inline) + (wpn-type uint8) + ) + (:methods + (projectile-method-50 () none) + (projectile-method-51 () none) + (projectile-method-52 () none) + (projectile-method-53 () none) + (projectile-method-54 () none) + (projectile-method-55 () none) + (projectile-method-56 () none) + (projectile-method-57 () none) + (projectile-method-58 () none) + (projectile-method-59 () none) + (projectile-method-60 () none) + (projectile-method-61 () none) + (projectile-method-62 () none) + (projectile-method-63 () none) + (projectile-method-64 () none) + (projectile-method-65 () none) + (projectile-method-66 () none) + (projectile-method-67 () none) + (projectile-method-68 () none) + (projectile-method-69 () none) + (projectile-method-70 () none) + (projectile-method-71 () none) + ) + ) + +;; definition for method 3 of type projectile +(defmethod inspect ((this projectile)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Tstarting-pos: ~`vector`P~%" (-> this starting-pos)) + (format #t "~2Tstarting-dir: ~`vector`P~%" (-> this starting-dir)) + (format #t "~2Ttarget-pos: ~`vector`P~%" (-> this target-pos)) + (format #t "~2Tbase-target-pos: ~`vector`P~%" (-> this base-target-pos)) + (format #t "~2Tpre-move-transv: ~`vector`P~%" (-> this pre-move-transv)) + (format #t "~2Ttimeout: ~D~%" (-> this timeout)) + (format #t "~2Tspawn-time: ~D~%" (-> this spawn-time)) + (format #t "~2Toptions: ~D~%" (-> this options)) + (format #t "~2Tlast-target: ~D~%" (-> this last-target)) + (format #t "~2Tnotify-handle: ~D~%" (-> this notify-handle)) + (format #t "~2Towner-handle: ~D~%" (-> this owner-handle)) + (format #t "~2Tignore-handle: ~D~%" (-> this ignore-handle)) + (format #t "~2Tupdate-velocity: ~A~%" (-> this update-velocity)) + (format #t "~2Tmove: ~A~%" (-> this move)) + (format #t "~2Tpick-target: ~A~%" (-> this pick-target)) + (format #t "~2Tmax-speed: ~f~%" (-> this max-speed)) + (format #t "~2Told-dist[16] @ #x~X~%" (-> this old-dist)) + (format #t "~2Told-dist-count: ~D~%" (-> this old-dist-count)) + (format #t "~2Thits: ~D~%" (-> this hits)) + (format #t "~2Tmax-hits: ~D~%" (-> this max-hits)) + (format #t "~2Ttween: ~f~%" (-> this tween)) + (format #t "~2Tattack-mode: ~A~%" (-> this attack-mode)) + (format #t "~2Tattack-id: ~D~%" (-> this attack-id)) + (format #t "~2Tdamage: ~f~%" (-> this damage)) + (format #t "~2Tvehicle-damage-factor: ~f~%" (-> this vehicle-damage-factor)) + (format #t "~2Tvehicle-impulse-factor: ~f~%" (-> this vehicle-impulse-factor)) + (format #t "~2Tcharge-level: ~f~%" (-> this charge-level)) + (format #t "~2Tsound-id: ~D~%" (-> this sound-id)) + (format #t "~2Tstop-speed: (meters ~m)~%" (-> this stop-speed)) + (format #t "~2Tinvinc-time: ~D~%" (-> this invinc-time)) + (format #t "~2Tdesired-target: ~D~%" (-> this desired-target)) + (format #t "~2Tdesired-target-pos: #~%" (-> this desired-target-pos)) + (format #t "~2Twpn-type: ~D~%" (-> this wpn-type)) + (label cfg-4) + this + ) + +;; definition of type projectile-init-by-other-params +(deftype projectile-init-by-other-params (structure) + ((pos vector :inline) + (vel vector :inline) + (target-pos vector :inline) + (target-handle handle) + (ent entity) + (charge float) + (attack-id uint32) + (options projectile-options) + (notify-handle handle) + (owner-handle handle) + (ignore-handle handle) + (timeout time-frame) + (damage float) + (vehicle-damage-factor float) + (vehicle-impulse-factor float) + (wpn-type uint8) + ) + ) + +;; definition for method 3 of type projectile-init-by-other-params +(defmethod inspect ((this projectile-init-by-other-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'projectile-init-by-other-params) + (format #t "~1Tpos: #~%" (-> this pos)) + (format #t "~1Tvel: #~%" (-> this vel)) + (format #t "~1Ttarget-pos: #~%" (-> this target-pos)) + (format #t "~1Ttarget-handle: ~D~%" (-> this target-handle)) + (format #t "~1Tent: ~A~%" (-> this ent)) + (format #t "~1Tcharge: ~f~%" (-> this charge)) + (format #t "~1Tattack-id: ~D~%" (-> this attack-id)) + (format #t "~1Toptions: ~D~%" (-> this options)) + (format #t "~1Tnotify-handle: ~D~%" (-> this notify-handle)) + (format #t "~1Towner-handle: ~D~%" (-> this owner-handle)) + (format #t "~1Tignore-handle: ~D~%" (-> this ignore-handle)) + (format #t "~1Ttimeout: ~D~%" (-> this timeout)) + (format #t "~1Tdamage: ~f~%" (-> this damage)) + (format #t "~1Tvehicle-damage-factor: ~f~%" (-> this vehicle-damage-factor)) + (format #t "~1Tvehicle-impulse-factor: ~f~%" (-> this vehicle-impulse-factor)) + (format #t "~1Twpn-type: ~D~%" (-> this wpn-type)) + (label cfg-4) + this + ) + +;; definition for function spawn-projectile +(defun spawn-projectile ((arg0 type) (arg1 projectile-init-by-other-params) (arg2 process-tree) (arg3 dead-pool)) + (let ((s4-0 (get-process arg3 arg0 #x4000 1))) + (when s4-0 + (let ((t9-1 (method-of-type process activate))) + (t9-1 s4-0 arg2 "projectile" (the-as pointer #x70004000)) + ) + (run-now-in-process s4-0 projectile-init-by-other arg1) + (-> s4-0 ppointer) + ) + ) + ) + +;; definition of type projectile-bounce +(deftype projectile-bounce (projectile) + ((played-bounce-time time-frame) + (tumble-quat quaternion :inline) + (gravity float) + ) + (:methods + (projectile-bounce-method-72 () none) + (projectile-bounce-method-73 () none) + (projectile-bounce-method-74 () none) + ) + ) + +;; definition for method 3 of type projectile-bounce +(defmethod inspect ((this projectile-bounce)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type projectile inspect))) + (t9-0 this) + ) + (format #t "~2Tplayed-bounce-time: ~D~%" (-> this played-bounce-time)) + (format #t "~2Ttumble-quat: #~%" (-> this tumble-quat)) + (format #t "~2Tgravity: ~f~%" (-> this gravity)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/common-obs/water-info-h_REF.gc b/test/decompiler/reference/jakx/engine/common-obs/water-info-h_REF.gc new file mode 100644 index 0000000000..076d509023 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/common-obs/water-info-h_REF.gc @@ -0,0 +1,177 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type water-info +(deftype water-info (structure) + ((trans vector :inline) + (normal vector :inline) + (base-height meters) + (depth meters) + (handle handle) + (flags water-flag) + (prim drawable-region-prim) + (extra-flags uint32) + ) + ) + +;; definition for method 3 of type water-info +(defmethod inspect ((this water-info)) + (when (not this) + (set! this this) + (goto cfg-40) + ) + (format #t "[~8x] ~A~%" this 'water-info) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Tnormal: ~`vector`P~%" (-> this normal)) + (format #t "~1Tbase-height: (meters ~m)~%" (-> this base-height)) + (format #t "~1Tdepth: (meters ~m)~%" (-> this depth)) + (format #t "~1Thandle: ~D~%" (-> this handle)) + (format #t "~1Tflags: #x~X : (water-flag " (-> this flags)) + (let ((s5-0 (-> this flags))) + (if (= (logand (water-flag bouncing) s5-0) (water-flag bouncing)) + (format #t "active ") + ) + (if (= (logand s5-0 (water-flag tar)) (water-flag tar)) + (format #t "deadly ") + ) + (if (= (logand s5-0 (water-flag swim-ground)) (water-flag swim-ground)) + (format #t "lava ") + ) + (if (= (logand s5-0 (water-flag use-water-anim)) (water-flag use-water-anim)) + (format #t "swamp ") + ) + (if (= (logand s5-0 (water-flag deadly)) (water-flag deadly)) + (format #t "dark-eco ") + ) + (if (= (logand s5-0 (water-flag under-water)) (water-flag under-water)) + (format #t "part-water ") + ) + (if (= (logand (water-flag head-under-water) s5-0) (water-flag head-under-water)) + (format #t "over-water ") + ) + (if (= (logand s5-0 (water-flag can-ground)) (water-flag can-ground)) + (format #t "use-ocean ") + ) + (if (= (logand s5-0 (water-flag no-grab-sound)) (water-flag no-grab-sound)) + (format #t "flow ") + ) + (if (= (logand s5-0 (water-flag flow)) (water-flag flow)) + (format #t "part-rings ") + ) + (if (= (logand s5-0 (water-flag swamp)) (water-flag swamp)) + (format #t "part-drip ") + ) + (if (= (logand s5-0 (water-flag lava)) (water-flag lava)) + (format #t "part-splash ") + ) + (if (= (logand s5-0 (water-flag use-ocean)) (water-flag use-ocean)) + (format #t "tar ") + ) + (if (= (logand s5-0 (water-flag can-wade)) (water-flag can-wade)) + (format #t "icy ") + ) + (if (= (logand s5-0 (water-flag can-swim)) (water-flag can-swim)) + (format #t "mud ") + ) + (if (= (logand s5-0 (water-flag mud)) (water-flag mud)) + (format #t "use-water-anim ") + ) + (if (= (logand s5-0 (water-flag dark-eco)) (water-flag dark-eco)) + (format #t "touch-water ") + ) + (if (= (logand s5-0 (water-flag active)) (water-flag active)) + (format #t "puddle ") + ) + ) + (format #t ")~%") + (format #t "~1Tprim: ~A~%" (-> this prim)) + (format #t "~1Textra-flags: ~D~%" (-> this extra-flags)) + (label cfg-40) + this + ) + +;; definition of type water-sphere +(deftype water-sphere (structure) + ((sphere sphere :inline) + (flags water-flag) + (user0 int32) + ) + ) + +;; definition for method 3 of type water-sphere +(defmethod inspect ((this water-sphere)) + (when (not this) + (set! this this) + (goto cfg-40) + ) + (format #t "[~8x] ~A~%" this 'water-sphere) + (format #t "~1Tsphere: #~%" (-> this sphere)) + (format #t "~1Tflags: #x~X : (water-flag " (-> this flags)) + (let ((s5-0 (-> this flags))) + (if (= (logand (water-flag bouncing) s5-0) (water-flag bouncing)) + (format #t "active ") + ) + (if (= (logand s5-0 (water-flag tar)) (water-flag tar)) + (format #t "deadly ") + ) + (if (= (logand s5-0 (water-flag swim-ground)) (water-flag swim-ground)) + (format #t "lava ") + ) + (if (= (logand s5-0 (water-flag use-water-anim)) (water-flag use-water-anim)) + (format #t "swamp ") + ) + (if (= (logand s5-0 (water-flag deadly)) (water-flag deadly)) + (format #t "dark-eco ") + ) + (if (= (logand s5-0 (water-flag under-water)) (water-flag under-water)) + (format #t "part-water ") + ) + (if (= (logand (water-flag head-under-water) s5-0) (water-flag head-under-water)) + (format #t "over-water ") + ) + (if (= (logand s5-0 (water-flag can-ground)) (water-flag can-ground)) + (format #t "use-ocean ") + ) + (if (= (logand s5-0 (water-flag no-grab-sound)) (water-flag no-grab-sound)) + (format #t "flow ") + ) + (if (= (logand s5-0 (water-flag flow)) (water-flag flow)) + (format #t "part-rings ") + ) + (if (= (logand s5-0 (water-flag swamp)) (water-flag swamp)) + (format #t "part-drip ") + ) + (if (= (logand s5-0 (water-flag lava)) (water-flag lava)) + (format #t "part-splash ") + ) + (if (= (logand s5-0 (water-flag use-ocean)) (water-flag use-ocean)) + (format #t "tar ") + ) + (if (= (logand s5-0 (water-flag can-wade)) (water-flag can-wade)) + (format #t "icy ") + ) + (if (= (logand s5-0 (water-flag can-swim)) (water-flag can-swim)) + (format #t "mud ") + ) + (if (= (logand s5-0 (water-flag mud)) (water-flag mud)) + (format #t "use-water-anim ") + ) + (if (= (logand s5-0 (water-flag dark-eco)) (water-flag dark-eco)) + (format #t "touch-water ") + ) + (if (= (logand s5-0 (water-flag active)) (water-flag active)) + (format #t "puddle ") + ) + ) + (format #t ")~%") + (format #t "~1Tuser0: ~D~%" (-> this user0)) + (label cfg-40) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/debug/debug-h_REF.gc b/test/decompiler/reference/jakx/engine/debug/debug-h_REF.gc new file mode 100644 index 0000000000..03cdbd9db7 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/debug/debug-h_REF.gc @@ -0,0 +1,269 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type pos-history +(deftype pos-history (structure) + ((points (inline-array vector)) + (num-points int32) + (h-first int32) + (h-last int32) + ) + ) + +;; definition for method 3 of type pos-history +(defmethod inspect ((this pos-history)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'pos-history) + (format #t "~1Tpoints: #x~X~%" (-> this points)) + (format #t "~1Tnum-points: ~D~%" (-> this num-points)) + (format #t "~1Th-first: ~D~%" (-> this h-first)) + (format #t "~1Th-last: ~D~%" (-> this h-last)) + (label cfg-4) + this + ) + +;; definition of type debug-vertex +(deftype debug-vertex (structure) + ((trans vector4w :inline) + (normal vector3h :inline) + (st vector2h :inline) + (color uint32) + ) + ) + +;; definition for method 3 of type debug-vertex +(defmethod inspect ((this debug-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'debug-vertex) + (format #t "~1Ttrans: ~`vector4w`P~%" (-> this trans)) + (format #t "~1Tnormal: ~`vector3h`P~%" (-> this normal)) + (format #t "~1Tst: ~`vector2h`P~%" (-> this st)) + (format #t "~1Tcolor: #x~X~%" (-> this color)) + (label cfg-4) + this + ) + +;; definition of type debug-vertex-stats +(deftype debug-vertex-stats (basic) + ((length int32) + (pos-count int32) + (vertex debug-vertex 600 :inline) + ) + ) + +;; definition for method 3 of type debug-vertex-stats +(defmethod inspect ((this debug-vertex-stats)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tpos-count: ~D~%" (-> this pos-count)) + (format #t "~1Tvertex[600] @ #x~X~%" (-> this vertex)) + (label cfg-4) + this + ) + +;; definition for symbol *color-black*, type rgba +(define *color-black* (new 'static 'rgba :a #x80)) + +;; definition for symbol *color-white*, type rgba +(define *color-white* (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)) + +;; definition for symbol *color-gray*, type rgba +(define *color-gray* (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)) + +;; definition for symbol *color-red*, type rgba +(define *color-red* (new 'static 'rgba :r #xff :a #x80)) + +;; definition for symbol *color-green*, type rgba +(define *color-green* (new 'static 'rgba :g #xff :a #x80)) + +;; definition for symbol *color-blue*, type rgba +(define *color-blue* (new 'static 'rgba :b #xff :a #x80)) + +;; definition for symbol *color-cyan*, type rgba +(define *color-cyan* (new 'static 'rgba :g #xff :b #xff :a #x80)) + +;; definition for symbol *color-magenta*, type rgba +(define *color-magenta* (new 'static 'rgba :r #xff :b #xff :a #x80)) + +;; definition for symbol *color-yellow*, type rgba +(define *color-yellow* (new 'static 'rgba :r #xff :g #xff :a #x80)) + +;; definition for symbol *color-purple*, type rgba +(define *color-purple* (new 'static 'rgba :r #x40 :b #x80 :a #x80)) + +;; definition for symbol *color-light-gray*, type rgba +(define *color-light-gray* (new 'static 'rgba :r #xb0 :g #xb0 :b #xb0 :a #xb0)) + +;; definition for symbol *color-light-red*, type rgba +(define *color-light-red* (new 'static 'rgba :r #xff :g #x80 :b #x80 :a #x80)) + +;; definition for symbol *color-light-green*, type rgba +(define *color-light-green* (new 'static 'rgba :r #x80 :g #xff :b #x80 :a #x80)) + +;; definition for symbol *color-light-blue*, type rgba +(define *color-light-blue* (new 'static 'rgba :r #x80 :g #x80 :b #xff :a #x80)) + +;; definition for symbol *color-light-cyan*, type rgba +(define *color-light-cyan* (new 'static 'rgba :r #x80 :g #xff :b #xff :a #x80)) + +;; definition for symbol *color-light-magenta*, type rgba +(define *color-light-magenta* (new 'static 'rgba :r #xff :g #x80 :b #xff :a #x80)) + +;; definition for symbol *color-light-yellow*, type rgba +(define *color-light-yellow* (new 'static 'rgba :r #xff :g #xff :b #x80 :a #x80)) + +;; definition for symbol *color-dark-red*, type rgba +(define *color-dark-red* (new 'static 'rgba :r #x80 :a #x80)) + +;; definition for symbol *color-dark-green*, type rgba +(define *color-dark-green* (new 'static 'rgba :g #x80 :a #x80)) + +;; definition for symbol *color-dark-blue*, type rgba +(define *color-dark-blue* (new 'static 'rgba :b #x80 :a #x80)) + +;; definition for symbol *color-dark-cyan*, type rgba +(define *color-dark-cyan* (new 'static 'rgba :g #x80 :b #x80 :a #x80)) + +;; definition for symbol *color-dark-magenta*, type rgba +(define *color-dark-magenta* (new 'static 'rgba :r #x80 :b #x80 :a #x80)) + +;; definition for symbol *color-dark-yellow*, type rgba +(define *color-dark-yellow* (new 'static 'rgba :r #x80 :g #x80 :a #x80)) + +;; definition for symbol *color-orange*, type rgba +(define *color-orange* (new 'static 'rgba :r #xff :g #x80 :a #x80)) + +;; definition (debug) for function draw-debug-text-3d +;; WARN: Return type mismatch int vs none. +(defun-debug draw-debug-text-3d ((arg0 string) (arg1 vector) (arg2 bucket-id) (arg3 font-color) (arg4 vector2h) (arg5 rgba)) + (add-debug-text-3d #t arg2 arg0 arg1 arg3 arg4) + 0 + (none) + ) + +;; definition (debug) for function draw-debug-x +;; WARN: Return type mismatch int vs none. +(defun-debug draw-debug-x ((arg0 vector) (arg1 bucket-id) (arg2 rgba)) + (add-debug-x #t arg1 arg0 arg2) + 0 + (none) + ) + +;; definition (debug) for function draw-debug-line +;; WARN: Return type mismatch int vs none. +(defun-debug draw-debug-line ((arg0 vector) (arg1 vector) (arg2 bucket-id) (arg3 rgba) (arg4 symbol) (arg5 rgba)) + (add-debug-line #t arg2 arg0 arg1 arg3 arg4 arg5) + 0 + (none) + ) + +;; definition (debug) for function draw-debug-vector +;; WARN: Return type mismatch int vs none. +(defun-debug draw-debug-vector ((arg0 vector) (arg1 vector) (arg2 bucket-id) (arg3 rgba) (arg4 meters)) + (add-debug-vector #t arg2 arg0 arg1 arg4 arg3) + 0 + (none) + ) + +;; definition (debug) for function draw-debug-flat-triangle +;; WARN: Return type mismatch int vs none. +(defun-debug draw-debug-flat-triangle ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 bucket-id) (arg4 rgba)) + (add-debug-flat-triangle #t arg3 arg0 arg1 arg2 arg4) + 0 + (none) + ) + +;; definition (debug) for function draw-debug-sphere +;; WARN: Return type mismatch int vs none. +(defun-debug draw-debug-sphere ((arg0 vector) (arg1 bucket-id) (arg2 float) (arg3 rgba)) + (add-debug-sphere + #t + arg1 + arg0 + (if (< 0.0 arg2) + arg2 + (-> arg0 w) + ) + arg3 + ) + 0 + (none) + ) + +;; definition (debug) for function draw-debug-matrix +;; WARN: Return type mismatch int vs none. +(defun-debug draw-debug-matrix ((arg0 matrix) (arg1 bucket-id) (arg2 float)) + (add-debug-matrix #t arg1 arg0 arg2) + 0 + (none) + ) + +;; definition (debug) for function draw-debug-box-with-transform +;; WARN: Return type mismatch int vs none. +(defun-debug draw-debug-box-with-transform ((arg0 bounding-box) (arg1 matrix) (arg2 bucket-id) (arg3 rgba)) + (add-debug-box-with-transform #t arg2 arg0 arg1 arg3) + 0 + (none) + ) + +;; definition (debug) for function draw-debug-line-sphere +;; WARN: Return type mismatch int vs none. +(defun-debug draw-debug-line-sphere ((arg0 vector) (arg1 vector) (arg2 bucket-id) (arg3 float) (arg4 rgba)) + (add-debug-line-sphere + #t + arg2 + arg0 + arg1 + (if (< 0.0 arg3) + arg3 + (-> arg0 w) + ) + arg4 + ) + 0 + (none) + ) + +;; definition of type stack-debug +(deftype stack-debug (structure) + ((r29 uint128) + (r31 uint128) + (test-count int32) + (visit int32) + (obj basic) + ) + ) + +;; definition for method 3 of type stack-debug +;; INFO: Used lq/sq +(defmethod inspect ((this stack-debug)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'stack-debug) + (format #t "~1Tr29: ~D~%" (-> this r29)) + (format #t "~1Tr31: ~D~%" (-> this r31)) + (format #t "~1Ttest-count: ~D~%" (-> this test-count)) + (format #t "~1Tvisit: ~D~%" (-> this visit)) + (format #t "~1Tobj: ~A~%" (-> this obj)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/debug/memory-usage-h_REF.gc b/test/decompiler/reference/jakx/engine/debug/memory-usage-h_REF.gc new file mode 100644 index 0000000000..9ca34f0689 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/debug/memory-usage-h_REF.gc @@ -0,0 +1,72 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) + +;; definition of type memory-usage-info +(deftype memory-usage-info (structure) + ((name string) + (count int32) + (used int32) + (total int32) + ) + ) + +;; definition for method 3 of type memory-usage-info +(defmethod inspect ((this memory-usage-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'memory-usage-info) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tcount: ~D~%" (-> this count)) + (format #t "~1Tused: ~D~%" (-> this used)) + (format #t "~1Ttotal: ~D~%" (-> this total)) + (label cfg-4) + this + ) + +;; definition of type memory-usage-block +(deftype memory-usage-block (basic) + ((work-bsp basic) + (length int32) + (data memory-usage-info 112 :inline) + ) + (:methods + (reset! (_type_) _type_) + (calculate-total (_type_) int) + (print-mem-usage (_type_ level object) _type_) + ) + ) + +;; definition for method 3 of type memory-usage-block +(defmethod inspect ((this memory-usage-block)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Twork-bsp: ~A~%" (-> this work-bsp)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tdata[112] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition for symbol *mem-usage*, type memory-usage-block +(define *mem-usage* (new 'debug 'memory-usage-block)) + +;; definition for symbol *dma-mem-usage*, type memory-usage-block +(define *dma-mem-usage* (new 'debug 'memory-usage-block)) + +;; definition for symbol *temp-mem-usage*, type memory-usage-block +(define *temp-mem-usage* (the-as memory-usage-block #f)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/debug/stats-h_REF.gc b/test/decompiler/reference/jakx/engine/debug/stats-h_REF.gc new file mode 100644 index 0000000000..5960154f2c --- /dev/null +++ b/test/decompiler/reference/jakx/engine/debug/stats-h_REF.gc @@ -0,0 +1,348 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type tr-stat +(deftype tr-stat (structure) + "triangle stats for a renderer. This can apply to a lot of different renderer types." + ((groups uint16) + (fragments uint16) + (tris uint32) + (dverts uint32) + (instances uint16) + (pad uint16) + ) + ) + +;; definition for method 3 of type tr-stat +(defmethod inspect ((this tr-stat)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tr-stat) + (format #t "~1Tgroups: ~D~%" (-> this groups)) + (format #t "~1Tfragments: ~D~%" (-> this fragments)) + (format #t "~1Ttris: ~D~%" (-> this tris)) + (format #t "~1Tdverts: ~D~%" (-> this dverts)) + (format #t "~1Tinstances: ~D~%" (-> this instances)) + (format #t "~1Tpad: ~D~%" (-> this pad)) + (label cfg-4) + this + ) + +;; definition of type merc-global-stats +(deftype merc-global-stats (structure) + "Triangle stats for all merc renderers." + ((merc tr-stat :inline) + (emerc tr-stat :inline) + (mercneric tr-stat :inline) + ) + ) + +;; definition for method 3 of type merc-global-stats +(defmethod inspect ((this merc-global-stats)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-global-stats) + (format #t "~1Tmerc: #~%" (-> this merc)) + (format #t "~1Temerc: #~%" (-> this emerc)) + (format #t "~1Tmercneric: #~%" (-> this mercneric)) + (label cfg-4) + this + ) + +;; definition of type perf-stat +(deftype perf-stat (structure) + "Performance statistics for a single 'bucket' or category. Unlike the more general profile-bars, +this records statistics like cache hits/instruction counts." + ((frame-number uint32) + (count uint32) + (cycles uint32) + (instructions uint32) + (icache uint32) + (dcache uint32) + (select uint32) + (ctrl uint32) + (accum0 uint32) + (accum1 uint32) + (to-vu0-waits uint32) + (to-spr-waits uint32) + (from-spr-waits uint32) + ) + :pack-me + (:methods + (perf-stat-method-9 () none) + (print-to-stream (_type_ string basic) none) + (start-profiling! (_type_) none) + (stop-profiling! (_type_) none) + (update-wait-stats (_type_ uint uint uint) none) + ) + ) + +;; definition for method 3 of type perf-stat +(defmethod inspect ((this perf-stat)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'perf-stat) + (format #t "~1Tframe-number: ~D~%" (-> this frame-number)) + (format #t "~1Tcount: ~D~%" (-> this count)) + (format #t "~1Tcycles: ~D~%" (-> this cycles)) + (format #t "~1Tinstructions: ~D~%" (-> this instructions)) + (format #t "~1Ticache: ~D~%" (-> this icache)) + (format #t "~1Tdcache: ~D~%" (-> this dcache)) + (format #t "~1Tselect: ~D~%" (-> this select)) + (format #t "~1Tctrl: ~D~%" (-> this ctrl)) + (format #t "~1Taccum0: ~D~%" (-> this accum0)) + (format #t "~1Taccum1: ~D~%" (-> this accum1)) + (format #t "~1Tto-vu0-waits: ~D~%" (-> this to-vu0-waits)) + (format #t "~1Tto-spr-waits: ~D~%" (-> this to-spr-waits)) + (format #t "~1Tfrom-spr-waits: ~D~%" (-> this from-spr-waits)) + (label cfg-4) + this + ) + +;; definition (debug) for function perf-stat-bucket->string +(defun-debug perf-stat-bucket->string ((arg0 perf-stat-bucket)) + (case arg0 + (((perf-stat-bucket collide-fill)) + "collide-fill" + ) + (((perf-stat-bucket nav)) + "nav" + ) + (((perf-stat-bucket bones)) + "bones" + ) + (((perf-stat-bucket hud-draw-string)) + "hud-draw-string" + ) + (((perf-stat-bucket rb-move)) + "rb-move" + ) + (((perf-stat-bucket vehicle-ai)) + "vehicle-ai" + ) + (((perf-stat-bucket foreground)) + "foreground" + ) + (((perf-stat-bucket inst-tie)) + "inst-tie" + ) + (((perf-stat-bucket vqp-common)) + "vqp-common" + ) + (((perf-stat-bucket nav-dma-write)) + "nav-dma-write" + ) + (((perf-stat-bucket collide-list)) + "collide-list" + ) + (((perf-stat-bucket rb-physics)) + "rb-physics" + ) + (((perf-stat-bucket nav-part3)) + "nav-part3" + ) + (((perf-stat-bucket mercneric)) + "mercneric" + ) + (((perf-stat-bucket rb-probe)) + "rb-probe" + ) + (((perf-stat-bucket vehicle-ai-calculate-vector)) + "vehicle-ai-calculate-vector" + ) + (((perf-stat-bucket tfrag-scissor)) + "tfrag-scissor" + ) + (((perf-stat-bucket vqp-sections)) + "vqp-sections" + ) + (((perf-stat-bucket misc)) + "misc" + ) + (((perf-stat-bucket find-nearest-poly)) + "find-nearest-poly" + ) + (((perf-stat-bucket nav-part6)) + "nav-part6" + ) + (((perf-stat-bucket nav-part2)) + "nav-part2" + ) + (((perf-stat-bucket inst-shrub)) + "inst-shrub" + ) + (((perf-stat-bucket proto-shrub)) + "proto-shrub" + ) + (((perf-stat-bucket rb-all)) + "rb-all" + ) + (((perf-stat-bucket drawable)) + "drawable" + ) + (((perf-stat-bucket nav-part9)) + "nav-part9" + ) + (((perf-stat-bucket all-code)) + "all-code" + ) + (((perf-stat-bucket actor-hash)) + "actor-hash" + ) + (((perf-stat-bucket nav-dma-all)) + "nav-dma-all" + ) + (((perf-stat-bucket hud-draw-sprite)) + "hud-draw-sprite" + ) + (((perf-stat-bucket nav-part10)) + "nav-part10" + ) + (((perf-stat-bucket hud-format)) + "hud-format" + ) + (((perf-stat-bucket race-line)) + "race-line" + ) + (((perf-stat-bucket nav-dma-work)) + "nav-dma-work" + ) + (((perf-stat-bucket update-los)) + "update-los" + ) + (((perf-stat-bucket proto-tie)) + "proto-tie" + ) + (((perf-stat-bucket nav-part4)) + "nav-part4" + ) + (((perf-stat-bucket spatial-hash-search)) + "spatial-hash-search" + ) + (((perf-stat-bucket find-containing-poly)) + "find-containing-poly" + ) + (((perf-stat-bucket vqp-ja-post)) + "vqp-ja-post" + ) + (((perf-stat-bucket rb-callback)) + "rb-callback" + ) + (((perf-stat-bucket nav-part7)) + "nav-part7" + ) + (((perf-stat-bucket tfrag)) + "tfrag" + ) + (((perf-stat-bucket vqp-sound)) + "vqp-sound" + ) + (((perf-stat-bucket hud)) + "hud" + ) + (((perf-stat-bucket collide)) + "collide" + ) + (((perf-stat-bucket nav-dma-read)) + "nav-dma-read" + ) + (((perf-stat-bucket rb-fc)) + "rb-fc" + ) + (((perf-stat-bucket vqp-post)) + "vqp-post" + ) + (((perf-stat-bucket vqp-parts)) + "vqp-parts" + ) + (((perf-stat-bucket spatial-hash-build)) + "spatial-hash-build" + ) + (((perf-stat-bucket camera)) + "camera" + ) + (((perf-stat-bucket tie-generic)) + "tie-generic" + ) + (((perf-stat-bucket vqp-all)) + "vqp-all" + ) + (((perf-stat-bucket background)) + "background" + ) + (((perf-stat-bucket nav-part5)) + "nav-part5" + ) + (((perf-stat-bucket nav-part1)) + "nav-part1" + ) + (((perf-stat-bucket nav-part8)) + "nav-part8" + ) + (else + "*unknown*" + ) + ) + ) + +;; definition of type perf-stat-array +(deftype perf-stat-array (inline-array-class) + "Array of all stats for all buckets." + ((data perf-stat :inline :dynamic) + ) + ) + +;; definition for method 3 of type perf-stat-array +(defmethod inspect ((this perf-stat-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> perf-stat-array heap-base) (the-as uint 52)) + +;; definition for method 11 of type perf-stat +;; WARN: Return type mismatch int vs none. +(defmethod start-profiling! ((this perf-stat)) + 0 + (none) + ) + +;; definition for method 12 of type perf-stat +;; WARN: Return type mismatch int vs none. +(defmethod stop-profiling! ((this perf-stat)) + 0 + (none) + ) + +;; definition for method 13 of type perf-stat +;; WARN: Return type mismatch int vs none. +(defmethod update-wait-stats ((this perf-stat) (arg0 uint) (arg1 uint) (arg2 uint)) + 0 + (none) + ) + +;; failed to figure out what this is: +(when (not *debug-segment*) + (set! (-> perf-stat method-table 11) nothing) + (set! (-> perf-stat method-table 12) nothing) + (set! (-> perf-stat method-table 13) nothing) + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/dma/dma-bucket_REF.gc b/test/decompiler/reference/jakx/engine/dma/dma-bucket_REF.gc new file mode 100644 index 0000000000..ba7765d477 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/dma/dma-bucket_REF.gc @@ -0,0 +1,70 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function dma-buffer-add-buckets +;; WARN: Return type mismatch pointer vs (inline-array dma-bucket). +(defun dma-buffer-add-buckets ((dma-buf dma-buffer) (bucket-count int)) + (let ((v0-0 (-> dma-buf base))) + (let ((v1-0 (the-as object v0-0))) + (dotimes (a2-0 bucket-count) + (set! (-> (the-as dma-bucket v1-0) tag) + (new 'static 'dma-tag :id (dma-tag-id next) :addr (the-as int (&+ (the-as pointer v1-0) 16))) + ) + (set! (-> (the-as dma-bucket v1-0) last) (the-as (pointer dma-tag) v1-0)) + (set! v1-0 (&+ (the-as pointer v1-0) 16)) + ) + (set! (-> dma-buf base) (the-as pointer v1-0)) + ) + (the-as (inline-array dma-bucket) v0-0) + ) + ) + +;; definition for function dma-buffer-patch-buckets +(defun dma-buffer-patch-buckets ((base dma-bucket) (count int)) + (when (nonzero? base) + (dotimes (v1-1 count) + (cond + ((= base (-> base last)) + (set! (-> base tag) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> base clear) (the-as uint 0)) + 0 + ) + (else + (set! (-> base last 0 addr) (the-as int (&+ base 16))) + (cond + ((and (or *display-profile* *stats-profile-bars*) (not *display-capture-mode*)) + (set! (-> (the-as dma-packet base) vif0) (new 'static 'vif-tag :cmd (vif-cmd mark) :imm v1-1)) + (set! (-> (the-as dma-packet base) vif1) (new 'static 'vif-tag :irq #x1)) + ) + (else + (set! (-> base clear) (the-as uint 0)) + 0 + ) + ) + ) + ) + (&+! base 16) + ) + ) + base + ) + +;; definition for function dma-bucket-insert-tag +(defun dma-bucket-insert-tag ((buckets (inline-array dma-bucket)) + (bucket bucket-id) + (start-tag pointer) + (end-tag-to-patch (pointer dma-tag)) + ) + (let ((v1-1 (-> buckets bucket))) + (set! (-> (the-as dma-bucket (-> v1-1 last)) next) (the-as uint start-tag)) + (set! (-> v1-1 last) end-tag-to-patch) + ) + start-tag + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/dma/dma-buffer_REF.gc b/test/decompiler/reference/jakx/engine/dma/dma-buffer_REF.gc new file mode 100644 index 0000000000..e857c61a5d --- /dev/null +++ b/test/decompiler/reference/jakx/engine/dma/dma-buffer_REF.gc @@ -0,0 +1,238 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type dma-packet +(deftype dma-packet (structure) + "The header for a DMA transfer, containing an DMA tag, and VIF tags." + ((dma dma-tag) + (vif0 vif-tag) + (vif1 vif-tag) + (quad uint128 :overlay-at dma) + ) + ) + +;; definition for method 3 of type dma-packet +;; INFO: Used lq/sq +(defmethod inspect ((this dma-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'dma-packet) + (format #t "~1Tdma: #x~X~%" (-> this dma)) + (format #t "~1Tvif0: #x~X~%" (-> this vif0)) + (format #t "~1Tvif1: #x~X~%" (-> this vif1)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (label cfg-4) + this + ) + +;; definition of type dma-packet-array +(deftype dma-packet-array (inline-array-class) + "Unused dma array. Unclear how it should be used." + ((data dma-packet :dynamic) + ) + ) + +;; definition for method 3 of type dma-packet-array +(defmethod inspect ((this dma-packet-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> dma-packet-array heap-base) (the-as uint 16)) + +;; definition of type dma-gif +(deftype dma-gif (structure) + "Believed unused GIF header type." + ((gif uint64 2) + (gif0 uint64 :overlay-at (-> gif 0)) + (gif1 uint64 :overlay-at (-> gif 1)) + (quad uint128 :overlay-at (-> gif 0)) + ) + ) + +;; definition for method 3 of type dma-gif +;; INFO: Used lq/sq +(defmethod inspect ((this dma-gif)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'dma-gif) + (format #t "~1Tgif[2] @ #x~X~%" (&-> this gif0)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (label cfg-4) + this + ) + +;; definition of type dma-gif-packet +(deftype dma-gif-packet (structure) + "The header for a DMA transfer that goes directly to GIF, containing DMA, VIF, GIF tags." + ((dma-vif dma-packet :inline) + (gif uint64 2) + (gif0 uint64 :overlay-at (-> gif 0)) + (gif1 uint64 :overlay-at (-> gif 1)) + (quad uint128 2 :overlay-at (-> dma-vif dma)) + ) + ) + +;; definition for method 3 of type dma-gif-packet +(defmethod inspect ((this dma-gif-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'dma-gif-packet) + (format #t "~1Tdma-vif: #~%" (-> this dma-vif)) + (format #t "~1Tgif[2] @ #x~X~%" (-> this gif)) + (format #t "~1Tquad[2] @ #x~X~%" (-> this dma-vif)) + (label cfg-4) + this + ) + +;; definition of type dma-buffer +(deftype dma-buffer (basic) + "A buffer for DMA data." + ((allocated-length int32) + (base pointer) + (end pointer) + (real-buffer-end int32) + (data-buffer uint8 :dynamic :overlay-at real-buffer-end) + (data uint64 1 :offset 32) + ) + (:methods + (new (symbol type int) _type_) + ) + ) + +;; definition for method 3 of type dma-buffer +(defmethod inspect ((this dma-buffer)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tbase: #x~X~%" (-> this base)) + (format #t "~1Tend: #x~X~%" (-> this end)) + (format #t "~1Treal-buffer-end: ~D~%" (-> this real-buffer-end)) + (format #t "~1Tdata[1] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition for method 0 of type dma-buffer +(defmethod new dma-buffer ((allocation symbol) (type-to-make type) (size-bytes int)) + "Allocate a DMA buffer to hold the given size" + (let ((v0-0 (object-new allocation type-to-make (+ size-bytes -4 (-> type-to-make size))))) + (set! (-> v0-0 base) (-> v0-0 data)) + (set! (-> v0-0 allocated-length) size-bytes) + (set! (-> v0-0 real-buffer-end) (the-as int (&+ (-> v0-0 data) size-bytes))) + v0-0 + ) + ) + +;; definition for function dma-buffer-inplace-new +(defun dma-buffer-inplace-new ((dma-buff dma-buffer) (size-bytes int)) + (set! (-> dma-buff base) (-> dma-buff data)) + (set! (-> dma-buff allocated-length) size-bytes) + dma-buff + ) + +;; definition for method 4 of type dma-buffer +(defmethod length ((this dma-buffer)) + (-> this allocated-length) + ) + +;; definition for method 5 of type dma-buffer +(defmethod asize-of ((this dma-buffer)) + (+ (-> this allocated-length) -4 (-> dma-buffer size)) + ) + +;; definition for function dma-buffer-length +(defun dma-buffer-length ((dma-buf dma-buffer)) + (shr (+ (&- (-> dma-buf base) (the-as uint (-> dma-buf data))) 15) 4) + ) + +;; definition for function dma-buffer-free +(defun dma-buffer-free ((dma-buf dma-buffer)) + (shr (+ (&- (-> dma-buf end) (the-as uint (-> dma-buf base))) 15) 4) + ) + +;; definition for function dma-buffer-add-vu-function +;; ERROR: Failed store: (s.w! (+ t2-0 8) t3-5) at op 23 +;; ERROR: Failed store: (s.w! (+ t2-0 12) t3-8) at op 32 +(defun dma-buffer-add-vu-function ((dma-buf dma-buffer) (vu-func vu-function) (flush-path-3 int)) + (let ((v1-0 (the-as object (+ (the-as uint vu-func) 16))) + (a3-0 (-> vu-func qlength)) + (a1-1 (-> vu-func origin)) + ) + (while (> a3-0 0) + (let ((t0-1 (min 127 a3-0))) + (let* ((t1-1 dma-buf) + (t2-0 (-> t1-1 base)) + ) + (set! (-> (the-as (pointer int64) t2-0)) + (logior (logior #x30000000 (shr (shl t0-1 48) 48)) (shr (shl (the-as int v1-0) 33) 1)) + ) + (let ((t3-5 (shr + (shl + (if (zero? flush-path-3) + 16 + 19 + ) + 57 + ) + 33 + ) + ) + ) + (s.w! (+ t2-0 8) t3-5) + ) + (let ((t3-8 (logior (logior #x4a000000 (shr (shl a1-1 48) 48)) (shr (shl (* t0-1 2) 56) 40)))) + (s.w! (+ t2-0 12) t3-8) + ) + (set! (-> t1-1 base) (&+ t2-0 16)) + ) + (set! v1-0 (+ (the-as uint v1-0) (* t0-1 16))) + (set! a3-0 (- a3-0 t0-1)) + (+! a1-1 (* t0-1 2)) + ) + ) + ) + #f + ) + +;; definition for function dma-buffer-send +(defun dma-buffer-send ((chan dma-bank) (buf dma-buffer)) + (when (< (-> buf allocated-length) (&- (-> buf base) (the-as uint (-> buf data)))) + (crash!) + 0 + ) + (dma-send chan (the-as uint (-> buf data)) (the-as uint (dma-buffer-length buf))) + (none) + ) + +;; definition for function dma-buffer-send-chain +(defun dma-buffer-send-chain ((chan dma-bank-source) (buf dma-buffer)) + (when (< (-> buf allocated-length) (&- (-> buf base) (the-as uint (-> buf data)))) + (crash!) + 0 + ) + (dma-send-chain chan (the-as uint (-> buf data))) + (none) + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/dma/dma-disasm_REF.gc b/test/decompiler/reference/jakx/engine/dma/dma-disasm_REF.gc new file mode 100644 index 0000000000..fa98a039a6 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/dma/dma-disasm_REF.gc @@ -0,0 +1,744 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) + +;; definition of type vif-disasm-element +(deftype vif-disasm-element (structure) + ((mask uint32) + (tag vif-cmd-32) + (val uint32) + (print uint32) + (string1 string) + (string2 string) + ) + ) + +;; definition for method 3 of type vif-disasm-element +(defmethod inspect ((this vif-disasm-element)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'vif-disasm-element) + (format #t "~1Tmask: ~D~%" (-> this mask)) + (format #t "~1Ttag: ~D~%" (-> this tag)) + (format #t "~1Tval: ~D~%" (-> this val)) + (format #t "~1Tprint: ~D~%" (-> this print)) + (format #t "~1Tstring1: ~A~%" (-> this string1)) + (format #t "~1Tstring2: ~A~%" (-> this string2)) + (label cfg-4) + this + ) + +;; definition for symbol *vif-disasm-table*, type (array vif-disasm-element) +(define *vif-disasm-table* + (new 'static 'boxed-array :type vif-disasm-element + (new 'static 'vif-disasm-element :mask #x7f :string1 "nop") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 stcycl) :print #x2 :string1 "stcycl") + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 offset) + :print #x1 + :string1 "offset" + :string2 "offset" + ) + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 base) :print #x1 :string1 "base" :string2 "base") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 itop) :print #x1 :string1 "itop" :string2 "addr") + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 stmod) + :print #x1 + :string1 "stmod" + :string2 "mode" + ) + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 mskpath3) + :print #x1 + :string1 "mskpath3" + :string2 "mask" + ) + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 mark) :print #x1 :string1 "mark" :string2 "mark") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 flushe) :string1 "flushe") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 flush) :string1 "flush") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 flusha) :string1 "flusha") + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 mscal) + :print #x1 + :string1 "mscal" + :string2 "addr" + ) + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 mscnt) :string1 "mscnt") + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 mscalf) + :print #x1 + :string1 "mscalf" + :string2 "addr" + ) + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 stmask) + :print #x3 + :string1 "stmask" + :string2 "mask" + ) + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 strow) + :print #x4 + :string1 "strow" + :string2 "row" + ) + (new 'static 'vif-disasm-element + :mask #x7f + :tag (vif-cmd-32 stcol) + :print #x4 + :string1 "stcol" + :string2 "col" + ) + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 mpg) :print #x5 :string1 "mpg") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 direct) :print #x6 :string1 "direct") + (new 'static 'vif-disasm-element :mask #x7f :tag (vif-cmd-32 directhl) :print #x6 :string1 "directhl") + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-s-32) + :val #x10 + :print #x7 + :string1 "unpack-s-32" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-s-16) + :val #x8 + :print #x7 + :string1 "unpack-s-16" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-s-8) + :val #x4 + :print #x7 + :string1 "unpack-s-8" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v2-32) + :val #x8 + :print #x7 + :string1 "unpack-v2-32" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v2-16) + :val #x4 + :print #x7 + :string1 "unpack-v2-16" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v2-8) + :val #x2 + :print #x7 + :string1 "unpack-v2-8" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v3-32) + :val #xc + :print #x7 + :string1 "unpack-v3-32" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v3-16) + :val #x6 + :print #x7 + :string1 "unpack-v3-16" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v3-8) + :val #x3 + :print #x7 + :string1 "unpack-v3-8" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v4-32) + :val #x10 + :print #x7 + :string1 "unpack-v4-32" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v4-16) + :val #x8 + :print #x7 + :string1 "unpack-v4-16" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v4-8) + :val #x4 + :print #x7 + :string1 "unpack-v4-8" + ) + (new 'static 'vif-disasm-element + :mask #x6f + :tag (vif-cmd-32 unpack-v4-5) + :val #x2 + :print #x7 + :string1 "unpack-v4-5" + ) + (new 'static 'vif-disasm-element :print #x8) + ) + ) + +;; definition for function disasm-vif-details +(defun disasm-vif-details ((fmt-dest symbol) (vif-data (pointer uint8)) (unpack-cmd vif-cmd) (unpack-count int)) + "Disassemble the data stored in a vif unpack." + (let ((s4-0 unpack-count)) + (cond + ((= unpack-cmd (vif-cmd unpack-v4-8)) + (let ((s3-0 (&-> vif-data 4))) + (dotimes (s2-0 s4-0) + (format + fmt-dest + " #x~X: #x~2X #x~2X #x~2X #x~2X~%" + (+ (+ (* s2-0 4) 4) (the-as int vif-data)) + (-> s3-0 (* s2-0 4)) + (-> s3-0 (+ (* s2-0 4) 1)) + (-> s3-0 (+ (* s2-0 4) 2)) + (-> s3-0 (+ (* s2-0 4) 3)) + ) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-s-8)) + (let ((s3-1 (&-> vif-data 4))) + (dotimes (s2-1 s4-0) + (format fmt-dest " #x~X: #x~2x~%" (+ (+ s2-1 4) (the-as int vif-data)) unpack-count) + (-> s3-1 (* 3 s2-1)) + (-> s3-1 (+ (* 3 s2-1) 1)) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-v4-32)) + (let ((s3-2 (&-> vif-data 4))) + (dotimes (s2-2 s4-0) + (format + fmt-dest + " #x~X: #x~8x #x~8x #x~8x #x~8x~%" + (+ (+ (* s2-2 16) 4) (the-as int vif-data)) + (-> (the-as (pointer uint32) (&+ s3-2 (* (* s2-2 4) 4)))) + (-> (the-as (pointer uint32) (&+ s3-2 (* (+ (* s2-2 4) 1) 4)))) + (-> (the-as (pointer uint32) (&+ s3-2 (* (+ (* s2-2 4) 2) 4)))) + (-> (the-as (pointer uint32) (&+ s3-2 (* (+ (* s2-2 4) 3) 4)))) + ) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-v4-16)) + (let ((s3-3 (&-> vif-data 4))) + (dotimes (s2-3 s4-0) + (format + fmt-dest + " #x~X: #x~4x #x~4x #x~4x #x~4x~%" + (+ (+ (* s2-3 8) 4) (the-as int vif-data)) + (-> (the-as (pointer uint16) (&+ s3-3 (* (* s2-3 4) 2)))) + (-> (the-as (pointer uint16) (&+ s3-3 (* (+ (* s2-3 4) 1) 2)))) + (-> (the-as (pointer uint16) (&+ s3-3 (* (+ (* s2-3 4) 2) 2)))) + (-> (the-as (pointer uint16) (&+ s3-3 (* (+ (* s2-3 4) 3) 2)))) + ) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-v3-32)) + (let ((s3-4 (&-> vif-data 4))) + (dotimes (s2-4 s4-0) + (format + fmt-dest + " #x~X: #x~8x #x~8x #x~8x~%" + (+ (+ (* 12 s2-4) 4) (the-as int vif-data)) + (-> (the-as (pointer uint32) (&+ s3-4 (* 12 s2-4)))) + (-> (the-as (pointer uint32) (&+ s3-4 (* (+ (* 3 s2-4) 1) 4)))) + (-> (the-as (pointer uint32) (&+ s3-4 (* (+ (* 3 s2-4) 2) 4)))) + ) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-v3-16)) + (let ((s3-5 (&-> vif-data 4))) + (dotimes (s2-5 s4-0) + (format + fmt-dest + " #x~X: #x~4x #x~4x #x~4x~%" + (+ (+ (* 6 s2-5) 4) (the-as int vif-data)) + (-> (the-as (pointer uint16) (&+ s3-5 (* 6 s2-5)))) + (-> (the-as (pointer uint16) (&+ s3-5 (* (+ (* 3 s2-5) 1) 2)))) + (-> (the-as (pointer uint16) (&+ s3-5 (* (+ (* 3 s2-5) 2) 2)))) + ) + ) + ) + ) + ((= unpack-cmd (vif-cmd unpack-v2-16)) + (let ((s3-6 (&-> vif-data 4))) + (dotimes (s2-6 s4-0) + (format + fmt-dest + " #x~X: #x~4x #x~4x~%" + (+ (+ (* s2-6 4) 4) (the-as int vif-data)) + (-> (the-as (pointer uint16) (&+ s3-6 (* 6 s2-6)))) + (-> (the-as (pointer uint16) (&+ s3-6 (* (+ (* 3 s2-6) 1) 2)))) + ) + ) + ) + ) + (else + (format + fmt-dest + " #x~X: Data format #b~b not yet supported, add it for yourself!~%" + (&-> vif-data 4) + unpack-cmd + ) + ) + ) + ) + #f + ) + +;; definition for function disasm-vif-tag +;; INFO: Used lq/sq +(defun disasm-vif-tag ((tag (pointer vif-tag)) (count int) (format-dest symbol) (details? symbol)) + "Disassemble vif tag, and possibly the associated data." + (let ((gp-0 0)) + (while (< gp-0 (* count 4)) + (let ((s0-0 4)) + (let ((s1-0 (-> tag 0))) + (format format-dest " #x~X:" tag) + (dotimes (v1-0 (-> *vif-disasm-table* length)) + (let ((sv-16 (-> s1-0 cmd))) + (when (= (logand sv-16 (-> *vif-disasm-table* v1-0 mask)) (-> *vif-disasm-table* v1-0 tag)) + (let ((a0-12 (-> *vif-disasm-table* v1-0 print))) + (cond + ((zero? a0-12) + (format format-dest " (~s :irq ~D)~%" (-> *vif-disasm-table* v1-0 string1) (-> s1-0 irq)) + ) + ((= a0-12 1) + (format + format-dest + " (~s :irq ~D :~s #x~X)~%" + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> *vif-disasm-table* v1-0 string2) + (-> s1-0 imm) + ) + ) + ((= a0-12 2) + (let ((t1-1 (-> s1-0 imm))) + (format + format-dest + " (~s :irq ~D :wl ~D :cl ~D)~%" + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (shr (shl t1-1 48) 56) + (shr (shl t1-1 56) 56) + ) + ) + ) + ((= a0-12 3) + (set! s0-0 8) + (format + format-dest + " (~s :irq ~D :~s #x~X)~%" + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> *vif-disasm-table* v1-0 string2) + (-> tag 1) + ) + ) + ((= a0-12 4) + (set! s0-0 20) + (format + format-dest + " (~s :irq ~D :~s " + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> *vif-disasm-table* v1-0 string2) + ) + (format format-dest "#x~X #x~X #x~X #x~X)~%" (-> tag 1) (-> tag 2) (-> tag 3) (-> tag 4)) + ) + ((= a0-12 5) + (format + format-dest + " (~s :irq ~D :instructions #x~D :addr #x~X)~%" + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> s1-0 num) + (-> s1-0 imm) + ) + ) + ((= a0-12 6) + (if (-> s1-0 imm) + (set! s0-0 #x100000) + (set! s0-0 (the-as int (* (-> s1-0 imm) 16))) + ) + (format + format-dest + " (~s :irq ~D :qwc #x~D)~%" + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> s1-0 imm) + ) + (let ((sv-32 (&-> tag 1)) + (sv-48 0) + ) + (while (< sv-48 (the-as int (-> s1-0 imm))) + (format + format-dest + " #x~X: #x~8x #x~8x #x~8x #x~8x~%" + (+ (+ (* sv-48 16) 4) (the-as int tag)) + (-> sv-32 (* sv-48 4)) + (-> sv-32 (+ (* sv-48 4) 1)) + (-> sv-32 (+ (* sv-48 4) 2)) + (-> sv-32 (+ (* sv-48 4) 3)) + ) + (+! sv-48 1) + ) + ) + #f + ) + ((= a0-12 7) + (set! s0-0 (the-as int (+ (logand -4 (+ (* (-> *vif-disasm-table* v1-0 val) (-> s1-0 num)) 3)) 4))) + (let ((sv-64 (-> s1-0 imm))) + (format + format-dest + " (~s :irq ~D :num ~D :addr #x~X " + (-> *vif-disasm-table* v1-0 string1) + (-> s1-0 irq) + (-> s1-0 num) + (shr (shl sv-64 54) 54) + ) + (format + format-dest + ":msk ~D :flg ~D :usn ~D [skip ~d])~%" + (-> s1-0 msk) + (shr (shl sv-64 48) 63) + (shr (shl sv-64 49) 63) + (the-as uint s0-0) + ) + ) + (if details? + (disasm-vif-details + format-dest + (the-as (pointer uint8) tag) + (logand sv-16 (vif-cmd cmd-mask)) + (the-as int (-> s1-0 num)) + ) + ) + ) + ((= a0-12 8) + (format format-dest " (*unknown* vif-tag #x~X)~%" (-> s1-0 cmd)) + ) + ) + ) + (set! v1-0 (-> *vif-disasm-table* length)) + ) + ) + ) + ) + (+! gp-0 s0-0) + (&+! tag s0-0) + ) + ) + (- gp-0 (* count 4)) + ) + ) + +;; definition for function disasm-dma-tag +;; WARN: Return type mismatch object vs none. +(defun disasm-dma-tag ((tag dma-tag) (format-dest symbol)) + "Disassemble just the 64-byte dma tag" + (format format-dest "(dma-tag ") + (let ((t9-1 format) + (a0-2 format-dest) + (a1-2 "~s") + (v1-1 (-> tag id)) + ) + (t9-1 a0-2 a1-2 (cond + ((= v1-1 (dma-tag-id refe)) + "refe" + ) + ((= v1-1 (dma-tag-id refs)) + "refs" + ) + ((= v1-1 (dma-tag-id ret)) + "ret" + ) + ((= v1-1 (dma-tag-id cnt)) + "cnt" + ) + ((= v1-1 (dma-tag-id next)) + "next" + ) + ((= v1-1 (dma-tag-id call)) + "call" + ) + ((= v1-1 (dma-tag-id ref)) + "ref" + ) + ((= v1-1 (dma-tag-id end)) + "end" + ) + (else + "*unknown*" + ) + ) + ) + ) + (if (> (-> tag addr) 0) + (format format-dest " :addr #x~8x" (-> tag addr)) + ) + (if (> (-> tag qwc) 0) + (format format-dest " :qwc ~d" (-> tag qwc)) + ) + (if (> (-> tag spr) 0) + (format format-dest " :spr ~d" (-> tag spr)) + ) + (if (> (-> tag irq) 0) + (format format-dest " :irq ~d" (-> tag irq)) + ) + (if (> (-> tag pce) 0) + (format format-dest " :pce ~d" (-> tag pce)) + ) + (format format-dest ")~%") + (none) + ) + +;; definition for symbol *dma-disasm*, type symbol +(define *dma-disasm* #t) + +;; definition for function disasm-dma-list +;; WARN: Check prologue - tricky store of a0 +;; INFO: Used lq/sq +(defun disasm-dma-list ((data dma-packet) (mode symbol) (verbose symbol) (stream symbol) (expected-size int)) + "Print out an entire DMA list. + If mode is #t, print vif tags too. If mode is 'details, also print data unpacked by vif-tags. + If verbose is #t, print out the addresses of each tag, and total size statistics. + If expected size is negative, it is ignored. Otherwise, only disassemble this much dma data." + (let ((sv-32 data) + (s2-0 mode) + (s3-0 verbose) + (gp-0 stream) + (s1-0 expected-size) + ) + (if s3-0 + (format gp-0 "~%--- ~X -----------------------------~%" sv-32) + ) + (let ((s0-0 #f)) + (let ((s4-0 0) + (s5-0 0) + ) + (let ((sv-16 (the-as uint 0)) + (sv-48 0) + (sv-64 (the-as dma-packet 0)) + (sv-80 (the-as dma-packet 1)) + (sv-96 -1) + (sv-112 (new 'static 'dma-tag)) + ) + (while (not s0-0) + (let ((t9-1 valid?) + (a0-2 sv-32) + (a1-2 #f) + (a2-2 "dma-list tag pointer") + ) + (cond + ((not (t9-1 a0-2 (the-as type a1-2) a2-2 #t gp-0)) + (format gp-0 "ERROR: dma-list tag pointer invalid~%") + (set! s0-0 'error) + ) + (else + (set! sv-112 (-> (the-as dma-packet sv-32) dma)) + (when (not (or (zero? s5-0) (let ((t9-3 valid?) + (a0-4 sv-16) + (a1-4 #f) + ) + (set! a2-2 "dma-list data pointer") + (t9-3 a0-4 (the-as type a1-4) a2-2 #t gp-0) + ) + ) + ) + (format gp-0 "ERROR: dma-list data pointer invalid~%") + (set! s0-0 'error) + ) + (when (logtest? (the-as dma-tag #x3ff0000) sv-112) + (format gp-0 "ERROR: dma tag has data in reserved bits ~X~%" (the-as none a2-2)) + (set! s0-0 'error) + ) + ) + ) + ) + (when (or s3-0 (= s0-0 'error)) + (format gp-0 "#x~8x: " sv-32) + (cond + ((zero? sv-96) + (format gp-0 " ") + ) + ((= sv-96 1) + (format gp-0 " ") + ) + ) + (disasm-dma-tag sv-112 gp-0) + ) + (cond + (s0-0 + ) + ((or (= (-> sv-112 id) (dma-tag-id ref)) (= (-> sv-112 id) (dma-tag-id refs)) (zero? (-> sv-112 id))) + (set! sv-16 (-> sv-112 addr)) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (when s2-0 + (let ((v0-10 + (disasm-vif-tag (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) 2 gp-0 (= s2-0 'details)) + ) + ) + (disasm-vif-tag + (the-as (pointer vif-tag) (+ (the-as int sv-16) v0-10)) + (the-as int (- (* (the-as uint sv-48) 4) (the-as uint (/ v0-10 4)))) + gp-0 + (= s2-0 'details) + ) + ) + ) + (set! sv-32 (the-as dma-packet (&-> (the-as (pointer uint64) sv-32) 2))) + (if (= (-> sv-112 id) (dma-tag-id refe)) + (set! s0-0 #t) + ) + ) + ((= (-> sv-112 id) (dma-tag-id cnt)) + (set! sv-16 (the-as uint (&-> (the-as (pointer uint64) sv-32) 2))) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (if s2-0 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) + (the-as int (+ (* (the-as uint sv-48) 4) 2)) + gp-0 + (= s2-0 'details) + ) + ) + (set! sv-32 (the-as dma-packet (+ (the-as uint sv-32) (* (+ (the-as uint sv-48) 1) 16)))) + sv-32 + ) + ((= (-> sv-112 id) (dma-tag-id next)) + (set! sv-16 (the-as uint (&-> (the-as (pointer uint64) sv-32) 2))) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (if s2-0 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) + (the-as int (+ (* (the-as uint sv-48) 4) 2)) + gp-0 + (= s2-0 'details) + ) + ) + (when (= sv-32 (-> sv-112 addr)) + (format gp-0 "ERROR: next tag creates infinite loop.~%") + (set! s0-0 'error) + ) + (set! sv-32 (the-as dma-packet (-> sv-112 addr))) + sv-32 + ) + ((= (-> sv-112 id) (dma-tag-id call)) + (set! sv-16 (the-as uint (&-> (the-as (pointer uint64) sv-32) 2))) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (if s2-0 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) + (the-as int (+ (* (the-as uint sv-48) 4) 2)) + gp-0 + (= s2-0 'details) + ) + ) + (set! sv-32 (the-as dma-packet (-> sv-112 addr))) + (+! sv-96 1) + (cond + ((zero? sv-96) + (set! sv-64 (the-as dma-packet (&+ (the-as (pointer uint64) sv-16) (the-as uint sv-48)))) + sv-64 + ) + (else + (set! sv-80 (the-as dma-packet (&+ (the-as (pointer uint64) sv-16) (the-as uint sv-48)))) + sv-80 + ) + ) + ) + ((= (-> sv-112 id) (dma-tag-id ret)) + (set! sv-16 (the-as uint (&-> (the-as (pointer uint64) sv-32) 2))) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (if s2-0 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) + (the-as int (+ (* (the-as uint sv-48) 4) 2)) + gp-0 + (= s2-0 'details) + ) + ) + (let ((v1-123 sv-96)) + (cond + ((zero? v1-123) + (set! sv-32 sv-64) + sv-32 + ) + ((= v1-123 1) + (set! sv-32 sv-80) + sv-32 + ) + (else + (set! s0-0 #t) + ) + ) + ) + (+! sv-96 -1) + sv-96 + ) + ((= (-> sv-112 id) (dma-tag-id end)) + (set! sv-16 (the-as uint (&-> (the-as (pointer uint64) sv-32) 2))) + (set! sv-48 (the-as int (-> sv-112 qwc))) + (set! s0-0 #t) + (if s2-0 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) sv-32) 1)) + (the-as int (+ (* (the-as uint sv-48) 4) 2)) + gp-0 + (= s2-0 'details) + ) + ) + ) + (else + (format gp-0 "ERROR: Unknown DMA TAG command.~%") + (set! s0-0 'error) + ) + ) + (+! s4-0 sv-48) + (+! s5-0 1) + (if (and (>= s1-0 0) (>= s5-0 s1-0)) + (set! s0-0 #t) + ) + ) + ) + (when (or s3-0 (= s0-0 'error)) + (format gp-0 "NOTICE: Total tags: ~d~%" s5-0) + (format gp-0 "NOTICE: Total QWC: ~d~%" s4-0) + (format gp-0 "--------------------------------~%~%") + ) + ) + (!= s0-0 'error) + ) + ) + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/dma/dma-h_REF.gc b/test/decompiler/reference/jakx/engine/dma/dma-h_REF.gc new file mode 100644 index 0000000000..30a1d7e76b --- /dev/null +++ b/test/decompiler/reference/jakx/engine/dma/dma-h_REF.gc @@ -0,0 +1,360 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type dma-chcr +(deftype dma-chcr (uint32) + "Memory mapped DMA channel control register. Typically used to start and check on DMA transfer." + ((dir uint8 :offset 0 :size 1) + (mod uint8 :offset 2 :size 2) + (asp uint8 :offset 4 :size 2) + (tte uint8 :offset 6 :size 1) + (tie uint8 :offset 7 :size 1) + (str uint8 :offset 8 :size 1) + (tag uint16 :offset 16 :size 16) + ) + ) + +;; definition for method 3 of type dma-chcr +(defmethod inspect ((this dma-chcr)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'dma-chcr) + (format #t "~1Tdir: ~D~%" (-> this dir)) + (format #t "~1Tmod: ~D~%" (-> this mod)) + (format #t "~1Tasp: ~D~%" (-> this asp)) + (format #t "~1Ttte: ~D~%" (-> this tte)) + (format #t "~1Ttie: ~D~%" (-> this tie)) + (format #t "~1Tstr: ~D~%" (-> this str)) + (format #t "~1Ttag: #x~X~%" (-> this tag)) + (label cfg-4) + this + ) + +;; definition of type dma-bank +(deftype dma-bank (structure) + "Bank of memory mapped DMA registers for a single channel. Used to control DMA." + ((chcr dma-chcr :offset 0) + (madr uint32 :offset 16) + (qwc uint32 :offset 32) + ) + ) + +;; definition for method 3 of type dma-bank +(defmethod inspect ((this dma-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'dma-bank) + (format #t "~1Tchcr: #x~X~%" (-> this chcr)) + (format #t "~1Tmadr: #x~X~%" (-> this madr)) + (format #t "~1Tqwc: #x~X~%" (-> this qwc)) + (label cfg-4) + this + ) + +;; definition of type dma-bank-source +(deftype dma-bank-source (dma-bank) + "DMA channel registers for a DMA channel supporting source-chain." + ((tadr uint32 :offset 48) + ) + ) + +;; definition for method 3 of type dma-bank-source +(defmethod inspect ((this dma-bank-source)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'dma-bank-source) + (format #t "~1Tchcr: #x~X~%" (-> this chcr)) + (format #t "~1Tmadr: #x~X~%" (-> this madr)) + (format #t "~1Tqwc: #x~X~%" (-> this qwc)) + (format #t "~1Ttadr: #x~X~%" (-> this tadr)) + (label cfg-4) + this + ) + +;; definition of type dma-bank-vif +(deftype dma-bank-vif (dma-bank-source) + "DMA channel registers for a DMA channel with call/ret stack." + ((as0 uint32 :offset 64) + (as1 uint32 :offset 80) + ) + ) + +;; definition for method 3 of type dma-bank-vif +(defmethod inspect ((this dma-bank-vif)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'dma-bank-vif) + (format #t "~1Tchcr: #x~X~%" (-> this chcr)) + (format #t "~1Tmadr: #x~X~%" (-> this madr)) + (format #t "~1Tqwc: #x~X~%" (-> this qwc)) + (format #t "~1Ttadr: #x~X~%" (-> this tadr)) + (format #t "~1Tas0: #x~X~%" (-> this as0)) + (format #t "~1Tas1: #x~X~%" (-> this as1)) + (label cfg-4) + this + ) + +;; definition of type dma-bank-spr +(deftype dma-bank-spr (dma-bank-source) + "DMA channel registers for a DMA channel supporting scratchpad transfer." + ((sadr uint32 :offset 128) + ) + ) + +;; definition for method 3 of type dma-bank-spr +(defmethod inspect ((this dma-bank-spr)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'dma-bank-spr) + (format #t "~1Tchcr: #x~X~%" (-> this chcr)) + (format #t "~1Tmadr: #x~X~%" (-> this madr)) + (format #t "~1Tqwc: #x~X~%" (-> this qwc)) + (format #t "~1Ttadr: #x~X~%" (-> this tadr)) + (format #t "~1Tsadr: #x~X~%" (-> this sadr)) + (label cfg-4) + this + ) + +;; definition of type dma-ctrl +(deftype dma-ctrl (uint32) + "Main DMA control register, shared for all channels." + ((dmae uint8 :offset 0 :size 1) + (rele uint8 :offset 1 :size 1) + (mfd uint8 :offset 2 :size 2) + (sts uint8 :offset 4 :size 2) + (std uint8 :offset 6 :size 2) + (rcyc uint8 :offset 8 :size 3) + ) + ) + +;; definition of type dma-enable +(deftype dma-enable (uint32) + ((cpnd uint8 :offset 16 :size 1) + ) + ) + +;; definition of type dma-sqwc +(deftype dma-sqwc (uint32) + ((sqwc uint8 :offset 0 :size 8) + (tqwc uint8 :offset 16 :size 8) + ) + ) + +;; definition of type dma-bank-control +(deftype dma-bank-control (structure) + "Memory mapping for shared DMA registers." + ((ctrl dma-ctrl :offset 0) + (stat uint32 :offset 16) + (pcr uint32 :offset 32) + (sqwc dma-sqwc :offset 48) + (rbsr uint32 :offset 64) + (rbor uint32 :offset 80) + (stadr uint32 :offset 96) + (enabler uint32 :offset 5408) + (enablew uint32 :offset 5520) + ) + ) + +;; definition for method 3 of type dma-bank-control +(defmethod inspect ((this dma-bank-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'dma-bank-control) + (format #t "~1Tctrl: #x~X~%" (-> this ctrl)) + (format #t "~1Tstat: #x~X~%" (-> this stat)) + (format #t "~1Tpcr: #x~X~%" (-> this pcr)) + (format #t "~1Tsqwc: #x~X~%" (-> this sqwc)) + (format #t "~1Trbsr: #x~X~%" (-> this rbsr)) + (format #t "~1Trbor: #x~X~%" (-> this rbor)) + (format #t "~1Tstadr: #x~X~%" (-> this stadr)) + (format #t "~1Tenabler: ~D~%" (-> this enabler)) + (format #t "~1Tenablew: ~D~%" (-> this enablew)) + (label cfg-4) + this + ) + +;; definition of type vu-code-block +(deftype vu-code-block (basic) + "Unused type for some VU code. vu-function is used instead." + ((name basic) + (code uint32) + (size int32) + (dest-address uint32) + ) + ) + +;; definition for method 3 of type vu-code-block +(defmethod inspect ((this vu-code-block)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tcode: #x~X~%" (-> this code)) + (format #t "~1Tsize: ~D~%" (-> this size)) + (format #t "~1Tdest-address: ~D~%" (-> this dest-address)) + (label cfg-4) + this + ) + +;; definition of type vu-stat +(deftype vu-stat (uint64) + () + ) + +;; definition of type dma-tag +(deftype dma-tag (uint64) + "The 64-bit tag used by the DMA system." + ((qwc uint16 :offset 0 :size 16) + (pce uint8 :offset 26 :size 2) + (id dma-tag-id :offset 28 :size 3) + (irq uint8 :offset 31 :size 1) + (addr uint32 :offset 32 :size 31) + (spr uint8 :offset 63 :size 1) + ) + ) + +;; definition for method 3 of type dma-tag +(defmethod inspect ((this dma-tag)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'dma-tag) + (format #t "~1Tqwc: ~D~%" (-> this qwc)) + (format #t "~1Tpce: ~D~%" (-> this pce)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tirq: ~D~%" (-> this irq)) + (format #t "~1Taddr: #x~X~%" (-> this addr)) + (format #t "~1Tspr: ~D~%" (-> this spr)) + (label cfg-4) + this + ) + +;; definition of type dma-bucket +(deftype dma-bucket (structure) + "A linked list of DMA data, typically all in the same category. Used to organize the full DMA chain." + ((tag dma-tag) + (last (pointer dma-tag)) + (dummy uint32) + (next uint32 :offset 4) + (clear uint64 :overlay-at last) + (vif0 uint32 :overlay-at last) + (vif1 uint32 :overlay-at dummy) + ) + ) + +;; definition for method 3 of type dma-bucket +(defmethod inspect ((this dma-bucket)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'dma-bucket) + (format #t "~1Ttag: ~D~%" (-> this tag)) + (format #t "~1Tlast: #x~X~%" (-> this last)) + (format #t "~1Tdummy: ~D~%" (-> this dummy)) + (format #t "~1Tnext: #x~X~%" (-> this next)) + (format #t "~1Tclear: ~D~%" (-> this clear)) + (format #t "~1Tvif0: ~D~%" (-> this last)) + (format #t "~1Tvif1: ~D~%" (-> this dummy)) + (label cfg-4) + this + ) + +;; definition of type vif-mask +(deftype vif-mask (uint32) + ((m0 uint8 :offset 0 :size 2) + (m1 uint8 :offset 2 :size 2) + (m2 uint8 :offset 4 :size 2) + (m3 uint8 :offset 6 :size 2) + (m4 uint8 :offset 8 :size 2) + (m5 uint8 :offset 10 :size 2) + (m6 uint8 :offset 12 :size 2) + (m7 uint8 :offset 14 :size 2) + (m8 uint8 :offset 16 :size 2) + (m9 uint8 :offset 18 :size 2) + (m10 uint8 :offset 20 :size 2) + (m11 uint8 :offset 22 :size 2) + (m12 uint8 :offset 24 :size 2) + (m13 uint8 :offset 26 :size 2) + (m14 uint8 :offset 28 :size 2) + (m15 uint8 :offset 30 :size 2) + ) + ) + +;; definition of type vif-stcycl-imm +(deftype vif-stcycl-imm (uint16) + "The imm field of a VIF code using STCYCL, which adjusts the pattern for storing data." + ((cl uint8 :offset 0 :size 8) + (wl uint8 :offset 8 :size 8) + ) + ) + +;; definition of type vif-unpack-imm +(deftype vif-unpack-imm (uint16) + "The imm field of a VIF code using UNPACK, which transfers data to VU memory." + ((addr uint16 :offset 0 :size 10) + (usn uint8 :offset 14 :size 1) + (flg uint8 :offset 15 :size 1) + ) + ) + +;; definition of type vif-tag +(deftype vif-tag (uint32) + "A tag consumed by the VIF, which accepts DMA data." + ((imm uint16 :offset 0 :size 16) + (num uint8 :offset 16 :size 8) + (cmd vif-cmd :offset 24 :size 7) + (irq uint8 :offset 31 :size 1) + (msk uint8 :offset 28 :size 1) + ) + ) + +;; definition for method 3 of type vif-tag +(defmethod inspect ((this vif-tag)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'vif-tag) + (format #t "~1Timm: #x~X~%" (-> this imm)) + (format #t "~1Tnum: ~D~%" (-> this num)) + (format #t "~1Tcmd: #x~X~%" (-> this cmd)) + (format #t "~1Tmsk: ~D~%" (-> this msk)) + (format #t "~1Tirq: ~D~%" (-> this irq)) + (label cfg-4) + this + ) + +;; definition for function dma-sync-fast +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function dma-send-no-scratch +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function dma-sync-with-count +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function dma-count-until-done +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/draw/draw-node-h_REF.gc b/test/decompiler/reference/jakx/engine/draw/draw-node-h_REF.gc new file mode 100644 index 0000000000..5f02c686e4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/draw/draw-node-h_REF.gc @@ -0,0 +1,74 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type draw-node +(deftype draw-node (drawable) + "Node in a bounding volume heirarchy. This is a base class, and there are no children. +The child is a pointer to the start of inline array of drawables (note: not a drawable-inline-array, literally a bunch of plain drawables) +The size of this array is child-count. The type is either more draw-nodes, or, some other drawable like tfragment, depending on the flags. +Different renderers have different restrictions on the tree structure, like max child count, or if all children have the same depth. +Generally, tfrag/collide use a very rigid equal depth, max 8 children rule, but with shrub, anything goes. +This is a very awkward data structure to traverse, but it is designed for fast view frustum culling. +Note that there can be multiple ways to reach drawables in here in some cases - for example you can follow +this tree, or check one of the depth arrays found in tfrag. +" + ((child-count uint8 :offset 6) + (flags uint8 :offset 7) + (child drawable :offset 8) + (distance float :offset 12) + ) + ) + +;; definition for method 3 of type draw-node +(defmethod inspect ((this draw-node)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tchild-count: ~D~%" (-> this child-count)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tchild: #x~X~%" (-> this child)) + (format #t "~1Tdistance: #x~X~%" (-> this distance)) + (label cfg-4) + this + ) + +;; definition of type drawable-inline-array-node +(deftype drawable-inline-array-node (drawable-inline-array) + "Top level container for a BVH made of draw-nodes." + ((data draw-node 1 :inline) + (pad uint32) + ) + ) + +;; definition of type draw-node-dma +(deftype draw-node-dma (structure) + "DMA buffer layout for draw node culling routine, which copies draw-nodes directly to scratchpad in bulk. +This would not work with the memory layout of shrub." + ((banka draw-node 32 :inline) + (bankb draw-node 32 :inline) + ) + ) + +;; definition for method 3 of type draw-node-dma +(defmethod inspect ((this draw-node-dma)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'draw-node-dma) + (format #t "~1Tbanka[32] @ #x~X~%" (-> this banka)) + (format #t "~1Tbankb[32] @ #x~X~%" (-> this bankb)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/draw/drawable-actor-h_REF.gc b/test/decompiler/reference/jakx/engine/draw/drawable-actor-h_REF.gc new file mode 100644 index 0000000000..c84f3ca7e3 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/draw/drawable-actor-h_REF.gc @@ -0,0 +1,52 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type drawable-actor +(deftype drawable-actor (drawable) + "Wrapper around an entity-actor to put it in the drawable system. +Note that this is never used to actually draw actors - it is just used as a list of all entity-actors +for the entity/birth system." + ((actor entity-actor :offset 8) + ) + ) + +;; definition for method 3 of type drawable-actor +(defmethod inspect ((this drawable-actor)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tactor: ~A~%" (-> this actor)) + (label cfg-4) + this + ) + +;; definition of type drawable-tree-actor +(deftype drawable-tree-actor (drawable-tree) + "Adapater for putting the actors in the tree-array." + () + ) + +;; definition of type drawable-inline-array-actor +(deftype drawable-inline-array-actor (drawable-inline-array) + "Array of drawable-actors." + ((data drawable-actor 1 :inline) + (pad uint8 4) + ) + ) + +;; definition for method 10 of type drawable-tree-actor +;; WARN: Return type mismatch int vs none. +(defmethod draw ((this drawable-tree-actor)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/draw/drawable-group-h_REF.gc b/test/decompiler/reference/jakx/engine/draw/drawable-group-h_REF.gc new file mode 100644 index 0000000000..5ff66b8209 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/draw/drawable-group-h_REF.gc @@ -0,0 +1,39 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type drawable-group +(deftype drawable-group (drawable) + "Base class for an array of references to other drawables. +These are typically used for very high-level organization of drawable." + ((length int16 :offset 6) + (data drawable :dynamic) + ) + (:methods + (new (symbol type int) _type_) + ) + ) + +;; definition for method 3 of type drawable-group +(defmethod inspect ((this drawable-group)) + (when (not this) + (set! this this) + (goto cfg-7) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (dotimes (s5-0 (-> this length)) + (format #t "~T [~D]~1Tdata: ~A~%" s5-0 (-> this data s5-0)) + ) + (label cfg-7) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/draw/drawable-h_REF.gc b/test/decompiler/reference/jakx/engine/draw/drawable-h_REF.gc new file mode 100644 index 0000000000..2874baf2e5 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/draw/drawable-h_REF.gc @@ -0,0 +1,66 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type drawable +(deftype drawable (basic) + "Base class for `drawable` scene graph system. +This base class is really abused in many ways, and the meaning of the various methods differ depending +on the exact type. Not even the ID and bsphere here are always populated. +This is used for very high level organization of different rendering data types, and also very low-level +culling/rendering optimizations. It supports both array-of-references and inline-array containers with precise +control over memory layout for use with DMA." + ((id int16) + (bsphere vector :inline) + ) + (:methods + (login (_type_) _type_) + (draw (_type_) none) + (drawable-method-11 (_type_) none) + (drawable-method-12 (_type_) none) + (collect-stats (_type_) none) + (debug-draw (_type_) none) + (unpack-vis (_type_ (pointer int8) (pointer int8)) (pointer int8)) + (collect-regions (_type_ sphere int region-prim-list) none) + ) + ) + +;; definition for method 3 of type drawable +(defmethod inspect ((this drawable)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (label cfg-4) + this + ) + +;; definition of type drawable-error +(deftype drawable-error (drawable) + "A drawable which just represents an error. When drawn, it simply displays a sphere with an error message." + ((name string) + ) + ) + +;; definition for method 3 of type drawable-error +(defmethod inspect ((this drawable-error)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tname: ~A~%" (-> this name)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/draw/drawable-inline-array-h_REF.gc b/test/decompiler/reference/jakx/engine/draw/drawable-inline-array-h_REF.gc new file mode 100644 index 0000000000..eae834268e --- /dev/null +++ b/test/decompiler/reference/jakx/engine/draw/drawable-inline-array-h_REF.gc @@ -0,0 +1,29 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type drawable-inline-array +(deftype drawable-inline-array (drawable) + ((length int16 :offset 6) + ) + ) + +;; definition for method 3 of type drawable-inline-array +(defmethod inspect ((this drawable-inline-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/draw/drawable-tree-h_REF.gc b/test/decompiler/reference/jakx/engine/draw/drawable-tree-h_REF.gc new file mode 100644 index 0000000000..99aaa84f16 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/draw/drawable-tree-h_REF.gc @@ -0,0 +1,25 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type drawable-tree +(deftype drawable-tree (drawable-group) + "A drawable tree is a container of drawables of a specific rendering type. +Instead of having a single large tree of mixed types, there will be a tree of tfrags, a tree of ties, etc. +The top-level tfrag tree will have a type that's a child of drawable-tree. +Generally, the object passed to a large renderer is a drawable-tree." + () + ) + +;; definition of type drawable-tree-array +(deftype drawable-tree-array (drawable-group) + "Collection of drawable trees. This might have a tfrag tree, tie tree, etc." + ((trees drawable-tree :dynamic :offset 32) + ) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/engine/connect_REF.gc b/test/decompiler/reference/jakx/engine/engine/connect_REF.gc new file mode 100644 index 0000000000..c06fa79809 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/engine/connect_REF.gc @@ -0,0 +1,856 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type connectable +(deftype connectable (structure) + ((next0 connectable) + (prev0 connectable) + (next1 connectable) + (prev1 connectable) + ) + ) + +;; definition for method 3 of type connectable +(defmethod inspect ((this connectable)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'connectable) + (format #t "~1Tnext0: ~`connectable`P~%" (-> this next0)) + (format #t "~1Tprev0: ~`connectable`P~%" (-> this prev0)) + (format #t "~1Tnext1: ~`connectable`P~%" (-> this next1)) + (format #t "~1Tprev1: ~`connectable`P~%" (-> this prev1)) + (label cfg-4) + this + ) + +;; definition of type connection +(deftype connection (connectable) + "This is the actual data for the connection. +It may be used in multiple ways, but the most common is to use `param0` as a function. +It receives `param1`, `param2`, `param3`, and the engine as the arguments. +In some cases, the return value is checked for `'dead`." + ((param0 basic) + (param1 basic) + (param2 int32) + (param3 int32) + (quad uint128 2 :overlay-at next0) + ) + (:methods + (get-engine (connection) engine) + (get-process (connection) process) + (belongs-to-engine? (connection engine) symbol) + (belongs-to-process? (connection process) symbol) + (move-to-dead (connection) connection) + ) + ) + +;; definition for method 3 of type connection +(defmethod inspect ((this connection)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'connection) + (format #t "~1Tnext0: ~`connectable`P~%" (-> this next0)) + (format #t "~1Tprev0: ~`connectable`P~%" (-> this prev0)) + (format #t "~1Tnext1: ~`connectable`P~%" (-> this next1)) + (format #t "~1Tprev1: ~`connectable`P~%" (-> this prev1)) + (format #t "~1Tparam0: ~A~%" (-> this param0)) + (format #t "~1Tparam1: ~A~%" (-> this param1)) + (format #t "~1Tparam2: ~A~%" (-> this param2)) + (format #t "~1Tparam3: ~A~%" (-> this param3)) + (format #t "~1Tquad[2] @ #x~X~%" (&-> this next0)) + (label cfg-4) + this + ) + +;; definition of type engine +(deftype engine (basic) + "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. + +New for Jak 2: You can use a child class of [[connection]]." + ((name symbol) + (engine-time time-frame :offset 16) + (allocated-length int16 :offset 10) + (length int16 :offset 8) + (element-type type :offset 12) + (alive-list connectable :inline) + (alive-list-end connectable :inline) + (dead-list connectable :inline) + (dead-list-end connectable :inline) + (data connection :inline :dynamic) + ) + (:methods + (new (symbol type symbol int type) _type_) + (inspect-all-connections (engine) engine) + (apply-to-connections (engine (function connectable none)) int) + (apply-to-connections-reverse (engine (function connectable none)) int) + (execute-connections (engine object) int) + (execute-connections-and-move-to-dead (engine object) int) + (execute-connections-if-needed (engine object) int) + (add-connection (engine process object object object object) connection) + (remove-from-process (engine process) int) + (remove-matching (engine (function connection engine symbol)) int) + (remove-all (engine) int) + (remove-by-param0 (engine object) int) + (remove-by-param1 (engine int) int) + (remove-by-param2 (engine int) int) + (get-first-connectable (engine) connectable) + (get-last-connectable (engine) connectable) + (get-next-connectable (_type_ connectable) connectable) + (get-prev-connectable (_type_ connectable) connectable) + ) + ) + +;; definition for method 12 of type connection +(defmethod belongs-to-process? ((this connection) (arg0 process)) + "Does this connection belong to the given process?" + (= arg0 (get-process this)) + ) + +;; definition for method 2 of type connection +(defmethod print ((this connection)) + (format + #t + "#" + (-> this param0) + (-> this param1) + (-> this param2) + (-> this param3) + this + ) + this + ) + +;; definition for method 9 of type connection +;; WARN: Return type mismatch pointer vs engine. +(defmethod get-engine ((this connection)) + "Get the engine for this connection. This must be used on a live connection." + (while (-> (the-as connectable this) prev0) + (nop!) + (nop!) + (set! this (the-as connection (-> (the-as connectable this) prev0))) + ) + (the-as engine (&+ (the-as pointer this) -28)) + ) + +;; definition for method 10 of type connection +;; WARN: Return type mismatch pointer vs process. +(defmethod get-process ((this connection)) + "Get the process for this connection." + (while (-> (the-as connectable this) prev1) + (nop!) + (nop!) + (set! this (the-as connection (-> (the-as connectable this) prev1))) + ) + (the-as process (&+ (the-as pointer this) -124)) + ) + +;; definition for method 11 of type connection +(defmethod belongs-to-engine? ((this 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." + (and (< (the-as int arg0) (the-as int this)) + (< (the-as int this) (the-as int (&+ + (&+ (the-as pointer arg0) (-> arg0 type size)) + (* (-> arg0 allocated-length) (the-as int (-> arg0 element-type size))) + ) + ) + ) + ) + ) + +;; definition for method 22 of type engine +(defmethod get-first-connectable ((this engine)) + (-> this alive-list next0) + ) + +;; definition for method 23 of type engine +(defmethod get-last-connectable ((this engine)) + (-> this alive-list-end) + ) + +;; definition for method 24 of type engine +(defmethod get-next-connectable ((this engine) (arg0 connectable)) + (-> arg0 next0) + ) + +;; definition for method 25 of type engine +(defmethod get-prev-connectable ((this engine) (arg0 connectable)) + (-> arg0 prev0) + ) + +;; definition for method 0 of type engine +(defmethod new engine ((allocation symbol) (type-to-make type) (arg0 symbol) (arg1 int) (arg2 type)) + (let ((v0-0 + (object-new + allocation + type-to-make + (the-as int (+ (-> type-to-make size) (* (the-as uint arg1) (-> arg2 size)))) + ) + ) + ) + (set! (-> v0-0 allocated-length) arg1) + (set! (-> v0-0 length) 0) + (set! (-> v0-0 name) arg0) + (set! (-> v0-0 element-type) arg2) + (set! (-> v0-0 alive-list next0) (-> v0-0 alive-list-end)) + (set! (-> v0-0 alive-list prev0) #f) + (set! (-> v0-0 alive-list next1) #f) + (set! (-> v0-0 alive-list prev1) #f) + (set! (-> v0-0 alive-list-end next0) #f) + (set! (-> v0-0 alive-list-end prev0) (-> v0-0 alive-list)) + (set! (-> v0-0 alive-list-end next1) #f) + (set! (-> v0-0 alive-list-end prev1) #f) + (set! (-> v0-0 dead-list next0) (the-as connectable (-> v0-0 data))) + (set! (-> v0-0 dead-list prev0) #f) + (set! (-> v0-0 dead-list next1) #f) + (set! (-> v0-0 dead-list prev1) #f) + (set! (-> v0-0 dead-list-end next0) #f) + (set! (-> v0-0 dead-list-end prev0) + (the-as connectable (+ (+ (* (the-as uint (+ arg1 -1)) (-> arg2 size)) 92) (the-as uint v0-0))) + ) + (set! (-> v0-0 dead-list-end next1) #f) + (set! (-> v0-0 dead-list-end prev1) #f) + (let ((v1-9 (the-as object (-> v0-0 data)))) + (set! (-> v0-0 data 0 prev0) (-> v0-0 dead-list)) + (set! (-> v0-0 data 0 next0) (the-as connectable (&+ (the-as pointer v1-9) (-> arg2 size)))) + (let ((v1-10 (the-as object (&+ (the-as pointer v1-9) (-> arg2 size))))) + (let ((a0-6 1) + (a1-3 (+ arg1 -2)) + ) + (while (>= a1-3 a0-6) + (set! (-> (the-as connectable v1-10) prev0) + (the-as connectable (&- (the-as pointer v1-10) (the-as uint (-> arg2 size)))) + ) + (set! (-> (the-as (pointer int32) v1-10)) (&+ (the-as pointer v1-10) (-> arg2 size))) + (set! v1-10 (&+ (the-as pointer v1-10) (-> arg2 size))) + (+! a0-6 1) + ) + ) + (set! (-> (the-as connectable v1-10) prev0) + (the-as connectable (&- (the-as pointer v1-10) (the-as uint (-> arg2 size)))) + ) + (set! (-> (the-as (pointer int32) v1-10)) (-> v0-0 dead-list-end)) + ) + ) + v0-0 + ) + ) + +;; definition for method 2 of type engine +(defmethod print ((this engine)) + (format #t "#<~A ~A @ #x~X>" (-> this type) (-> this name) this) + this + ) + +;; definition for method 3 of type engine +(defmethod inspect ((this engine)) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~Tname: ~A~%" (-> this name)) + (format #t "~Tengine-time: ~D~%" (-> this engine-time)) + (format #t "~Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~Tlength: ~D~%" (-> this length)) + (format #t "~Telement-type: ~A~%" (-> this element-type)) + (format #t "~Talive-list:~%") + (let ((s5-0 *print-column*)) + (set! *print-column* (+ *print-column* 64)) + (inspect (-> this alive-list)) + (set! *print-column* s5-0) + ) + (format #t "~Talive-list-end:~%") + (let ((s5-1 *print-column*)) + (set! *print-column* (+ *print-column* 64)) + (inspect (-> this alive-list-end)) + (set! *print-column* s5-1) + ) + (format #t "~Tdead-list:~%") + (let ((s5-2 *print-column*)) + (set! *print-column* (+ *print-column* 64)) + (inspect (-> this dead-list)) + (set! *print-column* s5-2) + ) + (format #t "~Tdead-list-end:~%") + (let ((s5-3 *print-column*)) + (set! *print-column* (+ *print-column* 64)) + (inspect (-> this dead-list-end)) + (set! *print-column* s5-3) + ) + (format #t "~Tdata[~D]: @ #x~X~%" (-> this allocated-length) (-> this data)) + this + ) + +;; definition for method 4 of type engine +(defmethod length ((this engine)) + (-> this length) + ) + +;; definition for method 5 of type engine +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this engine)) + (the-as int (+ (-> this type size) (* (-> this allocated-length) (the-as int (-> this element-type size))))) + ) + +;; definition for method 10 of type engine +(defmethod apply-to-connections ((this engine) (arg0 (function connectable none))) + "Apply arg0 to all connections for the engine. + It's okay to have arg0 remove the connection." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (arg0 a0-1) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +;; definition for method 11 of type engine +(defmethod apply-to-connections-reverse ((this engine) (arg0 (function connectable none))) + "Apply arg0 to all connections, reverse order. + Do not use arg0 to remove yourself from the list." + (let ((s4-0 (-> this alive-list-end prev0))) + (while (!= s4-0 (-> this alive-list)) + (arg0 s4-0) + (set! s4-0 (-> s4-0 prev0)) + ) + ) + 0 + ) + +;; definition for method 12 of type engine +(defmethod execute-connections ((this engine) (arg0 object)) + "Run the engine!" + (set! (-> this engine-time) (-> *display* real-clock frame-counter)) + (let ((s4-0 (the-as connection (-> this alive-list-end prev0)))) + (while (!= s4-0 (-> this alive-list)) + ((the-as (function object object object object object) (-> s4-0 param0)) + (-> s4-0 param1) + (-> s4-0 param2) + (-> s4-0 param3) + arg0 + ) + (set! s4-0 (the-as connection (-> s4-0 prev0))) + ) + ) + 0 + ) + +;; definition for method 13 of type engine +(defmethod execute-connections-and-move-to-dead ((this engine) (arg0 object)) + "Run the engine! If any objects return `'dead`, remove them." + (set! (-> this engine-time) (-> *display* real-clock frame-counter)) + (let ((s4-0 (the-as connection (-> this alive-list-end prev0)))) + (while (!= s4-0 (-> this alive-list)) + (let ((v1-3 ((the-as (function object object object object object) (-> s4-0 param0)) + (-> s4-0 param1) + (-> s4-0 param2) + (-> s4-0 param3) + arg0 + ) + ) + ) + (set! s4-0 (the-as connection (-> s4-0 prev0))) + (if (= v1-3 'dead) + ((method-of-type connection move-to-dead) (the-as connection (-> s4-0 next0))) + ) + ) + ) + ) + 0 + ) + +;; definition for method 14 of type engine +(defmethod execute-connections-if-needed ((this engine) (arg0 object)) + "Execute connections, but only if it hasn't been done on this frame." + (if (!= (-> *display* real-clock frame-counter) (-> this engine-time)) + (execute-connections this arg0) + ) + 0 + ) + +;; definition for function connection-process-apply +(defun connection-process-apply ((arg0 process) (arg1 (function object none))) + "Apply a function to all connectables of a process." + (when arg0 + (let ((s5-0 (-> arg0 connection-list next1))) + (while s5-0 + (arg1 s5-0) + (set! s5-0 (-> s5-0 next1)) + ) + ) + #f + ) + ) + +;; definition for method 9 of type engine +(defmethod inspect-all-connections ((this engine)) + "inspect all of the connections." + (let ((gp-0 *kernel-symbol-warnings*)) + (set! *kernel-symbol-warnings* #f) + (let* ((s4-0 (-> this alive-list next0)) + (s3-0 (-> s4-0 next0)) + ) + (while (!= s4-0 (-> this alive-list-end)) + (format + #t + "from process ~A:~%~`connection`I" + ((method-of-type connection get-process) (the-as connection s4-0)) + s4-0 + ) + (set! s4-0 s3-0) + (set! s3-0 (-> s3-0 next0)) + ) + ) + (set! *kernel-symbol-warnings* gp-0) + ) + this + ) + +;; definition for method 15 of type engine +(defmethod add-connection ((this engine) (arg0 process) (arg1 object) (arg2 object) (arg3 object) (arg4 object)) + "Add a connection between this engine and a given process." + (let ((v1-0 (the-as connection (-> this dead-list next0)))) + (when (not (or (not arg0) (= v1-0 (-> this dead-list-end)))) + (set! (-> v1-0 param0) (the-as basic arg1)) + (set! (-> v1-0 param1) (the-as basic arg2)) + (set! (-> v1-0 param2) (the-as int arg3)) + (set! (-> v1-0 param3) (the-as int arg4)) + (set! (-> this dead-list next0) (-> v1-0 next0)) + (set! (-> v1-0 next0 prev0) (-> this dead-list)) + (set! (-> v1-0 next0) (-> this alive-list next0)) + (set! (-> v1-0 next0 prev0) v1-0) + (set! (-> v1-0 prev0) (-> this alive-list)) + (set! (-> this alive-list next0) v1-0) + (set! (-> v1-0 next1) (-> arg0 connection-list next1)) + (if (-> v1-0 next1) + (set! (-> v1-0 next1 prev1) v1-0) + ) + (set! (-> v1-0 prev1) (-> arg0 connection-list)) + (set! (-> arg0 connection-list next1) v1-0) + (+! (-> this length) 1) + v1-0 + ) + ) + ) + +;; definition for method 13 of type connection +(defmethod move-to-dead ((this connection)) + "Move this connection from the alive list to the dead list." + (let ((v1-1 (get-engine this))) + (set! (-> this prev0 next0) (-> this next0)) + (set! (-> this next0 prev0) (-> this prev0)) + (set! (-> this prev1 next1) (-> this next1)) + (if (-> this next1) + (set! (-> this next1 prev1) (-> this prev1)) + ) + (set! (-> this next0) (-> v1-1 dead-list next0)) + (set! (-> this next0 prev0) this) + (set! (-> this prev0) (-> v1-1 dead-list)) + (set! (-> v1-1 dead-list next0) this) + (+! (-> v1-1 length) -1) + ) + this + ) + +;; definition for function process-disconnect +(defun process-disconnect ((arg0 process)) + "Disconnect all connections for the given process." + (when arg0 + (let ((gp-0 (-> arg0 connection-list next1))) + (while gp-0 + ((method-of-type connection move-to-dead) (the-as connection gp-0)) + (set! gp-0 (-> gp-0 next1)) + ) + ) + ) + 0 + ) + +;; definition for method 16 of type engine +(defmethod remove-from-process ((this engine) (arg0 process)) + "Remove all connections from process for this engine." + (when arg0 + (let ((s5-0 (-> arg0 connection-list next1))) + (while s5-0 + (if ((method-of-type connection belongs-to-engine?) (the-as connection s5-0) this) + ((method-of-type connection move-to-dead) (the-as connection s5-0)) + ) + (set! s5-0 (-> s5-0 next1)) + ) + ) + ) + 0 + ) + +;; definition for method 17 of type engine +(defmethod remove-matching ((this 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." + (let* ((s4-0 (-> this alive-list next0)) + (s3-0 (-> s4-0 next0)) + ) + (while (!= s4-0 (-> this alive-list-end)) + (if (arg0 (the-as connection s4-0) this) + ((method-of-type connection move-to-dead) (the-as connection s4-0)) + ) + (set! s4-0 s3-0) + (set! s3-0 (-> s3-0 next0)) + ) + ) + 0 + ) + +;; definition for method 18 of type engine +(defmethod remove-all ((this engine)) + "Remove all connections from an engine." + (let* ((a0-1 (-> this alive-list next0)) + (s5-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this 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)) + ) + ) + 0 + ) + +;; definition for method 19 of type engine +(defmethod remove-by-param0 ((this engine) (arg0 object)) + "Remove all connections with param0 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param0) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +;; definition for method 20 of type engine +(defmethod remove-by-param1 ((this engine) (arg0 int)) + "Remove all connections with param1 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param1) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +;; definition for method 21 of type engine +(defmethod remove-by-param2 ((this engine) (arg0 int)) + "Remove all connections with param2 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param2) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +;; definition of type connection-pers +(deftype connection-pers (structure) + "This is another engine system, very similar to the first, but not specific to a process. +Each connection has a `key`, which is like the process, but unlike normal engine, +the key's don't track which engine-pers they belong to. + +Unlike [[engine]], users can use [[engine-pers]] as a parent class." + ((next connection-pers) + (key object) + (update-time time-frame) + (param object 4) + (param-int32 int32 4 :overlay-at (-> param 0)) + (param-int64 int64 2 :overlay-at (-> param 0)) + (param-float float 4 :overlay-at (-> param 0)) + (param-quat uint128 :overlay-at (-> param 0)) + ) + ) + +;; definition for method 3 of type connection-pers +;; INFO: Used lq/sq +(defmethod inspect ((this connection-pers)) + (when (not this) + (set! this this) + (goto cfg-16) + ) + (format #t "[~8x] ~A~%" this 'connection-pers) + (format #t "~1Tnext: #~%" (-> this next)) + (format #t "~1Tkey: ~A~%" (-> this key)) + (format #t "~1Tupdate-time: ~D~%" (-> this update-time)) + (format #t "~1Tparam[4] @ #x~X~%" (-> this param)) + (dotimes (s5-0 4) + (format #t "~T [~D]~1Tparam: ~A~%" s5-0 (-> this param s5-0)) + ) + (format #t "~1Tparam-int32[4] @ #x~X~%" (-> this param)) + (dotimes (s5-1 4) + (format #t "~T [~D]~1Tparam-int32: ~D~%" s5-1 (-> this param s5-1)) + ) + (format #t "~1Tparam-int64[2] @ #x~X~%" (-> this param)) + (dotimes (s5-2 2) + (format #t "~T [~D]~1Tparam-int64: ~D~%" s5-2 (-> this param-int64 s5-2)) + ) + (format #t "~1Tparam-float[4] @ #x~X~%" (-> this param)) + (dotimes (s5-3 4) + (format #t "~T [~D]~1Tparam-float: ~f~%" s5-3 (the-as float (-> this param s5-3))) + ) + (format #t "~1Tparam-quat: #x~X~%" (-> this param-quat)) + (label cfg-16) + this + ) + +;; definition of type engine-pers +(deftype engine-pers (basic) + ((name symbol) + (length int16) + (allocated-length int16) + (element-type type) + (execute-time time-frame) + (alive-list connection-pers) + (dead-list connection-pers) + (data connection-pers :inline :dynamic) + ) + (:methods + (new (symbol type symbol int type) _type_) + (schedule-callback (_type_ object time-frame) connection-pers) + (kill-callback (_type_ connection-pers) none) + (kill-by-key (_type_ object) none) + (kill-matching (_type_ (function engine-pers connection-pers object object symbol) object object) none) + (update-callback (_type_) none) + (run-pending-updates! (_type_ time-frame) none) + ) + ) + +;; definition for method 3 of type engine-pers +(defmethod inspect ((this engine-pers)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Telement-type: ~A~%" (-> this element-type)) + (format #t "~1Texecute-time: ~D~%" (-> this execute-time)) + (format #t "~1Talive-list: #~%" (-> this alive-list)) + (format #t "~1Tdead-list: #~%" (-> this dead-list)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition for method 0 of type engine-pers +(defmethod new engine-pers ((allocation symbol) (type-to-make type) (arg0 symbol) (arg1 int) (arg2 type)) + (let ((v0-0 (object-new + allocation + type-to-make + (the-as int (+ (-> type-to-make size) (* (the-as uint arg1) (-> arg2 size)))) + ) + ) + ) + (set! (-> v0-0 allocated-length) arg1) + (set! (-> v0-0 length) 0) + (set! (-> v0-0 name) arg0) + (set! (-> v0-0 element-type) arg2) + (set! (-> v0-0 alive-list) #f) + (set! (-> v0-0 dead-list) (the-as connection-pers (-> v0-0 data))) + (let ((v1-3 (the-as object (-> v0-0 data)))) + (dotimes (a0-1 arg1) + (set! (-> (the-as (pointer pointer) v1-3) 0) (&+ (the-as pointer v1-3) (-> arg2 size))) + (set! v1-3 (&+ (the-as pointer v1-3) (-> arg2 size))) + ) + (set! (-> (the-as (pointer int32) (&- (the-as pointer v1-3) (the-as uint (-> arg2 size))))) #f) + ) + v0-0 + ) + ) + +;; definition for method 4 of type engine-pers +(defmethod length ((this engine-pers)) + (-> this length) + ) + +;; definition for method 5 of type engine-pers +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this engine-pers)) + (the-as int (+ (-> this type size) (* (-> this allocated-length) (the-as int (-> this element-type size))))) + ) + +;; definition for method 9 of type engine-pers +;; INFO: Used lq/sq +(defmethod schedule-callback ((this engine-pers) (arg0 object) (arg1 time-frame)) + "Get a connection for this key. + If no connection exists, add it. + Schedule an update to happen in arg1 seconds." + (local-vars (v0-0 connection-pers)) + (let ((v1-0 (-> this alive-list))) + (while v1-0 + (when (= arg0 (-> v1-0 key)) + (set! v0-0 v1-0) + (goto cfg-8) + ) + (set! v1-0 (-> v1-0 next)) + ) + ) + (set! v0-0 (-> this dead-list)) + (when v0-0 + (set! (-> this dead-list) (-> v0-0 next)) + (set! (-> v0-0 next) (-> this alive-list)) + (set! (-> this alive-list) v0-0) + (+! (-> this length) 1) + (set! (-> v0-0 key) arg0) + (set! (-> v0-0 param-quat) (the-as uint128 0)) + 0 + ) + (label cfg-8) + (if v0-0 + (set! (-> v0-0 update-time) (+ (-> this execute-time) arg1)) + ) + v0-0 + ) + +;; definition for method 10 of type engine-pers +;; WARN: Return type mismatch int vs none. +(defmethod kill-callback ((this engine-pers) (arg0 connection-pers)) + "Called when a connection is removed." + 0 + (none) + ) + +;; definition for method 13 of type engine-pers +;; WARN: Return type mismatch int vs none. +(defmethod update-callback ((this engine-pers)) + "Called when a connection is run. + Users can override this as needed." + 0 + (none) + ) + +;; definition for method 11 of type engine-pers +;; WARN: Return type mismatch int vs none. +(defmethod kill-by-key ((this engine-pers) (arg0 object)) + "Remove connections with this key, calling `kill-callback`." + (let ((s4-0 (&-> this alive-list)) + (s2-0 (-> this alive-list)) + ) + (while s2-0 + (let ((s3-0 (-> s2-0 next))) + (cond + ((!= arg0 (-> s2-0 key)) + (set! s4-0 (&-> s2-0 next)) + ) + (else + (kill-callback this s2-0) + (set! (-> s4-0 0) (-> s2-0 next)) + (set! (-> s2-0 next) (-> this dead-list)) + (set! (-> this dead-list) s2-0) + (+! (-> this length) -1) + ) + ) + (set! s2-0 s3-0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type engine-pers +;; WARN: Return type mismatch int vs none. +(defmethod kill-matching ((this engine-pers) + (arg0 (function engine-pers connection-pers object object symbol)) + (arg1 object) + (arg2 object) + ) + "Call the given function on each connection. If it returns truthy, kill that connection." + (let ((s2-0 (&-> this alive-list)) + (s0-0 (-> this alive-list)) + ) + (while s0-0 + (let ((s1-0 (-> s0-0 next))) + (cond + ((not (arg0 this s0-0 arg1 arg2)) + (set! s2-0 (&-> s0-0 next)) + ) + (else + (kill-callback this s0-0) + (set! (-> s2-0 0) (-> s0-0 next)) + (set! (-> s0-0 next) (-> this dead-list)) + (set! (-> this dead-list) s0-0) + (+! (-> this length) -1) + ) + ) + (set! s0-0 s1-0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 14 of type engine-pers +;; WARN: Return type mismatch int vs none. +(defmethod run-pending-updates! ((this engine-pers) (arg0 time-frame)) + "Run updates if they scheduled. If something is found that has no pending update, kill it. + Note that we won't kill things on this call if they fail to update their `update-time`. + They will survive until the next call to `run-pending-updates`! + (or you can modify their `update-time` before that to prevent them from being killed.)" + (let ((s4-0 (-> this execute-time)) + (s2-0 (&-> this alive-list)) + (s1-0 (-> this alive-list)) + ) + (while s1-0 + (let ((s3-0 (-> s1-0 next))) + (cond + ((>= (-> s1-0 update-time) s4-0) + (update-callback this) + (set! s2-0 (&-> s1-0 next)) + ) + (else + (kill-callback this s1-0) + (set! (-> s2-0 0) (-> s1-0 next)) + (set! (-> s1-0 next) (-> this dead-list)) + (set! (-> this dead-list) s1-0) + (+! (-> this length) -1) + ) + ) + (set! s1-0 s3-0) + ) + ) + ) + (set! (-> this execute-time) arg0) + 0 + (none) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/engine/engines_REF.gc b/test/decompiler/reference/jakx/engine/engine/engines_REF.gc new file mode 100644 index 0000000000..364f581cef --- /dev/null +++ b/test/decompiler/reference/jakx/engine/engine/engines_REF.gc @@ -0,0 +1,102 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(kmemopen global "engines") + +;; definition for symbol *background-draw-engine*, type engine +(define *background-draw-engine* (new 'global 'engine 'draw 6 connection)) + +;; definition for symbol *matrix-engine*, type (array handle) +(define *matrix-engine* (new 'global 'boxed-array handle 384)) + +;; failed to figure out what this is: +(set! (-> *matrix-engine* length) 0) + +;; definition for symbol *cloth-engine*, type (array handle) +(define *cloth-engine* (new 'global 'boxed-array handle 32)) + +;; failed to figure out what this is: +(set! (-> *cloth-engine* length) 0) + +;; definition for symbol *part-engine*, type engine +(define *part-engine* (new 'global 'engine 'sparticle-launcher 256 connection)) + +;; definition of type particle-local-space-info +(deftype particle-local-space-info (connection) + ((params basic 3 :overlay-at param1) + (mat-prev matrix :inline) + (mat-new matrix :inline) + (hand handle) + (flags part-local-space-flags) + (pad uint32 1) + ) + ) + +;; definition for method 3 of type particle-local-space-info +(defmethod inspect ((this particle-local-space-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'particle-local-space-info) + (format #t "~1Tnext0: ~`connectable`P~%" (-> this next0)) + (format #t "~1Tprev0: ~`connectable`P~%" (-> this prev0)) + (format #t "~1Tnext1: ~`connectable`P~%" (-> this next1)) + (format #t "~1Tprev1: ~`connectable`P~%" (-> this prev1)) + (format #t "~1Tparam0: ~A~%" (-> this param0)) + (format #t "~1Tparam1: ~A~%" (-> this param1)) + (format #t "~1Tparam2: ~A~%" (-> this param2)) + (format #t "~1Tparam3: ~A~%" (-> this param3)) + (format #t "~1Tquad[2] @ #x~X~%" (&-> this next0)) + (format #t "~1Tparams[3] @ #x~X~%" (-> this params)) + (format #t "~1Tmat-prev: #~%" (-> this mat-prev)) + (format #t "~1Tmat-new: #~%" (-> this mat-new)) + (format #t "~1Thand: ~D~%" (-> this hand)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tpad[1] @ #x~X~%" (-> this pad)) + (label cfg-4) + this + ) + +;; definition for symbol *cam-post-hook-engine*, type engine +(define *cam-post-hook-engine* (new 'global 'engine 'cam-post-hook-engine 4 connection)) + +;; definition for symbol *part-local-space-engine*, type engine +(define *part-local-space-engine* + (new 'global 'engine 'particle-local-space-info 112 particle-local-space-info) + ) + +;; definition for symbol *camera-engine*, type engine +(define *camera-engine* (new 'global 'engine 'camera-eng 128 connection)) + +;; this part is debug only +(when *debug-segment* +;; definition for symbol *debug-engine*, type engine +(define *debug-engine* (new 'debug 'engine 'debug 64 connection)) + +) +;; definition for symbol *pad-engine*, type engine +(define *pad-engine* (new 'global 'engine 'pad 4 connection)) + +;; definition for symbol *lightning-engine*, type engine +(define *lightning-engine* (new 'global 'engine 'lightning-control 64 connection)) + +;; definition for symbol *hud-engine*, type engine +(define *hud-engine* (new 'global 'engine 'hud 16 connection)) + +;; definition for symbol *prim-client-engine*, type engine +(define *prim-client-engine* (new 'global 'engine 'prim-client 32 connection)) + +;; definition for symbol *prim-engine*, type engine +(define *prim-engine* (new 'global 'engine 'prim-strip 128 connection)) + +;; definition for symbol *task-manager-engine*, type engine +(define *task-manager-engine* (new 'global 'engine 'task-manager 16 connection)) + +;; failed to figure out what this is: +(kmemclose) + + + + diff --git a/test/decompiler/reference/jakx/engine/entity/entity-h_REF.gc b/test/decompiler/reference/jakx/engine/entity/entity-h_REF.gc new file mode 100644 index 0000000000..356aee641b --- /dev/null +++ b/test/decompiler/reference/jakx/engine/entity/entity-h_REF.gc @@ -0,0 +1,353 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *generate-actor-vis*, type symbol +(define *generate-actor-vis* #f) + +;; definition for symbol *generate-actor-vis-start*, type symbol +(define *generate-actor-vis-start* #f) + +;; definition for symbol *generate-actor-vis-output*, type symbol +(define *generate-actor-vis-output* #f) + +;; definition of type entity-perm +(deftype entity-perm (structure) + "Entity information that gets persisted in the save file." + ((user-object object 2) + (user-uint64 uint64 :overlay-at (-> user-object 0)) + (user-float float 2 :overlay-at (-> user-object 0)) + (user-int32 int32 2 :overlay-at (-> user-object 0)) + (user-uint32 uint32 2 :overlay-at (-> user-object 0)) + (user-int16 int16 4 :overlay-at (-> user-object 0)) + (user-uint16 uint16 4 :overlay-at (-> user-object 0)) + (user-int8 int8 8 :overlay-at (-> user-object 0)) + (user-uint8 uint8 8 :overlay-at (-> user-object 0)) + (status entity-perm-status) + (dummy uint8 1) + (task game-task) + (aid actor-id) + (quad uint128 :overlay-at (-> user-object 0)) + ) + (:methods + (update (_type_ symbol entity-perm-status) _type_) + ) + ) + +;; definition for method 3 of type entity-perm +;; INFO: Used lq/sq +(defmethod inspect ((this entity-perm)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'entity-perm) + (format #t "~1Tuser-object[2] @ #x~X~%" (-> this user-object)) + (format #t "~1Tuser-uint64: ~D~%" (-> this user-uint64)) + (format #t "~1Tuser-float[2] @ #x~X~%" (-> this user-object)) + (format #t "~1Tuser-int32[2] @ #x~X~%" (-> this user-object)) + (format #t "~1Tuser-uint32[2] @ #x~X~%" (-> this user-object)) + (format #t "~1Tuser-int16[4] @ #x~X~%" (-> this user-object)) + (format #t "~1Tuser-uint16[4] @ #x~X~%" (-> this user-object)) + (format #t "~1Tuser-int8[8] @ #x~X~%" (-> this user-object)) + (format #t "~1Tuser-uint8[8] @ #x~X~%" (-> this user-object)) + (format #t "~1Tstatus: ~D~%" (-> this status)) + (format #t "~1Tdummy[1] @ #x~X~%" (-> this dummy)) + (format #t "~1Ttask: ~D~%" (-> this task)) + (format #t "~1Taid: ~D~%" (-> this aid)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (label cfg-4) + this + ) + +;; definition of type entity-links +(deftype entity-links (structure) + "A linked list of entities with some extra data about their current status." + ((prev-link entity-links) + (next-link entity-links) + (entity entity) + (process process) + (level level) + (vis-id int32) + (kill-mask task-mask) + (vis-dist meters) + (trans vector :inline) + (perm entity-perm :inline) + (status entity-perm-status :overlay-at (-> perm status)) + (aid uint32 :overlay-at (-> perm aid)) + (task game-task :overlay-at (-> perm task)) + ) + (:methods + (birth? (_type_ vector) symbol) + ) + ) + +;; definition for method 3 of type entity-links +(defmethod inspect ((this entity-links)) + (when (not this) + (set! this this) + (goto cfg-42) + ) + (format #t "[~8x] ~A~%" this 'entity-links) + (format #t "~1Tprev-link: #~%" (-> this prev-link)) + (format #t "~1Tnext-link: #~%" (-> this next-link)) + (format #t "~1Tentity: ~A~%" (-> this entity)) + (format #t "~1Tprocess: ~A~%" (-> this process)) + (format #t "~1Tlevel: ~A~%" (-> this level)) + (format #t "~1Tvis-id: ~D~%" (-> this vis-id)) + (format #t "~1Tkill-mask: #x~X : (task-mask " (-> this kill-mask)) + (let ((s5-0 (-> this kill-mask))) + (if (= (logand s5-0 (task-mask network)) (task-mask network)) + (format #t "network ") + ) + (if (= (logand s5-0 (task-mask task0)) (task-mask task0)) + (format #t "task0 ") + ) + (if (= (logand s5-0 (task-mask task2)) (task-mask task2)) + (format #t "task2 ") + ) + (if (= (logand s5-0 (task-mask task4)) (task-mask task4)) + (format #t "task4 ") + ) + (if (= (logand s5-0 (task-mask task6)) (task-mask task6)) + (format #t "task6 ") + ) + (if (= (logand s5-0 (task-mask ctywide)) (task-mask ctywide)) + (format #t "ctywide ") + ) + (if (= (logand s5-0 (task-mask never)) (task-mask never)) + (format #t "never ") + ) + (if (= (logand (task-mask movie1) s5-0) (task-mask movie1)) + (format #t "movie1 ") + ) + (if (= (logand s5-0 (task-mask vehicle)) (task-mask vehicle)) + (format #t "vehicle ") + ) + (if (= (logand s5-0 (task-mask primary0)) (task-mask primary0)) + (format #t "primary0 ") + ) + (if (= (logand s5-0 (task-mask task1)) (task-mask task1)) + (format #t "task1 ") + ) + (if (= (logand s5-0 (task-mask task3)) (task-mask task3)) + (format #t "task3 ") + ) + (if (= (logand s5-0 (task-mask task5)) (task-mask task5)) + (format #t "task5 ") + ) + (if (= (logand s5-0 (task-mask task7)) (task-mask task7)) + (format #t "task7 ") + ) + (if (= (logand (task-mask movie2) s5-0) (task-mask movie2)) + (format #t "movie2 ") + ) + (if (= (logand s5-0 (task-mask done)) (task-mask done)) + (format #t "done ") + ) + (if (= (logand s5-0 (task-mask special)) (task-mask special)) + (format #t "special ") + ) + (if (= (logand (task-mask movie0) s5-0) (task-mask movie0)) + (format #t "movie0 ") + ) + (if (= (logand s5-0 (task-mask dummy0)) (task-mask dummy0)) + (format #t "dummy0 ") + ) + ) + (format #t ")~%") + (format #t "~1Tvis-dist: (meters ~m)~%" (-> this vis-dist)) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Tperm: ~`entity-perm`P~%" (-> this perm)) + (format #t "~1Tstatus: ~D~%" (-> this perm status)) + (format #t "~1Taid: ~D~%" (-> this perm aid)) + (format #t "~1Ttask: ~D~%" (-> this perm task)) + (label cfg-42) + this + ) + +;; definition of type entity-perm-array +(deftype entity-perm-array (inline-array-class) + ((data entity-perm :inline :dynamic) + ) + ) + +;; definition for method 3 of type entity-perm-array +(defmethod inspect ((this entity-perm-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> entity-perm-array heap-base) (the-as uint 16)) + +;; definition of type entity-links-array +(deftype entity-links-array (inline-array-class) + "An array of [[entity-links]]. +Levels store a reference to this which holds all the entities in the level." + ((data entity-links :inline :dynamic) + ) + ) + +;; definition for method 3 of type entity-links-array +(defmethod inspect ((this entity-links-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> entity-links-array heap-base) (the-as uint 64)) + +;; definition of type entity +(deftype entity (res-lump) + "Entities are mainly used to place objects in a level. + +As a child of [[res-lump]], they store various types of metadata +in [[res-tag]]s (such as name, curve data, volume data, etc.) +that gets accessed by the accompanying process." + ((trans vector :inline) + (aid uint32) + (unknown uint32) + ) + (:methods + (birth! (_type_) _type_) + (kill! (_type_) _type_) + (entity-method-24 (_type_) _type_) + (entity-method-25 (_type_) _type_) + (get-level (_type_) level) + ) + ) + +;; type entity-camera is defined here, but it is unknown to the decompiler + +;; type entity-nav-mesh is defined here, but it is unknown to the decompiler + +;; type entity-race-mesh is defined here, but it is unknown to the decompiler + +;; definition of type entity-actor +(deftype entity-actor (entity) + "Child class of [[entity]] used to spawn [[process-drawable]] actors." + ((etype type :offset 56) + (task game-task) + (kill-mask task-mask :overlay-at unknown) + (vis-id int16) + (quat quaternion :inline) + ) + (:methods + (next-actor (_type_) entity-actor) + (prev-actor (_type_) entity-actor) + (debug-print (_type_ symbol type) none) + (toggle-status (_type_ entity-perm-status symbol) none) + (get-simple-travel-vector (_type_ vector vector vector object float) nav-mesh) + (project-point-to-nav-mesh (_type_ vector vector nav-poly float) nav-poly) + ) + ) + +;; definition of type actor-reference +(deftype actor-reference (structure) + ((actor entity-actor) + (id uint32) + ) + :pack-me + ) + +;; definition for method 3 of type actor-reference +(defmethod inspect ((this actor-reference)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'actor-reference) + (format #t "~1Tactor: ~A~%" (-> this actor)) + (format #t "~1Tid: ~D~%" (-> this id)) + (label cfg-4) + this + ) + +;; definition of type actor-group +(deftype actor-group (inline-array-class) + ((data actor-reference :dynamic) + ) + ) + +;; definition for method 3 of type actor-group +(defmethod inspect ((this actor-group)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> actor-group heap-base) (the-as uint 8)) + +;; definition of type entity-info +(deftype entity-info (basic) + ((ptype object) + (pool symbol) + (heap-size int32) + ) + ) + +;; definition for method 3 of type entity-info +(defmethod inspect ((this entity-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tptype: ~A~%" (-> this ptype)) + (format #t "~1Tpool: ~A~%" (-> this pool)) + (format #t "~1Theap-size: ~D~%" (-> this heap-size)) + (label cfg-4) + this + ) + +;; definition of type actor-bank +(deftype actor-bank (basic) + ((pause-dist float) + (birth-dist float) + (birth-max int32) + ) + ) + +;; definition for method 3 of type actor-bank +(defmethod inspect ((this actor-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tpause-dist: ~f~%" (-> this pause-dist)) + (format #t "~1Tbirth-dist: ~f~%" (-> this birth-dist)) + (format #t "~1Tbirth-max: ~D~%" (-> this birth-max)) + (label cfg-4) + this + ) + +;; definition for symbol *ACTOR-bank*, type actor-bank +(define *ACTOR-bank* (new 'static 'actor-bank :pause-dist 204800.0 :birth-dist 901120.0 :birth-max 10)) + +;; failed to figure out what this is: +0 diff --git a/test/decompiler/reference/jakx/engine/entity/res-h_REF.gc b/test/decompiler/reference/jakx/engine/entity/res-h_REF.gc new file mode 100644 index 0000000000..5ef16e7626 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/entity/res-h_REF.gc @@ -0,0 +1,73 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type res-tag +(deftype res-tag (uint128) + "Metadata about a property in a [[res-lump]], such as name, element type and element count." + ((name symbol :offset 0 :size 32) + (key-frame float :offset 32 :size 32) + (elt-type type :offset 64 :size 32) + (data-offset uint16 :offset 96 :size 16) + (elt-count uint32 :offset 112 :size 15) + (inlined? uint8 :offset 127 :size 1) + ) + ) + +;; definition of type res-lump +(deftype res-lump (basic) + "A collection of [[res-tag]]s and their data." + ((length int32) + (allocated-length int16) + (flags res-lump-flags) + (data-base pointer) + (data-top pointer) + (data-size int32) + (extra entity-links) + (tag (pointer res-tag)) + ) + (:methods + (new (symbol type int int) _type_) + (get-property-data (_type_ symbol symbol float pointer (pointer res-tag) pointer) pointer :no-virtual) + (get-property-struct (_type_ symbol symbol float structure (pointer res-tag) pointer) structure :no-virtual) + (get-property-value (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 :no-virtual) + (get-property-value-float (_type_ symbol symbol float float (pointer res-tag) pointer) float) + (get-tag-index-data (_type_ int) pointer) + (get-tag-data (_type_ res-tag) pointer) + (allocate-data-memory-for-tag! (_type_ res-tag) res-tag) + (sort! (_type_) _type_) + (add-data! (_type_ res-tag pointer) res-lump) + (add-32bit-data! (_type_ res-tag object) res-lump) + (lookup-tag-idx (_type_ symbol symbol float) res-tag-pair :no-virtual) + (make-property-data (_type_ float res-tag-pair pointer) pointer) + (get-curve-data! (_type_ curve symbol symbol float) symbol) + ) + ) + +;; definition for method 3 of type res-lump +(defmethod inspect ((this res-lump)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tdata-base: #x~X~%" (-> this data-base)) + (format #t "~1Tdata-top: #x~X~%" (-> this data-top)) + (format #t "~1Tdata-size: ~D~%" (-> this data-size)) + (format #t "~1Textra: ~A~%" (-> this extra)) + (format #t "~1Ttag: #x~X~%" (-> this tag)) + (label cfg-4) + this + ) + +;; definition for symbol *res-key-string*, type string +(define *res-key-string* (new 'global 'string 64 (the-as string #f))) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/game/effect-control-h_REF.gc b/test/decompiler/reference/jakx/engine/game/effect-control-h_REF.gc new file mode 100644 index 0000000000..18e08fe9b2 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/game/effect-control-h_REF.gc @@ -0,0 +1,75 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type effect-control +(deftype effect-control (basic) + "An effect such as a particle with sound effects that plays during an animation." + ((process process-drawable) + (flags effect-control-flag) + (last-frame-group art-joint-anim) + (last-frame-num float) + (channel-offset int32) + (res res-lump) + (name (pointer res-tag)) + (param uint32) + ) + (:methods + (new (symbol type process-drawable) _type_) + (effect-control-method-9 (_type_) none) + (do-effect (_type_ string float int) none) + (do-effect-for-surface (_type_ symbol float int basic pat-surface) none) + (play-effect-sound (_type_ symbol float int basic sound-name) int) + (set-channel-offset! (_type_ int) none) + (play-effects-from-res-lump (_type_ float float float) none) + ) + ) + +;; definition for method 3 of type effect-control +(defmethod inspect ((this effect-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tprocess: ~A~%" (-> this process)) + (format #t "~1Tflags: #x~X~%" (-> this flags)) + (format #t "~1Tlast-frame-group: ~A~%" (-> this last-frame-group)) + (format #t "~1Tlast-frame-num: ~f~%" (-> this last-frame-num)) + (format #t "~1Tchannel-offset: ~D~%" (-> this channel-offset)) + (format #t "~1Tres: ~A~%" (-> this res)) + (format #t "~1Tname: #x~X~%" (-> this name)) + (format #t "~1Tparam: #x~X~%" (-> this param)) + (label cfg-4) + this + ) + +;; definition for method 0 of type effect-control +(defmethod new effect-control ((allocation symbol) (type-to-make type) (arg0 process-drawable)) + (cond + ((res-lump-struct (-> arg0 draw jgeo extra) 'effect-name structure) + (let ((v0-1 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-1 process) arg0) + (set! (-> v0-1 last-frame-group) #f) + v0-1 + ) + ) + (else + (the-as effect-control #f) + ) + ) + ) + +;; definition for method 13 of type effect-control +;; WARN: Return type mismatch int vs none. +(defmethod set-channel-offset! ((this effect-control) (offset int)) + (set! (-> this channel-offset) offset) + 0 + (none) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/game/game-h_REF.gc b/test/decompiler/reference/jakx/engine/game/game-h_REF.gc new file mode 100644 index 0000000000..00cfa0b104 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/game/game-h_REF.gc @@ -0,0 +1,468 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type process-drawable +(deftype process-drawable (process-nettable) + ((root trsqv) + (node-list cspace-array) + (draw draw-control) + (skel joint-control) + (nav nav-control) + (path path-control) + (vol vol-control) + (fact fact-info) + (link actor-link-info) + (part sparticle-launch-control) + (sound ambient-sound) + (rbody rigid-body-control) + (state-flags state-flags) + (state-time time-frame) + ) + (:methods + (process-drawable-method-42 () none) + (process-drawable-method-43 () none) + (process-drawable-method-44 () none) + (process-drawable-method-45 () none) + (process-drawable-method-46 () none) + (process-drawable-method-47 () none) + (process-drawable-method-48 () none) + (process-drawable-method-49 () none) + ) + (:states + (process-drawable-art-error string) + process-drawable-idle + ) + ) + +;; definition for method 3 of type process-drawable +(defmethod inspect ((this process-drawable)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-nettable inspect))) + (t9-0 this) + ) + (format #t "~2Troot: ~A~%" (-> this root)) + (format #t "~2Tnode-list: ~A~%" (-> this node-list)) + (format #t "~2Tdraw: ~A~%" (-> this draw)) + (format #t "~2Tskel: ~A~%" (-> this skel)) + (format #t "~2Tnav: ~A~%" (-> this nav)) + (format #t "~2Tpath: ~A~%" (-> this path)) + (format #t "~2Tvol: ~A~%" (-> this vol)) + (format #t "~2Tfact: ~A~%" (-> this fact)) + (format #t "~2Tlink: ~A~%" (-> this link)) + (format #t "~2Tpart: ~A~%" (-> this part)) + (format #t "~2Tsound: ~A~%" (-> this sound)) + (format #t "~2Trbody: ~A~%" (-> this rbody)) + (format #t "~2Tstate-flags: ~D~%" (-> this state-flags)) + (format #t "~2Tstate-time: ~D~%" (-> this state-time)) + (label cfg-4) + this + ) + +;; definition of type process-drawable-reserved +(deftype process-drawable-reserved (process-drawable) + "A process drawable with a lot of unused method slots. +GOAL cannot increase the number of methods at runtime, so, for interactive development, it is useful +to have a type with a large number of slots which can be turned into real methods without needed to reboot the PS2." + () + (:methods + (process-drawable-reserved-method-50 () none) + (process-drawable-reserved-method-51 () none) + (process-drawable-reserved-method-52 () none) + (process-drawable-reserved-method-53 () none) + (process-drawable-reserved-method-54 () none) + (process-drawable-reserved-method-55 () none) + (process-drawable-reserved-method-56 () none) + (process-drawable-reserved-method-57 () none) + (process-drawable-reserved-method-58 () none) + (process-drawable-reserved-method-59 () none) + (process-drawable-reserved-method-60 () none) + (process-drawable-reserved-method-61 () none) + (process-drawable-reserved-method-62 () none) + (process-drawable-reserved-method-63 () none) + (process-drawable-reserved-method-64 () none) + (process-drawable-reserved-method-65 () none) + (process-drawable-reserved-method-66 () none) + (process-drawable-reserved-method-67 () none) + (process-drawable-reserved-method-68 () none) + (process-drawable-reserved-method-69 () none) + (process-drawable-reserved-method-70 () none) + (process-drawable-reserved-method-71 () none) + (process-drawable-reserved-method-72 () none) + (process-drawable-reserved-method-73 () none) + (process-drawable-reserved-method-74 () none) + (process-drawable-reserved-method-75 () none) + (process-drawable-reserved-method-76 () none) + (process-drawable-reserved-method-77 () none) + (process-drawable-reserved-method-78 () none) + (process-drawable-reserved-method-79 () none) + (process-drawable-reserved-method-80 () none) + (process-drawable-reserved-method-81 () none) + (process-drawable-reserved-method-82 () none) + (process-drawable-reserved-method-83 () none) + (process-drawable-reserved-method-84 () none) + (process-drawable-reserved-method-85 () none) + (process-drawable-reserved-method-86 () none) + (process-drawable-reserved-method-87 () none) + (process-drawable-reserved-method-88 () none) + (process-drawable-reserved-method-89 () none) + (process-drawable-reserved-method-90 () none) + (process-drawable-reserved-method-91 () none) + (process-drawable-reserved-method-92 () none) + (process-drawable-reserved-method-93 () none) + (process-drawable-reserved-method-94 () none) + (process-drawable-reserved-method-95 () none) + (process-drawable-reserved-method-96 () none) + (process-drawable-reserved-method-97 () none) + (process-drawable-reserved-method-98 () none) + (process-drawable-reserved-method-99 () none) + (process-drawable-reserved-method-100 () none) + (process-drawable-reserved-method-101 () none) + (process-drawable-reserved-method-102 () none) + (process-drawable-reserved-method-103 () none) + (process-drawable-reserved-method-104 () none) + (process-drawable-reserved-method-105 () none) + (process-drawable-reserved-method-106 () none) + (process-drawable-reserved-method-107 () none) + (process-drawable-reserved-method-108 () none) + (process-drawable-reserved-method-109 () none) + (process-drawable-reserved-method-110 () none) + (process-drawable-reserved-method-111 () none) + (process-drawable-reserved-method-112 () none) + (process-drawable-reserved-method-113 () none) + (process-drawable-reserved-method-114 () none) + (process-drawable-reserved-method-115 () none) + (process-drawable-reserved-method-116 () none) + (process-drawable-reserved-method-117 () none) + (process-drawable-reserved-method-118 () none) + (process-drawable-reserved-method-119 () none) + (process-drawable-reserved-method-120 () none) + (process-drawable-reserved-method-121 () none) + (process-drawable-reserved-method-122 () none) + (process-drawable-reserved-method-123 () none) + (process-drawable-reserved-method-124 () none) + (process-drawable-reserved-method-125 () none) + (process-drawable-reserved-method-126 () none) + (process-drawable-reserved-method-127 () none) + (process-drawable-reserved-method-128 () none) + (process-drawable-reserved-method-129 () none) + (process-drawable-reserved-method-130 () none) + (process-drawable-reserved-method-131 () none) + (process-drawable-reserved-method-132 () none) + (process-drawable-reserved-method-133 () none) + (process-drawable-reserved-method-134 () none) + (process-drawable-reserved-method-135 () none) + (process-drawable-reserved-method-136 () none) + (process-drawable-reserved-method-137 () none) + (process-drawable-reserved-method-138 () none) + (process-drawable-reserved-method-139 () none) + (process-drawable-reserved-method-140 () none) + (process-drawable-reserved-method-141 () none) + (process-drawable-reserved-method-142 () none) + (process-drawable-reserved-method-143 () none) + (process-drawable-reserved-method-144 () none) + (process-drawable-reserved-method-145 () none) + (process-drawable-reserved-method-146 () none) + (process-drawable-reserved-method-147 () none) + (process-drawable-reserved-method-148 () none) + (process-drawable-reserved-method-149 () none) + (process-drawable-reserved-method-150 () none) + (process-drawable-reserved-method-151 () none) + (process-drawable-reserved-method-152 () none) + (process-drawable-reserved-method-153 () none) + (process-drawable-reserved-method-154 () none) + (process-drawable-reserved-method-155 () none) + (process-drawable-reserved-method-156 () none) + (process-drawable-reserved-method-157 () none) + (process-drawable-reserved-method-158 () none) + (process-drawable-reserved-method-159 () none) + (process-drawable-reserved-method-160 () none) + (process-drawable-reserved-method-161 () none) + (process-drawable-reserved-method-162 () none) + (process-drawable-reserved-method-163 () none) + (process-drawable-reserved-method-164 () none) + (process-drawable-reserved-method-165 () none) + (process-drawable-reserved-method-166 () none) + (process-drawable-reserved-method-167 () none) + (process-drawable-reserved-method-168 () none) + (process-drawable-reserved-method-169 () none) + (process-drawable-reserved-method-170 () none) + (process-drawable-reserved-method-171 () none) + (process-drawable-reserved-method-172 () none) + (process-drawable-reserved-method-173 () none) + (process-drawable-reserved-method-174 () none) + (process-drawable-reserved-method-175 () none) + (process-drawable-reserved-method-176 () none) + (process-drawable-reserved-method-177 () none) + (process-drawable-reserved-method-178 () none) + (process-drawable-reserved-method-179 () none) + (process-drawable-reserved-method-180 () none) + (process-drawable-reserved-method-181 () none) + (process-drawable-reserved-method-182 () none) + (process-drawable-reserved-method-183 () none) + (process-drawable-reserved-method-184 () none) + (process-drawable-reserved-method-185 () none) + (process-drawable-reserved-method-186 () none) + (process-drawable-reserved-method-187 () none) + (process-drawable-reserved-method-188 () none) + (process-drawable-reserved-method-189 () none) + (process-drawable-reserved-method-190 () none) + (process-drawable-reserved-method-191 () none) + (process-drawable-reserved-method-192 () none) + (process-drawable-reserved-method-193 () none) + (process-drawable-reserved-method-194 () none) + (process-drawable-reserved-method-195 () none) + (process-drawable-reserved-method-196 () none) + (process-drawable-reserved-method-197 () none) + (process-drawable-reserved-method-198 () none) + (process-drawable-reserved-method-199 () none) + (process-drawable-reserved-method-200 () none) + (process-drawable-reserved-method-201 () none) + (process-drawable-reserved-method-202 () none) + (process-drawable-reserved-method-203 () none) + (process-drawable-reserved-method-204 () none) + (process-drawable-reserved-method-205 () none) + (process-drawable-reserved-method-206 () none) + (process-drawable-reserved-method-207 () none) + (process-drawable-reserved-method-208 () none) + (process-drawable-reserved-method-209 () none) + (process-drawable-reserved-method-210 () none) + (process-drawable-reserved-method-211 () none) + (process-drawable-reserved-method-212 () none) + (process-drawable-reserved-method-213 () none) + (process-drawable-reserved-method-214 () none) + (process-drawable-reserved-method-215 () none) + (process-drawable-reserved-method-216 () none) + (process-drawable-reserved-method-217 () none) + (process-drawable-reserved-method-218 () none) + (process-drawable-reserved-method-219 () none) + (process-drawable-reserved-method-220 () none) + (process-drawable-reserved-method-221 () none) + (process-drawable-reserved-method-222 () none) + (process-drawable-reserved-method-223 () none) + (process-drawable-reserved-method-224 () none) + (process-drawable-reserved-method-225 () none) + (process-drawable-reserved-method-226 () none) + (process-drawable-reserved-method-227 () none) + (process-drawable-reserved-method-228 () none) + (process-drawable-reserved-method-229 () none) + (process-drawable-reserved-method-230 () none) + (process-drawable-reserved-method-231 () none) + (process-drawable-reserved-method-232 () none) + (process-drawable-reserved-method-233 () none) + (process-drawable-reserved-method-234 () none) + (process-drawable-reserved-method-235 () none) + (process-drawable-reserved-method-236 () none) + (process-drawable-reserved-method-237 () none) + (process-drawable-reserved-method-238 () none) + (process-drawable-reserved-method-239 () none) + (process-drawable-reserved-method-240 () none) + (process-drawable-reserved-method-241 () none) + (process-drawable-reserved-method-242 () none) + (process-drawable-reserved-method-243 () none) + (process-drawable-reserved-method-244 () none) + (process-drawable-reserved-method-245 () none) + (process-drawable-reserved-method-246 () none) + (process-drawable-reserved-method-247 () none) + ) + ) + +;; definition for method 3 of type process-drawable-reserved +(defmethod inspect ((this process-drawable-reserved)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (label cfg-4) + this + ) + +;; definition of type attack-dir-info +(deftype attack-dir-info (structure) + "Information about the position/direction of an attack." + ((dir vector :inline) + (xz-dir vector :inline) + (attacker-velocity vector :inline) + (pos vector :inline) + ) + ) + +;; definition for method 3 of type attack-dir-info +(defmethod inspect ((this attack-dir-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'attack-dir-info) + (format #t "~1Tdir: #~%" (-> this dir)) + (format #t "~1Txz-dir: #~%" (-> this xz-dir)) + (format #t "~1Tattacker-velocity: #~%" (-> this attacker-velocity)) + (format #t "~1Tpos: #~%" (-> this pos)) + (label cfg-4) + this + ) + +;; definition of type attack-info +(deftype attack-info (structure) + "Information about an incoming attack." + ((trans vector :inline) + (vector vector :inline) + (attacker-velocity vector :inline) + (intersection vector :inline) + (attacker handle) + (attack-time time-frame) + (invinc-time time-frame) + (mask attack-mask) + (mode symbol) + (shove-back meters) + (shove-up meters) + (speed meters) + (dist meters) + (control float) + (angle symbol) + (rotate-to degrees) + (prev-state state) + (id uint32) + (count uint8) + (penetrate-using penetrate) + (damage float) + (shield-damage float) + (vehicle-damage-factor float) + (vehicle-impulse-factor float) + (knock knocked-type) + (test symbol) + ) + (:methods + (attack-info-method-9 () none) + ) + ) + +;; definition for method 3 of type attack-info +(defmethod inspect ((this attack-info)) + (when (not this) + (set! this this) + (goto cfg-56) + ) + (format #t "[~8x] ~A~%" this 'attack-info) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Tvector: ~`vector`P~%" (-> this vector)) + (format #t "~1Tattacker-velocity: ~`vector`P~%" (-> this attacker-velocity)) + (format #t "~1Tintersection: ~`vector`P~%" (-> this intersection)) + (format #t "~1Tattacker: ~`handle`P~%" (-> this attacker)) + (format #t "~1Tattack-time: ~D~%" (-> this attack-time)) + (format #t "~1Tinvinc-time: ~D~%" (-> this invinc-time)) + (format #t "~1Tmask: #x~X : (attack-info-mask " (-> this mask)) + (let ((s5-0 (-> this mask))) + (if (= (logand s5-0 (attack-mask vector)) (attack-mask vector)) + (format #t "vector ") + ) + (if (= (logand s5-0 (attack-mask angle)) (attack-mask angle)) + (format #t "angle ") + ) + (if (= (logand (attack-mask test) s5-0) (attack-mask test)) + (format #t "test ") + ) + (if (= (logand s5-0 (attack-mask invinc-time)) (attack-mask invinc-time)) + (format #t "invinc-time ") + ) + (if (= (logand s5-0 (attack-mask attacker)) (attack-mask attacker)) + (format #t "attacker ") + ) + (if (= (logand s5-0 (attack-mask dist)) (attack-mask dist)) + (format #t "dist ") + ) + (if (= (logand s5-0 (attack-mask intersection)) (attack-mask intersection)) + (format #t "intersection ") + ) + (if (= (logand s5-0 (attack-mask shove-back)) (attack-mask shove-back)) + (format #t "shove-back ") + ) + (if (= (logand s5-0 (attack-mask shove-up)) (attack-mask shove-up)) + (format #t "shove-up ") + ) + (if (= (logand s5-0 (attack-mask mode)) (attack-mask mode)) + (format #t "mode ") + ) + (if (= (logand (attack-mask count) s5-0) (attack-mask count)) + (format #t "count ") + ) + (if (= (logand (attack-mask wpn-type) s5-0) (attack-mask wpn-type)) + (format #t "wpn-type ") + ) + (if (= (logand s5-0 (attack-mask rotate-to)) (attack-mask rotate-to)) + (format #t "rotate-to ") + ) + (if (= (logand s5-0 (attack-mask speed)) (attack-mask speed)) + (format #t "speed ") + ) + (if (= (logand s5-0 (attack-mask attack-time)) (attack-mask attack-time)) + (format #t "attack-time ") + ) + (if (= (logand (attack-mask vehicle-damage-factor) s5-0) (attack-mask vehicle-damage-factor)) + (format #t "vehicle-damage-factor ") + ) + (if (= (logand (attack-mask damage) s5-0) (attack-mask damage)) + (format #t "damage ") + ) + (if (= (logand s5-0 (attack-mask control)) (attack-mask control)) + (format #t "control ") + ) + (if (= (logand s5-0 (attack-mask trans)) (attack-mask trans)) + (format #t "trans ") + ) + (if (= (logand (attack-mask penetrate-using) s5-0) (attack-mask penetrate-using)) + (format #t "penetrate-using ") + ) + (if (= (logand (attack-mask vehicle-impulse-factor) s5-0) (attack-mask vehicle-impulse-factor)) + (format #t "vehicle-impulse-factor ") + ) + (if (= (logand (attack-mask attacker-velocity) s5-0) (attack-mask attacker-velocity)) + (format #t "attacker-velocity ") + ) + (if (= (logand s5-0 (attack-mask id)) (attack-mask id)) + (format #t "id ") + ) + (if (= (logand s5-0 (attack-mask prev-state)) (attack-mask prev-state)) + (format #t "prev-state ") + ) + (if (= (logand (attack-mask knock) s5-0) (attack-mask knock)) + (format #t "knock ") + ) + (if (= (logand (attack-mask shield-damage) s5-0) (attack-mask shield-damage)) + (format #t "shield-damage ") + ) + ) + (format #t ")~%") + (format #t "~1Tmode: ~A~%" (-> this mode)) + (format #t "~1Tshove-back: (meters ~m)~%" (-> this shove-back)) + (format #t "~1Tshove-up: (meters ~m)~%" (-> this shove-up)) + (format #t "~1Tspeed: (meters ~m)~%" (-> this speed)) + (format #t "~1Tdist: (meters ~m)~%" (-> this dist)) + (format #t "~1Tcontrol: ~f~%" (-> this control)) + (format #t "~1Tangle: ~A~%" (-> this angle)) + (format #t "~1Trotate-to: (deg ~r)~%" (-> this rotate-to)) + (format #t "~1Tprev-state: ~A~%" (-> this prev-state)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Twpn-type: ~D~%" (-> this count)) + (format #t "~1Tpenetrate-using: ~D~%" (-> this penetrate-using)) + (format #t "~1Tdamage: ~f~%" (-> this damage)) + (format #t "~1Tshield-damage: ~f~%" (-> this shield-damage)) + (format #t "~1Tvehicle-damage-factor: ~f~%" (-> this vehicle-damage-factor)) + (format #t "~1Tvehicle-impulse-factor: ~f~%" (-> this vehicle-impulse-factor)) + (format #t "~1Tknock: ~D~%" (-> this knock)) + (format #t "~1Ttest: ~A~%" (-> this test)) + (label cfg-56) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/game/main-h_REF.gc b/test/decompiler/reference/jakx/engine/game/main-h_REF.gc new file mode 100644 index 0000000000..892dcebc7c --- /dev/null +++ b/test/decompiler/reference/jakx/engine/game/main-h_REF.gc @@ -0,0 +1,571 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *stats-poly*, type symbol +(define *stats-poly* #f) + +;; definition for symbol *stats-memory*, type symbol +(define *stats-memory* #f) + +;; definition for symbol *stats-memory-short*, type symbol +(define *stats-memory-short* #f) + +;; definition for symbol *stats-memory-level-index*, type int +(define *stats-memory-level-index* 0) + +;; definition for symbol *stats-collide*, type symbol +(define *stats-collide* #f) + +;; definition for symbol *stats-bsp*, type symbol +(define *stats-bsp* #f) + +;; definition for symbol *stats-buffer*, type symbol +(define *stats-buffer* #f) + +;; definition for symbol *stats-target*, type symbol +(define *stats-target* #f) + +;; definition for symbol *stats-profile-bars*, type symbol +(define *stats-profile-bars* #f) + +;; definition for symbol *stats-perf*, type symbol +(define *stats-perf* #f) + +;; definition for symbol *stats-sound*, type symbol +(define *stats-sound* #f) + +;; definition for symbol *artist-all-visible*, type symbol +(define *artist-all-visible* #f) + +;; definition for symbol *artist-flip-visible*, type symbol +(define *artist-flip-visible* #f) + +;; definition for symbol *artist-fix-visible*, type symbol +(define *artist-fix-visible* #f) + +;; definition for symbol *artist-fix-frustum*, type symbol +(define *artist-fix-frustum* #f) + +;; definition for symbol *artist-error-spheres*, type symbol +(define *artist-error-spheres* #f) + +;; definition for symbol *artist-use-menu-subdiv*, type symbol +(define *artist-use-menu-subdiv* #f) + +;; definition for symbol *display-profile*, type symbol +(define *display-profile* #t) + +;; definition for symbol *display-sidekick-stats*, type symbol +(define *display-sidekick-stats* #f) + +;; definition for symbol *display-quad-stats*, type symbol +(define *display-quad-stats* #f) + +;; definition for symbol *display-tri-stats*, type symbol +(define *display-tri-stats* #f) + +;; definition for symbol *display-ground-stats*, type symbol +(define *display-ground-stats* #f) + +;; definition for symbol *display-collision-marks*, type symbol +(define *display-collision-marks* #f) + +;; definition for symbol *display-collide-cache*, type symbol +(define *display-collide-cache* #f) + +;; definition for symbol *display-render-collision*, type symbol +(define *display-render-collision* #f) + +;; definition for symbol *display-hipri-collision-marks*, type symbol +(define *display-hipri-collision-marks* #f) + +;; definition for symbol *display-edge-collision-marks*, type symbol +(define *display-edge-collision-marks* #f) + +;; definition for symbol *display-geo-marks*, type symbol +(define *display-geo-marks* #f) + +;; definition for symbol *display-target-marks*, type symbol +(define *display-target-marks* #f) + +;; definition for symbol *target-rc-board-controls*, type symbol +(define *target-rc-board-controls* #f) + +;; definition for symbol *display-collide-history*, type int +(define *display-collide-history* 0) + +;; definition for symbol *amy-cam*, type symbol +(define *amy-cam* #f) + +;; definition for symbol *display-xyz-axes*, type symbol +(define *display-xyz-axes* #f) + +;; definition for symbol *display-cam-collide-history*, type symbol +(define *display-cam-collide-history* #f) + +;; definition for symbol *record-cam-collide-history*, type symbol +(define *record-cam-collide-history* #f) + +;; definition for symbol *display-cam-master-marks*, type symbol +(define *display-cam-master-marks* #f) + +;; definition for symbol *display-cam-other*, type symbol +(define *display-cam-other* #f) + +;; definition for symbol *display-camera-marks*, type symbol +(define *display-camera-marks* #f) + +;; definition for symbol *camera-no-mip-correction*, type symbol +(define *camera-no-mip-correction* #f) + +;; definition for symbol *camera-turbo-free*, type symbol +(define *camera-turbo-free* #f) + +;; definition for symbol *suppress-vehicle-respawn*, type object +(define *suppress-vehicle-respawn* (the-as object #f)) + +;; definition for symbol *display-cam-los-info*, type symbol +(define *display-cam-los-info* #f) + +;; definition for symbol *display-cam-los-debug*, type symbol +(define *display-cam-los-debug* #f) + +;; definition for symbol *display-cam-los-marks*, type symbol +(define *display-cam-los-marks* #f) + +;; definition for symbol *display-cam-coll-marks*, type symbol +(define *display-cam-coll-marks* #f) + +;; definition for symbol *display-camera-info*, type symbol +(define *display-camera-info* #f) + +;; definition for symbol *display-camera-old-stats*, type symbol +(define *display-camera-old-stats* #f) + +;; definition for symbol *display-camera-last-attacker*, type symbol +(define *display-camera-last-attacker* #f) + +;; definition for symbol *display-file-info*, type symbol +(define *display-file-info* #f) + +;; definition for symbol *display-actor-marks*, type symbol +(define *display-actor-marks* #f) + +;; definition for symbol *display-sprite-info*, type symbol +(define *display-sprite-info* #f) + +;; definition for symbol *display-sprite-marks*, type symbol +(define *display-sprite-marks* #f) + +;; definition for symbol *display-sprite-spheres*, type symbol +(define *display-sprite-spheres* #f) + +;; definition for symbol *display-bsp-errors*, type symbol +(define *display-bsp-errors* #t) + +;; definition for symbol *display-entity-errors*, type symbol +(define *display-entity-errors* #t) + +;; definition for symbol *display-capture-mode*, type symbol +(define *display-capture-mode* #f) + +;; definition for symbol *display-instance-info*, type symbol +(define *display-instance-info* #f) + +;; definition for symbol *display-deci-count*, type symbol +(define *display-deci-count* #f) + +;; definition for symbol *sync-dma*, type symbol +(define *sync-dma* #f) + +;; definition for symbol *display-strip-lines*, type strip-lines-controls +(define *display-strip-lines* (the-as strip-lines-controls 0)) + +;; definition for symbol *display-battle-marks*, type symbol +(define *display-battle-marks* #f) + +;; definition for symbol *display-joint-axes*, type symbol +(define *display-joint-axes* #f) + +;; definition for symbol *display-nav-marks*, type symbol +(define *display-nav-marks* #f) + +;; definition for symbol *display-nav-network*, type symbol +(define *display-nav-network* #f) + +;; definition for symbol *display-path-marks*, type symbol +(define *display-path-marks* #f) + +;; definition for symbol *display-vol-marks*, type symbol +(define *display-vol-marks* #f) + +;; definition for symbol *display-water-marks*, type symbol +(define *display-water-marks* #f) + +;; definition for symbol *display-nav-mesh*, type symbol +(define *display-nav-mesh* #f) + +;; definition for symbol *display-race-mesh*, type symbol +(define *display-race-mesh* #f) + +;; definition for symbol *display-ai-tuning*, type symbol +(define *display-ai-tuning* #f) + +;; definition for symbol *display-actor-pointer*, type symbol +(define *display-actor-pointer* #f) + +;; definition for symbol *display-actor-vis*, type symbol +(define *display-actor-vis* #f) + +;; definition for symbol *display-actor-graph*, type symbol +(define *display-actor-graph* #f) + +;; definition for symbol *display-traffic-height-map*, type symbol +(define *display-traffic-height-map* #f) + +;; definition for symbol *display-trail-graph*, type symbol +(define *display-trail-graph* #f) + +;; definition for symbol *display-color-bars*, type symbol +(define *display-color-bars* #f) + +;; definition for symbol *display-bug-report*, type symbol +(define *display-bug-report* #f) + +;; definition for symbol *display-level-border*, type symbol +(define *display-level-border* #f) + +;; definition for symbol *display-memcard-info*, type symbol +(define *display-memcard-info* #f) + +;; definition for symbol *display-split-boxes*, type symbol +(define *display-split-boxes* #f) + +;; definition for symbol *display-split-box-info*, type symbol +(define *display-split-box-info* #f) + +;; definition for symbol *display-texture-distances*, type symbol +(define *display-texture-distances* #f) + +;; definition for symbol *display-texture-download*, type symbol +(define *display-texture-download* #f) + +;; definition for symbol *display-art-control*, type symbol +(define *display-art-control* #f) + +;; definition for symbol *display-gui-control*, type symbol +(define *display-gui-control* #f) + +;; definition for symbol *display-level-spheres*, type symbol +(define *display-level-spheres* #f) + +;; definition for symbol *time-of-day-fast*, type symbol +(define *time-of-day-fast* #f) + +;; definition for symbol *display-iop-info*, type symbol +(define *display-iop-info* #f) + +;; definition for symbol *slow-frame-rate*, type symbol +(define *slow-frame-rate* #f) + +;; definition for symbol *display-region-marks*, type symbol +(define *display-region-marks* #f) + +;; definition for symbol *execute-regions*, type symbol +(define *execute-regions* #t) + +;; definition for symbol *disable-bot*, type symbol +(define *disable-bot* #f) + +;; definition for symbol *debug-reverb*, type symbol +(define *debug-reverb* #f) + +;; definition for symbol *debug-whoosh*, type symbol +(define *debug-whoosh* #f) + +;; definition for symbol *debug-engine-sounds*, type symbol +(define *debug-engine-sounds* #f) + +;; definition for symbol *debug-pause*, type symbol +(define *debug-pause* #f) + +;; definition for symbol *debug-view-anims*, type symbol +(define *debug-view-anims* #f) + +;; definition for symbol *debug-unkillable*, type symbol +(define *debug-unkillable* #f) + +;; definition for symbol *debug-player-vehicle-unkillable*, type symbol +(define *debug-player-vehicle-unkillable* #f) + +;; definition for symbol *debug-actor*, type process +(define *debug-actor* (the-as process #f)) + +;; definition for symbol *debug-force-highspeed*, type symbol +(define *debug-force-highspeed* #f) + +;; definition for symbol *gun-marks*, type symbol +(define *gun-marks* #f) + +;; definition for symbol *debug-split-screen*, type symbol +(define *debug-split-screen* #f) + +;; definition for symbol *ignore-want-load-display*, type symbol +(define *ignore-want-load-display* #f) + +;; definition for symbol *bug-report-output-mode*, type symbol +(define *bug-report-output-mode* (if *debug-segment* + 'file-stream + '*stdcon* + ) + ) + +;; definition for symbol *draw-debug-boxes*, type symbol +(define *draw-debug-boxes* #f) + +;; definition for symbol *hide-menus*, type symbol +(define *hide-menus* #f) + +;; definition for symbol *list-all-scenes*, type symbol +(define *list-all-scenes* #f) + +;; definition for symbol *display-scene-control*, type scene-controls +(define *display-scene-control* (the-as scene-controls 0)) + +;; definition for symbol *display-bot-marks*, type bot-marks-controls +(define *display-bot-marks* (the-as bot-marks-controls 0)) + +;; definition for symbol *display-race-marks*, type race-marks-controls +(define *display-race-marks* (the-as race-marks-controls 0)) + +;; definition for symbol *race-record-path*, type symbol +(define *race-record-path* #f) + +;; definition for symbol *select-race*, type race-selection +(define *select-race* (race-selection desrally-record)) + +;; definition for symbol *select-race-path*, type int +(define *select-race-path* 0) + +;; definition for symbol *bot-record-path*, type int +(define *bot-record-path* -1) + +;; definition for symbol *subdivide-draw-mode*, type subdivide-setting +(define *subdivide-draw-mode* (the-as subdivide-setting 0)) + +;; definition for symbol *subdivide-scissor-draw-mode*, type subdivide-setting +(define *subdivide-scissor-draw-mode* (the-as subdivide-setting 0)) + +;; definition for symbol *subdivide-foreground-draw-mode*, type subdivide-setting +(define *subdivide-foreground-draw-mode* (the-as subdivide-setting 0)) + +;; definition for symbol *subdivide-ocean-draw-mode*, type subdivide-setting +(define *subdivide-ocean-draw-mode* (the-as subdivide-setting 0)) + +;; definition (perm) for symbol *dproc*, type process +(define-perm *dproc* process #f) + +;; definition for symbol *run*, type symbol +(define *run* #f) + +;; definition for symbol *teleport*, type symbol +(define *teleport* #f) + +;; definition for symbol *teleport-count*, type int +(define *teleport-count* 0) + +;; definition for symbol *draw-hook*, type (function none) +(define *draw-hook* nothing) + +;; definition for symbol *debug-hook*, type pair +(define *debug-hook* '()) + +;; definition for symbol *menu-hook*, type (function debug-menu-context) +(define *menu-hook* (the-as (function debug-menu-context) nothing)) + +;; definition for symbol *progress-hook*, type (function none) +(define *progress-hook* nothing) + +;; definition for symbol *dma-timeout-hook*, type (function none) +(define *dma-timeout-hook* nothing) + +;; definition of type frame-stats +(deftype frame-stats (structure) + ((field-time time-frame 2) + (field int32) + ) + ) + +;; definition for method 3 of type frame-stats +(defmethod inspect ((this frame-stats)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'frame-stats) + (format #t "~1Tfield-time[2] @ #x~X~%" (-> this field-time)) + (format #t "~1Tfield: ~D~%" (-> this field)) + (label cfg-4) + this + ) + +;; definition for symbol *frame-stats*, type frame-stats +(define *frame-stats* (new 'static 'frame-stats)) + +;; definition of type screen-filter +(deftype screen-filter (basic) + ((draw? symbol) + (bucket bucket-id) + (depth int32) + (ztest uint64) + (color vector :inline) + (color-src vector :inline) + (color-dest vector :inline) + (extra vector :inline) + (speed float :overlay-at (-> extra data 0)) + (current-interp float :overlay-at (-> extra data 1)) + (lock-vsync? symbol) + (idx int32) + (frames int32) + ) + (:methods + (screen-filter-method-9 () none) + (screen-filter-method-10 () none) + (screen-filter-method-11 () none) + ) + ) + +;; definition for method 3 of type screen-filter +(defmethod inspect ((this screen-filter)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tdraw?: ~A~%" (-> this draw?)) + (format #t "~1Tbucket: ~D~%" (-> this bucket)) + (format #t "~1Tdepth: #x~X~%" (-> this depth)) + (format #t "~1Tztest: #x~X~%" (-> this ztest)) + (format #t "~1Tcolor: #~%" (-> this color)) + (format #t "~1Tcolor-src: #~%" (-> this color-src)) + (format #t "~1Tcolor-dest: #~%" (-> this color-dest)) + (format #t "~1Textra: #~%" (-> this extra)) + (format #t "~1Tspeed: ~f~%" (-> this extra x)) + (format #t "~1Tcurrent-interp: ~f~%" (-> this extra y)) + (format #t "~1Tlock-vsync?: ~A~%" (-> this lock-vsync?)) + (format #t "~1Tidx: ~D~%" (-> this idx)) + (format #t "~1Tframes: ~D~%" (-> this frames)) + (label cfg-4) + this + ) + +;; definition of type col-rend +(deftype col-rend (basic) + ((draw? symbol) + (outline? symbol) + (show-back-faces? symbol) + (show-normals? symbol) + (ghost-hidden? symbol) + (show-only uint32) + (show-only-mask uint32) + (cspec collide-spec) + (track uint8) + (bbox-radius float) + (bbox-center vector :inline) + (camera-to-bbox-dist float) + ) + (:methods + (draw (_type_) none) + ) + ) + +;; definition for method 3 of type col-rend +(defmethod inspect ((this col-rend)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tdraw?: ~A~%" (-> this draw?)) + (format #t "~1Toutline?: ~A~%" (-> this outline?)) + (format #t "~1Tshow-back-faces?: ~A~%" (-> this show-back-faces?)) + (format #t "~1Tshow-normals?: ~A~%" (-> this show-normals?)) + (format #t "~1Tghost-hidden?: ~A~%" (-> this ghost-hidden?)) + (format #t "~1Tshow-only: ~D~%" (-> this show-only)) + (format #t "~1Tshow-only-mask: ~D~%" (-> this show-only-mask)) + (format #t "~1Tcspec: ~D~%" (-> this cspec)) + (format #t "~1Ttrack: ~D~%" (-> this track)) + (format #t "~1Tbbox-radius: ~f~%" (-> this bbox-radius)) + (format #t "~1Tbbox-center: #~%" (-> this bbox-center)) + (format #t "~1Tcamera-to-bbox-dist: ~f~%" (-> this camera-to-bbox-dist)) + (label cfg-4) + this + ) + +;; definition for symbol *col-rend*, type col-rend +(define *col-rend* (new 'static 'col-rend + :draw? #f + :outline? #t + :show-back-faces? #t + :show-normals? #f + :ghost-hidden? #t + :cspec (collide-spec crate civilian enemy) + :track #x1 + :bbox-radius 24576.0 + :camera-to-bbox-dist 65536.0 + ) + ) + +;; definition (debug) for function debug-actor? +(defun-debug debug-actor? ((arg0 object)) + (= arg0 *debug-actor*) + ) + +;; definition for symbol *record-fma*, type symbol +(define *record-fma* #f) + +;; definition for symbol *record-fma-use-path*, type symbol +(define *record-fma-use-path* #f) + +;; definition for symbol *record-fma-path-mode*, type symbol +(define *record-fma-path-mode* #f) + +;; definition for symbol *record-fma-path-high-res*, type symbol +(define *record-fma-path-high-res* #f) + +;; definition for symbol *record-fma-path-dry-run*, type symbol +(define *record-fma-path-dry-run* #f) + +;; definition for symbol *record-fma-real*, type symbol +(define *record-fma-real* #f) + +;; definition for symbol *record-fma-low-res*, type symbol +(define *record-fma-low-res* #f) + +;; definition for symbol *record-fma-start*, type int +(define *record-fma-start* 0) + +;; definition for symbol *record-fma-end*, type int +(define *record-fma-end* 0) + +;; definition for symbol *record-fma-pal*, type symbol +(define *record-fma-pal* #f) + +;; definition for symbol *profile-slot*, type int +(define *profile-slot* 0) + +;; definition for symbol *game-mode*, type symbol +(define *game-mode* #f) + +;; definition for symbol *lobby-local-players*, type int +(define *lobby-local-players* 1) + +;; definition for symbol *first-boot*, type symbol +(define *first-boot* #t) + +;; definition for symbol *cheat-temp*, type (pointer int32) +(define *cheat-temp* (the-as (pointer int32) (malloc 'global 32))) + + + + diff --git a/test/decompiler/reference/jakx/engine/game/settings-h_REF.gc b/test/decompiler/reference/jakx/engine/game/settings-h_REF.gc new file mode 100644 index 0000000000..90ea96ba86 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/game/settings-h_REF.gc @@ -0,0 +1,751 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *settings-dialog-volume*, type float +(define *settings-dialog-volume* 0.95) + +;; definition for symbol *settings-music-volume*, type float +(define *settings-music-volume* 0.7) + +;; definition for symbol *settings-sfx-volume*, type float +(define *settings-sfx-volume* 0.75) + +;; definition for symbol *settings-music-seek-speed*, type float +(define *settings-music-seek-speed* 2.0) + +;; definition of type user-setting-data +(deftype user-setting-data (structure) + ((border-mode symbol) + (process-mask process-mask) + (common-page int32) + (language language-enum) + (unknown-usd-1 int32) + (unknown-usd-2 int32) + (unknown-usd-3 int32) + (unknown-usd-4 int32) + (movie (pointer process)) + (talking (pointer process)) + (spooling (pointer process)) + (hint (pointer process)) + (ambient (pointer process)) + (video-mode symbol) + (aspect-ratio symbol) + (unknown-usd-5 int32) + (unknown-usd-6 int32) + (unknown-usd-7 int32) + (auto-save symbol) + (unknown-usd-8 int32) + (bg-r float) + (bg-g float) + (bg-b float) + (bg-a float) + (bg-a-speed float) + (bg-a-force float) + (blur-a float) + (blur-a-speed float) + (allow-progress symbol) + (allow-in-game-menu basic) + (allow-pause symbol) + (unknown-usd-9 int32) + (unknown-usd-10 int32) + (unknown-usd-11 int32) + (movie-name symbol) + (weather symbol) + (unknown-usd-12 int32) + (unknown-usd-13 int32) + (unknown-usd-14 int32) + (task-mask task-mask) + (unknown-usd-15 int32) + (speed-mult float) + (features uint64) + (vehicles uint64) + (sfx-volume float) + (sfx-volume-movie float) + (music-volume float) + (music-volume-movie float) + (dialog-volume float) + (dialog-volume-talker float) + (ambient-volume float) + (ambient-volume-movie float) + (dynamic-ambient-volume float) + (talker-volume float) + (mode-sound-bank uint32) + (sound-reverb float) + (sound-reverb-mode int32) + (sound-reverb-seek-speed float) + (stereo-mode int32) + (music symbol) + (spool-anim spool-anim) + (task-manager (pointer process)) + (task symbol) + (airlock symbol) + (minimap uint32) + (allow-continue symbol) + (unknown-usd-16 int32) + (unknown-usd-17 int32) + (subtitle symbol) + (doorway symbol) + (gem symbol) + (half-speed symbol) + (gun-buoy symbol) + (double-jump symbol) + (pilot symbol) + (pilot-exit symbol) + (pilot-death symbol) + (speech-control symbol) + (vehicle-hijacking symbol) + (endlessfall symbol) + (rain float) + (snow float) + (exclusive-load symbol) + (render symbol) + (allow-timeout symbol) + (mirror symbol) + (movie-skip-frame float) + (allow-blackout symbol) + (race-minimap int32) + (beard symbol) + (ignore-target symbol) + (subtitle-language uint8) + (sound-bank-load symbol) + (allow-error symbol) + (under-water-pitch-mod float) + (unknown-usd-18 int32) + (restart-info resetter-spec) + (fail-info resetter-spec) + (death-info resetter-spec) + (quit-info resetter-spec) + (extra-bank-count uint32) + (extra-bank pair 3) + (borrow-count uint32) + (borrow pair 3) + (exclusive-task-count uint32) + (exclusive-task int32 3) + (level-trans-time int32) + (unknown-usd-19 int32) + (unknown-usd-20 int32) + (unknown-usd-21 int32) + (unknown-usd-22 int32) + (unknown-usd-23 int32) + (letterbox float) + (letterbox-speed float) + (unknown-usd-24 int32) + (unknown-usd-25 int32) + (unknown-usd-26 int32) + (unknown-usd-27 int32) + (unknown-usd-28 int32) + (unknown-usd-29 int32) + (unknown-usd-30 int32) + (unknown-usd-31 int32) + (unknown-usd-32 int32) + (borrow-city-count uint32) + (borrow-city pair 3) + (unknown-usd-33 int32 28) + (audio-language uint8) + (unknown-usd-34 int32 11) + (special-volume float) + (unknown-usd-35 int32 17) + ) + (:methods + (user-setting-data-method-9 () none) + (user-setting-data-method-10 () none) + ) + ) + +;; definition for method 3 of type user-setting-data +(defmethod inspect ((this user-setting-data)) + (when (not this) + (set! this this) + (goto cfg-79) + ) + (format #t "[~8x] ~A~%" this 'user-setting-data) + (format #t "~1Tborder-mode: ~A~%" (-> this border-mode)) + (format #t "~1Tprocess-mask: #x~X~%" (-> this process-mask)) + (let ((t9-3 format) + (a0-4 #t) + (a1-3 "~1Tlanguage: #x~X : ~S~%") + (a2-3 (-> this language)) + (v1-2 (-> this language)) + ) + (t9-3 a0-4 a1-3 a2-3 (cond + ((= v1-2 (language-enum russian)) + "russian" + ) + ((= v1-2 (language-enum english)) + "english" + ) + ((= v1-2 (language-enum uk-english)) + "uk-english" + ) + ((= v1-2 (language-enum french)) + "french" + ) + ((= v1-2 (language-enum korean)) + "korean" + ) + ((= v1-2 (language-enum german)) + "german" + ) + ((= v1-2 (language-enum dutch)) + "dutch" + ) + ((= v1-2 (language-enum portuguese)) + "portuguese" + ) + ((= v1-2 (language-enum spanish)) + "spanish" + ) + ((= v1-2 (language-enum commentary)) + "commentary" + ) + ((= v1-2 (language-enum italian)) + "italian" + ) + ((= v1-2 (language-enum japanese)) + "japanese" + ) + (else + "*unknown*" + ) + ) + ) + ) + (format #t "~1Tmovie: ~A~%" (ppointer->process (-> this movie))) + (format #t "~1Ttalking: ~A~%" (ppointer->process (-> this talking))) + (format #t "~1Tspooling: ~A~%" (ppointer->process (-> this spooling))) + (format #t "~1Thint: ~A~%" (ppointer->process (-> this hint))) + (format #t "~1Tambient: ~A~%" (ppointer->process (-> this ambient))) + (format #t "~1Tvideo-mode: ~A~%" (-> this video-mode)) + (format #t "~1Taspect-ratio: ~A~%" (-> this aspect-ratio)) + (format #t "~1Tauto-save: ~A~%" (-> this auto-save)) + (format #t "~1Tbg-r: ~f~%" (-> this bg-r)) + (format #t "~1Tbg-g: ~f~%" (-> this bg-g)) + (format #t "~1Tbg-b: ~f~%" (-> this bg-b)) + (format #t "~1Tbg-a: ~f~%" (-> this bg-a)) + (format #t "~1Tbg-a-speed: ~f~%" (-> this bg-a-speed)) + (format #t "~1Tbg-a-force: ~f~%" (-> this bg-a-force)) + (format #t "~1Tblur-a: ~f~%" (-> this blur-a)) + (format #t "~1Tblur-a-speed: ~f~%" (-> this blur-a-speed)) + (format #t "~1Tallow-progress: ~A~%" (-> this allow-progress)) + (format #t "~1Tallow-in-game-menu: ~A~%" (-> this allow-in-game-menu)) + (format #t "~1Tallow-pause: ~A~%" (-> this allow-pause)) + (format #t "~1Tmovie-name: ~A~%" (-> this movie-name)) + (format #t "~1Tweather: ~A~%" (-> this weather)) + (format #t "~1Ttask-mask: #x~X : (task-mask " (-> this task-mask)) + (let ((s5-0 (-> this task-mask))) + (if (= (logand s5-0 (task-mask network)) (task-mask network)) + (format #t "network ") + ) + (if (= (logand s5-0 (task-mask task0)) (task-mask task0)) + (format #t "task0 ") + ) + (if (= (logand s5-0 (task-mask task2)) (task-mask task2)) + (format #t "task2 ") + ) + (if (= (logand s5-0 (task-mask task4)) (task-mask task4)) + (format #t "task4 ") + ) + (if (= (logand s5-0 (task-mask task6)) (task-mask task6)) + (format #t "task6 ") + ) + (if (= (logand s5-0 (task-mask ctywide)) (task-mask ctywide)) + (format #t "ctywide ") + ) + (if (= (logand s5-0 (task-mask never)) (task-mask never)) + (format #t "never ") + ) + (if (= (logand (task-mask movie1) s5-0) (task-mask movie1)) + (format #t "movie1 ") + ) + (if (= (logand s5-0 (task-mask vehicle)) (task-mask vehicle)) + (format #t "vehicle ") + ) + (if (= (logand s5-0 (task-mask primary0)) (task-mask primary0)) + (format #t "primary0 ") + ) + (if (= (logand s5-0 (task-mask task1)) (task-mask task1)) + (format #t "task1 ") + ) + (if (= (logand s5-0 (task-mask task3)) (task-mask task3)) + (format #t "task3 ") + ) + (if (= (logand s5-0 (task-mask task5)) (task-mask task5)) + (format #t "task5 ") + ) + (if (= (logand s5-0 (task-mask task7)) (task-mask task7)) + (format #t "task7 ") + ) + (if (= (logand (task-mask movie2) s5-0) (task-mask movie2)) + (format #t "movie2 ") + ) + (if (= (logand s5-0 (task-mask done)) (task-mask done)) + (format #t "done ") + ) + (if (= (logand s5-0 (task-mask special)) (task-mask special)) + (format #t "special ") + ) + (if (= (logand (task-mask movie0) s5-0) (task-mask movie0)) + (format #t "movie0 ") + ) + (if (= (logand s5-0 (task-mask dummy0)) (task-mask dummy0)) + (format #t "dummy0 ") + ) + ) + (format #t ")~%") + (format #t "~1Tspeed-mult: ~f~%" (-> this speed-mult)) + (format #t "~1Tfeatures: ~D~%" (-> this features)) + (format #t "~1Tvehicles: ~D~%" (-> this vehicles)) + (format #t "~1Tsfx-volume: ~f~%" (-> this sfx-volume)) + (format #t "~1Tsfx-volume-movie: ~f~%" (-> this sfx-volume-movie)) + (format #t "~1Tmusic-volume: ~f~%" (-> this music-volume)) + (format #t "~1Tmusic-volume-movie: ~f~%" (-> this music-volume-movie)) + (format #t "~1Tdialog-volume: ~f~%" (-> this dialog-volume)) + (format #t "~1Tdialog-volume-talker: ~f~%" (-> this dialog-volume-talker)) + (format #t "~1Tambient-volume: ~f~%" (-> this ambient-volume)) + (format #t "~1Tambient-volume-movie: ~f~%" (-> this ambient-volume-movie)) + (format #t "~1Tdynamic-ambient-volume: ~f~%" (-> this dynamic-ambient-volume)) + (format #t "~1Ttalker-volume: ~f~%" (-> this talker-volume)) + (format #t "~1Tmode-sound-bank: ~A~%" (-> this mode-sound-bank)) + (format #t "~1Tsound-reverb: ~f~%" (-> this sound-reverb)) + (format #t "~1Tsound-reverb-mode: ~D~%" (-> this sound-reverb-mode)) + (format #t "~1Tsound-reverb-seek-speed: ~f~%" (-> this sound-reverb-seek-speed)) + (format #t "~1Tstereo-mode: ~D~%" (-> this stereo-mode)) + (format #t "~1Tmusic: ~A~%" (-> this music)) + (format #t "~1Tspool-anim: ~A~%" (-> this spool-anim)) + (format #t "~1Ttask-manager: ~A~%" (ppointer->process (-> this task-manager))) + (format #t "~1Ttask: ~A~%" (-> this task)) + (format #t "~1Tairlock: ~A~%" (-> this airlock)) + (format #t "~1Tminimap: ~D~%" (-> this minimap)) + (format #t "~1Tallow-continue: ~A~%" (-> this allow-continue)) + (format #t "~1Tsubtitle: ~A~%" (-> this subtitle)) + (format #t "~1Tdoorway: ~A~%" (-> this doorway)) + (format #t "~1Tgem: ~A~%" (-> this gem)) + (format #t "~1Thalf-speed: ~A~%" (-> this half-speed)) + (format #t "~1Tgun-buoy: ~A~%" (-> this gun-buoy)) + (format #t "~1Tdouble-jump: ~A~%" (-> this double-jump)) + (format #t "~1Tpilot: ~A~%" (-> this pilot)) + (format #t "~1Tpilot-exit: ~A~%" (-> this pilot-exit)) + (format #t "~1Tpilot-death: ~A~%" (-> this pilot-death)) + (format #t "~1Tspeech-control: ~A~%" (-> this speech-control)) + (format #t "~1Tvehicle-hijacking: ~A~%" (-> this vehicle-hijacking)) + (format #t "~1Tendlessfall: ~A~%" (-> this endlessfall)) + (format #t "~1Train: ~f~%" (-> this rain)) + (format #t "~1Tsnow: ~f~%" (-> this snow)) + (format #t "~1Texclusive-load: ~A~%" (-> this exclusive-load)) + (format #t "~1Trender: ~A~%" (-> this render)) + (format #t "~1Tallow-timeout: ~A~%" (-> this allow-timeout)) + (format #t "~1Tmirror: ~A~%" (-> this mirror)) + (format #t "~1Tmovie-skip-frame: ~f~%" (-> this movie-skip-frame)) + (format #t "~1Tallow-blackout: ~A~%" (-> this allow-blackout)) + (format #t "~1Trace-minimap: ~D~%" (-> this race-minimap)) + (format #t "~1Tbeard: ~A~%" (-> this beard)) + (format #t "~1Tignore-target: ~A~%" (-> this ignore-target)) + (format #t "~1Tsubtitle-language: ~D~%" (-> this subtitle-language)) + (format #t "~1Tsound-bank-load: ~A~%" (-> this sound-bank-load)) + (format #t "~1Tallow-error: ~A~%" (-> this allow-error)) + (format #t "~1Tunder-water-pitch-mod: ~f~%" (-> this under-water-pitch-mod)) + (format #t "~1Trestart-info: ~A~%" (-> this restart-info)) + (format #t "~1Tfail-info: ~A~%" (-> this fail-info)) + (format #t "~1Tdeath-info: ~A~%" (-> this death-info)) + (format #t "~1Tquit-info: ~A~%" (-> this quit-info)) + (format #t "~1Textra-bank-count: ~D~%" (-> this extra-bank-count)) + (format #t "~1Textra-bank[3] @ #x~X~%" (-> this extra-bank)) + (format #t "~1Tborrow-count: ~D~%" (-> this borrow-count)) + (format #t "~1Tborrow[3] @ #x~X~%" (-> this borrow)) + (format #t "~1Texclusive-task-count: ~D~%" (-> this exclusive-task-count)) + (format #t "~1Texclusive-task[3] @ #x~X~%" (-> this exclusive-task)) + (format #t "~1Tlevel-trans-time: ~D~%" (-> this level-trans-time)) + (format #t "~1Tletterbox: ~f~%" (-> this letterbox)) + (format #t "~1Tletterbox-speed: ~f~%" (-> this letterbox-speed)) + (format #t "~1Tborrow-city-count: ~D~%" (-> this borrow-city-count)) + (format #t "~1Tborrow-city[3] @ #x~X~%" (-> this borrow-city)) + (format #t "~1Taudio-language: ~D~%" (-> this audio-language)) + (format #t "~1Tspecial-volume: ~f~%" (-> this special-volume)) + (label cfg-79) + this + ) + +;; definition of type cam-setting-data +(deftype cam-setting-data (structure) + ((fov degrees) + (pov-handle uint64 :offset 16) + (pov-bone int32) + (pov-offset vector :inline) + (string-default symbol) + (string-max-length meters) + (string-min-length meters) + (string-max-height meters) + (string-min-height meters) + (string-cliff-height meters) + (string-camera-floor meters) + (string-camera-ceiling meters) + (gun-max-height meters) + (gun-min-height meters) + (string-local-down vector :inline) + (slave-options cam-slave-options) + (matrix-blend-max-angle degrees) + (matrix-blend-max-partial float) + (string-spline-max-move meters) + (string-spline-accel meters) + (string-spline-max-move-player meters) + (string-spline-accel-player meters) + (string-startup-vector vector :inline) + (use-string-startup-vector symbol) + (look-at-point vector :inline) + (use-look-at-point symbol) + (target-height meters) + (foot-offset meters) + (head-offset meters) + (teleport-on-entity-change symbol) + (entity-name string) + (cam-slope string) + (entity-or-mode-changed symbol) + (master-options cam-master-options) + (entity-mask uint32) + (mode-name symbol) + (real-entity-name string) + (cam-mode symbol) + (interp-time uint32) + (no-intro symbol) + (use-point-of-interest symbol) + (point-of-interest vector :inline) + (handle-of-interest uint64) + (mouse-tumble-point vector :inline) + (use-mouse-tumble-point symbol) + (mouse-input symbol) + (cpad1-skip-buttons symbol) + (butt-handle uint64) + (butt-angle float) + (extra-follow-height float) + (interp-time-priority uint32) + (string-max-length-default symbol) + (string-min-length-default symbol) + (string-max-height-default symbol) + (string-min-height-default symbol) + (flip-vertical symbol) + (flip-horizontal symbol) + (dummy object 1) + (fov-priority float) + (ocean-off basic) + (ocean-override basic) + (crash-cam-force-freeze basic) + ) + (:methods + (cam-setting-data-method-9 () none) + (cam-setting-data-method-10 () none) + ) + ) + +;; definition for method 3 of type cam-setting-data +(defmethod inspect ((this cam-setting-data)) + (when (not this) + (set! this this) + (goto cfg-76) + ) + (format #t "[~8x] ~A~%" this 'cam-setting-data) + (format #t "~1Tfov: (deg ~r)~%" (-> this fov)) + (format #t "~1Tpov-handle: ~D~%" (-> this pov-handle)) + (format #t "~1Tpov-bone: ~D~%" (-> this pov-bone)) + (format #t "~1Tpov-offset: ~`vector`P~%" (-> this pov-offset)) + (format #t "~1Tstring-default: ~`boolean`P~%" (-> this string-default)) + (format #t "~1Tstring-max-length: (meters ~m)~%" (-> this string-max-length)) + (format #t "~1Tstring-min-length: (meters ~m)~%" (-> this string-min-length)) + (format #t "~1Tstring-max-height: (meters ~m)~%" (-> this string-max-height)) + (format #t "~1Tstring-min-height: (meters ~m)~%" (-> this string-min-height)) + (format #t "~1Tstring-cliff-height: (meters ~m)~%" (-> this string-cliff-height)) + (format #t "~1Tstring-camera-floor: (meters ~m)~%" (-> this string-camera-floor)) + (format #t "~1Tstring-camera-ceiling: (meters ~m)~%" (-> this string-camera-ceiling)) + (format #t "~1Tgun-max-height: (meters ~m)~%" (-> this gun-max-height)) + (format #t "~1Tgun-min-height: (meters ~m)~%" (-> this gun-min-height)) + (format #t "~1Tstring-local-down: ~`vector`P~%" (-> this string-local-down)) + (format #t "~1Tslave-options: #x~X : (cam-slave-options " (-> this slave-options)) + (let ((s5-0 (-> this slave-options))) + (if (= (logand s5-0 (cam-slave-options SAME_SIDE)) (cam-slave-options SAME_SIDE)) + (format #t "SAME_SIDE ") + ) + (if (= (logand (cam-slave-options GUN_CAM) s5-0) (cam-slave-options GUN_CAM)) + (format #t "GUN_CAM ") + ) + (if (= (logand (cam-slave-options BOMBBOT) s5-0) (cam-slave-options BOMBBOT)) + (format #t "BOMBBOT ") + ) + (if (= (logand s5-0 (cam-slave-options STICKY_ANGLE)) (cam-slave-options STICKY_ANGLE)) + (format #t "STICKY_ANGLE ") + ) + (if (= (logand s5-0 (cam-slave-options FIND_HIDDEN_TARGET)) (cam-slave-options FIND_HIDDEN_TARGET)) + (format #t "FIND_HIDDEN_TARGET ") + ) + (if (= (logand (cam-slave-options RAPID_TRACKING) s5-0) (cam-slave-options RAPID_TRACKING)) + (format #t "RAPID_TRACKING ") + ) + (if (= (logand s5-0 (cam-slave-options SHRINK_MAX_ANGLE)) (cam-slave-options SHRINK_MAX_ANGLE)) + (format #t "SHRINK_MAX_ANGLE ") + ) + (if (= (logand s5-0 (cam-slave-options JUMP_PITCHES)) (cam-slave-options JUMP_PITCHES)) + (format #t "JUMP_PITCHES ") + ) + (if (= (logand s5-0 (cam-slave-options LINE_OF_SIGHT)) (cam-slave-options LINE_OF_SIGHT)) + (format #t "LINE_OF_SIGHT ") + ) + (if (= (logand s5-0 (cam-slave-options PLAYER_MOVING_CAMERA)) (cam-slave-options PLAYER_MOVING_CAMERA)) + (format #t "PLAYER_MOVING_CAMERA ") + ) + (if (= (logand (cam-slave-options ALLOW_SHIFT_BUTTONS) s5-0) (cam-slave-options ALLOW_SHIFT_BUTTONS)) + (format #t "ALLOW_SHIFT_BUTTONS ") + ) + (if (= (logand s5-0 (cam-slave-options NO_ROTATE)) (cam-slave-options NO_ROTATE)) + (format #t "NO_ROTATE ") + ) + (if (= (logand (cam-slave-options WIDE_FOV) s5-0) (cam-slave-options WIDE_FOV)) + (format #t "WIDE_FOV ") + ) + (if (= (logand s5-0 (cam-slave-options MOVE_SPHERICAL)) (cam-slave-options MOVE_SPHERICAL)) + (format #t "MOVE_SPHERICAL ") + ) + (if (= (logand s5-0 (cam-slave-options DRAG)) (cam-slave-options DRAG)) + (format #t "DRAG ") + ) + (if (= (logand s5-0 (cam-slave-options MOVEMENT_BLOCKED)) (cam-slave-options MOVEMENT_BLOCKED)) + (format #t "MOVEMENT_BLOCKED ") + ) + (if (= (logand (cam-slave-options BLOCK_RIGHT_STICK) s5-0) (cam-slave-options BLOCK_RIGHT_STICK)) + (format #t "BLOCK_RIGHT_STICK ") + ) + (if (= (logand s5-0 (cam-slave-options COLLIDE)) (cam-slave-options COLLIDE)) + (format #t "COLLIDE ") + ) + (if (= (logand s5-0 (cam-slave-options ALLOW_Z_ROT)) (cam-slave-options ALLOW_Z_ROT)) + (format #t "ALLOW_Z_ROT ") + ) + (if (= (logand (cam-slave-options JUMP_LAG) s5-0) (cam-slave-options JUMP_LAG)) + (format #t "JUMP_LAG ") + ) + (if (= (logand s5-0 (cam-slave-options BIKE_MODE)) (cam-slave-options BIKE_MODE)) + (format #t "BIKE_MODE ") + ) + (if (= (logand (cam-slave-options EASE_SPLINE_IDX) s5-0) (cam-slave-options EASE_SPLINE_IDX)) + (format #t "EASE_SPLINE_IDX ") + ) + (if (= (logand s5-0 (cam-slave-options GOTO_GOOD_POINT)) (cam-slave-options GOTO_GOOD_POINT)) + (format #t "GOTO_GOOD_POINT ") + ) + (if (= (logand s5-0 (cam-slave-options BUTT_CAM)) (cam-slave-options BUTT_CAM)) + (format #t "BUTT_CAM ") + ) + (if (= (logand (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) s5-0) + (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) + ) + (format #t "VERTICAL_FOLLOW_MATCHES_CAMERA ") + ) + (if (= (logand (cam-slave-options HAVE_BUTT_HANDLE) s5-0) (cam-slave-options HAVE_BUTT_HANDLE)) + (format #t "HAVE_BUTT_HANDLE ") + ) + ) + (format #t ")~%") + (format #t "~1Tmatrix-blend-max-angle: (deg ~r)~%" (-> this matrix-blend-max-angle)) + (format #t "~1Tmatrix-blend-max-partial: ~f~%" (-> this matrix-blend-max-partial)) + (format #t "~1Tstring-spline-max-move: (meters ~m)~%" (-> this string-spline-max-move)) + (format #t "~1Tstring-spline-accel: (meters ~m)~%" (-> this string-spline-accel)) + (format #t "~1Tstring-spline-max-move-player: (meters ~m)~%" (-> this string-spline-max-move-player)) + (format #t "~1Tstring-spline-accel-player: (meters ~m)~%" (-> this string-spline-accel-player)) + (format #t "~1Tstring-startup-vector: ~`vector`P~%" (-> this string-startup-vector)) + (format #t "~1Tuse-string-startup-vector: ~A~%" (-> this use-string-startup-vector)) + (format #t "~1Tlook-at-point: ~`vector`P~%" (-> this look-at-point)) + (format #t "~1Tuse-look-at-point: ~A~%" (-> this use-look-at-point)) + (format #t "~1Ttarget-height: (meters ~m)~%" (-> this target-height)) + (format #t "~1Tfoot-offset: (meters ~m)~%" (-> this foot-offset)) + (format #t "~1Thead-offset: (meters ~m)~%" (-> this head-offset)) + (format #t "~1Tteleport-on-entity-change: ~`boolean`P~%" (-> this teleport-on-entity-change)) + (format #t "~1Tentity-name: ~`string`P~%" (-> this entity-name)) + (format #t "~1Tcam-slope: ~`string`P~%" (-> this cam-slope)) + (format #t "~1Tentity-or-mode-changed: ~`boolean`P~%" (-> this entity-or-mode-changed)) + (format #t "~1Tmaster-options: #x~X : (cam-master-options " (-> this master-options)) + (let ((s5-1 (-> this master-options))) + (if (= (logand s5-1 (cam-master-options IMMEDIATE_STRING_MIN_MAX)) (cam-master-options IMMEDIATE_STRING_MIN_MAX)) + (format #t "IMMEDIATE_STRING_MIN_MAX ") + ) + (if (= (logand s5-1 (cam-master-options IN_BASE_REGION)) (cam-master-options IN_BASE_REGION)) + (format #t "IN_BASE_REGION ") + ) + (if (= (logand s5-1 (cam-master-options FLIP_COMBINER)) (cam-master-options FLIP_COMBINER)) + (format #t "FLIP_COMBINER ") + ) + (if (= (logand s5-1 (cam-master-options SET_COMBINER_AXIS)) (cam-master-options SET_COMBINER_AXIS)) + (format #t "SET_COMBINER_AXIS ") + ) + (if (= (logand s5-1 (cam-master-options USE_L1_R1)) (cam-master-options USE_L1_R1)) + (format #t "USE_L1_R1 ") + ) + (if (= (logand s5-1 (cam-master-options IGNORE_ANALOG)) (cam-master-options IGNORE_ANALOG)) + (format #t "IGNORE_ANALOG ") + ) + (if (= (logand s5-1 (cam-master-options BLOCK_RIGHT_STICK)) (cam-master-options BLOCK_RIGHT_STICK)) + (format #t "BLOCK_RIGHT_STICK ") + ) + (if (= (logand s5-1 (cam-master-options READ_BUTTONS)) (cam-master-options READ_BUTTONS)) + (format #t "READ_BUTTONS ") + ) + (if (= (logand s5-1 (cam-master-options HAVE_TARGET)) (cam-master-options HAVE_TARGET)) + (format #t "HAVE_TARGET ") + ) + (if (= (logand s5-1 (cam-master-options HAVE_EASE_TO_POS)) (cam-master-options HAVE_EASE_TO_POS)) + (format #t "HAVE_EASE_TO_POS ") + ) + ) + (format #t ")~%") + (format #t "~1Tentity-mask: ~D~%" (-> this entity-mask)) + (format #t "~1Tmode-name: ~A~%" (-> this mode-name)) + (format #t "~1Treal-entity-name: ~`string`P~%" (-> this real-entity-name)) + (format #t "~1Tcam-mode: ~A~%" (-> this cam-mode)) + (format #t "~1Tinterp-time: ~D~%" (-> this interp-time)) + (format #t "~1Tno-intro: ~A~%" (-> this no-intro)) + (format #t "~1Tuse-point-of-interest: ~A~%" (-> this use-point-of-interest)) + (format #t "~1Tpoint-of-interest: ~`vector`P~%" (-> this point-of-interest)) + (format #t "~1Thandle-of-interest: ~D~%" (-> this handle-of-interest)) + (format #t "~1Tmouse-tumble-point: ~`vector`P~%" (-> this mouse-tumble-point)) + (format #t "~1Tuse-mouse-tumble-point: ~A~%" (-> this use-mouse-tumble-point)) + (format #t "~1Tmouse-input: ~A~%" (-> this mouse-input)) + (format #t "~1Tcpad1-skip-buttons: ~A~%" (-> this cpad1-skip-buttons)) + (format #t "~1Tbutt-handle: ~D~%" (-> this butt-handle)) + (format #t "~1Tbutt-angle: ~f~%" (-> this butt-angle)) + (format #t "~1Textra-follow-height: ~f~%" (-> this extra-follow-height)) + (format #t "~1Tinterp-time-priority: ~D~%" (-> this interp-time-priority)) + (format #t "~1Tstring-max-length-default: ~A~%" (-> this string-max-length-default)) + (format #t "~1Tstring-min-length-default: ~A~%" (-> this string-min-length-default)) + (format #t "~1Tstring-max-height-default: ~A~%" (-> this string-max-height-default)) + (format #t "~1Tstring-min-height-default: ~A~%" (-> this string-min-height-default)) + (format #t "~1Tflip-vertical: ~A~%" (-> this flip-vertical)) + (format #t "~1Tflip-horizontal: ~A~%" (-> this flip-horizontal)) + (format #t "~1Tfov-priority: ~f~%" (-> this fov-priority)) + (format #t "~1Tocean-off: ~A~%" (-> this ocean-off)) + (format #t "~1Tocean-override: ~A~%" (-> this ocean-override)) + (format #t "~1Tcrash-cam-force-freeze: ~A~%" (-> this crash-cam-force-freeze)) + (label cfg-76) + this + ) + +;; definition of type cam-setting-state +(deftype cam-setting-state (structure) + ((current cam-setting-data :inline) + (target cam-setting-data :inline) + (default cam-setting-data :inline) + ) + ) + +;; definition for method 3 of type cam-setting-state +(defmethod inspect ((this cam-setting-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cam-setting-state) + (format #t "~1Tcurrent: #~%" (-> this current)) + (format #t "~1Ttarget: #~%" (-> this target)) + (format #t "~1Tdefault: #~%" (-> this default)) + (label cfg-4) + this + ) + +;; definition of type engine-group +(deftype engine-group (structure) + ((engine basic) + (engine-pers basic) + (engine-hi basic) + ) + ) + +;; definition for method 3 of type engine-group +(defmethod inspect ((this engine-group)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'engine-group) + (format #t "~1Tengine: ~A~%" (-> this engine)) + (format #t "~1Tengine-pers: ~A~%" (-> this engine-pers)) + (format #t "~1Tengine-hi: ~A~%" (-> this engine-hi)) + (label cfg-4) + this + ) + +;; definition of type setting-control +(deftype setting-control (basic) + ((user-current user-setting-data :inline) + (user-target user-setting-data :inline) + (user-default user-setting-data :inline) + (cam-settings cam-setting-state 4 :inline) + (engine engine) + (engine-pers engine-pers) + (engine-hi engine) + (cam-engines engine-group 4) + ) + (:methods + (new (symbol type int) _type_) + (setting-control-method-9 () none) + (setting-control-method-10 () none) + (setting-control-method-11 () none) + (setting-control-method-12 () none) + (setting-control-method-13 () none) + (setting-control-method-14 () none) + (setting-control-method-15 () none) + (setting-control-method-16 () none) + (setting-control-method-17 () none) + (setting-control-method-18 () none) + (setting-control-method-19 () none) + (setting-control-method-20 () none) + (setting-control-method-21 () none) + (setting-control-method-22 () none) + (setting-control-method-23 () none) + (setting-control-method-24 () none) + ) + ) + +;; definition for method 3 of type setting-control +(defmethod inspect ((this setting-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tuser-current: #~%" (-> this user-current)) + (format #t "~1Tuser-target: #~%" (-> this user-target)) + (format #t "~1Tuser-default: #~%" (-> this user-default)) + (format #t "~1Tcam-settings[4] @ #x~X~%" (-> this cam-settings)) + (format #t "~1Tengine: ~A~%" (-> this engine)) + (format #t "~1Tengine-pers: ~A~%" (-> this engine-pers)) + (format #t "~1Tengine-hi: ~A~%" (-> this engine-hi)) + (format #t "~1Tcam-engines[4] @ #x~X~%" (-> this cam-engines)) + (label cfg-4) + this + ) + +;; definition for method 0 of type setting-control +(defmethod new setting-control ((allocation symbol) (type-to-make type) (arg0 int)) + (let ((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 arg0 connection)) + (set! (-> s4-0 engine-hi) ((method-of-type engine new) allocation engine 'setting-control arg0 connection)) + (set! (-> s4-0 engine-pers) + ((method-of-type engine-pers new) allocation engine-pers 'setting-control arg0 connection-pers) + ) + (dotimes (s3-0 4) + (set! (-> s4-0 cam-engines s3-0) (new 'global 'engine-group)) + (set! (-> s4-0 cam-engines s3-0 engine) + ((method-of-type engine new) allocation engine 'setting-control arg0 connection) + ) + (set! (-> s4-0 cam-engines s3-0 engine-hi) + ((method-of-type engine new) allocation engine 'setting-control arg0 connection) + ) + (set! (-> s4-0 cam-engines s3-0 engine-pers) + ((method-of-type engine-pers new) allocation engine-pers 'setting-control arg0 connection-pers) + ) + ) + s4-0 + ) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/game/task/game-task-h_REF.gc b/test/decompiler/reference/jakx/engine/game/task/game-task-h_REF.gc new file mode 100644 index 0000000000..d90eb505f7 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/game/task/game-task-h_REF.gc @@ -0,0 +1,574 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *net-play-mode-names*, type (array symbol) +(define *net-play-mode-names* (new 'static 'boxed-array :type symbol + 'race + 'deathrace + 'timebox + 'timetrial + 'deathmatch + 'hunt + 'collect + 'ctf + 'reversi + 'team-deathmatch + 'football + 'artifact + 'king-of-hill + 'rushhour + 'assassin + 'training + 'training2 + 'boss-battle + 'artist + 'invalid + 'intro-b + ) + ) + +;; definition for symbol *net-play-mode-text-ids*, type (pointer text-id) +(define *net-play-mode-text-ids* (new 'static 'array text-id 24 + (text-id text-id-1581) + (text-id text-id-1588) + (text-id text-id-1655) + (text-id text-id-2183) + (text-id text-id-1580) + (text-id text-id-1579) + (text-id text-id-1838) + (text-id text-id-1694) + (text-id text-id-1839) + (text-id text-id-1695) + (text-id text-id-1624) + (text-id text-id-1625) + (text-id text-id-1633) + (text-id text-id-1656) + (text-id text-id-2513) + (text-id text-id-1659) + (text-id text-id-1659) + (text-id text-id-1940) + (text-id null) + (text-id null) + (text-id null) + (text-id null) + (text-id null) + (text-id null) + ) + ) + +;; definition for symbol *net-play-mode-icon-string*, type (array string) +(define *net-play-mode-icon-string* (new 'static 'boxed-array :type string + "amode-icon-crace-01" + "amode-icon-drace-01" + "amode-icon-ttrial-01" + "amode-icon-ttrial-01" + "amode-icon-dmatch-01" + "amode-icon-shunt-01" + "common-white" + "amode-icon-cflag-01" + "common-white" + "common-white" + "amode-icon-derby-01" + "amode-icon-arace-01" + "common-white" + "amode-icon-rhour-01" + "common-white" + "common-white" + "common-white" + "common-white" + "common-white" + "common-white" + ) + ) + +;; definition of type task-level-info +(deftype task-level-info (structure) + ((flags uint32) + (text-id uint32) + (venue-text-id uint32) + (caps-text-id uint32) + (tex-name basic) + (race-mesh-name basic) + (race-banner-name basic) + (race-ai-tuning-name basic) + ) + ) + +;; definition for method 3 of type task-level-info +(defmethod inspect ((this task-level-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'task-level-info) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Ttext-id: ~D~%" (-> this text-id)) + (format #t "~1Tvenue-text-id: ~D~%" (-> this venue-text-id)) + (format #t "~1Tcaps-text-id: ~D~%" (-> this caps-text-id)) + (format #t "~1Ttex-name: ~A~%" (-> this tex-name)) + (format #t "~1Trace-mesh-name: ~A~%" (-> this race-mesh-name)) + (format #t "~1Trace-banner-name: ~A~%" (-> this race-banner-name)) + (format #t "~1Trace-ai-tuning-name: ~A~%" (-> this race-ai-tuning-name)) + (label cfg-4) + this + ) + +;; definition for symbol *task-level*, type (array symbol) +(define *task-level* (new 'static 'boxed-array :type symbol + 'default + 'brdroom + 'jungle + 'snow + 'kras + 'canyon + 'canspar + 'temple + 'spartem + 'haven + 'havjung + 'havsew + 'havtour + 'ice + 'sewer + 'coliseum + 'desarena + 'snobowl + 'cliffs + 'spargus + 'spatour + 'docks + 'dockkra + 'dromdoc + 'kcross + 'peak + 'iceberg + 'icepass + 'drome + 'kratour + 'icetour + 'desisle + 'atoll + 'fort + 'garage + 'hiphog + 'eight + 'eightb + 'rustyh + 'curve + 'andrew + 'ben + 'test + 'city + 'artist + ) + ) + +;; definition for symbol *task-level-info*, type (array task-level-info) +(define *task-level-info* (new 'static 'boxed-array :type task-level-info + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x55f + :venue-text-id #xf10 + :caps-text-id #x631 + :tex-name "icon-jungle" + :race-mesh-name "race-mesh-25" + :race-banner-name "race-banner-4" + :race-ai-tuning-name "*jungle-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x54f + :venue-text-id #xf20 + :caps-text-id #x633 + :tex-name "icon-snow" + :race-mesh-name "race-mesh-26" + :race-banner-name "race-banner-2" + :race-ai-tuning-name "*snow-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x550 + :venue-text-id #xf08 + :caps-text-id #x632 + :tex-name "icon-kras" + :race-mesh-name "race-mesh-22" + :race-banner-name "race-banner-3" + :race-ai-tuning-name "*kras-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x5e9 + :venue-text-id #xf19 + :caps-text-id #x70e + :tex-name "icon-canyon" + :race-mesh-name "race-mesh-41" + :race-banner-name "race-banner-12" + :race-ai-tuning-name "*canyon-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x76b + :venue-text-id #xf1b + :caps-text-id #x730 + :tex-name "icon-canspar" + :race-mesh-name "race-mesh-42" + :race-banner-name "race-banner-9" + :race-ai-tuning-name "*canspar-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x7a1 + :venue-text-id #xf1a + :caps-text-id #x7a5 + :tex-name "icon-temple" + :race-mesh-name "race-mesh-55" + :race-banner-name "race-banner-20" + :race-ai-tuning-name "*temple-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x92e + :venue-text-id #xf1d + :caps-text-id #x793 + :tex-name "icon-spartem" + :race-mesh-name "race-mesh-56" + :race-banner-name "race-banner-21" + :race-ai-tuning-name "*spartem-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x5ae + :venue-text-id #xf11 + :caps-text-id #x674 + :tex-name "icon-haven" + :race-mesh-name "race-mesh-27" + :race-banner-name "race-banner-5" + :race-ai-tuning-name "*haven-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x673 + :venue-text-id #xf13 + :caps-text-id #x676 + :tex-name "icon-havjung" + :race-mesh-name "race-mesh-31" + :race-banner-name "race-banner-6" + :race-ai-tuning-name "*havjung-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x74b + :venue-text-id #xf14 + :caps-text-id #x731 + :tex-name "icon-havsew" + :race-mesh-name "race-mesh-40" + :race-banner-name "race-banner-8" + :race-ai-tuning-name "*havsew-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x7ea + :venue-text-id #xf15 + :caps-text-id #x732 + :tex-name "icon-havtour" + :race-mesh-name "race-mesh-50" + :race-banner-name "race-banner-10" + :race-ai-tuning-name "*havtour-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x9e8 + :venue-text-id #xf22 + :caps-text-id #x733 + :tex-name "icon-ice" + :race-mesh-name "race-mesh-66" + :race-banner-name "race-banner-18" + :race-ai-tuning-name "*ice-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x11c + :venue-text-id #xf12 + :caps-text-id #x734 + :tex-name "icon-sewer" + :race-mesh-name "race-mesh-37" + :race-banner-name "race-banner-11" + :race-ai-tuning-name "*sewer-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x561 + :venue-text-id #xf0e + :caps-text-id #x630 + :tex-name "icon-coliseum" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x562 + :venue-text-id #xf1e + :caps-text-id #x62f + :tex-name "icon-desert" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x5af + :venue-text-id #xf26 + :caps-text-id #x675 + :tex-name "icon-snobowl" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x560 + :venue-text-id #xf17 + :caps-text-id #x62e + :tex-name "icon-cliffs" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x74c + :venue-text-id #xf18 + :caps-text-id #x735 + :tex-name "icon-spargus" + :race-mesh-name "race-mesh-38" + :race-banner-name "race-banner-7" + :race-ai-tuning-name "*spargus-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x79f + :venue-text-id #xf1c + :caps-text-id #x7a6 + :tex-name "icon-spatour" + :race-mesh-name "race-mesh-79" + :race-banner-name "race-banner-15" + :race-ai-tuning-name "*spatour-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x5e8 + :venue-text-id #xf09 + :caps-text-id #x736 + :tex-name "icon-docks" + :race-mesh-name "race-mesh-44" + :race-banner-name "race-banner-13" + :race-ai-tuning-name "*docks-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x8d0 + :venue-text-id #xf0b + :caps-text-id #x737 + :tex-name "icon-dockkra" + :race-mesh-name "race-mesh-45" + :race-banner-name "race-banner-14" + :race-ai-tuning-name "*dockkra-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x7a2 + :venue-text-id #xf0c + :caps-text-id #x7a9 + :tex-name "icon-dromdoc" + :race-mesh-name "race-mesh-73" + :race-banner-name "race-banner-19" + :race-ai-tuning-name "*dromdoc-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x6fe + :venue-text-id #xf0f + :caps-text-id #x6ff + :tex-name "icon-kcross" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x977 + :venue-text-id #xf21 + :caps-text-id #x738 + :tex-name "icon-peak" + :race-mesh-name "race-mesh-69" + :race-banner-name "race-banner-23" + :race-ai-tuning-name "*peak-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x9e9 + :venue-text-id #xf23 + :caps-text-id #x792 + :tex-name "icon-iceberg" + :race-mesh-name "race-mesh-64" + :race-banner-name "race-banner-22" + :race-ai-tuning-name "*iceberg-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x9ea + :venue-text-id #xf24 + :caps-text-id #x791 + :tex-name "icon-icepass" + :race-mesh-name "race-mesh-63" + :race-banner-name "race-banner-25" + :race-ai-tuning-name "*icepass-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x9ed + :venue-text-id #xf0a + :caps-text-id #x75b + :tex-name "icon-drome" + :race-mesh-name "race-mesh-72" + :race-banner-name "race-banner-16" + :race-ai-tuning-name "*drome-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x7a3 + :venue-text-id #xf0d + :caps-text-id #x7a7 + :tex-name "icon-kratour" + :race-mesh-name "race-mesh-76" + :race-banner-name "race-banner-24" + :race-ai-tuning-name "*kratour-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x7a0 + :venue-text-id #xf25 + :caps-text-id #x7a4 + :tex-name "icon-icetour" + :race-mesh-name "race-mesh-84" + :race-banner-name "race-banner-26" + :race-ai-tuning-name "*icetour-ai-tuning*" + ) + (new 'static 'task-level-info + :text-id #x9e7 + :venue-text-id #xf1f + :caps-text-id #x739 + :tex-name "icon-desisle" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x11b + :venue-text-id #xf16 + :caps-text-id #x7a8 + :tex-name "icon-atoll" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :text-id #x9eb + :caps-text-id #x9ec + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "race-mesh-1" + :race-banner-name "" + :race-ai-tuning-name "*generic-ai-tuning*" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + (new 'static 'task-level-info + :tex-name "common-white" + :race-mesh-name "" + :race-banner-name "" + :race-ai-tuning-name "" + ) + ) + ) + +;; definition for symbol *driver-list-cup1*, type (array uint8) +(define *driver-list-cup1* (new 'static 'boxed-array :type uint8 #xb #xa #x1 #x5 #x7 #x9 #x6)) + +;; definition for symbol *driver-list-cup1-gp*, type (array uint8) +(define *driver-list-cup1-gp* (new 'static 'boxed-array :type uint8 #xb #xa #x1 #x5 #x7)) + +;; definition for symbol *driver-list-cup1-temp*, type (array uint8) +(define *driver-list-cup1-temp* (new 'static 'boxed-array :type uint8 #x1 #x5 #xa #x9 #x6)) + +;; definition for symbol *driver-list-cup2*, type (array uint8) +(define *driver-list-cup2* (new 'static 'boxed-array :type uint8 #x3)) + +;; definition for symbol *driver-list-cup2-gp*, type (array uint8) +(define *driver-list-cup2-gp* (new 'static 'boxed-array :type uint8 #x3 #x1 #xb #xa #x7)) + +;; definition for symbol *driver-list-cup3*, type (array uint8) +(define *driver-list-cup3* (new 'static 'boxed-array :type uint8 #x2 #xd)) + +;; definition for symbol *driver-list-cup3-capture*, type (array uint8) +(define *driver-list-cup3-capture* (new 'static 'boxed-array :type uint8 #xb #x1 #x3 #xa #x7)) + +;; definition for symbol *driver-list-cup3-gp*, type (array uint8) +(define *driver-list-cup3-gp* (new 'static 'boxed-array :type uint8 #x2 #xb #xd #x3 #xa)) + +;; definition for symbol *driver-list-cup4-capture*, type (array uint8) +(define *driver-list-cup4-capture* (new 'static 'boxed-array :type uint8 #xb #x1 #x2 #xa #x7)) + +;; definition for symbol *driver-list-cup4-gp*, type (array uint8) +(define *driver-list-cup4-gp* (new 'static 'boxed-array :type uint8 #x13 #x2 #xb #x3 #x4)) + +;; definition for symbol *driver-list-boss*, type (array uint8) +(define *driver-list-boss* (new 'static 'boxed-array :type uint8 #x13)) + +;; definition for symbol *driver-list-training*, type (array uint8) +(define *driver-list-training* (new 'static 'boxed-array :type uint8 #x5 #x6 #x7 #xb)) + + + + diff --git a/test/decompiler/reference/jakx/engine/geometry/bounding-box-h_REF.gc b/test/decompiler/reference/jakx/engine/geometry/bounding-box-h_REF.gc new file mode 100644 index 0000000000..e08ef63f94 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/geometry/bounding-box-h_REF.gc @@ -0,0 +1,124 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type bounding-box +(deftype bounding-box (structure) + ((min vector :inline) + (max vector :inline) + ) + (:methods + (add-spheres! (_type_ (inline-array sphere) int) int) + (add-box! (_type_ bounding-box) int) + (add-point! (_type_ vector) none) + (intersects-line-segment? (_type_ vector vector) symbol) + (set-from-point-offset! (_type_ vector vector) none) + (set-from-point-offset-pad! (_type_ vector vector float) int) + (set-to-point! (_type_ vector) none) + (set-from-sphere! (_type_ sphere) none) + (set-from-spheres! (_type_ (inline-array sphere) int) int) + (get-bounding-sphere (_type_ vector) vector) + (inside-xyz? (_type_ vector) symbol) + (inside-xz? (_type_ vector) symbol) + (bounding-box-method-21 (_type_ (inline-array vector)) symbol) + ) + ) + +;; definition for method 3 of type bounding-box +(defmethod inspect ((this bounding-box)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bounding-box) + (format #t "~1Tmin: ~`vector`P~%" (-> this min)) + (format #t "~1Tmax: ~`vector`P~%" (-> this max)) + (label cfg-4) + this + ) + +;; definition of type bounding-box2 +(deftype bounding-box2 (structure) + ((min vector2 :inline) + (max vector2 :inline) + ) + ) + +;; definition for method 3 of type bounding-box2 +(defmethod inspect ((this bounding-box2)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bounding-box2) + (format #t "~1Tmin: #~%" (-> this min)) + (format #t "~1Tmax: #~%" (-> this max)) + (label cfg-4) + this + ) + +;; definition of type bounding-box4w +(deftype bounding-box4w (structure) + ((min vector4w :inline) + (max vector4w :inline) + ) + ) + +;; definition for method 3 of type bounding-box4w +(defmethod inspect ((this bounding-box4w)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bounding-box4w) + (format #t "~1Tmin: ~`vector4w`P~%" (-> this min)) + (format #t "~1Tmax: ~`vector4w`P~%" (-> this max)) + (label cfg-4) + this + ) + +;; definition of type bounding-box-both +(deftype bounding-box-both (structure) + ((box bounding-box :inline) + (box4w bounding-box4w :inline) + ) + ) + +;; definition for method 3 of type bounding-box-both +(defmethod inspect ((this bounding-box-both)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bounding-box-both) + (format #t "~1Tbox: #~%" (-> this box)) + (format #t "~1Tbox4w: #~%" (-> this box4w)) + (label cfg-4) + this + ) + +;; definition of type bounding-box-array +(deftype bounding-box-array (inline-array-class) + ((data bounding-box :dynamic) + ) + ) + +;; definition for method 3 of type bounding-box-array +(defmethod inspect ((this bounding-box-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> bounding-box-array heap-base) (the-as uint 32)) + + + + diff --git a/test/decompiler/reference/jakx/engine/geometry/geometry-h_REF.gc b/test/decompiler/reference/jakx/engine/geometry/geometry-h_REF.gc new file mode 100644 index 0000000000..4cd327d662 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/geometry/geometry-h_REF.gc @@ -0,0 +1,235 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type curve +(deftype curve (structure) + ((cverts (inline-array vector)) + (num-cverts int32) + (knots (pointer float)) + (num-knots int32) + (length float) + ) + :allow-misaligned + ) + +;; definition for method 3 of type curve +(defmethod inspect ((this curve)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'curve) + (format #t "~1Tcverts: #x~X~%" (-> this cverts)) + (format #t "~1Tnum-cverts: ~D~%" (-> this num-cverts)) + (format #t "~1Tknots: #x~X~%" (-> this knots)) + (format #t "~1Tnum-knots: ~D~%" (-> this num-knots)) + (format #t "~1Tlength: ~f~%" (-> this length)) + (label cfg-4) + this + ) + +;; definition of type line-intersection-val +(deftype line-intersection-val (structure) + ((tt0 float) + (tt1 float) + ) + ) + +;; definition for method 3 of type line-intersection-val +(defmethod inspect ((this line-intersection-val)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'line-intersection-val) + (format #t "~1Ttt0: ~f~%" (-> this tt0)) + (format #t "~1Ttt1: ~f~%" (-> this tt1)) + (label cfg-4) + this + ) + +;; definition of type border-plane +(deftype border-plane (basic) + ((name symbol) + (action basic) + (slot int8) + (trans vector :inline) + (normal vector :inline) + ) + (:methods + (debug-draw (_type_) int) + (point-past-plane? (_type_ vector) symbol) + ) + ) + +;; definition for method 3 of type border-plane +(defmethod inspect ((this border-plane)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Taction: ~A~%" (-> this action)) + (format #t "~1Tslot: ~D~%" (-> this slot)) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Tnormal: ~`vector`P~%" (-> this normal)) + (label cfg-4) + this + ) + +;; definition of type lissajous +(deftype lissajous (structure) + "A curve where the x and y position are set by two different sinusoids. +This stores the parameters and state for evaluating this curve." + ((x-mag float) + (y-mag float) + (theta float) + (wx float) + (wy float) + (period-shift float) + (theta-rate float) + ) + :pack-me + (:methods + (evaluate! (_type_ vector) vector) + ) + ) + +;; definition for method 3 of type lissajous +(defmethod inspect ((this lissajous)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'lissajous) + (format #t "~1Tx-mag: ~f~%" (-> this x-mag)) + (format #t "~1Ty-mag: ~f~%" (-> this y-mag)) + (format #t "~1Ttheta: ~f~%" (-> this theta)) + (format #t "~1Twx: ~f~%" (-> this wx)) + (format #t "~1Twy: ~f~%" (-> this wy)) + (format #t "~1Tperiod-shift: ~f~%" (-> this period-shift)) + (format #t "~1Ttheta-rate: ~f~%" (-> this theta-rate)) + (label cfg-4) + this + ) + +;; definition of type lissajous-interp +(deftype lissajous-interp (structure) + "Handles interpolating between two different lissajous parameters, and also +stepping forward the dynamics." + ((current lissajous :inline) + (dest lissajous :inline) + (rate lissajous :inline) + ) + (:methods + (evaluate! (_type_ vector) vector) + (update! (_type_) float) + ) + ) + +;; definition for method 3 of type lissajous-interp +(defmethod inspect ((this lissajous-interp)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'lissajous-interp) + (format #t "~1Tcurrent: #~%" (-> this current)) + (format #t "~1Tdest: #~%" (-> this dest)) + (format #t "~1Trate: #~%" (-> this rate)) + (label cfg-4) + this + ) + +;; definition of type ellipsoid +(deftype ellipsoid (vector) + ((width float :overlay-at (-> data 0)) + (height float :overlay-at (-> data 1)) + (length float :overlay-at (-> data 2)) + (h float :overlay-at (-> data 1)) + (l float :overlay-at (-> data 2)) + ) + ) + +;; definition for method 3 of type ellipsoid +;; INFO: Used lq/sq +(defmethod inspect ((this ellipsoid)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ellipsoid) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tz: ~f~%" (-> this z)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Theight: ~f~%" (-> this y)) + (format #t "~1Twidth: ~f~%" (-> this x)) + (format #t "~1Tlength: ~f~%" (-> this z)) + (format #t "~1Th: ~f~%" (-> this y)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tl: ~f~%" (-> this z)) + (label cfg-4) + this + ) + +;; definition for function point-in-ellipsoid? +(defun point-in-ellipsoid? ((arg0 ellipsoid) (arg1 vector)) + (let ((v1-1 (vector*! (new 'stack-no-clear 'vector) arg1 arg1))) + (+ (/ (-> v1-1 x) (square (-> arg0 w))) + (/ (-> v1-1 y) (square (-> arg0 y))) + (/ (-> v1-1 z) (square (-> arg0 z))) + ) + ) + ) + +;; definition for function ellipsoid-random-point-on! +(defun ellipsoid-random-point-on! ((arg0 ellipsoid) (arg1 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (let* ((s2-0 sincos-rad!) + (s1-0 s5-0) + (f30-0 -3.1415925) + (f28-0 6.283185) + (v1-3 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-4 (the-as number (logior #x3f800000 v1-3))) + ) + (s2-0 s1-0 (+ f30-0 (* f28-0 (+ -1.0 (the-as float v1-4))))) + ) + (let* ((s2-1 sincos-rad!) + (s1-1 s4-0) + (f30-1 -1.5707963) + (f28-1 3.1415925) + (v1-9 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-10 (the-as number (logior #x3f800000 v1-9))) + ) + (s2-1 s1-1 (+ f30-1 (* f28-1 (+ -1.0 (the-as float v1-10))))) + ) + (set! (-> arg1 x) (* (-> arg0 w) (-> s4-0 y) (-> s5-0 x))) + (set! (-> arg1 y) (* (-> arg0 y) (-> s4-0 x))) + (set! (-> arg1 z) (* (-> arg0 z) (-> s4-0 y) (-> s5-0 y))) + ) + arg1 + ) + +;; definition for function ellipsoid-normal-at! +(defun ellipsoid-normal-at! ((arg0 ellipsoid) (arg1 vector) (arg2 vector)) + (let ((v0-0 arg1)) + (set! (-> v0-0 x) (/ (-> arg2 x) (square (-> arg0 w)))) + (set! (-> v0-0 y) (/ (-> arg2 y) (square (-> arg0 y)))) + (set! (-> v0-0 z) (/ (-> arg2 z) (square (-> arg0 z)))) + (set! (-> v0-0 w) 1.0) + v0-0 + ) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/background/background-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/background/background-h_REF.gc new file mode 100644 index 0000000000..3567c12d43 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/background/background-h_REF.gc @@ -0,0 +1,76 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type background-work +(deftype background-work (basic) + "List of all things for the background renderer to draw." + ((tfrag-tree-count int32) + (tfrag-trees drawable-tree-tfrag 19) + (tfrag-levels level 19) + (tfrag-trans-tree-count int32) + (tfrag-trans-trees drawable-tree-tfrag-trans 19) + (tfrag-trans-levels level 19) + (tfrag-water-tree-count int32) + (tfrag-water-trees drawable-tree-tfrag-water 19) + (tfrag-water-levels level 19) + (tfrag-shared-tree-count int32) + (tfrag-shared-trees drawable-tree-tfrag-shared 19) + (tfrag-shared-levels level 19) + (tfrag-trans-shared-tree-count int32) + (tfrag-trans-shared-trees drawable-tree-tfrag-trans-shared 19) + (tfrag-trans-shared-levels level 19) + (tfrag-water-shared-tree-count int32) + (tfrag-water-shared-trees drawable-tree-tfrag-water-shared 19) + (tfrag-water-shared-levels level 19) + (shrub-tree-count int32) + (shrub-trees drawable-tree-instance-shrub 19) + (shrub-levels level 19) + (tie-tree-count int32) + (tie-trees drawable-tree-instance-tie 19) + (tie-levels level 19) + (wait-to-vu0 uint32) + ) + ) + +;; definition for method 3 of type background-work +(defmethod inspect ((this background-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttfrag-tree-count: ~D~%" (-> this tfrag-tree-count)) + (format #t "~1Ttfrag-trees[19] @ #x~X~%" (-> this tfrag-trees)) + (format #t "~1Ttfrag-levels[19] @ #x~X~%" (-> this tfrag-levels)) + (format #t "~1Ttfrag-trans-tree-count: ~D~%" (-> this tfrag-trans-tree-count)) + (format #t "~1Ttfrag-trans-trees[19] @ #x~X~%" (-> this tfrag-trans-trees)) + (format #t "~1Ttfrag-trans-levels[19] @ #x~X~%" (-> this tfrag-trans-levels)) + (format #t "~1Ttfrag-water-tree-count: ~D~%" (-> this tfrag-water-tree-count)) + (format #t "~1Ttfrag-water-trees[19] @ #x~X~%" (-> this tfrag-water-trees)) + (format #t "~1Ttfrag-water-levels[19] @ #x~X~%" (-> this tfrag-water-levels)) + (format #t "~1Ttfrag-shared-tree-count: ~D~%" (-> this tfrag-shared-tree-count)) + (format #t "~1Ttfrag-shared-trees[19] @ #x~X~%" (-> this tfrag-shared-trees)) + (format #t "~1Ttfrag-shared-levels[19] @ #x~X~%" (-> this tfrag-shared-levels)) + (format #t "~1Ttfrag-trans-shared-tree-count: ~D~%" (-> this tfrag-trans-shared-tree-count)) + (format #t "~1Ttfrag-trans-shared-trees[19] @ #x~X~%" (-> this tfrag-trans-shared-trees)) + (format #t "~1Ttfrag-trans-shared-levels[19] @ #x~X~%" (-> this tfrag-trans-shared-levels)) + (format #t "~1Ttfrag-water-shared-tree-count: ~D~%" (-> this tfrag-water-shared-tree-count)) + (format #t "~1Ttfrag-water-shared-trees[19] @ #x~X~%" (-> this tfrag-water-shared-trees)) + (format #t "~1Ttfrag-water-shared-levels[19] @ #x~X~%" (-> this tfrag-water-shared-levels)) + (format #t "~1Tshrub-tree-count: ~D~%" (-> this shrub-tree-count)) + (format #t "~1Tshrub-trees[19] @ #x~X~%" (-> this shrub-trees)) + (format #t "~1Tshrub-levels[19] @ #x~X~%" (-> this shrub-levels)) + (format #t "~1Ttie-tree-count: ~D~%" (-> this tie-tree-count)) + (format #t "~1Ttie-trees[19] @ #x~X~%" (-> this tie-trees)) + (format #t "~1Ttie-levels[19] @ #x~X~%" (-> this tie-levels)) + (format #t "~1Twait-to-vu0: ~D~%" (-> this wait-to-vu0)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/background/prototype-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/background/prototype-h_REF.gc new file mode 100644 index 0000000000..93c42755ff --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/background/prototype-h_REF.gc @@ -0,0 +1,478 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type prototype-bucket +(deftype prototype-bucket (basic) + ((name string) + (flags prototype-flags) + (texture-masks-index uint16) + (in-level uint16) + (utextures uint16) + (geometry drawable 4) + (dists vector :inline) + (rdists vector :inline) + (near-plane meters :overlay-at (-> dists data 0)) + (near-stiff meters :overlay-at (-> dists data 1)) + (mid-plane meters :overlay-at (-> dists data 2)) + (far-plane meters :overlay-at (-> dists data 3)) + (rlength-near float :overlay-at (-> rdists data 0)) + (rlength-stiff float :overlay-at (-> rdists data 1)) + (rlength-mid float :overlay-at (-> rdists data 2)) + (stiffness float :overlay-at (-> rdists data 3)) + ) + ) + +;; definition for method 3 of type prototype-bucket +(defmethod inspect ((this prototype-bucket)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Ttexture-masks-index: ~D~%" (-> this texture-masks-index)) + (format #t "~1Tin-level: ~D~%" (-> this in-level)) + (format #t "~1Tutextures: ~D~%" (-> this utextures)) + (format #t "~1Twide-level-index: ~D~%" (-> this utextures)) + (format #t "~1Tgeometry[4] @ #x~X~%" (-> this geometry)) + (format #t "~1Tdists: #~%" (-> this dists)) + (format #t "~1Trdists: #~%" (-> this rdists)) + (format #t "~1Tnear-plane: (meters ~m)~%" (-> this dists x)) + (format #t "~1Tnear-stiff: (meters ~m)~%" (-> this dists y)) + (format #t "~1Tmid-plane: (meters ~m)~%" (-> this dists z)) + (format #t "~1Tfar-plane: (meters ~m)~%" (-> this dists w)) + (format #t "~1Trlength-near: ~f~%" (-> this rdists x)) + (format #t "~1Trlength-stiff: ~f~%" (-> this rdists y)) + (format #t "~1Trlength-mid: ~f~%" (-> this rdists z)) + (format #t "~1Tstiffness: ~f~%" (-> this rdists w)) + (label cfg-4) + this + ) + +;; definition of type prototype-bucket-shrub +(deftype prototype-bucket-shrub (prototype-bucket) + ((next uint32 4) + (count uint16 4) + (count-quad uint128 :overlay-at (-> count 0)) + (mod-count uint16 4 :offset 88) + (last dma-packet 4) + (next-clear uint128 :overlay-at (-> next 0)) + (count-clear uint64 :overlay-at (-> count 0)) + (last-clear uint128 :overlay-at (-> last 0)) + ) + ) + +;; definition for method 3 of type prototype-bucket-shrub +;; INFO: Used lq/sq +(defmethod inspect ((this prototype-bucket-shrub)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Ttexture-masks-index: ~D~%" (-> this texture-masks-index)) + (format #t "~1Tin-level: ~D~%" (-> this in-level)) + (format #t "~1Tutextures: ~D~%" (-> this utextures)) + (format #t "~1Twide-level-index: ~D~%" (-> this utextures)) + (format #t "~1Tgeometry[4] @ #x~X~%" (-> this geometry)) + (format #t "~1Tdists: #~%" (-> this dists)) + (format #t "~1Trdists: #~%" (-> this rdists)) + (format #t "~1Tnear-plane: (meters ~m)~%" (-> this dists x)) + (format #t "~1Tnear-stiff: (meters ~m)~%" (-> this dists y)) + (format #t "~1Tmid-plane: (meters ~m)~%" (-> this dists z)) + (format #t "~1Tfar-plane: (meters ~m)~%" (-> this dists w)) + (format #t "~1Trlength-near: ~f~%" (-> this rdists x)) + (format #t "~1Trlength-stiff: ~f~%" (-> this rdists y)) + (format #t "~1Trlength-mid: ~f~%" (-> this rdists z)) + (format #t "~1Tstiffness: ~f~%" (-> this rdists w)) + (format #t "~1Tnext[4] @ #x~X~%" (-> this next)) + (format #t "~1Tcount[4] @ #x~X~%" (-> this count)) + (format #t "~1Tmod-count[4] @ #x~X~%" (-> this mod-count)) + (format #t "~1Tlast[4] @ #x~X~%" (-> this last)) + (format #t "~1Tnext-clear: ~D~%" (-> this next-clear)) + (format #t "~1Tcount-clear: ~D~%" (-> this count-clear)) + (format #t "~1Tlast-clear: ~D~%" (-> this last-clear)) + (label cfg-4) + this + ) + +;; definition of type prototype-inline-array-shrub +(deftype prototype-inline-array-shrub (drawable) + ((length int16 :offset 6) + (data prototype-bucket-shrub 1 :inline :offset 32) + (pad uint32) + ) + ) + +;; definition for method 3 of type prototype-inline-array-shrub +(defmethod inspect ((this prototype-inline-array-shrub)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tdata[1] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type prototype-array-shrub-info +(deftype prototype-array-shrub-info (basic) + ((prototype-inline-array-shrub prototype-inline-array-shrub) + (wind-vectors uint32) + (wind-count int32) + ) + ) + +;; definition for method 3 of type prototype-array-shrub-info +(defmethod inspect ((this prototype-array-shrub-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tprototype-inline-array-shrub: ~A~%" (-> this prototype-inline-array-shrub)) + (format #t "~1Twind-vectors: #x~X~%" (-> this wind-vectors)) + (format #t "~1Twind-count: ~D~%" (-> this wind-count)) + (label cfg-4) + this + ) + +;; definition of type prototype-bucket-tie +(deftype prototype-bucket-tie (prototype-bucket) + ((next uint32 12) + (count uint16 12) + (frag-count uint8 4) + (index-start uint8 4) + (base-qw uint16 4) + (tie-rvanish float) + (tie-vanish-far float) + (envmap-rfade float) + (envmap-fade-far float) + (envmap-shader adgif-shader) + (tint-color uint32) + (collide-hash-fragment-array collide-hash-fragment-array) + (tie-colors time-of-day-palette) + (data uint32 :dynamic) + (color-index-qwc uint32 :dynamic) + (scissor-frag-count uint8 :overlay-at (-> frag-count 0)) + (near-frag-count uint8 :overlay-at (-> frag-count 1)) + (mid-frag-count uint8 :overlay-at (-> frag-count 2)) + (far-frag-count uint8 :overlay-at (-> frag-count 3)) + (scissor-index-start uint8 :overlay-at (-> index-start 0)) + (near-index-start uint8 :overlay-at (-> index-start 1)) + (mid-index-start uint8 :overlay-at (-> index-start 2)) + (far-index-start uint8 :overlay-at (-> index-start 3)) + (scissor-base-qw uint16 :overlay-at (-> base-qw 0)) + (near-base-qw uint16 :overlay-at (-> base-qw 1)) + (mid-base-qw uint16 :overlay-at (-> base-qw 2)) + (far-base-qw uint16 :overlay-at (-> base-qw 3)) + (tie-next uint32 4 :overlay-at (-> next 0)) + (tie-scissor-next uint32 :overlay-at (-> next 0)) + (tie-near-next uint32 :overlay-at (-> next 1)) + (tie-mid-next uint32 :overlay-at (-> next 2)) + (tie-far-next uint32 :overlay-at (-> next 3)) + (trans-next uint32 4 :overlay-at (-> next 0)) + (trans-scissor-next uint32 4 :overlay-at (-> next 0)) + (trans-near-next uint32 :overlay-at (-> next 1)) + (trans-mid-next uint32 :overlay-at (-> next 2)) + (trans-far-next uint32 :overlay-at (-> next 3)) + (water-next uint32 4 :overlay-at (-> next 0)) + (water-scissor-next uint32 4 :overlay-at (-> next 0)) + (water-near-next uint32 :overlay-at (-> next 1)) + (water-mid-next uint32 :overlay-at (-> next 2)) + (water-far-next uint32 :overlay-at (-> next 3)) + (envmap-next uint32 4 :overlay-at (-> next 4)) + (envmap-scissor-next uint32 4 :overlay-at (-> next 4)) + (envmap-near-next uint32 :overlay-at (-> next 5)) + (envmap-mid-next uint32 :overlay-at (-> next 6)) + (envmap-far-next uint32 :overlay-at (-> next 7)) + (generic-next uint32 3 :overlay-at (-> next 8)) + (generic-near-next uint32 :overlay-at (-> next 8)) + (generic-mid-next uint32 :overlay-at (-> next 9)) + (generic-far-next uint32 :overlay-at (-> next 10)) + (vanish-next uint32 :overlay-at (-> next 11)) + (tie-count uint16 4 :overlay-at (-> count 0)) + (tie-scissor-count uint16 :overlay-at (-> count 0)) + (tie-near-count uint16 :overlay-at (-> count 1)) + (tie-mid-count uint16 :overlay-at (-> count 2)) + (tie-far-count uint16 :overlay-at (-> count 3)) + (trans-count uint16 4 :overlay-at (-> count 0)) + (trans-scissor-count uint16 :overlay-at (-> count 0)) + (trans-near-count uint16 :overlay-at (-> count 1)) + (trans-mid-count uint16 :overlay-at (-> count 2)) + (trans-far-count uint16 :overlay-at (-> count 3)) + (water-count uint16 4 :overlay-at (-> count 0)) + (water-scissor-count uint16 :overlay-at (-> count 0)) + (water-near-count uint16 :overlay-at (-> count 1)) + (water-mid-count uint16 :overlay-at (-> count 2)) + (water-far-count uint16 :overlay-at (-> count 3)) + (envmap-count uint16 4 :overlay-at (-> count 4)) + (envmap-scissor-count uint16 :overlay-at (-> count 4)) + (envmap-near-count uint16 :overlay-at (-> count 5)) + (envmap-mid-count uint16 :overlay-at (-> count 6)) + (envmap-far-count uint16 :overlay-at (-> count 7)) + (generic-count uint16 3 :overlay-at (-> count 8)) + (generic-near-count uint16 :overlay-at (-> count 8)) + (generic-mid-count uint16 :overlay-at (-> count 9)) + (generic-far-count uint16 :overlay-at (-> count 10)) + (vanish-count uint16 :overlay-at (-> count 11)) + (next-clear uint128 3 :overlay-at (-> next 0)) + (count-clear uint64 3 :overlay-at (-> count 0)) + (tie-geom prototype-tie 4 :overlay-at (-> geometry 0)) + ) + ) + +;; definition for method 3 of type prototype-bucket-tie +(defmethod inspect ((this prototype-bucket-tie)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Ttexture-masks-index: ~D~%" (-> this texture-masks-index)) + (format #t "~1Tin-level: ~D~%" (-> this in-level)) + (format #t "~1Tutextures: ~D~%" (-> this utextures)) + (format #t "~1Twide-level-index: ~D~%" (-> this utextures)) + (format #t "~1Tgeometry[4] @ #x~X~%" (-> this tie-geom)) + (format #t "~1Tdists: #~%" (-> this dists)) + (format #t "~1Trdists: #~%" (-> this rdists)) + (format #t "~1Tnear-plane: (meters ~m)~%" (-> this dists x)) + (format #t "~1Tnear-stiff: (meters ~m)~%" (-> this dists y)) + (format #t "~1Tmid-plane: (meters ~m)~%" (-> this dists z)) + (format #t "~1Tfar-plane: (meters ~m)~%" (-> this dists w)) + (format #t "~1Trlength-near: ~f~%" (-> this rdists x)) + (format #t "~1Trlength-stiff: ~f~%" (-> this rdists y)) + (format #t "~1Trlength-mid: ~f~%" (-> this rdists z)) + (format #t "~1Tstiffness: ~f~%" (-> this rdists w)) + (format #t "~1Tnext[12] @ #x~X~%" (-> this next)) + (format #t "~1Tcount[12] @ #x~X~%" (-> this count)) + (format #t "~1Tfrag-count[4] @ #x~X~%" (-> this frag-count)) + (format #t "~1Tindex-start[4] @ #x~X~%" (-> this index-start)) + (format #t "~1Tbase-qw[4] @ #x~X~%" (-> this base-qw)) + (format #t "~1Ttie-rvanish: ~f~%" (-> this tie-rvanish)) + (format #t "~1Ttie-vanish-far: ~f~%" (-> this tie-vanish-far)) + (format #t "~1Tenvmap-rfade: ~f~%" (-> this envmap-rfade)) + (format #t "~1Tenvmap-fade-far: ~f~%" (-> this envmap-fade-far)) + (format #t "~1Tenvmap-shader: #~%" (-> this envmap-shader)) + (format #t "~1Ttint-color: ~D~%" (-> this tint-color)) + (format #t "~1Tcollide-hash-fragment-array: ~A~%" (-> this collide-hash-fragment-array)) + (format #t "~1Ttie-colors: ~A~%" (-> this tie-colors)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (format #t "~1Tcolor-index-qwc[0] @ #x~X~%" (-> this data)) + (format #t "~1Tscissor-frag-count: ~D~%" (-> this scissor-frag-count)) + (format #t "~1Tnear-frag-count: ~D~%" (-> this near-frag-count)) + (format #t "~1Tmid-frag-count: ~D~%" (-> this mid-frag-count)) + (format #t "~1Tfar-frag-count: ~D~%" (-> this far-frag-count)) + (format #t "~1Tscissor-index-start: ~D~%" (-> this scissor-index-start)) + (format #t "~1Tnear-index-start: ~D~%" (-> this near-index-start)) + (format #t "~1Tmid-index-start: ~D~%" (-> this mid-index-start)) + (format #t "~1Tfar-index-start: ~D~%" (-> this far-index-start)) + (format #t "~1Tscissor-base-qw: ~D~%" (-> this scissor-base-qw)) + (format #t "~1Tnear-base-qw: ~D~%" (-> this near-base-qw)) + (format #t "~1Tmid-base-qw: ~D~%" (-> this mid-base-qw)) + (format #t "~1Tfar-base-qw: ~D~%" (-> this far-base-qw)) + (format #t "~1Ttie-next[4] @ #x~X~%" (-> this next)) + (format #t "~1Ttie-scissor-next: #x~X~%" (-> this tie-scissor-next)) + (format #t "~1Ttie-near-next: #x~X~%" (-> this tie-near-next)) + (format #t "~1Ttie-mid-next: #x~X~%" (-> this tie-mid-next)) + (format #t "~1Ttie-far-next: #x~X~%" (-> this tie-far-next)) + (format #t "~1Ttrans-next[4] @ #x~X~%" (-> this next)) + (format #t "~1Ttrans-scissor-next[4] @ #x~X~%" (-> this next)) + (format #t "~1Ttrans-near-next: #x~X~%" (-> this tie-near-next)) + (format #t "~1Ttrans-mid-next: #x~X~%" (-> this tie-mid-next)) + (format #t "~1Ttrans-far-next: #x~X~%" (-> this tie-far-next)) + (format #t "~1Twater-next[4] @ #x~X~%" (-> this next)) + (format #t "~1Twater-scissor-next[4] @ #x~X~%" (-> this next)) + (format #t "~1Twater-near-next: #x~X~%" (-> this tie-near-next)) + (format #t "~1Twater-mid-next: #x~X~%" (-> this tie-mid-next)) + (format #t "~1Twater-far-next: #x~X~%" (-> this tie-far-next)) + (format #t "~1Tenvmap-next[4] @ #x~X~%" (-> this envmap-next)) + (format #t "~1Tenvmap-scissor-next[4] @ #x~X~%" (-> this envmap-next)) + (format #t "~1Tenvmap-near-next: #x~X~%" (-> this envmap-near-next)) + (format #t "~1Tenvmap-mid-next: #x~X~%" (-> this envmap-mid-next)) + (format #t "~1Tenvmap-far-next: #x~X~%" (-> this envmap-far-next)) + (format #t "~1Tgeneric-next[3] @ #x~X~%" (-> this generic-next)) + (format #t "~1Tgeneric-near-next: #x~X~%" (-> this generic-near-next)) + (format #t "~1Tgeneric-mid-next: #x~X~%" (-> this generic-mid-next)) + (format #t "~1Tgeneric-far-next: #x~X~%" (-> this generic-far-next)) + (format #t "~1Tvanish-next: #x~X~%" (-> this vanish-next)) + (format #t "~1Ttie-count[4] @ #x~X~%" (-> this count)) + (format #t "~1Ttie-scissor-count: ~D~%" (-> this tie-scissor-count)) + (format #t "~1Ttie-near-count: ~D~%" (-> this tie-near-count)) + (format #t "~1Ttie-mid-count: ~D~%" (-> this tie-mid-count)) + (format #t "~1Ttie-far-count: ~D~%" (-> this tie-far-count)) + (format #t "~1Ttrans-count[4] @ #x~X~%" (-> this count)) + (format #t "~1Ttrans-scissor-count: ~D~%" (-> this tie-scissor-count)) + (format #t "~1Ttrans-near-count: ~D~%" (-> this tie-near-count)) + (format #t "~1Ttrans-mid-count: ~D~%" (-> this tie-mid-count)) + (format #t "~1Ttrans-far-count: ~D~%" (-> this tie-far-count)) + (format #t "~1Twater-count[4] @ #x~X~%" (-> this count)) + (format #t "~1Twater-scissor-count: ~D~%" (-> this tie-scissor-count)) + (format #t "~1Twater-near-count: ~D~%" (-> this tie-near-count)) + (format #t "~1Twater-mid-count: ~D~%" (-> this tie-mid-count)) + (format #t "~1Twater-far-count: ~D~%" (-> this tie-far-count)) + (format #t "~1Tenvmap-count[4] @ #x~X~%" (-> this envmap-count)) + (format #t "~1Tenvmap-scissor-count: ~D~%" (-> this envmap-scissor-count)) + (format #t "~1Tenvmap-near-count: ~D~%" (-> this envmap-near-count)) + (format #t "~1Tenvmap-mid-count: ~D~%" (-> this envmap-mid-count)) + (format #t "~1Tenvmap-far-count: ~D~%" (-> this envmap-far-count)) + (format #t "~1Tgeneric-count[3] @ #x~X~%" (-> this generic-count)) + (format #t "~1Tgeneric-near-count: ~D~%" (-> this generic-near-count)) + (format #t "~1Tgeneric-mid-count: ~D~%" (-> this generic-mid-count)) + (format #t "~1Tgeneric-far-count: ~D~%" (-> this generic-far-count)) + (format #t "~1Tvanish-count: ~D~%" (-> this vanish-count)) + (format #t "~1Tnext-clear[3] @ #x~X~%" (-> this next)) + (format #t "~1Tcount-clear[3] @ #x~X~%" (-> this count)) + (label cfg-4) + this + ) + +;; definition of type prototype-array-tie +(deftype prototype-array-tie (array) + ((array-data prototype-bucket-tie :dynamic :offset 16) + ) + (:methods + (prototype-array-tie-method-9 () none) + ) + ) + +;; definition for method 3 of type prototype-array-tie +(defmethod inspect ((this prototype-array-tie)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttype: ~A~%" (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tcontent-type: ~A~%" (-> this content-type)) + (label cfg-4) + this + ) + +;; definition of type proxy-prototype-array-tie +(deftype proxy-prototype-array-tie (basic) + ((prototype-array-tie prototype-array-tie) + (wind-vectors uint32) + (wind-count uint16) + (prototype-max-qwc uint16) + ) + ) + +;; definition for method 3 of type proxy-prototype-array-tie +(defmethod inspect ((this proxy-prototype-array-tie)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tprototype-array-tie: ~A~%" (-> this prototype-array-tie)) + (format #t "~1Twind-vectors: #x~X~%" (-> this wind-vectors)) + (format #t "~1Twind-count: ~D~%" (-> this wind-count)) + (format #t "~1Tprototype-max-qwc: ~D~%" (-> this prototype-max-qwc)) + (label cfg-4) + this + ) + +;; definition of type prototype-node +(deftype prototype-node (structure) + ((prototype basic) + (level basic) + (id int16) + (next-prototype int16) + (next-child int16) + (prev-child int16) + ) + ) + +;; definition for method 3 of type prototype-node +(defmethod inspect ((this prototype-node)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'prototype-node) + (format #t "~1Tprototype: ~A~%" (-> this prototype)) + (format #t "~1Tlevel: ~A~%" (-> this level)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tnext-prototype: ~D~%" (-> this next-prototype)) + (format #t "~1Tnext-child: ~D~%" (-> this next-child)) + (format #t "~1Tprev-child: ~D~%" (-> this prev-child)) + (label cfg-4) + this + ) + +;; definition of type prototype-node-group +(deftype prototype-node-group (basic) + ((next-prototype int16) + (next-free int16) + (next-child-prototype int16 19) + (data prototype-node 512 :inline) + ) + (:methods + (prototype-node-group-method-9 () none) + (prototype-node-group-method-10 () none) + (prototype-node-group-method-11 () none) + (prototype-node-group-method-12 () none) + (prototype-node-group-method-13 () none) + (prototype-node-group-method-14 () none) + ) + ) + +;; definition for method 3 of type prototype-node-group +(defmethod inspect ((this prototype-node-group)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tnext-prototype: ~D~%" (-> this next-prototype)) + (format #t "~1Tnext-free: ~D~%" (-> this next-free)) + (format #t "~1Tnext-child-prototype[19] @ #x~X~%" (-> this next-child-prototype)) + (format #t "~1Tdata[512] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type instance +(deftype instance (drawable) + ((bucket-index uint16 :offset 6) + (origin matrix4h :inline) + (flags instance-flags :overlay-at (-> origin data 7)) + (wind-index uint16 :overlay-at (-> origin data 15)) + ) + ) + +;; definition for method 3 of type instance +(defmethod inspect ((this instance)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tbucket-index: ~D~%" (-> this bucket-index)) + (format #t "~1Torigin: #~%" (-> this origin)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Twind-index: ~D~%" (-> this wind-index)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/background/subdivide-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/background/subdivide-h_REF.gc new file mode 100644 index 0000000000..56d8d3b9e9 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/background/subdivide-h_REF.gc @@ -0,0 +1,327 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type subdivide-settings +(deftype subdivide-settings (basic) + "Input settings for distances for switching mesh level of details. +These are set by the level code and read by rendering code." + ((dist float 5) + (meters float 5) + (close float 20) + (far float 20) + ) + (:methods + (new (symbol type float float) _type_) + ) + ) + +;; definition for method 3 of type subdivide-settings +(defmethod inspect ((this subdivide-settings)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tdist[5] @ #x~X~%" (-> this dist)) + (format #t "~1Tmeters[5] @ #x~X~%" (-> this meters)) + (format #t "~1Tclose[20] @ #x~X~%" (-> this close)) + (format #t "~1Tfar[20] @ #x~X~%" (-> this far)) + (label cfg-4) + this + ) + +;; definition for method 0 of type subdivide-settings +(defmethod new subdivide-settings ((allocation symbol) (type-to-make type) (arg0 float) (arg1 float)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (dotimes (v1-2 18) + (set! (-> v0-0 close v1-2) arg0) + (set! (-> v0-0 far v1-2) arg1) + ) + v0-0 + ) + ) + +;; definition of type subdivide-dists +(deftype subdivide-dists (structure) + "Unused subdivide distances. Internally, tfrag/tie figure these out instead." + ((data uint32 32 :offset 0) + (vector vector 8 :overlay-at (-> data 0)) + (k0s uint128 4 :overlay-at (-> data 0)) + (k1s uint128 4 :overlay-at (-> data 16)) + ) + ) + +;; definition for method 3 of type subdivide-dists +(defmethod inspect ((this subdivide-dists)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'subdivide-dists) + (format #t "~1Tdata[32] @ #x~X~%" (-> this data)) + (format #t "~1Tvector[8] @ #x~X~%" (-> this data)) + (format #t "~1Tk0s[4] @ #x~X~%" (-> this data)) + (format #t "~1Tk1s[4] @ #x~X~%" (-> this k1s)) + (label cfg-4) + this + ) + +;; definition of type terrain-stats +(deftype terrain-stats (structure) + "Desptie the name `terrain-stats`, these are more general triangle stats for all renderers." + ((pris tr-stat :inline) + (tie-generic tr-stat :inline) + (tie-vanish tr-stat :inline) + (tie tr-stat :inline) + (tie-scissor tr-stat :inline) + (tie-envmap tr-stat :inline) + (tie-envmap-scissor tr-stat :inline) + (tie-trans tr-stat :inline) + (tie-scissor-trans tr-stat :inline) + (tie-envmap-trans tr-stat :inline) + (tie-envmap-scissor-trans tr-stat :inline) + (tie-water tr-stat :inline) + (tie-scissor-water tr-stat :inline) + (tie-envmap-water tr-stat :inline) + (tie-envmap-scissor-water tr-stat :inline) + (shrub-near tr-stat :inline) + (shrub tr-stat :inline) + (tfrag-scissor tr-stat :inline) + (tfrag tr-stat :inline) + (billboard tr-stat :inline) + (tfrag-trans tr-stat :inline) + (tfrag-scissor-trans tr-stat :inline) + (tfrag-water tr-stat :inline) + (tfrag-scissor-water tr-stat :inline) + (trans-pris tr-stat :inline) + (trans-shrub tr-stat :inline) + (ocean-mid tr-stat :inline) + (ocean-near tr-stat :inline) + (shadow tr-stat :inline) + (total tr-stat :inline) + ) + ) + +;; definition for method 3 of type terrain-stats +(defmethod inspect ((this terrain-stats)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'terrain-stats) + (format #t "~1Tpris: #~%" (-> this pris)) + (format #t "~1Ttie-generic: #~%" (-> this tie-generic)) + (format #t "~1Ttie-vanish: #~%" (-> this tie-vanish)) + (format #t "~1Ttie: #~%" (-> this tie)) + (format #t "~1Ttie-scissor: #~%" (-> this tie-scissor)) + (format #t "~1Ttie-envmap: #~%" (-> this tie-envmap)) + (format #t "~1Ttie-envmap-scissor: #~%" (-> this tie-envmap-scissor)) + (format #t "~1Ttie-trans: #~%" (-> this tie-trans)) + (format #t "~1Ttie-scissor-trans: #~%" (-> this tie-scissor-trans)) + (format #t "~1Ttie-envmap-trans: #~%" (-> this tie-envmap-trans)) + (format #t "~1Ttie-envmap-scissor-trans: #~%" (-> this tie-envmap-scissor-trans)) + (format #t "~1Ttie-water: #~%" (-> this tie-water)) + (format #t "~1Ttie-scissor-water: #~%" (-> this tie-scissor-water)) + (format #t "~1Ttie-envmap-water: #~%" (-> this tie-envmap-water)) + (format #t "~1Ttie-envmap-scissor-water: #~%" (-> this tie-envmap-scissor-water)) + (format #t "~1Tshrub-near: #~%" (-> this shrub-near)) + (format #t "~1Tshrub: #~%" (-> this shrub)) + (format #t "~1Ttfrag-scissor: #~%" (-> this tfrag-scissor)) + (format #t "~1Ttfrag: #~%" (-> this tfrag)) + (format #t "~1Tbillboard: #~%" (-> this billboard)) + (format #t "~1Ttfrag-trans: #~%" (-> this tfrag-trans)) + (format #t "~1Ttfrag-scissor-trans: #~%" (-> this tfrag-scissor-trans)) + (format #t "~1Ttfrag-water: #~%" (-> this tfrag-water)) + (format #t "~1Ttfrag-scissor-water: #~%" (-> this tfrag-scissor-water)) + (format #t "~1Ttrans-pris: #~%" (-> this trans-pris)) + (format #t "~1Ttrans-shrub: #~%" (-> this trans-shrub)) + (format #t "~1Tocean-mid: #~%" (-> this ocean-mid)) + (format #t "~1Tocean-near: #~%" (-> this ocean-near)) + (format #t "~1Tshadow: #~%" (-> this shadow)) + (format #t "~1Ttotal: #~%" (-> this total)) + (label cfg-4) + this + ) + +;; definition of type background-area +(deftype background-area (structure) + "Scratchpad memory layout for most background rendering +This uses the full scratchpad so it should only be used when the stack isn't on the scratchpad (rendering code). +Interestingly, dma-area went from a union of all the -dma types to a plain array of bytes in jak 3." + ((dma-area uint8 14336) + (vis-list uint8 2048) + ) + ) + +;; definition for method 3 of type background-area +(defmethod inspect ((this background-area)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'background-area) + (format #t "~1Tdma-area[14336] @ #x~X~%" (-> this dma-area)) + (format #t "~1Tvis-list[2048] @ #x~X~%" (-> this vis-list)) + (label cfg-4) + this + ) + +;; definition of type foreground-area +(deftype foreground-area (structure) + "Scratchpad memory layout for most foreground rendering." + ((generic-work generic-work :inline :offset 0) + (foreground-work foreground-work :inline :offset 0) + (joint-work joint-work :inline :offset 0) + (bone-mem bone-memory :inline :offset 0) + (shadow-work shadow-work :inline :offset 0) + ) + ) + +;; definition for method 3 of type foreground-area +(defmethod inspect ((this foreground-area)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'foreground-area) + (format #t "~1Tgeneric-work: #~%" (-> this generic-work)) + (format #t "~1Tforeground-work: #~%" (-> this generic-work)) + (format #t "~1Tjoint-work: #~%" (-> this generic-work)) + (format #t "~1Tbone-mem: #~%" (-> this generic-work)) + (format #t "~1Tshadow-work: #~%" (-> this generic-work)) + (label cfg-4) + this + ) + +;; definition of type region-prim-area +(deftype region-prim-area (structure) + "Scratchpad memory layout for regions." + ((region-prim-list region-prim-list :inline) + (pos vector :inline) + (exit-pos vector :inline) + (ray vector :inline) + (exit-ray vector :inline) + (region-enter-count int32) + (region-enter-list region 320) + (region-enter-prim-list drawable-region-sphere 320) + (region-exit-count int32) + (region-exit-list region 320) + (region-exit-prim-list drawable-region-sphere 320) + (region-inside-count int32) + (region-inside-list region 320) + (region-inside-prim-list drawable-region-sphere 320) + (region-start-count int32) + (region-start-list region 320) + (region-start-prim-list drawable-region-sphere 320) + ) + (:methods + (track-entered-region! (_type_ drawable-region-sphere) int) + (track-exited-region! (_type_ drawable-region-sphere) int) + (track-inside-region! (_type_ drawable-region-sphere) int) + (track-start-region! (_type_ drawable-region-sphere) int) + ) + ) + +;; definition for method 3 of type region-prim-area +(defmethod inspect ((this region-prim-area)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'region-prim-area) + (format #t "~1Tregion-prim-list: #~%" (-> this region-prim-list)) + (format #t "~1Tpos: ~`vector`P~%" (-> this pos)) + (format #t "~1Tray: ~`vector`P~%" (-> this ray)) + (format #t "~1Tregion-enter-count: ~D~%" (-> this region-enter-count)) + (format #t "~1Tregion-enter-list[320] @ #x~X~%" (-> this region-enter-list)) + (format #t "~1Tregion-enter-prim-list[320] @ #x~X~%" (-> this region-enter-prim-list)) + (format #t "~1Tregion-exit-count: ~D~%" (-> this region-exit-count)) + (format #t "~1Tregion-exit-list[320] @ #x~X~%" (-> this region-exit-list)) + (format #t "~1Tregion-exit-prim-list[320] @ #x~X~%" (-> this region-exit-prim-list)) + (format #t "~1Tregion-inside-count: ~D~%" (-> this region-inside-count)) + (format #t "~1Tregion-inside-list[320] @ #x~X~%" (-> this region-inside-list)) + (format #t "~1Tregion-inside-prim-list[320] @ #x~X~%" (-> this region-inside-prim-list)) + (format #t "~1Tregion-start-count: ~D~%" (-> this region-start-count)) + (format #t "~1Tregion-start-list[320] @ #x~X~%" (-> this region-start-list)) + (format #t "~1Tregion-start-prim-list[320] @ #x~X~%" (-> this region-start-prim-list)) + (label cfg-4) + this + ) + +;; definition of type sprite-area +(deftype sprite-area (structure) + "Scratchpad memory layout for sprites." + ((clock-data vector 22 :inline) + (buffer uint8 :dynamic) + ) + ) + +;; definition for method 3 of type sprite-area +(defmethod inspect ((this sprite-area)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sprite-area) + (format #t "~1Tclock-data[22] @ #x~X~%" (-> this clock-data)) + (format #t "~1Tbuffer[0] @ #x~X~%" (-> this buffer)) + (label cfg-4) + this + ) + +;; definition of type work-area +(deftype work-area (structure) + "All scratchpad memory layouts." + ((background background-area :inline :offset 0) + (foreground foreground-area :inline :offset 0) + (region-prim region-prim-area :inline :offset 0) + (sprite sprite-area :inline :offset 0) + ) + ) + +;; definition for method 3 of type work-area +(defmethod inspect ((this work-area)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'work-area) + (format #t "~1Tbackground: #~%" (-> this background)) + (format #t "~1Tforeground: #~%" (-> this background)) + (format #t "~1Tregion-prim: #~%" (-> this background)) + (format #t "~1Tsprite: #~%" (-> this background)) + (label cfg-4) + this + ) + +;; definition of type terrain-context +(deftype terrain-context (structure) + "Useless wrapper around work-area. (this added some stuff in jak 1)" + ((work work-area :inline) + ) + ) + +;; definition for method 3 of type terrain-context +(defmethod inspect ((this terrain-context)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'terrain-context) + (format #t "~1Twork: #~%" (-> this work)) + (label cfg-4) + this + ) + +;; definition for symbol *terrain-stats*, type terrain-stats +(define *terrain-stats* (new 'global 'terrain-stats)) + +;; definition for symbol *collide-stats*, type collide-stats +(define *collide-stats* (new 'global 'collide-stats)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/background/tfrag/tfrag-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/background/tfrag/tfrag-h_REF.gc new file mode 100644 index 0000000000..2c8a32c813 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/background/tfrag/tfrag-h_REF.gc @@ -0,0 +1,474 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type tfragment-stats +(deftype tfragment-stats (structure) + "Triangle and vertex stats for a single tfragment." + ((num-tris uint16 4) + (num-dverts uint16 4) + ) + ) + +;; definition for method 3 of type tfragment-stats +(defmethod inspect ((this tfragment-stats)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tfragment-stats) + (format #t "~1Tnum-tris[4] @ #x~X~%" (-> this num-tris)) + (format #t "~1Tnum-dverts[4] @ #x~X~%" (-> this num-dverts)) + (label cfg-4) + this + ) + +;; definition of type tfragment-debug-data +(deftype tfragment-debug-data (structure) + "Optional debug information (stats, lines) for a tfragment." + ((stats tfragment-stats :inline) + (debug-lines (array vector-array)) + ) + ) + +;; definition for method 3 of type tfragment-debug-data +(defmethod inspect ((this tfragment-debug-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tfragment-debug-data) + (format #t "~1Tstats: #~%" (-> this stats)) + (format #t "~1Tdebug-lines: ~A~%" (-> this debug-lines)) + (label cfg-4) + this + ) + +;; definition of type generic-tfragment +(deftype generic-tfragment (structure) + "Unused. Could have been a way to render tfrag's through generic." + ((dummy int32) + ) + ) + +;; definition for method 3 of type generic-tfragment +(defmethod inspect ((this generic-tfragment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-tfragment) + (format #t "~1Tdummy: ~D~%" (-> this dummy)) + (label cfg-4) + this + ) + +;; definition of type tfragment +(deftype tfragment (drawable) + "A tfrag mesh fragment. This is just references to DMA data, plus some metadata." + ((color-index uint16 :offset 6) + (debug-data tfragment-debug-data :offset 8) + (color-indices uint32 :offset 12) + (colors uint32 :overlay-at color-indices) + (dma-chain uint32 3 :offset 32) + (dma-common uint32 :overlay-at (-> dma-chain 0)) + (dma-level-0 uint32 :overlay-at dma-common) + (dma-base uint32 :overlay-at (-> dma-chain 1)) + (dma-level-1 uint32 :overlay-at (-> dma-chain 2)) + (dma-qwc uint8 4 :offset 44) + (dma-qwc-word uint32 :overlay-at (-> dma-qwc 0)) + (shader (inline-array adgif-shader) :offset 48) + (num-shaders uint8 :offset 52) + (num-base-colors uint8 :offset 53) + (num-level0-colors uint8 :offset 54) + (num-level1-colors uint8 :offset 55) + (color-offset uint8 :offset 56) + (color-count uint8 :offset 57) + (texture-masks-index uint16 :offset 58) + (generic generic-tfragment :offset 60) + (generic-u32 uint32 :overlay-at generic) + ) + ) + +;; definition for method 3 of type tfragment +(defmethod inspect ((this tfragment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tcolor-index: ~D~%" (-> this color-index)) + (format #t "~1Tdebug-data: #~%" (-> this debug-data)) + (format #t "~1Tcolor-indices: #x~X~%" (-> this color-indices)) + (format #t "~1Tcolors: #x~X~%" (-> this color-indices)) + (format #t "~1Tdma-chain[3] @ #x~X~%" (-> this dma-chain)) + (format #t "~1Tdma-common: #x~X~%" (-> this dma-common)) + (format #t "~1Tdma-level-0: #x~X~%" (-> this dma-common)) + (format #t "~1Tdma-base: #x~X~%" (-> this dma-base)) + (format #t "~1Tdma-level-1: #x~X~%" (-> this dma-level-1)) + (format #t "~1Tdma-qwc[4] @ #x~X~%" (-> this dma-qwc)) + (format #t "~1Tshader: #x~X~%" (-> this shader)) + (format #t "~1Tnum-shaders: ~D~%" (-> this num-shaders)) + (format #t "~1Tnum-base-colors: ~D~%" (-> this num-base-colors)) + (format #t "~1Tnum-level0-colors: ~D~%" (-> this num-level0-colors)) + (format #t "~1Tnum-level1-colors: ~D~%" (-> this num-level1-colors)) + (format #t "~1Tcolor-offset: ~D~%" (-> this color-offset)) + (format #t "~1Tcolor-count: ~D~%" (-> this color-count)) + (format #t "~1Ttexture-masks-index: ~D~%" (-> this texture-masks-index)) + (format #t "~1Tgeneric: #~%" (-> this generic)) + (label cfg-4) + this + ) + +;; definition of type drawable-inline-array-tfrag +(deftype drawable-inline-array-tfrag (drawable-inline-array) + "Array of tfragments" + ((data tfragment 1 :inline) + (pad uint32) + ) + ) + +;; definition of type drawable-inline-array-tfrag-trans +(deftype drawable-inline-array-tfrag-trans (drawable-inline-array-tfrag) + ((data2 tfragment 1 :inline) + (pad2 uint32) + ) + ) + +;; definition of type drawable-inline-array-tfrag-water +(deftype drawable-inline-array-tfrag-water (drawable-inline-array-tfrag) + ((data2 tfragment 1 :inline) + (pad2 uint32) + ) + ) + +;; definition of type drawable-tree-tfrag +(deftype drawable-tree-tfrag (drawable-tree) + "top level tfrag tree." + ((time-of-day-pal time-of-day-palette :offset 12) + (arrays drawable-inline-array :dynamic :offset 32) + ) + ) + +;; definition of type drawable-tree-tfrag-trans +(deftype drawable-tree-tfrag-trans (drawable-tree-tfrag) + () + ) + +;; definition of type drawable-tree-tfrag-water +(deftype drawable-tree-tfrag-water (drawable-tree-tfrag-trans) + () + ) + +;; definition of type drawable-tree-tfrag-shared +(deftype drawable-tree-tfrag-shared (drawable-tree-tfrag) + () + ) + +;; definition of type drawable-tree-tfrag-trans-shared +(deftype drawable-tree-tfrag-trans-shared (drawable-tree-tfrag-shared) + () + ) + +;; definition of type drawable-tree-tfrag-water-shared +(deftype drawable-tree-tfrag-water-shared (drawable-tree-tfrag-shared) + () + ) + +;; definition of type tfrag-dists +(deftype tfrag-dists (structure) + "Distances for mesh level-of-detail blending for use on VU1." + ((data uint32 16) + (vector vector 4 :overlay-at (-> data 0)) + (k0s vector 2 :overlay-at (-> data 0)) + (k1s vector 2 :overlay-at (-> data 8)) + ) + ) + +;; definition for method 3 of type tfrag-dists +(defmethod inspect ((this tfrag-dists)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tfrag-dists) + (format #t "~1Tdata[16] @ #x~X~%" (-> this data)) + (format #t "~1Tvector[4] @ #x~X~%" (-> this data)) + (format #t "~1Tk0s[2] @ #x~X~%" (-> this data)) + (format #t "~1Tk1s[2] @ #x~X~%" (-> this k1s)) + (label cfg-4) + this + ) + +;; definition of type tfrag-data +(deftype tfrag-data (structure) + "Constants for VU1 data memory for tfrag rendering." + ((data uint32 56) + (vector vector 14 :overlay-at (-> data 0)) + (fog vector :inline :overlay-at (-> data 0)) + (val vector :inline :overlay-at (-> data 4)) + (strgif gs-gif-tag :inline :overlay-at (-> data 8)) + (fangif gs-gif-tag :inline :overlay-at (-> data 12)) + (adgif gs-gif-tag :inline :overlay-at (-> data 16)) + (hvdf-offset vector :inline :overlay-at (-> data 20)) + (hmge-scale vector :inline :overlay-at (-> data 24)) + (invh-scale vector :inline :overlay-at (-> data 28)) + (ambient vector :inline :overlay-at (-> data 32)) + (guard vector :inline :overlay-at (-> data 36)) + (dists tfrag-dists :inline :overlay-at (-> data 40)) + (k0s uint128 2 :overlay-at (-> data 40)) + (k1s uint128 2 :overlay-at (-> data 48)) + ) + ) + +;; definition for method 3 of type tfrag-data +(defmethod inspect ((this tfrag-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tfrag-data) + (format #t "~1Tdata[56] @ #x~X~%" (-> this data)) + (format #t "~1Tvector[14] @ #x~X~%" (-> this data)) + (format #t "~1Tfog: #~%" (-> this data)) + (format #t "~1Tval: #~%" (-> this val)) + (format #t "~1Tstrgif: #~%" (-> this strgif)) + (format #t "~1Tfangif: #~%" (-> this fangif)) + (format #t "~1Tadgif: #~%" (-> this adgif)) + (format #t "~1Thvdf-offset: #~%" (-> this hvdf-offset)) + (format #t "~1Thmge-scale: #~%" (-> this hmge-scale)) + (format #t "~1Tinvh-scale: #~%" (-> this invh-scale)) + (format #t "~1Tambient: #~%" (-> this ambient)) + (format #t "~1Tguard: #~%" (-> this guard)) + (format #t "~1Tdists: #~%" (-> this dists)) + (format #t "~1Tk0s[2] @ #x~X~%" (-> this dists)) + (format #t "~1Tk1s[2] @ #x~X~%" (-> this dists k1s)) + (label cfg-4) + this + ) + +;; definition of type tfrag-control +(deftype tfrag-control (structure) + "VU1 'control' data containing address and counters." + ((num-base-points uint32) + (num-shared-base-points uint32) + (num-level0-points uint32) + (num-shared-level0-points uint32) + (num-level1-points uint32) + (num-shared-level1-points uint32) + (ptr-vtxdata uint32) + (ptr-base-points uint32) + (ptr-shared-base-points uint32) + (ptr-level0-points uint32) + (ptr-shared-level0-points uint32) + (ptr-level1-points uint32) + (ptr-shared-level1-points uint32) + (ptr-draw-points uint32) + (ptr-interpolated-0 uint32) + (ptr-shared-interpolated-0 uint32) + (ptr-interpolated1 uint32) + (ptr-shared-interpolated1 uint32) + (ptr-strip-data uint32) + (ptr-texture-data uint32) + ) + ) + +;; definition for method 3 of type tfrag-control +(defmethod inspect ((this tfrag-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tfrag-control) + (format #t "~1Tnum-base-points: ~D~%" (-> this num-base-points)) + (format #t "~1Tnum-shared-base-points: ~D~%" (-> this num-shared-base-points)) + (format #t "~1Tnum-level0-points: ~D~%" (-> this num-level0-points)) + (format #t "~1Tnum-shared-level0-points: ~D~%" (-> this num-shared-level0-points)) + (format #t "~1Tnum-level1-points: ~D~%" (-> this num-level1-points)) + (format #t "~1Tnum-shared-level1-points: ~D~%" (-> this num-shared-level1-points)) + (format #t "~1Tptr-vtxdata: ~D~%" (-> this ptr-vtxdata)) + (format #t "~1Tptr-base-points: ~D~%" (-> this ptr-base-points)) + (format #t "~1Tptr-shared-base-points: ~D~%" (-> this ptr-shared-base-points)) + (format #t "~1Tptr-level0-points: ~D~%" (-> this ptr-level0-points)) + (format #t "~1Tptr-shared-level0-points: ~D~%" (-> this ptr-shared-level0-points)) + (format #t "~1Tptr-level1-points: ~D~%" (-> this ptr-level1-points)) + (format #t "~1Tptr-shared-level1-points: ~D~%" (-> this ptr-shared-level1-points)) + (format #t "~1Tptr-draw-points: ~D~%" (-> this ptr-draw-points)) + (format #t "~1Tptr-interpolated-0: ~D~%" (-> this ptr-interpolated-0)) + (format #t "~1Tptr-shared-interpolated-0: ~D~%" (-> this ptr-shared-interpolated-0)) + (format #t "~1Tptr-interpolated1: ~D~%" (-> this ptr-interpolated1)) + (format #t "~1Tptr-shared-interpolated1: ~D~%" (-> this ptr-shared-interpolated1)) + (format #t "~1Tptr-strip-data: ~D~%" (-> this ptr-strip-data)) + (format #t "~1Tptr-texture-data: ~D~%" (-> this ptr-texture-data)) + (label cfg-4) + this + ) + +;; definition of type tfrag-stats +(deftype tfrag-stats (structure) + "TFRAG statistics computed on EE." + ((from int32) + (to int32) + (cnt int32) + (tris int32) + (tfaces int32) + (tfrags int32) + (dtris int32) + (base-verts int32) + (level0-verts int32) + (level1-verts int32) + (dma-cnt int32) + (dma-dta int32) + (dma-tex int32) + (strips int32) + (drawpoints int32) + (vif int32) + ) + ) + +;; definition for method 3 of type tfrag-stats +(defmethod inspect ((this tfrag-stats)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tfrag-stats) + (format #t "~1Tfrom: ~D~%" (-> this from)) + (format #t "~1Tto: ~D~%" (-> this to)) + (format #t "~1Tcnt: ~D~%" (-> this cnt)) + (format #t "~1Ttris: ~D~%" (-> this tris)) + (format #t "~1Ttfaces: ~D~%" (-> this tfaces)) + (format #t "~1Ttfrags: ~D~%" (-> this tfrags)) + (format #t "~1Tdtris: ~D~%" (-> this dtris)) + (format #t "~1Tbase-verts: ~D~%" (-> this base-verts)) + (format #t "~1Tlevel0-verts: ~D~%" (-> this level0-verts)) + (format #t "~1Tlevel1-verts: ~D~%" (-> this level1-verts)) + (format #t "~1Tdma-cnt: ~D~%" (-> this dma-cnt)) + (format #t "~1Tdma-dta: ~D~%" (-> this dma-dta)) + (format #t "~1Tdma-tex: ~D~%" (-> this dma-tex)) + (format #t "~1Tstrips: ~D~%" (-> this strips)) + (format #t "~1Tdrawpoints: ~D~%" (-> this drawpoints)) + (format #t "~1Tvif: ~D~%" (-> this vif)) + (label cfg-4) + this + ) + +;; definition of type tfrag-packet +(deftype tfrag-packet (structure) + ((tag uint128 2) + ) + ) + +;; definition for method 3 of type tfrag-packet +(defmethod inspect ((this tfrag-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tfrag-packet) + (format #t "~1Ttag[2] @ #x~X~%" (-> this tag)) + (label cfg-4) + this + ) + +;; definition of type tfrag-work +(deftype tfrag-work (structure) + "Scratch space for generating TFRAG DMA." + ((base-tmpl dma-packet :inline) + (level-0-tmpl dma-packet :inline) + (common-tmpl dma-packet :inline) + (level-1-tmpl dma-packet :inline) + (color-tmpl dma-packet :inline) + (frag-dists vector :inline) + (min-dist vector :inline) + (color-ptr vector4w :inline) + (tr-stat-tfrag tr-stat) + (tr-stat-tfrag-scissor tr-stat) + (vu1-enable-tfrag int32) + (vu1-enable-tfrag-scissor int32) + (cur-vis-bits uint32) + (end-vis-bits uint32) + (src-ptr uint32) + (last-call uint32) + (dma-buffer basic) + (test-id uint32) + (wait-from-spr uint32) + (wait-to-spr uint32) + (near-wait-from-spr uint32) + (near-wait-to-spr uint32) + (max-fragment uint16) + (min-fragment uint16) + (texture-dists uint32) + ) + ) + +;; definition for method 3 of type tfrag-work +(defmethod inspect ((this tfrag-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tfrag-work) + (format #t "~1Tbase-tmpl: #~%" (-> this base-tmpl)) + (format #t "~1Tlevel-0-tmpl: #~%" (-> this level-0-tmpl)) + (format #t "~1Tcommon-tmpl: #~%" (-> this common-tmpl)) + (format #t "~1Tlevel-1-tmpl: #~%" (-> this level-1-tmpl)) + (format #t "~1Tcolor-tmpl: #~%" (-> this color-tmpl)) + (format #t "~1Tfrag-dists: #~%" (-> this frag-dists)) + (format #t "~1Tmin-dist: #~%" (-> this min-dist)) + (format #t "~1Tcolor-ptr: #~%" (-> this color-ptr)) + (format #t "~1Ttr-stat-tfrag: #~%" (-> this tr-stat-tfrag)) + (format #t "~1Ttr-stat-tfrag-scissor: #~%" (-> this tr-stat-tfrag-scissor)) + (format #t "~1Tvu1-enable-tfrag: ~D~%" (-> this vu1-enable-tfrag)) + (format #t "~1Tvu1-enable-tfrag-scissor: ~D~%" (-> this vu1-enable-tfrag-scissor)) + (format #t "~1Tcur-vis-bits: ~D~%" (-> this cur-vis-bits)) + (format #t "~1Tend-vis-bits: ~D~%" (-> this end-vis-bits)) + (format #t "~1Tsrc-ptr: ~D~%" (-> this src-ptr)) + (format #t "~1Tlast-call: ~D~%" (-> this last-call)) + (format #t "~1Tdma-buffer: ~A~%" (-> this dma-buffer)) + (format #t "~1Ttest-id: ~D~%" (-> this test-id)) + (format #t "~1Twait-from-spr: ~D~%" (-> this wait-from-spr)) + (format #t "~1Twait-to-spr: ~D~%" (-> this wait-to-spr)) + (format #t "~1Tnear-wait-from-spr: ~D~%" (-> this near-wait-from-spr)) + (format #t "~1Tnear-wait-to-spr: ~D~%" (-> this near-wait-to-spr)) + (format #t "~1Tmax-fragment: ~D~%" (-> this max-fragment)) + (format #t "~1Tmin-fragment: ~D~%" (-> this min-fragment)) + (format #t "~1Ttexture-dists: #x~X~%" (-> this texture-dists)) + (label cfg-4) + this + ) + +;; definition of type tfrag-dma +(deftype tfrag-dma (structure) + "Memory layout for to/from scratchpad for tfrag." + ((banka tfragment 16 :inline) + (bankb tfragment 16 :inline) + (outa uint128 128) + (outb uint128 128) + (colors rgba 2047) + ) + ) + +;; definition for method 3 of type tfrag-dma +(defmethod inspect ((this tfrag-dma)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tfrag-dma) + (format #t "~1Tbanka[16] @ #x~X~%" (-> this banka)) + (format #t "~1Tbankb[16] @ #x~X~%" (-> this bankb)) + (format #t "~1Touta[128] @ #x~X~%" (-> this outa)) + (format #t "~1Toutb[128] @ #x~X~%" (-> this outb)) + (format #t "~1Tcolors[2048] @ #x~X~%" (-> this colors)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/background/tie/tie-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/background/tie/tie-h_REF.gc new file mode 100644 index 0000000000..52dc1bca4e --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/background/tie/tie-h_REF.gc @@ -0,0 +1,672 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type tie-fragment-debug +(deftype tie-fragment-debug (structure) + "Optional debug information about a tie-fragment." + ((num-tris uint16) + (num-dverts uint16) + (debug-lines (array vector-array)) + ) + ) + +;; definition for method 3 of type tie-fragment-debug +(defmethod inspect ((this tie-fragment-debug)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tie-fragment-debug) + (format #t "~1Tnum-tris: ~D~%" (-> this num-tris)) + (format #t "~1Tnum-dverts: ~D~%" (-> this num-dverts)) + (format #t "~1Tdebug-lines: ~A~%" (-> this debug-lines)) + (label cfg-4) + this + ) + +;; definition of type tie-fragment +(deftype tie-fragment (drawable) + "A mesh fragment of a TIE. This is a chunk of mesh that is rendered by VU1, stored as DMA chains." + ((gif-ref (inline-array adgif-shader) :overlay-at id) + (point-ref uint32 :offset 8) + (color-index uint16 :offset 12) + (base-colors uint8 :offset 14) + (tex-count uint16 :offset 32) + (gif-count uint16 :offset 34) + (vertex-count uint16 :offset 36) + (color-count uint16) + (dp-ref uint32) + (dp-qwc uint32) + (generic-ref uint32) + (generic-count uint16) + (normal-count uint16) + (normal-ref uint32) + (debug tie-fragment-debug) + ) + ) + +;; definition for method 3 of type tie-fragment +(defmethod inspect ((this tie-fragment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tgif-ref: #x~X~%" (-> this gif-ref)) + (format #t "~1Tpoint-ref: #x~X~%" (-> this point-ref)) + (format #t "~1Tcolor-index: ~D~%" (-> this color-index)) + (format #t "~1Tbase-colors: ~D~%" (-> this base-colors)) + (format #t "~1Ttex-count: ~D~%" (-> this tex-count)) + (format #t "~1Tgif-count: ~D~%" (-> this gif-count)) + (format #t "~1Tvertex-count: ~D~%" (-> this vertex-count)) + (format #t "~1Tcolor-count: ~D~%" (-> this color-count)) + (format #t "~1Tdp-ref: #x~X~%" (-> this dp-ref)) + (format #t "~1Tdp-qwc: ~D~%" (-> this dp-qwc)) + (format #t "~1Tgeneric-ref: #x~X~%" (-> this generic-ref)) + (format #t "~1Tgeneric-count: ~D~%" (-> this generic-count)) + (format #t "~1Tnormal-count: ~D~%" (-> this normal-count)) + (format #t "~1Tnormal-ref: #x~X~%" (-> this normal-ref)) + (format #t "~1Tdebug: #~%" (-> this debug)) + (label cfg-4) + this + ) + +;; definition of type instance-tie +(deftype instance-tie (instance) + "A TIE model instance." + ((color-indices uint32 :offset 8) + (bucket-ptr prototype-bucket-tie :offset 12) + (max-scale uint16 :overlay-at (-> origin data 3)) + (rmin-scale uint16 :overlay-at (-> origin data 11)) + ) + ) + +;; definition for method 3 of type instance-tie +(defmethod inspect ((this instance-tie)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tbucket-index: ~D~%" (-> this bucket-index)) + (format #t "~1Torigin: #~%" (-> this origin)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Twind-index: ~D~%" (-> this wind-index)) + (format #t "~1Tcolor-indices: #x~X~%" (-> this color-indices)) + (format #t "~1Tbucket-ptr: ~A~%" (-> this bucket-ptr)) + (format #t "~1Tmax-scale: ~D~%" (-> this max-scale)) + (format #t "~1Trmin-scale: ~D~%" (-> this rmin-scale)) + (label cfg-4) + this + ) + +;; definition of type drawable-inline-array-instance-tie +(deftype drawable-inline-array-instance-tie (drawable-inline-array) + "Array of tie instances stored in the level." + ((data instance-tie 1 :inline) + (pad uint32) + ) + ) + +;; definition of type drawable-tree-instance-tie +(deftype drawable-tree-instance-tie (drawable-tree) + "Top-level drawable-tree for TIEs" + ((prototypes proxy-prototype-array-tie :offset 8) + ) + ) + +;; definition for method 3 of type drawable-tree-instance-tie +(defmethod inspect ((this drawable-tree-instance-tie)) + (when (not this) + (set! this this) + (goto cfg-7) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (dotimes (s5-0 (-> this length)) + (format #t "~T [~D]~1Tdata: ~A~%" s5-0 (-> this data s5-0)) + ) + (format #t "~1Tprototypes: ~A~%" (-> this prototypes)) + (label cfg-7) + this + ) + +;; definition of type prototype-tie +(deftype prototype-tie (drawable-inline-array) + "Prototype for a TIE: just an array of fragments." + ((data tie-fragment 1 :inline) + (pad uint32) + ) + ) + +;; definition of type tie-matrix +(deftype tie-matrix (structure) + "Per-instance matrix for TIE VU1 rendering." + ((mat matrix :inline) + (morph qword :inline) + (fog qword :inline) + (envmap-flag uint32 :overlay-at (-> fog data 0)) + (guard-flag uint32 :overlay-at (-> fog data 1)) + (vertex-alpha float :overlay-at (-> fog data 2)) + (fog-value float :overlay-at (-> fog data 3)) + (fixed-alpha float :overlay-at (-> morph data 1)) + ) + ) + +;; definition for method 3 of type tie-matrix +(defmethod inspect ((this tie-matrix)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'tie-matrix) + (format #t "~1Tmat: #~%" (-> this mat)) + (format #t "~1Tmorph: #~%" (-> this morph)) + (format #t "~1Tfog: #~%" (-> this fog)) + (format #t "~1Tenvmap-flag: ~D~%" (-> this envmap-flag)) + (format #t "~1Tguard-flag: ~D~%" (-> this guard-flag)) + (format #t "~1Tvertex-alpha: ~f~%" (-> this vertex-alpha)) + (format #t "~1Tfog-value: ~f~%" (-> this fog-value)) + (format #t "~1Tfixed-alpha: ~f~%" (-> this fixed-alpha)) + (label cfg-4) + this + ) + +;; definition of type instance-tie-work +(deftype instance-tie-work (structure) + "workspace for TIE instance DMA generation" + ((wind-const vector :inline) + (hmge-d vector :inline) + (hvdf-offset vector :inline) + (wind-force vector :inline) + (constant vector :inline) + (far-morph vector :inline) + (dist-test vector :inline) + (min-dist vector :inline) + (guard-plane plane 4 :inline) + (upload-color-0 dma-packet :inline) + (upload-color-1 dma-packet :inline) + (upload-color-2 dma-packet :inline) + (upload-color-ret dma-packet :inline) + (upload-color-temp dma-packet :inline) + (generic-color-0 dma-packet :inline) + (generic-color-1 dma-packet :inline) + (generic-color-end dma-packet :inline) + (envmap-color-0 dma-packet :inline) + (envmap-color-1 dma-packet :inline) + (tie-scissor-perspective-matrix matrix :inline) + (tod-env-color vector :inline) + (morph-temp vector :inline) + (fog-temp vector :inline) + (fade-temp float) + (wind-vectors uint32) + (test-id uint32) + (test-id2 uint32) + (dma-buffer basic) + (to-spr uint32) + (from-spr uint32) + (wind-work uint32) + (cur-vis-bits uint32) + (end-vis-bits uint32) + (refl-fade-fac float) + (refl-fade-end float) + (flags uint32) + (vanish-flag uint32) + (translucent-flag uint32) + (wait-from-spr uint32) + (wait-to-spr uint32) + (use-etie symbol) + (buffer-start uint32) + (buffer-end uint32) + (tfrag-dists uint32) + (alpha-dists uint32) + (water-dists uint32) + ) + ) + +;; definition for method 3 of type instance-tie-work +(defmethod inspect ((this instance-tie-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'instance-tie-work) + (format #t "~1Twind-const: #~%" (-> this wind-const)) + (format #t "~1Thmge-d: #~%" (-> this hmge-d)) + (format #t "~1Thvdf-offset: #~%" (-> this hvdf-offset)) + (format #t "~1Twind-force: #~%" (-> this wind-force)) + (format #t "~1Tconstant: #~%" (-> this constant)) + (format #t "~1Tfar-morph: #~%" (-> this far-morph)) + (format #t "~1Tdist-test: #~%" (-> this dist-test)) + (format #t "~1Tmin-dist: #~%" (-> this min-dist)) + (format #t "~1Tguard-plane[4] @ #x~X~%" (-> this guard-plane)) + (format #t "~1Tupload-color-0: #~%" (-> this upload-color-0)) + (format #t "~1Tupload-color-1: #~%" (-> this upload-color-1)) + (format #t "~1Tupload-color-2: #~%" (-> this upload-color-2)) + (format #t "~1Tupload-color-ret: #~%" (-> this upload-color-ret)) + (format #t "~1Tupload-color-temp: #~%" (-> this upload-color-temp)) + (format #t "~1Tgeneric-color-0: #~%" (-> this generic-color-0)) + (format #t "~1Tgeneric-color-1: #~%" (-> this generic-color-1)) + (format #t "~1Tgeneric-color-end: #~%" (-> this generic-color-end)) + (format #t "~1Tenvmap-color-0: #~%" (-> this envmap-color-0)) + (format #t "~1Tenvmap-color-1: #~%" (-> this envmap-color-1)) + (format #t "~1Ttie-scissor-perspective-matrix: #~%" (-> this tie-scissor-perspective-matrix)) + (format #t "~1Ttod-env-color: #~%" (-> this tod-env-color)) + (format #t "~1Tmorph-temp: #~%" (-> this morph-temp)) + (format #t "~1Tfog-temp: #~%" (-> this fog-temp)) + (format #t "~1Tfade-temp: ~f~%" (-> this fade-temp)) + (format #t "~1Twind-vectors: #x~X~%" (-> this wind-vectors)) + (format #t "~1Ttest-id: ~D~%" (-> this test-id)) + (format #t "~1Ttest-id2: ~D~%" (-> this test-id2)) + (format #t "~1Tdma-buffer: ~A~%" (-> this dma-buffer)) + (format #t "~1Tto-spr: ~D~%" (-> this to-spr)) + (format #t "~1Tfrom-spr: ~D~%" (-> this from-spr)) + (format #t "~1Twind-work: ~D~%" (-> this wind-work)) + (format #t "~1Tcur-vis-bits: ~D~%" (-> this cur-vis-bits)) + (format #t "~1Tend-vis-bits: ~D~%" (-> this end-vis-bits)) + (format #t "~1Trefl-fade-fac: ~f~%" (-> this refl-fade-fac)) + (format #t "~1Trefl-fade-end: ~f~%" (-> this refl-fade-end)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tvanish-flag: ~D~%" (-> this vanish-flag)) + (format #t "~1Ttranslucent-flag: ~D~%" (-> this translucent-flag)) + (format #t "~1Twait-from-spr: ~D~%" (-> this wait-from-spr)) + (format #t "~1Twait-to-spr: ~D~%" (-> this wait-to-spr)) + (format #t "~1Tuse-etie: ~A~%" (-> this use-etie)) + (format #t "~1Tbuffer-start: #x~X~%" (-> this buffer-start)) + (format #t "~1Tbuffer-end: #x~X~%" (-> this buffer-end)) + (format #t "~1Ttfrag-dists: #x~X~%" (-> this tfrag-dists)) + (format #t "~1Talpha-dists: #x~X~%" (-> this alpha-dists)) + (format #t "~1Twater-dists: #x~X~%" (-> this water-dists)) + (label cfg-4) + this + ) + +;; definition of type instance-tie-dma +(deftype instance-tie-dma (structure) + "Scratchpad memory layout for TIE instance DMA generation." + ((banka instance-tie 32 :inline) + (bankb instance-tie 32 :inline) + (outa uint128 256) + (outb uint128 256) + (work instance-tie-work :dynamic) + ) + ) + +;; definition for method 3 of type instance-tie-dma +(defmethod inspect ((this instance-tie-dma)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'instance-tie-dma) + (format #t "~1Tbanka[32] @ #x~X~%" (-> this banka)) + (format #t "~1Tbankb[32] @ #x~X~%" (-> this bankb)) + (format #t "~1Touta[256] @ #x~X~%" (-> this outa)) + (format #t "~1Toutb[256] @ #x~X~%" (-> this outb)) + (format #t "~1Twork: #~%" (-> this work 0)) + (label cfg-4) + this + ) + +;; definition of type prototype-tie-work +(deftype prototype-tie-work (structure) + "workspace for TIE protype DMA generation." + ((upload-flushe dma-packet :inline) + (upload-palette dma-packet :inline) + (upload-model-0 dma-packet :inline) + (upload-model-1 dma-packet :inline) + (upload-model-2 dma-packet :inline) + (upload-model-3 dma-packet :inline) + (upload-model-near-0 dma-packet :inline) + (upload-model-near-1 dma-packet :inline) + (upload-model-near-2 dma-packet :inline) + (upload-model-near-3 dma-packet :inline) + (upload-model-near-4 dma-packet :inline) + (envmap-palette dma-packet :inline) + (envmap-shader dma-packet :inline) + (upload-envmap-0 dma-packet :inline) + (upload-envmap-1 dma-packet :inline) + (upload-envmap-2 dma-packet :inline) + (upload-envmap-3 dma-packet :inline) + (upload-envmap-4 dma-packet :inline) + (upload-envmap-scissor-4 dma-packet :inline) + (generic-palette dma-packet :inline) + (generic-model-0 dma-packet :inline) + (generic-model-1 dma-packet :inline) + (generic-model-2 dma-packet :inline) + (model-next dma-packet :inline) + (clamp uint64) + (prototype-array basic) + (wait-from-spr uint32) + (wait-to-spr uint32) + (mood mood-context) + (wide-level-index uint32) + (prototype-tie-work-todo-01 uint32) + (last uint32 16) + (next uint32 16) + (count uint16 16) + (tie-last uint32 :overlay-at (-> last 0)) + (tie-next uint32 :overlay-at (-> next 0)) + (tie-count uint16 :overlay-at (-> count 0)) + (trans-last uint32 :overlay-at (-> last 1)) + (trans-next uint32 :overlay-at (-> next 1)) + (trans-count uint16 :overlay-at (-> count 1)) + (water-last uint32 :overlay-at (-> last 2)) + (water-next uint32 :overlay-at (-> next 2)) + (water-count uint16 :overlay-at (-> count 2)) + (scissor-last uint32 :overlay-at (-> last 3)) + (scissor-next uint32 :overlay-at (-> next 3)) + (scissor-count uint16 :overlay-at (-> count 3)) + (scissor-trans-last uint32 :overlay-at (-> last 4)) + (scissor-trans-next uint32 :overlay-at (-> next 4)) + (scissor-trans-count uint16 :overlay-at (-> count 4)) + (scissor-water-last uint32 :overlay-at (-> last 5)) + (scissor-water-next uint32 :overlay-at (-> next 5)) + (scissor-water-count uint16 :overlay-at (-> count 5)) + (envmap-last uint32 :overlay-at (-> last 6)) + (envmap-next uint32 :overlay-at (-> next 6)) + (envmap-count uint16 :overlay-at (-> count 6)) + (envmap-trans-last uint32 :overlay-at (-> last 7)) + (envmap-trans-next uint32 :overlay-at (-> next 7)) + (envmap-trans-count uint16 :overlay-at (-> count 7)) + (envmap-water-last uint32 :overlay-at (-> last 8)) + (envmap-water-next uint32 :overlay-at (-> next 8)) + (envmap-water-count uint16 :overlay-at (-> count 8)) + (envmap-scissor-last uint32 :overlay-at (-> last 9)) + (envmap-scissor-next uint32 :overlay-at (-> next 9)) + (envmap-scissor-count uint16 :overlay-at (-> count 9)) + (envmap-scissor-trans-last uint32 :overlay-at (-> last 10)) + (envmap-scissor-trans-next uint32 :overlay-at (-> next 10)) + (envmap-scissor-trans-count uint16 :overlay-at (-> count 10)) + (envmap-scissor-water-last uint32 :overlay-at (-> last 11)) + (envmap-scissor-water-next uint32 :overlay-at (-> next 11)) + (envmap-scissor-water-count uint16 :overlay-at (-> count 11)) + (generic-last uint32 :overlay-at (-> last 12)) + (generic-next uint32 :overlay-at (-> next 12)) + (generic-count uint16 :overlay-at (-> count 12)) + (generic-trans-last uint32 :overlay-at (-> last 13)) + (generic-trans-next uint32 :overlay-at (-> next 13)) + (generic-trans-count uint16 :overlay-at (-> count 13)) + (generic-water-last uint32 :overlay-at (-> last 14)) + (generic-water-next uint32 :overlay-at (-> next 14)) + (generic-water-count uint16 :overlay-at (-> count 14)) + (vanish-last uint32 :overlay-at (-> last 15)) + (vanish-next uint32 :overlay-at (-> next 15)) + (vanish-count uint16 :overlay-at (-> count 15)) + ) + ) + +;; definition for method 3 of type prototype-tie-work +(defmethod inspect ((this prototype-tie-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'prototype-tie-work) + (format #t "~1Tupload-flushe: #~%" (-> this upload-flushe)) + (format #t "~1Tupload-palette: #~%" (-> this upload-palette)) + (format #t "~1Tupload-model-0: #~%" (-> this upload-model-0)) + (format #t "~1Tupload-model-1: #~%" (-> this upload-model-1)) + (format #t "~1Tupload-model-2: #~%" (-> this upload-model-2)) + (format #t "~1Tupload-model-3: #~%" (-> this upload-model-3)) + (format #t "~1Tupload-model-near-0: #~%" (-> this upload-model-near-0)) + (format #t "~1Tupload-model-near-1: #~%" (-> this upload-model-near-1)) + (format #t "~1Tupload-model-near-2: #~%" (-> this upload-model-near-2)) + (format #t "~1Tupload-model-near-3: #~%" (-> this upload-model-near-3)) + (format #t "~1Tupload-model-near-4: #~%" (-> this upload-model-near-4)) + (format #t "~1Tenvmap-palette: #~%" (-> this envmap-palette)) + (format #t "~1Tenvmap-shader: #~%" (-> this envmap-shader)) + (format #t "~1Tupload-envmap-0: #~%" (-> this upload-envmap-0)) + (format #t "~1Tupload-envmap-1: #~%" (-> this upload-envmap-1)) + (format #t "~1Tupload-envmap-2: #~%" (-> this upload-envmap-2)) + (format #t "~1Tupload-envmap-3: #~%" (-> this upload-envmap-3)) + (format #t "~1Tupload-envmap-4: #~%" (-> this upload-envmap-4)) + (format #t "~1Tupload-envmap-scissor-4: #~%" (-> this upload-envmap-scissor-4)) + (format #t "~1Tgeneric-palette: #~%" (-> this generic-palette)) + (format #t "~1Tgeneric-model-0: #~%" (-> this generic-model-0)) + (format #t "~1Tgeneric-model-1: #~%" (-> this generic-model-1)) + (format #t "~1Tgeneric-model-2: #~%" (-> this generic-model-2)) + (format #t "~1Tmodel-next: #~%" (-> this model-next)) + (format #t "~1Tclamp: ~D~%" (-> this clamp)) + (format #t "~1Tprototype-array: ~A~%" (-> this prototype-array)) + (format #t "~1Twait-from-spr: ~D~%" (-> this wait-from-spr)) + (format #t "~1Twait-to-spr: ~D~%" (-> this wait-to-spr)) + (format #t "~1Tmood: #~%" (-> this mood)) + (format #t "~1Twide-level-index: ~D~%" (-> this wide-level-index)) + (format #t "~1Tlast[16] @ #x~X~%" (-> this last)) + (format #t "~1Tnext[16] @ #x~X~%" (-> this next)) + (format #t "~1Tcount[16] @ #x~X~%" (-> this count)) + (format #t "~1Ttie-last: #x~X~%" (-> this tie-last)) + (format #t "~1Ttie-next: #x~X~%" (-> this tie-next)) + (format #t "~1Ttie-count: ~D~%" (-> this tie-count)) + (format #t "~1Ttrans-last: #x~X~%" (-> this trans-last)) + (format #t "~1Ttrans-next: #x~X~%" (-> this trans-next)) + (format #t "~1Ttrans-count: ~D~%" (-> this trans-count)) + (format #t "~1Twater-last: #x~X~%" (-> this water-last)) + (format #t "~1Twater-next: #x~X~%" (-> this water-next)) + (format #t "~1Twater-count: ~D~%" (-> this water-count)) + (format #t "~1Tscissor-last: #x~X~%" (-> this scissor-last)) + (format #t "~1Tscissor-next: #x~X~%" (-> this scissor-next)) + (format #t "~1Tscissor-count: ~D~%" (-> this scissor-count)) + (format #t "~1Tscissor-trans-last: #x~X~%" (-> this scissor-trans-last)) + (format #t "~1Tscissor-trans-next: #x~X~%" (-> this scissor-trans-next)) + (format #t "~1Tscissor-trans-count: ~D~%" (-> this scissor-trans-count)) + (format #t "~1Tscissor-water-last: #x~X~%" (-> this scissor-water-last)) + (format #t "~1Tscissor-water-next: #x~X~%" (-> this scissor-water-next)) + (format #t "~1Tscissor-water-count: ~D~%" (-> this scissor-water-count)) + (format #t "~1Tenvmap-last: #x~X~%" (-> this envmap-last)) + (format #t "~1Tenvmap-next: #x~X~%" (-> this envmap-next)) + (format #t "~1Tenvmap-count: ~D~%" (-> this envmap-count)) + (format #t "~1Tenvmap-trans-last: #x~X~%" (-> this envmap-trans-last)) + (format #t "~1Tenvmap-trans-next: #x~X~%" (-> this envmap-trans-next)) + (format #t "~1Tenvmap-trans-count: ~D~%" (-> this envmap-trans-count)) + (format #t "~1Tenvmap-water-last: #x~X~%" (-> this envmap-water-last)) + (format #t "~1Tenvmap-water-next: #x~X~%" (-> this envmap-water-next)) + (format #t "~1Tenvmap-water-count: ~D~%" (-> this envmap-water-count)) + (format #t "~1Tenvmap-scissor-last: #x~X~%" (-> this envmap-scissor-last)) + (format #t "~1Tenvmap-scissor-next: #x~X~%" (-> this envmap-scissor-next)) + (format #t "~1Tenvmap-scissor-count: ~D~%" (-> this envmap-scissor-count)) + (format #t "~1Tenvmap-scissor-trans-last: #x~X~%" (-> this envmap-scissor-trans-last)) + (format #t "~1Tenvmap-scissor-trans-next: #x~X~%" (-> this envmap-scissor-trans-next)) + (format #t "~1Tenvmap-scissor-trans-count: ~D~%" (-> this envmap-scissor-trans-count)) + (format #t "~1Tenvmap-scissor-water-last: #x~X~%" (-> this envmap-scissor-water-last)) + (format #t "~1Tenvmap-scissor-water-next: #x~X~%" (-> this envmap-scissor-water-next)) + (format #t "~1Tenvmap-scissor-water-count: ~D~%" (-> this envmap-scissor-water-count)) + (format #t "~1Tgeneric-last: #x~X~%" (-> this generic-last)) + (format #t "~1Tgeneric-next: #x~X~%" (-> this generic-next)) + (format #t "~1Tgeneric-count: ~D~%" (-> this generic-count)) + (format #t "~1Tgeneric-trans-last: #x~X~%" (-> this generic-trans-last)) + (format #t "~1Tgeneric-trans-next: #x~X~%" (-> this generic-trans-next)) + (format #t "~1Tgeneric-trans-count: ~D~%" (-> this generic-trans-count)) + (format #t "~1Tgeneric-water-last: #x~X~%" (-> this generic-water-last)) + (format #t "~1Tgeneric-water-next: #x~X~%" (-> this generic-water-next)) + (format #t "~1Tgeneric-water-count: ~D~%" (-> this generic-water-count)) + (format #t "~1Tvanish-last: #x~X~%" (-> this vanish-last)) + (format #t "~1Tvanish-next: #x~X~%" (-> this vanish-next)) + (format #t "~1Tvanish-count: ~D~%" (-> this vanish-count)) + (label cfg-4) + this + ) + +;; definition of type prototype-tie-dma +(deftype prototype-tie-dma (structure) + ((colora rgba 256) + (colorb rgba 256) + (outa uint128 256) + (outb uint128 256) + (geometry uint32 4) + (next uint32 12) + (count uint16 12) + (counts uint32 4) + (palette-ptr uint32 :overlay-at (-> counts 2)) + (model-ptr uint32 :overlay-at (-> counts 3)) + (ret-ptr uint32) + (length uint32) + (flags uint32) + (dma-buffer basic) + (this-frag-count uint32) + (frag-count uint8 4) + (from-spr uint32) + (to-spr uint32) + (spr-out uint32) + (this-count uint32) + (scissor-geometry uint32 :overlay-at (-> geometry 0)) + (near-geometry uint32 :overlay-at (-> geometry 1)) + (mid-geometry uint32 :overlay-at (-> geometry 2)) + (far-geometry uint32 :overlay-at (-> geometry 3)) + (scissor-frag-count uint8 :overlay-at (-> frag-count 0)) + (near-frag-count uint8 :overlay-at (-> frag-count 1)) + (mid-frag-count uint8 :overlay-at (-> frag-count 2)) + (far-frag-count uint8 :overlay-at (-> frag-count 3)) + (tie-scissor-next uint32 :overlay-at (-> next 0)) + (tie-near-next uint32 :overlay-at (-> next 1)) + (tie-mid-next uint32 :overlay-at (-> next 2)) + (tie-far-next uint32 :overlay-at (-> next 3)) + (trans-scissor-next uint32 4 :overlay-at (-> next 0)) + (trans-near-next uint32 :overlay-at (-> next 1)) + (trans-mid-next uint32 :overlay-at (-> next 2)) + (trans-far-next uint32 :overlay-at (-> next 3)) + (water-scissor-next uint32 4 :overlay-at (-> next 0)) + (water-near-next uint32 :overlay-at (-> next 1)) + (water-mid-next uint32 :overlay-at (-> next 2)) + (water-far-next uint32 :overlay-at (-> next 3)) + (envmap-scissor-next uint32 4 :overlay-at (-> next 4)) + (envmap-near-next uint32 :overlay-at (-> next 5)) + (envmap-mid-next uint32 :overlay-at (-> next 6)) + (envmap-far-next uint32 :overlay-at (-> next 7)) + (generic-near-next uint32 :overlay-at (-> next 8)) + (generic-mid-next uint32 :overlay-at (-> next 9)) + (generic-far-next uint32 :overlay-at (-> next 10)) + (vanish-next uint32 :overlay-at (-> next 11)) + (tie-count uint16 :overlay-at (-> count 0)) + (tie-scissor-count uint16 :overlay-at (-> count 0)) + (tie-near-count uint16 :overlay-at (-> count 1)) + (tie-mid-count uint16 :overlay-at (-> count 2)) + (tie-far-count uint16 :overlay-at (-> count 3)) + (trans-count uint16 :overlay-at (-> count 0)) + (trans-scissor-count uint16 :overlay-at (-> count 0)) + (trans-near-count uint16 :overlay-at (-> count 1)) + (trans-mid-count uint16 :overlay-at (-> count 2)) + (trans-far-count uint16 :overlay-at (-> count 3)) + (water-count uint16 :overlay-at (-> count 0)) + (water-scissor-count uint16 :overlay-at (-> count 0)) + (water-near-count uint16 :overlay-at (-> count 1)) + (water-mid-count uint16 :overlay-at (-> count 2)) + (water-far-count uint16 :overlay-at (-> count 3)) + (envmap-count uint16 :overlay-at (-> count 4)) + (envmap-scissor-count uint16 :overlay-at (-> count 4)) + (envmap-near-count uint16 :overlay-at (-> count 5)) + (envmap-mid-count uint16 :overlay-at (-> count 6)) + (envmap-far-count uint16 :overlay-at (-> count 7)) + (generic-count uint16 :overlay-at (-> count 8)) + (generic-near-count uint16 :overlay-at (-> count 8)) + (generic-mid-count uint16 :overlay-at (-> count 9)) + (generic-far-count uint16 :overlay-at (-> count 10)) + (vanish-count uint16 :overlay-at (-> count 11)) + (next-clear uint32 3 :overlay-at (-> next 0)) + (count-clear uint16 3 :overlay-at (-> count 0)) + ) + ) + +;; definition for method 3 of type prototype-tie-dma +(defmethod inspect ((this prototype-tie-dma)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'prototype-tie-dma) + (format #t "~1Tcolora[256] @ #x~X~%" (-> this colora)) + (format #t "~1Tcolorb[256] @ #x~X~%" (-> this colorb)) + (format #t "~1Touta[256] @ #x~X~%" (-> this outa)) + (format #t "~1Toutb[256] @ #x~X~%" (-> this outb)) + (format #t "~1Tgeometry[4] @ #x~X~%" (-> this geometry)) + (format #t "~1Tnext[12] @ #x~X~%" (-> this next)) + (format #t "~1Tcount[12] @ #x~X~%" (-> this count)) + (format #t "~1Tcounts[4] @ #x~X~%" (-> this counts)) + (format #t "~1Tpalette-ptr: #x~X~%" (-> this palette-ptr)) + (format #t "~1Tmodel-ptr: #x~X~%" (-> this model-ptr)) + (format #t "~1Tret-ptr: #x~X~%" (-> this ret-ptr)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tdma-buffer: ~A~%" (-> this dma-buffer)) + (format #t "~1Tthis-frag-count: ~D~%" (-> this this-frag-count)) + (format #t "~1Tfrag-count[4] @ #x~X~%" (-> this frag-count)) + (format #t "~1Tfrom-spr: #x~X~%" (-> this from-spr)) + (format #t "~1Tto-spr: #x~X~%" (-> this to-spr)) + (format #t "~1Tspr-out: #x~X~%" (-> this spr-out)) + (format #t "~1Tthis-count: ~D~%" (-> this this-count)) + (format #t "~1Tscissor-geometry: #x~X~%" (-> this scissor-geometry)) + (format #t "~1Tnear-geometry: #x~X~%" (-> this near-geometry)) + (format #t "~1Tmid-geometry: #x~X~%" (-> this mid-geometry)) + (format #t "~1Tfar-geometry: #x~X~%" (-> this far-geometry)) + (format #t "~1Tscissor-frag-count: ~D~%" (-> this scissor-frag-count)) + (format #t "~1Tnear-frag-count: ~D~%" (-> this near-frag-count)) + (format #t "~1Tmid-frag-count: ~D~%" (-> this mid-frag-count)) + (format #t "~1Tfar-frag-count: ~D~%" (-> this far-frag-count)) + (format #t "~1Ttie-scissor-next: #x~X~%" (-> this tie-scissor-next)) + (format #t "~1Ttie-near-next: #x~X~%" (-> this tie-near-next)) + (format #t "~1Ttie-mid-next: #x~X~%" (-> this tie-mid-next)) + (format #t "~1Ttie-far-next: #x~X~%" (-> this tie-far-next)) + (format #t "~1Ttrans-scissor-next[4] @ #x~X~%" (-> this next)) + (format #t "~1Ttrans-near-next: #x~X~%" (-> this tie-near-next)) + (format #t "~1Ttrans-mid-next: #x~X~%" (-> this tie-mid-next)) + (format #t "~1Ttrans-far-next: #x~X~%" (-> this tie-far-next)) + (format #t "~1Twater-scissor-next[4] @ #x~X~%" (-> this next)) + (format #t "~1Twater-near-next: #x~X~%" (-> this tie-near-next)) + (format #t "~1Twater-mid-next: #x~X~%" (-> this tie-mid-next)) + (format #t "~1Twater-far-next: #x~X~%" (-> this tie-far-next)) + (format #t "~1Tenvmap-scissor-next[4] @ #x~X~%" (-> this envmap-scissor-next)) + (format #t "~1Tenvmap-near-next: #x~X~%" (-> this envmap-near-next)) + (format #t "~1Tenvmap-mid-next: #x~X~%" (-> this envmap-mid-next)) + (format #t "~1Tenvmap-far-next: #x~X~%" (-> this envmap-far-next)) + (format #t "~1Tgeneric-near-next: #x~X~%" (-> this generic-near-next)) + (format #t "~1Tgeneric-mid-next: #x~X~%" (-> this generic-mid-next)) + (format #t "~1Tgeneric-far-next: #x~X~%" (-> this generic-far-next)) + (format #t "~1Tvanish-next: #x~X~%" (-> this vanish-next)) + (format #t "~1Ttie-count: ~D~%" (-> this tie-count)) + (format #t "~1Ttie-scissor-count: ~D~%" (-> this tie-count)) + (format #t "~1Ttie-near-count: ~D~%" (-> this tie-near-count)) + (format #t "~1Ttie-mid-count: ~D~%" (-> this tie-mid-count)) + (format #t "~1Ttie-far-count: ~D~%" (-> this tie-far-count)) + (format #t "~1Ttrans-count: ~D~%" (-> this tie-count)) + (format #t "~1Ttrans-scissor-count: ~D~%" (-> this tie-count)) + (format #t "~1Ttrans-near-count: ~D~%" (-> this tie-near-count)) + (format #t "~1Ttrans-mid-count: ~D~%" (-> this tie-mid-count)) + (format #t "~1Ttrans-far-count: ~D~%" (-> this tie-far-count)) + (format #t "~1Twater-count: ~D~%" (-> this tie-count)) + (format #t "~1Twater-scissor-count: ~D~%" (-> this tie-count)) + (format #t "~1Twater-near-count: ~D~%" (-> this tie-near-count)) + (format #t "~1Twater-mid-count: ~D~%" (-> this tie-mid-count)) + (format #t "~1Twater-far-count: ~D~%" (-> this tie-far-count)) + (format #t "~1Tenvmap-count: ~D~%" (-> this envmap-count)) + (format #t "~1Tenvmap-scissor-count: ~D~%" (-> this envmap-count)) + (format #t "~1Tenvmap-near-count: ~D~%" (-> this envmap-near-count)) + (format #t "~1Tenvmap-mid-count: ~D~%" (-> this envmap-mid-count)) + (format #t "~1Tenvmap-far-count: ~D~%" (-> this envmap-far-count)) + (format #t "~1Tgeneric-count: ~D~%" (-> this generic-count)) + (format #t "~1Tgeneric-near-count: ~D~%" (-> this generic-count)) + (format #t "~1Tgeneric-mid-count: ~D~%" (-> this generic-mid-count)) + (format #t "~1Tgeneric-far-count: ~D~%" (-> this generic-far-count)) + (format #t "~1Tvanish-count: ~D~%" (-> this vanish-count)) + (format #t "~1Tnext-clear[3] @ #x~X~%" (-> this next)) + (format #t "~1Tcount-clear[3] @ #x~X~%" (-> this count)) + (label cfg-4) + this + ) + +;; definition for symbol *instance-tie-work-copy*, type instance-tie-work +(define *instance-tie-work-copy* (the-as instance-tie-work #f)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/background/wind-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/background/wind-h_REF.gc new file mode 100644 index 0000000000..0e40741afb --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/background/wind-h_REF.gc @@ -0,0 +1,146 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type wind-vector +(deftype wind-vector (structure) + ((wind-pos vector4w :inline) + (wind-vel vector4w :inline) + (stiffness float :overlay-at (-> wind-vel data 3)) + ) + ) + +;; definition for method 3 of type wind-vector +(defmethod inspect ((this wind-vector)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'wind-vector) + (format #t "~1Twind-pos: #~%" (-> this wind-pos)) + (format #t "~1Twind-vel: #~%" (-> this wind-vel)) + (format #t "~1Tstiffness: ~f~%" (-> this stiffness)) + (label cfg-4) + this + ) + +;; definition for symbol *wind-scales*, type (array uint8) +(define *wind-scales* (new 'static 'boxed-array :type uint8 + #x2 + #x5 + #x2 + #x3 + #x2 + #x2 + #x3 + #x10 + #xa + #x2 + #x4 + #x2 + #x8 + #x2 + #x2 + #x10 + #x2 + #x2 + #x8 + #x2 + #x10 + #x2 + #x4 + #x10 + #xa + #x2 + #x4 + #x2 + #x8 + #x2 + #x2 + #x10 + ) + ) + +;; definition of type wind-work +(deftype wind-work (basic) + ((wind-array vector 64 :inline) + (wind-normal vector :inline) + (wind-temp vector :inline) + (wind-force float 64) + (wind-const vector :inline) + (wind-time uint32) + (wait-to-vu0 uint32) + (wait-to-spr uint32) + (wait-from-spr uint32) + (spr-index uint32) + (count uint32) + (next-count uint32) + (last-count uint32) + (to-spr uint32) + (from-spr uint32) + (next-mem uint32) + (last-mem uint32) + (next-spr uint32) + (last-spr uint32) + (to-ptrs uint32 3) + ) + ) + +;; definition for method 3 of type wind-work +(defmethod inspect ((this wind-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Twind-array[64] @ #x~X~%" (-> this wind-array)) + (format #t "~1Twind-normal: ~`vector`P~%" (-> this wind-normal)) + (format #t "~1Twind-temp: ~`vector`P~%" (-> this wind-temp)) + (format #t "~1Twind-force[64] @ #x~X~%" (-> this wind-force)) + (format #t "~1Twind-const: ~`vector`P~%" (-> this wind-const)) + (format #t "~1Twind-time: ~D~%" (-> this wind-time)) + (format #t "~1Twait-to-vu0: ~D~%" (-> this wait-to-vu0)) + (format #t "~1Twait-to-spr: ~D~%" (-> this wait-to-spr)) + (format #t "~1Twait-from-spr: ~D~%" (-> this wait-from-spr)) + (format #t "~1Tspr-index: ~D~%" (-> this spr-index)) + (format #t "~1Tcount: ~D~%" (-> this count)) + (format #t "~1Tnext-count: ~D~%" (-> this next-count)) + (format #t "~1Tlast-count: ~D~%" (-> this last-count)) + (format #t "~1Tto-spr: ~D~%" (-> this to-spr)) + (format #t "~1Tfrom-spr: ~D~%" (-> this from-spr)) + (format #t "~1Tnext-mem: #x~X~%" (-> this next-mem)) + (format #t "~1Tlast-mem: #x~X~%" (-> this last-mem)) + (format #t "~1Tnext-spr: #x~X~%" (-> this next-spr)) + (format #t "~1Tlast-spr: #x~X~%" (-> this last-spr)) + (format #t "~1Tto-ptrs[3] @ #x~X~%" (-> this to-ptrs)) + (label cfg-4) + this + ) + +;; definition of type wind-dma +(deftype wind-dma (structure) + ((buffer0 wind-vector 128 :inline) + (buffer1 wind-vector 128 :inline) + (buffer2 wind-vector 128 :inline) + ) + ) + +;; definition for method 3 of type wind-dma +(defmethod inspect ((this wind-dma)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'wind-dma) + (format #t "~1Tbuffer0[128] @ #x~X~%" (-> this buffer0)) + (format #t "~1Tbuffer1[128] @ #x~X~%" (-> this buffer1)) + (format #t "~1Tbuffer2[128] @ #x~X~%" (-> this buffer2)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/blit-displays-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/blit-displays-h_REF.gc new file mode 100644 index 0000000000..a4e589bf21 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/blit-displays-h_REF.gc @@ -0,0 +1,92 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type blit-displays-work +(deftype blit-displays-work (structure) + ((adgif-tmpl dma-gif-packet :inline) + (sprite-tmpl dma-gif-packet :inline) + (contrast-tmpl dma-gif-packet :inline) + (sprite-slow-tmpl dma-gif-packet :inline) + (screen-tmpl dma-gif-packet :inline) + (blur-tmpl dma-gif-packet :inline) + (blur-tmpl2 dma-gif-packet :inline) + (line-tmpl dma-gif-packet :inline) + (scan-tmpl dma-gif-packet :inline) + (color vector4w :inline) + (line-color uint64) + (scan-colors vector4w 15 :inline) + (vu1-enable-user-menu uint64) + (texture-enable-user-menu uint32) + (horizontal-flip-flag symbol) + (scan-alpha float) + (scanline uint32) + (progress-interp float) + (progress-interp-dest float) + (progress-interp-speed float) + ) + (:methods + (blit-displays-work-method-9 () none) + (blit-displays-work-method-10 () none) + (blit-displays-work-method-11 () none) + (blit-displays-work-method-12 () none) + (blit-displays-work-method-13 () none) + (blit-displays-work-method-14 () none) + (blit-displays-work-method-15 () none) + (blit-displays-work-method-16 () none) + (blit-displays-work-method-17 () none) + (blit-displays-work-method-18 () none) + (get-horizontal-flip-flag (_type_) symbol) + (set-horizontal-flip-flag (_type_ symbol) symbol) + (blit-displays-work-method-21 () none) + (blit-displays-work-method-22 () none) + (blit-displays-work-method-23 () none) + (blit-displays-work-method-24 () none) + (blit-displays-work-method-25 () none) + (blit-displays-work-method-26 () none) + ) + ) + +;; definition for method 3 of type blit-displays-work +(defmethod inspect ((this blit-displays-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'blit-displays-work) + (format #t "~1Tadgif-tmpl: #~%" (-> this adgif-tmpl)) + (format #t "~1Tsprite-tmpl: #~%" (-> this sprite-tmpl)) + (format #t "~1Tcontrast-tmpl: #~%" (-> this contrast-tmpl)) + (format #t "~1Tsprite-slow-tmpl: #~%" (-> this sprite-slow-tmpl)) + (format #t "~1Tscreen-tmpl: #~%" (-> this screen-tmpl)) + (format #t "~1Tblur-tmpl: #~%" (-> this blur-tmpl)) + (format #t "~1Tblur-tmpl2: #~%" (-> this blur-tmpl2)) + (format #t "~1Tline-tmpl: #~%" (-> this line-tmpl)) + (format #t "~1Tscan-tmpl: #~%" (-> this scan-tmpl)) + (format #t "~1Tcolor: #~%" (-> this color)) + (format #t "~1Tline-color: ~D~%" (-> this line-color)) + (format #t "~1Tscan-colors[15] @ #x~X~%" (-> this scan-colors)) + (format #t "~1Tvu1-enable-user-menu: ~D~%" (-> this vu1-enable-user-menu)) + (format #t "~1Ttexture-enable-user-menu: ~D~%" (-> this texture-enable-user-menu)) + (format #t "~1Thorizontal-flip-flag: ~A~%" (-> this horizontal-flip-flag)) + (format #t "~1Tscan-alpha: ~f~%" (-> this scan-alpha)) + (format #t "~1Tscanline: ~D~%" (-> this scanline)) + (format #t "~1Tprogress-interp: ~f~%" (-> this progress-interp)) + (format #t "~1Tprogress-interp-dest: ~f~%" (-> this progress-interp-dest)) + (format #t "~1Tprogress-interp-speed: ~f~%" (-> this progress-interp-speed)) + (label cfg-4) + this + ) + +;; definition for method 19 of type blit-displays-work +(defmethod get-horizontal-flip-flag ((this blit-displays-work)) + (-> this horizontal-flip-flag) + ) + +;; definition for method 20 of type blit-displays-work +(defmethod set-horizontal-flip-flag ((this blit-displays-work) (arg0 symbol)) + (set! (-> this horizontal-flip-flag) arg0) + arg0 + ) + +;; failed to figure out what this is: +0 diff --git a/test/decompiler/reference/jakx/engine/gfx/foreground/bones-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/foreground/bones-h_REF.gc new file mode 100644 index 0000000000..635d2d7aa7 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/foreground/bones-h_REF.gc @@ -0,0 +1,214 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type bone-buffer +(deftype bone-buffer (structure) + ((joint matrix 16 :inline) + (bone bone 16 :inline) + (output pris-mtx 16 :inline) + ) + ) + +;; definition for method 3 of type bone-buffer +(defmethod inspect ((this bone-buffer)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bone-buffer) + (format #t "~1Tjoint[16] @ #x~X~%" (-> this joint)) + (format #t "~1Tbone[16] @ #x~X~%" (-> this bone)) + (format #t "~1Toutput[16] @ #x~X~%" (-> this output)) + (label cfg-4) + this + ) + +;; definition of type bone-layout +(deftype bone-layout (structure) + ((data uint16 8) + (joint (inline-array matrix) 2 :overlay-at (-> data 0)) + (bone (inline-array bone) 2 :overlay-at (-> data 4)) + (output (inline-array pris-mtx) 2 :offset 16) + (unused uint32 2 :offset 24) + ) + ) + +;; definition for method 3 of type bone-layout +(defmethod inspect ((this bone-layout)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bone-layout) + (format #t "~1Tdata[8] @ #x~X~%" (-> this data)) + (format #t "~1Tjoint[2] @ #x~X~%" (-> this data)) + (format #t "~1Tbone[2] @ #x~X~%" (-> this bone)) + (format #t "~1Toutput[2] @ #x~X~%" (-> this output)) + (format #t "~1Tunused[2] @ #x~X~%" (-> this unused)) + (label cfg-4) + this + ) + +;; definition of type bone-regs +(deftype bone-regs (structure) + ((dma-buf dma-buffer) + (wait-count uint32) + (in-count uint32) + (sp-size uint32) + (sp-bufnum uint32) + (joint-ptr (inline-array joint)) + (bone-ptr (inline-array bone)) + (num-bones uint32) + (mtxs (inline-array pris-mtx)) + ) + ) + +;; definition for method 3 of type bone-regs +(defmethod inspect ((this bone-regs)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bone-regs) + (format #t "~1Tdma-buf: ~A~%" (-> this dma-buf)) + (format #t "~1Twait-count: ~D~%" (-> this wait-count)) + (format #t "~1Tin-count: ~D~%" (-> this in-count)) + (format #t "~1Tsp-size: ~D~%" (-> this sp-size)) + (format #t "~1Tsp-bufnum: ~D~%" (-> this sp-bufnum)) + (format #t "~1Tjoint-ptr: #x~X~%" (-> this joint-ptr)) + (format #t "~1Tbone-ptr: #x~X~%" (-> this bone-ptr)) + (format #t "~1Tnum-bones: ~D~%" (-> this num-bones)) + (format #t "~1Tmtxs: #x~X~%" (-> this mtxs)) + (label cfg-4) + this + ) + +;; definition of type bone-work +(deftype bone-work (structure) + ((layout bone-layout :inline) + (regs bone-regs :inline) + ) + ) + +;; definition for method 3 of type bone-work +(defmethod inspect ((this bone-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bone-work) + (format #t "~1Tlayout: #~%" (-> this layout)) + (format #t "~1Tregs: #~%" (-> this regs)) + (label cfg-4) + this + ) + +;; definition of type bone-debug +(deftype bone-debug (structure) + ((time-ctr uint32) + (timing uint32 360) + ) + ) + +;; definition for method 3 of type bone-debug +(defmethod inspect ((this bone-debug)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bone-debug) + (format #t "~1Ttime-ctr: ~D~%" (-> this time-ctr)) + (format #t "~1Ttiming[360] @ #x~X~%" (-> this timing)) + (label cfg-4) + this + ) + +;; definition of type bone-memory +(deftype bone-memory (structure) + ((work bone-work :inline) + (buffer bone-buffer 2 :inline) + ) + ) + +;; definition for method 3 of type bone-memory +(defmethod inspect ((this bone-memory)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bone-memory) + (format #t "~1Twork: #~%" (-> this work)) + (format #t "~1Tbuffer[2] @ #x~X~%" (-> this buffer)) + (label cfg-4) + this + ) + +;; definition of type bone-calculation +(deftype bone-calculation (structure) + ((flags bone-calc-flags) + (num-bones uint16) + (matrix-area (inline-array pris-mtx)) + (joints (inline-array joint)) + (bones (inline-array bone)) + (ripple-scale float) + (ripple-y-scale float) + (ripple-normal-scale float) + (ripple-area (inline-array vector)) + (ripple-vec vector :inline :overlay-at ripple-scale) + (next bone-calculation) + (dummy-1 uint32) + (dummy-2 uint32) + (dummy-3 uint32) + ) + ) + +;; definition for method 3 of type bone-calculation +(defmethod inspect ((this bone-calculation)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bone-calculation) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnum-bones: ~D~%" (-> this num-bones)) + (format #t "~1Tmatrix-area: #x~X~%" (-> this matrix-area)) + (format #t "~1Tjoints: #x~X~%" (-> this joints)) + (format #t "~1Tbones: #x~X~%" (-> this bones)) + (format #t "~1Tripple-scale: ~f~%" (-> this ripple-scale)) + (format #t "~1Tripple-y-scale: ~f~%" (-> this ripple-y-scale)) + (format #t "~1Tripple-normal-scale: ~f~%" (-> this ripple-normal-scale)) + (format #t "~1Tripple-area: #x~X~%" (-> this ripple-area)) + (format #t "~1Tnext: #~%" (-> this next)) + (format #t "~1Tdummy-1: ~D~%" (-> this dummy-1)) + (format #t "~1Tdummy-2: ~D~%" (-> this dummy-2)) + (format #t "~1Tdummy-3: ~D~%" (-> this dummy-3)) + (label cfg-4) + this + ) + +;; definition of type bone-calculation-list +(deftype bone-calculation-list (structure) + ((first bone-calculation) + (next bone-calculation) + ) + ) + +;; definition for method 3 of type bone-calculation-list +(defmethod inspect ((this bone-calculation-list)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'bone-calculation-list) + (format #t "~1Tfirst: #~%" (-> this first)) + (format #t "~1Tnext: #~%" (-> this next)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/foreground/eye-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/foreground/eye-h_REF.gc new file mode 100644 index 0000000000..91f9773971 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/foreground/eye-h_REF.gc @@ -0,0 +1,152 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type eye +(deftype eye (structure) + "Data for a single eye." + ((data vector 2 :inline) + (x float :overlay-at (-> data 0 data 0)) + (y float :overlay-at (-> data 0 data 1)) + (lid float :overlay-at (-> data 0 data 2)) + (iris-scale float :offset 16) + (pupil-scale float :offset 20) + (lid-scale float :offset 24) + (tbp int32) + (shader-count uint32) + (shader adgif-shader 8) + ) + ) + +;; definition for method 3 of type eye +(defmethod inspect ((this eye)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'eye) + (format #t "~1Tdata[2] @ #x~X~%" (&-> this x)) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tlid: ~f~%" (-> this lid)) + (format #t "~1Tiris-scale: ~f~%" (-> this iris-scale)) + (format #t "~1Tpupil-scale: ~f~%" (-> this pupil-scale)) + (format #t "~1Tlid-scale: ~f~%" (-> this lid-scale)) + (format #t "~1Ttbp: ~D~%" (-> this tbp)) + (format #t "~1Tshader-count: ~D~%" (-> this shader-count)) + (format #t "~1Tshader[8] @ #x~X~%" (-> this shader)) + (label cfg-4) + this + ) + +;; definition of type eye-control +(deftype eye-control (structure) + ((process uint64) + (random-time uint16) + (bucket uint16) + (blink float) + (shaders (inline-array adgif-shader)) + (eyes eye 2 :inline) + (left eye :inline :overlay-at (-> eyes 0)) + (right eye :inline :offset 112) + (level-index int16) + (high-res? symbol) + (level-texture-page uint32) + (art-group-name uint8 67 :offset 201) + ) + ) + +;; definition for method 3 of type eye-control +(defmethod inspect ((this eye-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'eye-control) + (format #t "~1Tprocess: ~D~%" (-> this process)) + (format #t "~1Trandom-time: ~D~%" (-> this random-time)) + (format #t "~1Tbucket: ~D~%" (-> this bucket)) + (format #t "~1Tblink: ~f~%" (-> this blink)) + (format #t "~1Tshaders: #x~X~%" (-> this shaders)) + (format #t "~1Teyes[2] @ #x~X~%" (-> this eyes)) + (format #t "~1Tleft: #~%" (-> this eyes)) + (format #t "~1Tright: #~%" (-> this right)) + (format #t "~1Tlevel-index: ~D~%" (-> this level-index)) + (format #t "~1Thigh-res?: ~A~%" (-> this high-res?)) + (format #t "~1Tlevel-texture-page: ~D~%" (-> this level-texture-page)) + (format #t "~1Tart-group-name: ~g~%" (&-> this art-group-name 3)) + (label cfg-4) + this + ) + +;; definition of type eye-control-array +(deftype eye-control-array (basic) + "An array of [[eye-control]]s." + ((data eye-control 32 :inline) + ) + ) + +;; definition for method 3 of type eye-control-array +(defmethod inspect ((this eye-control-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tdata[32] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type eye-work +(deftype eye-work (structure) + "Eye renderer DMA data." + ((sprite-tmpl dma-gif-packet :inline) + (sprite-tmpl2 dma-gif-packet :inline) + (adgif-tmpl dma-gif-packet :inline) + (blink-table float 10) + ) + ) + +;; definition for method 3 of type eye-work +(defmethod inspect ((this eye-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'eye-work) + (format #t "~1Tsprite-tmpl: #~%" (-> this sprite-tmpl)) + (format #t "~1Tsprite-tmpl2: #~%" (-> this sprite-tmpl2)) + (format #t "~1Tadgif-tmpl: #~%" (-> this adgif-tmpl)) + (format #t "~1Tblink-table[10] @ #x~X~%" (-> this blink-table)) + (label cfg-4) + this + ) + +;; definition for symbol *eye-control-array*, type eye-control-array +(define *eye-control-array* (new 'static 'eye-control-array)) + +;; failed to figure out what this is: +(dotimes (v1-5 32) + (let ((a0-11 (-> *eye-control-array* data v1-5))) + (set! (-> a0-11 process) (the-as uint #f)) + (set! (-> a0-11 random-time) (the-as uint 60)) + (set! (-> a0-11 blink) 0.0) + (set! (-> a0-11 shaders) (the-as (inline-array adgif-shader) #f)) + (set! (-> a0-11 level-index) -1) + (set! (-> a0-11 high-res?) #f) + (set! (-> a0-11 art-group-name 3) (the-as uint 0)) + (dotimes (a1-11 2) + (set! (-> a0-11 eyes a1-11 shader-count) (the-as uint 0)) + (dotimes (a2-11 8) + (set! (-> (the-as eye-control (+ (+ (* a2-11 4) (* 80 a1-11)) (the-as int a0-11))) left shader 0) #f) + ) + ) + ) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/foreground/foreground-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/foreground/foreground-h_REF.gc new file mode 100644 index 0000000000..ad78d474fc --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/foreground/foreground-h_REF.gc @@ -0,0 +1,814 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type mercneric-chain +(deftype mercneric-chain (structure) + "A DMA chain for drawing with mercneric, and metadata needed to append. +This chain is assumed to run with a specific tpage from a specific level available." + ((first uint32) + (next uint32) + (state generic-bucket-state :inline) + (vu1-bucket bucket-id) + ) + :pack-me + ) + +;; definition for method 3 of type mercneric-chain +(defmethod inspect ((this mercneric-chain)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mercneric-chain) + (format #t "~1Tfirst: #x~X~%" (-> this first)) + (format #t "~1Tnext: #x~X~%" (-> this next)) + (format #t "~1Tstate: #~%" (-> this state)) + (format #t "~1Tvu1-bucket: ~D~%" (-> this vu1-bucket)) + (label cfg-4) + this + ) + +;; definition of type merc-chain +(deftype merc-chain (structure) + "A DMA chain for drawing with merc. +This chain is assumed to run with a specific tpage from a specific level available." + ((first dma-packet) + (patch dma-packet) + (vu1-bucket bucket-id) + ) + :pack-me + ) + +;; definition for method 3 of type merc-chain +(defmethod inspect ((this merc-chain)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-chain) + (format #t "~1Tfirst: #~%" (-> this first)) + (format #t "~1Tpatch: #~%" (-> this patch)) + (format #t "~1Tvu1-bucket: ~D~%" (-> this vu1-bucket)) + (label cfg-4) + this + ) + +;; definition of type foreground-bucket +(deftype foreground-bucket (structure) + "A foreground bucket is merc, emerc, and mercneric chain for a given texture mode." + ((merc merc-chain :inline) + (emerc merc-chain :inline) + (mercneric mercneric-chain :inline) + ) + ) + +;; definition for method 3 of type foreground-bucket +(defmethod inspect ((this foreground-bucket)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'foreground-bucket) + (format #t "~1Tmerc: #~%" (-> this merc)) + (format #t "~1Temerc: #~%" (-> this emerc)) + (format #t "~1Tmercneric: #~%" (-> this mercneric)) + (label cfg-4) + this + ) + +;; definition of type foreground-level-buckets +(deftype foreground-level-buckets (structure) + "Collection of buckets for a single level. +Each bucket has a different texture. The order is: +tfrag, pris, shrub, alpha, water, pris, pris2" + ((data foreground-bucket 10 :inline) + ) + ) + +;; definition for method 3 of type foreground-level-buckets +(defmethod inspect ((this foreground-level-buckets)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'foreground-level-buckets) + (format #t "~1Tdata[10] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type foreground-bucket-grid +(deftype foreground-bucket-grid (structure) + "Array of buckets for each level, plus the single warp chain shared between everybody." + ((level-buckets foreground-level-buckets 19 :inline) + (warp-chain mercneric-chain :inline) + ) + ) + +;; definition for method 3 of type foreground-bucket-grid +(defmethod inspect ((this foreground-bucket-grid)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'foreground-bucket-grid) + (format #t "~1Tlevel-buckets[19] @ #x~X~%" (-> this level-buckets)) + (format #t "~1Twarp-chain: #~%" (-> this warp-chain)) + (label cfg-4) + this + ) + +;; definition of type foreground-regs +(deftype foreground-regs (structure) + "Frequently accessed foreground values. These are in scratchpad for fast access +during foreground processing." + ((dist float) + (merc-used uint32) + (emerc-used uint32) + (mercneric-used uint32) + (use-isometric uint32) + (base-start dma-packet) + (joint-ptr (inline-array joint)) + (bone-ptr (inline-array bone)) + (num-bones uint32) + (mtxs (inline-array pris-mtx)) + (dma-buf dma-buffer) + (default-texture-index uint32) + (mercneric-chain mercneric-chain) + (level-buckets foreground-level-buckets) + ) + ) + +;; definition for method 3 of type foreground-regs +(defmethod inspect ((this foreground-regs)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'foreground-regs) + (format #t "~1Tdist: ~f~%" (-> this dist)) + (format #t "~1Tmerc-used: ~D~%" (-> this merc-used)) + (format #t "~1Temerc-used: ~D~%" (-> this emerc-used)) + (format #t "~1Tmercneric-used: ~D~%" (-> this mercneric-used)) + (format #t "~1Tuse-isometric: ~D~%" (-> this use-isometric)) + (format #t "~1Tbase-start: #~%" (-> this base-start)) + (format #t "~1Tjoint-ptr: #x~X~%" (-> this joint-ptr)) + (format #t "~1Tbone-ptr: #x~X~%" (-> this bone-ptr)) + (format #t "~1Tnum-bones: ~D~%" (-> this num-bones)) + (format #t "~1Tmtxs: #x~X~%" (-> this mtxs)) + (format #t "~1Tdma-buf: ~A~%" (-> this dma-buf)) + (format #t "~1Tdefault-texture-index: ~D~%" (-> this default-texture-index)) + (format #t "~1Tmercneric-chain: #~%" (-> this mercneric-chain)) + (format #t "~1Tlevel-buckets: #~%" (-> this level-buckets)) + (label cfg-4) + this + ) + +;; definition of type foreground-work +(deftype foreground-work (structure) + "Memory map for scratchpad during foreground processing. +This is not used by the renderers, bone matrix, or joint code - just the code +that assigns stuff to buckets and prepares DMA for merc (or requests for generic merc)." + ((regs foreground-regs :inline) + (draw-index-map uint8 19 :offset 64) + (grid foreground-bucket-grid :inline) + (bounds sphere :inline) + (lights vu-lights :inline) + (distance vector :inline) + (next-tmpl dma-packet :inline) + ) + ) + +;; definition for method 3 of type foreground-work +(defmethod inspect ((this foreground-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'foreground-work) + (format #t "~1Tregs: #~%" (-> this regs)) + (format #t "~1Tdraw-index-map[19] @ #x~X~%" (-> this draw-index-map)) + (format #t "~1Tgrid: #~%" (-> this grid)) + (format #t "~1Tbounds: #~%" (-> this bounds)) + (format #t "~1Tlights: #~%" (-> this lights)) + (format #t "~1Tdistance: #~%" (-> this distance)) + (format #t "~1Tnext-tmpl: #~%" (-> this next-tmpl)) + (label cfg-4) + this + ) + +;; definition for function invalidate-cache-line +;; ERROR: Unsupported inline assembly instruction kind - [cache dxwbin a0, 0] +;; ERROR: Unsupported inline assembly instruction kind - [cache dxwbin a0, 1] +(defun invalidate-cache-line ((arg0 pointer)) + (.sync.l) + (.cache dxwbin arg0 0) + (.sync.l) + (.cache dxwbin arg0 1) + (.sync.l) + 0 + ) + +;; definition of type texscroll-globals +(deftype texscroll-globals (structure) + "List of all merc-effects that need texscroll applied." + ((requests int32) + (effects merc-effect 32) + ) + ) + +;; definition for method 3 of type texscroll-globals +(defmethod inspect ((this texscroll-globals)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texscroll-globals) + (format #t "~1Trequests: ~D~%" (-> this requests)) + (format #t "~1Teffects[32] @ #x~X~%" (-> this effects)) + (label cfg-4) + this + ) + +;; definition of type merc-effect-bucket-info +(deftype merc-effect-bucket-info (structure) + "Scratch info computed per-merc-effect by the foreground code, then later read by merc +DMA generation. This is only for the currently-processing merc model's effects." + ((color-fade rgba) + (alpha uint8 :offset 3) + (merc-path uint8) + (ignore-alpha uint8) + (disable-draw uint8) + (disable-envmap uint8) + ) + :pack-me + ) + +;; definition for method 3 of type merc-effect-bucket-info +(defmethod inspect ((this merc-effect-bucket-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-effect-bucket-info) + (format #t "~1Tcolor-fade: ~D~%" (-> this color-fade)) + (format #t "~1Tmerc-path: ~D~%" (-> this merc-path)) + (format #t "~1Tignore-alpha: ~D~%" (-> this ignore-alpha)) + (format #t "~1Tdisable-draw: ~D~%" (-> this disable-draw)) + (format #t "~1Tdisable-envmap: ~D~%" (-> this disable-envmap)) + (label cfg-4) + this + ) + +;; definition of type merc-bucket-info +(deftype merc-bucket-info (structure) + "Scratch info for the current merc-ctrl. Written by the foreground code, read by merc DMA generation." + ((light vu-lights :inline) + (needs-clip int32) + (need-mercprime-if-merc int32) + (must-use-mercneric-for-clip int32) + (effect merc-effect-bucket-info 64 :inline) + ) + ) + +;; definition for method 3 of type merc-bucket-info +(defmethod inspect ((this merc-bucket-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-bucket-info) + (format #t "~1Tlight: #~%" (-> this light)) + (format #t "~1Tneeds-clip: ~D~%" (-> this needs-clip)) + (format #t "~1Tneed-mercprime-if-merc: ~D~%" (-> this need-mercprime-if-merc)) + (format #t "~1Tmust-use-mercneric-for-clip: ~D~%" (-> this must-use-mercneric-for-clip)) + (format #t "~1Teffect[64] @ #x~X~%" (-> this effect)) + (label cfg-4) + this + ) + +;; definition of type foreground-globals +(deftype foreground-globals (structure) + "The foreground renderer state: all DMA chains, settings for the current merc-ctrl, texscroll list." + ((foreground-grid foreground-bucket-grid :inline) + (merc-bucket-info merc-bucket-info :inline) + (texscroll texscroll-globals :inline) + ) + ) + +;; definition for method 3 of type foreground-globals +(defmethod inspect ((this foreground-globals)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'foreground-globals) + (format #t "~1Tforeground-grid: #~%" (-> this foreground-grid)) + (format #t "~1Tmerc-bucket-info: #~%" (-> this merc-bucket-info)) + (format #t "~1Ttexscroll: #~%" (-> this texscroll)) + (label cfg-4) + this + ) + +;; definition of type shadow-dma-packet +(deftype shadow-dma-packet (structure) + "DMA tag for submitting shadow data." + ((tag generic-merc-tag :inline) + (settings shadow-settings :inline) + (geo-ref dma-packet :inline) + (mtx-ref dma-packet :inline) + (end-tag dma-packet :inline) + ) + ) + +;; definition for method 3 of type shadow-dma-packet +(defmethod inspect ((this shadow-dma-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-dma-packet) + (format #t "~1Ttag: #~%" (-> this tag)) + (format #t "~1Tsettings: #~%" (-> this settings)) + (format #t "~1Tgeo-ref: #~%" (-> this geo-ref)) + (format #t "~1Tmtx-ref: #~%" (-> this mtx-ref)) + (format #t "~1Tend-tag: #~%" (-> this end-tag)) + (label cfg-4) + this + ) + +;; definition for symbol *bucket-map*, type (pointer bucket-id-16) +(define *bucket-map* (new 'static 'array bucket-id-16 462 + (bucket-id-16 tfrag-scissor-l0-tfrag) + (bucket-id-16 tie-scissor-l0-tfrag) + (bucket-id-16 etie-scissor-l0-tfrag) + (bucket-id-16 bucket7) + (bucket-id-16 emerc-l0-tfrag) + (bucket-id-16 bucket0) + (bucket-id-16 etie-l1-tfrag) + (bucket-id-16 tfrag-scissor-l1-tfrag) + (bucket-id-16 tie-scissor-l1-tfrag) + (bucket-id-16 bucket7) + (bucket-id-16 merc-l1-tfrag) + (bucket-id-16 bucket6) + (bucket-id-16 merc-l5-water) + (bucket-id-16 gmerc-l5-water) + (bucket-id-16 tfrag-l5-water) + (bucket-id-16 tex-l5-water) + (bucket-id-16 tie-l5-water) + (bucket-id-16 emerc-l4-tfrag) + (bucket-id-16 etie-l5-water) + (bucket-id-16 tie-scissor-l5-water) + (bucket-id-16 tfrag-scissor-l5-water) + (bucket-id-16 tex-l5-water) + (bucket-id-16 etie-scissor-l5-water) + (bucket-id-16 etie-l5-tfrag) + (bucket-id-16 shrub-l2-shrub) + (bucket-id-16 shrub-near-l2-shrub) + (bucket-id-16 billboard-l2-shrub) + (bucket-id-16 shrub-near-trans-l1-shrub) + (bucket-id-16 shrub-vanish-l2-shrub) + (bucket-id-16 tie-l0-tfrag) + (bucket-id-16 tex-l3-shrub) + (bucket-id-16 shrub-l3-shrub) + (bucket-id-16 shrub-near-l3-shrub) + (bucket-id-16 shrub-near-trans-l1-shrub) + (bucket-id-16 billboard-l3-shrub) + (bucket-id-16 emerc-l0-tfrag) + (bucket-id-16 tex-l3-alpha) + (bucket-id-16 tfrag-l3-alpha) + (bucket-id-16 tie-l3-alpha) + (bucket-id-16 tfrag-scissor-l2-alpha) + (bucket-id-16 gmerc-l3-alpha) + (bucket-id-16 tie-l1-tfrag) + (bucket-id-16 gmerc2-l3-alpha) + (bucket-id-16 tex-l4-alpha) + (bucket-id-16 tfrag-l4-alpha) + (bucket-id-16 tfrag-scissor-l2-alpha) + (bucket-id-16 emerc-l4-alpha) + (bucket-id-16 emerc-l1-tfrag) + (bucket-id-16 bucket634) + (bucket-id-16 bucket634) + (bucket-id-16 bucket635) + (bucket-id-16 bucket633) + (bucket-id-16 bucket642) + (bucket-id-16 tex-l7-tfrag) + (bucket-id-16 bucket643) + (bucket-id-16 bucket643) + (bucket-id-16 bucket644) + (bucket-id-16 bucket633) + (bucket-id-16 bucket651) + (bucket-id-16 merc-l7-tfrag) + (bucket-id-16 merc-l5-water) + (bucket-id-16 gmerc-l5-water) + (bucket-id-16 tfrag-l5-water) + (bucket-id-16 tex-l5-water) + (bucket-id-16 tie-l5-water) + (bucket-id-16 emerc-l4-tfrag) + (bucket-id-16 etie-l5-water) + (bucket-id-16 tie-scissor-l5-water) + (bucket-id-16 tfrag-scissor-l5-water) + (bucket-id-16 tex-l5-water) + (bucket-id-16 etie-scissor-l5-water) + (bucket-id-16 etie-l5-tfrag) + (bucket-id-16 debug-no-zbuf1) + (bucket-id-16 tex-hud-hud-alpha) + (bucket-id-16 hud-draw-hud-alpha) + (bucket-id-16 generic-warp) + (bucket-id-16 tex-hud-pris2) + (bucket-id-16 tie-vanish-l5-tfrag) + (bucket-id-16 hud-draw-pris2) + (bucket-id-16 bucket582) + (bucket-id-16 debug) + (bucket-id-16 generic-warp) + (bucket-id-16 debug-no-zbuf2) + (bucket-id-16 tie-scissor-l6-tfrag) + (bucket-id-16 debug-no-zbuf1) + (bucket-id-16 tex-hud-hud-alpha) + (bucket-id-16 hud-draw-hud-alpha) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket768) + (bucket-id-16 tie-l8-tfrag) + (bucket-id-16 hud-draw-pris2) + (bucket-id-16 bucket582) + (bucket-id-16 debug) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket771) + (bucket-id-16 etie-l8-tfrag) + (bucket-id-16 debug-no-zbuf1) + (bucket-id-16 tex-hud-hud-alpha) + (bucket-id-16 hud-draw-hud-alpha) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket770) + (bucket-id-16 tfrag-scissor-l8-tfrag) + (bucket-id-16 hud-draw-pris2) + (bucket-id-16 bucket582) + (bucket-id-16 debug) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket773) + (bucket-id-16 tie-scissor-l8-tfrag) + (bucket-id-16 debug-no-zbuf1) + (bucket-id-16 tex-hud-hud-alpha) + (bucket-id-16 hud-draw-hud-alpha) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 hud-draw-pris2) + (bucket-id-16 bucket582) + (bucket-id-16 debug) + (bucket-id-16 generic-warp) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 etie-l2-tfrag) + (bucket-id-16 tfrag-scissor-l2-tfrag) + (bucket-id-16 tie-scissor-l2-tfrag) + (bucket-id-16 emerc-l1-tfrag) + (bucket-id-16 merc-l2-tfrag) + (bucket-id-16 bucket1) + (bucket-id-16 tie-l3-tfrag) + (bucket-id-16 etie-l3-tfrag) + (bucket-id-16 tfrag-scissor-l3-tfrag) + (bucket-id-16 emerc-l1-tfrag) + (bucket-id-16 etie-scissor-l3-tfrag) + (bucket-id-16 bucket7) + (bucket-id-16 tex-l6-water) + (bucket-id-16 merc-l6-water) + (bucket-id-16 gmerc-l6-water) + (bucket-id-16 gmerc2-l5-water) + (bucket-id-16 tfrag-l6-water) + (bucket-id-16 gmerc-l4-tfrag) + (bucket-id-16 tie-l6-water) + (bucket-id-16 etie-l6-water) + (bucket-id-16 tie-scissor-l6-water) + (bucket-id-16 gmerc2-l5-water) + (bucket-id-16 tfrag-scissor-l6-water) + (bucket-id-16 tfrag-scissor-l5-tfrag) + (bucket-id-16 tex-l4-shrub) + (bucket-id-16 shrub-l4-shrub) + (bucket-id-16 shrub-near-l4-shrub) + (bucket-id-16 shrub-vanish-l3-shrub) + (bucket-id-16 billboard-l4-shrub) + (bucket-id-16 etie-l0-tfrag) + (bucket-id-16 gmerc2-l4-shrub) + (bucket-id-16 tex-l5-shrub) + (bucket-id-16 shrub-l5-shrub) + (bucket-id-16 shrub-vanish-l3-shrub) + (bucket-id-16 shrub-near-l5-shrub) + (bucket-id-16 gmerc-l0-tfrag) + (bucket-id-16 gmerc2-l4-alpha) + (bucket-id-16 tex-l5-alpha) + (bucket-id-16 tfrag-l5-alpha) + (bucket-id-16 gmerc-l4-alpha) + (bucket-id-16 emerc-l5-alpha) + (bucket-id-16 etie-l1-tfrag) + (bucket-id-16 etie-scissor-l5-alpha) + (bucket-id-16 gmerc2-l5-alpha) + (bucket-id-16 tex-l6-alpha) + (bucket-id-16 gmerc-l4-alpha) + (bucket-id-16 merc-l6-alpha) + (bucket-id-16 gmerc-l1-tfrag) + (bucket-id-16 bucket653) + (bucket-id-16 bucket653) + (bucket-id-16 bucket654) + (bucket-id-16 bucket652) + (bucket-id-16 bucket661) + (bucket-id-16 tfrag-l7-tfrag) + (bucket-id-16 bucket662) + (bucket-id-16 bucket662) + (bucket-id-16 bucket663) + (bucket-id-16 bucket652) + (bucket-id-16 bucket670) + (bucket-id-16 emerc-l7-tfrag) + (bucket-id-16 tex-l6-water) + (bucket-id-16 merc-l6-water) + (bucket-id-16 gmerc-l6-water) + (bucket-id-16 gmerc2-l5-water) + (bucket-id-16 tfrag-l6-water) + (bucket-id-16 gmerc-l4-tfrag) + (bucket-id-16 tie-l6-water) + (bucket-id-16 etie-l6-water) + (bucket-id-16 tie-scissor-l6-water) + (bucket-id-16 gmerc2-l5-water) + (bucket-id-16 tfrag-scissor-l6-water) + (bucket-id-16 tfrag-scissor-l5-tfrag) + (bucket-id-16 bucket586) + (bucket-id-16 bucket587) + (bucket-id-16 bucket588) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket589) + (bucket-id-16 gmerc2-l5-tfrag) + (bucket-id-16 bucket590) + (bucket-id-16 bucket591) + (bucket-id-16 bucket592) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket593) + (bucket-id-16 etie-scissor-l6-tfrag) + (bucket-id-16 bucket586) + (bucket-id-16 bucket587) + (bucket-id-16 bucket588) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket768) + (bucket-id-16 tie-l8-tfrag) + (bucket-id-16 bucket590) + (bucket-id-16 bucket591) + (bucket-id-16 bucket592) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket771) + (bucket-id-16 etie-l8-tfrag) + (bucket-id-16 bucket586) + (bucket-id-16 bucket587) + (bucket-id-16 bucket588) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket770) + (bucket-id-16 tfrag-scissor-l8-tfrag) + (bucket-id-16 bucket590) + (bucket-id-16 bucket591) + (bucket-id-16 bucket592) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket773) + (bucket-id-16 tie-scissor-l8-tfrag) + (bucket-id-16 bucket586) + (bucket-id-16 bucket587) + (bucket-id-16 bucket588) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 bucket590) + (bucket-id-16 bucket591) + (bucket-id-16 bucket592) + (bucket-id-16 debug-menu) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 tie-l4-tfrag) + (bucket-id-16 etie-l4-tfrag) + (bucket-id-16 tfrag-scissor-l4-tfrag) + (bucket-id-16 merc-l3-tfrag) + (bucket-id-16 etie-scissor-l4-tfrag) + (bucket-id-16 bucket2) + (bucket-id-16 tfrag-l5-tfrag) + (bucket-id-16 tie-l5-tfrag) + (bucket-id-16 etie-l5-tfrag) + (bucket-id-16 merc-l3-tfrag) + (bucket-id-16 tie-scissor-l5-tfrag) + (bucket-id-16 hfrag) + (bucket-id-16 gmerc2-l6-water) + (bucket-id-16 tex-l7-water) + (bucket-id-16 merc-l7-water) + (bucket-id-16 etie-scissor-l6-water) + (bucket-id-16 gmerc-l7-water) + (bucket-id-16 tie-vanish-l4-tfrag) + (bucket-id-16 tfrag-l7-water) + (bucket-id-16 tie-l7-water) + (bucket-id-16 etie-l7-water) + (bucket-id-16 etie-scissor-l6-water) + (bucket-id-16 tie-scissor-l7-water) + (bucket-id-16 tie-scissor-l5-tfrag) + (bucket-id-16 gmerc2-l5-shrub) + (bucket-id-16 tex-l6-shrub) + (bucket-id-16 shrub-l6-shrub) + (bucket-id-16 billboard-l5-shrub) + (bucket-id-16 shrub-near-l6-shrub) + (bucket-id-16 tfrag-scissor-l0-tfrag) + (bucket-id-16 gmerc-l6-shrub) + (bucket-id-16 gmerc2-l6-shrub) + (bucket-id-16 tex-l7-shrub) + (bucket-id-16 billboard-l5-shrub) + (bucket-id-16 shrub-l7-shrub) + (bucket-id-16 tie-vanish-l0-tfrag) + (bucket-id-16 etie-scissor-l6-alpha) + (bucket-id-16 gmerc2-l6-alpha) + (bucket-id-16 tex-l7-alpha) + (bucket-id-16 emerc-l6-alpha) + (bucket-id-16 merc-l7-alpha) + (bucket-id-16 tfrag-scissor-l1-tfrag) + (bucket-id-16 tie-scissor-l7-alpha) + (bucket-id-16 etie-scissor-l7-alpha) + (bucket-id-16 gmerc2-l7-alpha) + (bucket-id-16 emerc-l6-alpha) + (bucket-id-16 etie-l8-alpha) + (bucket-id-16 tie-vanish-l1-tfrag) + (bucket-id-16 bucket672) + (bucket-id-16 bucket672) + (bucket-id-16 bucket673) + (bucket-id-16 bucket671) + (bucket-id-16 bucket680) + (bucket-id-16 tie-l7-tfrag) + (bucket-id-16 bucket681) + (bucket-id-16 bucket681) + (bucket-id-16 bucket682) + (bucket-id-16 bucket671) + (bucket-id-16 bucket689) + (bucket-id-16 gmerc-l7-tfrag) + (bucket-id-16 gmerc2-l6-water) + (bucket-id-16 tex-l7-water) + (bucket-id-16 merc-l7-water) + (bucket-id-16 etie-scissor-l6-water) + (bucket-id-16 gmerc-l7-water) + (bucket-id-16 tie-vanish-l4-tfrag) + (bucket-id-16 tfrag-l7-water) + (bucket-id-16 tie-l7-water) + (bucket-id-16 etie-l7-water) + (bucket-id-16 etie-scissor-l6-water) + (bucket-id-16 tie-scissor-l7-water) + (bucket-id-16 tie-scissor-l5-tfrag) + (bucket-id-16 bucket595) + (bucket-id-16 bucket596) + (bucket-id-16 bucket597) + (bucket-id-16 bucket594) + (bucket-id-16 bucket598) + (bucket-id-16 tex-l6-tfrag) + (bucket-id-16 bucket599) + (bucket-id-16 bucket600) + (bucket-id-16 bucket601) + (bucket-id-16 bucket594) + (bucket-id-16 bucket602) + (bucket-id-16 merc-l6-tfrag) + (bucket-id-16 bucket595) + (bucket-id-16 bucket596) + (bucket-id-16 bucket597) + (bucket-id-16 bucket594) + (bucket-id-16 bucket768) + (bucket-id-16 tie-l8-tfrag) + (bucket-id-16 bucket599) + (bucket-id-16 bucket600) + (bucket-id-16 bucket601) + (bucket-id-16 bucket594) + (bucket-id-16 bucket771) + (bucket-id-16 etie-l8-tfrag) + (bucket-id-16 bucket595) + (bucket-id-16 bucket596) + (bucket-id-16 bucket597) + (bucket-id-16 bucket594) + (bucket-id-16 bucket770) + (bucket-id-16 tfrag-scissor-l8-tfrag) + (bucket-id-16 bucket599) + (bucket-id-16 bucket600) + (bucket-id-16 bucket601) + (bucket-id-16 bucket594) + (bucket-id-16 bucket773) + (bucket-id-16 tie-scissor-l8-tfrag) + (bucket-id-16 bucket595) + (bucket-id-16 bucket596) + (bucket-id-16 bucket597) + (bucket-id-16 bucket594) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 bucket599) + (bucket-id-16 bucket600) + (bucket-id-16 bucket601) + (bucket-id-16 bucket594) + (bucket-id-16 bucket788) + (bucket-id-16 merc-l8-tfrag) + (bucket-id-16 tfrag-l6-tfrag) + (bucket-id-16 tie-l6-tfrag) + (bucket-id-16 etie-l6-tfrag) + (bucket-id-16 etie-scissor-l5-tfrag) + (bucket-id-16 tie-scissor-l6-tfrag) + (bucket-id-16 blit) + (bucket-id-16 tex-l7-tfrag) + (bucket-id-16 tfrag-l7-tfrag) + (bucket-id-16 tie-l7-tfrag) + (bucket-id-16 etie-scissor-l5-tfrag) + (bucket-id-16 tfrag-scissor-l7-tfrag) + (bucket-id-16 hfrag-scissor) + (bucket-id-16 etie-scissor-l7-water) + (bucket-id-16 gmerc2-l7-water) + (bucket-id-16 tex-l8-water) + (bucket-id-16 tfrag-scissor-l7-water) + (bucket-id-16 merc-l8-water) + (bucket-id-16 gmerc2-l4-tfrag) + (bucket-id-16 gmerc-l8-water) + (bucket-id-16 tfrag-l8-water) + (bucket-id-16 tie-l8-water) + (bucket-id-16 tfrag-scissor-l7-water) + (bucket-id-16 etie-l8-water) + (bucket-id-16 etie-scissor-l5-tfrag) + (bucket-id-16 gmerc-l7-shrub) + (bucket-id-16 gmerc2-l7-shrub) + (bucket-id-16 tex-l8-shrub) + (bucket-id-16 shrub-near-l7-shrub) + (bucket-id-16 shrub-l8-shrub) + (bucket-id-16 tie-scissor-l0-tfrag) + (bucket-id-16 emerc-l8-shrub) + (bucket-id-16 gmerc-l8-shrub) + (bucket-id-16 gmerc2-l8-shrub) + (bucket-id-16 shrub-near-l7-shrub) + (bucket-id-16 tex-l9-shrub) + (bucket-id-16 gmerc2-l0-tfrag) + (bucket-id-16 tie-scissor-l8-alpha) + (bucket-id-16 etie-scissor-l8-alpha) + (bucket-id-16 gmerc2-l8-alpha) + (bucket-id-16 merc-l8-alpha) + (bucket-id-16 etie-l9-alpha) + (bucket-id-16 tie-scissor-l1-tfrag) + (bucket-id-16 tfrag-scissor-l9-alpha) + (bucket-id-16 tie-scissor-l9-alpha) + (bucket-id-16 etie-scissor-l9-alpha) + (bucket-id-16 merc-l8-alpha) + (bucket-id-16 emerc-lcom-tfrag) + (bucket-id-16 gmerc2-l1-tfrag) + (bucket-id-16 bucket691) + (bucket-id-16 bucket691) + (bucket-id-16 bucket692) + (bucket-id-16 bucket690) + (bucket-id-16 bucket699) + (bucket-id-16 etie-l7-tfrag) + (bucket-id-16 bucket700) + (bucket-id-16 bucket700) + (bucket-id-16 bucket701) + (bucket-id-16 bucket690) + (bucket-id-16 bucket708) + (bucket-id-16 tie-vanish-l7-tfrag) + (bucket-id-16 etie-scissor-l7-water) + (bucket-id-16 gmerc2-l7-water) + (bucket-id-16 tex-l8-water) + (bucket-id-16 tfrag-scissor-l7-water) + (bucket-id-16 merc-l8-water) + (bucket-id-16 gmerc2-l4-tfrag) + (bucket-id-16 gmerc-l8-water) + (bucket-id-16 tfrag-l8-water) + (bucket-id-16 tie-l8-water) + (bucket-id-16 tfrag-scissor-l7-water) + (bucket-id-16 etie-l8-water) + (bucket-id-16 etie-scissor-l5-tfrag) + (bucket-id-16 bucket604) + (bucket-id-16 bucket605) + (bucket-id-16 bucket606) + (bucket-id-16 bucket603) + (bucket-id-16 bucket607) + (bucket-id-16 tfrag-l6-tfrag) + (bucket-id-16 bucket608) + (bucket-id-16 bucket609) + (bucket-id-16 bucket610) + (bucket-id-16 bucket603) + (bucket-id-16 bucket611) + (bucket-id-16 emerc-l6-tfrag) + (bucket-id-16 bucket604) + (bucket-id-16 bucket605) + (bucket-id-16 bucket606) + (bucket-id-16 bucket603) + (bucket-id-16 bucket768) + (bucket-id-16 tie-l8-tfrag) + (bucket-id-16 bucket608) + (bucket-id-16 bucket609) + (bucket-id-16 bucket610) + (bucket-id-16 bucket603) + (bucket-id-16 bucket771) + (bucket-id-16 etie-l8-tfrag) + (bucket-id-16 bucket604) + (bucket-id-16 bucket605) + (bucket-id-16 bucket606) + (bucket-id-16 bucket603) + (bucket-id-16 bucket770) + (bucket-id-16 tfrag-scissor-l8-tfrag) + ) + ) + +;; definition for function vu1-bucket-map +(defun vu1-bucket-map ((arg0 int) (arg1 int) (arg2 int) (arg3 merc-mode)) + (-> *bucket-map* (+ (+ (* 120 arg0) (* 12 arg1) (* 6 arg2)) (the-as int arg3))) + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/foreground/lights-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/foreground/lights-h_REF.gc new file mode 100644 index 0000000000..4df1a035bc --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/foreground/lights-h_REF.gc @@ -0,0 +1,228 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type vu-lights +(deftype vu-lights (structure) + ((direction vector 3 :inline) + (color vector 3 :inline) + (ambient vector :inline) + (fade-int uint32 :offset 44) + (fade-flags uint32 :offset 28) + ) + ) + +;; definition for method 3 of type vu-lights +(defmethod inspect ((this vu-lights)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'vu-lights) + (format #t "~1Tdirection[3] @ #x~X~%" (-> this direction)) + (format #t "~1Tcolor[3] @ #x~X~%" (-> this color)) + (format #t "~1Tambient: ~`vector`P~%" (-> this ambient)) + (label cfg-4) + this + ) + +;; definition of type light +(deftype light (structure) + "extra: {?, shadow, ?, ?}" + ((direction vector :inline) + (color rgbaf :inline) + (extra vector :inline) + (level float :overlay-at (-> extra data 0)) + (luminance float :overlay-at (-> extra data 2)) + (priority float :overlay-at (-> extra data 3)) + (bytes uint8 4 :overlay-at (-> extra data 1)) + (mask uint16 :overlay-at (-> extra data 1)) + (palette-index int8 :overlay-at (-> bytes 3)) + ) + ) + +;; definition for method 3 of type light +(defmethod inspect ((this light)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'light) + (format #t "~1Tdirection: #~%" (-> this direction)) + (format #t "~1Tcolor: #~%" (-> this color)) + (format #t "~1Textra: #~%" (-> this extra)) + (format #t "~1Tlevel: ~f~%" (-> this extra x)) + (format #t "~1Tluminance: ~f~%" (-> this extra z)) + (format #t "~1Tpriority: ~f~%" (-> this extra w)) + (format #t "~1Tbytes[4] @ #x~X~%" (&-> this extra y)) + (format #t "~1Tmask: ~D~%" (-> this mask)) + (format #t "~1Tpalette-index: ~D~%" (-> this palette-index)) + (label cfg-4) + this + ) + +;; definition of type light-shadow-mask +(deftype light-shadow-mask (uint32) + () + ) + +;; definition of type light-sphere +(deftype light-sphere (structure) + ((name string) + (bsphere vector :inline) + (direction vector :inline) + (color vector :inline) + (decay-start float :offset 4) + (ambient-point-ratio float :offset 8) + (brightness float :offset 12) + (bytes uint8 4 :overlay-at (-> color data 3)) + (mask uint16 :overlay-at (-> color data 3)) + (palette-index int8 :overlay-at (-> bytes 3)) + (shadow uint32 :overlay-at (-> direction data 0)) + ) + ) + +;; definition for method 3 of type light-sphere +(defmethod inspect ((this light-sphere)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'light-sphere) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tdirection: ~`vector`P~%" (&-> this shadow)) + (format #t "~1Tcolor: ~`vector`P~%" (-> this color)) + (format #t "~1Tdecay-start: ~f~%" (-> this decay-start)) + (format #t "~1Tambient-point-ratio: ~f~%" (-> this ambient-point-ratio)) + (format #t "~1Tbrightness: ~f~%" (-> this brightness)) + (format #t "~1Tbytes[4] @ #x~X~%" (&-> this color w)) + (format #t "~1Tmask: ~D~%" (-> this mask)) + (format #t "~1Tpalette-index: ~D~%" (-> this palette-index)) + (format #t "~1Tshadow: #x~X~%" (-> this shadow)) + (label cfg-4) + this + ) + +;; definition of type light-hash-bucket +(deftype light-hash-bucket (structure) + ((index uint16) + (count uint16) + ) + :pack-me + ) + +;; definition for method 3 of type light-hash-bucket +(defmethod inspect ((this light-hash-bucket)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'light-hash-bucket) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tcount: ~D~%" (-> this count)) + (label cfg-4) + this + ) + +;; definition of type light-hash +(deftype light-hash (basic) + ((num-lights uint16) + (num-indices uint16) + (num-buckets uint16) + (bucket-step uint8 2) + (base-trans vector :inline) + (axis-scale vector :inline) + (dimension-array vector4w :inline) + (bucket-array (inline-array light-hash-bucket)) + (index-array pointer) + (light-sphere-array (inline-array light-sphere)) + ) + ) + +;; definition for method 3 of type light-hash +(defmethod inspect ((this light-hash)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tnum-lights: ~D~%" (-> this num-lights)) + (format #t "~1Tnum-indices: ~D~%" (-> this num-indices)) + (format #t "~1Tnum-buckets: ~D~%" (-> this num-buckets)) + (format #t "~1Tbucket-step[2] @ #x~X~%" (-> this bucket-step)) + (format #t "~1Tbase-trans: #~%" (-> this base-trans)) + (format #t "~1Taxis-scale: #~%" (-> this axis-scale)) + (format #t "~1Tdimension-array: #~%" (-> this dimension-array)) + (format #t "~1Tbucket-array: #x~X~%" (-> this bucket-array)) + (format #t "~1Tindex-array: #x~X~%" (-> this index-array)) + (format #t "~1Tlight-sphere-array: #x~X~%" (-> this light-sphere-array)) + (label cfg-4) + this + ) + +;; definition of type light-hash-work +(deftype light-hash-work (structure) + ((ones vector4w :inline) + ) + ) + +;; definition for method 3 of type light-hash-work +(defmethod inspect ((this light-hash-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'light-hash-work) + (format #t "~1Tones: #~%" (-> this ones)) + (label cfg-4) + this + ) + +;; definition for symbol *light-hash*, type light-hash +(define *light-hash* (the-as light-hash #f)) + +;; definition for method 2 of type light +(defmethod print ((this light)) + (format + #t + "# this extra x) + (-> this direction x) + (-> this direction y) + (-> this direction z) + ) + (format #t "~F ~F ~F @ #x~X>" (-> this color x) (-> this color y) (-> this color z) this) + this + ) + +;; definition of type light-group +(deftype light-group (structure) + ((dir0 light :inline) + (dir1 light :inline) + (dir2 light :inline) + (ambi light :inline) + (lights light 4 :inline :overlay-at dir0) + ) + ) + +;; definition for method 3 of type light-group +(defmethod inspect ((this light-group)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'light-group) + (format #t "~1Tdir0: ~`light`P~%" (-> this dir0)) + (format #t "~1Tdir1: ~`light`P~%" (-> this dir1)) + (format #t "~1Tdir2: ~`light`P~%" (-> this dir2)) + (format #t "~1Tambi: ~`light`P~%" (-> this ambi)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/foreground/merc/generic-merc-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/foreground/merc/generic-merc-h_REF.gc new file mode 100644 index 0000000000..e8043fac1b --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/foreground/merc/generic-merc-h_REF.gc @@ -0,0 +1,286 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type merc-matrix +(deftype merc-matrix (structure) + ((quad uint128 8) + (vector vector 8 :inline :overlay-at (-> quad 0)) + (tag uint64 :overlay-at (-> quad 0)) + ) + ) + +;; definition for method 3 of type merc-matrix +(defmethod inspect ((this merc-matrix)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-matrix) + (format #t "~1Tquad[8] @ #x~X~%" (-> this vector)) + (format #t "~1Tvector[8] @ #x~X~%" (-> this vector)) + (format #t "~1Ttag: ~D~%" (-> this tag)) + (label cfg-4) + this + ) + +;; definition of type generic-merc-tag +(deftype generic-merc-tag (dma-packet) + ((next-ptr uint32 :overlay-at vif1) + (size uint32 :overlay-at vif0) + ) + ) + +;; definition for method 3 of type generic-merc-tag +;; INFO: Used lq/sq +(defmethod inspect ((this generic-merc-tag)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-merc-tag) + (format #t "~1Tdma: #x~X~%" (-> this dma)) + (format #t "~1Tvif0: #x~X~%" (-> this vif0)) + (format #t "~1Tvif1: #x~X~%" (-> this vif1)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Tnext-ptr: ~D~%" (-> this vif1)) + (format #t "~1Tsize: ~D~%" (-> this vif0)) + (label cfg-4) + this + ) + +;; definition of type generic-merc-ctrl +(deftype generic-merc-ctrl (structure) + ((tag generic-merc-tag :inline) + (lights vu-lights :inline) + (header merc-ctrl-header :inline) + (effect merc-effect :inline) + ) + ) + +;; definition for method 3 of type generic-merc-ctrl +(defmethod inspect ((this generic-merc-ctrl)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-merc-ctrl) + (format #t "~1Ttag: #~%" (-> this tag)) + (format #t "~1Tlights: #~%" (-> this lights)) + (format #t "~1Theader: #~%" (-> this header)) + (format #t "~1Teffect: #~%" (-> this effect)) + (label cfg-4) + this + ) + +;; definition of type generic-merc-ctrl-with-sfx +(deftype generic-merc-ctrl-with-sfx (generic-merc-ctrl) + ((sfx-data uint128 11) + ) + ) + +;; definition for method 3 of type generic-merc-ctrl-with-sfx +(defmethod inspect ((this generic-merc-ctrl-with-sfx)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-merc-ctrl-with-sfx) + (format #t "~1Ttag: #~%" (-> this tag)) + (format #t "~1Tlights: #~%" (-> this lights)) + (format #t "~1Theader: #~%" (-> this header)) + (format #t "~1Teffect: #~%" (-> this effect)) + (format #t "~1Tsfx-data[11] @ #x~X~%" (-> this sfx-data)) + (label cfg-4) + this + ) + +;; definition of type generic-merc-input +(deftype generic-merc-input (structure) + ((geo-tag generic-merc-tag :inline) + (geo-block uint8 1296) + (byte-header merc-byte-header :inline :overlay-at (-> geo-block 0)) + (matrix merc-matrix 9 :inline) + (control generic-merc-ctrl-with-sfx :inline) + (end-tag generic-merc-tag :inline) + (shader adgif-shader :inline) + ) + ) + +;; definition for method 3 of type generic-merc-input +(defmethod inspect ((this generic-merc-input)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-merc-input) + (format #t "~1Tgeo-tag: #~%" (-> this geo-tag)) + (format #t "~1Tgeo-block[1296] @ #x~X~%" (-> this geo-block)) + (format #t "~1Tbyte-header: #~%" (-> this geo-block)) + (format #t "~1Tmatrix[9] @ #x~X~%" (-> this matrix)) + (format #t "~1Tcontrol: #~%" (-> this control)) + (format #t "~1Tend-tag: #~%" (-> this end-tag)) + (format #t "~1Tshader: #~%" (-> this shader)) + (label cfg-4) + this + ) + +;; definition of type generic-merc-output +(deftype generic-merc-output (structure) + ((info gsf-info :inline) + (header gsf-header :inline) + (index-kick-table uint16 80) + (index-table uint8 160 :overlay-at (-> index-kick-table 0)) + (inverse-table uint8 256) + (vertex-table gsf-vertex 72 :inline) + ) + ) + +;; definition for method 3 of type generic-merc-output +(defmethod inspect ((this generic-merc-output)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-merc-output) + (format #t "~1Tinfo: #~%" (-> this info)) + (format #t "~1Theader: #~%" (-> this header)) + (format #t "~1Tindex-kick-table[80] @ #x~X~%" (-> this index-kick-table)) + (format #t "~1Tindex-table[160] @ #x~X~%" (-> this index-kick-table)) + (format #t "~1Tinverse-table[256] @ #x~X~%" (-> this inverse-table)) + (format #t "~1Tvertex-table[72] @ #x~X~%" (-> this vertex-table)) + (label cfg-4) + this + ) + +;; definition of type generic-merc-dcache +(deftype generic-merc-dcache (structure) + ((output-a generic-merc-output :inline) + (output-b generic-merc-output :inline) + (inv-table-1 uint8 544) + (inv-table-7 uint8 544) + (inv-safety uint8 16) + (effect-data uint8 1584) + ) + ) + +;; definition for method 3 of type generic-merc-dcache +(defmethod inspect ((this generic-merc-dcache)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-merc-dcache) + (format #t "~1Toutput-a: #~%" (-> this output-a)) + (format #t "~1Toutput-b: #~%" (-> this output-b)) + (format #t "~1Tinv-table-1[544] @ #x~X~%" (-> this inv-table-1)) + (format #t "~1Tinv-table-7[544] @ #x~X~%" (-> this inv-table-7)) + (format #t "~1Tinv-safety[16] @ #x~X~%" (-> this inv-safety)) + (format #t "~1Teffect-data[1584] @ #x~X~%" (-> this effect-data)) + (label cfg-4) + this + ) + +;; definition of type gm-shadow +(deftype gm-shadow (structure) + ((perspective matrix :inline) + (isometric matrix :inline) + (inv-camera-rot matrix :inline) + (envmap-shader adgif-shader :inline) + (current-chain uint32) + (next-chain uint32) + (buf-index uint32) + (fragment-count uint32) + (write-limit int32) + (indexed-input-base generic-merc-input) + (other-input-base generic-merc-input) + (indexed-output-base generic-merc-output) + (other-output-base generic-merc-output) + (p-input uint32) + (gsf-buf generic-merc-dcache) + (p-fheader merc-fp-header) + (curr-chain basic) + (mercneric-convert basic) + (generic-prepare-dma-single basic) + (generic-prepare-dma-double basic) + (generic-light-proc basic) + (generic-envmap-proc basic) + (high-speed-reject basic) + (dummy-0 uint32) + (hsr-xmult vector :inline) + (hsr-ymult vector :inline) + (warp-consts vector :inline) + (warp-nums vector :inline) + ) + ) + +;; definition for method 3 of type gm-shadow +(defmethod inspect ((this gm-shadow)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gm-shadow) + (format #t "~1Tperspective: #~%" (-> this perspective)) + (format #t "~1Tisometric: #~%" (-> this isometric)) + (format #t "~1Tinv-camera-rot: #~%" (-> this inv-camera-rot)) + (format #t "~1Tenvmap-shader: #~%" (-> this envmap-shader)) + (format #t "~1Tcurrent-chain: ~D~%" (-> this current-chain)) + (format #t "~1Tnext-chain: ~D~%" (-> this next-chain)) + (format #t "~1Tbuf-index: ~D~%" (-> this buf-index)) + (format #t "~1Tfragment-count: ~D~%" (-> this fragment-count)) + (format #t "~1Twrite-limit: ~D~%" (-> this write-limit)) + (format #t "~1Tindexed-input-base: #~%" (-> this indexed-input-base)) + (format #t "~1Tother-input-base: #~%" (-> this other-input-base)) + (format #t "~1Tindexed-output-base: #~%" (-> this indexed-output-base)) + (format #t "~1Tother-output-base: #~%" (-> this other-output-base)) + (format #t "~1Tp-input: #x~X~%" (-> this p-input)) + (format #t "~1Tgsf-buf: #~%" (-> this gsf-buf)) + (format #t "~1Tp-fheader: #~%" (-> this p-fheader)) + (format #t "~1Tcurr-chain: ~A~%" (-> this curr-chain)) + (format #t "~1Tmercneric-convert: ~A~%" (-> this mercneric-convert)) + (format #t "~1Tgeneric-prepare-dma-single: ~A~%" (-> this generic-prepare-dma-single)) + (format #t "~1Tgeneric-prepare-dma-double: ~A~%" (-> this generic-prepare-dma-double)) + (format #t "~1Tgeneric-light-proc: ~A~%" (-> this generic-light-proc)) + (format #t "~1Tgeneric-envmap-proc: ~A~%" (-> this generic-envmap-proc)) + (format #t "~1Thigh-speed-reject: ~A~%" (-> this high-speed-reject)) + (format #t "~1Tdummy-0: ~D~%" (-> this dummy-0)) + (format #t "~1Thsr-xmult: #~%" (-> this hsr-xmult)) + (format #t "~1Thsr-ymult: #~%" (-> this hsr-ymult)) + (format #t "~1Twarp-consts: #~%" (-> this warp-consts)) + (format #t "~1Twarp-nums: #~%" (-> this warp-nums)) + (label cfg-4) + this + ) + +;; definition of type generic-merc-work +(deftype generic-merc-work (structure) + ((input-a generic-merc-input :inline) + (input-b generic-merc-input :inline) + (ctrl generic-merc-ctrl-with-sfx :inline) + (shadow gm-shadow :inline) + (stack uint128 16) + ) + ) + +;; definition for method 3 of type generic-merc-work +(defmethod inspect ((this generic-merc-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-merc-work) + (format #t "~1Tinput-a: #~%" (-> this input-a)) + (format #t "~1Tinput-b: #~%" (-> this input-b)) + (format #t "~1Tctrl: #~%" (-> this ctrl)) + (format #t "~1Tshadow: #~%" (-> this shadow)) + (format #t "~1Tstack[16] @ #x~X~%" (-> this stack)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/foreground/merc/merc-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/foreground/merc/merc-h_REF.gc new file mode 100644 index 0000000000..19bc86da3c --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/foreground/merc/merc-h_REF.gc @@ -0,0 +1,905 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type ripple-merc-query +(deftype ripple-merc-query (inline-array-class) + "Information about which merc vertices to apply the 'ripple' effect to." + ((start-vertex int32) + (vertex-skip int32) + (vertex-count int32) + (current-loc int32) + (data vector :inline :dynamic) + ) + ) + +;; definition for method 3 of type ripple-merc-query +(defmethod inspect ((this ripple-merc-query)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tstart-vertex: ~D~%" (-> this start-vertex)) + (format #t "~1Tvertex-skip: ~D~%" (-> this vertex-skip)) + (format #t "~1Tvertex-count: ~D~%" (-> this vertex-count)) + (format #t "~1Tcurrent-loc: ~D~%" (-> this current-loc)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> ripple-merc-query heap-base) (the-as uint 16)) + +;; definition of type merc-byte-header +(deftype merc-byte-header (structure) + "Header for a single [[merc-fragment]] uploaded to the VU." + ((srcdest-off uint8) + (rgba-off uint8) + (lump-off uint8) + (fp-off uint8) + (mat1-cnt uint8) + (mat2-cnt uint8) + (mat3-cnt uint8) + (samecopy-cnt uint8) + (crosscopy-cnt uint8) + (strip-len uint8) + (mm-quadword-fp-off uint8) + (mm-quadword-size uint8) + (perc-off uint8) + (mat-slot uint8 10) + ) + ) + +;; definition for method 3 of type merc-byte-header +(defmethod inspect ((this merc-byte-header)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-byte-header) + (format #t "~1Tsrcdest-off: ~D~%" (-> this srcdest-off)) + (format #t "~1Trgba-off: ~D~%" (-> this rgba-off)) + (format #t "~1Tlump-off: ~D~%" (-> this lump-off)) + (format #t "~1Tfp-off: ~D~%" (-> this fp-off)) + (format #t "~1Tmat1-cnt: ~D~%" (-> this mat1-cnt)) + (format #t "~1Tmat2-cnt: ~D~%" (-> this mat2-cnt)) + (format #t "~1Tmat3-cnt: ~D~%" (-> this mat3-cnt)) + (format #t "~1Tsamecopy-cnt: ~D~%" (-> this samecopy-cnt)) + (format #t "~1Tcrosscopy-cnt: ~D~%" (-> this crosscopy-cnt)) + (format #t "~1Tstrip-len: ~D~%" (-> this strip-len)) + (format #t "~1Tmm-quadword-fp-off: ~D~%" (-> this mm-quadword-fp-off)) + (format #t "~1Tmm-quadword-size: ~D~%" (-> this mm-quadword-size)) + (format #t "~1Tperc-off: ~D~%" (-> this perc-off)) + (format #t "~1Tmat-slot[10] @ #x~X~%" (-> this mat-slot)) + (label cfg-4) + this + ) + +;; definition of type merc-fragment +(deftype merc-fragment (structure) + "A single merc fragment that fits into VU memory." + ((header merc-byte-header :inline) + (rest uint8 1) + ) + (:methods + (login-adgifs (_type_) merc-fragment) + ) + ) + +;; definition for method 3 of type merc-fragment +(defmethod inspect ((this merc-fragment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-fragment) + (format #t "~1Theader: #~%" (-> this header)) + (format #t "~1Trest[1] @ #x~X~%" (-> this rest)) + (label cfg-4) + this + ) + +;; definition of type merc-vtx +(deftype merc-vtx (structure) + "A packed merc vertex." + ((mat-0 uint8) + (mat-1 uint8) + (nrm-x uint8) + (pos-x uint8) + (dst-0 uint8) + (dst-1 uint8) + (nrm-y uint8) + (pos-y uint8) + (tex-s uint8) + (tex-t uint8) + (nrm-z uint8) + (pos-z uint8) + ) + ) + +;; definition for method 3 of type merc-vtx +(defmethod inspect ((this merc-vtx)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-vtx) + (format #t "~1Tmat-0: ~D~%" (-> this mat-0)) + (format #t "~1Tmat-1: ~D~%" (-> this mat-1)) + (format #t "~1Tnrm-x: ~D~%" (-> this nrm-x)) + (format #t "~1Tpos-x: ~D~%" (-> this pos-x)) + (format #t "~1Tdst-0: ~D~%" (-> this dst-0)) + (format #t "~1Tdst-1: ~D~%" (-> this dst-1)) + (format #t "~1Tnrm-y: ~D~%" (-> this nrm-y)) + (format #t "~1Tpos-y: ~D~%" (-> this pos-y)) + (format #t "~1Ttex-s: ~D~%" (-> this tex-s)) + (format #t "~1Ttex-t: ~D~%" (-> this tex-t)) + (format #t "~1Tnrm-z: ~D~%" (-> this nrm-z)) + (format #t "~1Tpos-z: ~D~%" (-> this pos-z)) + (label cfg-4) + this + ) + +;; definition of type merc-fp-header +(deftype merc-fp-header (structure) + "Merc header for a [[merc-fragment]]'s floating point data." + ((x-add float) + (y-add float) + (z-add float) + (shader-cnt uint8) + (kick-info-offset uint8) + (kick-info-step uint8) + (hword-cnt uint8) + ) + ) + +;; definition for method 3 of type merc-fp-header +(defmethod inspect ((this merc-fp-header)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-fp-header) + (format #t "~1Tx-add: ~f~%" (-> this x-add)) + (format #t "~1Ty-add: ~f~%" (-> this y-add)) + (format #t "~1Tz-add: ~f~%" (-> this z-add)) + (format #t "~1Tshader-cnt: ~D~%" (-> this shader-cnt)) + (format #t "~1Tkick-info-offset: ~D~%" (-> this kick-info-offset)) + (format #t "~1Tkick-info-step: ~D~%" (-> this kick-info-step)) + (format #t "~1Thword-cnt: ~D~%" (-> this hword-cnt)) + (label cfg-4) + this + ) + +;; definition for function merc-fragment-fp-data +;; WARN: Return type mismatch int vs merc-fp-header. +(defun merc-fragment-fp-data ((frag merc-fragment)) + "Get the floating point data of a [[merc-fragment]]." + (the-as merc-fp-header (+ (the-as uint frag) (* (-> frag header mm-quadword-fp-off) 16))) + ) + +;; definition of type merc-mat-dest +(deftype merc-mat-dest (structure) + "Metadata for a merc matrix upload." + ((matrix-number uint8) + (matrix-dest uint8) + ) + :pack-me + ) + +;; definition for method 3 of type merc-mat-dest +(defmethod inspect ((this merc-mat-dest)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-mat-dest) + (format #t "~1Tmatrix-number: ~D~%" (-> this matrix-number)) + (format #t "~1Tmatrix-dest: ~D~%" (-> this matrix-dest)) + (label cfg-4) + this + ) + +;; definition of type merc-fragment-control +(deftype merc-fragment-control (structure) + "Data about a [[merc-fragment]] needed for merc DMA generation." + ((unsigned-four-count uint8) + (lump-four-count uint8) + (fp-qwc uint8) + (mat-xfer-count uint8) + (mat-dest-data merc-mat-dest :inline :dynamic) + ) + ) + +;; definition for method 3 of type merc-fragment-control +(defmethod inspect ((this merc-fragment-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-fragment-control) + (format #t "~1Tunsigned-four-count: ~D~%" (-> this unsigned-four-count)) + (format #t "~1Tlump-four-count: ~D~%" (-> this lump-four-count)) + (format #t "~1Tfp-qwc: ~D~%" (-> this fp-qwc)) + (format #t "~1Tmat-xfer-count: ~D~%" (-> this mat-xfer-count)) + (format #t "~1Tmat-dest-data[0] @ #x~X~%" (-> this mat-dest-data)) + (label cfg-4) + this + ) + +;; definition of type merc-blend-data +(deftype merc-blend-data (structure) + "Packed BLERC data." + ((int8-data int8 :dynamic) + ) + ) + +;; definition for method 3 of type merc-blend-data +(defmethod inspect ((this merc-blend-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-blend-data) + (format #t "~1Tint8-data[0] @ #x~X~%" (-> this int8-data)) + (label cfg-4) + this + ) + +;; definition of type merc-blend-ctrl +(deftype merc-blend-ctrl (structure) + "Information about the vertices of a model modified by BLERC." + ((blend-vtx-count uint8) + (nonzero-index-count uint8) + (bt-index uint8 :dynamic) + ) + ) + +;; definition for method 3 of type merc-blend-ctrl +(defmethod inspect ((this merc-blend-ctrl)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-blend-ctrl) + (format #t "~1Tblend-vtx-count: ~D~%" (-> this blend-vtx-count)) + (format #t "~1Tnonzero-index-count: ~D~%" (-> this nonzero-index-count)) + (format #t "~1Tbt-index[0] @ #x~X~%" (-> this bt-index)) + (label cfg-4) + this + ) + +;; definition of type mei-envmap-tint +(deftype mei-envmap-tint (structure) + "Data for the extra 'envmap tint' effect." + ((fade0 float) + (fade1 float) + (tint rgba) + (dummy int32) + ) + ) + +;; definition for method 3 of type mei-envmap-tint +(defmethod inspect ((this mei-envmap-tint)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mei-envmap-tint) + (format #t "~1Tfade0: ~f~%" (-> this fade0)) + (format #t "~1Tfade1: ~f~%" (-> this fade1)) + (format #t "~1Ttint: ~D~%" (-> this tint)) + (format #t "~1Tdummy: ~D~%" (-> this dummy)) + (label cfg-4) + this + ) + +;; definition of type mei-texture-scroll +(deftype mei-texture-scroll (structure) + "Data for the extra 'texscroll' effect." + ((max-dist float) + (st-int-scale uint8) + (time-factor uint8) + (scroll-dir uint8) + (cached-time uint8) + (time-delta uint8) + (dummy uint8 7) + ) + ) + +;; definition for method 3 of type mei-texture-scroll +(defmethod inspect ((this mei-texture-scroll)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mei-texture-scroll) + (format #t "~1Tmax-dist: ~f~%" (-> this max-dist)) + (format #t "~1Tst-int-scale: ~D~%" (-> this st-int-scale)) + (format #t "~1Ttime-factor: ~D~%" (-> this time-factor)) + (format #t "~1Tscroll-dir: ~D~%" (-> this scroll-dir)) + (format #t "~1Tcached-time: ~D~%" (-> this cached-time)) + (format #t "~1Ttime-delta: ~D~%" (-> this time-delta)) + (format #t "~1Tdummy[7] @ #x~X~%" (-> this dummy)) + (label cfg-4) + this + ) + +;; definition of type mei-ripple +(deftype mei-ripple (structure) + "Data for the extra 'ripple' effect." + ((x-base float) + (z-base float) + (grid-size float) + (angle float) + ) + ) + +;; definition for method 3 of type mei-ripple +(defmethod inspect ((this mei-ripple)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mei-ripple) + (format #t "~1Tx-base: ~f~%" (-> this x-base)) + (format #t "~1Tz-base: ~f~%" (-> this z-base)) + (format #t "~1Tgrid-size: ~f~%" (-> this grid-size)) + (format #t "~1Tangle: ~f~%" (-> this angle)) + (label cfg-4) + this + ) + +;; definition of type merc-extra-info +(deftype merc-extra-info (structure) + "Info for merc extra effects." + ((envmap-tint-offset uint8) + (shader-offset uint8) + (texture-scroll-offset uint8) + (ripple-offset uint8) + (dummy uint8 12) + ) + ) + +;; definition for method 3 of type merc-extra-info +(defmethod inspect ((this merc-extra-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-extra-info) + (format #t "~1Tenvmap-tint-offset: ~D~%" (-> this envmap-tint-offset)) + (format #t "~1Tshader-offset: ~D~%" (-> this shader-offset)) + (format #t "~1Ttexture-scroll-offset: ~D~%" (-> this texture-scroll-offset)) + (format #t "~1Tripple-offset: ~D~%" (-> this ripple-offset)) + (format #t "~1Tdummy[12] @ #x~X~%" (-> this dummy)) + (label cfg-4) + this + ) + +;; definition of type merc-effect +(deftype merc-effect (structure) + "A collection of [[merc-fragment]]s with data for any extra effects." + ((frag-geo merc-fragment) + (frag-ctrl merc-fragment-control) + (blend-data merc-blend-data) + (blend-ctrl merc-blend-ctrl) + (merc-effect-version uint8) + (effect-bits effect-bits) + (frag-count uint16) + (blend-frag-count uint16) + (tri-count uint16) + (dvert-count uint16) + (texture-index uint8) + (effect-usage uint8) + (extra-info merc-extra-info) + ) + (:methods + (login-adgifs (_type_) none) + ) + ) + +;; definition for method 3 of type merc-effect +(defmethod inspect ((this merc-effect)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-effect) + (format #t "~1Tfrag-geo: #~%" (-> this frag-geo)) + (format #t "~1Tfrag-ctrl: #~%" (-> this frag-ctrl)) + (format #t "~1Tblend-data: #~%" (-> this blend-data)) + (format #t "~1Tblend-ctrl: #~%" (-> this blend-ctrl)) + (format #t "~1Tmerc-effect-version: ~D~%" (-> this merc-effect-version)) + (format #t "~1Teffect-bits: ~D~%" (-> this effect-bits)) + (format #t "~1Tfrag-count: ~D~%" (-> this frag-count)) + (format #t "~1Tblend-frag-count: ~D~%" (-> this blend-frag-count)) + (format #t "~1Ttri-count: ~D~%" (-> this tri-count)) + (format #t "~1Tdvert-count: ~D~%" (-> this dvert-count)) + (format #t "~1Ttexture-index: ~D~%" (-> this texture-index)) + (format #t "~1Teffect-usage: ~D~%" (-> this effect-usage)) + (format #t "~1Textra-info: #~%" (-> this extra-info)) + (label cfg-4) + this + ) + +;; definition of type merc-eye-ctrl +(deftype merc-eye-ctrl (structure) + "Eye info for both eyes of a merc model." + ((eye-slot int8) + (shader-offset int8) + (shader-count int8) + (eye-ctrl-index int8) + (shader adgif-shader 6 :inline) + (left-iris-shader adgif-shader :inline :overlay-at (-> shader 0)) + (left-pupil-shader adgif-shader :inline :overlay-at (-> shader 1)) + (left-lid-shader adgif-shader :inline :overlay-at (-> shader 2)) + (right-iris-shader adgif-shader :inline :overlay-at (-> shader 3)) + (right-pupil-shader adgif-shader :inline :overlay-at (-> shader 4)) + (right-lid-shader adgif-shader :inline :overlay-at (-> shader 5)) + ) + ) + +;; definition for method 3 of type merc-eye-ctrl +(defmethod inspect ((this merc-eye-ctrl)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-eye-ctrl) + (format #t "~1Teye-slot: ~D~%" (-> this eye-slot)) + (format #t "~1Tshader-offset: ~D~%" (-> this shader-offset)) + (format #t "~1Tshader-count: ~D~%" (-> this shader-count)) + (format #t "~1Teye-ctrl-index: ~D~%" (-> this eye-ctrl-index)) + (format #t "~1Tshader[6] @ #x~X~%" (-> this shader)) + (format #t "~1Tleft-iris-shader: #~%" (-> this shader)) + (format #t "~1Tleft-pupil-shader: #~%" (-> this left-pupil-shader)) + (format #t "~1Tleft-lid-shader: #~%" (-> this left-lid-shader)) + (format #t "~1Tright-iris-shader: #~%" (-> this right-iris-shader)) + (format #t "~1Tright-pupil-shader: #~%" (-> this right-pupil-shader)) + (format #t "~1Tright-lid-shader: #~%" (-> this right-lid-shader)) + (label cfg-4) + this + ) + +;; definition of type merc-eye-anim-frame +(deftype merc-eye-anim-frame (structure) + "A single frame of a merc eye animation." + ((pupil-trans-x int8) + (pupil-trans-y int8) + (blink int8) + (iris-scale int8 :offset 4) + (pupil-scale int8 :offset 5) + (lid-scale int8 :offset 6) + (dword uint64 :overlay-at pupil-trans-x) + ) + :pack-me + ) + +;; definition for method 3 of type merc-eye-anim-frame +(defmethod inspect ((this merc-eye-anim-frame)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-eye-anim-frame) + (format #t "~1Tpupil-trans-x: ~D~%" (-> this pupil-trans-x)) + (format #t "~1Tpupil-trans-y: ~D~%" (-> this pupil-trans-y)) + (format #t "~1Tblink: ~D~%" (-> this blink)) + (format #t "~1Tiris-scale: ~D~%" (-> this iris-scale)) + (format #t "~1Tpupil-scale: ~D~%" (-> this pupil-scale)) + (format #t "~1Tlid-scale: ~D~%" (-> this lid-scale)) + (format #t "~1Tdword: ~D~%" (-> this dword)) + (label cfg-4) + this + ) + +;; definition of type merc-eye-anim-block +(deftype merc-eye-anim-block (structure) + "A list of eye animation frames." + ((max-frame int16) + (data merc-eye-anim-frame :inline :dynamic) + ) + ) + +;; definition for method 3 of type merc-eye-anim-block +(defmethod inspect ((this merc-eye-anim-block)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-eye-anim-block) + (format #t "~1Tmax-frame: ~D~%" (-> this max-frame)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type texture-usage-group +(deftype texture-usage-group (structure) + ((data texture-masks 7 :inline) + ) + ) + +;; definition for method 3 of type texture-usage-group +(defmethod inspect ((this texture-usage-group)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-usage-group) + (format #t "~1Tdata[7] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type merc-ctrl-header +(deftype merc-ctrl-header (structure) + "The header for a [[merc-ctrl]], +containing metadata about the model used for drawing." + ((xyz-scale float) + (st-magic uint32) + (st-out-a uint32) + (st-out-b uint32) + (st-vif-add uint32) + (st-int-off uint16) + (st-int-scale uint16) + (effect-count uint32) + (blend-target-count uint32) + (fragment-count uint16) + (tri-count uint16) + (matrix-count uint8) + (shader-count uint8) + (transform-vertex-count uint16) + (dvert-count uint16) + (one-mat-count uint16) + (two-mat-count uint16) + (two-mat-reuse-count uint16) + (three-mat-count uint16) + (three-mat-reuse-count uint16) + (shader-upload-count uint8) + (matrix-upload-count uint8) + (same-copy-count uint16) + (cross-copy-count uint16) + (num-verts uint16) + (longest-edge float) + (eye-ctrl merc-eye-ctrl) + (pad uint32 3) + (masks-padding texture-masks :inline) + (texture-usage-group texture-usage-group :overlay-at (-> masks-padding data 0 mask data 0)) + (dummy-bytes uint8 :dynamic :overlay-at fragment-count) + (envmap-tint uint32 :overlay-at fragment-count) + (query basic :overlay-at matrix-count) + (needs-clip uint8 :overlay-at dvert-count) + (use-isometric uint8 :offset 41) + (use-attached-shader uint8 :overlay-at one-mat-count) + (display-triangles uint8 :offset 43) + (death-vertex-skip uint16 :overlay-at two-mat-count) + (death-start-vertex uint16 :overlay-at two-mat-reuse-count) + (death-effect uint32 :overlay-at three-mat-count) + (use-translucent uint8 :overlay-at shader-upload-count) + (display-this-fragment uint8 :overlay-at matrix-upload-count) + (use-warp uint8 :overlay-at same-copy-count) + (ignore-alpha uint8 :offset 55) + (force-fade uint8 :overlay-at cross-copy-count) + (disable-fog uint8 :offset 57) + (disable-envmap uint8 :overlay-at num-verts) + ) + ) + +;; definition for method 3 of type merc-ctrl-header +(defmethod inspect ((this merc-ctrl-header)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-ctrl-header) + (format #t "~1Txyz-scale: #x~X~%" (-> this xyz-scale)) + (format #t "~1Tst-magic: #x~X~%" (-> this st-magic)) + (format #t "~1Tst-out-a: #x~X~%" (-> this st-out-a)) + (format #t "~1Tst-out-b: #x~X~%" (-> this st-out-b)) + (format #t "~1Tst-vif-add: #x~X~%" (-> this st-vif-add)) + (format #t "~1Tst-int-off: ~D~%" (-> this st-int-off)) + (format #t "~1Tst-int-scale: ~D~%" (-> this st-int-scale)) + (format #t "~1Teffect-count: ~D~%" (-> this effect-count)) + (format #t "~1Tblend-target-count: ~D~%" (-> this blend-target-count)) + (format #t "~1Tfragment-count: ~D~%" (-> this fragment-count)) + (format #t "~1Ttri-count: ~D~%" (-> this tri-count)) + (format #t "~1Tmatrix-count: ~D~%" (-> this matrix-count)) + (format #t "~1Tshader-count: ~D~%" (-> this shader-count)) + (format #t "~1Ttransform-vertex-count: ~D~%" (-> this transform-vertex-count)) + (format #t "~1Tdvert-count: ~D~%" (-> this dvert-count)) + (format #t "~1Tone-mat-count: ~D~%" (-> this one-mat-count)) + (format #t "~1Ttwo-mat-count: ~D~%" (-> this two-mat-count)) + (format #t "~1Ttwo-mat-reuse-count: ~D~%" (-> this two-mat-reuse-count)) + (format #t "~1Tthree-mat-count: ~D~%" (-> this three-mat-count)) + (format #t "~1Tthree-mat-reuse-count: ~D~%" (-> this three-mat-reuse-count)) + (format #t "~1Tshader-upload-count: ~D~%" (-> this shader-upload-count)) + (format #t "~1Tmatrix-upload-count: ~D~%" (-> this matrix-upload-count)) + (format #t "~1Tsame-copy-count: ~D~%" (-> this same-copy-count)) + (format #t "~1Tcross-copy-count: ~D~%" (-> this cross-copy-count)) + (format #t "~1Tnum-verts: ~D~%" (-> this num-verts)) + (format #t "~1Tlongest-edge: ~f~%" (-> this longest-edge)) + (format #t "~1Teye-ctrl: #~%" (-> this eye-ctrl)) + (format #t "~1Tpad[3] @ #x~X~%" (-> this pad)) + (format #t "~1Tmasks-padding: #~%" (-> this masks-padding)) + (format #t "~1Ttexture-usage-group: #~%" (-> this texture-usage-group)) + (format #t "~1Tdummy-bytes[0] @ #x~X~%" (&-> this fragment-count)) + (format #t "~1Tenvmap-tint: ~D~%" (-> this envmap-tint)) + (format #t "~1Tquery: ~A~%" (-> this query)) + (format #t "~1Tneeds-clip: ~D~%" (-> this needs-clip)) + (format #t "~1Tuse-isometric: ~D~%" (-> this use-isometric)) + (format #t "~1Tuse-attached-shader: ~D~%" (-> this use-attached-shader)) + (format #t "~1Tdisplay-triangles: ~D~%" (-> this display-triangles)) + (format #t "~1Tdeath-vertex-skip: ~D~%" (-> this two-mat-count)) + (format #t "~1Tdeath-start-vertex: ~D~%" (-> this two-mat-reuse-count)) + (format #t "~1Tdeath-effect: ~D~%" (-> this death-effect)) + (format #t "~1Tuse-translucent: ~D~%" (-> this shader-upload-count)) + (format #t "~1Tdisplay-this-fragment: ~D~%" (-> this matrix-upload-count)) + (format #t "~1Tuse-warp: ~D~%" (-> this use-warp)) + (format #t "~1Tignore-alpha: ~D~%" (-> this ignore-alpha)) + (format #t "~1Tforce-fade: ~D~%" (-> this force-fade)) + (format #t "~1Tdisable-fog: ~D~%" (-> this disable-fog)) + (format #t "~1Tdisable-envmap: ~D~%" (-> this disable-envmap)) + (label cfg-4) + this + ) + +;; definition of type merc-ctrl +(deftype merc-ctrl (art-element) + "The merc data for a single model as it's stored in an art group. +Consists of a header and a list of [[merc-effect]]s." + ((num-joints int32 :overlay-at length) + (seg-table (array uint64) :overlay-at (-> pad 0)) + (header merc-ctrl-header :inline) + (effect merc-effect :inline :dynamic) + ) + ) + +;; definition for method 3 of type merc-ctrl +(defmethod inspect ((this merc-ctrl)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Textra: ~A~%" (-> this extra)) + (format #t "~1Tmaster-art-group-name: ~A~%" (-> this master-art-group-name)) + (format #t "~1Tmaster-art-group-index: ~D~%" (-> this master-art-group-index)) + (format #t "~1Tnum-joints: ~D~%" (-> this length)) + (format #t "~1Tseg-table: ~A~%" (-> this seg-table)) + (format #t "~1Theader: #~%" (-> this header)) + (format #t "~1Teffect[0] @ #x~X~%" (-> this effect)) + (label cfg-4) + this + ) + +;; definition of type merc-vu1-low-mem +(deftype merc-vu1-low-mem (structure) + ((tri-strip-gif gs-gif-tag :inline) + (ad-gif gs-gif-tag :inline) + (hvdf-offset vector :inline) + (perspective uint128 4) + (fog vector :inline) + ) + ) + +;; definition for method 3 of type merc-vu1-low-mem +(defmethod inspect ((this merc-vu1-low-mem)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'merc-vu1-low-mem) + (format #t "~1Ttri-strip-gif: #~%" (-> this tri-strip-gif)) + (format #t "~1Tad-gif: #~%" (-> this ad-gif)) + (format #t "~1Thvdf-offset: #~%" (-> this hvdf-offset)) + (format #t "~1Tperspective[4] @ #x~X~%" (-> this perspective)) + (format #t "~1Tfog: #~%" (-> this fog)) + (label cfg-4) + this + ) + +;; definition of type emerc-vu1-low-mem +(deftype emerc-vu1-low-mem (structure) + ((tri-strip-gif gs-gif-tag :inline) + (ad-gif gs-gif-tag :inline) + (hvdf-offset vector :inline) + (perspective vector 4 :inline) + (fog vector :inline) + (unperspect vector :inline) + ) + ) + +;; definition for method 3 of type emerc-vu1-low-mem +(defmethod inspect ((this emerc-vu1-low-mem)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'emerc-vu1-low-mem) + (format #t "~1Ttri-strip-gif: #~%" (-> this tri-strip-gif)) + (format #t "~1Tad-gif: #~%" (-> this ad-gif)) + (format #t "~1Thvdf-offset: #~%" (-> this hvdf-offset)) + (format #t "~1Tperspective[4] @ #x~X~%" (-> this perspective)) + (format #t "~1Tfog: #~%" (-> this fog)) + (format #t "~1Tunperspect: #~%" (-> this unperspect)) + (label cfg-4) + this + ) + +;; definition of type texture-login-data +(deftype texture-login-data (structure) + ((default-texture-index int32) + (current-texture-index int32) + (texture-usage-group texture-usage-group) + (merc-ctrl-header merc-ctrl-header) + (name basic) + ) + ) + +;; definition for method 3 of type texture-login-data +(defmethod inspect ((this texture-login-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-login-data) + (format #t "~1Tdefault-texture-index: ~D~%" (-> this default-texture-index)) + (format #t "~1Tcurrent-texture-index: ~D~%" (-> this current-texture-index)) + (format #t "~1Ttexture-usage-group: #~%" (-> this texture-usage-group)) + (format #t "~1Tmerc-ctrl-header: #~%" (-> this merc-ctrl-header)) + (format #t "~1Tname: ~A~%" (-> this name)) + (label cfg-4) + this + ) + +;; definition of type ripple-wave +(deftype ripple-wave (structure) + ((scale float) + (offs float) + (xdiv int16) + (zdiv int16) + (speed float) + (xmul float) + (zmul float) + (delta float) + ) + :pack-me + ) + +;; definition for method 3 of type ripple-wave +(defmethod inspect ((this ripple-wave)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ripple-wave) + (format #t "~1Tscale: ~f~%" (-> this scale)) + (format #t "~1Toffs: ~f~%" (-> this offs)) + (format #t "~1Txdiv: ~D~%" (-> this xdiv)) + (format #t "~1Tzdiv: ~D~%" (-> this zdiv)) + (format #t "~1Tspeed: ~f~%" (-> this speed)) + (format #t "~1Txmul: ~f~%" (-> this xmul)) + (format #t "~1Tzmul: ~f~%" (-> this zmul)) + (format #t "~1Tdelta: ~f~%" (-> this delta)) + (label cfg-4) + this + ) + +;; definition of type ripple-wave-set +(deftype ripple-wave-set (basic) + ((count int32) + (converted basic) + (normal-scale float) + (wave ripple-wave 4 :inline) + (frame-save uint64) + ) + ) + +;; definition for method 3 of type ripple-wave-set +(defmethod inspect ((this ripple-wave-set)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tcount: ~D~%" (-> this count)) + (format #t "~1Tconverted: ~A~%" (-> this converted)) + (format #t "~1Tnormal-scale: ~f~%" (-> this normal-scale)) + (format #t "~1Twave[4] @ #x~X~%" (-> this wave)) + (format #t "~1Tframe-save: ~D~%" (-> this frame-save)) + (label cfg-4) + this + ) + +;; definition of type ripple-control +(deftype ripple-control (basic) + ((global-scale float) + (last-frame-scale float) + (close-fade-dist float) + (far-fade-dist float) + (faded-scale float) + (individual-normal-scale float) + (waveform ripple-wave-set) + (send-query symbol) + (query ripple-merc-query) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +;; definition for method 3 of type ripple-control +(defmethod inspect ((this ripple-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tglobal-scale: ~f~%" (-> this global-scale)) + (format #t "~1Tlast-frame-scale: ~f~%" (-> this last-frame-scale)) + (format #t "~1Tclose-fade-dist: ~f~%" (-> this close-fade-dist)) + (format #t "~1Tfar-fade-dist: ~f~%" (-> this far-fade-dist)) + (format #t "~1Tfaded-scale: ~f~%" (-> this faded-scale)) + (format #t "~1Tindividual-normal-scale: ~f~%" (-> this individual-normal-scale)) + (format #t "~1Twaveform: ~A~%" (-> this waveform)) + (format #t "~1Tsend-query: ~A~%" (-> this send-query)) + (format #t "~1Tquery: ~A~%" (-> this query)) + (label cfg-4) + this + ) + +;; definition for method 0 of type ripple-control +(defmethod new ripple-control ((allocation symbol) (type-to-make type)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 global-scale) 0.0) + (set! (-> v0-0 last-frame-scale) -0.001) + (set! (-> v0-0 close-fade-dist) 4096000000.0) + (set! (-> v0-0 far-fade-dist) 8192000000.0) + (set! (-> v0-0 faded-scale) -0.001) + (set! (-> v0-0 waveform) #f) + (set! (-> v0-0 individual-normal-scale) 1.0) + (set! (-> v0-0 send-query) #f) + (set! (-> v0-0 query) #f) + v0-0 + ) + ) + +;; definition of type death-info +(deftype death-info (basic) + ((vertex-skip uint16) + (timer uint8) + (overlap uint8) + (effect uint32) + (sound string) + ) + ) + +;; definition for method 3 of type death-info +(defmethod inspect ((this death-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tvertex-skip: ~D~%" (-> this vertex-skip)) + (format #t "~1Ttimer: ~D~%" (-> this timer)) + (format #t "~1Toverlap: ~D~%" (-> this overlap)) + (format #t "~1Teffect: ~D~%" (-> this effect)) + (format #t "~1Tsound: ~A~%" (-> this sound)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/foreground/shadow-cpu-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/foreground/shadow-cpu-h_REF.gc new file mode 100644 index 0000000000..c37542ff32 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/foreground/shadow-cpu-h_REF.gc @@ -0,0 +1,542 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type shadow-settings +(deftype shadow-settings (structure) + "Settings used to draw a shadow." + ((center vector :inline) + (flags shadow-flags :overlay-at (-> center data 3)) + (shadow-dir vector :inline) + (dist-to-locus float :overlay-at (-> shadow-dir data 3)) + (bot-plane plane :inline) + (top-plane plane :inline) + (fade-vec vector :inline :offset 64) + (fade-dist float :overlay-at (-> fade-vec x)) + (fade-start float :overlay-at (-> fade-vec y)) + (dummy-2 int32 :overlay-at (-> fade-vec z)) + (shadow-type int32 :overlay-at (-> fade-vec w)) + ) + ) + +;; definition for method 3 of type shadow-settings +(defmethod inspect ((this shadow-settings)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-settings) + (format #t "~1Tcenter: #~%" (-> this center)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tshadow-dir: #~%" (-> this shadow-dir)) + (format #t "~1Tdist-to-locus: ~f~%" (-> this shadow-dir w)) + (format #t "~1Tbot-plane: #~%" (-> this bot-plane)) + (format #t "~1Ttop-plane: #~%" (-> this top-plane)) + (format #t "~1Tfade-dist: ~f~%" (-> this fade-dist)) + (format #t "~1Tfade-start: ~f~%" (-> this fade-start)) + (format #t "~1Tdummy-2: ~D~%" (-> this dummy-2)) + (format #t "~1Tshadow-type: ~D~%" (-> this shadow-type)) + (label cfg-4) + this + ) + +;; definition of type shadow-control +(deftype shadow-control (basic) + ((settings shadow-settings :inline) + ) + (:methods + (new (symbol type float float float vector shadow-flags float) _type_) + (enable-draw (shadow-control) int) + (disable-draw (shadow-control) int) + (set-top-plane-offset (shadow-control float) int) + (set-bottom-plane-offset (shadow-control float) int) + (probe-line-for-shadow (_type_ vector float float float) none) + (shadow-control-method-14 (_type_ vector vector float float float) none) + ) + ) + +;; definition for method 3 of type shadow-control +(defmethod inspect ((this shadow-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tsettings: #~%" (-> this settings)) + (label cfg-4) + this + ) + +;; definition for method 9 of type shadow-control +(defmethod enable-draw ((this shadow-control)) + (logclear! (-> this settings flags) (shadow-flags disable-draw)) + 0 + ) + +;; definition for method 10 of type shadow-control +(defmethod disable-draw ((this shadow-control)) + (logior! (-> this settings flags) (shadow-flags disable-draw)) + 0 + ) + +;; definition for method 12 of type shadow-control +(defmethod set-bottom-plane-offset ((this shadow-control) (arg0 float)) + (set! (-> this settings bot-plane w) (- arg0)) + 0 + ) + +;; definition for method 11 of type shadow-control +(defmethod set-top-plane-offset ((this shadow-control) (arg0 float)) + (set! (-> this settings top-plane w) (- arg0)) + 0 + ) + +;; definition of type shadow-data +(deftype shadow-data (structure) + "DMA data for the shadow renderer." + ((dma-unpack-template dma-packet :inline) + (dma-cnt dma-tag) + (vif-nop vif-tag) + (vif-unpack-v4-8 vif-tag) + (pdc basic) + (dist float) + (waits uint32) + (inside-volume? uint32) + ) + ) + +;; definition for method 3 of type shadow-data +(defmethod inspect ((this shadow-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-data) + (format #t "~1Tdma-unpack-template: #~%" (-> this dma-unpack-template)) + (format #t "~1Tdma-cnt: ~D~%" (-> this dma-cnt)) + (format #t "~1Tvif-nop: ~D~%" (-> this vif-nop)) + (format #t "~1Tvif-unpack-v4-8: ~D~%" (-> this vif-unpack-v4-8)) + (format #t "~1Tpdc: ~A~%" (-> this pdc)) + (format #t "~1Tdist: ~f~%" (-> this dist)) + (format #t "~1Twaits: ~D~%" (-> this waits)) + (format #t "~1Tinside-volume?: ~D~%" (-> this inside-volume?)) + (label cfg-4) + this + ) + +;; definition of type shadow-work +(deftype shadow-work (structure) + ((shadow-data shadow-data :inline) + (inbuf uint128 600) + ) + ) + +;; definition for method 3 of type shadow-work +(defmethod inspect ((this shadow-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-work) + (format #t "~1Tshadow-data: #~%" (-> this shadow-data)) + (format #t "~1Tinbuf[600] @ #x~X~%" (-> this inbuf)) + (label cfg-4) + this + ) + +;; definition of type shadow-bucket +(deftype shadow-bucket (structure) + ((first pointer) + (next pointer) + (bucket-id bucket-id) + (shadow-color rgba) + (constants shadow-vu1-constants) + ) + :allow-misaligned + ) + +;; definition for method 3 of type shadow-bucket +(defmethod inspect ((this shadow-bucket)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-bucket) + (format #t "~1Tfirst: #x~X~%" (-> this first)) + (format #t "~1Tnext: #x~X~%" (-> this next)) + (format #t "~1Tbucket-id: ~D~%" (-> this bucket-id)) + (format #t "~1Tshadow-color: ~D~%" (-> this shadow-color)) + (format #t "~1Tconstants: ~A~%" (-> this constants)) + (label cfg-4) + this + ) + +;; definition of type shadow-bucket-views +(deftype shadow-bucket-views (structure) + ((data shadow-bucket 2 :inline) + ) + :allow-misaligned + ) + +;; definition for method 3 of type shadow-bucket-views +(defmethod inspect ((this shadow-bucket-views)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-bucket-views) + (format #t "~1Tdata[2] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type shadow-globals +(deftype shadow-globals (structure) + ((num-buckets uint32) + (cur-bucket uint32) + (data shadow-bucket-views 3 :inline) + ) + ) + +;; definition for method 3 of type shadow-globals +(defmethod inspect ((this shadow-globals)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-globals) + (format #t "~1Tnum-buckets: ~D~%" (-> this num-buckets)) + (format #t "~1Tcur-bucket: ~D~%" (-> this cur-bucket)) + (format #t "~1Tdata[3] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition for symbol *shadow-globals*, type shadow-globals +(define *shadow-globals* (new 'global 'shadow-globals)) + +;; failed to figure out what this is: +(set! (-> *shadow-globals* data 0 data 0 bucket-id) (bucket-id emerc-lcom-pris)) + +;; failed to figure out what this is: +(set! (-> *shadow-globals* data 0 data 1 bucket-id) (bucket-id gmerc-lcom-pris)) + +;; failed to figure out what this is: +(set! (-> *shadow-globals* data 1 data 0 bucket-id) (bucket-id bucket774)) + +;; failed to figure out what this is: +(set! (-> *shadow-globals* data 1 data 1 bucket-id) (bucket-id bucket775)) + +;; failed to figure out what this is: +(set! (-> *shadow-globals* data 2 data 0 bucket-id) (bucket-id bucket776)) + +;; failed to figure out what this is: +(set! (-> *shadow-globals* data 2 data 1 bucket-id) (bucket-id bucket777)) + +;; definition of type shadow-vertex +(deftype shadow-vertex (structure) + ((x float) + (y float) + (z float) + (weight float) + ) + ) + +;; definition for method 3 of type shadow-vertex +(defmethod inspect ((this shadow-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-vertex) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tz: ~f~%" (-> this z)) + (format #t "~1Tweight: ~f~%" (-> this weight)) + (label cfg-4) + this + ) + +;; definition of type shadow-matrix-ref +(deftype shadow-matrix-ref (structure) + ((joint-0 uint8) + (joint-1 uint8) + ) + ) + +;; definition for method 3 of type shadow-matrix-ref +(defmethod inspect ((this shadow-matrix-ref)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-matrix-ref) + (format #t "~1Tjoint-0: ~D~%" (-> this joint-0)) + (format #t "~1Tjoint-1: ~D~%" (-> this joint-1)) + (label cfg-4) + this + ) + +;; definition of type shadow-edge +(deftype shadow-edge (structure) + ((ind-0 uint8) + (ind-1 uint8) + (tri-0 uint8) + (tri-1 uint8) + ) + ) + +;; definition for method 3 of type shadow-edge +;; INFO: this function exists in multiple non-identical object files +;; ERROR: failed type prop at 14: Could not figure out load: (set! a2 (l.hu gp)) +(defmethod inspect ((a0-0 shadow-edge)) + (local-vars + (v0-0 object) + (v0-1 none) + (v0-2 none) + (v0-3 none) + (v0-4 none) + (v0-5 shadow-edge) + (a0-1 symbol) + (a0-2 symbol) + (a0-3 none) + (a0-4 none) + (a0-5 none) + (a1-0 string) + (a1-1 string) + (a1-2 none) + (a1-3 none) + (a1-4 none) + (a2-0 shadow-edge) + (a2-1 none) + (a2-2 none) + (a2-3 none) + (a2-4 none) + (a3-0 symbol) + (t9-0 (function _varargs_ object)) + (t9-1 (function _varargs_ object)) + (t9-2 none) + (t9-3 none) + (t9-4 none) + ) + (if (begin (not a0-0)) + (begin (set! a0-0 a0-0) (goto cfg-4)) + ) + (set! t9-0 format) + (set! a0-1 #t) + (set! a1-0 L122) + (set! a2-0 a0-0) + (set! a3-0 'shadow-edge) + (call! a0-1 a1-0 a2-0 a3-0) + (set! t9-1 format) + (set! a0-2 #t) + (set! a1-1 L85) + (set! a2-1 (the-as none (l.hu a0-0))) + (call!) + (set! t9-2 (the-as none format)) + (set! a0-3 (the-as none #t)) + (set! a1-2 (the-as none L84)) + (set! a2-2 (the-as none (l.hu (+ a0-0 2)))) + (call!) + (set! t9-3 (the-as none format)) + (set! a0-4 (the-as none #t)) + (set! a1-3 (the-as none L83)) + (set! a2-3 (the-as none (l.hu (+ a0-0 4)))) + (call!) + (set! t9-4 (the-as none format)) + (set! a0-5 (the-as none #t)) + (set! a1-4 (the-as none L82)) + (set! a2-4 (the-as none (l.hu (+ a0-0 6)))) + (call!) + (label cfg-4) + (set! v0-5 a0-0) + (ret-value v0-5) + ) + +;; definition of type shadow-tri +(deftype shadow-tri (structure) + ((ind-0 uint8) + (ind-1 uint8) + (ind-2 uint8) + (faces uint8) + ) + ) + +;; definition for method 3 of type shadow-tri +(defmethod inspect ((this shadow-tri)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-tri) + (format #t "~1Tind-0: ~D~%" (-> this ind-0)) + (format #t "~1Tind-1: ~D~%" (-> this ind-1)) + (format #t "~1Tind-2: ~D~%" (-> this ind-2)) + (format #t "~1Tfaces: ~D~%" (-> this faces)) + (label cfg-4) + this + ) + +;; definition of type shadow-edge +(deftype shadow-edge (structure) + ((ind-0 uint8) + (ind-1 uint8) + (tri-0 uint8) + (tri-1 uint8) + ) + ) + +;; definition for method 3 of type shadow-edge +;; INFO: this function exists in multiple non-identical object files +(defmethod inspect ((this shadow-edge)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-edge) + (format #t "~1Tind-0: ~D~%" (-> this ind-0)) + (format #t "~1Tind-1: ~D~%" (-> this ind-1)) + (format #t "~1Ttri-0: ~D~%" (-> this tri-0)) + (format #t "~1Ttri-1: ~D~%" (-> this tri-1)) + (label cfg-4) + this + ) + +;; definition of type shadow-frag-header +(deftype shadow-frag-header (structure) + ((qwc-data uint32) + (num-joints uint32) + (num-verts uint16) + (num-twos uint16) + (num-single-tris uint16) + (num-single-edges uint16) + (num-double-tris uint16) + (num-double-edges uint16) + (ofs-verts uint32) + (ofs-refs uint32) + (ofs-single-tris uint32) + (ofs-single-edges uint32) + (ofs-double-tris uint32) + (ofs-double-edges uint32) + ) + ) + +;; definition for method 3 of type shadow-frag-header +(defmethod inspect ((this shadow-frag-header)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-frag-header) + (format #t "~1Tqwc-data: ~D~%" (-> this qwc-data)) + (format #t "~1Tnum-joints: ~D~%" (-> this num-joints)) + (format #t "~1Tnum-verts: ~D~%" (-> this num-verts)) + (format #t "~1Tnum-twos: ~D~%" (-> this num-twos)) + (format #t "~1Tnum-single-tris: ~D~%" (-> this num-single-tris)) + (format #t "~1Tnum-single-edges: ~D~%" (-> this num-single-edges)) + (format #t "~1Tnum-double-tris: ~D~%" (-> this num-double-tris)) + (format #t "~1Tnum-double-edges: ~D~%" (-> this num-double-edges)) + (format #t "~1Tofs-verts: ~D~%" (-> this ofs-verts)) + (format #t "~1Tofs-refs: ~D~%" (-> this ofs-refs)) + (format #t "~1Tofs-single-tris: ~D~%" (-> this ofs-single-tris)) + (format #t "~1Tofs-single-edges: ~D~%" (-> this ofs-single-edges)) + (format #t "~1Tofs-double-tris: ~D~%" (-> this ofs-double-tris)) + (format #t "~1Tofs-double-edges: ~D~%" (-> this ofs-double-edges)) + (label cfg-4) + this + ) + +;; definition of type shadow-frag-ref +(deftype shadow-frag-ref (structure) + ((header shadow-frag-header) + (qwc uint32) + ) + :pack-me + ) + +;; definition for method 3 of type shadow-frag-ref +(defmethod inspect ((this shadow-frag-ref)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shadow-frag-ref) + (format #t "~1Theader: #~%" (-> this header)) + (format #t "~1Tqwc: ~D~%" (-> this qwc)) + (label cfg-4) + this + ) + +;; definition of type shadow-geo +(deftype shadow-geo (art-element) + "The low poly model used for drawing the shadow." + ((version uint32 :overlay-at (-> pad 0)) + (total-size uint32 :overlay-at (-> pad 4)) + (total-qwc uint32) + (num-joints uint32) + (num-fragments uint32) + (frags shadow-frag-ref :inline :dynamic) + ) + ) + +;; definition for method 3 of type shadow-geo +(defmethod inspect ((this shadow-geo)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Textra: ~A~%" (-> this extra)) + (format #t "~1Tmaster-art-group-name: ~A~%" (-> this master-art-group-name)) + (format #t "~1Tmaster-art-group-index: ~D~%" (-> this master-art-group-index)) + (format #t "~1Tversion: ~D~%" (-> this version)) + (format #t "~1Ttotal-size: ~D~%" (-> this total-size)) + (format #t "~1Ttotal-qwc: ~D~%" (-> this total-qwc)) + (format #t "~1Tnum-joints: ~D~%" (-> this num-joints)) + (format #t "~1Tnum-fragments: ~D~%" (-> this num-fragments)) + (format #t "~1Tfrags[0] @ #x~X~%" (-> this frags)) + (label cfg-4) + this + ) + +;; definition for method 0 of type shadow-control +;; INFO: Used lq/sq +(defmethod new shadow-control ((allocation symbol) + (type-to-make type) + (arg0 float) + (arg1 float) + (arg2 float) + (arg3 vector) + (arg4 shadow-flags) + (arg5 float) + ) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (if arg3 + (set! (-> v0-0 settings center quad) (-> arg3 quad)) + ) + (set! (-> v0-0 settings flags) arg4) + (set-vector! (-> v0-0 settings shadow-dir) 0.0 -1.0 0.0 arg2) + (set-vector! (-> v0-0 settings bot-plane) 0.0 1.0 0.0 (- arg0)) + (set-vector! (-> v0-0 settings top-plane) 0.0 1.0 0.0 (- arg1)) + (set! (-> v0-0 settings fade-dist) arg5) + (set! (-> v0-0 settings shadow-type) 0) + v0-0 + ) + ) + +;; definition for symbol *shadow*, type symbol +(define *shadow* #f) + +;; definition for symbol *shadow-object*, type symbol +(define *shadow-object* #f) + +;; definition for symbol *shadow-debug*, type symbol +(define *shadow-debug* #f) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/foreground/shadow-vu1-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/foreground/shadow-vu1-h_REF.gc new file mode 100644 index 0000000000..8e4b1f21d4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/foreground/shadow-vu1-h_REF.gc @@ -0,0 +1,9 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/generic/generic-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/generic/generic-h_REF.gc new file mode 100644 index 0000000000..39c5c152ca --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/generic/generic-h_REF.gc @@ -0,0 +1,501 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type gsf-vertex +(deftype gsf-vertex (structure) + "Vertex used by generic. GSF = generic stripped fragment?" + ((data uint32 8) + (byte uint8 32 :overlay-at (-> data 0)) + (quad uint128 2 :overlay-at (-> data 0)) + (vt qword :inline :overlay-at (-> data 0)) + (pos vector3s :inline :overlay-at (-> data 0)) + (tex vector2uh :inline :overlay-at (-> data 3)) + (nrm vector3s :inline :overlay-at (-> data 4)) + (nc qword :inline :overlay-at (-> data 4)) + (clr vector4ub :inline :overlay-at (-> data 7)) + (dtex vector2uh :inline :overlay-at (-> data 4)) + (dclr vector4ub :inline :overlay-at (-> data 5)) + ) + ) + +;; definition for method 3 of type gsf-vertex +(defmethod inspect ((this gsf-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gsf-vertex) + (format #t "~1Tdata[8] @ #x~X~%" (-> this data)) + (format #t "~1Tbyte[32] @ #x~X~%" (-> this data)) + (format #t "~1Tquad[2] @ #x~X~%" (-> this data)) + (format #t "~1Tvt: #~%" (-> this data)) + (format #t "~1Tpos: #~%" (-> this data)) + (format #t "~1Ttex: #~%" (&-> this vt vector4w w)) + (format #t "~1Tnrm: #~%" (-> this nrm)) + (format #t "~1Tnc: #~%" (-> this nrm)) + (format #t "~1Tclr: #~%" (&-> this nc vector4w w)) + (format #t "~1Tdtex: #~%" (-> this nrm)) + (format #t "~1Tdclr: #~%" (&-> this nrm y)) + (label cfg-4) + this + ) + +;; definition of type gsf-vertex-array +(deftype gsf-vertex-array (structure) + ((vtx gsf-vertex :dynamic) + ) + ) + +;; definition for method 3 of type gsf-vertex-array +(defmethod inspect ((this gsf-vertex-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gsf-vertex-array) + (format #t "~1Tvtx[0] @ #x~X~%" (-> this vtx)) + (label cfg-4) + this + ) + +;; definition of type gsf-fx-vertex +(deftype gsf-fx-vertex (structure) + "Color/texture data only. Possibly used to share with a gsf-vertex with +the same position/normal." + ((clr vector4ub :inline) + (tex vector2uh :inline) + ) + ) + +;; definition for method 3 of type gsf-fx-vertex +(defmethod inspect ((this gsf-fx-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gsf-fx-vertex) + (format #t "~1Tclr: #~%" (-> this clr)) + (format #t "~1Ttex: #~%" (-> this tex)) + (label cfg-4) + this + ) + +;; definition of type gsf-fx-vertex-array +(deftype gsf-fx-vertex-array (structure) + ((data gsf-fx-vertex :dynamic) + ) + ) + +;; definition for method 3 of type gsf-fx-vertex-array +(defmethod inspect ((this gsf-fx-vertex-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gsf-fx-vertex-array) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type gsf-header +(deftype gsf-header (structure) + "Header for generic data." + ((num-strips uint8) + (num-new-vtxs uint8) + (num-dps uint16) + (num-vtxs uint16) + (strip-table uint8 10) + ) + ) + +;; definition for method 3 of type gsf-header +(defmethod inspect ((this gsf-header)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gsf-header) + (format #t "~1Tnum-strips: ~D~%" (-> this num-strips)) + (format #t "~1Tnum-new-vtxs: ~D~%" (-> this num-new-vtxs)) + (format #t "~1Tnum-dps: ~D~%" (-> this num-dps)) + (format #t "~1Tnum-vtxs: ~D~%" (-> this num-vtxs)) + (format #t "~1Tstrip-table[10] @ #x~X~%" (-> this strip-table)) + (label cfg-4) + this + ) + +;; definition of type gsf-ik +(deftype gsf-ik (structure) + ((index uint8) + (no-kick uint8) + ) + ) + +;; definition for method 3 of type gsf-ik +(defmethod inspect ((this gsf-ik)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gsf-ik) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tno-kick: ~D~%" (-> this no-kick)) + (label cfg-4) + this + ) + +;; definition of type gsf-info +(deftype gsf-info (structure) + ((ptr-iks uint32) + (ptr-verts uint32) + (ptr-fx uint32) + (dummy2 uint32) + ) + ) + +;; definition for method 3 of type gsf-info +(defmethod inspect ((this gsf-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gsf-info) + (format #t "~1Tptr-iks: #x~X~%" (-> this ptr-iks)) + (format #t "~1Tptr-verts: #x~X~%" (-> this ptr-verts)) + (format #t "~1Tptr-fx: #x~X~%" (-> this ptr-fx)) + (format #t "~1Tdummy2: ~D~%" (-> this dummy2)) + (label cfg-4) + this + ) + +;; definition of type gsf-buffer +(deftype gsf-buffer (structure) + ((data uint8 8192) + (info gsf-info :inline :overlay-at (-> data 0)) + (header gsf-header :inline :overlay-at (-> data 16)) + (work-area uint8 :dynamic :overlay-at (-> data 32)) + ) + ) + +;; definition for method 3 of type gsf-buffer +(defmethod inspect ((this gsf-buffer)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gsf-buffer) + (format #t "~1Tdata[8192] @ #x~X~%" (-> this data)) + (format #t "~1Tinfo: #~%" (-> this data)) + (format #t "~1Theader: #~%" (-> this header)) + (format #t "~1Twork-area[0] @ #x~X~%" (-> this work-area)) + (label cfg-4) + this + ) + +;; definition of type generic-frag +(deftype generic-frag (structure) + ((start-pos uint16) + (end-pos uint16) + ) + ) + +;; definition for method 3 of type generic-frag +(defmethod inspect ((this generic-frag)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-frag) + (format #t "~1Tstart-pos: ~D~%" (-> this start-pos)) + (format #t "~1Tend-pos: ~D~%" (-> this end-pos)) + (label cfg-4) + this + ) + +;; definition of type generic-strip +(deftype generic-strip (structure) + ((pos uint16) + (len uint16) + ) + ) + +;; definition for method 3 of type generic-strip +(defmethod inspect ((this generic-strip)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-strip) + (format #t "~1Tpos: ~D~%" (-> this pos)) + (format #t "~1Tlen: ~D~%" (-> this len)) + (label cfg-4) + this + ) + +;; definition of type generic-envmap-saves +(deftype generic-envmap-saves (structure) + ((index-mask vector4w :inline) + (verts uint128 12) + (kicks uint128 4) + ) + ) + +;; definition for method 3 of type generic-envmap-saves +(defmethod inspect ((this generic-envmap-saves)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-envmap-saves) + (format #t "~1Tindex-mask: #~%" (-> this index-mask)) + (format #t "~1Tverts[12] @ #x~X~%" (-> this verts)) + (format #t "~1Tkicks[4] @ #x~X~%" (-> this kicks)) + (label cfg-4) + this + ) + +;; definition of type generic-interp-job +(deftype generic-interp-job (structure) + ((job-type uint16) + (num uint16) + (first uint16) + (pad uint16) + (ptr-data uint32) + (morph-z uint16) + (morph-w uint16) + ) + :pack-me + ) + +;; definition for method 3 of type generic-interp-job +(defmethod inspect ((this generic-interp-job)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-interp-job) + (format #t "~1Tjob-type: ~D~%" (-> this job-type)) + (format #t "~1Tnum: ~D~%" (-> this num)) + (format #t "~1Tfirst: ~D~%" (-> this first)) + (format #t "~1Tpad: ~D~%" (-> this pad)) + (format #t "~1Tptr-data: #x~X~%" (-> this ptr-data)) + (format #t "~1Tmorph-z: ~D~%" (-> this morph-z)) + (format #t "~1Tmorph-w: ~D~%" (-> this morph-w)) + (label cfg-4) + this + ) + +;; definition of type generic-saves +(deftype generic-saves (structure) + ((ptr-dma uint32) + (ptr-vtxs uint32) + (ptr-clrs uint32) + (ptr-texs uint32) + (ptr-env-clrs uint32) + (ptr-env-texs uint32) + (cur-outbuf uint32) + (ptr-fx-buf uint32) + (xor-outbufs uint32) + (num-dps uint32) + (qwc uint32) + (gsf-buf gsf-buffer) + (ptr-shaders uint32) + (ptr-env-shader uint32) + (is-envmap uint16) + (is-translucent uint16) + (basep uint32) + (ptr-interp-job generic-interp-job) + (gifbuf-adr uint32) + (inbuf-adr uint32) + (fade-val uint32) + (time-of-day-color rgba) + (to-vu0-waits uint32) + (to-spr-waits uint32) + (from-spr-waits uint32) + (envmap generic-envmap-saves :inline) + ) + ) + +;; definition for method 3 of type generic-saves +(defmethod inspect ((this generic-saves)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-saves) + (format #t "~1Tptr-dma: #x~X~%" (-> this ptr-dma)) + (format #t "~1Tptr-vtxs: #x~X~%" (-> this ptr-vtxs)) + (format #t "~1Tptr-clrs: #x~X~%" (-> this ptr-clrs)) + (format #t "~1Tptr-texs: #x~X~%" (-> this ptr-texs)) + (format #t "~1Tptr-env-clrs: #x~X~%" (-> this ptr-env-clrs)) + (format #t "~1Tptr-env-texs: #x~X~%" (-> this ptr-env-texs)) + (format #t "~1Tcur-outbuf: #x~X~%" (-> this cur-outbuf)) + (format #t "~1Tptr-fx-buf: ~D~%" (-> this ptr-fx-buf)) + (format #t "~1Txor-outbufs: ~D~%" (-> this xor-outbufs)) + (format #t "~1Tnum-dps: ~D~%" (-> this num-dps)) + (format #t "~1Tqwc: ~D~%" (-> this qwc)) + (format #t "~1Tgsf-buf: #~%" (-> this gsf-buf)) + (format #t "~1Tptr-shaders: #x~X~%" (-> this ptr-shaders)) + (format #t "~1Tptr-env-shader: ~D~%" (-> this ptr-env-shader)) + (format #t "~1Tis-envmap: ~D~%" (-> this is-envmap)) + (format #t "~1Tis-translucent: ~D~%" (-> this is-translucent)) + (format #t "~1Tbasep: #x~X~%" (-> this basep)) + (format #t "~1Tptr-interp-job: #~%" (-> this ptr-interp-job)) + (format #t "~1Tgifbuf-adr: ~D~%" (-> this gifbuf-adr)) + (format #t "~1Tinbuf-adr: ~D~%" (-> this inbuf-adr)) + (format #t "~1Tfade-val: ~D~%" (-> this fade-val)) + (format #t "~1Ttime-of-day-color: ~D~%" (-> this time-of-day-color)) + (format #t "~1Tto-vu0-waits: ~D~%" (-> this to-vu0-waits)) + (format #t "~1Tto-spr-waits: ~D~%" (-> this to-spr-waits)) + (format #t "~1Tfrom-spr-waits: ~D~%" (-> this from-spr-waits)) + (format #t "~1Tenvmap: #~%" (-> this envmap)) + (label cfg-4) + this + ) + +;; definition of type generic-gif-tag +(deftype generic-gif-tag (structure) + ((data uint32 4) + (qword qword :inline :overlay-at (-> data 0)) + (fan-prim gif-tag-prim :overlay-at (-> data 0)) + (str-prim gif-tag-prim :overlay-at (-> data 1)) + (regs gif-tag-regs-32 :overlay-at (-> data 2)) + (num-strips uint32 :overlay-at (-> data 3)) + ) + ) + +;; definition for method 3 of type generic-gif-tag +(defmethod inspect ((this generic-gif-tag)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-gif-tag) + (format #t "~1Tdata[4] @ #x~X~%" (&-> this fan-prim)) + (format #t "~1Tqword: #~%" (&-> this fan-prim)) + (format #t "~1Tfan-prim: ~D~%" (-> this fan-prim)) + (format #t "~1Tstr-prim: ~D~%" (-> this str-prim)) + (format #t "~1Tregs: ~D~%" (-> this regs)) + (format #t "~1Tnum-strips: ~D~%" (-> this num-strips)) + (label cfg-4) + this + ) + +;; definition of type generic-envmap-consts +(deftype generic-envmap-consts (structure) + ((consts vector :inline) + (strgif generic-gif-tag :inline) + (colors vector4w :inline) + (shader adgif-shader :inline) + ) + ) + +;; definition for method 3 of type generic-envmap-consts +(defmethod inspect ((this generic-envmap-consts)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-envmap-consts) + (format #t "~1Tconsts: #~%" (-> this consts)) + (format #t "~1Tstrgif: #~%" (-> this strgif)) + (format #t "~1Tcolors: #~%" (-> this colors)) + (format #t "~1Tshader: #~%" (-> this shader)) + (label cfg-4) + this + ) + +;; definition of type generic-consts +(deftype generic-consts (structure) + ((dma-header dma-packet :inline) + (vif-header uint32 4) + (dma-ref-vtxs dma-packet :inline) + (dma-cnt-call dma-packet :inline) + (matrix matrix :inline) + (base-strgif generic-gif-tag :inline) + (alpha-opaque gs-adcmd :inline) + (alpha-translucent gs-adcmd :inline) + (ztest-normal gs-adcmd :inline) + (ztest-opaque gs-adcmd :inline) + (adcmd-offsets uint8 16) + (stcycle-tag uint32) + (unpack-vtx-tag uint32) + (unpack-clr-tag uint32) + (unpack-tex-tag uint32) + (mscal-tag uint32) + (flush-tag uint32) + (reset-cycle-tag uint32) + (dummy0 uint32) + (dma-tag-cnt uint64) + (envmap generic-envmap-consts :inline) + (light-consts vector :inline) + (texture-offset uint16 8) + ) + ) + +;; definition for method 3 of type generic-consts +(defmethod inspect ((this generic-consts)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-consts) + (format #t "~1Tdma-header: #~%" (-> this dma-header)) + (format #t "~1Tvif-header[4] @ #x~X~%" (-> this vif-header)) + (format #t "~1Tdma-ref-vtxs: #~%" (-> this dma-ref-vtxs)) + (format #t "~1Tdma-cnt-call: #~%" (-> this dma-cnt-call)) + (format #t "~1Tmatrix: #~%" (-> this matrix)) + (format #t "~1Tbase-strgif: #~%" (-> this base-strgif)) + (format #t "~1Talpha-opaque: #~%" (-> this alpha-opaque)) + (format #t "~1Talpha-translucent: #~%" (-> this alpha-translucent)) + (format #t "~1Tztest-normal: #~%" (-> this ztest-normal)) + (format #t "~1Tztest-opaque: #~%" (-> this ztest-opaque)) + (format #t "~1Tadcmd-offsets[16] @ #x~X~%" (-> this adcmd-offsets)) + (format #t "~1Tadcmds[4] @ #x~X~%" (-> this alpha-opaque)) + (format #t "~1Tstcycle-tag: ~D~%" (-> this stcycle-tag)) + (format #t "~1Tunpack-vtx-tag: ~D~%" (-> this unpack-vtx-tag)) + (format #t "~1Tunpack-clr-tag: ~D~%" (-> this unpack-clr-tag)) + (format #t "~1Tunpack-tex-tag: ~D~%" (-> this unpack-tex-tag)) + (format #t "~1Tmscal-tag: ~D~%" (-> this mscal-tag)) + (format #t "~1Tflush-tag: ~D~%" (-> this flush-tag)) + (format #t "~1Treset-cycle-tag: ~D~%" (-> this reset-cycle-tag)) + (format #t "~1Tdummy0: ~D~%" (-> this dummy0)) + (format #t "~1Tdma-tag-cnt: ~D~%" (-> this dma-tag-cnt)) + (format #t "~1Tenvmap: #~%" (-> this envmap)) + (format #t "~1Tlight-consts: #~%" (-> this light-consts)) + (format #t "~1Ttexture-offset[8] @ #x~X~%" (-> this texture-offset)) + (label cfg-4) + this + ) + +;; definition of type generic-storage +(deftype generic-storage (structure) + ((data uint128 16) + ) + ) + +;; definition for method 3 of type generic-storage +(defmethod inspect ((this generic-storage)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-storage) + (format #t "~1Tdata[16] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(kmemopen global "gsf-buffer") + +;; definition for symbol *gsf-buffer*, type object +(define *gsf-buffer* (the-as object (kmalloc global 9216 (kmalloc-flags align-64) "malloc"))) + +;; failed to figure out what this is: +(kmemclose) + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/generic/generic-vu1-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/generic/generic-vu1-h_REF.gc new file mode 100644 index 0000000000..85f73eec51 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/generic/generic-vu1-h_REF.gc @@ -0,0 +1,189 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type pris-mtx +(deftype pris-mtx (structure) + "Matrix for merc rendering. Named after the earlier 'pris' renderer. +Contains a transformation matrix for vertices, one for normals, and a scale. +This matrix is likely not used by generic VU1, but is used by the merc -> generic converter." + ((data float 32) + (vector vector 8 :overlay-at (-> data 0)) + (t-mtx matrix :inline :overlay-at (-> data 0)) + (n-mtx matrix3 :inline :overlay-at (-> data 16)) + (scale vector :inline :overlay-at (-> data 28)) + ) + ) + +;; definition for method 3 of type pris-mtx +(defmethod inspect ((this pris-mtx)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'pris-mtx) + (format #t "~1Tdata[32] @ #x~X~%" (-> this data)) + (format #t "~1Tvector[8] @ #x~X~%" (-> this data)) + (format #t "~1Tt-mtx: #~%" (-> this data)) + (format #t "~1Tn-mtx: #~%" (-> this n-mtx)) + (format #t "~1Tscale: #~%" (-> this scale)) + (label cfg-4) + this + ) + +;; definition of type generic-pris-mtx-save +(deftype generic-pris-mtx-save (structure) + ((loc-mtx pris-mtx :inline) + (par-mtx pris-mtx :inline) + (dif-mtx pris-mtx :inline) + ) + ) + +;; definition for method 3 of type generic-pris-mtx-save +(defmethod inspect ((this generic-pris-mtx-save)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-pris-mtx-save) + (format #t "~1Tloc-mtx: #~%" (-> this loc-mtx)) + (format #t "~1Tpar-mtx: #~%" (-> this par-mtx)) + (format #t "~1Tdif-mtx: #~%" (-> this dif-mtx)) + (label cfg-4) + this + ) + +;; definition of type generic-constants +(deftype generic-constants (structure) + "Constant data sent to VU1 for generic rendering." + ((fog vector :inline) + (adgif gs-gif-tag :inline) + (hvdf-offset vector :inline) + (hmge-scale vector :inline) + (invh-scale vector :inline) + (guard vector :inline) + (flush qword :inline) + (stores qword :inline) + ) + ) + +;; definition for method 3 of type generic-constants +(defmethod inspect ((this generic-constants)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-constants) + (format #t "~1Tfog: #~%" (-> this fog)) + (format #t "~1Tadgif: #~%" (-> this adgif)) + (format #t "~1Thvdf-offset: #~%" (-> this hvdf-offset)) + (format #t "~1Thmge-scale: #~%" (-> this hmge-scale)) + (format #t "~1Tinvh-scale: #~%" (-> this invh-scale)) + (format #t "~1Tguard: #~%" (-> this guard)) + (format #t "~1Tflush: #~%" (-> this flush)) + (format #t "~1Tstores: #~%" (-> this stores)) + (label cfg-4) + this + ) + +;; definition of type generic-shrub-constants +(deftype generic-shrub-constants (structure) + ((shrub-giftag generic-gif-tag :inline) + (shrub-adnop qword :inline) + ) + ) + +;; definition for method 3 of type generic-shrub-constants +(defmethod inspect ((this generic-shrub-constants)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-shrub-constants) + (format #t "~1Tshrub-giftag: #~%" (-> this shrub-giftag)) + (format #t "~1Tshrub-adnop: #~%" (-> this shrub-adnop)) + (label cfg-4) + this + ) + +;; definition of type gcf-shader +(deftype gcf-shader (structure) + ((adgif uint128 5) + (shader adgif-shader :inline :overlay-at (-> adgif 0)) + (pos uint32 :offset 12) + (num uint32 :offset 28) + ) + ) + +;; definition for method 3 of type gcf-shader +(defmethod inspect ((this gcf-shader)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gcf-shader) + (format #t "~1Tadgif[5] @ #x~X~%" (-> this adgif)) + (format #t "~1Tshader: #~%" (-> this adgif)) + (format #t "~1Tpos: ~D~%" (-> this pos)) + (format #t "~1Tnum: ~D~%" (-> this num)) + (label cfg-4) + this + ) + +;; definition of type gcf-control +(deftype gcf-control (structure) + ((matrix matrix :inline) + (giftag generic-gif-tag :inline) + (adnops gs-adcmd 2 :inline) + (num-strips uint32 :overlay-at (-> giftag data 3)) + (num-dps uint32 :overlay-at (-> adnops 0 word 3)) + (kick-offset uint32 :offset 108) + (shader gcf-shader :inline :dynamic) + ) + ) + +;; definition for method 3 of type gcf-control +(defmethod inspect ((this gcf-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gcf-control) + (format #t "~1Tmatrix: #~%" (-> this matrix)) + (format #t "~1Tgiftag: #~%" (-> this giftag)) + (format #t "~1Tadnops[2] @ #x~X~%" (-> this adnops)) + (format #t "~1Tnum-strips: ~D~%" (-> this giftag num-strips)) + (format #t "~1Tnum-dps: ~D~%" (-> this num-dps)) + (format #t "~1Tkick-offset: ~D~%" (-> this kick-offset)) + (format #t "~1Tshader[0] @ #x~X~%" (-> this shader)) + (label cfg-4) + this + ) + +;; definition of type gcf-vertex +(deftype gcf-vertex (structure) + ((tex vector4w :inline) + (clr gs-packed-rgba :inline) + (pos gs-packed-xyzw :inline) + ) + ) + +;; definition for method 3 of type gcf-vertex +(defmethod inspect ((this gcf-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gcf-vertex) + (format #t "~1Ttex: #~%" (-> this tex)) + (format #t "~1Tclr: #~%" (-> this clr)) + (format #t "~1Tpos: #~%" (-> this pos)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/generic/generic-work-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/generic/generic-work-h_REF.gc new file mode 100644 index 0000000000..f5a94b5450 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/generic/generic-work-h_REF.gc @@ -0,0 +1,208 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type generic-input-buffer +(deftype generic-input-buffer (structure) + ((data uint128 473) + (merc generic-merc-work :inline :overlay-at (-> data 0)) + (tie generic-tie-work :inline :overlay-at (-> data 0)) + ) + ) + +;; definition for method 3 of type generic-input-buffer +(defmethod inspect ((this generic-input-buffer)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-input-buffer) + (format #t "~1Tdata[473] @ #x~X~%" (-> this data)) + (format #t "~1Tmerc: #~%" (-> this data)) + (format #t "~1Ttie: #~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type generic-debug +(deftype generic-debug (structure) + ((locks uint32 4) + (timer uint32 32) + (count uint32 32) + (vps uint32 32) + (buffer int32) + (start-addr int32) + (lock int32) + ) + ) + +;; definition for method 3 of type generic-debug +(defmethod inspect ((this generic-debug)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-debug) + (format #t "~1Tlocks[4] @ #x~X~%" (-> this locks)) + (format #t "~1Ttimer[32] @ #x~X~%" (-> this timer)) + (format #t "~1Tcount[32] @ #x~X~%" (-> this count)) + (format #t "~1Tvps[32] @ #x~X~%" (-> this vps)) + (format #t "~1Tbuffer: ~D~%" (-> this buffer)) + (format #t "~1Tstart-addr: ~D~%" (-> this start-addr)) + (format #t "~1Tlock: ~D~%" (-> this lock)) + (label cfg-4) + this + ) + +;; definition of type generic-vu1-header +(deftype generic-vu1-header (structure) + ((matrix matrix :inline) + (strgif generic-gif-tag :inline) + (adcmds gs-adcmd 2 :inline) + (adnop1 gs-adcmd :inline :overlay-at (-> adcmds 0)) + (adnop2 gs-adcmd :inline :overlay-at (-> adcmds 1)) + (dps uint16 :overlay-at (-> adcmds 0 word 3)) + (kickoff uint16 :overlay-at (-> adnop2 w)) + (strips uint16 :overlay-at (-> strgif data 3)) + ) + ) + +;; definition for method 3 of type generic-vu1-header +(defmethod inspect ((this generic-vu1-header)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-vu1-header) + (format #t "~1Tmatrix: #~%" (-> this matrix)) + (format #t "~1Tstrgif: #~%" (-> this strgif)) + (format #t "~1Tadcmds[2] @ #x~X~%" (-> this adcmds)) + (format #t "~1Tadnop1: #~%" (-> this adcmds)) + (format #t "~1Tadnop2: #~%" (-> this adnop2)) + (format #t "~1Tdps: ~D~%" (-> this dps)) + (format #t "~1Tkickoff: ~D~%" (-> this kickoff)) + (format #t "~1Tstrips: ~D~%" (-> this strips)) + (label cfg-4) + this + ) + +;; definition of type generic-vu1-texbuf +(deftype generic-vu1-texbuf (structure) + ((header generic-vu1-header :inline) + (shader uint32 :dynamic) + ) + ) + +;; definition for method 3 of type generic-vu1-texbuf +(defmethod inspect ((this generic-vu1-texbuf)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-vu1-texbuf) + (format #t "~1Theader: #~%" (-> this header)) + (format #t "~1Tshader[0] @ #x~X~%" (-> this shader)) + (label cfg-4) + this + ) + +;; definition of type generic-texbuf +(deftype generic-texbuf (structure) + ((tag dma-packet :inline) + (header generic-vu1-header :inline) + (shader uint32 :dynamic) + ) + ) + +;; definition for method 3 of type generic-texbuf +(defmethod inspect ((this generic-texbuf)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-texbuf) + (format #t "~1Ttag: #~%" (-> this tag)) + (format #t "~1Theader: #~%" (-> this header)) + (format #t "~1Tshader[0] @ #x~X~%" (-> this shader)) + (label cfg-4) + this + ) + +;; definition of type generic-effect-work +(deftype generic-effect-work (structure) + ((consts generic-consts :inline) + (storage generic-storage :inline) + (storage2 generic-storage :inline) + (lights vu-lights :inline) + ) + ) + +;; definition for method 3 of type generic-effect-work +(defmethod inspect ((this generic-effect-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-effect-work) + (format #t "~1Tconsts: #~%" (-> this consts)) + (format #t "~1Tstorage: #~%" (-> this storage)) + (format #t "~1Tstorage2: #~%" (-> this storage2)) + (format #t "~1Tlights: #~%" (-> this lights)) + (label cfg-4) + this + ) + +;; definition of type generic-effect-buffer +(deftype generic-effect-buffer (structure) + ((outbuf-0 uint8 3552) + (work generic-effect-work :inline) + (outbuf-1 uint8 3552) + ) + ) + +;; definition for method 3 of type generic-effect-buffer +(defmethod inspect ((this generic-effect-buffer)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-effect-buffer) + (format #t "~1Toutbuf-0[3552] @ #x~X~%" (-> this outbuf-0)) + (format #t "~1Twork: #~%" (-> this work)) + (format #t "~1Toutbuf-1[3552] @ #x~X~%" (-> this outbuf-1)) + (label cfg-4) + this + ) + +;; definition of type generic-work +(deftype generic-work (structure) + ((saves generic-saves :inline) + (storage generic-storage :inline) + (in-buf generic-input-buffer :inline) + (fx-buf generic-effect-buffer :inline) + ) + ) + +;; definition for method 3 of type generic-work +(defmethod inspect ((this generic-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-work) + (format #t "~1Tsaves: #~%" (-> this saves)) + (format #t "~1Tstorage: #~%" (-> this storage)) + (format #t "~1Tin-buf: #~%" (-> this in-buf)) + (format #t "~1Tfx-buf: #~%" (-> this fx-buf)) + (label cfg-4) + this + ) + +;; definition for symbol *generic-debug*, type generic-debug +(define *generic-debug* (new 'global 'generic-debug)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/generic/lightning/lightning-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/generic/lightning/lightning-h_REF.gc new file mode 100644 index 0000000000..3eda2c35b6 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/generic/lightning/lightning-h_REF.gc @@ -0,0 +1,321 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type lightning-spec +(deftype lightning-spec (basic) + ((name string) + (flags lightning-spec-flags) + (rand-func uint8) + (adjust-distance uint8) + (start-color rgba) + (end-color rgba) + (fade-to-color rgba) + (fade-start-factor float) + (fade-time float) + (texture texture-id) + (reduction float) + (num-points int32) + (box-size float) + (merge-factor float) + (merge-count int32) + (radius float) + (duration float) + (duration-rand float) + (sound sound-spec) + (delay float) + (delay-rand float) + ) + ) + +;; definition for method 3 of type lightning-spec +(defmethod inspect ((this lightning-spec)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Trand-func: ~D~%" (-> this rand-func)) + (format #t "~1Tadjust-distance: ~D~%" (-> this adjust-distance)) + (format #t "~1Tstart-color: ~D~%" (-> this start-color)) + (format #t "~1Tend-color: ~D~%" (-> this end-color)) + (format #t "~1Tfade-to-color: ~D~%" (-> this fade-to-color)) + (format #t "~1Tfade-start-factor: ~f~%" (-> this fade-start-factor)) + (format #t "~1Tfade-time: ~f~%" (-> this fade-time)) + (format #t "~1Ttexture: ~D~%" (-> this texture)) + (format #t "~1Treduction: ~f~%" (-> this reduction)) + (format #t "~1Tnum-points: ~D~%" (-> this num-points)) + (format #t "~1Tbox-size: ~f~%" (-> this box-size)) + (format #t "~1Tmerge-factor: ~f~%" (-> this merge-factor)) + (format #t "~1Tmerge-count: ~D~%" (-> this merge-count)) + (format #t "~1Tradius: ~f~%" (-> this radius)) + (format #t "~1Tduration: ~f~%" (-> this duration)) + (format #t "~1Tduration-rand: ~f~%" (-> this duration-rand)) + (format #t "~1Tsound: #~%" (-> this sound)) + (format #t "~1Tdelay: ~f~%" (-> this delay)) + (format #t "~1Tdelay-rand: ~f~%" (-> this delay-rand)) + (label cfg-4) + this + ) + +;; definition for function lookup-lightning-spec-by-name +(defun lookup-lightning-spec-by-name ((arg0 string)) + (let* ((s5-0 *lightning-spec-id-table*) + (s4-0 (-> s5-0 length)) + ) + (dotimes (s3-0 s4-0) + (let ((s2-0 (-> s5-0 s3-0))) + (if (and (nonzero? s2-0) (string= arg0 (-> s2-0 name))) + (return s2-0) + ) + ) + ) + ) + (the-as lightning-spec #f) + ) + +;; definition of type lightning-state +(deftype lightning-state (structure) + ((mode uint8) + (counter float) + (points-to-draw int32) + (box-size float) + (gcf-control gcf-control :inline) + (line vector-array) + (meet vector-array) + (path vector-array) + (start-color rgba) + (end-color rgba) + ) + ) + +;; definition for method 3 of type lightning-state +(defmethod inspect ((this lightning-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'lightning-state) + (format #t "~1Tmode: ~D~%" (-> this mode)) + (format #t "~1Tcounter: ~f~%" (-> this counter)) + (format #t "~1Tpoints-to-draw: ~D~%" (-> this points-to-draw)) + (format #t "~1Tbox-size: ~f~%" (-> this box-size)) + (format #t "~1Tgcf-control: #~%" (-> this gcf-control)) + (format #t "~1Tline: ~A~%" (-> this line)) + (format #t "~1Tmeet: ~A~%" (-> this meet)) + (format #t "~1Tpath: ~A~%" (-> this path)) + (format #t "~1Tstart-color: ~D~%" (-> this start-color)) + (format #t "~1Tend-color: ~D~%" (-> this end-color)) + (label cfg-4) + this + ) + +;; definition of type lightning-control +(deftype lightning-control (basic) + ((spec lightning-spec) + (process (pointer process)) + (state lightning-state :inline) + ) + (:methods + (new (symbol type lightning-spec process float) _type_) + (change-mode (_type_ lightning-mode) lightning-mode) + (get-mode (_type_) lightning-mode) + (set-point! (_type_ int vector) none) + (set-first-meet-point (_type_ vector) none) + (set-last-meet-point (_type_ vector) none) + ) + ) + +;; definition for method 3 of type lightning-control +(defmethod inspect ((this lightning-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tspec: ~A~%" (-> this spec)) + (format #t "~1Tprocess: #x~X~%" (-> this process)) + (format #t "~1Tstate: #~%" (-> this state)) + (label cfg-4) + this + ) + +;; definition for method 9 of type lightning-control +(defmethod change-mode ((this lightning-control) (arg0 lightning-mode)) + (let ((v1-1 (!= arg0 (-> this state mode)))) + (case arg0 + (((lightning-mode lm3)) + (if v1-1 + (set! (-> this state counter) 0.0) + ) + ) + (((lightning-mode lm1)) + (set! (-> this state start-color) (-> this spec start-color)) + (set! (-> this state end-color) (-> this spec end-color)) + ) + ) + ) + (set! (-> this state mode) (the-as uint arg0)) + arg0 + ) + +;; definition for method 10 of type lightning-control +;; WARN: Return type mismatch uint vs lightning-mode. +(defmethod get-mode ((this lightning-control)) + (the-as lightning-mode (-> this state mode)) + ) + +;; definition for method 11 of type lightning-control +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod set-point! ((this lightning-control) (arg0 int) (arg1 vector)) + (let ((v1-0 (-> this state))) + (when (and (-> v1-0 path) (>= arg0 0) (< arg0 (-> v1-0 path length))) + (set! (-> v1-0 path data arg0 quad) (-> arg1 quad)) + (when (and (< (+ (-> v1-0 points-to-draw) -1) arg0) (case (-> v1-0 mode) + ((2 3) + #t + ) + (else + #f + ) + ) + ) + (set! (-> v1-0 line data arg0 quad) (-> arg1 quad)) + (set! (-> v1-0 meet data arg0 quad) (-> arg1 quad)) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type lightning-control +;; INFO: Used lq/sq +;; WARN: Return type mismatch (inline-array vector) vs none. +(defmethod set-first-meet-point ((this lightning-control) (arg0 vector)) + (set! (-> this state meet data 0 quad) (-> arg0 quad)) + (none) + ) + +;; definition for method 13 of type lightning-control +;; INFO: Used lq/sq +;; WARN: Return type mismatch vector vs none. +(defmethod set-last-meet-point ((this lightning-control) (arg0 vector)) + (set! (-> this state meet data (+ (-> this state points-to-draw) -1) quad) (-> arg0 quad)) + (none) + ) + +;; definition for method 7 of type lightning-control +(defmethod relocate ((this lightning-control) (offset int)) + (&+! (-> this state line) offset) + (&+! (-> this state meet) offset) + (if (-> this state path) + (&+! (-> this state path) offset) + ) + (let ((v1-8 (-> this spec))) + (if (and (>= (the-as int v1-8) (-> *kernel-context* relocating-min)) + (< (the-as int v1-8) (-> *kernel-context* relocating-max)) + ) + (&+! (-> this spec) offset) + ) + ) + this + ) + +;; definition for method 0 of type lightning-control +;; WARN: Return type mismatch object vs lightning-control. +(defmethod new lightning-control ((allocation symbol) (type-to-make type) (arg0 lightning-spec) (arg1 process) (arg2 float)) + (with-pp + (let ((gp-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (when (zero? (the-as lightning-control gp-0)) + (go process-drawable-art-error "memory") + (set! gp-0 0) + (goto cfg-14) + ) + (let ((s3-0 (-> arg0 num-points))) + (let ((f0-0 (-> arg0 box-size))) + (when (logtest? (-> arg0 flags) (lightning-spec-flags lsf4)) + (let ((f1-1 (fmax 1.0 (fmin 5.0 (/ arg2 (* 4096.0 (the float (-> arg0 adjust-distance)))))))) + (set! s3-0 (* s3-0 (the int f1-1))) + (set! f0-0 (* f0-0 f1-1)) + ) + ) + (set! (-> (the-as lightning-control gp-0) state box-size) f0-0) + ) + (set! (-> (the-as lightning-control gp-0) process) (process->ppointer arg1)) + (set! (-> (the-as lightning-control gp-0) state mode) (the-as uint 1)) + (set! (-> (the-as lightning-control gp-0) state line) + ((method-of-type vector-array new) allocation vector-array s3-0) + ) + (set! (-> (the-as lightning-control gp-0) state meet) + ((method-of-type vector-array new) allocation vector-array s3-0) + ) + (let ((v1-18 (-> arg0 rand-func))) + (set! (-> (the-as lightning-control gp-0) state path) + (if (or (= v1-18 2) (= v1-18 3)) + ((method-of-type vector-array new) allocation vector-array s3-0) + (the-as vector-array #f) + ) + ) + ) + (set! (-> (the-as lightning-control gp-0) state counter) 0.0) + (set! (-> (the-as lightning-control gp-0) state points-to-draw) s3-0) + ) + (set! (-> (the-as lightning-control gp-0) spec) arg0) + (set! (-> (the-as lightning-control gp-0) state start-color) (-> arg0 start-color)) + (set! (-> (the-as lightning-control gp-0) state end-color) (-> arg0 end-color)) + (add-connection *lightning-engine* pp nothing (the-as lightning-control gp-0) #f #f) + (label cfg-14) + (the-as lightning-control gp-0) + ) + ) + ) + +;; definition of type lightning-probe-vars +(deftype lightning-probe-vars (basic) + ((src-joint-index uint32) + (next-spawn-time time-frame) + (last-valid-time time-frame) + (point vector 2 :inline) + (start-pos vector :inline :overlay-at (-> point 0)) + (end-pos vector :inline :overlay-at (-> point 1)) + (probe-dirs (inline-array vector)) + ) + ) + +;; definition for method 3 of type lightning-probe-vars +(defmethod inspect ((this lightning-probe-vars)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tsrc-joint-index: ~D~%" (-> this src-joint-index)) + (format #t "~1Tnext-spawn-time: ~D~%" (-> this next-spawn-time)) + (format #t "~1Tlast-valid-time: ~D~%" (-> this last-valid-time)) + (format #t "~1Tpoint[2] @ #x~X~%" (-> this point)) + (format #t "~1Tstart-pos: #~%" (-> this point)) + (format #t "~1Tend-pos: #~%" (-> this end-pos)) + (format #t "~1Tprobe-dirs: #x~X~%" (-> this probe-dirs)) + (label cfg-4) + this + ) + +;; definition for symbol *lightning-probe-vars*, type lightning-probe-vars +(define *lightning-probe-vars* (new 'static 'lightning-probe-vars + :probe-dirs (new 'static 'inline-array vector 6 + (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 1.0 1.0)) + (new 'static 'vector :data (new 'static 'array float 4 1.0 0.0 0.0 1.0)) + (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 -1.0 1.0)) + (new 'static 'vector :data (new 'static 'array float 4 -1.0 0.0 0.0 1.0)) + (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0)) + (new 'static 'vector :data (new 'static 'array float 4 0.0 -1.0 0.0 1.0)) + ) + ) + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/hw/display-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/hw/display-h_REF.gc new file mode 100644 index 0000000000..d4661e7d02 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/hw/display-h_REF.gc @@ -0,0 +1,182 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type display-frame +(deftype display-frame (basic) + ((buffer dma-buffer 11) + (calc-buf dma-buffer :overlay-at (-> buffer 1)) + (vu1-buf dma-buffer :overlay-at (-> buffer 1)) + (debug-buf dma-buffer :overlay-at (-> buffer 8)) + (global-buf dma-buffer :overlay-at (-> buffer 9)) + (bucket-group (inline-array dma-bucket) :overlay-at (-> buffer 10)) + (profile-array profile-array :inline :offset 48) + (start-time uint64 :offset 56) + (run-time uint64 :offset 64) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +;; definition for method 3 of type display-frame +(defmethod inspect ((this display-frame)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tbuffer[11] @ #x~X~%" (-> this buffer)) + (format #t "~1Tcalc-buf: ~A~%" (-> this calc-buf)) + (format #t "~1Tvu1-buf: ~A~%" (-> this calc-buf)) + (format #t "~1Tdebug-buf: ~A~%" (-> this debug-buf)) + (format #t "~1Tglobal-buf: ~A~%" (-> this global-buf)) + (format #t "~1Tbucket-group: #~%" (-> this bucket-group)) + (format #t "~1Tprofile-array: #~%" (-> this profile-array)) + (format #t "~1Tstart-time: ~D~%" (-> this start-time)) + (format #t "~1Trun-time: ~D~%" (-> this run-time)) + (label cfg-4) + this + ) + +;; definition for method 0 of type display-frame +(defmethod new display-frame ((allocation symbol) (type-to-make type)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> gp-0 calc-buf) (the-as dma-buffer 0)) + (set! (-> gp-0 global-buf) (the-as dma-buffer 0)) + (set! (-> gp-0 debug-buf) (the-as dma-buffer 0)) + (when *debug-segment* + (set! (-> gp-0 profile-array data 0) (new 'debug 'profile-segment-array)) + (set! (-> gp-0 profile-array data 1) (new 'debug 'profile-segment-array)) + ) + gp-0 + ) + ) + +;; definition of type display +(deftype display (basic) + ((on-screen int32) + (last-screen int32) + (frames display-frame 2) + (bgcolor uint64) + (pmode uint64) + (clock clock 22) + (session-clock clock :overlay-at (-> clock 0)) + (game-clock clock :overlay-at (-> clock 1)) + (base-clock clock :overlay-at (-> clock 2)) + (real-clock clock :overlay-at (-> clock 3)) + (frame-clock clock :overlay-at (-> clock 4)) + (real-frame-clock clock :overlay-at (-> clock 5)) + (target-clock clock :overlay-at (-> clock 6)) + (entity-clock clock :overlay-at (-> clock 7)) + (part-clock clock :overlay-at (-> clock 8)) + (bg-clock clock :overlay-at (-> clock 9)) + (camera-clock clock :overlay-at (-> clock 10)) + (total-game-clock clock :overlay-at (-> clock 11)) + (user0-clock clock :overlay-at (-> clock 12)) + (user1-clock clock :overlay-at (-> clock 13)) + (user2-clock clock :overlay-at (-> clock 14)) + (user3-clock clock :overlay-at (-> clock 15)) + (user4-clock clock :overlay-at (-> clock 16)) + (user5-clock clock :overlay-at (-> clock 17)) + (user6-clock clock :overlay-at (-> clock 18)) + (user7-clock clock :overlay-at (-> clock 19)) + (user8-clock clock :overlay-at (-> clock 20)) + (user9-clock clock :overlay-at (-> clock 21)) + (time-factor float) + (dog-ratio float) + (vblank-start-time int64 2) + (total-run-time uint64) + (run-half-speed symbol) + (vu1-enable-user uint64) + (vu1-enable-user-menu uint64) + (force-sync uint32) + (mem-reserve-size uint32) + (dma-buffer-overflow symbol) + (default-end-buffer basic) + (init-buffer-zbuf-on basic) + (init-buffer-zbuf-off basic) + ) + (:methods + (new (symbol type int int int int int) _type_) + (set-time-ratios (_type_ float) float) + ) + ) + +;; definition for method 3 of type display +(defmethod inspect ((this display)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ton-screen: ~D~%" (-> this on-screen)) + (format #t "~1Tlast-screen: ~D~%" (-> this last-screen)) + (format #t "~1Tframes[2] @ #x~X~%" (-> this frames)) + (format #t "~1Tbgcolor: #x~X~%" (-> this bgcolor)) + (format #t "~1Tpmode: ~D~%" (-> this pmode)) + (format #t "~1Tclock[22] @ #x~X~%" (-> this clock)) + (format #t "~1Tsession-clock: ~A~%" (-> this session-clock)) + (format #t "~1Tgame-clock: ~A~%" (-> this game-clock)) + (format #t "~1Tbase-clock: ~A~%" (-> this base-clock)) + (format #t "~1Treal-clock: ~A~%" (-> this real-clock)) + (format #t "~1Tframe-clock: ~A~%" (-> this frame-clock)) + (format #t "~1Treal-frame-clock: ~A~%" (-> this real-frame-clock)) + (format #t "~1Ttarget-clock: ~A~%" (-> this target-clock)) + (format #t "~1Tentity-clock: ~A~%" (-> this entity-clock)) + (format #t "~1Tpart-clock: ~A~%" (-> this part-clock)) + (format #t "~1Tbg-clock: ~A~%" (-> this bg-clock)) + (format #t "~1Tcamera-clock: ~A~%" (-> this camera-clock)) + (format #t "~1Ttotal-game-clock: ~A~%" (-> this total-game-clock)) + (format #t "~1Tuser0-clock: ~A~%" (-> this user0-clock)) + (format #t "~1Tuser1-clock: ~A~%" (-> this user1-clock)) + (format #t "~1Tuser2-clock: ~A~%" (-> this user2-clock)) + (format #t "~1Tuser3-clock: ~A~%" (-> this user3-clock)) + (format #t "~1Tuser4-clock: ~A~%" (-> this user4-clock)) + (format #t "~1Tuser5-clock: ~A~%" (-> this user5-clock)) + (format #t "~1Tuser6-clock: ~A~%" (-> this user6-clock)) + (format #t "~1Tuser7-clock: ~A~%" (-> this user7-clock)) + (format #t "~1Tuser8-clock: ~A~%" (-> this user8-clock)) + (format #t "~1Tuser9-clock: ~A~%" (-> this user9-clock)) + (format #t "~1Ttime-factor: ~f~%" (-> this time-factor)) + (format #t "~1Tdog-ratio: ~f~%" (-> this dog-ratio)) + (format #t "~1Tvblank-start-time[2] @ #x~X~%" (-> this vblank-start-time)) + (format #t "~1Ttotal-run-time: ~D~%" (-> this total-run-time)) + (format #t "~1Trun-half-speed: ~A~%" (-> this run-half-speed)) + (format #t "~1Tvu1-enable-user: ~D~%" (-> this vu1-enable-user)) + (format #t "~1Tvu1-enable-user-menu: ~D~%" (-> this vu1-enable-user-menu)) + (format #t "~1Tforce-sync: ~D~%" (-> this force-sync)) + (format #t "~1Tmem-reserve-size: ~D~%" (-> this mem-reserve-size)) + (format #t "~1Tdma-buffer-overflow: ~A~%" (-> this dma-buffer-overflow)) + (format #t "~1Tdefault-end-buffer: ~A~%" (-> this default-end-buffer)) + (format #t "~1Tinit-buffer-zbuf-on: ~A~%" (-> this init-buffer-zbuf-on)) + (format #t "~1Tinit-buffer-zbuf-off: ~A~%" (-> this init-buffer-zbuf-off)) + (label cfg-4) + this + ) + +;; definition for method 0 of type display +(defmethod new display ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 int)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set-display gp-0) + (set! (-> gp-0 frames 0) (new 'global 'display-frame)) + (set! (-> gp-0 frames 1) (new 'global 'display-frame)) + (set! (-> gp-0 pmode) (the-as uint 165)) + (set! (-> gp-0 run-half-speed) #f) + (set! (-> gp-0 vu1-enable-user-menu) (the-as uint #x5fffffff8)) + (set! (-> gp-0 vu1-enable-user) (the-as uint #x5fffffff8)) + gp-0 + ) + ) + +;; definition for symbol *pre-draw-hook*, type (function object none) +(define *pre-draw-hook* (the-as (function object none) nothing)) + +;; definition for symbol *post-draw-hook*, type (function dma-buffer none) +(define *post-draw-hook* (the-as (function dma-buffer none) nothing)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/hw/gs_REF.gc b/test/decompiler/reference/jakx/engine/gfx/hw/gs_REF.gc new file mode 100644 index 0000000000..e1c7cef0c4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/hw/gs_REF.gc @@ -0,0 +1,962 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type gs-pmode +(deftype gs-pmode (uint64) + ((en1 uint8 :offset 0 :size 1) + (en2 uint8 :offset 1 :size 1) + (crtmd uint8 :offset 2 :size 3) + (mmod uint8 :offset 5 :size 1) + (amod uint8 :offset 6 :size 1) + (slbg uint8 :offset 7 :size 1) + (alp uint8 :offset 8 :size 8) + ) + ) + +;; definition of type gs-smode2 +(deftype gs-smode2 (uint64) + ((int uint8 :offset 0 :size 1) + (ffmd uint8 :offset 1 :size 1) + (dpms uint8 :offset 2 :size 2) + ) + ) + +;; definition for function psm-size +(defun psm-size ((arg0 gs-psm)) + (cond + ((= arg0 (gs-psm mt8)) + 64 + ) + ((= arg0 (gs-psm mt4)) + 32 + ) + ((or (= arg0 (gs-psm ct16)) (= arg0 (gs-psm ct16s)) (= arg0 (gs-psm mz16)) (= arg0 (gs-psm mz16s))) + 128 + ) + (else + 256 + ) + ) + ) + +;; definition for function psm-page-height +(defun psm-page-height ((arg0 gs-psm)) + (cond + ((= arg0 (gs-psm mt8)) + 64 + ) + ((= arg0 (gs-psm mt4)) + 128 + ) + ((or (= arg0 (gs-psm ct16)) (= arg0 (gs-psm ct16s)) (= arg0 (gs-psm mz16)) (= arg0 (gs-psm mz16s))) + 64 + ) + (else + 32 + ) + ) + ) + +;; definition for function psm->string +(defun psm->string ((arg0 gs-psm)) + (case arg0 + (((gs-psm ct24)) + "ct24" + ) + (((gs-psm mt4)) + "mt4" + ) + (((gs-psm ct32)) + "ct32" + ) + (((gs-psm mz16s)) + "mz16s" + ) + (((gs-psm ct16s)) + "ct16s" + ) + (((gs-psm mt8)) + "mt8" + ) + (((gs-psm mt8h)) + "mt8h" + ) + (((gs-psm mz16)) + "mz16" + ) + (((gs-psm mz24)) + "mz24" + ) + (((gs-psm mt4hh)) + "mt4hh" + ) + (((gs-psm ct16)) + "ct16" + ) + (((gs-psm mt4hl)) + "mt4hl" + ) + (((gs-psm mz32)) + "mz32" + ) + (else + "*unknown*" + ) + ) + ) + +;; definition of type gs-display-fb +(deftype gs-display-fb (uint64) + ((fbp uint16 :offset 0 :size 9) + (fbw uint8 :offset 9 :size 6) + (psm gs-psm :offset 15 :size 5) + (dbx uint16 :offset 32 :size 11) + (dby uint16 :offset 43 :size 11) + ) + ) + +;; definition of type gs-display +(deftype gs-display (uint64) + "the GS's DISPLAY registers make settings for the display position on the screen regarding +information on Rectangular Area Read Output Circuit n for the PCRTC. +write-only" + ((dx uint16 :offset 0 :size 12) + (dy uint16 :offset 12 :size 11) + (magh uint8 :offset 23 :size 4) + (magv uint8 :offset 27 :size 2) + (dw uint16 :offset 32 :size 12) + (dh uint16 :offset 44 :size 11) + ) + ) + +;; definition of type gs-bgcolor +(deftype gs-bgcolor (uint64) + "The GS's BGCOLOR register sets the background color of the PCRTC with RGB value. +write-only" + ((r uint8 :offset 0 :size 8) + (g uint8 :offset 8 :size 8) + (b uint8 :offset 16 :size 8) + ) + ) + +;; definition of type gs-csr +(deftype gs-csr (uint64) + "The GS's CSR register sets and obtains various GS statuses. +read-write. The fields have different effects depending on whether they're being read from +or written to. + +Bits 5 and 6 (0x20 and 0x40) should be zero." + ((signal uint8 :offset 0 :size 1) + (finish uint8 :offset 1 :size 1) + (hsint uint8 :offset 2 :size 1) + (vsint uint8 :offset 3 :size 1) + (edwint uint8 :offset 4 :size 1) + (flush uint8 :offset 8 :size 1) + (reset uint8 :offset 9 :size 1) + (nfield uint8 :offset 12 :size 1) + (field uint8 :offset 13 :size 1) + (fifo uint8 :offset 14 :size 2) + (rev uint8 :offset 16 :size 8) + (id uint8 :offset 24 :size 8) + ) + ) + +;; definition of type gs-bank +(deftype gs-bank (structure) + "Memory layout of the GS's privileged registers (mapped to EE memory). +It is missing the SIGLBLID/LABELID register at 4224 (useless anyway?)" + ((pmode gs-pmode) + (smode2 gs-smode2 :offset 32) + (dspfb1 gs-display-fb :offset 112) + (display1 gs-display :offset 128) + (dspfb2 gs-display-fb :offset 144) + (display2 gs-display :offset 160) + (extbuf uint64 :offset 176) + (extdata uint64 :offset 192) + (extwrite uint64 :offset 208) + (bgcolor gs-bgcolor :offset 224) + (csr gs-csr :offset 4096) + (imr uint64 :offset 4112) + (busdir uint64 :offset 4160) + ) + ) + +;; definition for method 3 of type gs-bank +(defmethod inspect ((this gs-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-bank) + (format #t "~1Tpmode: #x~X~%" (-> this pmode)) + (format #t "~1Tsmode2: #x~X~%" (-> this smode2)) + (format #t "~1Tdspfb1: #x~X~%" (-> this dspfb1)) + (format #t "~1Tdisplay1: #x~X~%" (-> this display1)) + (format #t "~1Tdspfb2: #x~X~%" (-> this dspfb2)) + (format #t "~1Tdisplay2: #x~X~%" (-> this display2)) + (format #t "~1Textbuf: #x~X~%" (-> this extbuf)) + (format #t "~1Textdata: #x~X~%" (-> this extdata)) + (format #t "~1Textwrite: #x~X~%" (-> this extwrite)) + (format #t "~1Tbgcolor: #x~X~%" (-> this bgcolor)) + (format #t "~1Tcsr: #x~X~%" (-> this csr)) + (format #t "~1Timr: #x~X~%" (-> this imr)) + (format #t "~1Tbusdir: #x~X~%" (-> this busdir)) + (label cfg-4) + this + ) + +;; type gs-frame is defined here, but it is unknown to the decompiler + +;; type gs-zbuf is defined here, but it is unknown to the decompiler + +;; type gs-xy-offset is defined here, but it is unknown to the decompiler + +;; type gs-scissor is defined here, but it is unknown to the decompiler + +;; type gs-prmode-cont is defined here, but it is unknown to the decompiler + +;; type gs-color-clamp is defined here, but it is unknown to the decompiler + +;; type gs-dthe is defined here, but it is unknown to the decompiler + +;; definition of type gs-test +(deftype gs-test (uint64) + "The GS's TEST register performs settings related to the pixel test." + ((ate uint8 :offset 0 :size 1) + (atst gs-atest :offset 1 :size 3) + (aref uint8 :offset 4 :size 8) + (afail uint8 :offset 12 :size 2) + (date uint8 :offset 14 :size 1) + (datm uint8 :offset 15 :size 1) + (zte uint8 :offset 16 :size 1) + (ztst gs-ztest :offset 17 :size 2) + ) + ) + +;; definition of type gs-prim +(deftype gs-prim (uint64) + ((prim gs-prim-type :offset 0 :size 3) + (iip uint8 :offset 3 :size 1) + (tme uint8 :offset 4 :size 1) + (fge uint8 :offset 5 :size 1) + (abe uint8 :offset 6 :size 1) + (aa1 uint8 :offset 7 :size 1) + (fst uint8 :offset 8 :size 1) + (ctxt uint8 :offset 9 :size 1) + (fix uint8 :offset 10 :size 1) + ) + ) + +;; type gs-rgbaq is defined here, but it is unknown to the decompiler + +;; type gs-xyz is defined here, but it is unknown to the decompiler + +;; type gs-uv is defined here, but it is unknown to the decompiler + +;; type gs-st is defined here, but it is unknown to the decompiler + +;; type gs-xyzf is defined here, but it is unknown to the decompiler + +;; definition of type gs-adcmd +(deftype gs-adcmd (structure) + ((word uint32 4) + (quad uint128 :overlay-at (-> word 0)) + (data uint64 :overlay-at (-> word 0)) + (cmds gs-reg64 :overlay-at (-> word 2)) + (cmd uint8 :overlay-at (-> word 2)) + (x uint32 :overlay-at (-> word 0)) + (y uint32 :overlay-at (-> word 1)) + (z uint32 :overlay-at (-> word 2)) + (w uint32 :overlay-at (-> word 3)) + ) + ) + +;; definition for method 3 of type gs-adcmd +;; INFO: Used lq/sq +(defmethod inspect ((this gs-adcmd)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-adcmd) + (format #t "~1Tword[4] @ #x~X~%" (&-> this x)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Tdata: ~D~%" (-> this data)) + (format #t "~1Tcmds: ~D~%" (-> this cmds)) + (format #t "~1Tcmd: ~D~%" (-> this cmd)) + (format #t "~1Tx: ~D~%" (-> this x)) + (format #t "~1Ty: ~D~%" (-> this y)) + (format #t "~1Tz: ~D~%" (-> this z)) + (format #t "~1Tw: ~D~%" (-> this w)) + (label cfg-4) + this + ) + +;; definition of type gs-trxpos +(deftype gs-trxpos (uint64) + "The GS's TRXPOS register specifies the position and +scanning direction of the rectangular area +in each buffer where buffer transmission is performed." + ((ssax uint16 :offset 0 :size 11) + (ssay uint16 :offset 16 :size 11) + (dsax uint16 :offset 32 :size 11) + (dsay uint16 :offset 48 :size 11) + (dir uint8 :offset 59 :size 2) + ) + ) + +;; definition of type gs-trxreg +(deftype gs-trxreg (uint64) + "The GS's TRXREG register specifies the size of the rectangular area, where the transmission +between buffers is implemented, in units of pixels. +The pixel mode must be the one set by the BITBLTBUF register." + ((rrw uint16 :offset 0 :size 12) + (rrh uint16 :offset 32 :size 12) + ) + ) + +;; definition of type gs-trxdir +(deftype gs-trxdir (uint64) + "The GS's TRXDIR register specifies the transmission direction in the transmission between +buffers, and activates transmission. +Appropriate settings must be made by the BITBLTBUF/TRXPOS/TRXREG before activating +the transmission." + ((xdir uint8 :offset 0 :size 2) + ) + ) + +;; definition of type gs-bitbltbuf +(deftype gs-bitbltbuf (uint64) + "The GS's BITBLTBUF register stores buffer-related settings for transmission source and +destination during transmission between buffers." + ((sbp uint16 :offset 0 :size 14) + (sbw uint8 :offset 16 :size 6) + (spsm uint8 :offset 24 :size 6) + (dbp uint16 :offset 32 :size 14) + (dbw uint8 :offset 48 :size 6) + (dpsm gs-psm :offset 56 :size 6) + ) + ) + +;; definition of type gs-tex0 +(deftype gs-tex0 (uint64) + "The GS's TEX0 registers set various kinds of information regarding the textures to be used." + ((tbp0 uint16 :offset 0 :size 14) + (tbw uint8 :offset 14 :size 6) + (psm uint8 :offset 20 :size 6) + (tw uint8 :offset 26 :size 4) + (th uint8 :offset 30 :size 4) + (tcc uint8 :offset 34 :size 1) + (tfx uint8 :offset 35 :size 2) + (cbp uint16 :offset 37 :size 14) + (cpsm uint8 :offset 51 :size 4) + (csm uint8 :offset 55 :size 1) + (csa uint8 :offset 56 :size 5) + (cld uint8 :offset 61 :size 3) + ) + ) + +;; definition of type gs-tex1 +(deftype gs-tex1 (uint64) + "The GS's TEX1 registers set information on the sampling method of the textures." + ((lcm uint8 :offset 0 :size 1) + (mxl uint8 :offset 2 :size 3) + (mmag uint8 :offset 5 :size 1) + (mmin uint8 :offset 6 :size 3) + (mtba uint8 :offset 9 :size 1) + (l uint8 :offset 19 :size 2) + (k int16 :offset 32 :size 12) + ) + ) + +;; definition of type gs-texa +(deftype gs-texa (uint64) + "The GS's TEXA register sets the Alpha value to be referred to when the Alpha value of the +texture is not an 8-bit value." + ((ta0 uint8 :offset 0 :size 8) + (aem uint8 :offset 15 :size 1) + (ta1 uint8 :offset 32 :size 8) + ) + ) + +;; definition of type gs-texclut +(deftype gs-texclut (uint64) + "The GS's TEXCLUT register specifies the CLUT position in the buffer when the CLUT storage mode +is CSM=1 (CSM2 mode)." + ((cbw uint8 :offset 0 :size 6) + (cou uint8 :offset 6 :size 6) + (cov uint16 :offset 12 :size 10) + ) + ) + +;; definition of type gs-miptbp +(deftype gs-miptbp (uint64) + "the GS's MIPTBP registers set the buffer pointer and buffer width of textures when performing +MIPMAP. MIPTBP1 sets levels 1 to 3, MIPTBP2 sets levels 4 to 6." + ((tbp1 uint16 :offset 0 :size 14) + (tbw1 uint8 :offset 14 :size 6) + (tbp2 uint16 :offset 20 :size 14) + (tbw2 uint8 :offset 34 :size 6) + (tbp3 uint16 :offset 40 :size 14) + (tbw3 uint8 :offset 54 :size 6) + ) + ) + +;; definition of type gs-alpha +(deftype gs-alpha (uint64) + ((a uint8 :offset 0 :size 2) + (b uint8 :offset 2 :size 2) + (c uint8 :offset 4 :size 2) + (d uint8 :offset 6 :size 2) + (fix uint8 :offset 32 :size 8) + ) + ) + +;; definition for method 3 of type gs-alpha +(defmethod inspect ((this gs-alpha)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-alpha) + (format #t "~1Ta: ~D~%" (-> this a)) + (format #t "~1Tb: ~D~%" (-> this b)) + (format #t "~1Tc: ~D~%" (-> this c)) + (format #t "~1Td: ~D~%" (-> this d)) + (format #t "~1Tfix: ~D~%" (-> this fix)) + (label cfg-4) + this + ) + +;; definition of type gs-clamp +(deftype gs-clamp (uint64) + ((wms gs-tex-wrap-mode :offset 0 :size 2) + (wmt gs-tex-wrap-mode :offset 2 :size 2) + (minu uint16 :offset 4 :size 10) + (maxu uint16 :offset 14 :size 10) + (minv uint16 :offset 24 :size 10) + (maxv uint16 :offset 34 :size 10) + ) + ) + +;; definition of type gs-fog +(deftype gs-fog (uint64) + ((f uint8 :offset 56 :size 8) + ) + ) + +;; definition for method 3 of type gs-fog +(defmethod inspect ((this gs-fog)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-fog) + (format #t "~1Tf: ~D~%" (-> this f)) + (label cfg-4) + this + ) + +;; definition of type gs-fogcol +(deftype gs-fogcol (uint64) + ((fcr uint8 :offset 0 :size 8) + (fcg uint8 :offset 8 :size 8) + (fcb uint8 :offset 16 :size 8) + ) + ) + +;; definition for method 3 of type gs-fogcol +(defmethod inspect ((this gs-fogcol)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-fogcol) + (format #t "~1Tr: ~D~%" (-> this fcr)) + (format #t "~1Tg: ~D~%" (-> this fcg)) + (format #t "~1Tb: ~D~%" (-> this fcb)) + (label cfg-4) + this + ) + +;; definition of type gif-ctrl +(deftype gif-ctrl (uint32) + ((rst uint8 :offset 0 :size 1) + (pse uint8 :offset 3 :size 1) + ) + ) + +;; definition of type gif-mode +(deftype gif-mode (uint32) + ((m3r uint8 :offset 0 :size 1) + (imt uint8 :offset 2 :size 1) + ) + ) + +;; definition of type gif-stat +(deftype gif-stat (uint32) + ((m3r uint8 :offset 0 :size 1) + (m3p uint8 :offset 1 :size 1) + (imt uint8 :offset 2 :size 1) + (pse uint8 :offset 3 :size 1) + (ip3 uint8 :offset 5 :size 1) + (p3q uint8 :offset 6 :size 1) + (p2q uint8 :offset 7 :size 1) + (p1q uint8 :offset 8 :size 1) + (oph uint8 :offset 9 :size 1) + (apath uint8 :offset 10 :size 2) + (dir uint8 :offset 12 :size 1) + (fqc uint8 :offset 24 :size 5) + ) + ) + +;; definition of type gif-cnt +(deftype gif-cnt (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (regcnt uint8 :offset 16 :size 4) + (vuaddr uint16 :offset 20 :size 10) + ) + ) + +;; definition of type gif-p3cnt +(deftype gif-p3cnt (uint32) + ((p3cnt uint16 :offset 0 :size 15) + ) + ) + +;; definition of type gif-p3tag +(deftype gif-p3tag (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + ) + +;; definition of type gif-bank +(deftype gif-bank (structure) + ((ctrl gif-ctrl :offset 0) + (mode gif-mode :offset 16) + (stat gif-stat :offset 32) + (tag0 uint32 :offset 64) + (tag1 uint32 :offset 80) + (tag2 uint32 :offset 96) + (tag3 uint32 :offset 112) + (cnt gif-cnt :offset 128) + (p3cnt gif-p3cnt :offset 144) + (p3tag gif-p3tag :offset 160) + ) + ) + +;; definition for method 3 of type gif-bank +(defmethod inspect ((this gif-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gif-bank) + (format #t "~1Tctrl: #x~X~%" (-> this ctrl)) + (format #t "~1Tmode: #x~X~%" (-> this mode)) + (format #t "~1Tstat: #x~X~%" (-> this stat)) + (format #t "~1Ttag0: #x~X~%" (-> this tag0)) + (format #t "~1Ttag1: #x~X~%" (-> this tag1)) + (format #t "~1Ttag2: #x~X~%" (-> this tag2)) + (format #t "~1Ttag3: #x~X~%" (-> this tag3)) + (format #t "~1Tcnt: #x~X~%" (-> this cnt)) + (format #t "~1Tp3cnt: #x~X~%" (-> this p3cnt)) + (format #t "~1Tp3tag: #x~X~%" (-> this p3tag)) + (label cfg-4) + this + ) + +;; definition of type gif-tag-prim +(deftype gif-tag-prim (uint32) + ((id uint16 :offset 0 :size 14) + (pre uint8 :offset 14 :size 1) + (prim gs-prim :offset 15 :size 11) + (flg gif-flag :offset 26 :size 2) + (nreg uint8 :offset 28 :size 4) + ) + ) + +;; definition of type gif-tag-count +(deftype gif-tag-count (uint32) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + ) + +;; definition of type gif-tag64 +(deftype gif-tag64 (uint64) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim gs-prim :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + ) + ) + +;; definition of type gif-tag +(deftype gif-tag (uint128) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim uint16 :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + (regs0 gif-reg-id :offset 64 :size 4) + (regs1 gif-reg-id :offset 68 :size 4) + (regs2 gif-reg-id :offset 72 :size 4) + (regs3 gif-reg-id :offset 76 :size 4) + (regs4 gif-reg-id :offset 80 :size 4) + (regs5 gif-reg-id :offset 84 :size 4) + (regs6 gif-reg-id :offset 88 :size 4) + (regs7 gif-reg-id :offset 92 :size 4) + (regs8 gif-reg-id :offset 96 :size 4) + (regs9 gif-reg-id :offset 100 :size 4) + (regs10 gif-reg-id :offset 104 :size 4) + (regs11 gif-reg-id :offset 108 :size 4) + (regs12 gif-reg-id :offset 112 :size 4) + (regs13 gif-reg-id :offset 116 :size 4) + (regs14 gif-reg-id :offset 120 :size 4) + (regs15 gif-reg-id :offset 124 :size 4) + ) + ) + +;; definition of type gs-gif-tag +(deftype gs-gif-tag (structure) + ((qword uint128) + (tag gif-tag64 :overlay-at qword) + (regs gif-tag-regs :offset 8) + (dword uint64 2 :overlay-at qword) + (word uint32 4 :overlay-at qword) + ) + ) + +;; definition for method 3 of type gs-gif-tag +(defmethod inspect ((this gs-gif-tag)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-gif-tag) + (format #t "~1Tqword: #~%" (&-> this tag)) + (format #t "~1Tdword[2] @ #x~X~%" (&-> this tag)) + (format #t "~1Tword[4] @ #x~X~%" (&-> this tag)) + (format #t "~1Ttag: ~D~%" (-> this tag)) + (format #t "~1Tregs: ~D~%" (-> this regs)) + (label cfg-4) + this + ) + +;; definition for method 3 of type gif-tag +;; WARN: Return type mismatch object vs gif-tag. +(defmethod inspect ((this gif-tag)) + (format #t "[~8x] gif-tag~%" this) + (format #t "~Tnloop: ~4d~%" (-> this nloop)) + (format #t "~Teop : ~4d~%" (-> this eop)) + (format #t "~Tid : ~4d~%" (-> this id)) + (format #t "~Tpre : ~4d~%" (-> this pre)) + (format #t "~Tprim : ~4d~%" (-> this prim)) + (format #t "~Tflg : ~4d~%" (-> this flg)) + (format #t "~Tnreg : ~4d~%" (-> this nreg)) + (format #t "~Tregs0 : ~4d~%" (-> this regs0)) + (format #t "~Tregs1 : ~4d~%" (-> this regs1)) + (format #t "~Tregs2 : ~4d~%" (-> this regs2)) + (format #t "~Tregs3 : ~4d~%" (-> this regs3)) + (format #t "~Tregs4 : ~4d~%" (-> this regs4)) + (format #t "~Tregs5 : ~4d~%" (-> this regs5)) + (format #t "~Tregs6 : ~4d~%" (-> this regs6)) + (format #t "~Tregs7 : ~4d~%" (-> this regs7)) + (format #t "~Tregs8 : ~4d~%" (-> this regs8)) + (format #t "~Tregs9 : ~4d~%" (-> this regs9)) + (format #t "~Tregs10: ~4d~%" (-> this regs10)) + (format #t "~Tregs11: ~4d~%" (-> this regs11)) + (format #t "~Tregs12: ~4d~%" (-> this regs12)) + (format #t "~Tregs13: ~4d~%" (-> this regs13)) + (format #t "~Tregs14: ~4d~%" (-> this regs14)) + (the-as gif-tag (format #t "~Tregs15: ~4d~%" (-> this regs15))) + ) + +;; definition for symbol *fog-color*, type rgba +(define *fog-color* (new 'static 'rgba :r #x80)) + +;; definition of type gif-packet +(deftype gif-packet (basic) + "Unused type for building a dynamically sized gif packet." + ((reg-count int32) + (gif-tag gs-gif-tag :inline) + (gif-tag0 uint128 :overlay-at (-> gif-tag qword)) + (args uint64 1) + ) + (:methods + (new (symbol type int) _type_) + ) + ) + +;; definition for method 3 of type gif-packet +;; INFO: Used lq/sq +(defmethod inspect ((this gif-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Treg-count: ~D~%" (-> this reg-count)) + (format #t "~1Tgif-tag0: #x~X~%" (-> this gif-tag0)) + (format #t "~1Targs[1] @ #x~X~%" (-> this args)) + (label cfg-4) + this + ) + +;; definition for method 0 of type gif-packet +(defmethod new gif-packet ((allocation symbol) (type-to-make type) (arg0 int)) + (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* (+ arg0 -1) 8)))) + ) + +;; definition for function open-gif-packet +(defun open-gif-packet ((arg0 gif-packet)) + (set! (-> arg0 reg-count) 0) + (set! (-> arg0 gif-tag regs) (new 'static 'gif-tag-regs)) + arg0 + ) + +;; definition for function add-reg-gif-packet +;; WARN: Return type mismatch gif-packet vs none. +(defun add-reg-gif-packet ((arg0 gif-packet) (arg1 int) (arg2 int)) + (let ((v1-0 (-> arg0 gif-tag))) + (logior! (-> v1-0 regs) (ash arg1 (* (-> arg0 reg-count) 4))) + ) + (set! (-> (&-> arg0 args (-> arg0 reg-count)) 0) (the-as uint arg2)) + (+! (-> arg0 reg-count) 1) + (none) + ) + +;; definition for function close-gif-packet +(defun close-gif-packet ((arg0 gif-packet) (arg1 int)) + (set! (-> arg0 gif-tag tag) + (new 'static 'gif-tag64 :nloop #x1 :flg (gif-flag reg-list) :eop arg1 :nreg (-> arg0 reg-count)) + ) + arg0 + ) + +;; definition of type draw-context +(deftype draw-context (basic) + ((orgx int32) + (orgy int32) + (orgz int32) + (width int32) + (height int32) + (color rgba 4) + ) + (:methods + (new (symbol type int int int int rgba) _type_) + ) + ) + +;; definition for method 3 of type draw-context +(defmethod inspect ((this draw-context)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Torgx: ~D~%" (-> this orgx)) + (format #t "~1Torgy: ~D~%" (-> this orgy)) + (format #t "~1Torgz: ~D~%" (-> this orgz)) + (format #t "~1Twidth: ~D~%" (-> this width)) + (format #t "~1Theight: ~D~%" (-> this height)) + (format #t "~1Tcolor: #x~X~%" (-> this color)) + (label cfg-4) + this + ) + +;; definition for method 0 of type draw-context +(defmethod new draw-context ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 rgba)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 orgx) arg0) + (set! (-> v0-0 orgy) arg1) + (set! (-> v0-0 orgz) #xffffff) + (set! (-> v0-0 width) arg2) + (set! (-> v0-0 height) arg3) + (set! (-> v0-0 color 0) arg4) + v0-0 + ) + ) + +;; definition for function draw-context-set-xy +;; WARN: Return type mismatch int vs none. +(defun draw-context-set-xy ((arg0 draw-context) (arg1 int) (arg2 int)) + (set! (-> arg0 orgx) arg1) + (set! (-> arg0 orgy) arg2) + (none) + ) + +;; definition of type gs-packed-rgba +(deftype gs-packed-rgba (vector4w) + ((r int32 :overlay-at (-> data 0)) + (g int32 :overlay-at (-> data 1)) + (b int32 :overlay-at (-> data 2)) + (a int32 :overlay-at (-> data 3)) + ) + ) + +;; definition for method 3 of type gs-packed-rgba +;; INFO: Used lq/sq +(defmethod inspect ((this gs-packed-rgba)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-rgba) + (format #t "~1Tdata[4] @ #x~X~%" (&-> this x)) + (format #t "~1Tx: ~D~%" (-> this x)) + (format #t "~1Ty: ~D~%" (-> this y)) + (format #t "~1Tz: ~D~%" (-> this z)) + (format #t "~1Tw: ~D~%" (-> this w)) + (format #t "~1Tdword[2] @ #x~X~%" (&-> this x)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Tr: ~D~%" (-> this x)) + (format #t "~1Tg: ~D~%" (-> this y)) + (format #t "~1Tb: ~D~%" (-> this z)) + (format #t "~1Ta: ~D~%" (-> this w)) + (label cfg-4) + this + ) + +;; definition of type gs-packed-xyzw +(deftype gs-packed-xyzw (vector) + ((ix int32 :overlay-at (-> data 0)) + (iy int32 :overlay-at (-> data 1)) + (iz int32 :overlay-at (-> data 2)) + (iw int32 :overlay-at (-> data 3)) + ) + ) + +;; definition for method 3 of type gs-packed-xyzw +;; INFO: Used lq/sq +(defmethod inspect ((this gs-packed-xyzw)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-xyzw) + (format #t "~1Tdata[4] @ #x~X~%" (&-> this ix)) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tz: ~f~%" (-> this z)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Tix: ~D~%" (-> this ix)) + (format #t "~1Tiy: ~D~%" (-> this iy)) + (format #t "~1Tiz: ~D~%" (-> this iz)) + (format #t "~1Tiw: ~D~%" (-> this iw)) + (label cfg-4) + this + ) + +;; definition of type gs-packed-stq +(deftype gs-packed-stq (vector) + ((tex-s float :overlay-at (-> data 0)) + (tex-t float :overlay-at (-> data 1)) + (tex-q float :overlay-at (-> data 2)) + ) + ) + +;; definition for method 3 of type gs-packed-stq +;; INFO: Used lq/sq +(defmethod inspect ((this gs-packed-stq)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-stq) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tz: ~f~%" (-> this z)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Ttex-s: ~f~%" (-> this x)) + (format #t "~1Ttex-t: ~f~%" (-> this y)) + (format #t "~1Ttex-q: ~f~%" (-> this z)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (label cfg-4) + this + ) + +;; definition of type gs-packed-uv +(deftype gs-packed-uv (vector) + ((u int16 :overlay-at (-> data 0)) + (v int16 :overlay-at (-> data 1)) + ) + ) + +;; definition for method 3 of type gs-packed-uv +;; INFO: Used lq/sq +(defmethod inspect ((this gs-packed-uv)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-uv) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tz: ~f~%" (-> this z)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Tu: ~D~%" (-> this u)) + (format #t "~1Tv: ~D~%" (-> this v)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (label cfg-4) + this + ) + +;; definition of type gs-packed-gt +(deftype gs-packed-gt (structure) + ((stq gs-packed-stq :inline :offset 0) + (rgba gs-packed-rgba :inline :offset 16) + (xyzw gs-packed-xyzw :inline :offset 32) + ) + ) + +;; definition for method 3 of type gs-packed-gt +(defmethod inspect ((this gs-packed-gt)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-gt) + (format #t "~1Tstq: #~%" (-> this stq)) + (format #t "~1Trgba: #~%" (-> this rgba)) + (format #t "~1Txyzw: #~%" (-> this xyzw)) + (label cfg-4) + this + ) + +;; definition of type gs-packed-gt4 +(deftype gs-packed-gt4 (structure) + ((data gs-packed-gt 4 :inline) + ) + ) + +;; definition for method 3 of type gs-packed-gt4 +(defmethod inspect ((this gs-packed-gt4)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-gt4) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/hw/video-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/hw/video-h_REF.gc new file mode 100644 index 0000000000..3e88531878 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/hw/video-h_REF.gc @@ -0,0 +1,56 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type video-params +(deftype video-params (structure) + "Parameters for the framebuffer." + ((set-video-mode symbol) + (reset-video-mode symbol) + (relative-x-scale float :offset 16) + (display-dx int32) + (display-dy int32) + (display-sy int32) + (relative-x-scale-reciprical float) + (smode2 uint64) + (aspect-ratio symbol) + ) + ) + +;; definition for method 3 of type video-params +(defmethod inspect ((this video-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'video-params) + (format #t "~1Tset-video-mode: ~A~%" (-> this set-video-mode)) + (format #t "~1Treset-video-mode: ~A~%" (-> this reset-video-mode)) + (format #t "~1Trelative-x-scale: ~f~%" (-> this relative-x-scale)) + (format #t "~1Tdisplay-dx: ~D~%" (-> this display-dx)) + (format #t "~1Tdisplay-dy: ~D~%" (-> this display-dy)) + (format #t "~1Tdisplay-sy: ~D~%" (-> this display-sy)) + (format #t "~1Trelative-x-scale-reciprical: ~f~%" (-> this relative-x-scale-reciprical)) + (format #t "~1Tsmode2: ~D~%" (-> this smode2)) + (format #t "~1Taspect-ratio: ~A~%" (-> this aspect-ratio)) + (label cfg-4) + this + ) + +;; definition for symbol *video-params*, type video-params +(define *video-params* (new 'static 'video-params + :set-video-mode #f + :reset-video-mode #f + :relative-x-scale 1.0 + :display-dy 8 + :display-sy #xe0 + :relative-x-scale-reciprical 1.0 + :aspect-ratio 'aspect4x3 + ) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/math-camera-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/math-camera-h_REF.gc new file mode 100644 index 0000000000..65fa7b680c --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/math-camera-h_REF.gc @@ -0,0 +1,227 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type vis-gif-tag +(deftype vis-gif-tag (structure) + "Unused." + ((fog0 uint32) + (strip uint32) + (regs uint32) + (fan uint32) + ) + ) + +;; definition for method 3 of type vis-gif-tag +(defmethod inspect ((this vis-gif-tag)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'vis-gif-tag) + (format #t "~1Tfog0: ~D~%" (-> this fog0)) + (format #t "~1Tstrip: ~D~%" (-> this strip)) + (format #t "~1Tregs: ~D~%" (-> this regs)) + (format #t "~1Tfan: ~D~%" (-> this fan)) + (label cfg-4) + this + ) + +;; definition of type cull-info +(deftype cull-info (structure) + "Also seems unused." + ((x-fact float) + (y-fact float) + (z-fact float) + (cam-radius float) + (cam-x float) + (cam-y float) + (xz-dir-ax float) + (xz-dir-az float) + (xz-dir-bx float) + (xz-dir-bz float) + (xz-cross-ab float) + (yz-dir-ay float) + (yz-dir-az float) + (yz-dir-by float) + (yz-dir-bz float) + (yz-cross-ab float) + ) + :allow-misaligned + ) + +;; definition for method 3 of type cull-info +(defmethod inspect ((this cull-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cull-info) + (format #t "~1Tx-fact: ~f~%" (-> this x-fact)) + (format #t "~1Ty-fact: ~f~%" (-> this y-fact)) + (format #t "~1Tz-fact: ~f~%" (-> this z-fact)) + (format #t "~1Tcam-radius: ~f~%" (-> this cam-radius)) + (format #t "~1Tcam-x: ~f~%" (-> this cam-x)) + (format #t "~1Tcam-y: ~f~%" (-> this cam-y)) + (format #t "~1Txz-dir-ax: ~f~%" (-> this xz-dir-ax)) + (format #t "~1Txz-dir-az: ~f~%" (-> this xz-dir-az)) + (format #t "~1Txz-dir-bx: ~f~%" (-> this xz-dir-bx)) + (format #t "~1Txz-dir-bz: ~f~%" (-> this xz-dir-bz)) + (format #t "~1Txz-cross-ab: ~f~%" (-> this xz-cross-ab)) + (format #t "~1Tyz-dir-ay: ~f~%" (-> this yz-dir-ay)) + (format #t "~1Tyz-dir-az: ~f~%" (-> this yz-dir-az)) + (format #t "~1Tyz-dir-by: ~f~%" (-> this yz-dir-by)) + (format #t "~1Tyz-dir-bz: ~f~%" (-> this yz-dir-bz)) + (format #t "~1Tyz-cross-ab: ~f~%" (-> this yz-cross-ab)) + (label cfg-4) + this + ) + +;; definition of type math-camera +(deftype math-camera (basic) + ((d meters) + (f meters) + (fov degrees) + (x-ratio float) + (y-ratio float) + (x-pix float) + (x-clip float) + (x-clip-ratio-in float) + (x-clip-ratio-over float) + (y-pix float) + (y-clip float) + (y-clip-ratio-in float) + (y-clip-ratio-over float) + (cull-info cull-info :inline) + (fog-start meters) + (fog-end meters) + (fog-max float) + (fog-min float) + (reset int32) + (smooth-step float) + (smooth-t float) + (perspective matrix :inline) + (isometric matrix :inline) + (sprite-2d matrix :inline) + (sprite-2d-hvdf vector :inline) + (camera-rot matrix :inline) + (inv-camera-rot matrix :inline) + (inv-camera-rot-smooth matrix :inline) + (inv-camera-rot-smooth-from quaternion :inline) + (camera-temp matrix :inline) + (prev-camera-temp matrix :inline) + (prev-inv-camera-rot matrix :inline) + (prev-trans vector :inline) + (hmge-scale vector :inline) + (inv-hmge-scale vector :inline) + (hvdf-off vector :inline) + (guard vector :inline) + (vis-gifs vis-gif-tag 4) + (giftex uint128 :overlay-at (-> vis-gifs 0)) + (gifgr uint128 :offset 864) + (giftex-trans uint128 :offset 880) + (gifgr-trans uint128 :offset 896) + (pfog0 float) + (pfog1 float) + (trans vector :inline) + (plane plane 4 :inline) + (guard-plane plane 4 :inline) + (shrub-mat matrix :inline) + (quat-other quaternion :inline) + (trans-other vector :inline) + (shrub-mat-other matrix :inline) + (camera-temp-other matrix :inline) + (camera-rot-other matrix :inline) + (camera-rot-other-sky matrix :inline) + (camera-rot-other-sprite matrix :inline) + (inv-camera-rot-other matrix :inline) + (plane-other plane 4 :inline) + (guard-plane-other plane 4 :inline) + (mirror-trans vector :inline) + (mirror-normal vector :inline) + (fov-correction-factor float) + ) + (:methods + (new (symbol type) _type_) + (math-camera-method-9 () none) + ) + ) + +;; definition for method 3 of type math-camera +;; INFO: Used lq/sq +(defmethod inspect ((this math-camera)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Td: (meters ~m)~%" (-> this d)) + (format #t "~1Tf: (meters ~m)~%" (-> this f)) + (format #t "~1Tfov: (deg ~r)~%" (-> this fov)) + (format #t "~1Tx-ratio: ~f~%" (-> this x-ratio)) + (format #t "~1Ty-ratio: ~f~%" (-> this y-ratio)) + (format #t "~1Tx-pix: ~f~%" (-> this x-pix)) + (format #t "~1Tx-clip: ~f~%" (-> this x-clip)) + (format #t "~1Tx-clip-ratio-in: ~f~%" (-> this x-clip-ratio-in)) + (format #t "~1Tx-clip-ratio-over: ~f~%" (-> this x-clip-ratio-over)) + (format #t "~1Ty-pix: ~f~%" (-> this y-pix)) + (format #t "~1Ty-clip: ~f~%" (-> this y-clip)) + (format #t "~1Ty-clip-ratio-in: ~f~%" (-> this y-clip-ratio-in)) + (format #t "~1Ty-clip-ratio-over: ~f~%" (-> this y-clip-ratio-over)) + (format #t "~1Tcull-info: #~%" (-> this cull-info)) + (format #t "~1Tfog-start: (meters ~m)~%" (-> this fog-start)) + (format #t "~1Tfog-end: (meters ~m)~%" (-> this fog-end)) + (format #t "~1Tfog-max: ~f~%" (-> this fog-max)) + (format #t "~1Tfog-min: ~f~%" (-> this fog-min)) + (format #t "~1Treset: ~D~%" (-> this reset)) + (format #t "~1Tsmooth-step: ~f~%" (-> this smooth-step)) + (format #t "~1Tsmooth-t: ~f~%" (-> this smooth-t)) + (format #t "~1Tperspective: #~%" (-> this perspective)) + (format #t "~1Tisometric: #~%" (-> this isometric)) + (format #t "~1Tsprite-2d: #~%" (-> this sprite-2d)) + (format #t "~1Tsprite-2d-hvdf: #~%" (-> this sprite-2d-hvdf)) + (format #t "~1Tcamera-rot: #~%" (-> this camera-rot)) + (format #t "~1Tinv-camera-rot: #~%" (-> this inv-camera-rot)) + (format #t "~1Tinv-camera-rot-smooth: #~%" (-> this inv-camera-rot-smooth)) + (format #t "~1Tinv-camera-rot-smooth-from: #~%" (-> this inv-camera-rot-smooth-from)) + (format #t "~1Tcamera-temp: #~%" (-> this camera-temp)) + (format #t "~1Tprev-camera-temp: #~%" (-> this prev-camera-temp)) + (format #t "~1Tprev-inv-camera-rot: #~%" (-> this prev-inv-camera-rot)) + (format #t "~1Tprev-trans: ~`vector`P~%" (-> this prev-trans)) + (format #t "~1Thmge-scale: #~%" (-> this hmge-scale)) + (format #t "~1Tinv-hmge-scale: #~%" (-> this inv-hmge-scale)) + (format #t "~1Thvdf-off: #~%" (-> this hvdf-off)) + (format #t "~1Tguard: #~%" (-> this guard)) + (format #t "~1Tvis-gifs[4] @ #x~X~%" (-> this vis-gifs)) + (format #t "~1Tgiftex: ~D~%" (-> this giftex)) + (format #t "~1Tgifgr: ~D~%" (-> this gifgr)) + (format #t "~1Tgiftex-trans: ~D~%" (-> this giftex-trans)) + (format #t "~1Tgifgr-trans: ~D~%" (-> this gifgr-trans)) + (format #t "~1Tpfog0: ~f~%" (-> this pfog0)) + (format #t "~1Tpfog1: ~f~%" (-> this pfog1)) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Tplane[4] @ #x~X~%" (-> this plane)) + (format #t "~1Tguard-plane[4] @ #x~X~%" (-> this guard-plane)) + (format #t "~1Tshrub-mat: #~%" (-> this shrub-mat)) + (format #t "~1Tquat-other: #~%" (-> this quat-other)) + (format #t "~1Ttrans-other: #~%" (-> this trans-other)) + (format #t "~1Tshrub-mat-other: #~%" (-> this shrub-mat-other)) + (format #t "~1Tcamera-temp-other: #~%" (-> this camera-temp-other)) + (format #t "~1Tcamera-rot-other: #~%" (-> this camera-rot-other)) + (format #t "~1Tcamera-rot-other-sky: #~%" (-> this camera-rot-other-sky)) + (format #t "~1Tcamera-rot-other-sprite: #~%" (-> this camera-rot-other-sprite)) + (format #t "~1Tinv-camera-rot-other: #~%" (-> this inv-camera-rot-other)) + (format #t "~1Tplane-other[4] @ #x~X~%" (-> this plane-other)) + (format #t "~1Tguard-plane-other[4] @ #x~X~%" (-> this guard-plane-other)) + (format #t "~1Tmirror-trans: #~%" (-> this mirror-trans)) + (format #t "~1Tmirror-normal: #~%" (-> this mirror-normal)) + (format #t "~1Tfov-correction-factor: ~f~%" (-> this fov-correction-factor)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/mood/mood-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/mood/mood-h_REF.gc new file mode 100644 index 0000000000..63b3e69594 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/mood/mood-h_REF.gc @@ -0,0 +1,732 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type mood-channel +(deftype mood-channel (structure) + ((data float 24) + (vecs vector4 6 :inline :overlay-at (-> data 0)) + ) + ) + +;; definition for method 3 of type mood-channel +(defmethod inspect ((this mood-channel)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-channel) + (format #t "~1Tdata[24] @ #x~X~%" (-> this data)) + (format #t "~1Tvecs[6] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type mood-channel-group +(deftype mood-channel-group (structure) + ((data mood-channel 4 :inline) + ) + ) + +;; definition for method 3 of type mood-channel-group +(defmethod inspect ((this mood-channel-group)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-channel-group) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type mood-fog +(deftype mood-fog (structure) + ((fog-color vector :inline) + (fog-dists vector :inline) + (fog-start meters :overlay-at (-> fog-dists data 0)) + (fog-end meters :overlay-at (-> fog-dists data 1)) + (fog-max float :overlay-at (-> fog-dists data 2)) + (fog-min float :overlay-at (-> fog-dists data 3)) + (erase-color vector :inline) + ) + ) + +;; definition for method 3 of type mood-fog +(defmethod inspect ((this mood-fog)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-fog) + (format #t "~1Tfog-color: #~%" (-> this fog-color)) + (format #t "~1Tfog-dists: #~%" (-> this fog-dists)) + (format #t "~1Tfog-start: (meters ~m)~%" (-> this fog-dists x)) + (format #t "~1Tfog-end: (meters ~m)~%" (-> this fog-dists y)) + (format #t "~1Tfog-max: ~f~%" (-> this fog-dists z)) + (format #t "~1Tfog-min: ~f~%" (-> this fog-dists w)) + (format #t "~1Terase-color: #~%" (-> this erase-color)) + (label cfg-4) + this + ) + +;; definition of type mood-fog-table +(deftype mood-fog-table (structure) + ((data mood-fog 8 :inline) + (_data uint128 24 :overlay-at data) + ) + ) + +;; definition for method 3 of type mood-fog-table +(defmethod inspect ((this mood-fog-table)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-fog-table) + (format #t "~1Tdata[8] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type mood-color +(deftype mood-color (structure) + ((lgt-color vector :inline) + (amb-color vector :inline) + ) + ) + +;; definition for method 3 of type mood-color +(defmethod inspect ((this mood-color)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-color) + (format #t "~1Tlgt-color: #~%" (-> this lgt-color)) + (format #t "~1Tamb-color: #~%" (-> this amb-color)) + (label cfg-4) + this + ) + +;; definition of type mood-direction-table +(deftype mood-direction-table (structure) + ((data vector 4 :inline) + ) + ) + +;; definition for method 3 of type mood-direction-table +(defmethod inspect ((this mood-direction-table)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-direction-table) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type mood-color-table +(deftype mood-color-table (structure) + ((data mood-color 8 :inline) + (_data uint128 16 :overlay-at data) + ) + ) + +;; definition for method 3 of type mood-color-table +(defmethod inspect ((this mood-color-table)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-color-table) + (format #t "~1Tdata[8] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type mood-sky-table +(deftype mood-sky-table (structure) + ((data vector 8 :inline) + ) + ) + +;; definition for method 3 of type mood-sky-table +(defmethod inspect ((this mood-sky-table)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-sky-table) + (format #t "~1Tdata[8] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type mood-clouds +(deftype mood-clouds (structure) + ((cloud-min float) + (cloud-max float) + ) + ) + +;; definition for method 3 of type mood-clouds +(defmethod inspect ((this mood-clouds)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-clouds) + (format #t "~1Tcloud-min: ~f~%" (-> this cloud-min)) + (format #t "~1Tcloud-max: ~f~%" (-> this cloud-max)) + (label cfg-4) + this + ) + +;; definition of type mood-weather +(deftype mood-weather (structure) + ((data float 2) + (cloud float :overlay-at (-> data 0)) + (fog float :overlay-at (-> data 1)) + ) + :pack-me + :allow-misaligned + ) + +;; definition for method 3 of type mood-weather +(defmethod inspect ((this mood-weather)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-weather) + (format #t "~1Tdata[2] @ #x~X~%" (-> this data)) + (format #t "~1Tcloud: ~f~%" (-> this cloud)) + (format #t "~1Tfog: ~f~%" (-> this fog)) + (label cfg-4) + this + ) + +;; definition of type mood-iweather +(deftype mood-iweather (structure) + ((data int32 2) + (cloud int32 :overlay-at (-> data 0)) + (fog int32 :overlay-at (-> data 1)) + ) + :allow-misaligned + ) + +;; definition for method 3 of type mood-iweather +(defmethod inspect ((this mood-iweather)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-iweather) + (format #t "~1Tdata[2] @ #x~X~%" (-> this data)) + (format #t "~1Tcloud: ~D~%" (-> this cloud)) + (format #t "~1Tfog: ~D~%" (-> this fog)) + (label cfg-4) + this + ) + +;; definition of type mood-range +(deftype mood-range (structure) + ((data float 4) + (min-cloud float :overlay-at (-> data 0)) + (max-cloud float :overlay-at (-> data 1)) + (min-fog float :overlay-at (-> data 2)) + (max-fog float :overlay-at (-> data 3)) + (quad uint128 :overlay-at (-> data 0)) + ) + ) + +;; definition for method 3 of type mood-range +;; INFO: Used lq/sq +(defmethod inspect ((this mood-range)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-range) + (format #t "~1Tdata[4] @ #x~X~%" (&-> this min-cloud)) + (format #t "~1Tmin-cloud: ~f~%" (-> this min-cloud)) + (format #t "~1Tmax-cloud: ~f~%" (-> this max-cloud)) + (format #t "~1Tmin-fog: ~f~%" (-> this min-fog)) + (format #t "~1Tmax-fog: ~f~%" (-> this max-fog)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (label cfg-4) + this + ) + +;; definition of type mood-filters-table +(deftype mood-filters-table (structure) + ((data vector 8 :inline) + ) + ) + +;; definition for method 3 of type mood-filters-table +(defmethod inspect ((this mood-filters-table)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-filters-table) + (format #t "~1Tdata[8] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type mood-table +(deftype mood-table (basic) + ((mood-fog-table mood-fog-table) + (mood-color-table mood-color-table) + (mood-channel-group mood-channel-group) + (mood-direction-table mood-direction-table) + (mood-sky-table mood-sky-table) + (mood-interp-table sky-color-day) + ) + ) + +;; definition for method 3 of type mood-table +(defmethod inspect ((this mood-table)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tmood-fog-table: #~%" (-> this mood-fog-table)) + (format #t "~1Tmood-color-table: #~%" (-> this mood-color-table)) + (format #t "~1Tmood-channel-group: #~%" (-> this mood-channel-group)) + (format #t "~1Tmood-direction-table: #~%" (-> this mood-direction-table)) + (format #t "~1Tmood-sky-table: #~%" (-> this mood-sky-table)) + (format #t "~1Tmood-interp-table: ~A~%" (-> this mood-interp-table)) + (label cfg-4) + this + ) + +;; definition of type light-state +(deftype light-state (structure) + ((time float) + (fade float) + ) + :pack-me + ) + +;; definition for method 3 of type light-state +(defmethod inspect ((this light-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'light-state) + (format #t "~1Ttime: ~f~%" (-> this time)) + (format #t "~1Tfade: ~f~%" (-> this fade)) + (label cfg-4) + this + ) + +;; definition of type flicker-state +(deftype flicker-state (structure) + ((flicker-off uint8) + (flicker-on uint8) + ) + :allow-misaligned + ) + +;; definition for method 3 of type flicker-state +(defmethod inspect ((this flicker-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'flicker-state) + (format #t "~1Tflicker-off: ~D~%" (-> this flicker-off)) + (format #t "~1Tflicker-on: ~D~%" (-> this flicker-on)) + (label cfg-4) + this + ) + +;; definition of type florescent-state +(deftype florescent-state (structure) + ((value float) + (delay int8) + (delay2 int8) + ) + ) + +;; definition for method 3 of type florescent-state +(defmethod inspect ((this florescent-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'florescent-state) + (format #t "~1Tvalue: ~f~%" (-> this value)) + (format #t "~1Tdelay: ~D~%" (-> this delay)) + (format #t "~1Tdelay2: ~D~%" (-> this delay2)) + (label cfg-4) + this + ) + +;; definition of type electricity-state +(deftype electricity-state (structure) + ((value float) + (scale float) + ) + :pack-me + ) + +;; definition for method 3 of type electricity-state +(defmethod inspect ((this electricity-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'electricity-state) + (format #t "~1Tvalue: ~f~%" (-> this value)) + (format #t "~1Tscale: ~f~%" (-> this scale)) + (label cfg-4) + this + ) + +;; definition of type pulse-state +(deftype pulse-state (structure) + ((pulse float) + (brightness float) + (target-brightness float) + (speed float) + ) + :pack-me + ) + +;; definition for method 3 of type pulse-state +(defmethod inspect ((this pulse-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'pulse-state) + (format #t "~1Tpulse: ~f~%" (-> this pulse)) + (format #t "~1Tbrightness: ~f~%" (-> this brightness)) + (format #t "~1Ttarget-brightness: ~f~%" (-> this target-brightness)) + (format #t "~1Tspeed: ~f~%" (-> this speed)) + (label cfg-4) + this + ) + +;; definition of type strobe-state +(deftype strobe-state (structure) + ((time float) + ) + ) + +;; definition for method 3 of type strobe-state +(defmethod inspect ((this strobe-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'strobe-state) + (format #t "~1Ttime: ~f~%" (-> this time)) + (label cfg-4) + this + ) + +;; definition of type flames-state +(deftype flames-state (structure) + ((time float) + (index uint8) + (length uint8) + (height uint8) + ) + :pack-me + ) + +;; definition for method 3 of type flames-state +(defmethod inspect ((this flames-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'flames-state) + (format #t "~1Ttime: ~f~%" (-> this time)) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Theight: ~D~%" (-> this height)) + (label cfg-4) + this + ) + +;; definition of type mood-context-core +(deftype mood-context-core (structure) + ((current-fog mood-fog :inline) + (current-sky-color vector :inline) + (current-env-color vector :inline) + (current-prt-color vector :inline) + (current-shadow-color vector :inline) + ) + ) + +;; definition for method 3 of type mood-context-core +(defmethod inspect ((this mood-context-core)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-context-core) + (format #t "~1Tcurrent-fog: #~%" (-> this current-fog)) + (format #t "~1Tcurrent-sky-color: #~%" (-> this current-sky-color)) + (format #t "~1Tcurrent-env-color: #~%" (-> this current-env-color)) + (format #t "~1Tcurrent-prt-color: #~%" (-> this current-prt-color)) + (format #t "~1Tcurrent-shadow-color: #~%" (-> this current-shadow-color)) + (label cfg-4) + this + ) + +;; definition of type mood-context-core2 +(deftype mood-context-core2 (mood-context-core) + ((light-group light-group 8 :inline) + ) + ) + +;; definition for method 3 of type mood-context-core2 +(defmethod inspect ((this mood-context-core2)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-context-core2) + (format #t "~1Tcurrent-fog: #~%" (-> this current-fog)) + (format #t "~1Tcurrent-sky-color: #~%" (-> this current-sky-color)) + (format #t "~1Tcurrent-env-color: #~%" (-> this current-env-color)) + (format #t "~1Tcurrent-prt-color: #~%" (-> this current-prt-color)) + (format #t "~1Tcurrent-shadow-color: #~%" (-> this current-shadow-color)) + (format #t "~1Tlight-group[8] @ #x~X~%" (-> this light-group)) + (label cfg-4) + this + ) + +;; definition of type mood-context-core3 +(deftype mood-context-core3 (mood-context-core2) + ((times vector 8 :inline) + ) + ) + +;; definition for method 3 of type mood-context-core3 +(defmethod inspect ((this mood-context-core3)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-context-core3) + (format #t "~1Tcurrent-fog: #~%" (-> this current-fog)) + (format #t "~1Tcurrent-sky-color: #~%" (-> this current-sky-color)) + (format #t "~1Tcurrent-env-color: #~%" (-> this current-env-color)) + (format #t "~1Tcurrent-prt-color: #~%" (-> this current-prt-color)) + (format #t "~1Tcurrent-shadow-color: #~%" (-> this current-shadow-color)) + (format #t "~1Tlight-group[8] @ #x~X~%" (-> this light-group)) + (format #t "~1Ttimes[8] @ #x~X~%" (-> this times)) + (label cfg-4) + this + ) + +;; definition of type mood-context +(deftype mood-context (mood-context-core3) + ((itimes vector4w 4 :inline) + (state uint32 32) + (data uint128 123 :overlay-at (-> current-fog fog-color data 0)) + ) + ) + +;; definition for method 3 of type mood-context +(defmethod inspect ((this mood-context)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-context) + (format #t "~1Tcurrent-fog: #~%" (-> this current-fog)) + (format #t "~1Tcurrent-sky-color: #~%" (-> this current-sky-color)) + (format #t "~1Tcurrent-env-color: #~%" (-> this current-env-color)) + (format #t "~1Tcurrent-prt-color: #~%" (-> this current-prt-color)) + (format #t "~1Tcurrent-shadow-color: #~%" (-> this current-shadow-color)) + (format #t "~1Tlight-group[8] @ #x~X~%" (-> this light-group)) + (format #t "~1Ttimes[8] @ #x~X~%" (-> this times)) + (format #t "~1Titimes[4] @ #x~X~%" (-> this itimes)) + (format #t "~1Tstate[32] @ #x~X~%" (-> this state)) + (label cfg-4) + this + ) + +;; definition of type mood-control-work +(deftype mood-control-work (structure) + ((color vector4w :inline) + (weather mood-weather :inline) + (iweather mood-iweather :inline) + (interp mood-weather :inline) + (index int32 4) + (color-interp float) + (color-index int32 2) + (channel-interp float) + (channel-index int32 2) + (cloud-interp float) + (cloud-index int32 2) + ) + ) + +;; definition for method 3 of type mood-control-work +(defmethod inspect ((this mood-control-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'mood-control-work) + (format #t "~1Tcolor: #~%" (-> this color)) + (format #t "~1Tweather: #~%" (-> this weather)) + (format #t "~1Tiweather: #~%" (-> this iweather)) + (format #t "~1Tinterp: #~%" (-> this interp)) + (format #t "~1Tindex[4] @ #x~X~%" (-> this index)) + (format #t "~1Tcolor-interp: ~f~%" (-> this color-interp)) + (format #t "~1Tcolor-index[2] @ #x~X~%" (-> this color-index)) + (format #t "~1Tchannel-interp: ~f~%" (-> this channel-interp)) + (format #t "~1Tchannel-index[2] @ #x~X~%" (-> this channel-index)) + (format #t "~1Tcloud-interp: ~f~%" (-> this cloud-interp)) + (format #t "~1Tcloud-index[2] @ #x~X~%" (-> this cloud-index)) + (label cfg-4) + this + ) + +;; definition of type mood-control +(deftype mood-control (mood-table) + ((mood-clouds mood-clouds) + (current-interp mood-weather :inline) + (target-interp mood-weather :inline) + (speed-interp mood-weather :inline) + (range mood-range :inline) + (time-until-random mood-weather :inline) + (time-until-random-min mood-weather :inline) + (time-until-random-max mood-weather :inline) + (current-special-interp float) + (target-special-interp float) + (rate-special-interp float) + (display-flag symbol) + (overide-weather-flag symbol) + (pad int32) + (overide mood-weather :inline) + (lightning-index int32) + (lightning-val int32) + (lightning-time int32) + (lightning-time2 float) + (lightning-time3 float) + (lightning-flash float) + (lightning-id sound-id) + (lightning-count0 uint32) + (lightning-count1 uint32) + (lightning-count2 uint32) + (rain-id sound-id) + (sound-pitch float) + (fogs mood-fog-table 9) + (colors mood-color-table 3) + (channels mood-channel-group 3) + (clouds mood-clouds 9) + ) + (:methods + (init-weather! (_type_) none) + (set-cloud-and-fog-interp! (_type_ float float float float) none) + (update-mood-range! (_type_ float float float float) none) + (set-time-for-random-weather! (_type_ float float) none) + (set-special-interps! (_type_ float float symbol) none) + (weather-event-concluded? (_type_) symbol) + (set-lightning-time! (_type_ int int float) none) + (apply-mood-clouds-and-fog (_type_ mood-control-work) none) + (apply-mood-fog (_type_ mood-control-work mood-color-table mood-color-table mood-color-table float) none) + (apply-fog-height (_type_ mood-control-work float float float float) none) + (apply-mood-colors (_type_ mood-control-work) none) + (mood-control-method-20 (_type_ mood-control-work mood-color-table mood-color-table mood-color-table float) none) + (apply-mood-channels (_type_ mood-control-work) none) + (adjust-num-clouds (_type_ mood-control-work) none) + (gen-lightning-and-thunder! (_type_ int) none) + (play-or-stop-lightning-sfx! (_type_ sound-spec vector) none) + ) + ) + +;; definition for method 3 of type mood-control +(defmethod inspect ((this mood-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tmood-fog-table: #~%" (-> this mood-fog-table)) + (format #t "~1Tmood-color-table: #~%" (-> this mood-color-table)) + (format #t "~1Tmood-channel-group: #~%" (-> this mood-channel-group)) + (format #t "~1Tmood-direction-table: #~%" (-> this mood-direction-table)) + (format #t "~1Tmood-sky-table: #~%" (-> this mood-sky-table)) + (format #t "~1Tmood-interp-table: ~A~%" (-> this mood-interp-table)) + (format #t "~1Tmood-clouds: #~%" (-> this mood-clouds)) + (format #t "~1Tcurrent-interp: #~%" (-> this current-interp)) + (format #t "~1Ttarget-interp: #~%" (-> this target-interp)) + (format #t "~1Tspeed-interp: #~%" (-> this speed-interp)) + (format #t "~1Trange: #~%" (-> this range)) + (format #t "~1Ttime-until-random: #~%" (-> this time-until-random)) + (format #t "~1Ttime-until-random-min: #~%" (-> this time-until-random-min)) + (format #t "~1Ttime-until-random-max: #~%" (-> this time-until-random-max)) + (format #t "~1Tcurrent-special-interp: ~f~%" (-> this current-special-interp)) + (format #t "~1Ttarget-special-interp: ~f~%" (-> this target-special-interp)) + (format #t "~1Trate-special-interp: ~f~%" (-> this rate-special-interp)) + (format #t "~1Tdisplay-flag: ~A~%" (-> this display-flag)) + (format #t "~1Toverride-weather-flag: ~A~%" (-> this overide-weather-flag)) + (format #t "~1Toverride: #~%" (-> this overide)) + (format #t "~1Tlightning-index: ~D~%" (-> this lightning-index)) + (format #t "~1Tlightning-val: ~D~%" (-> this lightning-val)) + (format #t "~1Tlightning-time: ~D~%" (-> this lightning-time)) + (format #t "~1Tlightning-time2: ~f~%" (-> this lightning-time2)) + (format #t "~1Tlightning-time3: ~f~%" (-> this lightning-time3)) + (format #t "~1Tlightning-flash: ~f~%" (-> this lightning-flash)) + (format #t "~1Tlightning-id: ~D~%" (-> this lightning-id)) + (format #t "~1Tlightning-count0: ~D~%" (-> this lightning-count0)) + (format #t "~1Tlightning-count1: ~D~%" (-> this lightning-count1)) + (format #t "~1Tlightning-count2: ~D~%" (-> this lightning-count2)) + (format #t "~1Train-id: ~D~%" (-> this rain-id)) + (format #t "~1Tsound-pitch: ~f~%" (-> this sound-pitch)) + (format #t "~1Tfogs[9] @ #x~X~%" (-> this fogs)) + (format #t "~1Tcolors[3] @ #x~X~%" (-> this colors)) + (format #t "~1Tchannels[3] @ #x~X~%" (-> this channels)) + (format #t "~1Tclouds[9] @ #x~X~%" (-> this clouds)) + (label cfg-4) + this + ) + +;; definition for method 13 of type mood-control +;; WARN: Return type mismatch int vs none. +(defmethod set-special-interps! ((this mood-control) (target-interp float) (rate-interp float) (set-current-interp? symbol)) + "Sets the `*-special-interp` values with the given values + @param! this The [[mood-control]] + @param target-interp Clamped between 0.0 and 1.0 + @param rate-interp Value to set [[this::rate-special-interp]] + @param set-current-interp? Uses `target-interp` to set [[this::current-special-interp] + @returns [[none]]" + (let ((clamped-interp (fmax 0.0 (fmin 1.0 target-interp)))) + (set! (-> this target-special-interp) clamped-interp) + (set! (-> this rate-special-interp) rate-interp) + (if set-current-interp? + (set! (-> this current-special-interp) clamped-interp) + ) + ) + 0 + (none) + ) + +;; definition for method 14 of type mood-control +(defmethod weather-event-concluded? ((this mood-control)) + "@returns [[#t]] if [[this::override-weather-flag]] is set, we aren't in a cutscene and [[this::current-special-interp]] is equal to `0.0`" + (and (-> this overide-weather-flag) (not (movie?)) (= (-> this current-special-interp) 0.0)) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/mood/time-of-day-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/mood/time-of-day-h_REF.gc new file mode 100644 index 0000000000..db4923c66a --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/mood/time-of-day-h_REF.gc @@ -0,0 +1,253 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type palette-fade-control +(deftype palette-fade-control (structure) + "Unused interface to the time-of-day control. Was used in jak 1 as an interface between level code, +and the code in mood.gc, which set the actual fade values for time-of-day." + ((trans vector :inline) + (fade float) + (actor-dist float) + ) + ) + +;; definition for method 3 of type palette-fade-control +(defmethod inspect ((this palette-fade-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'palette-fade-control) + (format #t "~1Ttrans: #~%" (-> this trans)) + (format #t "~1Tfade: ~f~%" (-> this fade)) + (format #t "~1Tactor-dist: ~f~%" (-> this actor-dist)) + (label cfg-4) + this + ) + +;; definition of type palette-fade-controls +(deftype palette-fade-controls (basic) + "Unused interface to the time-of-day control. Was used in jak 1 as an interface between level code, +and the code in mood.gc, which set the actual fade values for time-of-day." + ((control palette-fade-control 8 :inline) + ) + (:methods + (reset! (_type_) none) + (set-fade! (_type_ int float float vector) object) + ) + ) + +;; definition for method 3 of type palette-fade-controls +(defmethod inspect ((this palette-fade-controls)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tcontrol[8] @ #x~X~%" (-> this control)) + (label cfg-4) + this + ) + +;; definition (perm) for symbol *palette-fade-controls*, type palette-fade-controls +(define-perm *palette-fade-controls* palette-fade-controls (new 'global 'palette-fade-controls)) + +;; definition of type time-of-day-proc +(deftype time-of-day-proc (process) + "Process for running things that change with the time-of-day, like lighting, sun/stars/moon, etc." + ((hours int32) + (minutes int32) + (seconds int32) + (old-frame uint64) + (current-frame uint64) + (frames uint64) + (time-of-day float) + (old-frame-save uint64) + (current-frame-save uint64) + (frames-save uint64) + (time-of-day-save float) + (time-ratio float) + (dest-time-ratio float) + (dest-time-delta float) + (sun-count int32) + (sun sparticle-launch-control) + (green-sun-count int32) + (green-sun sparticle-launch-control) + (moon-count int32) + (moon sparticle-launch-control) + (start-timer int32) + ) + ) + +;; definition for method 3 of type time-of-day-proc +(defmethod inspect ((this time-of-day-proc)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Thours: ~D~%" (-> this hours)) + (format #t "~2Tminutes: ~D~%" (-> this minutes)) + (format #t "~2Tseconds: ~D~%" (-> this seconds)) + (format #t "~2Told-frame: ~D~%" (-> this old-frame)) + (format #t "~2Tcurrent-frame: ~D~%" (-> this current-frame)) + (format #t "~2Tframes: ~D~%" (-> this frames)) + (format #t "~2Ttime-of-day: ~f~%" (-> this time-of-day)) + (format #t "~2Told-frame-save: ~D~%" (-> this old-frame-save)) + (format #t "~2Tcurrent-frame-save: ~D~%" (-> this current-frame-save)) + (format #t "~2Tframes-save: ~D~%" (-> this frames-save)) + (format #t "~2Ttime-of-day-save: ~f~%" (-> this time-of-day-save)) + (format #t "~2Ttime-ratio: ~f~%" (-> this time-ratio)) + (format #t "~2Tdest-time-ratio: ~f~%" (-> this dest-time-ratio)) + (format #t "~2Tdest-time-delta: ~f~%" (-> this dest-time-delta)) + (format #t "~2Tsun-count: ~D~%" (-> this sun-count)) + (format #t "~2Tsun: ~A~%" (-> this sun)) + (format #t "~2Tgreen-sun-count: ~D~%" (-> this green-sun-count)) + (format #t "~2Tgreen-sun: ~A~%" (-> this green-sun)) + (format #t "~2Tmoon-count: ~D~%" (-> this moon-count)) + (format #t "~2Tmoon: ~A~%" (-> this moon)) + (format #t "~2Tstart-timer: ~D~%" (-> this start-timer)) + (label cfg-4) + this + ) + +;; definition of type time-of-day-palette +(deftype time-of-day-palette (basic) + "Pre-baked lighting values used by rendering code. The exact meaning of this data can vary, +but in all cases, the time-of-day system can do linear interpolation of two palettes to +blend between them." + ((width int32) + (height int32) + (pad int32) + (data int32 1) + ) + ) + +;; definition for method 3 of type time-of-day-palette +(defmethod inspect ((this time-of-day-palette)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Twidth: ~D~%" (-> this width)) + (format #t "~1Theight: ~D~%" (-> this height)) + (format #t "~1Tpad: ~D~%" (-> this pad)) + (format #t "~1Tdata[1] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type time-of-day-context +(deftype time-of-day-context (basic) + "A mix of inputs/outputs to the time-of-day system." + ((interp float 18) + (current-fog mood-fog :inline) + (current-sky-color vector :inline) + (current-env-color vector :inline) + (current-prt-color vector :inline) + (current-shadow-color vector :inline) + (light-group light-group 8 :inline) + (current-clouds mood-clouds :inline) + (times vector 8 :inline) + (title-light-group light-group :inline) + (rim-light-group light-group :inline) + (front-rear-light-group light-group :inline) + (fog-override mood-fog :inline) + (filter vector :inline) + (filter-color vector :inline) + (time float) + (target-interp float) + (erase-color rgba) + (sky symbol) + (special-mood basic) + (use-camera-other basic) + (title-updated symbol) + (mode time-of-day-palette-id) + (override-enable basic) + (override-palette uint32) + (max-rain float) + (exterior-level basic) + (ocean-alpha float) + (shadow-override float) + (fog-override-interp float) + ) + ) + +;; definition for method 3 of type time-of-day-context +(defmethod inspect ((this time-of-day-context)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tinterp[18] @ #x~X~%" (-> this interp)) + (format #t "~1Tcurrent-fog: #~%" (-> this current-fog)) + (format #t "~1Tcurrent-sky-color: #~%" (-> this current-sky-color)) + (format #t "~1Tcurrent-env-color: #~%" (-> this current-env-color)) + (format #t "~1Tcurrent-prt-color: #~%" (-> this current-prt-color)) + (format #t "~1Tcurrent-shadow-color: #~%" (-> this current-shadow-color)) + (format #t "~1Tlight-group[8] @ #x~X~%" (-> this light-group)) + (format #t "~1Tcurrent-clouds: #~%" (-> this current-clouds)) + (format #t "~1Ttimes[8] @ #x~X~%" (-> this times)) + (format #t "~1Ttitle-light-group: #~%" (-> this title-light-group)) + (format #t "~1Trim-light-group: #~%" (-> this rim-light-group)) + (format #t "~1Tfront-rear-light-group: #~%" (-> this front-rear-light-group)) + (format #t "~1Tfog-override: #~%" (-> this fog-override)) + (format #t "~1Tfilter: #~%" (-> this filter)) + (format #t "~1Tfilter-color: #~%" (-> this filter-color)) + (format #t "~1Ttime: ~f~%" (-> this time)) + (format #t "~1Ttarget-interp: ~f~%" (-> this target-interp)) + (format #t "~1Terase-color: ~D~%" (-> this erase-color)) + (format #t "~1Tsky: ~A~%" (-> this sky)) + (format #t "~1Tspecial-mood: ~A~%" (-> this special-mood)) + (format #t "~1Tuse-camera-other: ~A~%" (-> this use-camera-other)) + (format #t "~1Ttitle-updated: ~A~%" (-> this title-updated)) + (format #t "~1Tmode: ~D~%" (-> this mode)) + (format #t "~1Toverride-enable: ~A~%" (-> this override-enable)) + (format #t "~1Toverride-palette: ~D~%" (-> this override-palette)) + (format #t "~1Tmax-rain: ~f~%" (-> this max-rain)) + (format #t "~1Texterior-level: ~A~%" (-> this exterior-level)) + (format #t "~1Tocean-alpha: ~f~%" (-> this ocean-alpha)) + (format #t "~1Tshadow-override: ~f~%" (-> this shadow-override)) + (format #t "~1Tfog-override-interp: ~f~%" (-> this fog-override-interp)) + (label cfg-4) + this + ) + +;; definition of type time-of-day-dma +(deftype time-of-day-dma (structure) + "Memory layout for the time-of-day interpolation functions." + ((outa uint32 256) + (outb uint32 256) + (banka uint32 256) + (bankb uint32 256) + ) + ) + +;; definition for method 3 of type time-of-day-dma +(defmethod inspect ((this time-of-day-dma)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'time-of-day-dma) + (format #t "~1Touta[256] @ #x~X~%" (-> this outa)) + (format #t "~1Toutb[256] @ #x~X~%" (-> this outb)) + (format #t "~1Tbanka[256] @ #x~X~%" (-> this banka)) + (format #t "~1Tbankb[256] @ #x~X~%" (-> this bankb)) + (label cfg-4) + this + ) + +;; definition for symbol *time-of-day-context*, type time-of-day-context +(define *time-of-day-context* (new 'static 'time-of-day-context)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/ocean/ocean-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/ocean/ocean-h_REF.gc new file mode 100644 index 0000000000..14525c19d2 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/ocean/ocean-h_REF.gc @@ -0,0 +1,941 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type ocean-corner +(deftype ocean-corner (structure) + ((bsphere sphere :inline) + (start-corner vector :inline) + (y-scales vector :inline) + (alphas vector :inline) + (colors uint32 4) + ) + ) + +;; definition for method 3 of type ocean-corner +(defmethod inspect ((this ocean-corner)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-corner) + (format #t "~1Tbsphere: #~%" (-> this bsphere)) + (format #t "~1Tstart-corner: #~%" (-> this start-corner)) + (format #t "~1Ty-scales: #~%" (-> this y-scales)) + (format #t "~1Talphas: #~%" (-> this alphas)) + (format #t "~1Tcolors[4] @ #x~X~%" (-> this colors)) + (label cfg-4) + this + ) + +;; definition of type ocean-wave-info +(deftype ocean-wave-info (structure) + ((frequency float) + (amplitude float) + (wave-speed float) + (angle float) + (kx float) + (ky float) + (w float) + (flags int32) + ) + ) + +;; definition for method 3 of type ocean-wave-info +(defmethod inspect ((this ocean-wave-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-wave-info) + (format #t "~1Tfrequency: ~f~%" (-> this frequency)) + (format #t "~1Tamplitude: ~f~%" (-> this amplitude)) + (format #t "~1Twave-speed: ~f~%" (-> this wave-speed)) + (format #t "~1Tangle: ~f~%" (-> this angle)) + (format #t "~1Tkx: ~f~%" (-> this kx)) + (format #t "~1Tky: ~f~%" (-> this ky)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (label cfg-4) + this + ) + +;; definition of type ocean-vertex +(deftype ocean-vertex (structure) + ((pos vector :inline) + (stq vector :inline) + (col vector :inline) + ) + ) + +;; definition for method 3 of type ocean-vertex +(defmethod inspect ((this ocean-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-vertex) + (format #t "~1Tpos: #~%" (-> this pos)) + (format #t "~1Tstq: #~%" (-> this stq)) + (format #t "~1Tcol: #~%" (-> this col)) + (label cfg-4) + this + ) + +;; definition of type ocean-spheres +(deftype ocean-spheres (structure) + ((spheres sphere 36 :inline) + ) + ) + +;; definition for method 3 of type ocean-spheres +(defmethod inspect ((this ocean-spheres)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-spheres) + (format #t "~1Tspheres[36] @ #x~X~%" (-> this spheres)) + (label cfg-4) + this + ) + +;; definition of type ocean-colors +(deftype ocean-colors (structure) + ((colors rgba 2548) + ) + ) + +;; definition for method 3 of type ocean-colors +(defmethod inspect ((this ocean-colors)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-colors) + (format #t "~1Tcolors[2548] @ #x~X~%" (-> this colors)) + (label cfg-4) + this + ) + +;; definition of type ocean-colors-float +(deftype ocean-colors-float (structure) + ((colors vector 2548 :inline) + ) + ) + +;; definition for method 3 of type ocean-colors-float +(defmethod inspect ((this ocean-colors-float)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-colors-float) + (format #t "~1Tcolors[2548] @ #x~X~%" (-> this colors)) + (label cfg-4) + this + ) + +;; definition of type ocean-mid-mask +(deftype ocean-mid-mask (structure) + ((mask uint8 8) + (dword uint64 :overlay-at (-> mask 0)) + ) + :pack-me + ) + +;; definition for method 3 of type ocean-mid-mask +(defmethod inspect ((this ocean-mid-mask)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-mid-mask) + (format #t "~1Tmask[8] @ #x~X~%" (-> this mask)) + (format #t "~1Tdword: #x~X~%" (-> this dword)) + (label cfg-4) + this + ) + +;; definition of type ocean-mid-indices +(deftype ocean-mid-indices (basic) + ((data uint16 36) + ) + ) + +;; definition for method 3 of type ocean-mid-indices +(defmethod inspect ((this ocean-mid-indices)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tdata[36] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type ocean-mid-masks +(deftype ocean-mid-masks (basic) + ((data (inline-array ocean-mid-mask)) + ) + ) + +;; definition for method 3 of type ocean-mid-masks +(defmethod inspect ((this ocean-mid-masks)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tdata: #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type ocean-trans-mask +(deftype ocean-trans-mask (structure) + ((mask uint8 4) + (word int32 :overlay-at (-> mask 0)) + ) + :pack-me + ) + +;; definition for method 3 of type ocean-trans-mask +(defmethod inspect ((this ocean-trans-mask)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-trans-mask) + (format #t "~1Tmask[4] @ #x~X~%" (-> this mask)) + (format #t "~1Tword: #x~X~%" (-> this word)) + (label cfg-4) + this + ) + +;; definition of type ocean-trans-index +(deftype ocean-trans-index (structure) + ((parent int16) + (child int16) + ) + :pack-me + ) + +;; definition for method 3 of type ocean-trans-index +(defmethod inspect ((this ocean-trans-index)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-trans-index) + (format #t "~1Tparent: ~D~%" (-> this parent)) + (format #t "~1Tchild: ~D~%" (-> this child)) + (label cfg-4) + this + ) + +;; definition of type ocean-trans-indices +(deftype ocean-trans-indices (basic) + ((data ocean-trans-index 2304 :inline) + ) + ) + +;; definition for method 3 of type ocean-trans-indices +(defmethod inspect ((this ocean-trans-indices)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tdata[2304] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type ocean-near-index +(deftype ocean-near-index (structure) + ((data uint16 16) + ) + ) + +;; definition for method 3 of type ocean-near-index +(defmethod inspect ((this ocean-near-index)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-near-index) + (format #t "~1Tdata[16] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type ocean-near-indices +(deftype ocean-near-indices (basic) + ((data (inline-array ocean-near-index)) + ) + ) + +;; definition for method 3 of type ocean-near-indices +(defmethod inspect ((this ocean-near-indices)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tdata: #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type ocean-near-colors +(deftype ocean-near-colors (structure) + ((color0 vector :inline) + (color1 vector :inline) + (color2 vector :inline) + (color3 vector :inline) + ) + ) + +;; definition for method 3 of type ocean-near-colors +(defmethod inspect ((this ocean-near-colors)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-near-colors) + (format #t "~1Tcolor0: #~%" (-> this color0)) + (format #t "~1Tcolor1: #~%" (-> this color1)) + (format #t "~1Tcolor2: #~%" (-> this color2)) + (format #t "~1Tcolor3: #~%" (-> this color3)) + (label cfg-4) + this + ) + +;; definition of type ocean-trans-strip +(deftype ocean-trans-strip (structure) + ((verts uint128 10) + ) + ) + +;; definition for method 3 of type ocean-trans-strip +(defmethod inspect ((this ocean-trans-strip)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-trans-strip) + (format #t "~1Tverts[10] @ #x~X~%" (-> this verts)) + (label cfg-4) + this + ) + +;; definition of type ocean-trans-strip-array +(deftype ocean-trans-strip-array (structure) + ((data ocean-trans-strip 4 :inline) + ) + ) + +;; definition for method 3 of type ocean-trans-strip-array +(defmethod inspect ((this ocean-trans-strip-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-trans-strip-array) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type ocean-wave-data +(deftype ocean-wave-data (structure) + ((data uint8 1024) + ) + ) + +;; definition for method 3 of type ocean-wave-data +(defmethod inspect ((this ocean-wave-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-wave-data) + (format #t "~1Tdata[1024] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type ocean-wave-frames +(deftype ocean-wave-frames (structure) + ((frame ocean-wave-data 64 :inline) + ) + ) + +;; definition for method 3 of type ocean-wave-frames +(defmethod inspect ((this ocean-wave-frames)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-wave-frames) + (format #t "~1Tframe[64] @ #x~X~%" (-> this frame)) + (label cfg-4) + this + ) + +;; definition of type ocean-texture-constants +(deftype ocean-texture-constants (structure) + ((giftag qword :inline) + (buffers vector4w :inline) + (dests vector4w :inline) + (start vector :inline) + (offsets vector :inline) + (constants vector :inline) + (cam-nrm vector :inline) + ) + ) + +;; definition for method 3 of type ocean-texture-constants +(defmethod inspect ((this ocean-texture-constants)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-texture-constants) + (format #t "~1Tgiftag: #~%" (-> this giftag)) + (format #t "~1Tbuffers: #~%" (-> this buffers)) + (format #t "~1Tdests: #~%" (-> this dests)) + (format #t "~1Tstart: #~%" (-> this start)) + (format #t "~1Toffsets: #~%" (-> this offsets)) + (format #t "~1Tconstants: #~%" (-> this constants)) + (format #t "~1Tcam-nrm: #~%" (-> this cam-nrm)) + (label cfg-4) + this + ) + +;; definition of type ocean-mid-vertex +(deftype ocean-mid-vertex (structure) + ((stq vector :inline) + (col vector :inline) + (pos vector :inline) + ) + ) + +;; definition for method 3 of type ocean-mid-vertex +(defmethod inspect ((this ocean-mid-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-mid-vertex) + (format #t "~1Tstq: #~%" (-> this stq)) + (format #t "~1Tcol: #~%" (-> this col)) + (format #t "~1Tpos: #~%" (-> this pos)) + (label cfg-4) + this + ) + +;; definition of type ocean-mid-constants +(deftype ocean-mid-constants (structure) + ((hmge-scale vector :inline) + (inv-hmge-scale vector :inline) + (hvdf-offset vector :inline) + (fog vector :inline) + (constants vector :inline) + (constants2 vector :inline) + (drw-fan qword :inline) + (env-fan qword :inline) + (drw-adgif qword :inline) + (drw-texture adgif-shader :inline) + (drw-strip-0 qword :inline) + (drw-strip-1 qword :inline) + (env-adgif qword :inline) + (env-texture adgif-shader :inline) + (env-strip qword :inline) + (env-color vector :inline) + (index-table vector4w 8 :inline) + (pos0 vector :inline) + (pos1 vector :inline) + (pos2 vector :inline) + (pos3 vector :inline) + ) + ) + +;; definition for method 3 of type ocean-mid-constants +(defmethod inspect ((this ocean-mid-constants)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-mid-constants) + (format #t "~1Thmge-scale: #~%" (-> this hmge-scale)) + (format #t "~1Tinv-hmge-scale: #~%" (-> this inv-hmge-scale)) + (format #t "~1Thvdf-offset: #~%" (-> this hvdf-offset)) + (format #t "~1Tfog: #~%" (-> this fog)) + (format #t "~1Tconstants: #~%" (-> this constants)) + (format #t "~1Tconstants2: #~%" (-> this constants2)) + (format #t "~1Tdrw-fan: #~%" (-> this drw-fan)) + (format #t "~1Tenv-fan: #~%" (-> this env-fan)) + (format #t "~1Tdrw-adgif: #~%" (-> this drw-adgif)) + (format #t "~1Tdrw-texture: #~%" (-> this drw-texture)) + (format #t "~1Tdrw-strip-0: #~%" (-> this drw-strip-0)) + (format #t "~1Tdrw-strip-1: #~%" (-> this drw-strip-1)) + (format #t "~1Tenv-adgif: #~%" (-> this env-adgif)) + (format #t "~1Tenv-texture: #~%" (-> this env-texture)) + (format #t "~1Tenv-strip: #~%" (-> this env-strip)) + (format #t "~1Tenv-color: #~%" (-> this env-color)) + (format #t "~1Tindex-table[8] @ #x~X~%" (-> this index-table)) + (format #t "~1Tpos0: #~%" (-> this pos0)) + (format #t "~1Tpos1: #~%" (-> this pos1)) + (format #t "~1Tpos2: #~%" (-> this pos2)) + (format #t "~1Tpos3: #~%" (-> this pos3)) + (label cfg-4) + this + ) + +;; definition of type ocean-mid-upload +(deftype ocean-mid-upload (structure) + ((rot matrix :inline) + (matrix matrix :inline) + (colors uint128 108) + (masks uint128 2) + ) + ) + +;; definition for method 3 of type ocean-mid-upload +(defmethod inspect ((this ocean-mid-upload)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-mid-upload) + (format #t "~1Trot: #~%" (-> this rot)) + (format #t "~1Tmatrix: #~%" (-> this matrix)) + (format #t "~1Tcolors[108] @ #x~X~%" (-> this colors)) + (format #t "~1Tmasks[2] @ #x~X~%" (-> this masks)) + (label cfg-4) + this + ) + +;; definition of type ocean-mid-upload2 +(deftype ocean-mid-upload2 (structure) + ((rot matrix :inline) + (matrix matrix :inline) + (count vector4w :inline) + (tex0 vector :inline) + (tex1 vector :inline) + (tex2 vector :inline) + (tex3 vector :inline) + (clr0 vector :inline) + (clr1 vector :inline) + (clr2 vector :inline) + (clr3 vector :inline) + (verts uint128 18) + ) + ) + +;; definition for method 3 of type ocean-mid-upload2 +(defmethod inspect ((this ocean-mid-upload2)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-mid-upload2) + (format #t "~1Trot: #~%" (-> this rot)) + (format #t "~1Tmatrix: #~%" (-> this matrix)) + (format #t "~1Tcount: #~%" (-> this count)) + (format #t "~1Ttex0: #~%" (-> this tex0)) + (format #t "~1Ttex1: #~%" (-> this tex1)) + (format #t "~1Ttex2: #~%" (-> this tex2)) + (format #t "~1Ttex3: #~%" (-> this tex3)) + (format #t "~1Tclr0: #~%" (-> this clr0)) + (format #t "~1Tclr1: #~%" (-> this clr1)) + (format #t "~1Tclr2: #~%" (-> this clr2)) + (format #t "~1Tclr3: #~%" (-> this clr3)) + (format #t "~1Tverts[18] @ #x~X~%" (-> this verts)) + (label cfg-4) + this + ) + +;; definition of type ocean-mid-work +(deftype ocean-mid-work (structure) + ((env0 vector :inline) + (env1 vector :inline) + (env2 vector :inline) + (hmg0 vector :inline) + (hmg1 vector :inline) + (hmg2 vector :inline) + (indices uint128 16) + ) + ) + +;; definition for method 3 of type ocean-mid-work +(defmethod inspect ((this ocean-mid-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-mid-work) + (format #t "~1Tenv0: #~%" (-> this env0)) + (format #t "~1Tenv1: #~%" (-> this env1)) + (format #t "~1Tenv2: #~%" (-> this env2)) + (format #t "~1Thmg0: #~%" (-> this hmg0)) + (format #t "~1Thmg1: #~%" (-> this hmg1)) + (format #t "~1Thmg2: #~%" (-> this hmg2)) + (format #t "~1Tindices[16] @ #x~X~%" (-> this indices)) + (label cfg-4) + this + ) + +;; definition of type ocean-near-constants +(deftype ocean-near-constants (structure) + ((hmge-scale vector :inline) + (inv-hmge-scale vector :inline) + (hvdf-offset vector :inline) + (fog vector :inline) + (constants vector :inline) + (constants2 vector :inline) + (constants3 vector :inline) + (constants4 vector :inline) + (constants5 vector :inline) + (drw-fan qword :inline) + (drw2-fan qword :inline) + (env-fan qword :inline) + (drw-adgif qword :inline) + (drw-texture adgif-shader :inline) + (drw-strip qword :inline) + (env-adgif qword :inline) + (env-texture adgif-shader :inline) + (env-strip qword :inline) + (env-color vector :inline) + (drw2-adgif qword :inline) + (drw2-tex0 qword :inline) + (drw2-frame qword :inline) + (drw2-strip qword :inline) + (drw3-adgif qword :inline) + (drw3-frame qword :inline) + (index-table vector4w 4 :inline) + ) + ) + +;; definition for method 3 of type ocean-near-constants +(defmethod inspect ((this ocean-near-constants)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-near-constants) + (format #t "~1Thmge-scale: #~%" (-> this hmge-scale)) + (format #t "~1Tinv-hmge-scale: #~%" (-> this inv-hmge-scale)) + (format #t "~1Thvdf-offset: #~%" (-> this hvdf-offset)) + (format #t "~1Tfog: #~%" (-> this fog)) + (format #t "~1Tconstants: #~%" (-> this constants)) + (format #t "~1Tconstants2: #~%" (-> this constants2)) + (format #t "~1Tconstants3: #~%" (-> this constants3)) + (format #t "~1Tconstants4: #~%" (-> this constants4)) + (format #t "~1Tconstants5: #~%" (-> this constants5)) + (format #t "~1Tdrw-fan: #~%" (-> this drw-fan)) + (format #t "~1Tdrw2-fan: #~%" (-> this drw2-fan)) + (format #t "~1Tenv-fan: #~%" (-> this env-fan)) + (format #t "~1Tdrw-adgif: #~%" (-> this drw-adgif)) + (format #t "~1Tdrw-texture: #~%" (-> this drw-texture)) + (format #t "~1Tdrw-strip: #~%" (-> this drw-strip)) + (format #t "~1Tenv-adgif: #~%" (-> this env-adgif)) + (format #t "~1Tenv-texture: #~%" (-> this env-texture)) + (format #t "~1Tenv-strip: #~%" (-> this env-strip)) + (format #t "~1Tenv-color: #~%" (-> this env-color)) + (format #t "~1Tdrw2-adgif: #~%" (-> this drw2-adgif)) + (format #t "~1Tdrw2-tex0: #~%" (-> this drw2-tex0)) + (format #t "~1Tdrw2-frame: #~%" (-> this drw2-frame)) + (format #t "~1Tdrw2-strip: #~%" (-> this drw2-strip)) + (format #t "~1Tdrw3-adgif: #~%" (-> this drw3-adgif)) + (format #t "~1Tdrw3-frame: #~%" (-> this drw3-frame)) + (format #t "~1Tindex-table[4] @ #x~X~%" (-> this index-table)) + (label cfg-4) + this + ) + +;; definition of type ocean-near-upload +(deftype ocean-near-upload (structure) + ((rot matrix :inline) + (matrix matrix :inline) + (masks uint128 2) + (start-height vector4w :inline) + (start-st vector :inline) + (near-colors ocean-near-colors :inline) + ) + ) + +;; definition for method 3 of type ocean-near-upload +(defmethod inspect ((this ocean-near-upload)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-near-upload) + (format #t "~1Trot: #~%" (-> this rot)) + (format #t "~1Tmatrix: #~%" (-> this matrix)) + (format #t "~1Tmasks[2] @ #x~X~%" (-> this masks)) + (format #t "~1Tstart-height: #~%" (-> this start-height)) + (format #t "~1Tstart-st: #~%" (-> this start-st)) + (format #t "~1Tnear-colors: #~%" (-> this near-colors)) + (label cfg-4) + this + ) + +;; definition of type ocean-near-vertex +(deftype ocean-near-vertex (structure) + ((stq vector :inline) + (clr vector :inline) + (pos vector :inline) + ) + ) + +;; definition for method 3 of type ocean-near-vertex +(defmethod inspect ((this ocean-near-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-near-vertex) + (format #t "~1Tstq: #~%" (-> this stq)) + (format #t "~1Tclr: #~%" (-> this clr)) + (format #t "~1Tpos: #~%" (-> this pos)) + (label cfg-4) + this + ) + +;; definition of type ocean-near-work +(deftype ocean-near-work (structure) + ((verts-ptr vector :inline) + (indices uint128 16) + ) + ) + +;; definition for method 3 of type ocean-near-work +(defmethod inspect ((this ocean-near-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-near-work) + (format #t "~1Tverts-ptr: #~%" (-> this verts-ptr)) + (format #t "~1Tindices[16] @ #x~X~%" (-> this indices)) + (label cfg-4) + this + ) + +;; definition of type ocean-height-array +(deftype ocean-height-array (structure) + ((data float 1024) + ) + ) + +;; definition for method 3 of type ocean-height-array +(defmethod inspect ((this ocean-height-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-height-array) + (format #t "~1Tdata[1024] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type ocean-map +(deftype ocean-map (structure) + ((start-corner vector :inline) + (far-color vector :inline) + (ocean-colors ocean-colors) + (ocean-mid-indices ocean-mid-indices) + (ocean-trans-indices ocean-trans-indices) + (ocean-near-indices ocean-near-indices) + (ocean-mid-masks ocean-mid-masks) + ) + (:methods + (ocean-map-method-9 () none) + (ocean-map-method-10 () none) + ) + ) + +;; definition for method 3 of type ocean-map +(defmethod inspect ((this ocean-map)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean-map) + (format #t "~1Tstart-corner: #~%" (-> this start-corner)) + (format #t "~1Tfar-color: #~%" (-> this far-color)) + (format #t "~1Tocean-colors: #~%" (-> this ocean-colors)) + (format #t "~1Tocean-mid-indices: ~A~%" (-> this ocean-mid-indices)) + (format #t "~1Tocean-trans-indices: ~A~%" (-> this ocean-trans-indices)) + (format #t "~1Tocean-near-indices: ~A~%" (-> this ocean-near-indices)) + (format #t "~1Tocean-mid-masks: ~A~%" (-> this ocean-mid-masks)) + (label cfg-4) + this + ) + +;; definition of type ocean +(deftype ocean (ocean-map) + ((off symbol) + (near-off symbol) + (far-on symbol) + (all-on symbol) + (ocean-facing uint32) + (mid-mask-ptrs pointer 36) + (mid-camera-masks uint64 36) + (trans-mask-ptrs pointer 64) + (trans-camera-masks ocean-trans-mask 16) + (trans-temp-masks uint32 16) + (haze-lights haze-lights :inline) + (near-mask-indices uint16 16) + (mid-minx uint8) + (mid-maxx uint8) + (mid-minz uint8) + (mid-maxz uint8) + (near-minx uint8) + (near-maxx uint8) + (near-minz uint8) + (near-maxz uint8) + (temp-minx uint8) + (temp-maxx uint8) + (temp-minz uint8) + (temp-maxz uint8) + (tex1 uint64) + (tex1-near uint64) + (wait-to-vu0 uint32) + ) + (:methods + (ocean-method-11 () none) + (ocean-method-12 () none) + (ocean-method-13 () none) + (ocean-method-14 () none) + (ocean-method-15 () none) + (ocean-method-16 () none) + (ocean-method-17 () none) + (ocean-method-18 () none) + (ocean-method-19 () none) + (ocean-method-20 () none) + (ocean-method-21 () none) + (ocean-method-22 () none) + (ocean-method-23 () none) + (ocean-method-24 () none) + (ocean-method-25 () none) + (ocean-method-26 () none) + (ocean-method-27 () none) + (ocean-method-28 () none) + (ocean-method-29 () none) + (ocean-method-30 () none) + (ocean-method-31 () none) + (ocean-method-32 () none) + (ocean-method-33 () none) + (ocean-method-34 () none) + (ocean-method-35 () none) + (ocean-method-36 () none) + (ocean-method-37 () none) + (ocean-method-38 () none) + (ocean-method-39 () none) + (ocean-method-40 () none) + (ocean-method-41 () none) + (ocean-method-42 () none) + (ocean-method-43 () none) + (ocean-method-44 () none) + (ocean-method-45 () none) + (ocean-method-46 () none) + (ocean-method-47 () none) + (ocean-method-48 () none) + (ocean-method-49 () none) + (ocean-method-50 () none) + (ocean-method-51 () none) + (ocean-method-52 () none) + (ocean-method-53 () none) + (ocean-method-54 () none) + (ocean-method-55 () none) + (ocean-method-56 () none) + (ocean-method-57 () none) + (ocean-method-58 () none) + (ocean-method-59 () none) + (ocean-method-60 () none) + (ocean-method-61 () none) + (ocean-method-62 () none) + (ocean-method-63 () none) + (ocean-method-64 () none) + (ocean-method-65 () none) + (ocean-method-66 () none) + (ocean-method-67 () none) + (ocean-method-68 () none) + (ocean-method-69 () none) + (ocean-method-70 () none) + (ocean-method-71 () none) + (ocean-method-72 () none) + (ocean-method-73 () none) + (ocean-method-74 () none) + (ocean-method-75 () none) + (ocean-method-76 () none) + (ocean-method-77 () none) + (ocean-method-78 () none) + (ocean-method-79 () none) + (ocean-method-80 () none) + (ocean-method-81 () none) + (ocean-method-82 () none) + (ocean-method-83 () none) + ) + ) + +;; definition for method 3 of type ocean +(defmethod inspect ((this ocean)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ocean) + (format #t "~1Tstart-corner: #~%" (-> this start-corner)) + (format #t "~1Tfar-color: #~%" (-> this far-color)) + (format #t "~1Tocean-colors: #~%" (-> this ocean-colors)) + (format #t "~1Tocean-mid-indices: ~A~%" (-> this ocean-mid-indices)) + (format #t "~1Tocean-trans-indices: ~A~%" (-> this ocean-trans-indices)) + (format #t "~1Tocean-near-indices: ~A~%" (-> this ocean-near-indices)) + (format #t "~1Tocean-mid-masks: ~A~%" (-> this ocean-mid-masks)) + (format #t "~1Toff: ~A~%" (-> this off)) + (format #t "~1Tnear-off: ~A~%" (-> this near-off)) + (format #t "~1Tfar-on: ~A~%" (-> this far-on)) + (format #t "~1Tall-on: ~A~%" (-> this all-on)) + (format #t "~1Tocean-facing: ~D~%" (-> this ocean-facing)) + (format #t "~1Tmid-mask-ptrs[36] @ #x~X~%" (-> this mid-mask-ptrs)) + (format #t "~1Tmid-camera-masks[36] @ #x~X~%" (-> this mid-camera-masks)) + (format #t "~1Ttrans-mask-ptrs[64] @ #x~X~%" (-> this trans-mask-ptrs)) + (format #t "~1Ttrans-camera-masks[16] @ #x~X~%" (-> this trans-camera-masks)) + (format #t "~1Ttrans-temp-masks[16] @ #x~X~%" (-> this trans-temp-masks)) + (format #t "~1Thaze-lights: #~%" (-> this haze-lights)) + (format #t "~1Tnear-mask-indices[16] @ #x~X~%" (-> this near-mask-indices)) + (format #t "~1Tmid-minx: ~D~%" (-> this mid-minx)) + (format #t "~1Tmid-maxx: ~D~%" (-> this mid-maxx)) + (format #t "~1Tmid-minz: ~D~%" (-> this mid-minz)) + (format #t "~1Tmid-maxz: ~D~%" (-> this mid-maxz)) + (format #t "~1Tnear-minx: ~D~%" (-> this near-minx)) + (format #t "~1Tnear-maxx: ~D~%" (-> this near-maxx)) + (format #t "~1Tnear-minz: ~D~%" (-> this near-minz)) + (format #t "~1Tnear-maxz: ~D~%" (-> this near-maxz)) + (format #t "~1Ttemp-minx: ~D~%" (-> this temp-minx)) + (format #t "~1Ttemp-maxx: ~D~%" (-> this temp-maxx)) + (format #t "~1Ttemp-minz: ~D~%" (-> this temp-minz)) + (format #t "~1Ttemp-maxz: ~D~%" (-> this temp-maxz)) + (format #t "~1Ttex1: ~D~%" (-> this tex1)) + (format #t "~1Ttex1-near: ~D~%" (-> this tex1-near)) + (format #t "~1Twait-to-vu0: ~D~%" (-> this wait-to-vu0)) + (label cfg-4) + this + ) + +;; definition for symbol *ocean-map*, type ocean-map +(define *ocean-map* (the-as ocean-map #f)) + +;; definition for symbol *ocean*, type ocean +(define *ocean* (new 'static 'ocean :tex1 #xf6f00000178 :tex1-near #xf6f00000164)) + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/shrub/shrubbery-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/shrub/shrubbery-h_REF.gc new file mode 100644 index 0000000000..cdab2f00c1 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/shrub/shrubbery-h_REF.gc @@ -0,0 +1,484 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type billboard +(deftype billboard (drawable) + "A billboard for shrubbery in the distance. This is simple a quad that faces the camera. +The only data needed is the texture/mode. The location is determined by bsphere." + ((flat adgif-shader :inline) + ) + ) + +;; definition for method 3 of type billboard +(defmethod inspect ((this billboard)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tflat: #~%" (-> this flat)) + (label cfg-4) + this + ) + +;; definition of type shrub-view-data +(deftype shrub-view-data (structure) + "Camera and general settings for shrubbery VU1 program." + ((data uint128 3) + (texture-giftag gs-gif-tag :inline :overlay-at (-> data 0)) + (consts vector :inline :overlay-at (-> data 1)) + (fog-clamp vector :inline :overlay-at (-> data 2)) + (tex-start-ptr int32 :overlay-at (-> data 1)) + (gifbufsum float :overlay-at (-> data 1)) + (mtx-buf-ptr int32 :overlay-at (-> consts y)) + (exp23 float :overlay-at mtx-buf-ptr) + (fog-0 float :overlay-at (-> consts z)) + (fog-1 float :overlay-at (-> consts w)) + (fog-min float :overlay-at (-> data 2)) + (fog-max float :overlay-at (-> fog-clamp y)) + ) + ) + +;; definition for method 3 of type shrub-view-data +(defmethod inspect ((this shrub-view-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shrub-view-data) + (format #t "~1Tdata[3] @ #x~X~%" (-> this data)) + (format #t "~1Ttexture-giftag: #~%" (-> this data)) + (format #t "~1Tconsts: #~%" (-> this consts)) + (format #t "~1Tfog-clamp: #~%" (-> this fog-clamp)) + (format #t "~1Ttex-start-ptr: ~D~%" (-> this consts x)) + (format #t "~1Tgifbufsum: ~f~%" (-> this consts x)) + (format #t "~1Tmtx-buf-ptr: ~D~%" (-> this consts y)) + (format #t "~1Texp23: ~f~%" (-> this consts y)) + (format #t "~1Tfog-0: ~f~%" (-> this consts z)) + (format #t "~1Tfog-1: ~f~%" (-> this consts w)) + (format #t "~1Tfog-min: ~f~%" (-> this fog-clamp x)) + (format #t "~1Tfog-max: ~f~%" (-> this fog-clamp y)) + (label cfg-4) + this + ) + +;; definition of type shrubbery +(deftype shrubbery (drawable) + "Prototype (mesh/geometry) for a shrub. not _really_ a drawable in any way, as it +overwrites all the normal drawable fields." + ((textures (inline-array adgif-shader) :overlay-at id) + (header qword :offset 8) + (obj-qwc uint8 :offset 12) + (vtx-qwc uint8 :offset 13) + (col-qwc uint8 :offset 14) + (stq-qwc uint8 :offset 15) + (obj uint32 :overlay-at (-> bsphere data 0)) + (vtx uint32 :overlay-at (-> bsphere data 1)) + (col uint32 :overlay-at (-> bsphere data 2)) + (stq uint32 :overlay-at (-> bsphere data 3)) + ) + ) + +;; definition for method 3 of type shrubbery +(defmethod inspect ((this shrubbery)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Ttextures: #x~X~%" (-> this textures)) + (format #t "~1Theader: #~%" (-> this header)) + (format #t "~1Tobj-qwc: ~D~%" (-> this obj-qwc)) + (format #t "~1Tvtx-qwc: ~D~%" (-> this vtx-qwc)) + (format #t "~1Tcol-qwc: ~D~%" (-> this col-qwc)) + (format #t "~1Tstq-qwc: ~D~%" (-> this stq-qwc)) + (format #t "~1Tobj: #x~X~%" (-> this bsphere x)) + (format #t "~1Tvtx: #x~X~%" (-> this bsphere y)) + (format #t "~1Tcol: #x~X~%" (-> this bsphere z)) + (format #t "~1Tstq: #x~X~%" (-> this bsphere w)) + (label cfg-4) + this + ) + +;; definition of type instance-shrubbery +(deftype instance-shrubbery (instance) + "Instance of a shrub." + ((flat-normal vector :inline) + (flat-hwidth float :overlay-at (-> flat-normal data 3)) + (color uint32 :offset 8) + ) + ) + +;; definition for method 3 of type instance-shrubbery +(defmethod inspect ((this instance-shrubbery)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tbucket-index: ~D~%" (-> this bucket-index)) + (format #t "~1Torigin: #~%" (-> this origin)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Twind-index: ~D~%" (-> this wind-index)) + (format #t "~1Tflat-normal: #~%" (-> this flat-normal)) + (format #t "~1Tflat-hwidth: ~f~%" (-> this flat-normal w)) + (format #t "~1Tcolor: ~D~%" (-> this color)) + (label cfg-4) + this + ) + +;; definition of type drawable-inline-array-instance-shrub +(deftype drawable-inline-array-instance-shrub (drawable-inline-array) + "Array of shrub instances stored in the level data." + ((data instance-shrubbery 1 :inline) + (pad uint32) + ) + ) + +;; definition of type drawable-tree-instance-shrub +(deftype drawable-tree-instance-shrub (drawable-tree) + "Drawable-tree for the shrubs." + ((info prototype-array-shrub-info :offset 8) + (colors-added time-of-day-palette :offset 12) + ) + ) + +;; definition of type generic-shrub-fragment +(deftype generic-shrub-fragment (drawable) + "Shrub data, converted into the format for generic. +The shrub renderer doesn't support clipping, so it falls back to generic. +This requires storing the data for all shrubs prototype twice!" + ((textures (inline-array adgif-shader) :overlay-at id) + (vtx-cnt uint32 :offset 8) + (cnt-qwc uint8 :offset 12) + (vtx-qwc uint8 :offset 13) + (col-qwc uint8 :offset 14) + (stq-qwc uint8 :offset 15) + (cnt uint32 :overlay-at (-> bsphere data 0)) + (vtx uint32 :overlay-at (-> bsphere data 1)) + (col uint32 :overlay-at (-> bsphere data 2)) + (stq uint32 :overlay-at (-> bsphere data 3)) + ) + ) + +;; definition for method 3 of type generic-shrub-fragment +(defmethod inspect ((this generic-shrub-fragment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Ttextures: #x~X~%" (-> this textures)) + (format #t "~1Tvtx-cnt: ~D~%" (-> this vtx-cnt)) + (format #t "~1Tcnt-qwc: ~D~%" (-> this cnt-qwc)) + (format #t "~1Tvtx-qwc: ~D~%" (-> this vtx-qwc)) + (format #t "~1Tcol-qwc: ~D~%" (-> this col-qwc)) + (format #t "~1Tstq-qwc: ~D~%" (-> this stq-qwc)) + (format #t "~1Tcnt: #x~X~%" (-> this bsphere x)) + (format #t "~1Tvtx: #x~X~%" (-> this bsphere y)) + (format #t "~1Tcol: #x~X~%" (-> this bsphere z)) + (format #t "~1Tstq: #x~X~%" (-> this bsphere w)) + (label cfg-4) + this + ) + +;; definition of type prototype-shrubbery +(deftype prototype-shrubbery (drawable-inline-array) + "Array of shrub prototypes." + ((data shrubbery 1 :inline) + (pad uint32) + ) + ) + +;; definition of type prototype-trans-shrubbery +(deftype prototype-trans-shrubbery (prototype-shrubbery) + "Array of transparent shrub prototypes." + () + ) + +;; definition of type prototype-generic-shrub +(deftype prototype-generic-shrub (drawable-group) + () + ) + +;; definition of type shrubbery-matrix +(deftype shrubbery-matrix (structure) + "Instance matrix for a shrub, contains interpolated color." + ((mat matrix :inline) + (color qword :inline) + ) + ) + +;; definition for method 3 of type shrubbery-matrix +(defmethod inspect ((this shrubbery-matrix)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shrubbery-matrix) + (format #t "~1Tmat: #~%" (-> this mat)) + (format #t "~1Tcolor: #~%" (-> this color)) + (label cfg-4) + this + ) + +;; definition for function shrubbery-login-post-texture +;; INFO: Used lq/sq +;; WARN: Return type mismatch symbol vs none. +(defun shrubbery-login-post-texture ((arg0 shrubbery)) + "Do some weird fix-up to the shrubbery textures. this is likely to present normal-looking adgifs to the texture system, but then we scramble them up for easier consumption by VU1." + (let* ((v1-1 (-> arg0 header data 0)) + (a1-1 (the-as object (+ (the-as uint (-> arg0 header)) (* (+ (-> arg0 header data 1) 1) 16)))) + (a2-5 (the-as object (+ (the-as int a1-1) (* v1-1 64)))) + (a3-0 (the-as object (-> arg0 textures))) + ) + (dotimes (a0-1 (the-as int v1-1)) + (set! (-> (the-as qword a2-5) quad) (-> (the-as qword a3-0) quad)) + (let ((a2-6 (the-as object (+ (the-as int a2-5) 16))) + (a3-1 (the-as object (&+ (the-as pointer a3-0) 16))) + ) + (set! (-> (the-as qword a1-1) vector4w x) (the-as int (-> (the-as qword a3-1) data 0))) + (set! (-> (the-as qword a1-1) vector4w y) (the-as int (-> (the-as qword a3-1) data 1))) + (set! (-> (the-as qword a1-1) vector4w z) (the-as int (-> (the-as qword a3-1) data 2))) + (set! a1-1 (+ (the-as int a1-1) 16)) + (let ((a3-2 (the-as object (&+ (the-as pointer a3-1) 16)))) + (dotimes (t0-4 3) + (set! (-> (the-as qword a1-1) quad) (-> (the-as qword a3-2) quad)) + (set! a1-1 (+ (the-as int a1-1) 16)) + (set! a3-2 (&+ (the-as pointer a3-2) 16)) + ) + (set! (-> (the-as qword a2-6) quad) (-> (the-as qword a3-2) quad)) + (set! a2-5 (+ (the-as int a2-6) 16)) + (set! a3-0 (&+ (the-as pointer a3-2) 80)) + ) + ) + ) + ) + (none) + ) + +;; definition for symbol *shrub-state*, type int +(define *shrub-state* 0) + +;; definition of type shrub-near-packet +(deftype shrub-near-packet (structure) + "DMA templates for generic rendering of shrubs." + ((matrix-tmpl dma-packet :inline) + (header-tmpl dma-packet :inline) + (stq-tmpl dma-packet :inline) + (color-tmpl dma-packet :inline) + (vertex-tmpl dma-packet :inline) + (mscal-tmpl dma-packet :inline) + (init-tmpl dma-packet :inline) + (init-data qword 2 :inline) + ) + ) + +;; definition for method 3 of type shrub-near-packet +(defmethod inspect ((this shrub-near-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shrub-near-packet) + (format #t "~1Tmatrix-tmpl: #~%" (-> this matrix-tmpl)) + (format #t "~1Theader-tmpl: #~%" (-> this header-tmpl)) + (format #t "~1Tstq-tmpl: #~%" (-> this stq-tmpl)) + (format #t "~1Tcolor-tmpl: #~%" (-> this color-tmpl)) + (format #t "~1Tvertex-tmpl: #~%" (-> this vertex-tmpl)) + (format #t "~1Tmscal-tmpl: #~%" (-> this mscal-tmpl)) + (format #t "~1Tinit-tmpl: #~%" (-> this init-tmpl)) + (format #t "~1Tinit-data[8] @ #x~X~%" (-> this init-data)) + (label cfg-4) + this + ) + +;; definition of type instance-shrub-work +(deftype instance-shrub-work (structure) + "Scratchpad layout for generating shrub DMA." + ((dummy qword 3 :inline) + (chaina qword 8 :inline) + (chainb qword 8 :inline) + (colors rgba 1024) + (matrix-tmpl qword 20 :inline) + (count-tmpl vector4w 20 :inline) + (mscalf-tmpl dma-packet :inline) + (mscalf-ret-tmpl dma-packet :inline) + (adgif-tmpl dma-gif-packet :inline) + (billboard-tmpl dma-gif-packet :inline) + (billboard-const vector :inline) + (shrub-near-packets shrub-near-packet 6 :inline) + (dma-ref dma-packet :inline) + (dma-end dma-packet :inline) + (wind-const vector :inline) + (constants vector :inline) + (color-constant vector4w :inline) + (hmge-d vector :inline) + (hvdf-offset vector :inline) + (wind-force vector :inline) + (color vector :inline) + (bb-color vector :inline) + (min-dist vector :inline) + (temp-vec vector :inline) + (guard-plane plane 4 :inline) + (plane plane 4 :inline) + (last uint32 4) + (next uint32 4) + (count uint16 4) + (mod-count uint16 4) + (wind-vectors uint32) + (instance-ptr uint32) + (chain-ptr uint32) + (chain-ptr-next uint32) + (stack-ptr uint32) + (bucket-ptr uint32) + (src-ptr uint32) + (to-spr uint32) + (from-spr uint32) + (shrub-count uint32) + (stack-ptr2 uint32 :overlay-at stack-ptr) + (node uint32 6 :offset 6428) + (length uint32 6) + (prototypes uint32) + (bucket-ptr2 uint32 :overlay-at bucket-ptr) + (start-bank uint8 20 :offset 6484) + (buffer-index uint32) + (current-spr uint32) + (current-mem uint32) + (current-shrub-near-packet uint32) + (current-shrub-near-trans-packet uint32) + (to-spr2 uint32 :overlay-at to-spr) + (dma-buffer basic :offset 6528) + (near-last uint32) + (near-next uint32) + (near-count uint32) + (near-trans-last uint32) + (near-trans-next uint32) + (near-trans-count uint32) + (last-shrubs uint32) + (chains uint32) + (flags uint32) + (node-count uint32) + (inst-count uint32) + (wait-from-spr uint32) + (wait-to-spr uint32) + (texture-dists uint32) + ) + ) + +;; definition for method 3 of type instance-shrub-work +(defmethod inspect ((this instance-shrub-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'instance-shrub-work) + (format #t "~1Tdummy[3] @ #x~X~%" (-> this dummy)) + (format #t "~1Tchaina[8] @ #x~X~%" (-> this chaina)) + (format #t "~1Tchainb[8] @ #x~X~%" (-> this chainb)) + (format #t "~1Tcolors[1024] @ #x~X~%" (-> this colors)) + (format #t "~1Tmatrix-tmpl[20] @ #x~X~%" (-> this matrix-tmpl)) + (format #t "~1Tcount-tmpl[20] @ #x~X~%" (-> this count-tmpl)) + (format #t "~1Tmscalf-tmpl: #~%" (-> this mscalf-tmpl)) + (format #t "~1Tmscalf-ret-tmpl: #~%" (-> this mscalf-ret-tmpl)) + (format #t "~1Tadgif-tmpl: #~%" (-> this adgif-tmpl)) + (format #t "~1Tbillboard-tmpl: #~%" (-> this billboard-tmpl)) + (format #t "~1Tbillboard-const: #~%" (-> this billboard-const)) + (format #t "~1Tshrub-near-packets[6] @ #x~X~%" (-> this shrub-near-packets)) + (format #t "~1Tdma-ref: #~%" (-> this dma-ref)) + (format #t "~1Tdma-end: #~%" (-> this dma-end)) + (format #t "~1Twind-const: #~%" (-> this wind-const)) + (format #t "~1Tconstants: #~%" (-> this constants)) + (format #t "~1Tcolor-constant: #~%" (-> this color-constant)) + (format #t "~1Thmge-d: #~%" (-> this hmge-d)) + (format #t "~1Thvdf-offset: #~%" (-> this hvdf-offset)) + (format #t "~1Twind-force: #~%" (-> this wind-force)) + (format #t "~1Tcolor: #~%" (-> this color)) + (format #t "~1Tbb-color: #~%" (-> this bb-color)) + (format #t "~1Tmin-dist: #~%" (-> this min-dist)) + (format #t "~1Ttemp-vec: #~%" (-> this temp-vec)) + (format #t "~1Tguard-plane[4] @ #x~X~%" (-> this guard-plane)) + (format #t "~1Tplane[4] @ #x~X~%" (-> this plane)) + (format #t "~1Tlast[4] @ #x~X~%" (-> this last)) + (format #t "~1Tnext[4] @ #x~X~%" (-> this next)) + (format #t "~1Tcount[4] @ #x~X~%" (-> this count)) + (format #t "~1Tmod-count[4] @ #x~X~%" (-> this mod-count)) + (format #t "~1Twind-vectors: #x~X~%" (-> this wind-vectors)) + (format #t "~1Tinstance-ptr: ~D~%" (-> this instance-ptr)) + (format #t "~1Tchain-ptr: ~D~%" (-> this chain-ptr)) + (format #t "~1Tchain-ptr-next: ~D~%" (-> this chain-ptr-next)) + (format #t "~1Tstack-ptr: ~D~%" (-> this stack-ptr)) + (format #t "~1Tbucket-ptr: ~D~%" (-> this bucket-ptr)) + (format #t "~1Tsrc-ptr: ~D~%" (-> this src-ptr)) + (format #t "~1Tto-spr: ~D~%" (-> this to-spr)) + (format #t "~1Tfrom-spr: ~D~%" (-> this from-spr)) + (format #t "~1Tshrub-count: ~D~%" (-> this shrub-count)) + (format #t "~1Tstack-ptr: ~D~%" (-> this stack-ptr)) + (format #t "~1Tnode[6] @ #x~X~%" (-> this node)) + (format #t "~1Tlength[6] @ #x~X~%" (-> this length)) + (format #t "~1Tprototypes: ~D~%" (-> this prototypes)) + (format #t "~1Tbucket-ptr: ~D~%" (-> this bucket-ptr)) + (format #t "~1Tstart-bank[20] @ #x~X~%" (-> this start-bank)) + (format #t "~1Tbuffer-index: ~D~%" (-> this buffer-index)) + (format #t "~1Tcurrent-spr: ~D~%" (-> this current-spr)) + (format #t "~1Tcurrent-mem: ~D~%" (-> this current-mem)) + (format #t "~1Tcurrent-shrub-near-packet: ~D~%" (-> this current-shrub-near-packet)) + (format #t "~1Tcurrent-shrub-near-trans-packet: ~D~%" (-> this current-shrub-near-trans-packet)) + (format #t "~1Tto-spr: ~D~%" (-> this to-spr)) + (format #t "~1Tdma-buffer: ~A~%" (-> this dma-buffer)) + (format #t "~1Tnear-last: ~D~%" (-> this near-last)) + (format #t "~1Tnear-next: ~D~%" (-> this near-next)) + (format #t "~1Tnear-count: ~D~%" (-> this near-count)) + (format #t "~1Tnear-trans-last: ~D~%" (-> this near-trans-last)) + (format #t "~1Tnear-trans-next: ~D~%" (-> this near-trans-next)) + (format #t "~1Tnear-trans-count: ~D~%" (-> this near-trans-count)) + (format #t "~1Tlast-shrubs: ~D~%" (-> this last-shrubs)) + (format #t "~1Tchains: ~D~%" (-> this chains)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tnode-count: ~D~%" (-> this node-count)) + (format #t "~1Tinst-count: ~D~%" (-> this inst-count)) + (format #t "~1Twait-from-spr: ~D~%" (-> this wait-from-spr)) + (format #t "~1Twait-to-spr: ~D~%" (-> this wait-to-spr)) + (format #t "~1Ttexture-dists: #x~X~%" (-> this texture-dists)) + (label cfg-4) + this + ) + +;; definition of type instance-shrub-dma +(deftype instance-shrub-dma (structure) + ((instancea uint128 325) + (instanceb uint128 325) + (outa uint128 128) + (outb uint128 128) + ) + ) + +;; definition for method 3 of type instance-shrub-dma +(defmethod inspect ((this instance-shrub-dma)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'instance-shrub-dma) + (format #t "~1Tinstancea[325] @ #x~X~%" (-> this instancea)) + (format #t "~1Tinstanceb[325] @ #x~X~%" (-> this instanceb)) + (format #t "~1Touta[128] @ #x~X~%" (-> this outa)) + (format #t "~1Toutb[128] @ #x~X~%" (-> this outb)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/sky/sky-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/sky/sky-h_REF.gc new file mode 100644 index 0000000000..26c4f43f6d --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/sky/sky-h_REF.gc @@ -0,0 +1,497 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type sky-color-hour +(deftype sky-color-hour (structure) + ((snapshot1 int32) + (snapshot2 int32) + (morph-start float) + (morph-end float) + ) + ) + +;; definition for method 3 of type sky-color-hour +(defmethod inspect ((this sky-color-hour)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sky-color-hour) + (format #t "~1Tsnapshot1: ~D~%" (-> this snapshot1)) + (format #t "~1Tsnapshot2: ~D~%" (-> this snapshot2)) + (format #t "~1Tmorph-start: ~f~%" (-> this morph-start)) + (format #t "~1Tmorph-end: ~f~%" (-> this morph-end)) + (label cfg-4) + this + ) + +;; definition of type sky-color-day +(deftype sky-color-day (structure) + ((hour sky-color-hour 24 :inline) + ) + ) + +;; definition for method 3 of type sky-color-day +(defmethod inspect ((this sky-color-day)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sky-color-day) + (format #t "~1Thour[24] @ #x~X~%" (-> this hour)) + (label cfg-4) + this + ) + +;; definition of type sky-sun-data +(deftype sky-sun-data (structure) + ((data uint128 4) + (pos vector :inline :overlay-at (-> data 0)) + (r-sun float :overlay-at (-> data 1)) + (r-halo float :offset 20) + (r-aurora float :offset 24) + (c-sun-start rgba :overlay-at (-> data 2)) + (c-sun-end rgba :overlay-at (-> data 3)) + (c-halo-start rgba :offset 36) + (c-halo-end rgba :offset 52) + (c-aurora-start rgba :offset 40) + (c-aurora-end rgba :offset 56) + ) + ) + +;; definition for method 3 of type sky-sun-data +(defmethod inspect ((this sky-sun-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sky-sun-data) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (format #t "~1Tpos: #~%" (-> this data)) + (format #t "~1Tr-sun: ~f~%" (-> this r-sun)) + (format #t "~1Tr-halo: ~f~%" (-> this r-halo)) + (format #t "~1Tr-aurora: ~f~%" (-> this r-aurora)) + (format #t "~1Tc-sun-start: ~D~%" (-> this c-sun-start)) + (format #t "~1Tc-sun-end: ~D~%" (-> this c-sun-end)) + (format #t "~1Tc-halo-start: ~D~%" (-> this c-halo-start)) + (format #t "~1Tc-halo-end: ~D~%" (-> this c-halo-end)) + (format #t "~1Tc-aurora-start: ~D~%" (-> this c-aurora-start)) + (format #t "~1Tc-aurora-end: ~D~%" (-> this c-aurora-end)) + (label cfg-4) + this + ) + +;; definition of type sky-moon-data +(deftype sky-moon-data (structure) + ((data uint128 2) + (pos vector :inline :overlay-at (-> data 0)) + (scale vector :inline :overlay-at (-> data 1)) + ) + ) + +;; definition for method 3 of type sky-moon-data +(defmethod inspect ((this sky-moon-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sky-moon-data) + (format #t "~1Tdata[2] @ #x~X~%" (-> this data)) + (format #t "~1Tpos: #~%" (-> this data)) + (format #t "~1Tscale: #~%" (-> this scale)) + (label cfg-4) + this + ) + +;; definition of type sky-orbit +(deftype sky-orbit (structure) + ((high-noon float) + (tilt float) + (rise float) + (dist float) + (min-halo float) + (max-halo float) + ) + :allow-misaligned + ) + +;; definition for method 3 of type sky-orbit +(defmethod inspect ((this sky-orbit)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sky-orbit) + (format #t "~1Thigh-noon: ~f~%" (-> this high-noon)) + (format #t "~1Ttilt: ~f~%" (-> this tilt)) + (format #t "~1Trise: ~f~%" (-> this rise)) + (format #t "~1Tdist: ~f~%" (-> this dist)) + (format #t "~1Tmin-halo: ~f~%" (-> this min-halo)) + (format #t "~1Tmax-halo: ~f~%" (-> this max-halo)) + (label cfg-4) + this + ) + +;; definition of type sky-upload-data +(deftype sky-upload-data (structure) + ((data uint128 12) + (sun sky-sun-data 2 :inline :overlay-at (-> data 0)) + (moon sky-moon-data :inline :overlay-at (-> data 8)) + ) + ) + +;; definition for method 3 of type sky-upload-data +(defmethod inspect ((this sky-upload-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sky-upload-data) + (format #t "~1Tdata[12] @ #x~X~%" (-> this data)) + (format #t "~1Tsun[2] @ #x~X~%" (-> this data)) + (format #t "~1Tmoon: #~%" (-> this moon)) + (label cfg-4) + this + ) + +;; definition of type sky-vertex +(deftype sky-vertex (structure) + ((pos vector :inline) + (stq vector :inline) + (col vector :inline) + ) + ) + +;; definition for method 3 of type sky-vertex +;; INFO: this function exists in multiple non-identical object files +(defmethod inspect ((this sky-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sky-vertex) + (format #t "~1Tpos: #~%" (-> this pos)) + (format #t "~1Tstq: #~%" (-> this stq)) + (format #t "~1Tcol: #~%" (-> this col)) + (label cfg-4) + this + ) + +;; definition for method 3 of type sky-vertex +;; INFO: this function exists in multiple non-identical object files +(defmethod inspect ((this sky-vertex)) + (format #t "sky-vertex [~X]:~%" this) + (format #t "~TPos: [~F ~F ~F ~F]~%" (-> this pos x) (-> this pos y) (-> this pos z) (-> this pos w)) + (format #t "~TSTQ: [~F ~F ~F ~F]~%" (-> this stq x) (-> this stq y) (-> this stq z) (-> this stq w)) + (format #t "~TCol: [~F ~F ~F ~F]~%" (-> this col x) (-> this col y) (-> this col z) (-> this col w)) + this + ) + +;; definition of type cloud-vertex +(deftype cloud-vertex (structure) + ((pos vector :inline) + (stq vector :inline) + (col vector :inline) + (nrm vector :inline) + (stq2 vector :inline) + (col2 vector :inline) + (nrm2 vector :inline) + ) + ) + +;; definition for method 3 of type cloud-vertex +(defmethod inspect ((this cloud-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cloud-vertex) + (format #t "~1Tpos: ~`vector`P~%" (-> this pos)) + (format #t "~1Tstq: ~`vector`P~%" (-> this stq)) + (format #t "~1Tcol: ~`vector`P~%" (-> this col)) + (format #t "~1Tnrm: ~`vector`P~%" (-> this nrm)) + (format #t "~1Tstq2: ~`vector`P~%" (-> this stq2)) + (format #t "~1Tcol2: ~`vector`P~%" (-> this col2)) + (format #t "~1Tnrm2: ~`vector`P~%" (-> this nrm2)) + (label cfg-4) + this + ) + +;; definition of type cloud-vert-array +(deftype cloud-vert-array (structure) + ((data cloud-vertex 100 :inline) + ) + ) + +;; definition for method 3 of type cloud-vert-array +(defmethod inspect ((this cloud-vert-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cloud-vert-array) + (format #t "~1Tdata[100] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type haze-vertex +(deftype haze-vertex (structure) + ((pos vector :inline) + (nrm vector :inline) + (col vector :inline) + ) + ) + +;; definition for method 3 of type haze-vertex +(defmethod inspect ((this haze-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'haze-vertex) + (format #t "~1Tpos: ~`vector`P~%" (-> this pos)) + (format #t "~1Tnrm: ~`vector`P~%" (-> this nrm)) + (format #t "~1Tcol: ~`vector`P~%" (-> this col)) + (label cfg-4) + this + ) + +;; definition of type haze-vert-array +(deftype haze-vert-array (structure) + ((data haze-vertex 36 :inline) + ) + ) + +;; definition for method 3 of type haze-vert-array +(defmethod inspect ((this haze-vert-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'haze-vert-array) + (format #t "~1Tdata[36] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type cloud-lights +(deftype cloud-lights (structure) + ((sun0-normal vector :inline) + (sun1-normal vector :inline) + (moon-normal vector :inline) + (ambi-color vector :inline) + (ambi-color-lower vector :inline) + (sun0-color vector :inline) + (sun1-color vector :inline) + (moon-color vector :inline) + (sun0-color-lower vector :inline) + (sun0-scale float) + (sun1-scale float) + (moon-scale float) + ) + ) + +;; definition for method 3 of type cloud-lights +(defmethod inspect ((this cloud-lights)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cloud-lights) + (format #t "~1Tsun0-normal: #~%" (-> this sun0-normal)) + (format #t "~1Tsun1-normal: #~%" (-> this sun1-normal)) + (format #t "~1Tmoon-normal: #~%" (-> this moon-normal)) + (format #t "~1Tambi-color: #~%" (-> this ambi-color)) + (format #t "~1Tambi-color-lower: #~%" (-> this ambi-color-lower)) + (format #t "~1Tsun0-color: #~%" (-> this sun0-color)) + (format #t "~1Tsun1-color: #~%" (-> this sun1-color)) + (format #t "~1Tmoon-color: #~%" (-> this moon-color)) + (format #t "~1Tsun0-color-lower: #~%" (-> this sun0-color-lower)) + (format #t "~1Tsun0-scale: ~f~%" (-> this sun0-scale)) + (format #t "~1Tsun1-scale: ~f~%" (-> this sun1-scale)) + (format #t "~1Tmoon-scale: ~f~%" (-> this moon-scale)) + (label cfg-4) + this + ) + +;; definition of type haze-lights +(deftype haze-lights (structure) + ((sun0-normal vector :inline) + (sun1-normal vector :inline) + (moon-normal vector :inline) + (ambi-color vector :inline) + (sun0-color vector :inline) + (sun1-color vector :inline) + (moon-color vector :inline) + (sun0-scale float) + (sun1-scale float) + (moon-scale float) + ) + ) + +;; definition for method 3 of type haze-lights +(defmethod inspect ((this haze-lights)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'haze-lights) + (format #t "~1Tsun0-normal: #~%" (-> this sun0-normal)) + (format #t "~1Tsun1-normal: #~%" (-> this sun1-normal)) + (format #t "~1Tmoon-normal: #~%" (-> this moon-normal)) + (format #t "~1Tambi-color: #~%" (-> this ambi-color)) + (format #t "~1Tsun0-color: #~%" (-> this sun0-color)) + (format #t "~1Tsun1-color: #~%" (-> this sun1-color)) + (format #t "~1Tmoon-color: #~%" (-> this moon-color)) + (format #t "~1Tsun0-scale: ~f~%" (-> this sun0-scale)) + (format #t "~1Tsun1-scale: ~f~%" (-> this sun1-scale)) + (format #t "~1Tmoon-scale: ~f~%" (-> this moon-scale)) + (label cfg-4) + this + ) + +;; definition of type sky-work +(deftype sky-work (structure) + ((adgif-tmpl dma-gif-packet :inline) + (draw-tmpl dma-gif-packet :inline) + (draw-tmpl2 dma-gif-packet :inline) + (fog-tmpl dma-gif-packet :inline) + (blend-tmpl dma-gif-packet :inline) + (sprite-tmpl dma-gif-packet :inline) + (sprite-tmpl2 dma-gif-packet :inline) + (sun-coords vector 2 :inline) + (green-coords vector 2 :inline) + (moon0-coords vector 2 :inline) + (moon1-coords vector 2 :inline) + (moon2-coords vector 2 :inline) + (star-coords vector 2 :inline) + (sun-colors vector4w 2 :inline) + (green-colors vector4w 2 :inline) + (moon-colors vector4w 3 :inline) + (star-colors vector4w 16 :inline) + (st-coords vector 2 :inline) + (random vector4w 8 :inline) + (giftag-base dma-gif :inline) + (giftag-haze dma-gif :inline) + (giftag-roof dma-gif :inline) + (giftag-clouds dma-gif :inline) + (giftag-ocean dma-gif :inline) + (fog vector :inline) + (sky float 8) + (time float) + (off-s uint16) + (off-t uint16) + (orbit sky-orbit 3 :inline) + (upload-data sky-upload-data :inline) + (ambi-color vector :inline) + (ambi-color-lower vector :inline) + (sun0-color vector :inline) + (sun1-color vector :inline) + (moon-color vector :inline) + (sun0-color-lower vector :inline) + (cam-mat matrix :inline) + (star-mat matrix :inline) + (vec0 vector4w :inline) + (vec1 vector4w :inline) + (cloud-lights cloud-lights :inline) + (haze-lights haze-lights :inline) + (buf dma-buffer) + (stars vector 512 :inline) + (disable-day-star basic) + ) + (:methods + (sky-work-method-9 () none) + (sky-work-method-10 () none) + (sky-work-method-11 () none) + (sky-work-method-12 () none) + (sky-work-method-13 () none) + (sky-work-method-14 () none) + (sky-work-method-15 () none) + (sky-work-method-16 () none) + (sky-work-method-17 () none) + (sky-work-method-18 () none) + (sky-work-method-19 () none) + (sky-work-method-20 () none) + (sky-work-method-21 () none) + (sky-work-method-22 () none) + (sky-work-method-23 () none) + (sky-work-method-24 () none) + (sky-work-method-25 () none) + (sky-work-method-26 () none) + (sky-work-method-27 () none) + (sky-work-method-28 () none) + (sky-work-method-29 () none) + (sky-work-method-30 () none) + (sky-work-method-31 () none) + (sky-work-method-32 () none) + (sky-work-method-33 () none) + (sky-work-method-34 () none) + (sky-work-method-35 () none) + (sky-work-method-36 () none) + ) + ) + +;; definition for method 3 of type sky-work +(defmethod inspect ((this sky-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sky-work) + (format #t "~1Tadgif-tmpl: #~%" (-> this adgif-tmpl)) + (format #t "~1Tdraw-tmpl: #~%" (-> this draw-tmpl)) + (format #t "~1Tdraw-tmpl2: #~%" (-> this draw-tmpl2)) + (format #t "~1Tfog-tmpl: #~%" (-> this fog-tmpl)) + (format #t "~1Tblend-tmpl: #~%" (-> this blend-tmpl)) + (format #t "~1Tsprite-tmpl: #~%" (-> this sprite-tmpl)) + (format #t "~1Tsprite-tmpl2: #~%" (-> this sprite-tmpl2)) + (format #t "~1Tsun-coords[2] @ #x~X~%" (-> this sun-coords)) + (format #t "~1Tgreen-coords[2] @ #x~X~%" (-> this green-coords)) + (format #t "~1Tmoon0-coords[2] @ #x~X~%" (-> this moon0-coords)) + (format #t "~1Tmoon1-coords[2] @ #x~X~%" (-> this moon1-coords)) + (format #t "~1Tmoon2-coords[2] @ #x~X~%" (-> this moon2-coords)) + (format #t "~1Tstar-coords[2] @ #x~X~%" (-> this star-coords)) + (format #t "~1Tsun-colors[2] @ #x~X~%" (-> this sun-colors)) + (format #t "~1Tgreen-colors[2] @ #x~X~%" (-> this green-colors)) + (format #t "~1Tmoon-colors[3] @ #x~X~%" (-> this moon-colors)) + (format #t "~1Tstar-colors[16] @ #x~X~%" (-> this star-colors)) + (format #t "~1Tst-coords[2] @ #x~X~%" (-> this st-coords)) + (format #t "~1Trandom[8] @ #x~X~%" (-> this random)) + (format #t "~1Tgiftag-base: #~%" (-> this giftag-base)) + (format #t "~1Tgiftag-haze: #~%" (-> this giftag-haze)) + (format #t "~1Tgiftag-roof: #~%" (-> this giftag-roof)) + (format #t "~1Tgiftag-clouds: #~%" (-> this giftag-clouds)) + (format #t "~1Tgiftag-ocean: #~%" (-> this giftag-ocean)) + (format #t "~1Tfog: #~%" (-> this fog)) + (format #t "~1Tsky[8] @ #x~X~%" (-> this sky)) + (format #t "~1Ttime: ~f~%" (-> this time)) + (format #t "~1Toff-s: ~D~%" (-> this off-s)) + (format #t "~1Toff-t: ~D~%" (-> this off-t)) + (format #t "~1Torbit[3] @ #x~X~%" (-> this orbit)) + (format #t "~1Tupload-data: #~%" (-> this upload-data)) + (format #t "~1Tambi-color: #~%" (-> this ambi-color)) + (format #t "~1Tambi-color-lower: #~%" (-> this ambi-color-lower)) + (format #t "~1Tsun0-color: #~%" (-> this sun0-color)) + (format #t "~1Tsun1-color: #~%" (-> this sun1-color)) + (format #t "~1Tmoon-color: #~%" (-> this moon-color)) + (format #t "~1Tsun0-color-lower: #~%" (-> this sun0-color-lower)) + (format #t "~1Tcam-mat: #~%" (-> this cam-mat)) + (format #t "~1Tstar-mat: #~%" (-> this star-mat)) + (format #t "~1Tvec0: #~%" (-> this vec0)) + (format #t "~1Tvec1: #~%" (-> this vec1)) + (format #t "~1Tcloud-lights: #~%" (-> this cloud-lights)) + (format #t "~1Thaze-lights: #~%" (-> this haze-lights)) + (format #t "~1Tbuf: ~A~%" (-> this buf)) + (format #t "~1Tstars[512] @ #x~X~%" (-> this stars)) + (format #t "~1Tdisable-day-star: ~A~%" (-> this disable-day-star)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/sprite/particles/sparticle-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/sprite/particles/sparticle-h_REF.gc new file mode 100644 index 0000000000..bee8d9e3b0 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/sprite/particles/sparticle-h_REF.gc @@ -0,0 +1,181 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *sp-60-hz*, type symbol +(define *sp-60-hz* #t) + +;; definition of type sparticle-cpuinfo +(deftype sparticle-cpuinfo (structure) + "The per-particle information. This stays on the CPU, and isn't uploaded to the VU." + ((sprite sprite-vec-data-2d) + (adgif adgif-shader) + (radius float) + (omega float) + (vel-sxvel vector :inline) + (rot-syvel vector :inline) + (fade rgbaf :inline) + (acc vector :inline) + (rotvel3d quaternion :inline) + (vel vector3s :inline :overlay-at (-> vel-sxvel data 0)) + (accel vector3s :inline :overlay-at (-> acc data 0)) + (scalevelx float :overlay-at (-> vel-sxvel data 3)) + (scalevely float :overlay-at (-> rot-syvel data 3)) + (friction float) + (timer int32) + (flags sp-cpuinfo-flag) + (flags-s32 sp-cpuinfo-flag-s32 :overlay-at flags) + (user-int32 int32) + (user-uint32 uint32 :overlay-at user-int32) + (user-float float :overlay-at user-int32) + (user-pntr uint32 :overlay-at user-int32) + (user-object basic :overlay-at user-int32) + (user-sprite sprite-vec-data-2d :overlay-at user-int32) + (sp-func (function sparticle-system sparticle-cpuinfo sprite-vec-data-3d uint none)) + (next-time uint32) + (next-launcher basic) + (cache-alpha float) + (valid uint8) + (clock-index uint8) + (user1-int16 uint16) + (key sparticle-launch-control) + (binding sparticle-launch-state) + (data uint32 1 :overlay-at omega) + (datab int8 4 :overlay-at omega) + (dataf float 1 :overlay-at omega) + (datac uint8 1 :overlay-at omega) + ) + ) + +;; definition for method 3 of type sparticle-cpuinfo +(defmethod inspect ((this sparticle-cpuinfo)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sparticle-cpuinfo) + (format #t "~1Tsprite: #~%" (-> this sprite)) + (format #t "~1Tadgif: #~%" (-> this adgif)) + (format #t "~1Tradius: ~f~%" (-> this radius)) + (format #t "~1Tomega: ~f~%" (-> this omega)) + (format #t "~1Tvel-sxvel: #~%" (-> this vel-sxvel)) + (format #t "~1Trot-syvel: #~%" (-> this rot-syvel)) + (format #t "~1Tfade: #~%" (-> this fade)) + (format #t "~1Tacc: #~%" (-> this acc)) + (format #t "~1Trotvel3d: #~%" (-> this rotvel3d)) + (format #t "~1Tvel: #~%" (-> this vel-sxvel)) + (format #t "~1Taccel: #~%" (-> this acc)) + (format #t "~1Tscalevelx: ~f~%" (-> this vel-sxvel w)) + (format #t "~1Tscalevely: ~f~%" (-> this rot-syvel w)) + (format #t "~1Tfriction: ~f~%" (-> this friction)) + (format #t "~1Ttimer: ~D~%" (-> this timer)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tuser-int32: ~D~%" (-> this user-float)) + (format #t "~1Tuser-uint32: ~D~%" (-> this user-float)) + (format #t "~1Tuser-float: ~f~%" (-> this user-float)) + (format #t "~1Tuser-pntr: #x~X~%" (-> this user-float)) + (format #t "~1Tuser-object: ~A~%" (-> this user-float)) + (format #t "~1Tuser-sprite: #~%" (-> this user-float)) + (format #t "~1Tsp-func: ~A~%" (-> this sp-func)) + (format #t "~1Tnext-time: ~D~%" (-> this next-time)) + (format #t "~1Tnext-launcher: ~A~%" (-> this next-launcher)) + (format #t "~1Tcache-alpha: ~f~%" (-> this cache-alpha)) + (format #t "~1Tvalid: ~D~%" (-> this valid)) + (format #t "~1Tclock-index: ~D~%" (-> this clock-index)) + (format #t "~1Tuser1-int16: ~D~%" (-> this user1-int16)) + (format #t "~1Tcontrol: ~A~%" (-> this key)) + (format #t "~1Tbinding: ~D~%" (-> this binding)) + (format #t "~1Tdata[1] @ #x~X~%" (&-> this omega)) + (format #t "~1Tdatab[4] @ #x~X~%" (&-> this omega)) + (format #t "~1Tdataf[1] @ #x~X~%" (&-> this omega)) + (label cfg-4) + this + ) + +;; definition of type sparticle-launchinfo +(deftype sparticle-launchinfo (structure) + "Settings for launching a particle. These are a temporary thing consumed by the assembly particle code, and modified by particle callbacks." + ((launchrot vector :inline) + (conerot vector :inline) + (rotate-x float) + (rotate-y float) + (rotate-z float) + (coneradius float) + (rotate vector :inline :overlay-at rotate-x) + (scale-x float) + (scale-y float) + (scale-z float) + (dummy float) + (scale vector :inline :overlay-at scale-x) + (data uint8 1 :overlay-at (-> launchrot data 0)) + ) + ) + +;; definition for method 3 of type sparticle-launchinfo +(defmethod inspect ((this sparticle-launchinfo)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sparticle-launchinfo) + (format #t "~1Tlaunchrot: ~`vector`P~%" (-> this launchrot)) + (format #t "~1Tconerot: ~`vector`P~%" (-> this conerot)) + (format #t "~1Trotate-x: ~f~%" (-> this rotate-x)) + (format #t "~1Trotate-y: ~f~%" (-> this rotate-y)) + (format #t "~1Trotate-z: ~f~%" (-> this rotate-z)) + (format #t "~1Tconeradius: ~f~%" (-> this coneradius)) + (format #t "~1Trotate: ~`vector`P~%" (&-> this rotate-x)) + (format #t "~1Tscale-x: ~f~%" (-> this scale-x)) + (format #t "~1Tscale-y: ~f~%" (-> this scale-y)) + (format #t "~1Tscale-z: ~f~%" (-> this scale-z)) + (format #t "~1Tdummy: ~f~%" (-> this dummy)) + (format #t "~1Tscale: ~`vector`P~%" (&-> this scale-x)) + (format #t "~1Tdata[1] @ #x~X~%" (-> this launchrot)) + (label cfg-4) + this + ) + +;; definition of type sparticle-system +(deftype sparticle-system (basic) + "An entire particle 'system', which is a pipeline for spawning, updating, and generating sprite-renderer DMA data. +There are separate systems for different modes of sprite rendering: 2D/billboard, full 3D, and screen-space (HUD)" + ((blocks int32 2) + (length int32 2) + (num-alloc int32 2) + (is-3d basic) + (flags uint32) + (alloc-table (pointer uint64)) + (cpuinfo-table (inline-array sparticle-cpuinfo)) + (vecdata-table pointer) + (adgifdata-table (inline-array adgif-shader)) + ) + (:methods + (new (symbol type int int symbol pointer (inline-array adgif-shader)) _type_) + ) + ) + +;; definition for method 3 of type sparticle-system +(defmethod inspect ((this sparticle-system)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tblocks[2] @ #x~X~%" (-> this blocks)) + (format #t "~1Tlength[2] @ #x~X~%" (-> this length)) + (format #t "~1Tnum-alloc[2] @ #x~X~%" (-> this num-alloc)) + (format #t "~1Tis-3d: ~A~%" (-> this is-3d)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Talloc-table: #x~X~%" (-> this alloc-table)) + (format #t "~1Tcpuinfo-table: #x~X~%" (-> this cpuinfo-table)) + (format #t "~1Tvecdata-table: #x~X~%" (-> this vecdata-table)) + (format #t "~1Tadgifdata-table: #x~X~%" (-> this adgifdata-table)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/sprite/particles/sparticle-launcher-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/sprite/particles/sparticle-launcher-h_REF.gc new file mode 100644 index 0000000000..726db844d8 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/sprite/particles/sparticle-launcher-h_REF.gc @@ -0,0 +1,412 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type sparticle-birthinfo +(deftype sparticle-birthinfo (structure) + "Used internally by the sparticle code." + ((sprite uint32) + (anim int32) + (anim-speed float) + (birth-func basic) + (joint-ppoint int32) + (num-to-birth float) + (dataf float 1 :overlay-at sprite) + (data uint32 1 :overlay-at sprite) + ) + ) + +;; definition for method 3 of type sparticle-birthinfo +(defmethod inspect ((this sparticle-birthinfo)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sparticle-birthinfo) + (format #t "~1Tsprite: ~D~%" (-> this sprite)) + (format #t "~1Tanim: ~D~%" (-> this anim)) + (format #t "~1Tanim-speed: ~f~%" (-> this anim-speed)) + (format #t "~1Tbirth-func: ~A~%" (-> this birth-func)) + (format #t "~1Tjoint-ppoint: ~D~%" (-> this joint-ppoint)) + (format #t "~1Tnum-to-birth: ~f~%" (-> this num-to-birth)) + (format #t "~1Tdataf[1] @ #x~X~%" (&-> this sprite)) + (format #t "~1Tdata[1] @ #x~X~%" (&-> this sprite)) + (label cfg-4) + this + ) + +;; definition of type sp-field-init-spec +(deftype sp-field-init-spec (structure) + "Part of a particle definition - how to initialize a field of a particle." + ((field sp-field-id) + (flags sp-flag) + (initial-valuef float) + (random-rangef float) + (random-multf float) + (initial-value int32 :overlay-at initial-valuef) + (random-range int32 :overlay-at random-rangef) + (random-mult int32 :overlay-at random-multf) + (func symbol :overlay-at initial-valuef) + (tex texture-id :overlay-at initial-valuef) + (pntr pointer :overlay-at initial-valuef) + (object basic :overlay-at initial-valuef) + (sym symbol :overlay-at initial-valuef) + ) + :allow-misaligned + ) + +;; definition for method 3 of type sp-field-init-spec +(defmethod inspect ((this sp-field-init-spec)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sp-field-init-spec) + (format #t "~1Tfield: ~D~%" (-> this field)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tinitial-valuef: ~f~%" (-> this initial-valuef)) + (format #t "~1Trandom-rangef: ~f~%" (-> this random-rangef)) + (format #t "~1Trandom-multf: ~f~%" (-> this random-multf)) + (format #t "~1Tinitial-value: ~D~%" (-> this initial-valuef)) + (format #t "~1Trandom-range: ~D~%" (-> this random-rangef)) + (format #t "~1Trandom-mult: ~D~%" (-> this random-multf)) + (format #t "~1Tfunc: ~A~%" (-> this initial-valuef)) + (format #t "~1Ttex: ~D~%" (-> this initial-valuef)) + (format #t "~1Tpntr: #x~X~%" (-> this initial-valuef)) + (format #t "~1Tobject: ~A~%" (-> this initial-valuef)) + (format #t "~1Tsym: ~A~%" (-> this initial-valuef)) + (label cfg-4) + this + ) + +;; definition of type sparticle-launcher +(deftype sparticle-launcher (basic) + "A definition of a single particle, as a list of init specs." + ((birthaccum float) + (soundaccum float) + (init-specs (inline-array sp-field-init-spec)) + ) + (:methods + (get-field-spec-by-id (_type_ sp-field-id) sp-field-init-spec) + (setup-special-textures (_type_ string) none) + ) + ) + +;; definition for method 3 of type sparticle-launcher +(defmethod inspect ((this sparticle-launcher)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tbirthaccum: ~f~%" (-> this birthaccum)) + (format #t "~1Tinit-specs: #x~X~%" (-> this soundaccum)) + (format #t "~1Tlevel-flag: ~D~%" (-> this init-specs)) + (label cfg-4) + this + ) + +;; definition of type sparticle-group-item +(deftype sparticle-group-item (structure) + "A reference to a single sparticle-launcher (by ID) and some parameters for using it." + ((launcher uint32) + (fade-after meters) + (falloff-to meters) + (flags sp-group-item-flag) + (period uint16) + (length uint16) + (offset int16) + (hour-mask uint32) + (binding uint32) + ) + ) + +;; definition for method 3 of type sparticle-group-item +(defmethod inspect ((this sparticle-group-item)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sparticle-group-item) + (format #t "~1Tlauncher: ~D~%" (-> this launcher)) + (format #t "~1Tfade-after: (meters ~m)~%" (-> this fade-after)) + (format #t "~1Tfalloff-to: (meters ~m)~%" (-> this falloff-to)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tperiod: ~D~%" (-> this period)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Toffset: ~D~%" (-> this offset)) + (format #t "~1Thour-mask: ~D~%" (-> this hour-mask)) + (format #t "~1Tbinding: ~D~%" (-> this binding)) + (label cfg-4) + this + ) + +;; definition of type sparticle-launch-state +(deftype sparticle-launch-state (structure) + "The state associated with a launcher of a given sparticle." + ((group-item sparticle-group-item) + (flags sp-launch-state-flags) + (randomize uint16) + (center vector) + (sprite3d sprite-vec-data-3d) + (sprite sparticle-cpuinfo) + (offset uint32) + (accum float) + (spawn-time uint32) + (control sparticle-launch-control) + (swarm basic :overlay-at offset) + (seed uint32 :overlay-at accum) + (time uint32 :overlay-at spawn-time) + (spec basic :overlay-at sprite) + (id uint32 :overlay-at sprite3d) + ) + ) + +;; definition for method 3 of type sparticle-launch-state +(defmethod inspect ((this sparticle-launch-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sparticle-launch-state) + (format #t "~1Tgroup-item: #~%" (-> this group-item)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Trandomize: ~D~%" (-> this randomize)) + (format #t "~1Tcenter: #~%" (-> this center)) + (format #t "~1Tsprite3d: #~%" (-> this sprite3d)) + (format #t "~1Tsprite: ~A~%" (-> this sprite)) + (format #t "~1Toffset: ~D~%" (-> this offset)) + (format #t "~1Taccum: ~f~%" (-> this accum)) + (format #t "~1Tspawn-time: ~D~%" (-> this spawn-time)) + (format #t "~1Tcontrol: ~A~%" (-> this control)) + (format #t "~1Tswarm: ~A~%" (-> this offset)) + (format #t "~1Tseed: ~D~%" (-> this accum)) + (format #t "~1Ttime: ~D~%" (-> this spawn-time)) + (label cfg-4) + this + ) + +;; definition of type sparticle-launch-group +(deftype sparticle-launch-group (basic) + "Definition of multiple a particle-group, which is a collection of particle effects." + ((length int16) + (duration uint16) + (linger-duration uint16) + (flags sp-group-flag) + (name string) + (launcher (inline-array sparticle-group-item)) + (rotate-x degrees) + (rotate-y degrees) + (rotate-z degrees) + (scale-x float) + (scale-y float) + (scale-z float) + (bounds sphere :inline) + ) + (:methods + (create-launch-control (_type_ process) sparticle-launch-control) + ) + ) + +;; definition for method 3 of type sparticle-launch-group +(defmethod inspect ((this sparticle-launch-group)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tduration: ~D~%" (-> this duration)) + (format #t "~1Tlinger-duration: ~D~%" (-> this linger-duration)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tlauncher: #x~X~%" (-> this launcher)) + (format #t "~1Trotate-x: (deg ~r)~%" (-> this rotate-x)) + (format #t "~1Trotate-y: (deg ~r)~%" (-> this rotate-y)) + (format #t "~1Trotate-z: (deg ~r)~%" (-> this rotate-z)) + (format #t "~1Tscale-x: ~f~%" (-> this scale-x)) + (format #t "~1Tscale-y: ~f~%" (-> this scale-y)) + (format #t "~1Tscale-z: ~f~%" (-> this scale-z)) + (format #t "~1Tbounds: #~%" (-> this bounds)) + (label cfg-4) + this + ) + +;; definition for symbol *launch-matrix*, type matrix +(define *launch-matrix* (matrix-identity! (new 'global 'matrix))) + +;; definition of type sparticle-launch-control +(deftype sparticle-launch-control (inline-array-class) + "Top-level type containing all the state needed to launch a particle group. +These are typically owned by a process, and allocated on the process heap. +These refer to static particle definitions, and then spawn particles that are tracked by the +particle system itself. This type just holds the launching-related state." + ((group sparticle-launch-group) + (proc process-drawable) + (local-clock int32) + (local-space-binding particle-local-space-info :offset 28) + (matrix int8) + (pointer-control uint32) + (last-spawn-frame int32) + (last-spawn-time int32) + (origin matrix :inline) + (center vector :inline :overlay-at (-> origin data 12)) + (data sparticle-launch-state :inline :dynamic) + ) + (:methods + (sparticle-launch-control-method-14 () none) + (sparticle-launch-control-method-15 () none) + (sparticle-launch-control-method-16 () none) + (sparticle-launch-control-method-17 () none) + (sparticle-launch-control-method-18 () none) + (sparticle-launch-control-method-19 () none) + (sparticle-launch-control-method-20 () none) + (sparticle-launch-control-method-21 () none) + ) + ) + +;; definition for method 3 of type sparticle-launch-control +(defmethod inspect ((this sparticle-launch-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tgroup: ~A~%" (-> this group)) + (format #t "~1Tproc: ~A~%" (-> this proc)) + (format #t "~1Tlocal-clock: ~D~%" (-> this local-clock)) + (format #t "~1Tlocal-space-binding: #~%" (-> this local-space-binding)) + (format #t "~1Tmatrix: ~D~%" (-> this matrix)) + (format #t "~1Tpointer-control: #x~X~%" (-> this pointer-control)) + (format #t "~1Tlast-spawn-frame: ~D~%" (-> this last-spawn-frame)) + (format #t "~1Tlast-spawn-time: ~D~%" (-> this last-spawn-time)) + (format #t "~1Torigin: #~%" (-> this origin)) + (format #t "~1Tcenter: ~`vector`P~%" (-> this origin trans)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> sparticle-launch-control heap-base) (the-as uint 48)) + +;; definition of type sparticle-subsampler +(deftype sparticle-subsampler (basic) + ((min-emit float) + (accum float) + (spt-num float) + (sp-system sparticle-system) + (part-id uint32) + (spawn-mat matrix :inline) + (inited? symbol) + (per-meter-method? symbol) + ) + (:methods + (new (symbol type sparticle-system uint float symbol float) _type_) + (sparticle-subsampler-method-9 () none) + (sparticle-subsampler-method-10 () none) + ) + ) + +;; definition for method 3 of type sparticle-subsampler +(defmethod inspect ((this sparticle-subsampler)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tmin-emit: ~f~%" (-> this min-emit)) + (format #t "~1Taccum: ~f~%" (-> this accum)) + (format #t "~1Tspt-num: ~f~%" (-> this spt-num)) + (format #t "~1Tsp-system: ~A~%" (-> this sp-system)) + (format #t "~1Tpart-id: ~D~%" (-> this part-id)) + (format #t "~1Tspawn-mat: #~%" (-> this spawn-mat)) + (format #t "~1Tinited?: ~A~%" (-> this inited?)) + (format #t "~1Tper-meter-method?: ~A~%" (-> this per-meter-method?)) + (label cfg-4) + this + ) + +;; definition for method 0 of type sparticle-subsampler +(defmethod new sparticle-subsampler ((allocation symbol) + (type-to-make type) + (arg0 sparticle-system) + (arg1 uint) + (arg2 float) + (arg3 symbol) + (arg4 float) + ) + (let ((s1-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (if (zero? s1-0) + (go process-drawable-art-error "sparticle-subsampler") + ) + (set! (-> s1-0 per-meter-method?) arg3) + (set! (-> s1-0 part-id) arg1) + (set! (-> s1-0 inited?) #f) + (set! (-> s1-0 sp-system) arg0) + (set! (-> s1-0 spt-num) arg2) + (set! (-> s1-0 min-emit) arg4) + (matrix-identity! (-> s1-0 spawn-mat)) + s1-0 + ) + ) + +;; definition for function compute-rot-in-screenspace +(defun compute-rot-in-screenspace ((arg0 vector)) + 0.0 + (let ((a0-1 (-> (math-camera-matrix) fvec))) + 0.0 + (let ((v1-0 (new 'stack-no-clear 'vector))) + (let ((f0-3 (vector-dot a0-1 arg0))) + (vector-float*! v1-0 a0-1 f0-3) + ) + (vector-! arg0 arg0 v1-0) + ) + ) + (let ((a2-1 (matrix-transpose! (new 'stack-no-clear 'matrix) (math-camera-matrix)))) + (vector-matrix*! arg0 arg0 a2-1) + ) + (the float (sar (shl (the int (atan (-> arg0 y) (* -1.0 (-> arg0 x)))) 48) 48)) + ) + +;; definition of type particle-birth-work +(deftype particle-birth-work (structure) + ((quat quaternion :inline) + (vel-range vector 2 :inline) + (vel vector :inline :overlay-at (-> vel-range 0)) + (pos-range vector 2 :inline) + (pos vector :inline :overlay-at (-> pos-range 0)) + (d-pos vector :inline :overlay-at (-> pos-range 1)) + (mat matrix :inline) + (tt float) + (t-step float) + ) + ) + +;; definition for method 3 of type particle-birth-work +(defmethod inspect ((this particle-birth-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'particle-birth-work) + (format #t "~1Tquat: #~%" (-> this quat)) + (format #t "~1Tvel-range[2] @ #x~X~%" (-> this vel-range)) + (format #t "~1Tvel: #~%" (-> this vel-range)) + (format #t "~1Tpos-range[2] @ #x~X~%" (-> this pos-range)) + (format #t "~1Tpos: #~%" (-> this pos-range)) + (format #t "~1Td-pos: #~%" (-> this d-pos)) + (format #t "~1Tmat: #~%" (-> this mat)) + (format #t "~1Ttt: ~f~%" (-> this tt)) + (format #t "~1Tt-step: ~f~%" (-> this t-step)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/sprite/simple-sprite-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/sprite/simple-sprite-h_REF.gc new file mode 100644 index 0000000000..cd63c9c164 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/sprite/simple-sprite-h_REF.gc @@ -0,0 +1,90 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type sprite-glow-data +(deftype sprite-glow-data (structure) + ((position vector :inline) + (size-x float :overlay-at (-> position data 3)) + (size-probe float :offset 16) + (z-offset float) + (rot-angle float) + (size-y float) + (color rgbaf :inline) + (fade-a float) + (fade-b float) + (tex-id texture-id) + (dummy uint32) + (quads vector 4 :inline :overlay-at position) + ) + (:methods + (set-trans (_type_ vector) none) + ) + ) + +;; definition for method 3 of type sprite-glow-data +(defmethod inspect ((this sprite-glow-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sprite-glow-data) + (format #t "~1Tposition: #~%" (-> this position)) + (format #t "~1Tsize-x: ~f~%" (-> this position w)) + (format #t "~1Tsize-probe: ~f~%" (-> this size-probe)) + (format #t "~1Tz-offset: ~f~%" (-> this z-offset)) + (format #t "~1Trot-angle: ~f~%" (-> this rot-angle)) + (format #t "~1Tsize-y: ~f~%" (-> this size-y)) + (format #t "~1Tcolor: #~%" (-> this color)) + (format #t "~1Tfade-a: ~f~%" (-> this fade-a)) + (format #t "~1Tfade-b: ~f~%" (-> this fade-b)) + (format #t "~1Ttex-id: ~D~%" (-> this tex-id)) + (format #t "~1Tdummy: ~D~%" (-> this dummy)) + (label cfg-4) + this + ) + +;; definition for method 9 of type sprite-glow-data +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod set-trans ((this sprite-glow-data) (arg0 vector)) + (let ((f0-0 (-> this position w))) + (set! (-> this position quad) (-> arg0 quad)) + (set! (-> this position w) f0-0) + ) + 0 + (none) + ) + +;; definition of type simple-sprite-system +(deftype simple-sprite-system (structure) + ((count int16) + (max-count int16) + (data (inline-array sprite-glow-data)) + ) + (:methods + (add! (_type_ sprite-glow-data) none) + (draw-all-sprites! (_type_ dma-buffer) none) + (clear! (_type_) none) + ) + ) + +;; definition for method 3 of type simple-sprite-system +(defmethod inspect ((this simple-sprite-system)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'simple-sprite-system) + (format #t "~1Tcount: ~D~%" (-> this count)) + (format #t "~1Tmax-count: ~D~%" (-> this max-count)) + (format #t "~1Tdata: #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/sprite/sprite-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/sprite/sprite-h_REF.gc new file mode 100644 index 0000000000..1aeedaa000 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/sprite/sprite-h_REF.gc @@ -0,0 +1,183 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type sprite-vec-data-2d +(deftype sprite-vec-data-2d (structure) + "Per-particle data needed for rendering. This is sent to VU1." + ((x-y-z-sx vector :inline) + (flag-rot-sy vector :inline) + (r-g-b-a vector :inline) + (x float :overlay-at (-> x-y-z-sx data 0)) + (y float :overlay-at (-> x-y-z-sx data 1)) + (z float :overlay-at (-> x-y-z-sx data 2)) + (sx float :overlay-at (-> x-y-z-sx data 3)) + (sy float :overlay-at (-> flag-rot-sy data 3)) + (rot float :overlay-at (-> flag-rot-sy data 2)) + (flag int32 :overlay-at (-> flag-rot-sy data 0)) + (matrix int32 :overlay-at (-> flag-rot-sy data 1)) + (warp-turns int32 :overlay-at (-> flag-rot-sy data 0)) + (r float :overlay-at (-> r-g-b-a data 0)) + (g float :overlay-at (-> r-g-b-a data 1)) + (b float :overlay-at (-> r-g-b-a data 2)) + (a float :overlay-at (-> r-g-b-a data 3)) + (trans vector3s :inline :overlay-at (-> x-y-z-sx data 0)) + (color rgbaf :inline :overlay-at (-> r-g-b-a data 0)) + (data uint128 1 :overlay-at (-> x-y-z-sx data 0)) + (data64 uint64 6 :overlay-at (-> x-y-z-sx data 0)) + ) + ) + +;; definition for method 3 of type sprite-vec-data-2d +(defmethod inspect ((this sprite-vec-data-2d)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sprite-vec-data-2d) + (format #t "~1Tx-y-z-sx: #~%" (-> this x-y-z-sx)) + (format #t "~1Tflag-rot-sy: #~%" (&-> this flag)) + (format #t "~1Tr-g-b-a: #~%" (-> this r-g-b-a)) + (format #t "~1Tx: ~f~%" (-> this x-y-z-sx x)) + (format #t "~1Ty: ~f~%" (-> this x-y-z-sx y)) + (format #t "~1Tz: ~f~%" (-> this x-y-z-sx z)) + (format #t "~1Tsx: ~f~%" (-> this x-y-z-sx w)) + (format #t "~1Tsy: ~f~%" (-> this flag-rot-sy w)) + (format #t "~1Trot: ~f~%" (-> this flag-rot-sy z)) + (format #t "~1Tflag: ~D~%" (-> this flag)) + (format #t "~1Tmatrix: ~D~%" (-> this flag-rot-sy y)) + (format #t "~1Twarp-turns: ~D~%" (-> this flag)) + (format #t "~1Tr: ~f~%" (-> this r-g-b-a x)) + (format #t "~1Tg: ~f~%" (-> this r-g-b-a y)) + (format #t "~1Tb: ~f~%" (-> this r-g-b-a z)) + (format #t "~1Ta: ~f~%" (-> this r-g-b-a w)) + (format #t "~1Ttrans: #~%" (-> this x-y-z-sx)) + (format #t "~1Tcolor: #~%" (-> this r-g-b-a)) + (format #t "~1Tdata[1] @ #x~X~%" (-> this x-y-z-sx)) + (format #t "~1Tdata64[6] @ #x~X~%" (-> this x-y-z-sx)) + (label cfg-4) + this + ) + +;; definition of type sprite-array-2d +(deftype sprite-array-2d (basic) + "Array of sprite data for all 2D sprites. There are two groups: normal and HUD." + ((num-sprites int32 2) + (num-valid int32 2) + (vec-data pointer) + (adgif-data (inline-array adgif-shader)) + (pad uint128 4) + (data uint128 1) + ) + (:methods + (new (symbol type int int) _type_) + ) + ) + +;; definition for method 3 of type sprite-array-2d +(defmethod inspect ((this sprite-array-2d)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tnum-sprites[2] @ #x~X~%" (-> this num-sprites)) + (format #t "~1Tnum-valid[2] @ #x~X~%" (-> this num-valid)) + (format #t "~1Tvec-data: #x~X~%" (-> this vec-data)) + (format #t "~1Tadgif-data: #x~X~%" (-> this adgif-data)) + (format #t "~1Tpad[4] @ #x~X~%" (-> this pad)) + (format #t "~1Tdata[1] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type sprite-vec-data-3d +(deftype sprite-vec-data-3d (structure) + "Per-particle data needed for rendering. This is sent to VU1." + ((x-y-z-sx vector :inline) + (qx-qy-qz-sy vector :inline) + (r-g-b-a vector :inline) + (x float :overlay-at (-> x-y-z-sx data 0)) + (y float :overlay-at (-> x-y-z-sx data 1)) + (z float :overlay-at (-> x-y-z-sx data 2)) + (sx float :overlay-at (-> x-y-z-sx data 3)) + (sy float :overlay-at (-> qx-qy-qz-sy data 3)) + (qx float :overlay-at (-> qx-qy-qz-sy data 0)) + (qy float :overlay-at (-> qx-qy-qz-sy data 1)) + (qz float :overlay-at (-> qx-qy-qz-sy data 2)) + (r float :overlay-at (-> r-g-b-a data 0)) + (g float :overlay-at (-> r-g-b-a data 1)) + (b float :overlay-at (-> r-g-b-a data 2)) + (a float :overlay-at (-> r-g-b-a data 3)) + (trans vector3s :inline :overlay-at (-> x-y-z-sx data 0)) + (rot vector3s :inline :overlay-at (-> qx-qy-qz-sy data 0)) + (color rgbaf :inline :overlay-at (-> r-g-b-a data 0)) + (data uint128 1 :overlay-at (-> x-y-z-sx data 0)) + ) + ) + +;; definition for method 3 of type sprite-vec-data-3d +(defmethod inspect ((this sprite-vec-data-3d)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sprite-vec-data-3d) + (format #t "~1Tx-y-z-sx: #~%" (-> this x-y-z-sx)) + (format #t "~1Tqx-qy-qz-sy: #~%" (-> this qx-qy-qz-sy)) + (format #t "~1Tr-g-b-a: #~%" (-> this r-g-b-a)) + (format #t "~1Tx: ~f~%" (-> this x-y-z-sx x)) + (format #t "~1Ty: ~f~%" (-> this x-y-z-sx y)) + (format #t "~1Tz: ~f~%" (-> this x-y-z-sx z)) + (format #t "~1Tsx: ~f~%" (-> this x-y-z-sx w)) + (format #t "~1Tsy: ~f~%" (-> this qx-qy-qz-sy w)) + (format #t "~1Tqx: ~f~%" (-> this qx-qy-qz-sy x)) + (format #t "~1Tqy: ~f~%" (-> this qx-qy-qz-sy y)) + (format #t "~1Tqz: ~f~%" (-> this qx-qy-qz-sy z)) + (format #t "~1Tr: ~f~%" (-> this r-g-b-a x)) + (format #t "~1Tg: ~f~%" (-> this r-g-b-a y)) + (format #t "~1Tb: ~f~%" (-> this r-g-b-a z)) + (format #t "~1Ta: ~f~%" (-> this r-g-b-a w)) + (format #t "~1Ttrans: #~%" (-> this x-y-z-sx)) + (format #t "~1Trot: #~%" (-> this qx-qy-qz-sy)) + (format #t "~1Tcolor: #~%" (-> this r-g-b-a)) + (format #t "~1Tdata[1] @ #x~X~%" (-> this x-y-z-sx)) + (label cfg-4) + this + ) + +;; definition of type sprite-array-3d +(deftype sprite-array-3d (basic) + "Array of sprite data for all 3D sprites. There are two groups, but only the first is used." + ((num-sprites int32 2) + (num-valid int32 2) + (vec-data pointer) + (adgif-data (inline-array adgif-shader)) + (data uint128 1) + ) + (:methods + (new (symbol type int int) _type_) + ) + ) + +;; definition for method 3 of type sprite-array-3d +(defmethod inspect ((this sprite-array-3d)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tnum-sprites[2] @ #x~X~%" (-> this num-sprites)) + (format #t "~1Tnum-valid[2] @ #x~X~%" (-> this num-valid)) + (format #t "~1Tvec-data: #x~X~%" (-> this vec-data)) + (format #t "~1Tadgif-data: #x~X~%" (-> this adgif-data)) + (format #t "~1Tdata[1] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/texture/texture-anim-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/texture/texture-anim-h_REF.gc new file mode 100644 index 0000000000..6052bb92c4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/texture/texture-anim-h_REF.gc @@ -0,0 +1,692 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type texture-anim-layer +(deftype texture-anim-layer (structure) + ((interpolated-color vector :inline) + (interpolated-scale-offset vector :inline) + (interpolated-st-scale-offset vector :inline) + (interpolated-qs vector :inline) + (interpolated-rot vector :inline) + (extra vector :inline :offset 240) + (func (function dma-buffer uint int int texture-anim-layer float int)) + (func-id symbol :overlay-at func) + (init-func (function texture-anim-layer int)) + (init-func-id symbol :overlay-at init-func) + (tex texture) + (start-time float) + (end-time float) + (tex-name string) + (test gs-test) + (alpha gs-alpha) + (clamp gs-clamp) + (start-vectors vector 5 :inline :offset 80) + (start-color vector :inline :overlay-at (-> start-vectors 0)) + (start-scale vector2 :inline :offset 96) + (start-offset vector2 :inline :offset 104) + (start-st-scale vector2 :inline :offset 112) + (start-st-offset vector2 :inline :offset 120) + (start-qs vector :inline :overlay-at (-> start-vectors 3)) + (start-rot degrees :offset 144) + (start-st-rot degrees :offset 148) + (end-vectors vector 5 :inline :offset 160) + (end-color vector :inline :overlay-at (-> end-vectors 0)) + (end-scale vector2 :inline :offset 176) + (end-offset vector2 :inline :offset 184) + (end-st-scale vector2 :inline :offset 192) + (end-st-offset vector2 :inline :offset 200) + (end-qs vector :inline :overlay-at (-> end-vectors 3)) + (end-rot degrees :offset 224) + (end-st-rot degrees :offset 228) + ) + (:methods + (initialize-texture! (_type_) _type_) + (clear-texture! (_type_) _type_) + ) + ) + +;; definition for method 3 of type texture-anim-layer +(defmethod inspect ((this texture-anim-layer)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-anim-layer) + (format #t "~1Textra: #~%" (-> this extra)) + (format #t "~1Tfunc: ~A~%" (-> this func)) + (format #t "~1Tfunc-id: ~A~%" (-> this func)) + (format #t "~1Tinit-func: ~A~%" (-> this init-func)) + (format #t "~1Tinit-func-id: ~A~%" (-> this init-func)) + (format #t "~1Ttex: ~A~%" (-> this tex)) + (format #t "~1Tstart-time: ~f~%" (-> this start-time)) + (format #t "~1Tend-time: ~f~%" (-> this end-time)) + (format #t "~1Ttex-name: ~A~%" (-> this tex-name)) + (format #t "~1Ttest: #x~X~%" (-> this test)) + (format #t "~1Talpha: #x~X~%" (-> this alpha)) + (format #t "~1Tclamp: #x~X~%" (-> this clamp)) + (format #t "~1Tstart-color: ~`vector`P~%" (-> this start-color)) + (format #t "~1Tstart-scale: ~`vector2`P~%" (-> this start-scale)) + (format #t "~1Tstart-offset: ~`vector2`P~%" (-> this start-offset)) + (format #t "~1Tstart-st-scale: ~`vector2`P~%" (-> this start-st-scale)) + (format #t "~1Tstart-st-offset: ~`vector2`P~%" (-> this start-st-offset)) + (format #t "~1Tstart-qs: ~`vector`P~%" (-> this start-qs)) + (format #t "~1Tstart-rot: (deg ~r)~%" (-> this start-rot)) + (format #t "~1Tstart-st-rot: (deg ~r)~%" (-> this start-st-rot)) + (format #t "~1Tend-color: ~`vector`P~%" (-> this end-color)) + (format #t "~1Tend-scale: ~`vector2`P~%" (-> this end-scale)) + (format #t "~1Tend-offset: ~`vector2`P~%" (-> this end-offset)) + (format #t "~1Tend-st-scale: ~`vector2`P~%" (-> this end-st-scale)) + (format #t "~1Tend-st-offset: ~`vector2`P~%" (-> this end-st-offset)) + (format #t "~1Tend-qs: ~`vector`P~%" (-> this end-qs)) + (format #t "~1Tend-rot: (deg ~r)~%" (-> this end-rot)) + (format #t "~1Tend-st-rot: (deg ~r)~%" (-> this end-st-rot)) + (label cfg-4) + this + ) + +;; definition of type texture-anim +(deftype texture-anim (structure) + ((num-layers uint32) + (func (function dma-buffer texture-anim int)) + (func-id symbol :overlay-at func) + (init-func (function texture-anim int)) + (init-func-id symbol :overlay-at init-func) + (mip-func basic) + (mip-func-id basic :overlay-at mip-func) + (time-func basic) + (time-func-id basic :overlay-at time-func) + (tex texture) + (tex-name string) + (extra vector :inline) + (color rgba) + (frame-time float) + (frame-delta float) + (frame-mod float) + (test uint64) + (alpha uint64) + (clamp uint64) + (data texture-anim-layer :dynamic) + ) + (:methods + (texture-anim-method-9 () none) + (texture-anim-method-10 () none) + ) + ) + +;; definition for method 3 of type texture-anim +(defmethod inspect ((this texture-anim)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-anim) + (format #t "~1Tnum-layers: ~D~%" (-> this num-layers)) + (format #t "~1Tfunc: ~A~%" (-> this func)) + (format #t "~1Tfunc-id: ~A~%" (-> this func)) + (format #t "~1Tinit-func: ~A~%" (-> this init-func)) + (format #t "~1Tinit-func-id: ~A~%" (-> this init-func)) + (format #t "~1Tmip-func: ~A~%" (-> this mip-func)) + (format #t "~1Tmip-func-id: ~A~%" (-> this mip-func)) + (format #t "~1Ttime-func: ~A~%" (-> this time-func)) + (format #t "~1Ttime-func-id: ~A~%" (-> this time-func)) + (format #t "~1Ttex: ~A~%" (-> this tex)) + (format #t "~1Ttex-name: ~A~%" (-> this tex-name)) + (format #t "~1Textra: #~%" (-> this extra)) + (format #t "~1Tcolor: #x~X~%" (-> this color)) + (format #t "~1Tframe-time: ~f~%" (-> this frame-time)) + (format #t "~1Tframe-delta: ~f~%" (-> this frame-delta)) + (format #t "~1Tframe-mod: ~f~%" (-> this frame-mod)) + (format #t "~1Ttest: #x~X~%" (-> this test)) + (format #t "~1Talpha: #x~X~%" (-> this alpha)) + (format #t "~1Tclamp: #x~X~%" (-> this clamp)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type texture-anim-array +(deftype texture-anim-array (array) + ((array-data texture-anim :dynamic) + ) + (:methods + (init! (_type_) _type_) + (clear! (_type_) _type_) + ) + ) + +;; definition for method 3 of type texture-anim-array +(defmethod inspect ((this texture-anim-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttype: ~A~%" (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tcontent-type: ~A~%" (-> this content-type)) + (label cfg-4) + this + ) + +;; definition of type texture-anim-work +(deftype texture-anim-work (structure) + ((erase-tmpl dma-gif-packet :inline) + (draw-tmpl dma-gif-packet :inline) + (draw2-tmpl dma-gif-packet :inline) + (sprite-tmpl dma-gif-packet :inline) + (fill-tmpl dma-gif-packet :inline) + (adgif-tmpl dma-gif-packet :inline) + (corner0 vector :inline) + (corner1 vector :inline) + (corner2 vector :inline) + (corner3 vector :inline) + (const vector :inline) + (color vector4w :inline) + (random vector4w 8 :inline) + (random-index uint8) + (color80808040 vector4w :inline) + (color80808060 vector4w :inline) + (color80808000 vector4w :inline) + (st0000 vector :inline) + (st0505 vector :inline) + (st1010 vector :inline) + (uv00 vector4w :inline) + (uv44 vector4w :inline) + (uv88 vector4w :inline) + (uv1010 vector4w :inline) + (uv2020 vector4w :inline) + (uv4040 vector4w :inline) + (uv8080 vector4w :inline) + (xy0000 vector4w :inline) + (xy4040 vector4w :inline) + (xy0040 vector4w :inline) + (xy2060 vector4w :inline) + (xy2040 vector4w :inline) + (xy3050 vector4w :inline) + (xy3040 vector4w :inline) + (xy3848 vector4w :inline) + (xy3840 vector4w :inline) + (xy4048 vector4w :inline) + (xy3048 vector4w :inline) + (xy3850 vector4w :inline) + (xy4060 vector4w :inline) + ) + ) + +;; definition for method 3 of type texture-anim-work +(defmethod inspect ((this texture-anim-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-anim-work) + (format #t "~1Terase-tmpl: #~%" (-> this erase-tmpl)) + (format #t "~1Tdraw-tmpl: #~%" (-> this draw-tmpl)) + (format #t "~1Tdraw2-tmpl: #~%" (-> this draw2-tmpl)) + (format #t "~1Tsprite-tmpl: #~%" (-> this sprite-tmpl)) + (format #t "~1Tfill-tmpl: #~%" (-> this fill-tmpl)) + (format #t "~1Tadgif-tmpl: #~%" (-> this adgif-tmpl)) + (format #t "~1Tcorner0: #~%" (-> this corner0)) + (format #t "~1Tcorner1: #~%" (-> this corner1)) + (format #t "~1Tcorner2: #~%" (-> this corner2)) + (format #t "~1Tcorner3: #~%" (-> this corner3)) + (format #t "~1Tconst: #~%" (-> this const)) + (format #t "~1Tcolor: #~%" (-> this color)) + (format #t "~1Trandom[8] @ #x~X~%" (-> this random)) + (format #t "~1Trandom-index: ~D~%" (-> this random-index)) + (format #t "~1Tcolor80808040: #~%" (-> this color80808040)) + (format #t "~1Tcolor80808060: #~%" (-> this color80808060)) + (format #t "~1Tcolor80808000: #~%" (-> this color80808000)) + (format #t "~1Tst0000: #~%" (-> this st0000)) + (format #t "~1Tst0505: #~%" (-> this st0505)) + (format #t "~1Tst1010: #~%" (-> this st1010)) + (format #t "~1Tuv00: #~%" (-> this uv00)) + (format #t "~1Tuv44: #~%" (-> this uv44)) + (format #t "~1Tuv88: #~%" (-> this uv88)) + (format #t "~1Tuv1010: #~%" (-> this uv1010)) + (format #t "~1Tuv2020: #~%" (-> this uv2020)) + (format #t "~1Tuv4040: #~%" (-> this uv4040)) + (format #t "~1Tuv8080: #~%" (-> this uv8080)) + (format #t "~1Txy0000: #~%" (-> this xy0000)) + (format #t "~1Txy4040: #~%" (-> this xy4040)) + (format #t "~1Txy0040: #~%" (-> this xy0040)) + (format #t "~1Txy2060: #~%" (-> this xy2060)) + (format #t "~1Txy2040: #~%" (-> this xy2040)) + (format #t "~1Txy3050: #~%" (-> this xy3050)) + (format #t "~1Txy3040: #~%" (-> this xy3040)) + (format #t "~1Txy3848: #~%" (-> this xy3848)) + (format #t "~1Txy3840: #~%" (-> this xy3840)) + (format #t "~1Txy4048: #~%" (-> this xy4048)) + (format #t "~1Txy3048: #~%" (-> this xy3048)) + (format #t "~1Txy3850: #~%" (-> this xy3850)) + (format #t "~1Txy4060: #~%" (-> this xy4060)) + (label cfg-4) + this + ) + +;; definition of type clut16x16 +(deftype clut16x16 (structure) + ((clut rgba 256) + ) + ) + +;; definition for method 3 of type clut16x16 +(defmethod inspect ((this clut16x16)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'clut16x16) + (format #t "~1Tclut[256] @ #x~X~%" (-> this clut)) + (label cfg-4) + this + ) + +;; definition of type noise8x8 +(deftype noise8x8 (structure) + ((image uint8 64) + ) + ) + +;; definition for method 3 of type noise8x8 +(defmethod inspect ((this noise8x8)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'noise8x8) + (format #t "~1Timage[64] @ #x~X~%" (-> this image)) + (label cfg-4) + this + ) + +;; definition of type noise16x16 +(deftype noise16x16 (structure) + ((image uint8 256) + ) + ) + +;; definition for method 3 of type noise16x16 +(defmethod inspect ((this noise16x16)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'noise16x16) + (format #t "~1Timage[256] @ #x~X~%" (-> this image)) + (label cfg-4) + this + ) + +;; definition of type noise32x32 +(deftype noise32x32 (structure) + ((image uint8 1024) + ) + ) + +;; definition for method 3 of type noise32x32 +(defmethod inspect ((this noise32x32)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'noise32x32) + (format #t "~1Timage[1024] @ #x~X~%" (-> this image)) + (label cfg-4) + this + ) + +;; definition of type noise64x64 +(deftype noise64x64 (structure) + ((image uint8 4096) + ) + ) + +;; definition for method 3 of type noise64x64 +(defmethod inspect ((this noise64x64)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'noise64x64) + (format #t "~1Timage[4096] @ #x~X~%" (-> this image)) + (label cfg-4) + this + ) + +;; definition of type noise128x128 +(deftype noise128x128 (structure) + ((image uint8 16384) + ) + ) + +;; definition for method 3 of type noise128x128 +(defmethod inspect ((this noise128x128)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'noise128x128) + (format #t "~1Timage[16384] @ #x~X~%" (-> this image)) + (label cfg-4) + this + ) + +;; definition of type fog8x256 +(deftype fog8x256 (structure) + ((image uint8 256) + ) + ) + +;; definition for method 3 of type fog8x256 +(defmethod inspect ((this fog8x256)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'fog8x256) + (format #t "~1Timage[256] @ #x~X~%" (-> this image)) + (label cfg-4) + this + ) + +;; definition of type fog-texture-work +(deftype fog-texture-work (structure) + ((fog-height float) + (fog-near float) + (fog-far float) + (fog-delta float) + (alpha-near float) + (alpha-far float) + (alpha-delta float) + (color rgba) + ) + ) + +;; definition for method 3 of type fog-texture-work +(defmethod inspect ((this fog-texture-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'fog-texture-work) + (format #t "~1Tfog-height: ~f~%" (-> this fog-height)) + (format #t "~1Tfog-near: ~f~%" (-> this fog-near)) + (format #t "~1Tfog-far: ~f~%" (-> this fog-far)) + (format #t "~1Tfog-delta: ~f~%" (-> this fog-delta)) + (format #t "~1Talpha-near: ~f~%" (-> this alpha-near)) + (format #t "~1Talpha-far: ~f~%" (-> this alpha-far)) + (format #t "~1Talpha-delta: ~f~%" (-> this alpha-delta)) + (format #t "~1Tcolor: ~D~%" (-> this color)) + (label cfg-4) + this + ) + +;; definition for symbol *clut-translate*, type (pointer uint8) +(define *clut-translate* (new 'static 'array uint8 256 + #x0 + #x1 + #x2 + #x3 + #x4 + #x5 + #x6 + #x7 + #x10 + #x11 + #x12 + #x13 + #x14 + #x15 + #x16 + #x17 + #x8 + #x9 + #xa + #xb + #xc + #xd + #xe + #xf + #x18 + #x19 + #x1a + #x1b + #x1c + #x1d + #x1e + #x1f + #x20 + #x21 + #x22 + #x23 + #x24 + #x25 + #x26 + #x27 + #x30 + #x31 + #x32 + #x33 + #x34 + #x35 + #x36 + #x37 + #x28 + #x29 + #x2a + #x2b + #x2c + #x2d + #x2e + #x2f + #x38 + #x39 + #x3a + #x3b + #x3c + #x3d + #x3e + #x3f + #x40 + #x41 + #x42 + #x43 + #x44 + #x45 + #x46 + #x47 + #x50 + #x51 + #x52 + #x53 + #x54 + #x55 + #x56 + #x57 + #x48 + #x49 + #x4a + #x4b + #x4c + #x4d + #x4e + #x4f + #x58 + #x59 + #x5a + #x5b + #x5c + #x5d + #x5e + #x5f + #x60 + #x61 + #x62 + #x63 + #x64 + #x65 + #x66 + #x67 + #x70 + #x71 + #x72 + #x73 + #x74 + #x75 + #x76 + #x77 + #x68 + #x69 + #x6a + #x6b + #x6c + #x6d + #x6e + #x6f + #x78 + #x79 + #x7a + #x7b + #x7c + #x7d + #x7e + #x7f + #x80 + #x81 + #x82 + #x83 + #x84 + #x85 + #x86 + #x87 + #x90 + #x91 + #x92 + #x93 + #x94 + #x95 + #x96 + #x97 + #x88 + #x89 + #x8a + #x8b + #x8c + #x8d + #x8e + #x8f + #x98 + #x99 + #x9a + #x9b + #x9c + #x9d + #x9e + #x9f + #xa0 + #xa1 + #xa2 + #xa3 + #xa4 + #xa5 + #xa6 + #xa7 + #xb0 + #xb1 + #xb2 + #xb3 + #xb4 + #xb5 + #xb6 + #xb7 + #xa8 + #xa9 + #xaa + #xab + #xac + #xad + #xae + #xaf + #xb8 + #xb9 + #xba + #xbb + #xbc + #xbd + #xbe + #xbf + #xc0 + #xc1 + #xc2 + #xc3 + #xc4 + #xc5 + #xc6 + #xc7 + #xd0 + #xd1 + #xd2 + #xd3 + #xd4 + #xd5 + #xd6 + #xd7 + #xc8 + #xc9 + #xca + #xcb + #xcc + #xcd + #xce + #xcf + #xd8 + #xd9 + #xda + #xdb + #xdc + #xdd + #xde + #xdf + #xe0 + #xe1 + #xe2 + #xe3 + #xe4 + #xe5 + #xe6 + #xe7 + #xf0 + #xf1 + #xf2 + #xf3 + #xf4 + #xf5 + #xf6 + #xf7 + #xe8 + #xe9 + #xea + #xeb + #xec + #xed + #xee + #xef + #xf8 + #xf9 + #xfa + #xfb + #xfc + #xfd + #xfe + #xff + ) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/texture/texture-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/texture/texture-h_REF.gc new file mode 100644 index 0000000000..086ea4ab10 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/texture/texture-h_REF.gc @@ -0,0 +1,1659 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type texture-id +(deftype texture-id (uint32) + "Unique identifier for a texture +as the tpage number and index of the texture within the tpage." + ((index uint16 :offset 8 :size 12) + (page uint16 :offset 20 :size 12) + ) + ) + +;; definition for method 3 of type texture-id +(defmethod inspect ((this texture-id)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-id) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tpage: ~D~%" (-> this page)) + (label cfg-4) + this + ) + +;; definition of type texture-pool-segment +(deftype texture-pool-segment (structure) + "A chunk of VRAM." + ((dest uint32) + (size uint32) + ) + :pack-me + :allow-misaligned + ) + +;; definition for method 3 of type texture-pool-segment +(defmethod inspect ((this texture-pool-segment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-pool-segment) + (format #t "~1Tdest: #x~X~%" (-> this dest)) + (format #t "~1Tsize: #x~X~%" (-> this size)) + (label cfg-4) + this + ) + +;; definition of type texture-pool +(deftype texture-pool (basic) + "The manager for the VRAM." + ((top int32) + (cur int32) + (allocate-func (function texture-pool texture-page kheap int texture-page)) + (font-palette int32) + (segment texture-pool-segment 4 :inline) + (segment-near texture-pool-segment :inline :overlay-at (-> segment 0)) + (segment-common texture-pool-segment :inline :overlay-at (-> segment 1)) + (common-page texture-page 32) + (common-page-mask int32) + (update-sprites-flag symbol) + (update-flag symbol) + (texture-enable-user texture-enable-mask) + (texture-enable-user-menu texture-enable-mask) + (ids uint32 128) + ) + (:methods + (new (symbol type) _type_) + (texture-pool-method-9 () none) + (texture-pool-method-10 () none) + (texture-pool-method-11 () none) + (texture-pool-method-12 () none) + (texture-pool-method-13 () none) + (texture-pool-method-14 () none) + (texture-pool-method-15 () none) + (texture-pool-method-16 () none) + (texture-pool-method-17 () none) + (texture-pool-method-18 () none) + (texture-pool-method-19 () none) + (texture-pool-method-20 () none) + (texture-pool-method-21 () none) + (texture-pool-method-22 () none) + (texture-pool-method-23 () none) + (texture-pool-method-24 () none) + (texture-pool-method-25 () none) + (texture-pool-method-26 () none) + (texture-pool-method-27 () none) + ) + ) + +;; definition for method 3 of type texture-pool +(defmethod inspect ((this texture-pool)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttop: #x~X~%" (-> this top)) + (format #t "~1Tcur: #x~X~%" (-> this cur)) + (format #t "~1Tallocate-func: ~A~%" (-> this allocate-func)) + (format #t "~1Tfont-palette: ~D~%" (-> this font-palette)) + (format #t "~1Tsegment[4] @ #x~X~%" (-> this segment)) + (format #t "~1Tsegment-near: #~%" (-> this segment)) + (format #t "~1Tsegment-common: #~%" (-> this segment-common)) + (format #t "~1Tcommon-page[32] @ #x~X~%" (-> this common-page)) + (format #t "~1Tcommon-page-mask: ~D~%" (-> this common-page-mask)) + (format #t "~1Tupdate-sprites-flag: ~A~%" (-> this update-sprites-flag)) + (format #t "~1Tupdate-flag: ~A~%" (-> this update-flag)) + (format #t "~1Ttexture-enable-user: ~D~%" (-> this texture-enable-user)) + (format #t "~1Ttexture-enable-user-menu: ~D~%" (-> this texture-enable-user-menu)) + (format #t "~1Tids[128] @ #x~X~%" (-> this ids)) + (label cfg-4) + this + ) + +;; definition of type texture-mask +(deftype texture-mask (structure) + "Mask where each bit indicates if some part of a tpage is used, by a texture. +Additionally, the w component holds a minimum distance. The texture is only needed +if the distance to the object is smaller than this." + ((mask vector4w :inline) + (dist float :overlay-at (-> mask data 3)) + (long uint64 2 :overlay-at (-> mask data 0)) + (quad uint128 :overlay-at (-> mask data 0)) + ) + ) + +;; definition for method 3 of type texture-mask +;; INFO: Used lq/sq +(defmethod inspect ((this texture-mask)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-mask) + (format #t "~1Tmask: #~%" (-> this mask)) + (format #t "~1Tdist: ~f~%" (-> this dist)) + (format #t "~1Tlong[2] @ #x~X~%" (-> this mask)) + (format #t "~1Tquad: ~D~%" (-> this mask quad)) + (label cfg-4) + this + ) + +;; definition of type texture-masks +(deftype texture-masks (structure) + "Grouping of three masks, corresponding to the 3 segments of the texture. +So mask 0 is needed if segment 0 of the texture is needed, etc..." + ((data texture-mask 3 :inline) + (level basic :overlay-at (-> data 0 mask data 2)) + ) + ) + +;; definition for method 3 of type texture-masks +(defmethod inspect ((this texture-masks)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-masks) + (format #t "~1Tdata[3] @ #x~X~%" (-> this data)) + (format #t "~1Tlevel: ~A~%" (-> this level)) + (label cfg-4) + this + ) + +;; definition of type texture-masks-array +(deftype texture-masks-array (inline-array-class) + "Group of all texture-masks for a given tpage." + ((data texture-masks :inline :dynamic) + ) + ) + +;; definition for method 3 of type texture-masks-array +(defmethod inspect ((this texture-masks-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> texture-masks-array heap-base) (the-as uint 48)) + +;; definition for symbol *texture-masks*, type texture-masks +(define *texture-masks* (the-as texture-masks #f)) + +;; definition for symbol *texture-masks-array*, type texture-masks-array +(define *texture-masks-array* (the-as texture-masks-array #f)) + +;; definition of type texture +(deftype texture (basic) + "Metadata for a texture." + ((w int16) + (h int16) + (num-mips uint8) + (tex1-control uint8) + (psm gs-psm) + (mip-shift uint8) + (clutpsm uint16) + (dest uint16 7) + (clutdest uint16) + (width uint8 7) + (name string) + (size uint32) + (uv-dist float) + (pad uint32 3) + (masks texture-masks :inline) + ) + ) + +;; definition for method 3 of type texture +(defmethod inspect ((this texture)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tw: ~D~%" (-> this w)) + (format #t "~1Th: ~D~%" (-> this h)) + (format #t "~1Tnum-mips: ~D~%" (-> this num-mips)) + (format #t "~1Ttex1-control: ~D~%" (-> this tex1-control)) + (format #t "~1Tpsm: ~D~%" (-> this psm)) + (format #t "~1Tmip-shift: ~D~%" (-> this mip-shift)) + (format #t "~1Tclutpsm: ~D~%" (-> this clutpsm)) + (format #t "~1Tdest[7] @ #x~X~%" (-> this dest)) + (format #t "~1Tclutdest: ~D~%" (-> this clutdest)) + (format #t "~1Twidth[7] @ #x~X~%" (-> this width)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tsize: #x~X~%" (-> this size)) + (format #t "~1Tuv-dist: ~f~%" (-> this uv-dist)) + (format #t "~1Tpad[3] @ #x~X~%" (-> this pad)) + (format #t "~1Tmasks: #~%" (-> this masks)) + (label cfg-4) + this + ) + +;; definition of type texture-page-segment +(deftype texture-page-segment (structure) + "Metadata for a 'segment' of a texture page. +Each texture page has 3 segments - smaller number segments have higher detail mips." + ((block-data pointer) + (size uint32) + (dest uint32) + ) + :pack-me + :allow-misaligned + ) + +;; definition for method 3 of type texture-page-segment +(defmethod inspect ((this texture-page-segment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-page-segment) + (format #t "~1Tblock-data: #x~X~%" (-> this block-data)) + (format #t "~1Tsize: #x~X~%" (-> this size)) + (format #t "~1Tdest: #x~X~%" (-> this dest)) + (label cfg-4) + this + ) + +;; definition for function texture-mip->segment +(defun texture-mip->segment ((arg0 int) (arg1 int)) + (if (>= 2 arg1) + (+ (- -1 arg0) arg1) + (max 0 (- 2 arg0)) + ) + ) + +;; definition of type texture-page +(deftype texture-page (basic) + "A collection of textures. There is a tpage per category per level. +These tpages are loaded from the DVD. +e.g.: prison tfrag is its own tpage. +The tpage has multiple textures, and 3 segments. +Lower number segments are larger and have hi-res versions of textures." + ((info file-info) + (name string) + (id uint32) + (length int32) + (mip0-size uint32) + (size uint32) + (segment texture-page-segment 3 :inline) + (dram-size uint32) + (vram-size uint32) + (pad uint32 14) + (data texture :dynamic) + ) + (:methods + (texture-page-method-9 () none) + (texture-page-method-10 () none) + (texture-page-method-11 () none) + (texture-page-method-12 () none) + (texture-page-method-13 () none) + (texture-page-method-14 () none) + ) + ) + +;; definition for method 3 of type texture-page +(defmethod inspect ((this texture-page)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tinfo: ~A~%" (-> this info)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tmip0-size: ~D~%" (-> this mip0-size)) + (format #t "~1Tsize: #x~X~%" (-> this size)) + (format #t "~1Tsegment[3] @ #x~X~%" (-> this segment)) + (format #t "~1Tdram-size: ~D~%" (-> this dram-size)) + (format #t "~1Tvram-size: ~D~%" (-> this vram-size)) + (format #t "~1Tpad[14] @ #x~X~%" (-> this pad)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type shader-ptr +(deftype shader-ptr (uint32) + "A pointer to an adgif-shader, stored in bits 8-32. This allows them to fit into +an adgif shader easily." + ((first-8 uint8 :offset 0 :size 8) + (shader uint32 :offset 8 :size 24) + ) + ) + +;; definition of type texture-link +(deftype texture-link (structure) + "An overlay structure containing a shader-ptr that points to the next adgif-shader +in a linked list." + ((next shader-ptr 1) + ) + ) + +;; definition for method 3 of type texture-link +(defmethod inspect ((this texture-link)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-link) + (format #t "~1Tnext: #x~X~%" (-> this next 0)) + (label cfg-4) + this + ) + +;; definition of type texture-page-dir-entry +(deftype texture-page-dir-entry (structure) + "An entry for a texture in the texture-page-dir. +The texture-page-dir contains an entry for each tpage. +Each entry contains a reference to the tpage, and a linked list of shaders +using it." + ((length int16) + (status uint16) + (page texture-page) + (link texture-link) + ) + :pack-me + :allow-misaligned + ) + +;; definition for method 3 of type texture-page-dir-entry +(defmethod inspect ((this texture-page-dir-entry)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-page-dir-entry) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tstatus: ~D~%" (-> this status)) + (format #t "~1Tpage: ~A~%" (-> this page)) + (format #t "~1Tlink: #x~X~%" (-> this link)) + (label cfg-4) + this + ) + +;; definition of type texture-page-dir +(deftype texture-page-dir (basic) + "The list of all texture pages. +This is static data loaded from the DVD at boot." + ((length int32) + (entries texture-page-dir-entry 1 :inline) + ) + (:methods + (relocate (_type_ kheap (pointer uint8)) none :replace) + (unlink-shaders-in-heap (_type_ kheap) int) + (texture-page-dir-method-10 (_type_) none) + ) + ) + +;; definition of type texture-relocate-later +(deftype texture-relocate-later (basic) + "Unused in Jak 2, but metadata for postponing tpage copies until a second frame, +to have a smaller impact on frame times when loading." + ((memcpy symbol) + (dest uint32) + (source uint32) + (move uint32) + (entry texture-page-dir-entry) + (page texture-page) + ) + ) + +;; definition for method 3 of type texture-relocate-later +(defmethod inspect ((this texture-relocate-later)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tmemcpy: ~A~%" (-> this memcpy)) + (format #t "~1Tdest: ~D~%" (-> this dest)) + (format #t "~1Tsource: ~D~%" (-> this source)) + (format #t "~1Tmove: ~D~%" (-> this move)) + (format #t "~1Tentry: #~%" (-> this entry)) + (format #t "~1Tpage: ~A~%" (-> this page)) + (label cfg-4) + this + ) + +;; definition for symbol *texture-relocate-later*, type texture-relocate-later +(define *texture-relocate-later* (new 'global 'texture-relocate-later)) + +;; failed to figure out what this is: +(set! (-> *texture-relocate-later* memcpy) #f) + +;; definition for symbol *texture-page-dir*, type texture-page-dir +(define *texture-page-dir* (the-as texture-page-dir #f)) + +;; definition of type adgif-shader +(deftype adgif-shader (structure) + "GS texturing/blending settings, called adgif-shader. +These are used by many different renderers and partially managed by the texture system. +For example, the texture system will automatically update tbp to point to the location +of the texture." + ((quad qword 5 :inline) + (prims gs-reg64 10 :overlay-at quad) + (reg-0 gs-reg :overlay-at (-> quad 0 data 2)) + (reg-1 gs-reg :overlay-at (-> prims 3)) + (reg-2 gs-reg :overlay-at (-> prims 5)) + (reg-3 gs-reg :overlay-at (-> prims 7)) + (reg-4 gs-reg :overlay-at (-> prims 9)) + (tex0 gs-tex0 :overlay-at (-> quad 0 data 0)) + (tex1 gs-tex1 :overlay-at (-> prims 2)) + (miptbp1 gs-miptbp :overlay-at (-> prims 4)) + (clamp gs-clamp :overlay-at (-> prims 6)) + (clamp-reg gs-reg64 :overlay-at reg-3) + (alpha gs-miptbp :overlay-at (-> prims 8)) + (link-test link-test-flags :overlay-at (-> quad 0 data 2)) + (texture-id texture-id :overlay-at reg-1) + (next shader-ptr :overlay-at reg-2) + (alpha-as-miptb2 gs-miptbp :overlay-at alpha) + (reg-4-u32 gs-reg32 :overlay-at reg-4) + ) + ) + +;; definition for method 3 of type adgif-shader +(defmethod inspect ((this adgif-shader)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'adgif-shader) + (format #t "~1Tquad[5] @ #x~X~%" (&-> this tex0)) + (format #t "~1Tprims[10] @ #x~X~%" (&-> this tex0)) + (format #t "~1Treg-0: ~D~%" (-> this reg-0)) + (format #t "~1Treg-1: ~D~%" (-> this reg-1)) + (format #t "~1Treg-2: ~D~%" (-> this reg-2)) + (format #t "~1Treg-3: ~D~%" (-> this reg-3)) + (format #t "~1Treg-4: ~D~%" (-> this reg-4)) + (format #t "~1Ttex0: #x~X~%" (-> this tex0)) + (format #t "~1Ttex1: #x~X~%" (-> this tex1)) + (format #t "~1Tmiptbp1: #x~X~%" (-> this miptbp1)) + (format #t "~1Tclamp: #x~X~%" (-> this clamp)) + (format #t "~1Tclamp-reg: ~D~%" (-> this clamp-reg)) + (format #t "~1Talpha: #x~X~%" (-> this alpha)) + (format #t "~1Tlink-test: ~D~%" (-> this link-test)) + (format #t "~1Ttexture-id: ~D~%" (-> this texture-id)) + (format #t "~1Tnext: #x~X~%" (-> this next)) + (label cfg-4) + this + ) + +;; definition of type adgif-shader-array +(deftype adgif-shader-array (inline-array-class) + ((data adgif-shader :inline :dynamic) + ) + ) + +;; definition for method 3 of type adgif-shader-array +(defmethod inspect ((this adgif-shader-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> adgif-shader-array heap-base) (the-as uint 80)) + +;; definition of type texture-base +(deftype texture-base (structure) + "Metadata about an area of VRAM set aside for fancy dynamic texture effects +(sky, eye, etc)." + ((vram-page uint32) + (vram-block uint32) + (vram-word uint32) + ) + ) + +;; definition for method 3 of type texture-base +(defmethod inspect ((this texture-base)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-base) + (format #t "~1Tvram-page: ~D~%" (-> this vram-page)) + (format #t "~1Tvram-block: ~D~%" (-> this vram-block)) + (format #t "~1Tvram-word: ~D~%" (-> this vram-word)) + (label cfg-4) + this + ) + +;; definition for symbol ct32-24-block-table, type (array int32) +(define ct32-24-block-table (new 'static 'boxed-array :type int32 + 0 + 1 + 4 + 5 + 16 + 17 + 20 + 21 + 2 + 3 + 6 + 7 + 18 + 19 + 22 + 23 + 8 + 9 + 12 + 13 + 24 + 25 + 28 + 29 + 10 + 11 + 14 + 15 + 26 + 27 + 30 + 31 + ) + ) + +;; definition for symbol mz32-24-block-table, type (array int32) +(define mz32-24-block-table (new 'static 'boxed-array :type int32 + 16 + 17 + 20 + 21 + 0 + 1 + 4 + 5 + 18 + 19 + 22 + 23 + 2 + 3 + 6 + 7 + 24 + 25 + 28 + 29 + 8 + 9 + 12 + 13 + 26 + 27 + 30 + 31 + 10 + 11 + 14 + 15 + ) + ) + +;; definition for symbol ct16-block-table, type (array int32) +(define ct16-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + ) + ) + +;; definition for symbol ct16s-block-table, type (array int32) +(define ct16s-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 16 + 18 + 1 + 3 + 17 + 19 + 8 + 10 + 24 + 26 + 9 + 11 + 25 + 27 + 4 + 6 + 20 + 22 + 5 + 7 + 21 + 23 + 12 + 14 + 28 + 30 + 13 + 15 + 29 + 31 + ) + ) + +;; definition for symbol mz16-block-table, type (array int32) +(define mz16-block-table (new 'static 'boxed-array :type int32 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + ) + ) + +;; definition for symbol mz16s-block-table, type (array int32) +(define mz16s-block-table (new 'static 'boxed-array :type int32 + 16 + 18 + 0 + 2 + 17 + 19 + 1 + 3 + 24 + 26 + 8 + 10 + 25 + 27 + 9 + 11 + 20 + 22 + 4 + 6 + 21 + 23 + 5 + 7 + 28 + 30 + 12 + 14 + 29 + 31 + 13 + 15 + ) + ) + +;; definition for symbol mt8-block-table, type (array int32) +(define mt8-block-table (new 'static 'boxed-array :type int32 + 0 + 1 + 4 + 5 + 16 + 17 + 20 + 21 + 2 + 3 + 6 + 7 + 18 + 19 + 22 + 23 + 8 + 9 + 12 + 13 + 24 + 25 + 28 + 29 + 10 + 11 + 14 + 15 + 26 + 27 + 30 + 31 + ) + ) + +;; definition for symbol mt4-block-table, type (array int32) +(define mt4-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + ) + ) + +;; definition of type texture-page-translate-item +(deftype texture-page-translate-item (structure) + ((bucket bucket-id) + (level-index uint32) + (level-texture-page tpage-category-u32) + (texture-user texture-enable-mask-u32) + ) + ) + +;; definition for method 3 of type texture-page-translate-item +(defmethod inspect ((this texture-page-translate-item)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-page-translate-item) + (format #t "~1Tbucket: ~D~%" (-> this bucket)) + (format #t "~1Tlevel-index: ~D~%" (-> this level-index)) + (format #t "~1Tlevel-texture-page: ~D~%" (-> this level-texture-page)) + (format #t "~1Ttexture-user: ~D~%" (-> this texture-user)) + (label cfg-4) + this + ) + +;; definition for symbol *texture-page-translate*, type (array texture-page-translate-item) +(define *texture-page-translate* (new 'static 'boxed-array :type texture-page-translate-item + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-lcom-sky-pre) + :level-index #x12 + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 sky) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l1-tfrag) + :level-index #x1 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l3-tfrag) + :level-index #x2 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id etie-scissor-l5-tfrag) + :level-index #x3 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tie-scissor-l7-tfrag) + :level-index #x4 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tfrag-scissor-l9-tfrag) + :level-index #x5 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id shrub-near-trans-l1-shrub) + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id shrub-vanish-l3-shrub) + :level-index #x1 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id billboard-l5-shrub) + :level-index #x2 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id shrub-near-l7-shrub) + :level-index #x3 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id shrub-l9-shrub) + :level-index #x4 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l0-alpha) + :level-index #x5 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tfrag-scissor-l2-alpha) + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l4-alpha) + :level-index #x1 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l6-alpha) + :level-index #x2 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l8-alpha) + :level-index #x3 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-lcom-tfrag) + :level-index #x4 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l2-pris) + :level-index #x5 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 alpha) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l6-pris) + :level-index #x12 + :texture-user (texture-enable-mask-u32 tfrag) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l8-pris) + :level-index #x12 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 shrub) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x12 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-lcom-pris) + :level-index #x6 + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l1-pris2) + :level-index #x7 + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id emerc-l3-pris2) + :level-index #x8 + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l5-pris2) + :level-index #x9 + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l7-pris2) + :level-index #xa + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 shrub) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 alpha) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l8-pris2) + :level-index #xb + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-lcom-pris2) + :level-index #xc + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #xc + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id etie-l0-water) + :level-index #xd + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #xd + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tie-l1-water) + :level-index #xe + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #xe + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tfrag-l2-water) + :level-index #xf + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #xf + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc-l3-water) + :level-index #x10 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x10 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id merc-l4-water) + :level-index #x11 + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x11 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-l5-water) + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id gmerc2-l5-water) + :level-index #x1 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id etie-scissor-l6-water) + :level-index #x2 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tfrag-scissor-l7-water) + :level-index #x3 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id tie-scissor-l8-water) + :level-index #x4 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id etie-l9-water) + :level-index #x5 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id anti-alias) + :level-index #x12 + :level-texture-page (tpage-category-u32 pris) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id generic-warp) + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id debug-menu) + :level-index #x1 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket594) + :level-index #x2 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket603) + :level-index #x3 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket612) + :level-index #x4 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket621) + :level-index #x5 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 all-pris) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket630) + :level-index #x12 + :level-texture-page (tpage-category-u32 pris2) + :texture-user (texture-enable-mask-u32 sky) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket633) + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket652) + :level-index #x1 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket671) + :level-index #x2 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket690) + :level-index #x3 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket709) + :level-index #x4 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket728) + :level-index #x5 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket747) + :level-index #x12 + :level-texture-page (tpage-category-u32 water) + :texture-user (texture-enable-mask-u32 water) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x1 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x2 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x3 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x4 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x5 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket767) + :level-index #x12 + :level-texture-page (tpage-category-u32 sprite) + :texture-user (texture-enable-mask-u32 sprite) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x1 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x2 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x3 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x4 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x5 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket780) + :level-index #x12 + :level-texture-page (tpage-category-u32 warp) + :texture-user (texture-enable-mask-u32 warp) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x1 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x2 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x3 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x4 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x5 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket786) + :level-index #x12 + :level-texture-page (tpage-category-u32 hud) + :texture-user (texture-enable-mask-u32 hud) + ) + ) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/view-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/view-h_REF.gc new file mode 100644 index 0000000000..2ff8eb702a --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/view-h_REF.gc @@ -0,0 +1,58 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *view-count*, type int +(define *view-count* 1) + +;; definition for symbol *view-assert*, type symbol +(define *view-assert* #f) + +;; definition of type view +(deftype view (basic) + ((index int8) + (control-scheme uint8) + (camera basic) + (camera-combiner basic) + (target basic) + (math-camera basic) + ) + ) + +;; definition for method 3 of type view +(defmethod inspect ((this view)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tcontrol-scheme: ~D~%" (-> this control-scheme)) + (format #t "~1Tcamera: ~A~%" (-> this camera)) + (format #t "~1Tcamera-combiner: ~A~%" (-> this camera-combiner)) + (format #t "~1Ttarget: ~A~%" (-> this target)) + (format #t "~1Tmath-camera: ~A~%" (-> this math-camera)) + (label cfg-4) + this + ) + +;; definition for symbol *views*, type (array view) +(define *views* + "Length of 2, initialized empty" + (new 'static 'boxed-array :type view :length 0 :allocated-length 2) + ) + +;; definition for symbol *view-context-stack*, type (array int32) +(define *view-context-stack* (new 'static 'boxed-array :type int32 :length 0 :allocated-length 8)) + +;; definition for symbol *view-context-stack-ptr*, type (pointer int32) +(define *view-context-stack-ptr* (the-as (pointer int32) -1)) + +;; definition for symbol *view-default*, type symbol +(define *view-default* (the-as symbol 0)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/gfx/vu1-user-h_REF.gc b/test/decompiler/reference/jakx/engine/gfx/vu1-user-h_REF.gc new file mode 100644 index 0000000000..0a5ee46acb --- /dev/null +++ b/test/decompiler/reference/jakx/engine/gfx/vu1-user-h_REF.gc @@ -0,0 +1,82 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type dma-foreground-sink +(deftype dma-foreground-sink (basic) + "A specification for where a foreground renderer should output its DMA data." + ((bucket bucket-id) + (foreground-texture-page tpage-category) + (foreground-texture-level int8) + (foreground-output-bucket int8) + ) + ) + +;; definition for method 3 of type dma-foreground-sink +(defmethod inspect ((this dma-foreground-sink)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tbucket: ~D~%" (-> this bucket)) + (format #t "~1Tforeground-texture-page: ~D~%" (-> this foreground-texture-page)) + (format #t "~1Tforeground-texture-level: ~D~%" (-> this foreground-texture-level)) + (format #t "~1Tforeground-output-bucket: ~D~%" (-> this foreground-output-bucket)) + (label cfg-4) + this + ) + +;; definition of type generic-bucket-state +(deftype generic-bucket-state (structure) + "The state of buffers for the generic renderer. +When generating generic DMA data, you must know the previous state +of the VU's memory to properly double-buffer the input and output data." + ((gifbuf-adr uint32) + (inbuf-adr uint32) + ) + :pack-me + ) + +;; definition for method 3 of type generic-bucket-state +(defmethod inspect ((this generic-bucket-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'generic-bucket-state) + (format #t "~1Tgifbuf-adr: ~D~%" (-> this gifbuf-adr)) + (format #t "~1Tinbuf-adr: ~D~%" (-> this inbuf-adr)) + (label cfg-4) + this + ) + +;; definition of type generic-dma-foreground-sink +(deftype generic-dma-foreground-sink (dma-foreground-sink) + "A specification for where a foreground generic renderer should output DMA data, +and the state of the VU memory buffers at the end of the bucket." + ((state generic-bucket-state :inline) + ) + ) + +;; definition for method 3 of type generic-dma-foreground-sink +(defmethod inspect ((this generic-dma-foreground-sink)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tbucket: ~D~%" (-> this bucket)) + (format #t "~1Tforeground-texture-page: ~D~%" (-> this foreground-texture-page)) + (format #t "~1Tforeground-texture-level: ~D~%" (-> this foreground-texture-level)) + (format #t "~1Tforeground-output-bucket: ~D~%" (-> this foreground-output-bucket)) + (format #t "~1Tstate: #~%" (-> this state)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/level/level-h_REF.gc b/test/decompiler/reference/jakx/engine/level/level-h_REF.gc new file mode 100644 index 0000000000..5f90ead8db --- /dev/null +++ b/test/decompiler/reference/jakx/engine/level/level-h_REF.gc @@ -0,0 +1,972 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type level-vis-info +(deftype level-vis-info (basic) + ((level level) + (from-level symbol) + (from-bsp bsp-header) + (flags vis-info-flag) + (length uint32) + (allocated-length uint32) + (dictionary-length uint32) + (dictionary uint32) + (string-block uint32) + (ramdisk uint32) + (vis-bits uint32 4) + (current-vis-string uint32 4) + (vis-string uint32 :dynamic) + ) + ) + +;; definition for method 3 of type level-vis-info +(defmethod inspect ((this level-vis-info)) + (when (not this) + (set! this this) + (goto cfg-68) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlevel: ~A~%" (-> this level)) + (format #t "~1Tfrom-level: ~A~%" (-> this from-level)) + (format #t "~1Tfrom-bsp: ~A~%" (-> this from-bsp)) + (format #t "~1Tflags: #x~X : (vis-info-flag " (-> this flags)) + (let ((s5-0 (-> this flags))) + (if (= (logand (vis-info-flag dummy22) s5-0) (vis-info-flag dummy22)) + (format #t "dummy22 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy14)) (vis-info-flag dummy14)) + (format #t "dummy14 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy9)) (vis-info-flag dummy9)) + (format #t "dummy9 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy10)) (vis-info-flag dummy10)) + (format #t "dummy10 ") + ) + (if (= (logand (vis-info-flag dummy23) s5-0) (vis-info-flag dummy23)) + (format #t "dummy23 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy15)) (vis-info-flag dummy15)) + (format #t "dummy15 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy5)) (vis-info-flag dummy5)) + (format #t "dummy5 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy7)) (vis-info-flag dummy7)) + (format #t "dummy7 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy1)) (vis-info-flag dummy1)) + (format #t "dummy1 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy11)) (vis-info-flag dummy11)) + (format #t "dummy11 ") + ) + (if (= (logand (vis-info-flag dummy28) s5-0) (vis-info-flag dummy28)) + (format #t "dummy28 ") + ) + (if (= (logand (vis-info-flag dummy24) s5-0) (vis-info-flag dummy24)) + (format #t "dummy24 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy3)) (vis-info-flag dummy3)) + (format #t "dummy3 ") + ) + (if (= (logand (vis-info-flag dummy16) s5-0) (vis-info-flag dummy16)) + (format #t "dummy16 ") + ) + (if (= (logand (vis-info-flag dummy17) s5-0) (vis-info-flag dummy17)) + (format #t "dummy17 ") + ) + (if (= (logand (vis-info-flag dummy20) s5-0) (vis-info-flag dummy20)) + (format #t "dummy20 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy12)) (vis-info-flag dummy12)) + (format #t "dummy12 ") + ) + (if (= (logand (vis-info-flag loading) s5-0) (vis-info-flag loading)) + (format #t "loading ") + ) + (if (= (logand (vis-info-flag dummy25) s5-0) (vis-info-flag dummy25)) + (format #t "dummy25 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy6)) (vis-info-flag dummy6)) + (format #t "dummy6 ") + ) + (if (= (logand (vis-info-flag vis-valid) s5-0) (shl #x8000 16)) + (format #t "vis-valid ") + ) + (if (= (logand (vis-info-flag in-iop) s5-0) (vis-info-flag in-iop)) + (format #t "in-iop ") + ) + (if (= (logand (vis-info-flag dummy18) s5-0) (vis-info-flag dummy18)) + (format #t "dummy18 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy8)) (vis-info-flag dummy8)) + (format #t "dummy8 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy2)) (vis-info-flag dummy2)) + (format #t "dummy2 ") + ) + (if (= (logand (vis-info-flag dummy21) s5-0) (vis-info-flag dummy21)) + (format #t "dummy21 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy13)) (vis-info-flag dummy13)) + (format #t "dummy13 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy4)) (vis-info-flag dummy4)) + (format #t "dummy4 ") + ) + (if (= (logand (vis-info-flag dummy26) s5-0) (vis-info-flag dummy26)) + (format #t "dummy26 ") + ) + (if (= (logand (vis-info-flag dummy27) s5-0) (vis-info-flag dummy27)) + (format #t "dummy27 ") + ) + (if (= (logand (vis-info-flag dummy19) s5-0) (vis-info-flag dummy19)) + (format #t "dummy19 ") + ) + (if (= (logand s5-0 (vis-info-flag dummy0)) (vis-info-flag dummy0)) + (format #t "dummy0 ") + ) + ) + (format #t ")~%") + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdictionary-length: ~D~%" (-> this dictionary-length)) + (format #t "~1Tdictionary: #x~X~%" (-> this dictionary)) + (format #t "~1Tstring-block: #x~X~%" (-> this string-block)) + (format #t "~1Tramdisk: ~D~%" (-> this ramdisk)) + (format #t "~1Tvis-bits[4] @ #x~X~%" (-> this vis-bits)) + (format #t "~1Tcurrent-vis-string[4] @ #x~X~%" (-> this current-vis-string)) + (format #t "~1Tvis-string[0] @ #x~X~%" (-> this vis-string)) + (label cfg-68) + this + ) + +;; definition for method 5 of type level-vis-info +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this level-vis-info)) + (the-as int (+ (-> level-vis-info size) (-> this dictionary-length))) + ) + +;; definition of type level-borrow-info +(deftype level-borrow-info (basic) + ((borrow-size uint16 3) + (borrow-info object 3) + ) + ) + +;; definition for method 3 of type level-borrow-info +(defmethod inspect ((this level-borrow-info)) + (when (not this) + (set! this this) + (goto cfg-10) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tborrow-size[3] @ #x~X~%" (-> this borrow-size)) + (dotimes (s5-0 3) + (format #t "~T [~D]~1Tborrow-size: ~`integer`P~%" s5-0 (-> this borrow-size s5-0)) + ) + (format #t "~1Tborrow-info[3] @ #x~X~%" (-> this borrow-info)) + (dotimes (s5-1 3) + (format #t "~T [~D]~1Tborrow-info: ~`object`P~%" s5-1 (-> this borrow-info s5-1)) + ) + (label cfg-10) + this + ) + +;; definition of type level-load-info +(deftype level-load-info (basic) + ((name-list symbol 4) + (name symbol :overlay-at (-> name-list 0)) + (visname symbol :overlay-at (-> name-list 1)) + (nickname symbol :overlay-at (-> name-list 2)) + (dbname symbol :overlay-at (-> name-list 0)) + (taskname symbol :overlay-at (-> name-list 3)) + (index int16) + (task-level uint8) + (race-minimap uint8) + (level-flags level-flags) + (packages pair) + (memory-mode level-memory-mode) + (mood-func symbol) + (special-mood symbol) + (ocean symbol) + (ocean-height float) + (status-cache uint16) + (status-cache-sync uint16) + (draw-priority float) + (base-task-mask task-mask) + (continues pair) + (callback-list pair) + (borrow level-borrow-info) + (bottom-height meters) + (mood-range mood-range) + ) + (:methods + (level-load-info-method-9 () none) + (level-load-info-method-10 () none) + ) + ) + +;; definition for method 3 of type level-load-info +(defmethod inspect ((this level-load-info)) + (when (not this) + (set! this this) + (goto cfg-42) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname-list[4] @ #x~X~%" (&-> this name)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tvisname: ~A~%" (-> this visname)) + (format #t "~1Tnickname: ~A~%" (-> this nickname)) + (format #t "~1Tdbname: ~A~%" (-> this name)) + (format #t "~1Ttaskname: ~A~%" (-> this taskname)) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Ttask-level: ~D~%" (-> this task-level)) + (format #t "~1Trace-minimap: ~D~%" (-> this race-minimap)) + (format #t "~1Tlevel-flags: ~D~%" (-> this level-flags)) + (format #t "~1Tpackages: ~A~%" (-> this packages)) + (format #t "~1Tmemory-mode: ~D~%" (-> this memory-mode)) + (format #t "~1Tmood-func: ~A~%" (-> this mood-func)) + (format #t "~1Tspecial-mood: ~A~%" (-> this special-mood)) + (format #t "~1Tocean: ~A~%" (-> this ocean)) + (format #t "~1Tocean-height: ~f~%" (-> this ocean-height)) + (format #t "~1Tstatus-cache: ~D~%" (-> this status-cache)) + (format #t "~1Tstatus-cache-sync: ~D~%" (-> this status-cache-sync)) + (format #t "~1Tdraw-priority: ~f~%" (-> this draw-priority)) + (format #t "~1Tbase-task-mask: #x~X : (task-mask " (-> this base-task-mask)) + (let ((s5-0 (-> this base-task-mask))) + (if (= (logand s5-0 (task-mask network)) (task-mask network)) + (format #t "network ") + ) + (if (= (logand s5-0 (task-mask task0)) (task-mask task0)) + (format #t "task0 ") + ) + (if (= (logand s5-0 (task-mask task2)) (task-mask task2)) + (format #t "task2 ") + ) + (if (= (logand s5-0 (task-mask task4)) (task-mask task4)) + (format #t "task4 ") + ) + (if (= (logand s5-0 (task-mask task6)) (task-mask task6)) + (format #t "task6 ") + ) + (if (= (logand s5-0 (task-mask ctywide)) (task-mask ctywide)) + (format #t "ctywide ") + ) + (if (= (logand s5-0 (task-mask never)) (task-mask never)) + (format #t "never ") + ) + (if (= (logand (task-mask movie1) s5-0) (task-mask movie1)) + (format #t "movie1 ") + ) + (if (= (logand s5-0 (task-mask vehicle)) (task-mask vehicle)) + (format #t "vehicle ") + ) + (if (= (logand s5-0 (task-mask primary0)) (task-mask primary0)) + (format #t "primary0 ") + ) + (if (= (logand s5-0 (task-mask task1)) (task-mask task1)) + (format #t "task1 ") + ) + (if (= (logand s5-0 (task-mask task3)) (task-mask task3)) + (format #t "task3 ") + ) + (if (= (logand s5-0 (task-mask task5)) (task-mask task5)) + (format #t "task5 ") + ) + (if (= (logand s5-0 (task-mask task7)) (task-mask task7)) + (format #t "task7 ") + ) + (if (= (logand (task-mask movie2) s5-0) (task-mask movie2)) + (format #t "movie2 ") + ) + (if (= (logand s5-0 (task-mask done)) (task-mask done)) + (format #t "done ") + ) + (if (= (logand s5-0 (task-mask special)) (task-mask special)) + (format #t "special ") + ) + (if (= (logand (task-mask movie0) s5-0) (task-mask movie0)) + (format #t "movie0 ") + ) + (if (= (logand s5-0 (task-mask dummy0)) (task-mask dummy0)) + (format #t "dummy0 ") + ) + ) + (format #t ")~%") + (format #t "~1Tcontinues: ~A~%" (-> this continues)) + (format #t "~1Tcallback-list: ~A~%" (-> this callback-list)) + (format #t "~1Tborrow: ~A~%" (-> this borrow)) + (format #t "~1Tbottom-height: (meters ~m)~%" (-> this bottom-height)) + (format #t "~1Tmood-range: ~A~%" (-> this mood-range)) + (label cfg-42) + this + ) + +;; definition of type login-state +(deftype login-state (basic) + ((state int32) + (pos uint32) + (elts uint32) + (elt drawable 16) + ) + ) + +;; definition for method 3 of type login-state +(defmethod inspect ((this login-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tstate: ~D~%" (-> this state)) + (format #t "~1Tpos: ~D~%" (-> this pos)) + (format #t "~1Telts: ~D~%" (-> this elts)) + (format #t "~1Telt[16] @ #x~X~%" (-> this elt)) + (label cfg-4) + this + ) + +;; definition of type level +(deftype level (basic) + ((name symbol) + (load-name symbol) + (nickname symbol) + (index int32) + (status symbol) + (borrow-level level 3) + (borrow-from-level level) + (heap kheap :inline) + (borrow-heap kheap 3 :inline) + (bsp bsp-header) + (art-group load-dir-art-group) + (info level-load-info) + (level-TODO-01 int32) + (texture-page-dir texture-page-segment 11 :inline) + (loaded-texture-page texture-page 16) + (loaded-texture-page-count int32) + (entity entity-links-array) + (closest-object meters 10) + (tie-min-dist float :offset 376) + (fg-tfrag-min-dist float) + (fg-prim-min-dist float) + (fg-shrub-min-dist float) + (fg-warp-min-dist float :offset 396) + (fg-prim2-min-dist float :offset 404) + (upload-size int32 19) + (inside-boxes? symbol) + (display? symbol) + (render? symbol) + (meta-inside? symbol) + (force-inside? symbol) + (load-id uint32) + (mood-context mood-context) + (mood-func (function mood-context float int none)) + (mood-init (function mood-context none)) + (vis-bits pointer 2) + (all-visible? symbol) + (force-all-visible? symbol) + (linking symbol) + (vis-info level-vis-info 8) + (vis-self-index int32) + (vis-adj-index int32) + (vis-buffer uint32) + (mem-usage-block memory-usage-block) + (mem-usage int32) + (code-memory-start pointer) + (code-memory-end pointer) + (load-start-time uint64) + (load-stop-time uint64) + (load-buffer uint32 2) + (load-buffer-size uint32) + (load-buffer-last dgo-header) + (load-buffer-mode level-memory-mode) + (display-start-time uint64) + (memory-mask uint32) + (task-mask task-mask) + (tfrag-gs-test gs-test) + (level-TODO-003 int32) + (level-TODO-004 int32) + (texture-dirty-masks texture-mask 11 :inline) + (texture-mask texture-mask 19 :inline) + (tfrag-last-calls uint32 6) + (texture-anim-array texture-anim-array 11) + (light-hash light-hash) + (draw-priority float) + (draw-index int32) + (part-engine engine) + (user-object basic 4) + (loaded-text-info-count int32) + (loaded-text-info game-text-info 16) + (level-type type) + (load-order uint64) + (slot int32) + (filter-num uint32) + (filter-name string 16) + (filter-look uint8 16) + (buffer kheap) + ) + (:methods + (level-method-9 () none) + (level-method-10 () none) + (level-method-11 () none) + (level-method-12 () none) + (level-method-13 () none) + (level-method-14 () none) + (level-method-15 () none) + (level-method-16 () none) + (level-method-17 () none) + (level-method-18 () none) + (level-method-19 () none) + (level-method-20 () none) + (level-method-21 () none) + (level-method-22 () none) + (level-method-23 () none) + (level-method-24 () none) + (level-method-25 () none) + (level-method-26 () none) + (level-method-27 () none) + (level-method-28 () none) + (level-method-29 () none) + ) + ) + +;; definition for method 3 of type level +(defmethod inspect ((this level)) + (when (not this) + (set! this this) + (goto cfg-48) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tload-name: ~A~%" (-> this load-name)) + (format #t "~1Tnickname: ~A~%" (-> this nickname)) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tstatus: ~A~%" (-> this status)) + (format #t "~1Tborrow-level[3] @ #x~X~%" (-> this borrow-level)) + (dotimes (s5-0 3) + (format #t "~T [~D]~1Tborrow-level: ~A~%" s5-0 (-> this borrow-level s5-0)) + ) + (format #t "~1Tborrow-from-level: ~A~%" (-> this borrow-from-level)) + (format #t "~1Theap: #~%" (-> this heap)) + (format #t "~1Tborrow-heap[3] @ #x~X~%" (-> this borrow-heap)) + (format #t "~1Tbsp: ~A~%" (-> this bsp)) + (format #t "~1Tart-group: ~A~%" (-> this art-group)) + (format #t "~1Tinfo: ~A~%" (-> this info)) + (format #t "~1Ttexture-page-dir[11] @ #x~X~%" (-> this texture-page-dir)) + (format #t "~1Tloaded-texture-page[16] @ #x~X~%" (-> this loaded-texture-page)) + (format #t "~1Tloaded-texture-page-count: ~D~%" (-> this loaded-texture-page-count)) + (format #t "~1Tentity: ~A~%" (-> this entity)) + (format #t "~1Tclosest-object: (meters ~m)~%" (-> this closest-object)) + (format #t "~1Tupload-size[19] @ #x~X~%" (-> this upload-size)) + (format #t "~1Tinside-boxes?: ~A~%" (-> this inside-boxes?)) + (format #t "~1Tdisplay?: ~A~%" (-> this display?)) + (format #t "~1Trender?: ~A~%" (-> this render?)) + (format #t "~1Tmeta-inside?: ~A~%" (-> this meta-inside?)) + (format #t "~1Tforce-inside?: ~A~%" (-> this force-inside?)) + (format #t "~1Tload-id: ~D~%" (-> this load-id)) + (format #t "~1Tmood-context: #~%" (-> this mood-context)) + (format #t "~1Tmood-func: ~A~%" (-> this mood-func)) + (format #t "~1Tmood-init: ~A~%" (-> this mood-init)) + (format #t "~1Tvis-bits[2] @ #x~X~%" (-> this vis-bits)) + (format #t "~1Tall-visible?: ~A~%" (-> this all-visible?)) + (format #t "~1Tforce-all-visible?: ~A~%" (-> this force-all-visible?)) + (format #t "~1Tlinking: ~A~%" (-> this linking)) + (format #t "~1Tvis-info[8] @ #x~X~%" (-> this vis-info)) + (format #t "~1Tvis-self-index: ~D~%" (-> this vis-self-index)) + (format #t "~1Tvis-adj-index: ~D~%" (-> this vis-adj-index)) + (format #t "~1Tvis-buffer: #x~X~%" (-> this vis-buffer)) + (format #t "~1Tmem-usage-block: ~A~%" (-> this mem-usage-block)) + (format #t "~1Tmem-usage: ~D~%" (-> this mem-usage)) + (format #t "~1Tcode-memory-start: #x~X~%" (-> this code-memory-start)) + (format #t "~1Tcode-memory-end: #x~X~%" (-> this code-memory-end)) + (format #t "~1Tload-start-time: ~D~%" (-> this load-start-time)) + (format #t "~1Tload-stop-time: ~D~%" (-> this load-stop-time)) + (format #t "~1Tload-buffer[2] @ #x~X~%" (-> this load-buffer)) + (format #t "~1Tload-buffer-size: ~D~%" (-> this load-buffer-size)) + (format #t "~1Tload-buffer-last: #~%" (-> this load-buffer-last)) + (format #t "~1Tload-buffer-mode: ~D~%" (-> this load-buffer-mode)) + (format #t "~1Tdisplay-start-time: ~D~%" (-> this display-start-time)) + (format #t "~1Tmemory-mask: #b~B~%" (-> this memory-mask)) + (format #t "~1Ttask-mask: #x~X : (task-mask " (-> this task-mask)) + (let ((s5-1 (-> this task-mask))) + (if (= (logand s5-1 (task-mask network)) (task-mask network)) + (format #t "network ") + ) + (if (= (logand s5-1 (task-mask task0)) (task-mask task0)) + (format #t "task0 ") + ) + (if (= (logand s5-1 (task-mask task2)) (task-mask task2)) + (format #t "task2 ") + ) + (if (= (logand s5-1 (task-mask task4)) (task-mask task4)) + (format #t "task4 ") + ) + (if (= (logand s5-1 (task-mask task6)) (task-mask task6)) + (format #t "task6 ") + ) + (if (= (logand s5-1 (task-mask ctywide)) (task-mask ctywide)) + (format #t "ctywide ") + ) + (if (= (logand s5-1 (task-mask never)) (task-mask never)) + (format #t "never ") + ) + (if (= (logand (task-mask movie1) s5-1) (task-mask movie1)) + (format #t "movie1 ") + ) + (if (= (logand s5-1 (task-mask vehicle)) (task-mask vehicle)) + (format #t "vehicle ") + ) + (if (= (logand s5-1 (task-mask primary0)) (task-mask primary0)) + (format #t "primary0 ") + ) + (if (= (logand s5-1 (task-mask task1)) (task-mask task1)) + (format #t "task1 ") + ) + (if (= (logand s5-1 (task-mask task3)) (task-mask task3)) + (format #t "task3 ") + ) + (if (= (logand s5-1 (task-mask task5)) (task-mask task5)) + (format #t "task5 ") + ) + (if (= (logand s5-1 (task-mask task7)) (task-mask task7)) + (format #t "task7 ") + ) + (if (= (logand (task-mask movie2) s5-1) (task-mask movie2)) + (format #t "movie2 ") + ) + (if (= (logand s5-1 (task-mask done)) (task-mask done)) + (format #t "done ") + ) + (if (= (logand s5-1 (task-mask special)) (task-mask special)) + (format #t "special ") + ) + (if (= (logand (task-mask movie0) s5-1) (task-mask movie0)) + (format #t "movie0 ") + ) + (if (= (logand s5-1 (task-mask dummy0)) (task-mask dummy0)) + (format #t "dummy0 ") + ) + ) + (format #t ")~%") + (format #t "~1Ttfrag-gs-test: ~D~%" (-> this tfrag-gs-test)) + (format #t "~1Ttexture-dirty-masks[11] @ #x~X~%" (-> this texture-dirty-masks)) + (format #t "~1Ttexture-mask[19] @ #x~X~%" (-> this texture-mask)) + (format #t "~1Ttfrag-last-calls[6] @ #x~X~%" (-> this tfrag-last-calls)) + (format #t "~1Ttexture-anim-array[11] @ #x~X~%" (-> this texture-anim-array)) + (format #t "~1Tlight-hash: ~A~%" (-> this light-hash)) + (format #t "~1Tdraw-priority: ~f~%" (-> this draw-priority)) + (format #t "~1Tdraw-index: ~D~%" (-> this draw-index)) + (format #t "~1Tpart-engine: ~A~%" (-> this part-engine)) + (format #t "~1Tuser-object[4] @ #x~X~%" (-> this user-object)) + (dotimes (s5-2 4) + (format #t "~T [~D]~1Tuser-object: ~A~%" s5-2 (-> this user-object s5-2)) + ) + (format #t "~1Tloaded-text-info-count: ~D~%" (-> this loaded-text-info-count)) + (format #t "~1Tloaded-text-info[16] @ #x~X~%" (-> this loaded-text-info)) + (format #t "~1Tlevel-type: ~A~%" (-> this level-type)) + (format #t "~1Tload-order: ~D~%" (-> this load-order)) + (format #t "~1Tslot: ~D~%" (-> this slot)) + (format #t "~1Tfilter-num: ~D~%" (-> this filter-num)) + (format #t "~1Tfilter-name[16] @ #x~X~%" (-> this filter-name)) + (format #t "~1Tfilter-look[16] @ #x~X~%" (-> this filter-look)) + (format #t "~1Tbuffer: #~%" (-> this buffer)) + (label cfg-48) + this + ) + +;; definition of type level-group +(deftype level-group (basic) + ((length int32) + (log-in-level-bsp bsp-header) + (loading-level level) + (entity-link entity-links) + (border? symbol) + (vis? symbol) + (want-level basic) + (receiving-level basic) + (load-commands pair) + (play? symbol) + (prev-target-pos vector 2 :inline) + (curr-target-pos vector 2 :inline) + (prev-camera-pos vector 2 :inline) + (curr-camera-pos vector 2 :inline) + (heap kheap :inline) + (car-heap kheap :inline) + (driver-heap kheap :inline) + (cars-heap kheap :inline) + (sound-bank sound-bank-state 7 :inline) + (disk-load-timing? symbol) + (load-level symbol) + (load-size uint32) + (load-time float) + (load-login-time float) + (draw-level-count int32) + (draw-level level 19) + (draw-index-map uint8 19) + (shared-ties basic) + (status-cache-sync uint16) + (load-order uint64) + (wide-level level 2) + (tfrag-login-level basic) + (level-group-TODO-001 int32 11) + (level level 19 :inline :offset 544) + (level0 level :inline :overlay-at (-> level 0)) + (level1 level :inline :offset 1984) + (level2 level :inline :offset 3424) + (level3 level :inline :offset 4864) + (level4 level :inline :offset 6304) + (level5 level :inline :offset 7744) + (car0 level :inline :offset 9184) + (car1 level :inline :offset 10624) + (car2 level :inline :offset 12064) + (car3 level :inline :offset 13504) + (car4 level :inline :offset 14944) + (car5 level :inline :offset 16384) + (driver0 level :inline :offset 17824) + (driver1 level :inline :offset 19264) + (driver2 level :inline :offset 20704) + (driver3 level :inline :offset 22144) + (driver4 level :inline :offset 23584) + (driver5 level :inline :offset 25024) + (level-default level :inline :offset 26464) + (pad int32) + ) + (:methods + (level-group-method-9 () none) + (level-group-method-10 () none) + (level-group-method-11 () none) + (level-group-method-12 () none) + (level-group-method-13 () none) + (level-group-method-14 () none) + (level-group-method-15 () none) + (level-group-method-16 () none) + (level-group-method-17 () none) + (level-group-method-18 () none) + (level-group-method-19 () none) + (level-group-method-20 () none) + (level-group-method-21 () none) + (level-group-method-22 () none) + (level-group-method-23 () none) + (level-group-method-24 () none) + (level-group-method-25 () none) + (level-group-method-26 () none) + (level-group-method-27 () none) + (level-group-method-28 () none) + (level-group-method-29 () none) + (level-group-method-30 () none) + (level-group-method-31 () none) + (level-group-method-32 () none) + (level-group-method-33 () none) + ) + ) + +;; definition for method 3 of type level-group +(defmethod inspect ((this level-group)) + (when (not this) + (set! this this) + (goto cfg-22) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tentity-link: ~`entity-links`P~%" (-> this entity-link)) + (format #t "~1Tborder?: ~A~%" (-> this border?)) + (format #t "~1Tvis?: ~A~%" (-> this vis?)) + (format #t "~1Twant-level: ~A~%" (-> this want-level)) + (format #t "~1Treceiving-level: ~A~%" (-> this receiving-level)) + (format #t "~1Tload-commands: ~A~%" (-> this load-commands)) + (format #t "~1Tplay?: ~A~%" (-> this play?)) + (format #t "~1Tprev-target-pos[2] @ #x~X~%" (-> this prev-target-pos)) + (dotimes (s5-0 2) + (format #t "~T [~D]~1Tprev-target-pos: ~`vector`P~%" s5-0 (-> this prev-target-pos s5-0)) + ) + (format #t "~1Tcurr-target-pos[2] @ #x~X~%" (-> this curr-target-pos)) + (dotimes (s5-1 2) + (format #t "~T [~D]~1Tcurr-target-pos: ~`vector`P~%" s5-1 (-> this curr-target-pos s5-1)) + ) + (format #t "~1Tprev-camera-pos[2] @ #x~X~%" (-> this prev-camera-pos)) + (dotimes (s5-2 2) + (format #t "~T [~D]~1Tprev-camera-pos: ~`vector`P~%" s5-2 (-> this prev-camera-pos s5-2)) + ) + (format #t "~1Tcurr-camera-pos[2] @ #x~X~%" (-> this curr-camera-pos)) + (dotimes (s5-3 2) + (format #t "~T [~D]~1Tcurr-camera-pos: ~`vector`P~%" s5-3 (-> this curr-camera-pos s5-3)) + ) + (format #t "~1Theap: #~%" (-> this heap)) + (format #t "~1Tcar-heap: #~%" (-> this car-heap)) + (format #t "~1Tdriver-heap: #~%" (-> this driver-heap)) + (format #t "~1Tcars-heap: #~%" (-> this cars-heap)) + (format #t "~1Tsound-bank[7] @ #x~X~%" (-> this sound-bank)) + (dotimes (s5-4 7) + (format #t "~T [~D]~1Tsound-bank: ~`sound-bank-state`P~%" s5-4 (-> this sound-bank s5-4)) + ) + (format #t "~1Tdisk-load-timing?: ~A~%" (-> this disk-load-timing?)) + (format #t "~1Tload-level: ~A~%" (-> this load-level)) + (format #t "~1Tload-size: ~D~%" (-> this load-size)) + (format #t "~1Tload-time: ~f~%" (-> this load-time)) + (format #t "~1Tload-login-time: ~f~%" (-> this load-login-time)) + (format #t "~1Tdraw-level-count: ~D~%" (-> this draw-level-count)) + (format #t "~1Tdraw-level[19] @ #x~X~%" (-> this draw-level)) + (dotimes (s5-5 (-> this draw-level-count)) + (format #t "~T [~D]~1Tdraw-level: ~`object`P~%" s5-5 (-> this draw-level s5-5)) + ) + (format #t "~1Tdraw-index-map[19] @ #x~X~%" (-> this draw-index-map)) + (format #t "~1Tshared-ties: ~A~%" (-> this shared-ties)) + (format #t "~1Tstatus-cache-sync: ~D~%" (-> this status-cache-sync)) + (format #t "~1Tload-order: ~D~%" (-> this load-order)) + (format #t "~1Twide-level[2] @ #x~X~%" (-> this wide-level)) + (format #t "~1Ttfrag-login-level: ~A~%" (-> this tfrag-login-level)) + (format #t "~1Tlevel[19] @ #x~X~%" (-> this level)) + (format #t "~1Tdata[19] @ #x~X~%" (-> this level)) + (format #t "~1Tlevel0: ~`level`P~%" (-> this level)) + (format #t "~1Tlevel1: ~`level`P~%" (-> this level1)) + (format #t "~1Tlevel2: ~`level`P~%" (-> this level2)) + (format #t "~1Tlevel3: ~`level`P~%" (-> this level3)) + (format #t "~1Tlevel4: ~`level`P~%" (-> this level4)) + (format #t "~1Tlevel5: ~`level`P~%" (-> this level5)) + (format #t "~1Tcar0: ~`level`P~%" (-> this car0)) + (format #t "~1Tcar1: ~`level`P~%" (-> this car1)) + (format #t "~1Tcar2: ~`level`P~%" (-> this car2)) + (format #t "~1Tcar3: ~`level`P~%" (-> this car3)) + (format #t "~1Tcar4: ~`level`P~%" (-> this car4)) + (format #t "~1Tcar5: ~`level`P~%" (-> this car5)) + (format #t "~1Tdriver0: ~`level`P~%" (-> this driver0)) + (format #t "~1Tdriver1: ~`level`P~%" (-> this driver1)) + (format #t "~1Tdriver2: ~`level`P~%" (-> this driver2)) + (format #t "~1Tdriver3: ~`level`P~%" (-> this driver3)) + (format #t "~1Tdriver4: ~`level`P~%" (-> this driver4)) + (format #t "~1Tdriver5: ~`level`P~%" (-> this driver5)) + (format #t "~1Tlevel-default: ~`level`P~%" (-> this level-default)) + (label cfg-22) + this + ) + +;; failed to figure out what this is: +(when (zero? *level*) + (set! *level* + (new 'static 'level-group + :length 18 + :log-in-level-bsp #f + :loading-level #f + :entity-link #f + :border? #f + :vis? #f + :want-level #f + :load-commands '() + :play? #f + :sound-bank (new 'static 'inline-array sound-bank-state 7 + (new 'static 'sound-bank-state :name #f :mode (sound-bank-mode full)) + (new 'static 'sound-bank-state :name #f) + (new 'static 'sound-bank-state :name #f) + (new 'static 'sound-bank-state :name #f) + (new 'static 'sound-bank-state :name #f) + (new 'static 'sound-bank-state :name #f) + (new 'static 'sound-bank-state :name #f) + ) + :disk-load-timing? #f + :status-cache-sync #x1 + :level (new 'static 'inline-array level 19 + (new 'static 'level :name #f :status 'inactive :inside-boxes? #f :force-inside? #f :linking #f :level-type #f) + (new 'static 'level + :name #f + :index 1 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 2 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 3 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 4 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 5 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 6 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 7 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 8 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 9 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 10 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 11 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 12 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 13 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 14 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 15 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 16 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name #f + :index 17 + :status 'inactive + :inside-boxes? #f + :force-inside? #f + :linking #f + :level-type #f + ) + (new 'static 'level + :name 'default + :index 18 + :status 'reserved + :bsp #f + :inside-boxes? #f + :display? #f + :force-inside? #f + :linking #f + :level-type #f + ) + ) + ) + ) + (set! (-> *level* sound-bank 0 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 1 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 2 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 3 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 4 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 5 str-name) (new 'global 'string 16 (the-as string #f))) + (set! (-> *level* sound-bank 6 str-name) (new 'global 'string 16 (the-as string #f))) + (set! *draw-index* 0) + (set! *level-index* 0) + 0 + ) + +;; definition for symbol *city-mode*, type symbol +(define *city-mode* #f) + +;; definition for symbol *lobby-levels*, type (array symbol) +(define *lobby-levels* (new 'static 'boxed-array :type symbol '#f '#f)) + +;; definition for symbol *lobby-levels-display*, type (array symbol) +(define *lobby-levels-display* (new 'static 'boxed-array :type symbol '#f '#f)) + +;; definition for symbol *lobby-levels-tmp*, type (array symbol) +(define *lobby-levels-tmp* (new 'static 'boxed-array :type symbol :length 0 :allocated-length 6)) + +;; failed to figure out what this is: +(dotimes (v1-27 6) + (set! (-> *lobby-levels-tmp* v1-27) #f) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/level/region-h_REF.gc b/test/decompiler/reference/jakx/engine/level/region-h_REF.gc new file mode 100644 index 0000000000..3fdf1a2f25 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/level/region-h_REF.gc @@ -0,0 +1,266 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type region +(deftype region (structure) + "A region is a closed volume that you can, enter, exit, and be inside. +This stores a unique, and script functions for a single region. +These are stored separately from the actual geometry to allow the geometry to be smaller +and fit in scratchpad/cache better." + ((id uint32) + (on-enter pair) + (on-inside pair) + (on-exit pair) + ) + (:methods + (point-in-region-debug! (_type_ vector) symbol) + ) + ) + +;; definition for method 3 of type region +(defmethod inspect ((this region)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'region) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Ton-enter: ~A~%" (-> this on-enter)) + (format #t "~1Ton-inside: ~A~%" (-> this on-inside)) + (format #t "~1Ton-exit: ~A~%" (-> this on-exit)) + (label cfg-4) + this + ) + +;; definition of type region-array +(deftype region-array (inline-array-class) + "Array of region." + ((data region :inline :dynamic) + ) + ) + +;; definition for method 3 of type region-array +(defmethod inspect ((this region-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> region-array heap-base) (the-as uint 16)) + +;; definition of type drawable-region-prim +(deftype drawable-region-prim (drawable) + "Base class for a region + geometry. +Note that all child classes of this must be 32-bytes." + ((region region :offset 8) + ) + (:methods + (debug-draw-region (_type_ int) none) + (track-region (_type_ region-prim-area) symbol) + (within-area? (_type_ region-prim-area) symbol) + ) + ) + +;; definition for method 3 of type drawable-region-prim +(defmethod inspect ((this drawable-region-prim)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tregion: #~%" (-> this region)) + (label cfg-4) + this + ) + +;; definition of type drawable-tree-region-prim +(deftype drawable-tree-region-prim (drawable-tree) + "Top-level container for all regions of a level." + ((name symbol :offset 8) + (data2 drawable-inline-array :dynamic :offset 32) + ) + (:methods + (drawable-tree-region-prim-method-17 (_type_ vector) symbol) + (debug-print (_type_ vector object) none) + ) + ) + +;; definition for method 3 of type drawable-tree-region-prim +(defmethod inspect ((this drawable-tree-region-prim)) + (when (not this) + (set! this this) + (goto cfg-7) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data2)) + (dotimes (s5-0 (-> this length)) + (format #t "~T [~D]~1Tdata: ~A~%" s5-0 (-> this data2 s5-0)) + ) + (format #t "~1Tname: ~A~%" (-> this name)) + (label cfg-7) + this + ) + +;; definition of type drawable-inline-array-region-prim +(deftype drawable-inline-array-region-prim (drawable-inline-array) + "Inline array of drawable-region-prim. This actually stores child classes, but they are +exactly the same size as the parent, so it's okay." + ((data drawable-region-prim 1 :inline) + (pad uint8 4) + ) + ) + +;; definition of type drawable-region-sphere +(deftype drawable-region-sphere (drawable-region-prim) + "Region where the bsphere of the drawable is the volume." + () + ) + +;; definition for method 3 of type drawable-region-sphere +(defmethod inspect ((this drawable-region-sphere)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tregion: #~%" (-> this region)) + (label cfg-4) + this + ) + +;; definition of type region-face-data +(deftype region-face-data (structure) + "Data to store a single planar face, as a normal and list of vertices." + ((normal vector :inline) + (normal-offset float :overlay-at (-> normal data 3)) + (num-points uint32) + (points vector :inline :dynamic) + ) + ) + +;; definition for method 3 of type region-face-data +(defmethod inspect ((this region-face-data)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'region-face-data) + (format #t "~1Tnormal: #~%" (-> this normal)) + (format #t "~1Tnormal-offset: ~f~%" (-> this normal w)) + (format #t "~1Tnum-points: ~D~%" (-> this num-points)) + (format #t "~1Tpoints[0] @ #x~X~%" (-> this points)) + (label cfg-4) + this + ) + +;; definition of type drawable-region-face +(deftype drawable-region-face (drawable-region-prim) + "A drawable-region which is just a face. Unclear if `on-inside` is used." + ((data region-face-data :offset 12) + ) + ) + +;; definition for method 3 of type drawable-region-face +(defmethod inspect ((this drawable-region-face)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tregion: #~%" (-> this region)) + (format #t "~1Tdata: #~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type region-face-array +(deftype region-face-array (inline-array-class) + "An array of faces that hopefully make a closed volume." + ((data drawable-region-face :inline :dynamic :offset 16) + (pad uint32) + ) + ) + +;; definition for method 3 of type region-face-array +(defmethod inspect ((this region-face-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> region-face-array heap-base) (the-as uint 32)) + +;; definition of type drawable-region-volume +(deftype drawable-region-volume (drawable-region-prim) + "A drawable-region which is a bunch of faces that represent a closed volume." + ((faces region-face-array :offset 12) + ) + ) + +;; definition for method 3 of type drawable-region-volume +(defmethod inspect ((this drawable-region-volume)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tregion: #~%" (-> this region)) + (format #t "~1Tfaces: ~A~%" (-> this faces)) + (label cfg-4) + this + ) + +;; definition of type region-prim-list +(deftype region-prim-list (structure) + "A list of drawable-region-prim. This is the return type of queries like `which regions contain this point?`" + ((num-items int32) + (items drawable-region-prim 320) + ) + ) + +;; definition for method 3 of type region-prim-list +(defmethod inspect ((this region-prim-list)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'region-prim-list) + (format #t "~1Tnum-items: ~D~%" (-> this num-items)) + (format #t "~1Titems[320] @ #x~X~%" (-> this items)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/load/decomp-h_REF.gc b/test/decompiler/reference/jakx/engine/load/decomp-h_REF.gc new file mode 100644 index 0000000000..17e3efb534 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/load/decomp-h_REF.gc @@ -0,0 +1,33 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type decomp-work +(deftype decomp-work (structure) + ((buffer0 uint8 2048) + (buffer1 uint8 2048) + (indices uint16 2048) + (temp-indices uint16 2048) + ) + ) + +;; definition for method 3 of type decomp-work +(defmethod inspect ((this decomp-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'decomp-work) + (format #t "~1Tbuffer0[2048] @ #x~X~%" (-> this buffer0)) + (format #t "~1Tbuffer1[2048] @ #x~X~%" (-> this buffer1)) + (format #t "~1Tindices[2048] @ #x~X~%" (-> this indices)) + (format #t "~1Ttemp-indices[2048] @ #x~X~%" (-> this temp-indices)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/load/loader-h_REF.gc b/test/decompiler/reference/jakx/engine/load/loader-h_REF.gc new file mode 100644 index 0000000000..92e6f40bc5 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/load/loader-h_REF.gc @@ -0,0 +1,296 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type load-dir +(deftype load-dir (basic) + ((lev level) + (string-array (array string)) + (data-array (array basic)) + ) + (:methods + (new (symbol type int level) _type_) + (load-to-heap-by-name (_type_ string symbol kheap int) art-group) + (set-loaded-art (_type_ art-group) art-group) + ) + ) + +;; definition of type load-dir-art-group +(deftype load-dir-art-group (load-dir) + "Specialization of load-dir for `art-group`s." + ((art-group-array (array art-group) :overlay-at data-array) + ) + (:methods + (new (symbol type int level) _type_) + ) + ) + +;; definition for method 0 of type load-dir +(defmethod new load-dir ((allocation symbol) (type-to-make type) (arg0 int) (arg1 level)) + (let ((s4-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s4-0 lev) arg1) + (set! (-> s4-0 string-array) + (the-as (array string) ((method-of-type array new) allocation array string arg0)) + ) + (set! (-> s4-0 string-array length) 0) + (set! (-> s4-0 data-array) (the-as (array basic) ((method-of-type array new) allocation array basic arg0))) + (set! (-> s4-0 data-array length) 0) + s4-0 + ) + ) + +;; definition for method 0 of type load-dir-art-group +;; WARN: Return type mismatch load-dir vs load-dir-art-group. +(defmethod new load-dir-art-group ((allocation symbol) (type-to-make type) (arg0 int) (arg1 level)) + (let ((v0-0 ((method-of-type load-dir new) allocation type-to-make arg0 arg1))) + (set! (-> v0-0 data-array content-type) art-group) + (the-as load-dir-art-group v0-0) + ) + ) + +;; definition of type external-art-buffer +(deftype external-art-buffer (basic) + "An `external-art-buffer` is a buffer that streamed files use." + ((index int32) + (other external-art-buffer) + (status symbol) + (locked? symbol) + (login? symbol) + (frame-lock symbol) + (init-heap (function external-art-buffer object)) + (heap kheap :inline) + (pending-load-file string) + (pending-load-file-part int32) + (pending-load-file-owner handle) + (pending-load-file-priority float) + (load-file string) + (load-file-part int32) + (load-file-owner handle) + (load-file-priority float) + (buf pointer) + (len int32) + (art-group art-group) + (art-data uint32 :overlay-at art-group) + ) + (:methods + (new (symbol type int function symbol) _type_) + (set-pending-file (_type_ string int handle float) int) + (update (_type_) int) + (inactive? (_type_) symbol) + (file-status (_type_ string int) symbol) + (link-file (_type_ art-group) art-group) + (unlink-file (_type_ art-group) int) + (unlock! (_type_) int) + ) + ) + +;; definition for method 3 of type external-art-buffer +(defmethod inspect ((this external-art-buffer)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tother: ~A~%" (-> this other)) + (format #t "~1Tstatus: ~A~%" (-> this status)) + (format #t "~1Tlocked?: ~A~%" (-> this locked?)) + (format #t "~1Tlogin?: ~A~%" (-> this login?)) + (format #t "~1Tframe-lock: ~A~%" (-> this frame-lock)) + (format #t "~1Tinit-heap: ~A~%" (-> this init-heap)) + (format #t "~1Theap: #~%" (-> this heap)) + (format #t "~1Tpending-load-file: ~A~%" (-> this pending-load-file)) + (format #t "~1Tpending-load-file-part: ~D~%" (-> this pending-load-file-part)) + (format #t "~1Tpending-load-file-owner: ~D~%" (-> this pending-load-file-owner)) + (format #t "~1Tpending-load-file-priority: ~f~%" (-> this pending-load-file-priority)) + (format #t "~1Tload-file: ~A~%" (-> this load-file)) + (format #t "~1Tload-file-part: ~D~%" (-> this load-file-part)) + (format #t "~1Tload-file-owner: ~D~%" (-> this load-file-owner)) + (format #t "~1Tload-file-priority: ~f~%" (-> this load-file-priority)) + (format #t "~1Tbuf: #x~X~%" (-> this buf)) + (format #t "~1Tlen: ~D~%" (-> this len)) + (format #t "~1Tart-group: ~A~%" (-> this art-group)) + (format #t "~1Tart-data: #x~X~%" (-> this art-group)) + (label cfg-4) + this + ) + +;; definition for method 0 of type external-art-buffer +(defmethod new external-art-buffer ((allocation symbol) (type-to-make type) (arg0 int) (arg1 function) (arg2 symbol)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 index) arg0) + (set! (-> v0-0 init-heap) (the-as (function external-art-buffer object) arg1)) + (set! (-> v0-0 login?) arg2) + (set! (-> v0-0 load-file) #f) + (set! (-> v0-0 load-file-part) -1) + (set! (-> v0-0 load-file-owner) (the-as handle #f)) + (set! (-> v0-0 load-file-priority) 100000000.0) + (set! (-> v0-0 pending-load-file) #f) + (set! (-> v0-0 pending-load-file-part) -1) + (set! (-> v0-0 pending-load-file-owner) (the-as handle #f)) + (set! (-> v0-0 pending-load-file-priority) 100000000.0) + (set! (-> v0-0 art-group) #f) + (set! (-> v0-0 status) 'initialize) + (set! (-> v0-0 locked?) #f) + (set! (-> v0-0 other) #f) + v0-0 + ) + ) + +;; definition of type spool-anim +(deftype spool-anim (basic) + "A `spool-anim` is metadata for an animation that will be loaded in chunks +to a pair of external-art-buffers." + ((name string :offset 16) + (anim-name string) + (buffer external-art-buffer :overlay-at anim-name) + (parts int32) + (hint-id int32 :overlay-at parts) + (priority float) + (owner handle) + (command-list pair) + ) + ) + +;; definition for method 3 of type spool-anim +(defmethod inspect ((this spool-anim)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tanim-name: ~A~%" (-> this anim-name)) + (format #t "~1Tparts: ~D~%" (-> this parts)) + (format #t "~1Thint-id: ~D~%" (-> this parts)) + (format #t "~1Tpriority: ~f~%" (-> this priority)) + (format #t "~1Towner: ~D~%" (-> this owner)) + (format #t "~1Tcommand-list: ~A~%" (-> this command-list)) + (label cfg-4) + this + ) + +;; definition of type external-art-control +(deftype external-art-control (basic) + "The `external-art-control` manages loading chunks from `spool-anim`s to `external-art-buffer`." + ((buffer external-art-buffer 2) + (rec spool-anim 3 :inline) + (spool-lock handle) + (reserve-buffer external-art-buffer) + (reserve-buffer-count int16) + (dma-reserve-buffer-count int16) + (active-stream string) + (queue-stream (array spool-anim)) + (frame-mask uint32) + (dma-reserve-heap kheap :inline) + ) + (:methods + (new (symbol type) _type_) + (update (_type_ symbol) int) + (clear-rec (_type_) int) + (spool-push (_type_ string int process float) int) + (file-status (_type_ string int) symbol) + (reserve-alloc (_type_) kheap) + (reserve-free (_type_ kheap) int) + (none-reserved? (_type_) symbol) + ) + ) + +;; definition for method 3 of type external-art-control +(defmethod inspect ((this external-art-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tbuffer[2] @ #x~X~%" (-> this buffer)) + (format #t "~1Trec[3] @ #x~X~%" (-> this rec)) + (format #t "~1Tspool-lock: ~D~%" (-> this spool-lock)) + (format #t "~1Treserve-buffer: ~A~%" (-> this reserve-buffer)) + (format #t "~1Treserve-buffer-count: ~D~%" (-> this reserve-buffer-count)) + (format #t "~1Tdma-reserve-buffer-count: ~D~%" (-> this dma-reserve-buffer-count)) + (format #t "~1Tactive-stream: ~A~%" (-> this active-stream)) + (format #t "~1Tqueue-stream: ~A~%" (-> this queue-stream)) + (format #t "~1Tframe-mask: ~D~%" (-> this frame-mask)) + (format #t "~1Tdma-reserve-heap: #~%" (-> this dma-reserve-heap)) + (label cfg-4) + this + ) + +;; definition for method 0 of type external-art-control +(defmethod new external-art-control ((allocation symbol) (type-to-make type)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (dotimes (s4-0 2) + (set! (-> gp-0 buffer s4-0) + ((method-of-type external-art-buffer new) allocation external-art-buffer s4-0 external-art-buffer-init #t) + ) + ) + (set! (-> gp-0 buffer 0 other) (-> gp-0 buffer 1)) + (set! (-> gp-0 buffer 1 other) (-> gp-0 buffer 0)) + (dotimes (v1-9 3) + (set! (-> gp-0 rec v1-9 name) #f) + (set! (-> gp-0 rec v1-9 priority) 100000000.0) + (set! (-> gp-0 rec v1-9 owner) (the-as handle #f)) + ) + (set! (-> gp-0 spool-lock) (the-as handle #f)) + (set! (-> gp-0 reserve-buffer) #f) + (set! (-> gp-0 active-stream) #f) + (set! (-> gp-0 queue-stream) (new 'global 'boxed-array spool-anim 4)) + (dotimes (s5-1 (-> gp-0 queue-stream allocated-length)) + (set! (-> gp-0 queue-stream s5-1) (new 'global 'spool-anim)) + ) + (set! (-> gp-0 queue-stream length) 0) + gp-0 + ) + ) + +;; definition of type subtitle-range +(deftype subtitle-range (basic) + ((start-frame float) + (end-frame float) + (message basic 12) + ) + ) + +;; definition for method 3 of type subtitle-range +(defmethod inspect ((this subtitle-range)) + (when (not this) + (set! this this) + (goto cfg-7) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tstart-frame: ~f~%" (-> this start-frame)) + (format #t "~1Tend-frame: ~f~%" (-> this end-frame)) + (format #t "~1Tmessage[12] @ #x~X~%" (-> this message)) + (dotimes (s5-0 12) + (format #t "~T [~D]~1Tmessage: ~`object`P~%" s5-0 (-> this message s5-0)) + ) + (label cfg-7) + this + ) + +;; definition of type subtitle-image +(deftype subtitle-image (basic) + ((width uint16) + (height uint16) + (palette rgba 16 :offset 16) + (data uint8 :dynamic) + ) + ) + +;; definition for method 3 of type subtitle-image +(defmethod inspect ((this subtitle-image)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Twidth: ~D~%" (-> this width)) + (format #t "~1Theight: ~D~%" (-> this height)) + (format #t "~1Tpalette[16] @ #x~X~%" (-> this palette)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 diff --git a/test/decompiler/reference/jakx/engine/math/euler-h_REF.gc b/test/decompiler/reference/jakx/engine/math/euler-h_REF.gc new file mode 100644 index 0000000000..3c6d139046 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/math/euler-h_REF.gc @@ -0,0 +1,46 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol EulSafe, type (array int32) +(define EulSafe + "Maybe euler angle storage orders? +What is this naming convention?" + (new 'static 'boxed-array :type int32 0 1 2 0) + ) + +;; definition for symbol EulNext, type (array int32) +(define EulNext (new 'static 'boxed-array :type int32 1 2 0 1)) + +;; definition of type euler-angles +(deftype euler-angles (vector) + "Just uses the same xyzw and data array as vector. +The `w` stores an integer that seems to have +bitfields for... something? Like maybe the order? +Euler angles are mostly unused, and the code is a bit of disaster." + () + ) + +;; definition for method 3 of type euler-angles +;; INFO: Used lq/sq +(defmethod inspect ((this euler-angles)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'euler-angles) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tz: ~f~%" (-> this z)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/math/euler_REF.gc b/test/decompiler/reference/jakx/engine/math/euler_REF.gc new file mode 100644 index 0000000000..7785ea189d --- /dev/null +++ b/test/decompiler/reference/jakx/engine/math/euler_REF.gc @@ -0,0 +1,221 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function set-eul! +(defun set-eul! ((arg0 euler-angles) (arg1 float) (arg2 float) (arg3 float) (arg4 int)) + "Set euler angles and the flag bits." + (set! (-> arg0 x) arg1) + (set! (-> arg0 y) arg2) + (set! (-> arg0 z) arg3) + (set! (-> arg0 w) (the float arg4)) + arg0 + ) + +;; definition for function eul->matrix +;; INFO: Used lq/sq +(defun eul->matrix ((arg0 matrix) (arg1 euler-angles)) + "Convert from euler angles to 4x4 matrix." + (matrix-identity! arg0) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 quad) (-> arg1 quad)) + (when (= (logand (the int (-> s5-0 w)) 1) 1) + (let ((f0-2 (-> s5-0 x))) + (set! (-> s5-0 x) (-> s5-0 z)) + (set! (-> s5-0 z) f0-2) + ) + ) + (when (= (logand (/ (the int (-> s5-0 w)) 4) 1) 1) + (set! (-> s5-0 x) (- (-> s5-0 x))) + (set! (-> s5-0 y) (- (-> s5-0 y))) + (set! (-> s5-0 z) (- (-> s5-0 z))) + ) + (let* ((f26-0 (cos (-> s5-0 x))) + (f30-0 (cos (-> s5-0 y))) + (f22-0 (cos (-> s5-0 z))) + (f24-0 (sin (-> s5-0 x))) + (f28-0 (sin (-> s5-0 y))) + (f4-0 (sin (-> s5-0 z))) + (f0-17 (* f26-0 f22-0)) + (f1-1 (* f26-0 f4-0)) + (f2-0 (* f24-0 f22-0)) + (f3-0 (* f24-0 f4-0)) + ) + 0 + 0 + 0 + (let* ((v1-12 (logand (/ (the int (-> s5-0 w)) 4) 1)) + (a1-2 (-> EulSafe (logand (/ (the int (-> s5-0 w)) 8) 3))) + (a0-21 (-> EulNext (+ a1-2 v1-12))) + (v1-17 (-> EulNext (+ (- 1 v1-12) a1-2))) + ) + (cond + ((= (logand (/ (the int (-> s5-0 w)) 2) 1) 1) + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a1-2 4)) (the-as int arg0)))) f30-0) + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a0-21 4)) (the-as int arg0)))) (* f28-0 f24-0)) + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* v1-17 4)) (the-as int arg0)))) (* f28-0 f26-0)) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a1-2 4)) (the-as int arg0)))) (* f28-0 f4-0)) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a0-21 4)) (the-as int arg0)))) + (- f0-17 (* f30-0 f3-0)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* v1-17 4)) (the-as int arg0)))) + (- (- f2-0) (* f30-0 f1-1)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a1-2 4)) (the-as int arg0)))) (- (* f28-0 f22-0))) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a0-21 4)) (the-as int arg0)))) + (+ f1-1 (* f30-0 f2-0)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* v1-17 4)) (the-as int arg0)))) + (+ (- f3-0) (* f30-0 f0-17)) + ) + ) + (else + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a1-2 4)) (the-as int arg0)))) (* f30-0 f22-0)) + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a0-21 4)) (the-as int arg0)))) + (+ (- f1-1) (* f28-0 f2-0)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* v1-17 4)) (the-as int arg0)))) + (+ f3-0 (* f28-0 f0-17)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a1-2 4)) (the-as int arg0)))) (* f30-0 f4-0)) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a0-21 4)) (the-as int arg0)))) + (+ f0-17 (* f28-0 f3-0)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* v1-17 4)) (the-as int arg0)))) + (+ (- f2-0) (* f28-0 f1-1)) + ) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a1-2 4)) (the-as int arg0)))) (- f28-0)) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a0-21 4)) (the-as int arg0)))) (* f30-0 f24-0)) + (set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* v1-17 4)) (the-as int arg0)))) (* f30-0 f26-0)) + ) + ) + ) + ) + ) + arg0 + ) + +;; definition for function matrix->eul +(defun matrix->eul ((arg0 euler-angles) (arg1 matrix) (arg2 int)) + "Convert matrix to euler angles with given order flag. + Not clear how this works if the matrix has more than just a rotation." + 0 + 0 + 0 + (let* ((v1-4 (logand (/ arg2 4) 1)) + (s3-0 (-> EulSafe (logand (/ arg2 8) 3))) + (s2-0 (-> EulNext (+ s3-0 v1-4))) + (s1-0 (-> EulNext (+ (- 1 v1-4) s3-0))) + ) + (cond + ((= (logand (/ arg2 2) 1) 1) + (let ((f30-0 (sqrtf (+ (square (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s3-0 16)) (the-as int arg1))))) + (square (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s3-0 16)) (the-as int arg1))))) + ) + ) + ) + ) + (cond + ((< 0.00000000001 f30-0) + (set! (-> arg0 x) (atan + (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s3-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s3-0 16)) (the-as int arg1)))) + ) + ) + (set! (-> arg0 y) (atan f30-0 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1)))))) + (set! (-> arg0 z) (atan + (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1)))) + (- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))))) + ) + ) + ) + (else + (set! (-> arg0 x) (atan + (- (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s2-0 16)) (the-as int arg1))))) + (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s2-0 16)) (the-as int arg1)))) + ) + ) + (set! (-> arg0 y) (atan f30-0 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1)))))) + (set! (-> arg0 z) 0.0) + ) + ) + ) + ) + (else + (let ((f30-1 (sqrtf (+ (square (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))))) + (square (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1))))) + ) + ) + ) + ) + (cond + ((< 0.00000000001 f30-1) + (set! (-> arg0 x) + (atan + (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s1-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s1-0 16)) (the-as int arg1)))) + ) + ) + (set! (-> arg0 y) + (atan (- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))))) f30-1) + ) + (set! (-> arg0 z) (atan + (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1)))) + ) + ) + ) + (else + (set! (-> arg0 x) + (atan + (- (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s2-0 16)) (the-as int arg1))))) + (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s2-0 16)) (the-as int arg1)))) + ) + ) + (set! (-> arg0 y) + (atan (- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))))) f30-1) + ) + (set! (-> arg0 z) 0.0) + ) + ) + ) + ) + ) + ) + (when (= (logand (/ arg2 4) 1) 1) + (set! (-> arg0 x) (- (-> arg0 x))) + (set! (-> arg0 y) (- (-> arg0 y))) + (set! (-> arg0 z) (- (-> arg0 z))) + ) + (when (= (logand arg2 1) 1) + (let ((f0-49 (-> arg0 x))) + (set! (-> arg0 x) (-> arg0 z)) + (set! (-> arg0 z) f0-49) + ) + ) + (set! (-> arg0 w) (the float arg2)) + arg0 + ) + +;; definition for function eul->quat +(defun eul->quat ((arg0 quaternion) (arg1 euler-angles)) + "Convert euler angles to quaternion, not very efficient." + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (eul->matrix s5-0 arg1) + (matrix->quaternion arg0 s5-0) + ) + arg0 + ) + +;; definition for function quat->eul +(defun quat->eul ((arg0 euler-angles) (arg1 quaternion) (arg2 int)) + "Convert quaternion to euler angles with given order, not very efficient." + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (quaternion->matrix s5-0 arg1) + (matrix->eul arg0 s5-0 arg2) + ) + arg0 + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/math/math_REF.gc b/test/decompiler/reference/jakx/engine/math/math_REF.gc new file mode 100644 index 0000000000..66826ba9e4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/math/math_REF.gc @@ -0,0 +1,765 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function truncate +(defun truncate ((arg0 float)) + "Round (toward zero) to an integer. + @param arg0 float to truncate" + (the float (the int arg0)) + ) + +;; definition for function round +(defun round ((arg0 float)) + "Round to the nearest integer" + (the float (the int (+ 0.5 arg0))) + ) + +;; definition for function floor +(defun floor ((arg0 float)) + "Round (down) to an integer" + (let ((f0-3 (the float (the int arg0)))) + (if (or (>= arg0 0.0) (= arg0 f0-3)) + f0-3 + (+ -1.0 f0-3) + ) + ) + ) + +;; definition for function ceil +(defun ceil ((arg0 float)) + "Round (up) to an integer" + (let ((f0-3 (the float (the int arg0)))) + (if (or (>= 0.0 arg0) (= arg0 f0-3)) + f0-3 + (+ 1.0 f0-3) + ) + ) + ) + +;; definition for function integral? +(defun integral? ((arg0 float)) + "Is this number an integer?" + (= (the float (the int arg0)) arg0) + ) + +;; definition for function fractional-part +(defun fractional-part ((arg0 float)) + "Get the fractional part of a float." + (- arg0 (the float (the int arg0))) + ) + +;; definition for function odd? +(defun odd? ((arg0 int)) + "Is the number odd?" + (= (logand arg0 1) 1) + ) + +;; definition for function even? +(defun even? ((arg0 int)) + "Is the number even?" + (not (odd? arg0)) + ) + +;; definition for function sawtooth-wave +(defun sawtooth-wave ((arg0 float)) + "Sample a sawtooth with period 1. In range (0, 1)" + (let ((f0-2 (- arg0 (the float (the int arg0))))) + (if (< f0-2 0.0) + (set! f0-2 (+ 1.0 f0-2)) + ) + f0-2 + ) + ) + +;; definition for function triangle-wave +(defun triangle-wave ((arg0 float)) + "Sample a triangle wave. Period is 4, in range (-1, 1) (so slope is 1 or -1)." + (let* ((f0-1 (* 0.25 (+ -1.0 arg0))) + (f0-3 (- f0-1 (the float (the int f0-1)))) + ) + (if (< f0-3 0.0) + (set! f0-3 (+ 1.0 f0-3)) + ) + (+ -1.0 (fabs (+ -2.0 (* 4.0 f0-3)))) + ) + ) + +;; definition for function log-x-plus-1-order9 +(defun log-x-plus-1-order9 ((arg0 float)) + "Fast approximation of ln(x + 1). Probably only accurate for x in [0, 1]." + (* arg0 + (+ 1.0 + (* arg0 + (+ -0.5 + (* arg0 + (+ 0.33333334 + (* arg0 + (+ -0.25 (* arg0 (+ 0.2 (* arg0 (+ -0.16666666 (* arg0 (+ 0.14285715 (* arg0 (+ -0.125 (/ arg0 9)))))))))) + ) + ) + ) + ) + ) + ) + ) + ) + +;; definition for function logf +(defun logf ((arg0 float)) + "Natural log." + (let ((v1-1 (the-as int (+ (shr (the-as int arg0) 23) -126))) + (a0-2 (the-as number (logior #x3f000000 (logand (the-as uint #x807fffff) (the-as uint arg0))))) + ) + (when (< (the-as float (gpr->fpr (the-as int a0-2))) 0.70710677) + (set! a0-2 (+ (the-as float (gpr->fpr (the-as int a0-2))) (the-as float (gpr->fpr (the-as int a0-2))))) + (set! v1-1 (the-as int (+ (the-as uint v1-1) -1))) + ) + (let ((f0-5 (+ -1.0 (the-as float (gpr->fpr a0-2))))) + (+ (* f0-5 + (+ 1.0 + (* f0-5 + (+ -0.5 + (* f0-5 + (+ 0.33333334 + (* f0-5 + (+ -0.25 (* f0-5 (+ 0.2 (* f0-5 (+ -0.16666666 (* f0-5 (+ 0.14285715 (* f0-5 (+ -0.125 (/ f0-5 9)))))))))) + ) + ) + ) + ) + ) + ) + ) + (* 0.6931472 (the float v1-1)) + ) + ) + ) + ) + +;; definition for function log2f +(defun log2f ((arg0 float)) + "Log base 2." + (let ((v1-1 (the-as int (+ (shr (the-as int arg0) 23) -126))) + (a0-2 (the-as number (logior #x3f000000 (logand (the-as uint #x807fffff) (the-as uint arg0))))) + ) + (when (< (the-as float (gpr->fpr (the-as int a0-2))) 0.70710677) + (set! a0-2 (+ (the-as float (gpr->fpr (the-as int a0-2))) (the-as float (gpr->fpr (the-as int a0-2))))) + (set! v1-1 (the-as int (+ (the-as uint v1-1) -1))) + ) + (let* ((f0-5 (+ -1.0 (the-as float (gpr->fpr a0-2)))) + (f0-7 + (* f0-5 + (+ 1.0 + (* f0-5 + (+ -0.5 + (* f0-5 + (+ 0.33333334 + (* f0-5 + (+ -0.25 (* f0-5 (+ 0.2 (* f0-5 (+ -0.16666666 (* f0-5 (+ 0.14285715 (* f0-5 (+ -0.125 (/ f0-5 9)))))))))) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (+ (* 1.442695 f0-7) (the float v1-1)) + ) + ) + ) + +;; definition of type float-type +(deftype float-type (uint32) + () + ) + +;; definition for symbol exp-slead, type (pointer float) +(define exp-slead (new 'static 'array float 32 + 1.0 + 1.0218964 + 1.0442734 + 1.0671387 + 1.0905075 + 1.1143799 + 1.1387863 + 1.1637192 + 1.1892014 + 1.2152405 + 1.2418518 + 1.2690506 + 1.2968369 + 1.3252335 + 1.354248 + 1.3839035 + 1.4142075 + 1.4451752 + 1.4768219 + 1.5091629 + 1.5422058 + 1.5759735 + 1.6104889 + 1.645752 + 1.6817856 + 1.7186127 + 1.7562485 + 1.7947083 + 1.8340073 + 1.8741608 + 1.9151993 + 1.9571381 + ) + ) + +;; definition for symbol exp-strail, type (pointer float) +(define exp-strail (new 'static 'array float 32 + 0.0 + 0.0000007863494 + 0.00000040596257 + 0.0000017288019 + 0.00000022534104 + 0.0000068597833 + 0.0000023188388 + 0.0000056815315 + 0.0000057600223 + 0.0000068814647 + 0.000006005433 + 0.0000003590472 + 0.0000027016238 + 0.000003183687 + 0.000007500062 + 0.000006378546 + 0.000006103877 + 0.0000056360786 + 0.0000042465254 + 0.0000015247614 + 0.000005014861 + 0.000007334366 + 0.0000014403477 + 0.000003525029 + 0.000007247011 + 0.000006627224 + 0.0000036862523 + 0.00000082304996 + 0.0000008232258 + 0.0000068675085 + 0.000007281612 + 0.000006062652 + ) + ) + +;; definition for function exp +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function pow +(defun pow ((arg0 float) (arg1 float)) + "Compute arg0^arg1" + (exp (* arg1 (logf arg0))) + ) + +;; definition for function print-exp +;; WARN: Return type mismatch int vs none. +(defun print-exp ((arg0 float)) + "Print in the format AeB where A is in the range (1, 10)" + (let* ((f30-1 (floor (/ (logf (fabs arg0)) (logf 10.0)))) + (f0-4 (pow 10.0 f30-1)) + ) + (format #t "~fe~d" (/ arg0 f0-4) (the int f30-1)) + ) + 0 + (none) + ) + +;; definition of type rgba +(deftype rgba (uint32) + ((r uint8 :offset 0 :size 8) + (g uint8 :offset 8 :size 8) + (b uint8 :offset 16 :size 8) + (a uint8 :offset 24 :size 8) + ) + ) + +;; definition of type xyzw +(deftype xyzw (uint128) + () + ) + +;; definition of type xyzwh +(deftype xyzwh (uint128) + () + ) + +;; definition for function print-time +;; WARN: Return type mismatch int vs none. +(defun print-time ((arg0 object) (arg1 time-frame)) + "Print a [[time-frame]] as h:mm:ss." + 0 + 0 + 0 + (let* ((f0-1 (* 0.0033333334 (the float arg1))) + (a2-0 (the int (/ f0-1 60))) + (f0-2 (- f0-1 (* 60.0 (the float a2-0)))) + (a3-0 (the int f0-2)) + (f0-3 (- f0-2 (the float a3-0))) + (t0-0 (the int (* 100.0 f0-3))) + ) + (format arg0 "~d:~2,'0,d:~2,'0,d" a2-0 a3-0 t0-0) + ) + 0 + (none) + ) + +;; definition for function log2 +;; WARN: Return type mismatch uint vs int. +(defun log2 ((arg0 int)) + "Log base 2." + (the-as int (+ (sar (the-as int (the float arg0)) 23) -127)) + ) + +;; definition for function seek +(defun seek ((arg0 float) (arg1 float) (arg2 float)) + "Move arg0 toward arg1 by at most arg2." + (let ((f2-0 (- arg1 arg0))) + (cond + ((>= arg2 (fabs f2-0)) + arg1 + ) + ((>= f2-0 0.0) + (+ arg0 arg2) + ) + (else + (- arg0 arg2) + ) + ) + ) + ) + +;; definition for function seek-ease +(defun seek-ease ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Move arg0 toward arg1, and slow down before reaching the end. + When farther than arg3 away, move by at most arg2. + When closer than arg3, linearly ramp down the movement amount from arg2 to 0 but no lower than arg4." + (let ((f2-0 (- arg1 arg0))) + (when (>= arg3 (fabs f2-0)) + (set! arg2 (* arg2 (- 1.0 (/ (- arg3 (fabs f2-0)) arg3)))) + (if (< arg2 arg4) + (set! arg2 arg4) + ) + ) + (cond + ((>= arg2 (fabs f2-0)) + arg1 + ) + ((>= f2-0 0.0) + (+ arg0 arg2) + ) + (else + (- arg0 arg2) + ) + ) + ) + ) + +;; definition for function seek-ease-in-out +(defun seek-ease-in-out ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float) (arg5 float) (arg6 float)) + "Move arg0 toward arg2, and slow down at the start and end. + When within arg4 of arg1 (at the beginning of movement), ramp up speed, with a minimum speed of arg6 + When within arg5 of arg2 (at the end of movement), ramp down speed, with a minimum speed of arg5 + Normally, move at most arg3" + (let ((f2-0 (- arg2 arg0))) + (let ((f4-1 (- arg0 arg1))) + (when (>= arg4 (fabs f4-1)) + (set! arg3 (* arg3 (- 1.0 (/ (- arg4 (fabs f4-1)) arg4)))) + (if (< arg3 arg6) + (set! arg3 arg6) + ) + ) + ) + (when (>= arg5 (fabs f2-0)) + (set! arg3 (* arg3 (- 1.0 (/ (- arg5 (fabs f2-0)) arg5)))) + (if (< arg3 arg6) + (set! arg3 arg6) + ) + ) + (cond + ((>= arg3 (fabs f2-0)) + arg2 + ) + ((>= f2-0 0.0) + (+ arg0 arg3) + ) + (else + (- arg0 arg3) + ) + ) + ) + ) + +;; definition for function lerp +(defun lerp ((arg0 float) (arg1 float) (arg2 float)) + "Linearly interpolate between arg0 and arg1." + (+ arg0 (* arg2 (- arg1 arg0))) + ) + +;; definition (debug) for function lerp-scale-old +(defun-debug lerp-scale-old ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Linearly remap arg2 in [arg3, arg4] to [arg0, arg1]. + This is the jak 1 implementation, which I claimed was a bad implementation..." + (let ((f0-1 (fmax 0.0 (fmin 1.0 (/ (- arg2 arg3) (- arg4 arg3)))))) + (+ (* (- 1.0 f0-1) arg0) (* f0-1 arg1)) + ) + ) + +;; definition for function lerp-scale +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f0, f2] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f1, f3] +(defun lerp-scale ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Linearly remap arg2 in [arg3, arg4] to [arg0, arg1]. + More efficient than the -old version." + (local-vars (f0-2 float)) + (let* ((v1-0 1.0) + (f1-0 0.0) + (f0-0 v1-0) + (f4-0 arg2) + (f2-0 arg3) + (f3-0 arg4) + (f1-2 (fmin (fmax (/ (- f4-0 f2-0) (- f3-0 f2-0)) f1-0) f0-0)) + (f0-1 (- f0-0 f1-2)) + (f2-3 arg0) + (f3-1 arg1) + ) + (.mula.s f0-1 f2-3) + (.madd.s f0-2 f1-2 f3-1) + ) + f0-2 + ) + +;; definition for function lerp-scale-clamp +(defun lerp-scale-clamp ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Clamp the input, then linearly remap arg2 in [arg3, arg4] to [arg0, arg1]." + (let ((a2-1 (fmax (fmin arg2 arg4) arg3))) + (lerp-scale arg0 arg1 a2-1 arg3 arg4) + ) + ) + +;; definition for function lerp-clamp +(defun lerp-clamp ((arg0 float) (arg1 float) (arg2 float)) + "Linearly interpolate between arg0 and arg1. arg2 is clamped to [0, 1]" + (cond + ((>= 0.0 arg2) + arg0 + ) + ((>= arg2 1.0) + arg1 + ) + (else + (+ (* (- 1.0 arg2) arg0) (* arg2 arg1)) + ) + ) + ) + +;; definition for function rgba-lerp +;; WARN: Return type mismatch int vs rgba. +(defun rgba-lerp ((arg0 rgba) (arg1 rgba) (arg2 rgba)) + (local-vars + (v0-0 uint128) + (v1-0 uint128) + (v1-1 uint128) + (a0-1 uint128) + (a0-2 uint128) + (a1-1 uint128) + (a2-1 uint128) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.pextlb v1-0 0 arg0) + (.pextlb a0-1 0 arg1) + (.pextlh v1-1 0 v1-0) + (.pextlh a0-2 0 a0-1) + (.mov vf1 v1-1) + (.mov vf2 a0-2) + (.mov vf3 arg2) + (.itof.vf vf1 vf1) + (.itof.vf vf2 vf2) + (.mul.w.vf acc vf1 vf0) + (.add.mul.x.vf acc vf2 vf3 acc) + (.sub.mul.x.vf vf1 vf1 vf3 acc) + (.ftoi.vf vf3 vf1) + (.mov a1-1 vf3) + (.ppach a2-1 (the-as uint128 0) a1-1) + (.ppacb v0-0 (the-as uint128 0) a2-1) + (the-as rgba v0-0) + ) + ) + +;; definition for function seekl +(defun seekl ((arg0 int) (arg1 int) (arg2 int)) + "Move arg0 toward arg1, by at most arg2." + (let* ((v1-0 (- arg1 arg0)) + (a3-0 (abs v1-0)) + ) + (cond + ((>= arg2 a3-0) + arg1 + ) + ((>= v1-0 0) + (+ arg0 arg2) + ) + (else + (- arg0 arg2) + ) + ) + ) + ) + +;; definition for function rand-vu-init +;; WARN: Return type mismatch int vs float. +;; ERROR: Unsupported inline assembly instruction kind - [ctc2.i vi_R, a0] +;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v0, vi_R] +(defun rand-vu-init ((arg0 float)) + "Initialize the VU0 random generator." + (local-vars (v0-0 int)) + (.ctc2.i vi_R arg0) + (.cfc2.i v0-0 vi_R) + (the-as float v0-0) + ) + +;; failed to figure out what this is: +(rand-vu-init 1.418091) + +;; definition for function rand-vu +;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRGET] +;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRXOR] +;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRNEXT] +(defun rand-vu () + "Get a random number in [0, 1) and advance the random generator." + (local-vars (v0-0 float)) + (rlet ((Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (TODO.VRGET vf1) + (.sqrt.vf Q vf1 :ftf #b0) + (.add.vf.x vf2 vf0 Q) + (TODO.VRXOR vf2) + (TODO.VRNEXT vf1) + (.sub.w.vf vf1 vf1 vf0) + (.mov v0-0 vf1) + v0-0 + ) + ) + +;; definition for function rand-vu-nostep +;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRGET] +(defun rand-vu-nostep () + "Get the number currently in the random generator. + This will be equal to the last call of (rand-vu). + This will not update the random generator." + (local-vars (v0-0 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + ) + (init-vf0-vector) + (TODO.VRGET vf1) + (.sub.w.vf vf1 vf1 vf0) + (.mov v0-0 vf1) + v0-0 + ) + ) + +;; definition for function rand-vu-float-range +(defun rand-vu-float-range ((arg0 float) (arg1 float)) + "Get a random float in between arg0 and arg1." + (+ arg0 (* (rand-vu) (- arg1 arg0))) + ) + +;; definition for function rand-vu-percent? +(defun rand-vu-percent? ((arg0 float)) + "Get a boolean that's true with the given probability (in 0, 1)." + (>= arg0 (rand-vu)) + ) + +;; definition for function rand-vu-int-range +(defun rand-vu-int-range ((arg0 int) (arg1 int)) + "Get an integer in the given range (inclusive)." + (if (< arg0 arg1) + (set! arg1 (+ arg1 1)) + (set! arg0 (+ arg0 1)) + ) + (let ((f0-4 (rand-vu-float-range (the float arg0) (the float arg1)))) + (if (< f0-4 0.0) + (set! f0-4 (+ -1.0 f0-4)) + ) + (the int f0-4) + ) + ) + +;; definition for function rand-vu-int-count +(defun rand-vu-int-count ((arg0 int)) + "Get an integer in the range [0, max)." + (the int (* (rand-vu) (the float arg0))) + ) + +;; definition for function rand-vu-int-count-excluding +;; WARN: new jak 2 until loop case, check carefully +(defun rand-vu-int-count-excluding ((arg0 int) (arg1 int)) + "Get an integer in the range [0, arg0). + If bit n is set in arg1, exclude this value from being returned." + (let ((s4-0 0) + (s5-0 0) + ) + (let ((v1-0 1)) + (while (nonzero? arg0) + (+! arg0 -1) + (if (not (logtest? arg1 v1-0)) + (+! s4-0 1) + ) + (set! v1-0 (* v1-0 2)) + ) + ) + (when (> s4-0 0) + (let ((v1-4 (the int (* (rand-vu) (the float s4-0)))) + (a0-1 1) + ) + (until #f + (while (logtest? arg1 a0-1) + (nop!) + (nop!) + (+! s5-0 1) + (set! a0-1 (* a0-1 2)) + ) + (if (zero? v1-4) + (goto cfg-14) + ) + (+! v1-4 -1) + (+! s5-0 1) + (set! a0-1 (* a0-1 2)) + ) + ) + #f + ) + (label cfg-14) + s5-0 + ) + ) + +;; definition for function rand-vu-int-range-exclude +;; WARN: new jak 2 until loop case, check carefully +(defun rand-vu-int-range-exclude ((arg0 int) (arg1 int) (arg2 int)) + "Get an integer in the range [0, arg0), excluding arg2. + Note that this doesn't use bits like rand-vu-int-count-excluding." + (until #f + (let ((v1-0 (rand-vu-int-range arg0 arg1))) + (if (!= v1-0 arg2) + (return v1-0) + ) + ) + ) + (the-as int #f) + ) + +;; definition of type random-generator +(deftype random-generator (basic) + ((seed uint32) + ) + ) + +;; definition for method 3 of type random-generator +(defmethod inspect ((this random-generator)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tseed: ~D~%" (-> this seed)) + (label cfg-4) + this + ) + +;; definition for symbol *random-generator*, type random-generator +(define *random-generator* (new 'global 'random-generator)) + +;; failed to figure out what this is: +(set! (-> *random-generator* seed) (the-as uint #x666edd1e)) + +;; definition for function rand-uint31-gen +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function cube-root +(defun cube-root ((arg0 float)) + "Cube root with cool trick that I don't understand." + (cond + ((!= arg0 0.0) + (let* ((v1-0 arg0) + (a1-2 (+ (logand (shr (the-as int v1-0) 23) 255) -127)) + (f0-1 + (the-as + number + (gpr->fpr + (logior (logand (the-as uint #x807fffff) (the-as uint v1-0)) (shl (+ (/ (the-as int a1-2) 3) 127) 23)) + ) + ) + ) + ) + (dotimes (v1-3 6) + (set! f0-1 + (- (the-as float f0-1) (/ (- (* (the-as float (square (the-as float f0-1))) (the-as float f0-1)) arg0) + (* 3.0 (the-as float f0-1) (the-as float f0-1)) + ) + ) + ) + ) + (the-as float f0-1) + ) + ) + (else + 0.0 + ) + ) + ) + +;; definition for function int-noise +(defun int-noise ((arg0 int)) + "Generate random-ish floats in range -1, 1." + (let ((v1-1 (logxor (shl arg0 13) arg0))) + (- 1.0 (* 0.0000000009313226 + (the float (logand #x7fffffff (+ #x5208dd0d (* v1-1 (+ #xc0ae5 (* (* #x3d73 v1-1) v1-1)))))) + ) + ) + ) + ) + +;; definition for function smooth-step +(defun smooth-step ((arg0 float)) + "Interpolate between 0, 1 with a cubic polynomial. + These are picked so f(0) = 0, f(1) = 1, f'(0) = f'(1) = 0." + (cond + ((>= 0.0 arg0) + 0.0 + ) + ((>= arg0 1.0) + 1.0 + ) + (else + (* arg0 arg0 (+ 3.0 (* -2.0 arg0))) + ) + ) + ) + +;; definition for function smooth-interp +(defun smooth-interp ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Remap arg2 from (arg3, arg4) to (arg0, arg1), using cubic interpolation. + Satisfies: + - f(arg3) = arg0 + - f(arg4) = arg1 + - f'(arg3) = f'(arg4) = 0" + (+ arg0 (* (- arg1 arg0) (smooth-step (/ (- arg2 arg3) (- arg4 arg3))))) + ) diff --git a/test/decompiler/reference/jakx/engine/math/matrix-h_REF.gc b/test/decompiler/reference/jakx/engine/math/matrix-h_REF.gc new file mode 100644 index 0000000000..9208b55154 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/math/matrix-h_REF.gc @@ -0,0 +1,142 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type matrix +(deftype matrix (structure) + "A 4x4 matrix, stored in row-major order. +some, but not all, functions assume that a matrix is an affine transform. +others assume that the rotation has no scale or shear (and that its inverse is its transpose)." + ((data float 16) + (vector vector 4 :inline :overlay-at (-> data 0)) + (quad uint128 4 :overlay-at (-> data 0)) + (rvec vector :inline :overlay-at (-> data 0)) + (uvec vector :inline :overlay-at (-> data 4)) + (fvec vector :inline :overlay-at (-> data 8)) + (trans vector :inline :overlay-at (-> data 12)) + ) + (:methods + (transform-vectors! (_type_ (inline-array vector) (inline-array vector) int) none) + ) + ) + +;; definition for method 3 of type matrix +(defmethod inspect ((this matrix)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'matrix) + (format #t "~1Tdata[16] @ #x~X~%" (-> this rvec)) + (format #t "~1Tvector[4] @ #x~X~%" (-> this rvec)) + (format #t "~1Tquad[4] @ #x~X~%" (-> this rvec)) + (format #t "~1Trvec: #~%" (-> this rvec)) + (format #t "~1Tuvec: #~%" (-> this uvec)) + (format #t "~1Tfvec: #~%" (-> this fvec)) + (format #t "~1Ttrans: #~%" (-> this trans)) + (label cfg-4) + this + ) + +;; definition of type matrix3 +(deftype matrix3 (structure) + "A 3x3 matrix, stored in row-major order. +NOTE: the rows each have an extra 4-bytes of padding, +so this is really a 3x4 matrix. +This type is rarely used." + ((data float 12) + (vector vector 3 :inline :overlay-at (-> data 0)) + (quad uint128 3 :overlay-at (-> data 0)) + ) + ) + +;; definition for method 3 of type matrix3 +(defmethod inspect ((this matrix3)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'matrix3) + (format #t "~1Tdata[12] @ #x~X~%" (-> this vector)) + (format #t "~1Tvector[3] @ #x~X~%" (-> this vector)) + (format #t "~1Tquad[3] @ #x~X~%" (-> this vector)) + (label cfg-4) + this + ) + +;; definition of type matrix4h +(deftype matrix4h (structure) + "A matrix stored using 16-bit integers. +Note that these usually have different scaling for the 4th row which +contains the translation in an affine transform. +So you generally should not unpack these to floats without knowing where they came from +and how they were originally packed (for example, in tie/shrub)." + ((data int16 16) + (vector4h vector4h 4 :overlay-at (-> data 0)) + (long int64 4 :overlay-at (-> data 0)) + ) + ) + +;; definition for method 3 of type matrix4h +(defmethod inspect ((this matrix4h)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'matrix4h) + (format #t "~1Tdata[16] @ #x~X~%" (-> this vector4h)) + (format #t "~1Tvector4h[4] @ #x~X~%" (-> this vector4h)) + (format #t "~1Tlong[4] @ #x~X~%" (-> this vector4h)) + (label cfg-4) + this + ) + +;; definition for function matrix-copy! +;; INFO: Used lq/sq +(defun matrix-copy! ((arg0 matrix) (arg1 matrix)) + "Copy arg1 to arg0" + (matrix-copy! arg0 arg1) + arg0 + ) + +;; definition for function matrix<-vector-yz-exact! +;; INFO: Used lq/sq +(defun matrix<-vector-yz-exact! ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (set! (-> arg0 uvec quad) (-> arg2 quad)) + (vector-cross! (-> arg0 rvec) (-> arg0 uvec) arg1) + arg0 + ) + +;; definition for function matrix<-vector-yz! +;; INFO: Used lq/sq +(defun matrix<-vector-yz! ((arg0 matrix) (arg1 vector) (arg2 vector)) + (set! (-> arg0 fvec quad) (-> arg1 quad)) + (vector-cross! (-> arg0 rvec) arg2 arg1) + (vector-normalize! (-> arg0 rvec) 1.0) + (vector-cross! (-> arg0 uvec) arg1 (-> arg0 rvec)) + (set! (-> arg0 rvec w) 1.0) + (set! (-> arg0 uvec w) 1.0) + (set! (-> arg0 fvec w) 1.0) + arg0 + ) + +;; definition for function matrix<-vector-z! +;; INFO: Used lq/sq +(defun matrix<-vector-z! ((arg0 matrix) (arg1 vector)) + (let* ((s3-0 (new 'stack-no-clear 'vector)) + (v1-0 (vector-get-closest-perpendicular! s3-0 arg1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1))) + (s4-1 arg0) + ) + (set! (-> s4-1 fvec quad) (-> arg1 quad)) + (set! (-> s4-1 uvec quad) (-> v1-0 quad)) + (vector-cross! (-> s4-1 rvec) (-> s4-1 uvec) arg1) + ) + arg0 + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/math/quaternion-h_REF.gc b/test/decompiler/reference/jakx/engine/math/quaternion-h_REF.gc new file mode 100644 index 0000000000..663d685dd2 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/math/quaternion-h_REF.gc @@ -0,0 +1,44 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type quaternion +(deftype quaternion (structure) + "Quaternion. Stored in xyzw order." + ((data float 4) + (x float :overlay-at (-> data 0)) + (y float :overlay-at (-> data 1)) + (z float :overlay-at (-> data 2)) + (w float :overlay-at (-> data 3)) + (vec vector :inline :overlay-at (-> data 0)) + (quad uint128 :overlay-at (-> data 0)) + ) + ) + +;; definition for method 3 of type quaternion +;; INFO: Used lq/sq +(defmethod inspect ((this quaternion)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'quaternion) + (format #t "~1Tdata[4] @ #x~X~%" (&-> this x)) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tz: ~f~%" (-> this z)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tvec: #~%" (&-> this x)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (label cfg-4) + this + ) + +;; definition for symbol *unity-quaternion*, type quaternion +(define *unity-quaternion* (new 'static 'quaternion :w 1.0)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/math/quaternion_REF.gc b/test/decompiler/reference/jakx/engine/math/quaternion_REF.gc new file mode 100644 index 0000000000..3f122ef764 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/math/quaternion_REF.gc @@ -0,0 +1,1096 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 3 of type quaternion +(defmethod inspect ((this quaternion)) + (format #t "[~8x] quaternion~%" this) + (format #t "~T[~F] [~F] [~F] [~F]~%" (-> this x) (-> this y) (-> this z) (-> this w)) + (let ((f0-5 (/ 1.0 (sqrtf (+ (* (-> this x) (-> this x)) (* (-> this y) (-> this y)) (* (-> this z) (-> this z)))))) + ) + (format #t "~Taxis: ~F ~F ~F" (* f0-5 (-> this x)) (* f0-5 (-> this y)) (* f0-5 (-> this z))) + ) + (let ((f0-9 (* 2.0 (acos (-> this w))))) + (format #t "~T~Tangle: (deg ~R)~%" f0-9) + ) + (format #t "~T(static-quaternion ~f ~f ~f ~f)~%" (-> this x) (-> this y) (-> this z) (-> this w)) + this + ) + +;; definition for function quaternion-axis-angle! +(defun quaternion-axis-angle! ((arg0 quaternion) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Construct a quaternion from an axis and angle. The axis should be normalized." + (let ((s5-0 (new 'stack-no-clear 'vector))) + (sincos! s5-0 (/ arg4 2)) + (let ((f0-2 (-> s5-0 x))) + (set! (-> arg0 x) (* arg1 f0-2)) + (set! (-> arg0 y) (* arg2 f0-2)) + (set! (-> arg0 z) (* arg3 f0-2)) + ) + (set! (-> arg0 w) (-> s5-0 y)) + ) + arg0 + ) + +;; definition for function quaternion-vector-angle! +(defun quaternion-vector-angle! ((arg0 quaternion) (arg1 vector) (arg2 float)) + "Construct a quaternion from an axis and angle. The axis should be normalized." + (let ((s5-0 (new 'stack-no-clear 'vector))) + (sincos! s5-0 (/ arg2 2)) + (let ((f0-2 (-> s5-0 x))) + (set! (-> arg0 x) (* (-> arg1 x) f0-2)) + (set! (-> arg0 y) (* (-> arg1 y) f0-2)) + (set! (-> arg0 z) (* (-> arg1 z) f0-2)) + ) + (set! (-> arg0 w) (-> s5-0 y)) + ) + arg0 + ) + +;; definition for function vector-angle<-quaternion! +(defun vector-angle<-quaternion! ((arg0 vector) (arg1 quaternion)) + "Convert the quaternion arg1 to axis-angle form and store in arg0 (angle goes in w)" + (let ((f30-0 (/ 1.0 (sqrtf (- 1.0 (square (-> arg1 w)))))) + (f0-3 (* 2.0 (acos-rad (-> arg1 w)))) + ) + (set! (-> arg0 x) (* (-> arg1 x) f30-0)) + (set! (-> arg0 y) (* (-> arg1 y) f30-0)) + (set! (-> arg0 z) (* (-> arg1 z) f30-0)) + (set! (-> arg0 w) f0-3) + ) + arg0 + ) + +;; definition for function quaternion-look-at! +;; INFO: Used lq/sq +(defun quaternion-look-at! ((arg0 quaternion) (arg1 vector) (arg2 vector)) + "Look along arg1, with arg2 as up." + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (vector-cross! (-> s5-0 rvec) arg2 arg1) + (vector-cross! (-> s5-0 uvec) arg1 (-> s5-0 rvec)) + (set! (-> s5-0 fvec quad) (-> arg1 quad)) + (quaternion-normalize! (matrix->quaternion arg0 s5-0)) + ) + ) + +;; definition for function quaternion-zero! +;; INFO: Used lq/sq +(defun quaternion-zero! ((arg0 quaternion)) + "Set quaternion to all 0's." + (set! (-> arg0 quad) (the-as uint128 0)) + arg0 + ) + +;; definition for function quaternion-identity! +;; INFO: Used lq/sq +(defun quaternion-identity! ((arg0 quaternion)) + "Set quaternion to 0,0,0,1 (identity)." + (set! (-> arg0 quad) (the-as uint128 0)) + (set! (-> arg0 w) 1.0) + arg0 + ) + +;; definition for function quaternion-i! +;; INFO: Used lq/sq +(defun quaternion-i! ((arg0 quaternion)) + "Create unit i quaternion." + (set! (-> arg0 quad) (the-as uint128 0)) + (set! (-> arg0 x) 1.0) + arg0 + ) + +;; definition for function quaternion-j! +;; INFO: Used lq/sq +(defun quaternion-j! ((arg0 quaternion)) + "Create unit j quaternion." + (set! (-> arg0 quad) (the-as uint128 0)) + (set! (-> arg0 y) 1.0) + arg0 + ) + +;; definition for function quaternion-k! +;; INFO: Used lq/sq +(defun quaternion-k! ((arg0 quaternion)) + "Create unit k quaternion." + (set! (-> arg0 quad) (the-as uint128 0)) + (set! (-> arg0 z) 1.0) + arg0 + ) + +;; definition for function quaternion-copy! +;; INFO: Used lq/sq +(defun quaternion-copy! ((arg0 quaternion) (arg1 quaternion)) + "Set arg0 = arg1." + (set! (-> arg0 quad) (-> arg1 quad)) + arg0 + ) + +;; definition for function quaternion-set! +(defun quaternion-set! ((arg0 quaternion) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Set arg0 = [arg1, arg2, arg3, arg4]." + (set! (-> arg0 x) arg1) + (set! (-> arg0 y) arg2) + (set! (-> arg0 z) arg3) + (set! (-> arg0 w) arg4) + arg0 + ) + +;; definition for function quaternion+! +(defun quaternion+! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion)) + "Add quaternions as vectors." + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.add.vf vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function quaternion-! +(defun quaternion-! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion)) + "Subtract quaternions as vectors." + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.sub.vf vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function quaternion-negate! +;; ERROR: Bad vector register dependency: vf2 +(defun quaternion-negate! ((arg0 quaternion) (arg1 quaternion)) + "Set arg0 = -arg1." + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.sub.vf vf2 vf2 vf2) + (.sub.vf vf1 vf2 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function quaternion-conjugate! +;; ERROR: Bad vector register dependency: vf2 +(defun quaternion-conjugate! ((arg0 quaternion) (arg1 quaternion)) + "Set arg0 to the conjugate of arg1 (negate only ijk). + If arg1 is normalized, this is equivalent to the inverse + NOTE: this gives you the inverse rotation." + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.sub.vf vf2 vf2 vf2) + (.sub.vf.xyz vf2 vf2 vf1) + (.add.vf.w vf2 vf2 vf1) + (.svf (&-> arg0 quad) vf2) + arg0 + ) + ) + +;; definition for function quaternion-float*! +(defun quaternion-float*! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Multiply each element." + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.mov vf2 arg2) + (.mul.x.vf vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function quaternion-float/! +(defun quaternion-float/! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Divide each element." + (let ((f0-1 (/ 1.0 arg2))) + (quaternion-float*! arg0 arg1 f0-1) + ) + arg0 + ) + +;; definition for function quaternion-norm2 +(defun quaternion-norm2 ((arg0 quaternion)) + "Get the squared norm of a quaternion." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.mul.vf vf1 vf1 vf1) + (.add.z.vf.w acc vf1 vf1) + (.add.mul.y.vf.w acc vf0 vf1 acc) + (.add.mul.x.vf.w vf1 vf0 vf1 acc) + (.add.w.vf vf1 vf0 vf1) + (.mov v0-0 vf1) + v0-0 + ) + ) + +;; definition for function quaternion-norm +(defun quaternion-norm ((arg0 quaternion)) + "Get the norm of a quaternion." + (local-vars (v1-1 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.mul.vf vf1 vf1 vf1) + (.add.z.vf.w acc vf1 vf1) + (.add.mul.y.vf.w acc vf0 vf1 acc) + (.add.mul.x.vf.w vf1 vf0 vf1 acc) + (.add.w.vf vf1 vf0 vf1) + (.mov v1-1 vf1) + (sqrtf v1-1) + ) + ) + +;; definition for function quaternion-normalize! +(defun quaternion-normalize! ((arg0 quaternion)) + "Normalize a quaternion." + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.mul.vf vf2 vf1 vf1) + (.add.z.vf.w acc vf2 vf2) + (.add.mul.y.vf.w acc vf0 vf2 acc) + (.add.mul.x.vf.w vf2 vf0 vf2 acc) + (.isqrt.vf Q vf0 vf2 :fsf #b11 :ftf #b11) + (.wait.vf) + (.mul.vf vf2 vf1 Q) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf2) + arg0 + ) + ) + +;; definition for function quaternion-inverse! +;; ERROR: Bad vector register dependency: vf3 +(defun quaternion-inverse! ((arg0 quaternion) (arg1 quaternion)) + "Invert a quaternion. The inverse will satisfy q * q^-1 = identity, even if q is not normalized. + If your quaternion is normalized, it is faster/more accurate to do quaternion-conjugate!" + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.mul.vf vf2 vf1 vf1) + (.sub.vf vf3 vf3 vf3) + (.add.z.vf.w acc vf2 vf2) + (.add.mul.y.vf.w acc vf0 vf2 acc) + (.add.mul.x.vf.w vf2 vf0 vf2 acc) + (.sub.vf.xyz vf3 vf3 vf1) + (.div.vf Q vf0 vf2 :fsf #b11 :ftf #b11) + (.add.vf.w vf3 vf3 vf1) + (.wait.vf) + (.mul.vf vf3 vf3 Q) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf3) + arg0 + ) + ) + +;; definition for function quaternion-dot +(defun quaternion-dot ((arg0 quaternion) (arg1 quaternion)) + "Treat quaternions as vectors and take the dot product." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.lvf vf2 (&-> arg1 quad)) + (.mul.vf vf1 vf1 vf2) + (.add.z.vf.w acc vf1 vf1) + (.add.mul.y.vf.w acc vf0 vf1 acc) + (.add.mul.x.vf.w vf1 vf0 vf1 acc) + (.add.w.vf vf1 vf0 vf1) + (.mov v0-0 vf1) + v0-0 + ) + ) + +;; definition for function quaternion*! +(defun quaternion*! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion)) + "Real quaternion multiplication." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.sub.vf.w vf4 vf0 vf0) + (.mul.vf vf3 vf1 vf2) + (.outer.product.a.vf acc vf1 vf2) + (.outer.product.b.vf vf4 vf2 vf1 acc) + (.mul.w.vf acc vf1 vf2) + (.add.mul.w.vf acc vf2 vf1 acc) + (.sub.mul.w.vf.w acc vf0 vf3 acc) + (.sub.mul.z.vf.w acc vf0 vf3 acc) + (.sub.mul.y.vf.w acc vf0 vf3 acc) + (.sub.mul.x.vf.w acc vf0 vf3 acc) + (.add.mul.w.vf vf1 vf4 vf0 acc) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function quaternion-right-mult-matrix! +(defun quaternion-right-mult-matrix! ((arg0 matrix) (arg1 quaternion)) + "Place quaternion coefficients into a matrix. + You can convert a quaternion to a matrix by taking the product of this + right-mult and left-mult matrix, but this method is not used. + Instead, quaternion->matrix is a more efficient implementation." + (let ((f3-0 (-> arg1 x)) + (f2-0 (-> arg1 y)) + (f1-0 (-> arg1 z)) + (f0-0 (-> arg1 w)) + ) + (set! (-> arg0 rvec x) f0-0) + (set! (-> arg0 rvec y) f1-0) + (set! (-> arg0 rvec z) (- f2-0)) + (set! (-> arg0 rvec w) f3-0) + (set! (-> arg0 uvec x) (- f1-0)) + (set! (-> arg0 uvec y) f0-0) + (set! (-> arg0 uvec z) f3-0) + (set! (-> arg0 uvec w) f2-0) + (set! (-> arg0 fvec x) f2-0) + (set! (-> arg0 fvec y) (- f3-0)) + (set! (-> arg0 fvec z) f0-0) + (set! (-> arg0 fvec w) f1-0) + (set! (-> arg0 trans x) (- f3-0)) + (set! (-> arg0 trans y) (- f2-0)) + (set! (-> arg0 trans z) (- f1-0)) + (set! (-> arg0 trans w) f0-0) + ) + arg0 + ) + +;; definition for function quaternion-left-mult-matrix! +(defun quaternion-left-mult-matrix! ((arg0 matrix) (arg1 quaternion)) + "Place quaternion coefficients into a matrix. Unused." + (let ((f2-0 (-> arg1 x)) + (f1-0 (-> arg1 y)) + (f0-0 (-> arg1 z)) + ) + (let ((f3-0 (-> arg1 w))) + (set! (-> arg0 rvec x) f2-0) + (set! (-> arg0 rvec y) f3-0) + (set! (-> arg0 rvec z) (- f0-0)) + (set! (-> arg0 rvec w) f1-0) + (set! (-> arg0 uvec x) f1-0) + (set! (-> arg0 uvec y) f0-0) + (set! (-> arg0 uvec z) f3-0) + (set! (-> arg0 uvec w) (- f3-0)) + (set! (-> arg0 fvec x) f0-0) + (set! (-> arg0 fvec y) (- f1-0)) + (set! (-> arg0 fvec z) f2-0) + (set! (-> arg0 fvec w) f3-0) + (set! (-> arg0 trans x) f3-0) + ) + (set! (-> arg0 trans y) (- f2-0)) + (set! (-> arg0 trans z) (- f1-0)) + (set! (-> arg0 trans w) (- f0-0)) + ) + arg0 + ) + +;; definition for function quaternion->matrix +(defun quaternion->matrix ((arg0 matrix) (arg1 quaternion)) + "Convert quaternion to matrix." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.add.vf vf5 vf1 vf1) + (.add.w.vf.x vf2 vf0 vf1) + (.add.z.vf.y vf2 vf0 vf1) + (.sub.y.vf.z vf2 vf0 vf1) + (.sub.w.vf.w vf2 vf0 vf0) + (.sub.z.vf.x vf3 vf0 vf1) + (.add.w.vf.y vf3 vf0 vf1) + (.add.x.vf.z vf3 vf0 vf1) + (.sub.w.vf.w vf3 vf0 vf0) + (.add.y.vf.x vf4 vf0 vf1) + (.sub.x.vf.y vf4 vf0 vf1) + (.add.w.vf.z vf4 vf0 vf1) + (.sub.w.vf.w vf4 vf0 vf0) + (.outer.product.a.vf acc vf5 vf2) + (.outer.product.b.vf vf2 vf2 vf5 acc) + (.outer.product.a.vf acc vf5 vf3) + (.outer.product.b.vf vf3 vf3 vf5 acc) + (.outer.product.a.vf acc vf5 vf4) + (.outer.product.b.vf vf4 vf4 vf5 acc) + (.add.w.vf.x vf2 vf2 vf0) + (.add.w.vf.y vf3 vf3 vf0) + (.add.w.vf.z vf4 vf4 vf0) + (.svf (&-> arg0 trans quad) vf0) + (.svf (&-> arg0 rvec quad) vf2) + (.svf (&-> arg0 uvec quad) vf3) + (.svf (&-> arg0 fvec quad) vf4) + arg0 + ) + ) + +;; definition for function quaternion->matrix-2 +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function matrix->quaternion +(defun matrix->quaternion ((arg0 quaternion) (arg1 matrix)) + "Convert a rotation matrix to a quaternion." + (let ((f0-2 (+ (-> arg1 rvec x) (-> arg1 uvec y) (-> arg1 fvec z)))) + (cond + ((< 0.0 f0-2) + (let ((f0-4 (sqrtf (+ 1.0 f0-2)))) + (set! (-> arg0 w) (/ f0-4 2)) + (let ((f0-5 (/ 0.5 f0-4))) + (set! (-> arg0 x) (* f0-5 (- (-> arg1 uvec z) (-> arg1 fvec y)))) + (set! (-> arg0 y) (* f0-5 (- (-> arg1 fvec x) (-> arg1 rvec z)))) + (set! (-> arg0 z) (* f0-5 (- (-> arg1 rvec y) (-> arg1 uvec x)))) + ) + ) + ) + (else + (let ((a2-0 0) + (a3-0 1) + (v1-4 2) + ) + (when (< (-> arg1 rvec x) (-> arg1 uvec y)) + (set! a2-0 1) + (set! a3-0 2) + (set! v1-4 0) + ) + (when (< (-> (the-as (pointer float) (+ (+ (* a2-0 4) (* a2-0 16)) (the-as int arg1)))) (-> arg1 fvec z)) + (set! a2-0 2) + (set! a3-0 0) + (set! v1-4 1) + ) + (let ((f0-12 + (sqrtf + (+ (- 1.0 + (+ (-> (the-as (pointer float) (+ (+ (* a3-0 4) (* a3-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* v1-4 4) (* v1-4 16)) (the-as int arg1)))) + ) + ) + (-> (the-as (pointer float) (+ (+ (* a2-0 4) (* a2-0 16)) (the-as int arg1)))) + ) + ) + ) + ) + (set! (-> arg0 vec data a2-0) (/ f0-12 2)) + (if (!= f0-12 0.0) + (set! f0-12 (/ 0.5 f0-12)) + ) + (set! (-> arg0 w) + (* (- (-> (the-as (pointer float) (+ (+ (* v1-4 4) (* a3-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* a3-0 4) (* v1-4 16)) (the-as int arg1)))) + ) + f0-12 + ) + ) + (set! (-> arg0 vec data a3-0) + (* (+ (-> (the-as (pointer float) (+ (+ (* a3-0 4) (* a2-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* a2-0 4) (* a3-0 16)) (the-as int arg1)))) + ) + f0-12 + ) + ) + (set! (-> arg0 vec data v1-4) + (* (+ (-> (the-as (pointer float) (+ (+ (* v1-4 4) (* a2-0 16)) (the-as int arg1)))) + (-> (the-as (pointer float) (+ (+ (* a2-0 4) (* v1-4 16)) (the-as int arg1)))) + ) + f0-12 + ) + ) + ) + ) + ) + ) + ) + arg0 + ) + +;; definition for function matrix-with-scale->quaternion +;; INFO: Used lq/sq +(defun matrix-with-scale->quaternion ((arg0 quaternion) (arg1 matrix)) + "Convert a matrix with a rotation and scale into a quaternion (just the rotation)." + (local-vars (a1-4 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (let ((v1-0 (new-stack-matrix0))) + (let* ((f0-1 (vector-dot (-> arg1 rvec) (-> arg1 rvec))) + (f1-1 (vector-dot (-> arg1 uvec) (-> arg1 uvec))) + (f2-1 (vector-dot (-> arg1 fvec) (-> arg1 fvec))) + (f0-3 (/ 1.0 (sqrtf f0-1))) + (f1-3 (/ 1.0 (sqrtf f1-1))) + (f2-3 (/ 1.0 (sqrtf f2-1))) + ) + (.lvf vf1 (&-> arg1 rvec quad)) + (.lvf vf2 (&-> arg1 uvec quad)) + (.lvf vf3 (&-> arg1 fvec quad)) + (.lvf vf4 (&-> arg1 trans quad)) + (let ((a1-1 f0-3)) + (.mov vf5 a1-1) + ) + (let ((a1-2 f1-3)) + (.mov vf6 a1-2) + ) + (let ((a1-3 f2-3)) + (.mov vf7 a1-3) + ) + ) + (.mul.x.vf vf1 vf1 vf5) + (.mul.x.vf vf2 vf2 vf6) + (.mul.x.vf vf3 vf3 vf7) + (.svf (&-> v1-0 rvec quad) vf1) + (.svf (&-> v1-0 uvec quad) vf2) + (.svf (&-> v1-0 fvec quad) vf3) + (.svf (&-> v1-0 trans quad) vf4) + (.mov a1-4 vf4) + (matrix->quaternion arg0 v1-0) + ) + ) + ) + +;; definition for function quaternion-vector-len +(defun quaternion-vector-len ((arg0 quaternion)) + "Assuming quaternion is normalized, get the length of the xyz part." + (sqrtf (- 1.0 (square (-> arg0 w)))) + ) + +;; definition for function quaternion-log! +(defun quaternion-log! ((arg0 quaternion) (arg1 quaternion)) + "Take the log of a quaternion. Unused." + (cond + ((= (-> arg1 w) 0.0) + (set! (-> arg0 x) (* 1.5707963 (-> arg1 x))) + (set! (-> arg0 y) (* 1.5707963 (-> arg1 y))) + (set! (-> arg0 z) (* 1.5707963 (-> arg1 z))) + ) + (else + (let* ((f30-0 (quaternion-vector-len arg1)) + (f0-9 (/ (atan2-rad (-> arg1 w) f30-0) f30-0)) + ) + (set! (-> arg0 x) (* (-> arg1 x) f0-9)) + (set! (-> arg0 y) (* (-> arg1 y) f0-9)) + (set! (-> arg0 z) (* (-> arg1 z) f0-9)) + ) + ) + ) + arg0 + ) + +;; definition for function quaternion-exp! +(defun quaternion-exp! ((arg0 quaternion) (arg1 quaternion)) + "Quaternion exponentiation. Unused." + (let ((f30-0 (vector-length (-> arg1 vec)))) + (cond + ((= f30-0 0.0) + (set! (-> arg0 x) 0.0) + (set! (-> arg0 y) 0.0) + (set! (-> arg0 z) 0.0) + (set! (-> arg0 w) 1.0) + ) + (else + (let ((s5-0 (new 'stack-no-clear 'vector))) + (sincos-rad! s5-0 f30-0) + (let ((f0-6 (/ (-> s5-0 x) f30-0))) + (set! (-> arg0 x) (* (-> arg1 x) f0-6)) + (set! (-> arg0 y) (* (-> arg1 y) f0-6)) + (set! (-> arg0 z) (* (-> arg1 z) f0-6)) + ) + (set! (-> arg0 w) (-> s5-0 y)) + ) + ) + ) + ) + arg0 + ) + +;; definition for function quaternion-slerp! +(defun quaternion-slerp! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion) (arg3 float)) + "Real quaternion slerp. Spherical-linear interpolation is a nice way to interpolate + between quaternions." + (local-vars (v1-15 float)) + (rlet ((acc :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (let ((f0-0 (quaternion-dot arg1 arg2)) + (f30-0 1.0) + ) + (when (< f0-0 0.0) + (set! f0-0 (- f0-0)) + (set! f30-0 -1.0) + ) + (cond + ((< (- 1.0 f0-0) 0.0001) + (let ((v1-7 (- 1.0 arg3))) + (.mov vf1 v1-7) + ) + (let ((v1-8 (* arg3 f30-0))) + (.mov vf2 v1-8) + ) + (.lvf vf3 (&-> arg1 quad)) + (.lvf vf4 (&-> arg2 quad)) + (.mul.x.vf acc vf3 vf1) + (.add.mul.x.vf vf3 vf4 vf2 acc) + (.svf (&-> arg0 quad) vf3) + (quaternion-normalize! arg0) + ) + (else + (let* ((f1-6 (sqrtf (- 1.0 (square f0-0)))) + (f0-6 (/ (- f1-6 f0-0) (+ f1-6 f0-0))) + (f28-0 (/ 1.0 f1-6)) + ) + (let ((f0-7 (atan-series-rad f0-6)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s2-0 x) (* (- 1.0 arg3) f0-7)) + (set! (-> s2-0 y) (* arg3 f0-7 f30-0)) + (vector-sin-rad! s2-0 s2-0) + (.lvf vf1 (&-> s2-0 quad)) + ) + (let ((v1-14 f28-0)) + (.mov vf2 v1-14) + ) + ) + (.mul.x.vf vf1 vf1 vf2) + (.lvf vf3 (&-> arg1 quad)) + (.lvf vf4 (&-> arg2 quad)) + (.mul.x.vf acc vf3 vf1) + (.add.mul.y.vf vf3 vf4 vf1 acc) + (.svf (&-> arg0 quad) vf3) + (.mov v1-15 vf3) + ) + ) + ) + arg0 + ) + ) + +;; definition for function quaternion-pseudo-slerp! +(defun quaternion-pseudo-slerp! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion) (arg3 float)) + "This is a bad interpolation between quaternions. It lerps then normalizes. + It will behave extremely poorly for 180 rotations. + It is unused." + (rlet ((acc :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (let ((f1-0 (quaternion-dot arg1 arg2)) + (f0-0 1.0) + ) + (when (< f1-0 0.0) + (- f1-0) + (set! f0-0 -1.0) + ) + (let ((v1-5 (- 1.0 arg3))) + (.mov vf1 v1-5) + ) + (let ((v1-6 (* arg3 f0-0))) + (.mov vf2 v1-6) + ) + ) + (.lvf vf3 (&-> arg1 quad)) + (.lvf vf4 (&-> arg2 quad)) + (.mul.x.vf acc vf3 vf1) + (.add.mul.x.vf vf3 vf4 vf2 acc) + (.svf (&-> arg0 quad) vf3) + (quaternion-normalize! arg0) + arg0 + ) + ) + +;; definition for function quaternion-pseudo-seek +(defun quaternion-pseudo-seek ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion) (arg3 float)) + "Seek one quaternion toward another. Not using real slerp, so this is only good if the quaternions + are pretty similar." + (let ((s3-0 (new 'stack-no-clear 'quaternion))) + (let ((s5-0 (new 'stack-no-clear 'quaternion))) + (quaternion-copy! s3-0 arg2) + (if (< (quaternion-dot s3-0 arg1) 0.0) + (quaternion-negate! s3-0 s3-0) + ) + (quaternion-! s5-0 s3-0 arg1) + (let ((f0-1 (quaternion-norm2 s5-0))) + (if (< (square arg3) f0-1) + (quaternion-float*! s5-0 s5-0 (/ arg3 (sqrtf f0-1))) + ) + ) + (quaternion+! s3-0 arg1 s5-0) + ) + (quaternion-normalize! s3-0) + (quaternion-copy! arg0 s3-0) + ) + ) + +;; definition for function quaternion-smooth-seek! +(defun quaternion-smooth-seek! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion) (arg3 float)) + "Another hacky rotation interpolation." + (let ((gp-0 (new 'stack-no-clear 'inline-array 'quaternion 2))) + (quaternion-copy! (-> gp-0 0) arg2) + (if (< (quaternion-dot (-> gp-0 0) arg1) 0.0) + (quaternion-negate! (-> gp-0 0) (-> gp-0 0)) + ) + (quaternion-! (-> gp-0 1) (-> gp-0 0) arg1) + (quaternion-float*! (-> gp-0 1) (-> gp-0 1) (fmin 1.0 arg3)) + (quaternion+! (-> gp-0 0) arg1 (-> gp-0 1)) + (quaternion-normalize! (-> gp-0 0)) + (quaternion-copy! arg0 (-> gp-0 0)) + ) + ) + +;; definition for function quaternion-zxy! +(defun quaternion-zxy! ((arg0 quaternion) (arg1 vector)) + "Make a quaternion from a sequence of z, x, y axis rotations." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (vector-rad<-vector-deg/2! s4-0 arg1) + (vector-sincos-rad! gp-0 s5-0 s4-0) + (.lvf vf1 (&-> gp-0 quad)) + (.lvf vf2 (&-> s5-0 quad)) + ) + (.mul.x.vf.w vf4 vf0 vf1) + (.add.vf.xyz vf4 vf0 vf2) + (.sub.vf.yz vf4 vf0 vf4) + (.add.vf.xyz vf3 vf0 vf1) + (.mul.x.vf.w vf3 vf0 vf2) + (.outer.product.a.vf acc vf1 vf1) + (.outer.product.b.vf vf6 vf0 vf0 acc) + (.outer.product.a.vf acc vf2 vf2) + (.outer.product.b.vf vf5 vf0 vf0 acc) + (.mul.x.vf.w vf6 vf0 vf6) + (.mul.x.vf.w vf5 vf0 vf5) + (.mul.vf acc vf6 vf4) + (.add.mul.vf vf7 vf5 vf3 acc) + (.svf (&-> arg0 quad) vf7) + arg0 + ) + ) + +;; definition for function vector-x-quaternion! +;; INFO: Used lq/sq +(defun vector-x-quaternion! ((arg0 vector) (arg1 quaternion)) + "Get the first row of the rotation matrix for this quaternion." + (let ((s5-0 (new-stack-matrix0))) + (quaternion->matrix s5-0 arg1) + (set! (-> arg0 quad) (-> s5-0 rvec quad)) + ) + arg0 + ) + +;; definition for function vector-y-quaternion! +;; INFO: Used lq/sq +(defun vector-y-quaternion! ((arg0 vector) (arg1 quaternion)) + "Get the second row of the rotation matrix for this quaternion." + (let ((s5-0 (new-stack-matrix0))) + (quaternion->matrix s5-0 arg1) + (set! (-> arg0 quad) (-> s5-0 uvec quad)) + ) + arg0 + ) + +;; definition for function vector-z-quaternion! +;; INFO: Used lq/sq +(defun vector-z-quaternion! ((arg0 vector) (arg1 quaternion)) + "Get the third row of the rotation matrix for this quaternion." + (let ((s5-0 (new-stack-matrix0))) + (quaternion->matrix s5-0 arg1) + (set! (-> arg0 quad) (-> s5-0 fvec quad)) + ) + arg0 + ) + +;; definition for function quaternion-x-angle +(defun quaternion-x-angle ((arg0 quaternion)) + "Get the x rotation angle. Not very efficient." + (let ((v1-1 (vector-y-quaternion! (new 'stack-no-clear 'vector) arg0))) + (atan (-> v1-1 z) (-> v1-1 y)) + ) + ) + +;; definition for function quaternion-y-angle +(defun quaternion-y-angle ((arg0 quaternion)) + "Get the y rotation angle. Not very efficient." + (let ((v1-1 (vector-z-quaternion! (new 'stack-no-clear 'vector) arg0))) + (atan (-> v1-1 x) (-> v1-1 z)) + ) + ) + +;; definition for function quaternion-z-angle +(defun quaternion-z-angle ((arg0 quaternion)) + "Get the z rotation angle. Not very efficient." + (let ((v1-1 (vector-y-quaternion! (new 'stack-no-clear 'vector) arg0))) + (atan (-> v1-1 x) (-> v1-1 y)) + ) + ) + +;; definition for function quaternion-vector-y-angle +(defun quaternion-vector-y-angle ((arg0 quaternion) (arg1 vector)) + "Not sure. Angle between quaternion and axis, projected in xz plane?" + (let ((f30-0 (quaternion-y-angle arg0)) + (f0-2 (atan (-> arg1 x) (-> arg1 z))) + ) + (deg-diff f30-0 f0-2) + ) + ) + +;; definition for function quaternion-rotate-local-x! +;; INFO: Used lq/sq +(defun quaternion-rotate-local-x! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along x axis." + (let ((a2-1 (quaternion-vector-angle! + (new-stack-quaternion0) + (new 'static 'vector :data (new 'static 'array float 4 1.0 0.0 0.0 1.0)) + arg2 + ) + ) + ) + (quaternion-normalize! (quaternion*! arg0 arg1 a2-1)) + ) + ) + +;; definition for function quaternion-rotate-local-y! +;; INFO: Used lq/sq +(defun quaternion-rotate-local-y! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along y axis." + (let ((a2-1 (quaternion-vector-angle! + (new-stack-quaternion0) + (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0)) + arg2 + ) + ) + ) + (quaternion-normalize! (quaternion*! arg0 arg1 a2-1)) + ) + ) + +;; definition for function quaternion-rotate-local-z! +;; INFO: Used lq/sq +(defun quaternion-rotate-local-z! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along z axis." + (let ((a2-1 (quaternion-vector-angle! + (new-stack-quaternion0) + (new 'static 'vector :data (new 'static 'array float 4 0.0 0.0 1.0 1.0)) + arg2 + ) + ) + ) + (quaternion-normalize! (quaternion*! arg0 arg1 a2-1)) + ) + ) + +;; definition for function quaternion-rotate-y! +;; INFO: Used lq/sq +(defun quaternion-rotate-y! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along y axis (right multiply)." + (let ((a1-2 (quaternion-vector-angle! + (new-stack-quaternion0) + (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0)) + arg2 + ) + ) + ) + (quaternion-normalize! (quaternion*! arg0 a1-2 arg1)) + ) + ) + +;; definition for function quaternion-rotate-x! +;; INFO: Used lq/sq +(defun quaternion-rotate-x! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along x axis (right multiply)." + (let ((a1-3 (quaternion-vector-angle! (new-stack-quaternion0) (vector-x-quaternion! (new-stack-vector0) arg1) arg2)) + ) + (quaternion-normalize! (quaternion*! arg0 a1-3 arg1)) + ) + ) + +;; definition for function quaternion-rotate-z! +;; INFO: Used lq/sq +(defun quaternion-rotate-z! ((arg0 quaternion) (arg1 quaternion) (arg2 float)) + "Rotate existing quaternion along z axis (right multiply)." + (let ((a1-3 (quaternion-vector-angle! (new-stack-quaternion0) (vector-z-quaternion! (new-stack-vector0) arg1) arg2)) + ) + (quaternion-normalize! (quaternion*! arg0 a1-3 arg1)) + ) + ) + +;; definition for function quaternion-delta-y +(defun quaternion-delta-y ((arg0 quaternion) (arg1 quaternion)) + "Difference in yaw between two quaternions." + (acos (vector-dot + (vector-z-quaternion! (new 'stack-no-clear 'vector) arg0) + (vector-z-quaternion! (new 'stack-no-clear 'vector) arg1) + ) + ) + ) + +;; definition for function quaternion-rotate-y-to-vector! +(defun quaternion-rotate-y-to-vector! ((arg0 quaternion) (arg1 quaternion) (arg2 quaternion) (arg3 float)) + (let ((s5-0 (new 'stack-no-clear 'quaternion))) + (let ((t9-0 vector-xz-normalize!) + (a0-1 (new 'stack-no-clear 'vector)) + ) + (set! (-> a0-1 x) (-> arg2 x)) + (set! (-> a0-1 y) 0.0) + (set! (-> a0-1 z) (-> arg2 z)) + (set! (-> a0-1 w) 1.0) + (let ((s0-0 (t9-0 a0-1 1.0))) + (quaternion-from-two-vectors-max-angle! + s5-0 + (vector-z-quaternion! (new 'stack-no-clear 'vector) arg1) + s0-0 + arg3 + ) + ) + ) + (quaternion-normalize! (quaternion*! arg0 s5-0 arg1)) + ) + ) + +;; definition for function vector-rotate-around-axis! +(defun vector-rotate-around-axis! ((arg0 vector) (arg1 vector) (arg2 float) (arg3 vector)) + "Rotate along y so z-axis points to match another. Use arg3 as the max rotation amount." + (let ((a2-1 (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) arg3 arg2))) + (vector-orient-by-quat! arg0 arg1 a2-1) + ) + ) + +;; definition for function vector-rotate-x! +(defun vector-rotate-x! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate vector along x axis." + (vector-rotate-around-axis! arg0 arg1 arg2 *x-vector*) + ) + +;; definition for function vector-rotate-y! +(defun vector-rotate-y! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate vector along y axis." + (vector-rotate-around-axis! arg0 arg1 arg2 *y-vector*) + ) + +;; definition for function vector-rotate-y-fast! +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function vector-rotate-z! +(defun vector-rotate-z! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate vector along z axis." + (vector-rotate-around-axis! arg0 arg1 arg2 *z-vector*) + ) + +;; definition for function vector-y-angle +(defun vector-y-angle ((arg0 vector)) + "Get the yaw angle of a vector." + (atan (-> arg0 x) (-> arg0 z)) + ) + +;; definition for function vector-x-angle +(defun vector-x-angle ((arg0 vector)) + "Get the pitch angle of a vector." + (atan (-> arg0 y) (vector-xz-length arg0)) + ) + +;; definition for function quaternion<-rotate-y-vector +(defun quaternion<-rotate-y-vector ((arg0 quaternion) (arg1 vector)) + "Create a quaternion representing only the yaw of the given vector." + (quaternion-vector-angle! + arg0 + (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0)) + (vector-y-angle arg1) + ) + ) + +;; definition (debug) for function quaternion-validate +;; WARN: Return type mismatch int vs none. +(defun-debug quaternion-validate ((arg0 quaternion)) + "Verify that a quaternion is valid, print an error if the length is off by more than 1%.." + (with-pp + (let ((f0-0 (quaternion-norm arg0))) + (when (or (< 1.01 f0-0) (< f0-0 0.99)) + (format #t "WARNING: bad quaternion (magnitude ~F) process is " f0-0) + (if (and pp (type? pp process-tree)) + (format #t "~A~%" (-> pp name)) + (format #t "#f~%") + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for function quaternion-xz-angle +(defun quaternion-xz-angle ((arg0 quaternion)) + "Yet another function to compute the yaw of a quaternion. This is a particularly inefficient version." + (let ((gp-0 (new 'stack-no-clear 'matrix)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (quaternion->matrix gp-0 arg0) + (set-vector! s5-0 0.0 0.0 1.0 1.0) + (vector-matrix*! s5-0 s5-0 gp-0) + (vector-y-angle s5-0) + ) + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/math/transform-h_REF.gc b/test/decompiler/reference/jakx/engine/math/transform-h_REF.gc new file mode 100644 index 0000000000..bd5c898241 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/math/transform-h_REF.gc @@ -0,0 +1,63 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type transformq +(deftype transformq (structure) + "Transformation. w components of vectors should be 1.0 +This can represent any rotation, translation, and scaling. +Note that the scaling is applied before rotation +(meaning it scales along the axes of the pre-transformed frame)." + ((trans vector :inline) + (rot vector :inline) + (scale vector :inline) + ) + ) + +;; definition for method 3 of type transformq +(defmethod inspect ((this transformq)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'transformq) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Trot: ~`vector`P~%" (-> this rot)) + (format #t "~1Tscale: ~`vector`P~%" (-> this scale)) + (label cfg-4) + this + ) + +;; definition of type trsq +(deftype trsq (basic) + "Like transform, but it's a basic. +Note that the trsq child type overrides this rotation with a quaternion. +usage of the plain trs is very limited, at least in Jak 1." + ((trans vector :inline) + (rot vector :inline) + (scale vector :inline) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +;; definition for method 3 of type trsq +(defmethod inspect ((this trsq)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Trot: ~`vector`P~%" (-> this rot)) + (format #t "~1Tscale: ~`vector`P~%" (-> this scale)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/math/transformq-h_REF.gc b/test/decompiler/reference/jakx/engine/math/transformq-h_REF.gc new file mode 100644 index 0000000000..b9ba1d8de7 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/math/transformq-h_REF.gc @@ -0,0 +1,88 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type trsqv +(deftype trsqv (trsq) + "A transform with: +- type information (child of [[basic]]) +- rotation stored as quaternion +- velocity information. +This is a very commonly used type to represent the position of an in-game object. +The `root` of a process-drawable (the parent 'in-game object' type) is a [[trsqv]]. +Additionally, the collision system uses [[trsqv]] as the parent type for foreground +collision objects ([[collide-shape]], [[collide-shape-moving]]). +As a result, this type has a lot of weird methods and extra stuff hidden in it." + ((pause-adjust-distance meters :offset 4) + (nav-radius meters :offset 8) + (transv vector :inline) + (rotv vector :inline) + (scalev vector :inline) + (dir-targ quaternion :inline) + (angle-change-time time-frame) + (old-y-angle-diff float) + ) + (:methods + (seek-toward-heading-vec! (_type_ vector float time-frame) quaternion) + (set-heading-vec! (_type_ vector) quaternion) + (seek-to-point-toward-point! (_type_ vector float time-frame) quaternion) + (point-toward-point! (_type_ vector) quaternion) + (seek-toward-yaw-angle! (_type_ float float time-frame) quaternion) + (set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion) + (set-roll-to-grav! (_type_ float) quaternion) + (set-roll-to-grav-2! (_type_ float) quaternion) + (rotate-toward-orientation! (_type_ quaternion float float int int float) quaternion) + (set-quaternion! (_type_ quaternion) quaternion) + (set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion) + (point-toward-point-clear-roll-pitch! (_type_ vector) quaternion) + (rot->dir-targ! (_type_) quaternion) + (y-angle (_type_) float) + (global-y-angle-to-point (_type_ vector) float) + (relative-y-angle-to-point (_type_ vector) float) + (roll-relative-to-gravity (_type_) float) + (set-and-limit-velocity (_type_ int vector float) trsqv) + (get-quaternion (_type_) quaternion) + ) + ) + +;; definition for method 3 of type trsqv +(defmethod inspect ((this trsqv)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Trot: ~`vector`P~%" (-> this rot)) + (format #t "~1Tscale: ~`vector`P~%" (-> this scale)) + (format #t "~1Tpause-adjust-distance: (meters ~m)~%" (-> this pause-adjust-distance)) + (format #t "~1Tnav-radius: (meters ~m)~%" (-> this nav-radius)) + (format #t "~1Ttransv: ~`vector`P~%" (-> this transv)) + (format #t "~1Trotv: ~`vector`P~%" (-> this rotv)) + (format #t "~1Tscalev: ~`vector`P~%" (-> this scalev)) + (format #t "~1Tdir-targ: #~%" (-> this dir-targ)) + (format #t "~1Tangle-change-time: ~D~%" (-> this angle-change-time)) + (format #t "~1Told-y-angle-diff: ~f~%" (-> this old-y-angle-diff)) + (label cfg-4) + this + ) + +;; definition for method 23 of type trsqv +(defmethod global-y-angle-to-point ((this trsqv) (arg0 vector)) + "Get the angle in the xz plane from the position of this trsqv to the point arg0 + (ignores our current yaw)." + (vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> this trans))) + ) + +;; definition for method 24 of type trsqv +(defmethod relative-y-angle-to-point ((this trsqv) (arg0 vector)) + "Get the y angle between the current orientation and arg0 + (how much we'd have to yaw to point at arg0)." + (deg-diff (y-angle this) (vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> this trans)))) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/math/trigonometry-h_REF.gc b/test/decompiler/reference/jakx/engine/math/trigonometry-h_REF.gc new file mode 100644 index 0000000000..8e4b1f21d4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/math/trigonometry-h_REF.gc @@ -0,0 +1,9 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/math/trigonometry_REF.gc b/test/decompiler/reference/jakx/engine/math/trigonometry_REF.gc new file mode 100644 index 0000000000..e0ff9f28a9 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/math/trigonometry_REF.gc @@ -0,0 +1,660 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function radmod +(defun radmod ((arg0 float)) + "Wrap arg0 to be within (-pi, pi)." + (let ((f0-1 (+ 3.1415925 arg0))) + (if (< 0.0 f0-1) + (+ -3.1415925 (- f0-1 (* (the float (the int (/ f0-1 6.283185))) 6.283185))) + (+ 3.1415925 (- f0-1 (* (the float (the int (/ f0-1 6.283185))) 6.283185))) + ) + ) + ) + +;; definition for function deg- +(defun deg- ((arg0 float) (arg1 float)) + "Compute arg0-arg1, unwrapped, using rotation units. + Result should be in the range (-180, 180)" + (the float (sar (- (shl (the int arg0) 48) (shl (the int arg1) 48)) 48)) + ) + +;; definition for function deg-diff +(defun deg-diff ((arg0 float) (arg1 float)) + "Very similar to the function above, but computes arg1 - arg0 instead." + (the float (sar (- (shl (the int arg1) 48) (shl (the int arg0) 48)) 48)) + ) + +;; definition for function deg-seek +(defun deg-seek ((arg0 float) (arg1 float) (arg2 float)) + "Move in toward target by at most max-diff, using rotation units" + (let ((v1-1 (shl (the int arg0) 48)) + (a0-2 (shl (the int arg1) 48)) + ) + (let* ((a1-2 (shl (the int arg2) 48)) + (a2-1 (- a0-2 v1-1)) + (a3-0 (abs a2-1)) + ) + (set! a0-2 (cond + ((< a3-0 0) + (+ v1-1 a1-2) + ) + ((>= a1-2 a3-0) + (empty) + a0-2 + ) + ((>= a2-1 0) + (+ v1-1 a1-2) + ) + (else + (- v1-1 a1-2) + ) + ) + ) + ) + (the float (sar a0-2 48)) + ) + ) + +;; definition for function deg-seek-smooth +(defun deg-seek-smooth ((arg0 float) (arg1 float) (arg2 float) (arg3 float)) + "Step amount of the way from in to target, by at most max-diff, using rotation units" + (let ((f0-1 (* (deg- arg1 arg0) arg3))) + (if (< arg2 (fabs f0-1)) + (set! f0-1 (if (>= f0-1 0.0) + arg2 + (- arg2) + ) + ) + ) + (+ arg0 f0-1) + ) + ) + +;; definition for function deg-lerp-clamp +(defun deg-lerp-clamp ((arg0 float) (arg1 float) (arg2 float)) + "Map [0, 1] to min-val, max-val, handling wrapping and saturating, using rotation units." + (cond + ((>= 0.0 arg2) + arg0 + ) + ((>= arg2 1.0) + arg1 + ) + (else + (the float (sar (shl (the int (+ arg0 (* arg2 (deg-diff arg0 arg1)))) 48) 48)) + ) + ) + ) + +;; definition for symbol binary-table, type (array float) +(define binary-table (new 'static 'boxed-array :type float + 1.0 + 0.5 + 0.25 + 0.125 + 0.0625 + 0.03125 + 0.015625 + 0.0078125 + 0.00390625 + 0.001953125 + 0.0009765625 + 0.00048828125 + 0.00024414062 + 0.00012207031 + 0.000061035156 + 0.000030517578 + 0.000015258789 + 0.0000076293945 + 0.0000038146973 + 0.0000019073486 + 0.0000009536743 + 0.00000047683716 + 0.00000023841858 + 0.00000011920929 + 0.000000059604645 + 0.000000029802322 + 0.000000014901161 + 0.000000007450581 + 0.0000000037252903 + 0.0000000018626451 + 0.0000000009313226 + 0.0000000004656613 + ) + ) + +;; definition for symbol sincos-table, type (array float) +(define sincos-table (new 'static 'boxed-array :type float + 0.7853982 + 0.4636476 + 0.24497867 + 0.124354996 + 0.06241881 + 0.031239834 + 0.015623729 + 0.007812341 + 0.0039062302 + 0.0019531226 + 0.0009765622 + 0.0004882812 + 0.00024414062 + 0.00012207031 + 0.000061035156 + 0.000030517578 + 0.000015258789 + 0.0000076293945 + 0.0000038146973 + 0.0000019073486 + 0.0000009536743 + 0.00000047683716 + 0.00000023841858 + 0.00000011920929 + 0.000000059604645 + 0.000000029802322 + 0.000000014901161 + 0.000000007450581 + 0.0000000037252903 + 0.0000000018626451 + 0.0000000009313226 + 0.0000000004656613 + ) + ) + +;; definition for function sin +(defun sin ((arg0 float)) + "Compute the sine of an angle in rotation units. Unwraps it." + (let ((f2-0 (* 0.000095873795 (the float (sar (shl (the int arg0) 48) 48))))) + f2-0 + (let* ((f1-4 (* 0.999998 f2-0)) + (f0-3 (square f2-0)) + (f2-1 (* f2-0 f0-3)) + (f1-5 (+ f1-4 (* -0.16666014 f2-1))) + (f2-2 (* f2-1 f0-3)) + (f1-6 (+ f1-5 (* 0.008326521 f2-2))) + (f2-3 (* f2-2 f0-3)) + (f1-7 (+ f1-6 (* -0.0001956241 f2-3))) + (f0-4 (* f2-3 f0-3)) + ) + (+ f1-7 (* 0.0000023042373 f0-4)) + ) + ) + ) + +;; definition for function sin-rad +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for symbol *sin-poly-vec*, type vector +(define *sin-poly-vec* + (new 'static 'vector :data (new 'static 'array float 4 -0.16666014 0.008326521 -0.0001956241 0.0000023042373)) + ) + +;; definition for symbol *sin-poly-vec2*, type vector +(define *sin-poly-vec2* (new 'static 'vector :data (new 'static 'array float 4 0.999998 0.0 0.0 0.0))) + +;; definition for function vector-sin-rad! +(defun vector-sin-rad! ((arg0 vector) (arg1 vector)) + "Taylor series approximation of sine on all 4 elements in a vector. + Inputs should be in radians, in -pi to pi. + Somehow their coefficients are a little bit off. + Like the first coefficient, which should obviously be 1, is not quite 1." + (rlet ((acc :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.mul.vf vf3 vf1 vf1) + (.lvf vf10 (&-> *sin-poly-vec2* quad)) + (.lvf vf9 (&-> *sin-poly-vec* quad)) + (.mul.vf vf4 vf3 vf1) + (.mul.vf vf5 vf3 vf3) + (.mul.x.vf acc vf1 vf10) + (.mul.vf vf6 vf4 vf3) + (.mul.vf vf7 vf5 vf4) + (.add.mul.x.vf acc vf4 vf9 acc) + (.mul.vf vf8 vf6 vf5) + (.add.mul.y.vf acc vf6 vf9 acc) + (.add.mul.z.vf acc vf7 vf9 acc) + (.add.mul.w.vf vf2 vf8 vf9 acc) + (.svf (&-> arg0 quad) vf2) + arg0 + ) + ) + +;; definition for function cos-rad +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for symbol *cos-poly-vec*, type vector +(define *cos-poly-vec* + (new 'static 'vector :data (new 'static 'array float 4 -0.49998003 0.041620404 -0.0013636408 0.000020170546)) + ) + +;; definition for function vector-cos-rad! +;; ERROR: Bad vector register dependency: vf2 +(defun vector-cos-rad! ((arg0 vector) (arg1 vector)) + "Compute the cosine of all 4 vector elements. + Radians, with no wrapping. Uses taylor series with 4 coefficients." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.sub.vf vf2 vf2 vf2) + (.lvf vf9 (&-> *cos-poly-vec* quad)) + (.mul.vf vf3 vf1 vf1) + (.add.w.vf acc vf2 vf0) + (.mul.vf vf4 vf3 vf3) + (.add.mul.x.vf acc vf3 vf9 acc) + (.mul.vf vf5 vf4 vf3) + (.add.mul.y.vf acc vf4 vf9 acc) + (.mul.vf vf6 vf4 vf4) + (.add.mul.z.vf acc vf5 vf9 acc) + (.add.mul.w.vf vf2 vf6 vf9 acc) + (.svf (&-> arg0 quad) vf2) + arg0 + ) + ) + +;; definition for function vector-sincos-rad! +;; ERROR: Bad vector register dependency: vf14 +(defun vector-sincos-rad! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Compute the sine and cosine of each element of src, storing it in dst-sin and dst-cos. + This is more efficient than separate calls to sin and cos. + Inputs should be radians in -pi to pi. + TODO - original code contained a bad VF dependency" + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg2 quad)) + (.sub.vf vf14 vf14 vf14) + (.lvf vf11 (&-> *sin-poly-vec2* quad)) + (.mul.vf vf2 vf1 vf1) + (.lvf vf10 (&-> *sin-poly-vec* quad)) + (.lvf vf13 (&-> *cos-poly-vec* quad)) + (.mul.x.vf acc vf1 vf11) + (.mul.vf vf3 vf2 vf1) + (.mul.vf vf4 vf2 vf2) + (.mul.vf vf5 vf3 vf2) + (.mul.vf vf6 vf3 vf3) + (.mul.vf vf7 vf4 vf3) + (.mul.vf vf8 vf4 vf4) + (.mul.vf vf9 vf5 vf4) + (.add.mul.x.vf acc vf3 vf10 acc) + (.add.mul.y.vf acc vf5 vf10 acc) + (.add.mul.z.vf acc vf7 vf10 acc) + (.add.mul.w.vf vf12 vf9 vf10 acc) + (.add.w.vf acc vf14 vf0) + (.add.mul.x.vf acc vf2 vf13 acc) + (.add.mul.y.vf acc vf4 vf13 acc) + (.add.mul.z.vf acc vf6 vf13 acc) + (.add.mul.w.vf vf14 vf8 vf13 acc) + (.svf (&-> arg0 quad) vf12) + (.svf (&-> arg1 quad) vf14) + 0 + ) + ) + +;; definition for function sincos-rad! +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function sincos! +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function vector-rad<-vector-deg! +;; WARN: Return type mismatch float vs none. +(defun vector-rad<-vector-deg! ((out vector) (in vector)) + "Convert a vector in rotation units to radians, and unwrap. + Input can be anything, output will be -2pi to pi." + (local-vars (v0-0 float) (v1-1 uint128) (v1-2 uint128) (v1-3 uint128)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (let ((v1-0 #x38c90fda)) + (.lvf vf1 (&-> in quad)) + (.ftoi.vf vf1 vf1) + (.mov vf2 v1-0) + ) + (.mov v1-1 vf1) + (.pw.sll v1-2 v1-1 16) + (.pw.sra v1-3 v1-2 16) + (.mov vf1 v1-3) + (.itof.vf vf1 vf1) + (.mul.x.vf vf1 vf1 vf2) + (.svf (&-> out quad) vf1) + (.mov v0-0 vf1) + (none) + ) + ) + +;; definition for function vector-rad<-vector-deg/2! +;; WARN: Return type mismatch float vs int. +(defun vector-rad<-vector-deg/2! ((out vector) (in vector)) + "Divide the input by two, and then convert from rotation units to radians, unwrapping. + Not sure why this really needs to be separate the from previous function..." + (local-vars (v0-0 float) (v1-1 uint128) (v1-2 uint128) (v1-3 uint128)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (let ((v1-0 #x38c90fda)) + (let ((a2-0 #x3f000000)) + (.lvf vf1 (&-> in quad)) + (.mov vf2 a2-0) + ) + (.mul.x.vf vf1 vf1 vf2) + (.ftoi.vf vf1 vf1) + (.mov vf2 v1-0) + ) + (.mov v1-1 vf1) + (.pw.sll v1-2 v1-1 16) + (.pw.sra v1-3 v1-2 16) + (.mov vf1 v1-3) + (.itof.vf vf1 vf1) + (.mul.x.vf vf1 vf1 vf2) + (.svf (&-> out quad) vf1) + (.mov v0-0 vf1) + (the-as int v0-0) + ) + ) + +;; definition for function vector-sincos! +(defun vector-sincos! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Compute sine and cosine of each element in a vector, in rotation units" + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-rad<-vector-deg! s4-0 arg2) + (vector-sincos-rad! arg0 arg1 s4-0) + ) + ) + +;; definition for function tan-rad +(defun tan-rad ((arg0 float)) + "This function appears to be named wrong and actually operates on rotation units." + (/ (sin arg0) (cos arg0)) + ) + +;; definition for function cos +(defun cos ((arg0 float)) + "Cosine of rotation units." + (sin (+ 16384.0 arg0)) + ) + +;; definition for function tan +(defun tan ((arg0 float)) + "Correctly named tangent of rotation units." + (/ (sin arg0) (cos arg0)) + ) + +;; definition for function atan0 +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function atan-series-rad +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function atan-rad +(defun atan-rad ((arg0 float)) + "Inverse tangent in radians." + (atan-series-rad (/ (+ -1.0 arg0) (+ 1.0 arg0))) + ) + +;; definition for function sign-bit +(defun sign-bit ((arg0 int)) + "Return 1 if bit 31 is set, otherwise 0." + (local-vars (v1-1 int)) + (let ((v1-0 arg0)) + (shift-arith-right-32 v1-1 v1-0 31) + ) + (logand v1-1 1) + ) + +;; definition for function sign-float +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function sign +(defun sign ((arg0 float)) + "Similar to above, but returns 0 if input is 0. + But is more complicated." + (cond + ((< 0.0 arg0) + 1.0 + ) + ((< arg0 0.0) + -1.0 + ) + (else + 0.0 + ) + ) + ) + +;; definition for function atan2-rad +(defun atan2-rad ((arg0 float) (arg1 float)) + "Atan for radians." + (cond + ((= arg1 0.0) + (* 1.5707963 (sign arg0)) + ) + ((and (< arg0 0.0) (< arg1 0.0)) + (let ((f30-1 -3.1415925) + (f0-6 (/ arg0 arg1)) + ) + (+ f30-1 (atan-series-rad (/ (+ -1.0 f0-6) (+ 1.0 f0-6)))) + ) + ) + ((< arg0 0.0) + (let ((f0-14 (- (/ arg0 arg1)))) + (- (atan-series-rad (/ (+ -1.0 f0-14) (+ 1.0 f0-14)))) + ) + ) + ((< arg1 0.0) + (let ((f30-2 3.1415925) + (f0-22 (- (/ arg0 arg1))) + ) + (- f30-2 (atan-series-rad (/ (+ -1.0 f0-22) (+ 1.0 f0-22)))) + ) + ) + (else + (let ((f0-28 (/ arg0 arg1))) + (atan-series-rad (/ (+ -1.0 f0-28) (+ 1.0 f0-28))) + ) + ) + ) + ) + +;; definition for function atan +(defun atan ((arg0 float) (arg1 float)) + "Atan for rotation units. Signs behave like atan.." + (cond + ((and (= arg1 0.0) (= arg0 0.0)) + 0.0 + ) + ((and (< arg1 0.0) (< arg0 0.0)) + (+ -32768.0 (atan0 (- arg0) (- arg1))) + ) + ((< arg0 0.0) + (- (atan0 (- arg0) arg1)) + ) + ((< arg1 0.0) + (- 32768.0 (atan0 arg0 (- arg1))) + ) + (else + (atan0 arg0 arg1) + ) + ) + ) + +;; definition for function asin +(defun asin ((arg0 float)) + "Inverse sine, rotation units." + (let ((gp-0 #f)) + 0.0 + (when (< arg0 0.0) + (set! arg0 (- arg0)) + (set! gp-0 #t) + ) + (let ((f0-5 (cond + ((< 1.0 arg0) + 16383.996 + ) + (else + (let ((f0-8 (sqrtf (- 1.0 (square arg0))))) + (atan0 arg0 f0-8) + ) + ) + ) + ) + ) + (if gp-0 + (- f0-5) + f0-5 + ) + ) + ) + ) + +;; definition for function acos +(defun acos ((arg0 float)) + "Inverse cosine. Returns rotation units." + (- 16384.0 (asin arg0)) + ) + +;; definition for function acos-rad +(defun acos-rad ((arg0 float)) + "Inverse cosine, radians." + (cond + ((>= arg0 0.0) + (let* ((f0-3 (sqrtf (- 1.0 (square arg0)))) + (f0-5 (/ (- f0-3 arg0) (+ f0-3 arg0))) + ) + (atan-series-rad f0-5) + ) + ) + (else + (let* ((f0-8 (sqrtf (- 1.0 (square arg0)))) + (f0-10 (/ (+ f0-8 arg0) (- f0-8 arg0))) + ) + (- 3.1415925 (atan-series-rad f0-10)) + ) + ) + ) + ) + +;; definition for function sinerp +(defun sinerp ((arg0 float) (arg1 float) (arg2 float)) + "Map amount to min,max using sine. Kinda weird, usually people use cosine." + (lerp arg0 arg1 (sin (* 16384.0 arg2))) + ) + +;; definition for function sinerp-clamp +(defun sinerp-clamp ((arg0 float) (arg1 float) (arg2 float)) + "Like sinerp, but clamp to min,max." + (cond + ((>= 0.0 arg2) + arg0 + ) + ((>= arg2 1.0) + arg1 + ) + (else + (sinerp arg0 arg1 arg2) + ) + ) + ) + +;; definition for function coserp +(defun coserp ((arg0 float) (arg1 float) (arg2 float)) + "Weird lerp with cosine (over 90 degrees?)." + (lerp arg0 arg1 (- 1.0 (cos (* 16384.0 arg2)))) + ) + +;; definition for function coserp-clamp +(defun coserp-clamp ((arg0 float) (arg1 float) (arg2 float)) + "Weird 90 degree lerp with cosine, clamped to min,max." + (cond + ((>= 0.0 arg2) + arg0 + ) + ((>= arg2 1.0) + arg1 + ) + (else + (coserp arg0 arg1 arg2) + ) + ) + ) + +;; definition for function coserp180 +(defun coserp180 ((arg0 float) (arg1 float) (arg2 float)) + "Classic lerp with cosine." + (lerp arg0 arg1 (* 0.5 (- 1.0 (cos (* 32768.0 arg2))))) + ) + +;; definition for function coserp180-clamp +(defun coserp180-clamp ((arg0 float) (arg1 float) (arg2 float)) + "Classic coserp with saturation." + (cond + ((>= 0.0 arg2) + arg0 + ) + ((>= arg2 1.0) + arg1 + ) + (else + (coserp180 arg0 arg1 arg2) + ) + ) + ) + +;; definition for function ease-in-out +(defun ease-in-out ((arg0 int) (arg1 int)) + "Weird coserp like mapping from 0 to 1 as progress goes from 0 to total." + (local-vars (v1-0 int)) + (cond + ((>= arg1 arg0) + 1.0 + ) + ((<= arg1 0) + 0.0 + ) + ((begin (set! v1-0 (/ arg0 2)) (< v1-0 arg1)) + (let ((a0-1 (- arg1 arg0))) + (+ 0.5 (* 0.5 (sin (- 16384.0 (/ (* 16384.0 (the float a0-1)) (the float v1-0)))))) + ) + ) + (else + (- 0.5 (* 0.5 (cos (/ (* 16384.0 (the float arg1)) (the float v1-0))))) + ) + ) + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/math/vector_REF.gc b/test/decompiler/reference/jakx/engine/math/vector_REF.gc new file mode 100644 index 0000000000..f4dd7e2150 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/math/vector_REF.gc @@ -0,0 +1,1798 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function vector-cross! +(defun vector-cross! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Compute the cross product. The w component is set to junk." + (vector-cross! arg0 arg1 arg2) + ) + +;; definition for function vector-xz-cross! +(defun vector-xz-cross! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Compute the cross product of the xz components of inputs." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.add.x.vf.y vf1 vf0 vf0) + (.add.x.vf.y vf2 vf0 vf0) + (.outer.product.a.vf acc vf1 vf2) + (.outer.product.b.vf vf3 vf2 vf1 acc) + (.svf (&-> arg0 quad) vf3) + arg0 + ) + ) + +;; definition for function vector+float! +(defun vector+float! ((arg0 vector) (arg1 vector) (arg2 float)) + "Add float to each component of vector. The w component is set to 1" + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (.mov vf6 arg2) + (.lvf vf4 (&-> arg1 quad)) + (.add.x.vf.w vf5 vf0 vf0) + (.add.x.vf.xyz vf5 vf4 vf6) + (.svf (&-> arg0 quad) vf5) + arg0 + ) + ) + +;; definition for function vector*! +(defun vector*! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Elementwise product. Set w = 1." + (vector*! arg0 arg1 arg2) + ) + +;; definition for function vector+*! +(defun vector+*! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "set arg0 = arg1 + (arg3 * arg2). The w component will be set to 1." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (.mov vf7 arg3) + (.lvf vf5 (&-> arg2 quad)) + (.lvf vf4 (&-> arg1 quad)) + (.add.x.vf.w vf6 vf0 vf0) + (.mul.x.vf.xyz acc vf5 vf7) + (.add.mul.w.vf.xyz vf6 vf4 vf0 acc) + (.svf (&-> arg0 quad) vf6) + arg0 + ) + ) + +;; definition for function vector-*! +(defun vector-*! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Set arg0 = arg1 - (arg3 * arg2). The w component will be set to 1." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (.mov vf7 arg3) + (.lvf vf5 (&-> arg2 quad)) + (.lvf vf4 (&-> arg1 quad)) + (.add.x.vf.w vf6 vf0 vf0) + (.mul.w.vf.xyz acc vf4 vf0) + (.sub.mul.x.vf.xyz vf6 vf5 vf7 acc) + (.svf (&-> arg0 quad) vf6) + arg0 + ) + ) + +;; definition for function vector/! +(defun vector/! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Set arg0 = arg1 / arg2. The w component will be set to 1. + The implementation is kind of crazy." + (rlet ((Q :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (.lvf vf5 (&-> arg2 quad)) + (.div.vf Q vf0 vf5 :fsf #b11 :ftf #b1) + (.add.x.vf.w vf6 vf0 vf0) + (.lvf vf4 (&-> arg1 quad)) + (let ((v1-0 (/ (-> arg1 x) (-> arg2 x)))) + (.wait.vf) + (.mul.vf.y vf6 vf4 Q) + (.nop.vf) + (.nop.vf) + (.div.vf Q vf0 vf5 :fsf #b11 :ftf #b10) + (.mov vf7 v1-0) + ) + (.add.x.vf.x vf6 vf0 vf7) + (.wait.vf) + (.mul.vf.z vf6 vf4 Q) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf6) + arg0 + ) + ) + +;; definition for function vector-float*! +(defun vector-float*! ((arg0 vector) (arg1 vector) (arg2 float)) + "Multiply all values in a vector by arg2. Set w to 1." + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.mov vf2 arg2) + (.add.x.vf.w vf1 vf0 vf0) + (.mul.x.vf.xyz vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function vector-average! +(defun vector-average! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Set arg0 to the average of arg1 and arg2. Set w to 1." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 #x3f000000)) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.mov vf3 v1-0) + ) + (.add.x.vf.w vf4 vf0 vf0) + (.mul.x.vf acc vf1 vf3) + (.add.mul.x.vf.xyz vf4 vf2 vf3 acc) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +;; definition for function vector+float*! +(defun vector+float*! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "arg0 = arg1 + arg2 * arg3." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg2 quad)) + (.lvf vf1 (&-> arg1 quad)) + (.mov vf3 arg3) + (.add.x.vf.w vf4 vf0 vf0) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf.xyz vf4 vf1 vf0 acc) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +;; definition for function vector--float*! +(defun vector--float*! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Set arg0 = arg1 - (arg2 * arg3). The w component will be set to 1. + Is this different from vector-*!" + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg2 quad)) + (.lvf vf1 (&-> arg1 quad)) + (.mov vf3 arg3) + (.add.x.vf.w vf4 vf0 vf0) + (.mul.w.vf acc vf1 vf0) + (.sub.mul.x.vf.xyz vf4 vf2 vf3 acc) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +;; definition for function vector-min! +(defun vector-min! ((arg0 vector) (arg1 vector) (arg2 vector)) + (set! (-> arg0 x) (fmin (-> arg1 x) (-> arg2 x))) + (set! (-> arg0 y) (fmin (-> arg1 y) (-> arg2 y))) + (set! (-> arg0 z) (fmin (-> arg1 z) (-> arg2 z))) + (set! (-> arg0 w) 1.0) + arg0 + ) + +;; definition for function vector-max! +(defun vector-max! ((arg0 vector) (arg1 vector) (arg2 vector)) + (set! (-> arg0 x) (fmax (-> arg1 x) (-> arg2 x))) + (set! (-> arg0 y) (fmax (-> arg1 y) (-> arg2 y))) + (set! (-> arg0 z) (fmax (-> arg1 z) (-> arg2 z))) + (set! (-> arg0 w) 1.0) + arg0 + ) + +;; definition for function vector-float/! +(defun vector-float/! ((arg0 vector) (arg1 vector) (arg2 float)) + "Divide all components by arg2. The w component will be set to 1." + (rlet ((Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.mov vf3 arg2) + (.div.vf Q vf0 vf3 :fsf #b11 :ftf #b0) + (.lvf vf1 (&-> arg1 quad)) + (.add.x.vf.w vf4 vf0 vf0) + (.wait.vf) + (.mul.vf.xyz vf4 vf1 Q) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +;; definition for function vector-negate! +(defun vector-negate! ((arg0 vector) (arg1 vector)) + "Negate xyz, set w to 1." + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.sub.vf.xyz vf4 vf0 vf1) + (.add.x.vf.w vf4 vf0 vf0) + (.svf (&-> arg0 quad) vf4) + arg0 + ) + ) + +;; definition for function vector-negate-in-place! +(defun vector-negate-in-place! ((arg0 vector)) + "Negate xyz. Doesn't touch w." + (rlet ((vf0 :class vf) + (vf1 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.sub.vf.xyz vf1 vf0 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function vector= +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function vector-delta +(defun vector-delta ((arg0 vector) (arg1 vector)) + "Sum of the elementwise absolute value of differences." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.lvf vf2 (&-> arg1 quad)) + (.sub.vf vf1 vf2 vf1) + (.abs.vf vf1 vf1) + (.mul.x.vf.w acc vf0 vf1) + (.add.mul.y.vf.w acc vf0 vf1 acc) + (.add.mul.z.vf.w vf3 vf0 vf1 acc) + (.add.w.vf.x vf3 vf0 vf3) + (.mov v0-0 vf3) + v0-0 + ) + ) + +;; definition for function vector-seek! +(defun vector-seek! ((arg0 vector) (arg1 vector) (arg2 float)) + "Seek arg0 toward arg1. The arg0 is both read and written. + arg2 is saturated to (0, 1)" + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (.mov vf4 arg2) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg0 quad)) + (.add.x.vf.w vf1 vf0 vf0) + (.sub.x.vf.x vf5 vf0 vf4) + (.sub.vf.xyz vf3 vf1 vf2) + (.min.x.vf.xyz vf3 vf3 vf4) + (.max.x.vf.xyz vf3 vf3 vf5) + (.add.vf.xyz vf1 vf2 vf3) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function vector-smooth-seek! +(defun vector-smooth-seek! ((arg0 vector) (arg1 vector) (arg2 float)) + "Smoothly seek vec toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a _square_ with side length arg2. + Note that this doesn't project to a circle like the function below..." + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (vector-! v1-0 arg1 arg0) + (let ((v0-0 arg0)) + (let ((a1-2 (fmin 1.0 arg2))) + (.mov vf7 a1-2) + ) + (.lvf vf5 (&-> v1-0 quad)) + (.lvf vf4 (&-> arg0 quad)) + (.add.x.vf.w vf6 vf0 vf0) + (.mul.x.vf.xyz acc vf5 vf7) + (.add.mul.w.vf.xyz vf6 vf4 vf0 acc) + (.svf (&-> v0-0 quad) vf6) + v0-0 + ) + ) + ) + ) + +;; definition for function vector-seek-2d-xz-smooth! +(defun vector-seek-2d-xz-smooth! ((arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + "Smoothly seek vec's x and z components toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a circle of radius max-step. + Doesn't touch y or w." + (let ((f0-1 (- (-> arg1 x) (-> arg0 x))) + (f2-1 (- (-> arg1 z) (-> arg0 z))) + ) + (when (or (!= f0-1 0.0) (!= f2-1 0.0)) + (let* ((f1-5 (* f0-1 arg3)) + (f0-3 (* f2-1 arg3)) + (f2-4 (sqrtf (+ (square f1-5) (square f0-3)))) + ) + (cond + ((>= arg2 f2-4) + (+! (-> arg0 x) f1-5) + (+! (-> arg0 z) f0-3) + ) + (else + (let ((f2-6 (/ arg2 f2-4))) + (+! (-> arg0 x) (* f2-6 f1-5)) + (+! (-> arg0 z) (* f2-6 f0-3)) + ) + ) + ) + ) + ) + ) + arg0 + ) + +;; definition for function vector-seek-2d-yz-smooth! +(defun vector-seek-2d-yz-smooth! ((arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + "Smoothly seek vec's y and z components toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a circle of radius max-step. + Doesn't touch x or w." + (let ((f0-1 (- (-> arg1 y) (-> arg0 y))) + (f2-1 (- (-> arg1 z) (-> arg0 z))) + ) + (when (or (!= f0-1 0.0) (!= f2-1 0.0)) + (let* ((f1-5 (* f0-1 arg3)) + (f0-3 (* f2-1 arg3)) + (f2-4 (sqrtf (+ (square f1-5) (square f0-3)))) + ) + (cond + ((>= arg2 f2-4) + (+! (-> arg0 y) f1-5) + (+! (-> arg0 z) f0-3) + ) + (else + (let ((f2-6 (/ arg2 f2-4))) + (+! (-> arg0 y) (* f2-6 f1-5)) + (+! (-> arg0 z) (* f2-6 f0-3)) + ) + ) + ) + ) + ) + ) + arg0 + ) + +;; definition for function vector-seek-3d-smooth! +(defun vector-seek-3d-smooth! ((arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + "Smoothly seek vec's x, y, and z components toward target. + The step always points toward the target and has length (dist * alpha). + If the step is longer than max-step, the step is projected onto a circle of radius max-step. + Doesn't touch w." + (let ((f0-1 (- (-> arg1 x) (-> arg0 x))) + (f1-2 (- (-> arg1 y) (-> arg0 y))) + (f3-1 (- (-> arg1 z) (-> arg0 z))) + ) + (when (or (!= f0-1 0.0) (!= f1-2 0.0) (!= f3-1 0.0)) + (let* ((f2-6 (* f0-1 arg3)) + (f1-3 (* f1-2 arg3)) + (f0-4 (* f3-1 arg3)) + (f3-5 (sqrtf (+ (square f2-6) (square f1-3) (square f0-4)))) + ) + (cond + ((>= arg2 f3-5) + (+! (-> arg0 x) f2-6) + (+! (-> arg0 y) f1-3) + (+! (-> arg0 z) f0-4) + ) + (else + (let ((f3-7 (/ arg2 f3-5))) + (+! (-> arg0 x) (* f3-7 f2-6)) + (+! (-> arg0 y) (* f3-7 f1-3)) + (+! (-> arg0 z) (* f3-7 f0-4)) + ) + ) + ) + ) + ) + ) + arg0 + ) + +;; definition for function seek-with-smooth +(defun seek-with-smooth ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float)) + "Move value closer to target. + If we are within deadband, just go straight to target. + If not, try to go alpha*err. If that is a larger step than max-step, limit to max-step" + (let ((f0-1 (- arg1 arg0))) + (cond + ((>= arg4 (fabs f0-1)) + arg1 + ) + (else + (let ((f0-2 (* f0-1 arg3))) + (let ((f1-4 (- arg2))) + (cond + ((< f0-2 f1-4) + (set! f0-2 f1-4) + ) + ((< arg2 f0-2) + (set! f0-2 arg2) + ) + ) + ) + (+ f0-2 arg0) + ) + ) + ) + ) + ) + +;; definition for function vector-identity! +(defun vector-identity! ((arg0 vector)) + "Set arg0 to 1, 1, 1, 1." + (set! (-> arg0 x) 1.0) + (set! (-> arg0 y) 1.0) + (set! (-> arg0 z) 1.0) + (set! (-> arg0 w) 1.0) + arg0 + ) + +;; definition for function vector-seconds +(defun vector-seconds ((arg0 vector) (arg1 vector)) + "Convert from actual seconds to the seconds unit." + (set! (-> arg0 x) (* 300.0 (-> arg1 x))) + (set! (-> arg0 y) (* 300.0 (-> arg1 y))) + (set! (-> arg0 z) (* 300.0 (-> arg1 z))) + arg0 + ) + +;; definition for function vector-seconds! +(defun vector-seconds! ((arg0 vector)) + "Convert from actual seconds to seconds, in place." + (set! (-> arg0 x) (* 300.0 (-> arg0 x))) + (set! (-> arg0 y) (* 300.0 (-> arg0 y))) + (set! (-> arg0 z) (* 300.0 (-> arg0 z))) + arg0 + ) + +;; definition for function vector-v! +(defun vector-v! ((arg0 vector)) + "Convert a velocity to a displacement per frame. The velocity should be in X/actual_second. + Uses the current process clock." + (vector-float*! arg0 arg0 (seconds-per-frame)) + arg0 + ) + +;; definition for function vector-v+! +(defun vector-v+! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Euler forward step, using the current display time settings." + (vector+float*! arg0 arg1 arg2 (seconds-per-frame)) + arg0 + ) + +;; definition for function vector-v*float+! +(defun vector-v*float+! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Euler forward step, scaling velocity by velocity-scale." + (vector+float*! arg0 arg1 arg2 (* arg3 (seconds-per-frame))) + arg0 + ) + +;; definition for function vector-v++! +(defun vector-v++! ((arg0 vector) (arg1 vector)) + "Update position in place, using display's current timing." + (vector+float*! arg0 arg0 arg1 (seconds-per-frame)) + arg0 + ) + +;; definition for function vector-v*float! +(defun vector-v*float! ((arg0 vector) (arg1 vector) (arg2 float)) + "Go from velocity to delta-p per frame, scaling by scale." + (vector-float*! arg0 arg1 (* arg2 (seconds-per-frame))) + ) + +;; definition for function vector-v*float++! +(defun vector-v*float++! ((arg0 vector) (arg1 vector) (arg2 float)) + "Update position with given velocity, scaled by scale." + (vector+float*! arg0 arg0 arg1 (* arg2 (seconds-per-frame))) + arg0 + ) + +;; definition for function vector-to-ups! +(defun vector-to-ups! ((arg0 vector) (arg1 vector)) + "Go from units per frame to units per second?" + (local-vars (at-0 int)) + (with-pp + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (let ((f0-0 (-> pp clock frames-per-second))) + (.mov at-0 f0-0) + ) + (.mov vf2 at-0) + (.mov.vf.w vf1 vf0) + (.mul.x.vf.xyz vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + ) + +;; definition for function vector-from-ups! +(defun vector-from-ups! ((arg0 vector) (arg1 vector)) + "Go from units per second to units per frame?" + (local-vars (at-0 int)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (let ((f0-0 (seconds-per-frame))) + (.mov at-0 f0-0) + ) + (.mov vf2 at-0) + (.mov.vf.w vf1 vf0) + (.mul.x.vf.xyz vf1 vf1 vf2) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function vector-length +(defun vector-length ((arg0 vector)) + "Get the length of the xyz part." + (vector-length arg0) + ) + +;; definition for function vector-length-squared +(defun vector-length-squared ((arg0 vector)) + "Get the squared length of the xyz part." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.add.w.vf.x vf2 vf0 vf0) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf.x acc vf2 vf1) + (.add.mul.y.vf.x acc vf2 vf1 acc) + (.add.mul.z.vf.x vf1 vf2 vf1 acc) + (.mov v0-0 vf1) + v0-0 + ) + ) + +;; definition for function vector-xz-length-squared +(defun vector-xz-length-squared ((arg0 vector)) + "Get the length of the xz part, squared." + (+ (* (-> arg0 x) (-> arg0 x)) (* (-> arg0 z) (-> arg0 z))) + ) + +;; definition for function vector-xz-length +(defun vector-xz-length ((arg0 vector)) + "Get the length of the xz part." + (sqrtf (+ (* (-> arg0 x) (-> arg0 x)) (* (-> arg0 z) (-> arg0 z)))) + ) + +;; definition for function vector-vector-distance +(defun vector-vector-distance ((arg0 vector) (arg1 vector)) + "Subtract the xyz parts and get the norm." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg0 quad)) + (.lvf vf3 (&-> arg1 quad)) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf.w acc vf0 vf1) + (.add.mul.y.vf.w acc vf0 vf1 acc) + (.add.mul.z.vf.w vf1 vf0 vf1 acc) + (.sqrt.vf Q vf1 :ftf #b11) + (.add.w.vf.x vf1 vf0 vf0) + (.wait.vf) + (.mul.vf.x vf1 vf1 Q) + (.nop.vf) + (.nop.vf) + (.mov v0-0 vf1) + v0-0 + ) + ) + +;; definition for function vector-vector-distance-squared +(defun vector-vector-distance-squared ((arg0 vector) (arg1 vector)) + "Squared norm of the difference of the xyz parts." + (local-vars (v0-0 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (.lvf vf2 (&-> arg0 quad)) + (.lvf vf3 (&-> arg1 quad)) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.y.vf.x vf1 vf1 vf1) + (.add.z.vf.x vf1 vf1 vf1) + (.mov v0-0 vf1) + v0-0 + ) + ) + +;; definition for function vector-vector-xz-distance +(defun vector-vector-xz-distance ((arg0 vector) (arg1 vector)) + "Distance on the xz plane." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg0 quad)) + (.lvf vf3 (&-> arg1 quad)) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf.w acc vf0 vf1) + (.add.mul.z.vf.w vf1 vf0 vf1 acc) + (.sqrt.vf Q vf1 :ftf #b11) + (.add.w.vf.x vf1 vf0 vf0) + (.wait.vf) + (.mul.vf.x vf1 vf1 Q) + (.nop.vf) + (.nop.vf) + (.mov v0-0 vf1) + v0-0 + ) + ) + +;; definition for function vector-vector-xy-distance +(defun vector-vector-xy-distance ((arg0 vector) (arg1 vector)) + "distance on the xy plane." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg0 quad)) + (.lvf vf3 (&-> arg1 quad)) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf.w acc vf0 vf1) + (.add.mul.y.vf.w vf1 vf0 vf1 acc) + (.sqrt.vf Q vf1 :ftf #b11) + (.add.w.vf.x vf1 vf0 vf0) + (.wait.vf) + (.mul.vf.x vf1 vf1 Q) + (.nop.vf) + (.nop.vf) + (.mov v0-0 vf1) + v0-0 + ) + ) + +;; definition for function vector-vector-xz-distance-squared +(defun vector-vector-xz-distance-squared ((arg0 vector) (arg1 vector)) + "Distance on the xz plane squared." + (local-vars (v0-0 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (.lvf vf2 (&-> arg0 quad)) + (.lvf vf3 (&-> arg1 quad)) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.z.vf.x vf1 vf1 vf1) + (.mov v0-0 vf1) + v0-0 + ) + ) + +;; definition for function vector-vector-planar-distance +(defun vector-vector-planar-distance ((arg0 vector) (arg1 vector) (arg2 vector)) + (vector-vector-distance + (vector-flatten! (new 'stack-no-clear 'vector) arg0 arg2) + (vector-flatten! (new 'stack-no-clear 'vector) arg1 arg2) + ) + ) + +;; definition for function vector-normalize! +(defun vector-normalize! ((arg0 vector) (arg1 float)) + "Modify arg0 in place to have length arg1 for its xyz components. The w part is not changed." + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.mul.vf.xyz vf2 vf1 vf1) + (let ((v1-0 arg1)) + (.mov vf3 v1-0) + ) + (.mul.x.vf.w acc vf0 vf2) + (.add.mul.y.vf.w acc vf0 vf2 acc) + (.add.mul.z.vf.w vf2 vf0 vf2 acc) + (.isqrt.vf Q vf3 vf2 :fsf #b0 :ftf #b11) + (.wait.vf) + (.mul.vf.xyz vf1 vf1 Q) + (.nop.vf) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function vector-normalize-ret-len! +(defun vector-normalize-ret-len! ((arg0 vector) (arg1 float)) + "Modify arg0 in place to have length arg1 for its xyz components. + The w part isn't changed and the _original_ length is returned." + (local-vars (v1-1 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.mul.vf.xyz vf2 vf1 vf1) + (let ((v1-0 arg1)) + (.mov vf3 v1-0) + ) + (.mul.x.vf.w acc vf0 vf2) + (.add.mul.y.vf.w acc vf0 vf2 acc) + (.add.mul.z.vf.w vf2 vf0 vf2 acc) + (.isqrt.vf Q vf3 vf2 :fsf #b0 :ftf #b11) + (.add.w.vf.x vf2 vf0 vf2) + (.mov v1-1 vf2) + (let ((v0-0 (sqrtf v1-1))) + (.wait.vf) + (.mul.vf.xyz vf1 vf1 Q) + (.nop.vf) + (.nop.vf) + (.nop.vf) + (.svf (&-> arg0 quad) vf1) + v0-0 + ) + ) + ) + +;; definition for function vector-normalize-copy! +;; INFO: Used lq/sq +(defun vector-normalize-copy! ((arg0 vector) (arg1 vector) (arg2 float)) + "Normalize, but not in place. + This implementation is very good compared to the vector-normalize! one. + The w component is set to 1." + (let ((f0-0 (vector-length arg1))) + (cond + ((= f0-0 0.0) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + (else + (let ((v1-3 (/ arg2 f0-0))) + (set! (-> arg0 x) (* (-> arg1 x) v1-3)) + (set! (-> arg0 y) (* (-> arg1 y) v1-3)) + (set! (-> arg0 z) (* (-> arg1 z) v1-3)) + ) + ) + ) + ) + (set! (-> arg0 w) 1.0) + arg0 + ) + +;; definition for function vector-xz-normalize! +(defun vector-xz-normalize! ((arg0 vector) (arg1 float)) + "Normalize, xz components only." + (let* ((v1-0 arg0) + (f0-4 (sqrtf (+ (* (-> v1-0 x) (-> v1-0 x)) (* (-> v1-0 z) (-> v1-0 z))))) + ) + (when (!= f0-4 0.0) + (let ((v1-3 (/ arg1 f0-4))) + (set! (-> arg0 x) (* (-> arg0 x) v1-3)) + (set! (-> arg0 z) (* (-> arg0 z) v1-3)) + ) + ) + ) + arg0 + ) + +;; definition for function vector-xz-normalize-copy! +;; INFO: Used lq/sq +(defun vector-xz-normalize-copy! ((arg0 vector) (arg1 vector) (arg2 float)) + "Normalize, xz components only." + (let* ((v1-0 arg1) + (f0-4 (sqrtf (+ (* (-> v1-0 x) (-> v1-0 x)) (* (-> v1-0 z) (-> v1-0 z))))) + ) + (cond + ((= f0-4 0.0) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + (else + (let ((v1-3 (/ arg2 f0-4))) + (set! (-> arg0 x) (* (-> arg1 x) v1-3)) + (set! (-> arg0 y) 0.0) + (set! (-> arg0 z) (* (-> arg1 z) v1-3)) + ) + ) + ) + ) + (set! (-> arg0 w) 1.0) + arg0 + ) + +;; definition for function vector-length-max! +(defun vector-length-max! ((arg0 vector) (arg1 float)) + "Make vector at most arg1 length (xyz only). + If it is larger, project onto sphere. + Doesn't touch w" + (let ((f0-0 (vector-length arg0))) + (when (not (or (= f0-0 0.0) (< f0-0 arg1))) + (let ((f0-1 (/ arg1 f0-0))) + (set! (-> arg0 x) (* (-> arg0 x) f0-1)) + (set! (-> arg0 y) (* (-> arg0 y) f0-1)) + (set! (-> arg0 z) (* (-> arg0 z) f0-1)) + ) + ) + ) + arg0 + ) + +;; definition for function vector-xz-length-max! +(defun vector-xz-length-max! ((arg0 vector) (arg1 float)) + "Make vector at most arg1 length (xz only). + It it is larger, project onto circle. + Doesn't touch w or y." + (let* ((v1-0 arg0) + (f0-4 (sqrtf (+ (* (-> v1-0 x) (-> v1-0 x)) (* (-> v1-0 z) (-> v1-0 z))))) + ) + (when (not (or (= f0-4 0.0) (< f0-4 arg1))) + (let ((f0-5 (/ arg1 f0-4))) + (set! (-> arg0 x) (* (-> arg0 x) f0-5)) + (set! (-> arg0 z) (* (-> arg0 z) f0-5)) + ) + ) + ) + arg0 + ) + +;; definition for function vector-rotate-around-x! +;; INFO: Used lq/sq +(defun vector-rotate-around-x! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate a vector around the x axis." + (let* ((f28-0 (- arg2)) + (f30-0 (cos f28-0)) + (f1-0 (sin f28-0)) + (f2-0 (-> arg1 z)) + (f0-1 (-> arg1 y)) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 z) (- (* f2-0 f30-0) (* f0-1 f1-0))) + (set! (-> arg0 y) (+ (* f2-0 f1-0) (* f0-1 f30-0))) + ) + arg0 + ) + +;; definition for function vector-rotate-around-y! +;; INFO: Used lq/sq +(defun vector-rotate-around-y! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate a vector around the y axis." + (let ((f26-0 (-> arg1 z)) + (f30-0 (-> arg1 x)) + (f28-0 (cos arg2)) + (f0-0 (sin arg2)) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 z) (- (* f26-0 f28-0) (* f30-0 f0-0))) + (set! (-> arg0 x) (+ (* f26-0 f0-0) (* f30-0 f28-0))) + ) + arg0 + ) + +;; definition for function vector-rotate90-around-y! +;; INFO: Used lq/sq +(defun vector-rotate90-around-y! ((arg0 vector) (arg1 vector)) + "Rotate a vector 90 degrees around y." + (set! (-> arg0 quad) (-> arg1 quad)) + (let ((f0-0 (-> arg0 x))) + (set! (-> arg0 x) (- (-> arg1 z))) + (set! (-> arg0 z) f0-0) + ) + arg0 + ) + +;; definition for function vector-rotate-around-z! +;; INFO: Used lq/sq +(defun vector-rotate-around-z! ((arg0 vector) (arg1 vector) (arg2 float)) + "Rotate a vector around the z axis." + (let ((f26-0 (-> arg1 x)) + (f30-0 (-> arg1 y)) + (f28-0 (cos arg2)) + (f0-0 (sin arg2)) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 x) (- (* f26-0 f28-0) (* f30-0 f0-0))) + (set! (-> arg0 y) (+ (* f26-0 f0-0) (* f30-0 f28-0))) + ) + arg0 + ) + +;; definition for function rotate-y<-vector+vector +(defun rotate-y<-vector+vector ((arg0 vector) (arg1 vector)) + "Get the y rotation between vectors. These should have the same length." + (atan (- (-> arg1 x) (-> arg0 x)) (- (-> arg1 z) (-> arg0 z))) + ) + +;; definition for function rotate-x<-vector+vector +(defun rotate-x<-vector+vector ((arg0 vector) (arg1 vector)) + "Get the x rotation between vectors. These should have the same length." + (atan (- (-> arg1 y) (-> arg0 y)) (- (-> arg1 z) (-> arg0 z))) + ) + +;; definition for function rotate-z<-vector+vector +(defun rotate-z<-vector+vector ((arg0 vector) (arg1 vector)) + "Get the z rotation between vectors. These should have the same length." + (atan (- (-> arg1 x) (-> arg0 x)) (- (-> arg1 y) (-> arg0 y))) + ) + +;; definition for function rotate-vector-to-vector +(defun rotate-vector-to-vector ((arg0 vector) (arg1 vector) (arg2 vector)) + (let ((gp-0 (new 'stack-no-clear 'quaternion))) + (quaternion-from-two-vectors-max-angle! (the-as quaternion (&-> gp-0 x)) arg0 arg1 (the-as float arg2)) + (vector-orient-by-quat! arg0 arg0 (the-as quaternion (&-> gp-0 x))) + ) + (vector-normalize! arg0 1.0) + ) + +;; definition for function vector-cvt.w.s! +(defun vector-cvt.w.s! ((arg0 vector) (arg1 vector)) + "Convert float to int32. Truncate." + (rlet ((vf1 :class vf)) + (.lvf vf1 (&-> arg1 quad)) + (.ftoi.vf vf1 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function vector-cvt.s.w! +(defun vector-cvt.s.w! ((arg0 vector) (arg1 vector)) + "Convert float to int32." + (rlet ((vf1 :class vf)) + (.lvf vf1 (&-> arg1 quad)) + (.itof.vf vf1 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function rot-zxy-from-vector! +(defun rot-zxy-from-vector! ((arg0 vector) (arg1 vector)) + "I think this gives you a vector of euler angles to rotate some unit vector + to arg1." + (let* ((f28-0 (-> arg1 z)) + (f30-0 (-> arg1 x)) + (f0-0 (atan f30-0 f28-0)) + ) + (set! (-> arg0 y) f0-0) + (let* ((f26-0 (- f0-0)) + (f0-4 (- (* f28-0 (cos f26-0)) (* f30-0 (sin f26-0)))) + ) + (set! (-> arg0 x) (atan (- (-> arg1 y)) f0-4)) + ) + ) + (set! (-> arg0 z) 0.0) + arg0 + ) + +;; definition for function rot-zyx-from-vector! +(defun rot-zyx-from-vector! ((arg0 vector) (arg1 vector)) + "I think this gives you a vector of euler angles to rotate some unit vector + to arg1." + (let* ((f28-0 (-> arg1 z)) + (f30-0 (- (-> arg1 y))) + (f0-1 (atan f30-0 f28-0)) + ) + (set! (-> arg0 x) f0-1) + (let* ((f26-0 (- f0-1)) + (f0-5 (- (* f28-0 (cos f26-0)) (* f30-0 (sin f26-0)))) + ) + (set! (-> arg0 y) (atan (-> arg1 x) f0-5)) + ) + ) + (set! (-> arg0 z) 0.0) + arg0 + ) + +;; definition for function vector-world-to-local! +(defun vector-world-to-local! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 quaternion)) + (vector-! arg0 arg1 arg2) + (vector-inv-orient-by-quat! arg0 arg0 arg3) + ) + +;; definition for function vector-local-to-world! +(defun vector-local-to-world! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 quaternion)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (vector-orient-by-quat! arg0 arg1 arg3) + (let ((v0-1 arg0)) + (.lvf vf4 (&-> arg0 quad)) + (.lvf vf5 (&-> arg2 quad)) + (.mov.vf.w vf6 vf0) + (.add.vf.xyz vf6 vf4 vf5) + (.svf (&-> v0-1 quad) vf6) + v0-1 + ) + ) + ) + +;; definition for function vector-lerp! +(defun vector-lerp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Linearly interpolate between two vectors. Alpha isn't clamped. + w will be set to 1." + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.mov vf4 arg3) + (.add.x.vf.w vf3 vf0 vf0) + (.sub.vf vf2 vf2 vf1) + (.mul.x.vf vf2 vf2 vf4) + (.add.vf.xyz vf3 vf1 vf2) + (.svf (&-> arg0 quad) vf3) + arg0 + ) + ) + +;; definition for function vector-lerp-clamp! +;; INFO: Used lq/sq +(defun vector-lerp-clamp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Linearly interpolate between two vectors, clamping alpha to 0, 1. + w will be set to 1." + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (cond + ((>= 0.0 arg3) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + ((>= arg3 1.0) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + (else + (let ((v1-3 arg0)) + (let ((f0-2 arg3)) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (let ((a1-1 f0-2)) + (.mov vf4 a1-1) + ) + ) + (.add.x.vf.w vf3 vf0 vf0) + (.sub.vf vf2 vf2 vf1) + (.mul.x.vf vf2 vf2 vf4) + (.add.vf.xyz vf3 vf1 vf2) + (.svf (&-> v1-3 quad) vf3) + ) + ) + ) + arg0 + ) + ) + +;; definition for function vector4-lerp! +(defun vector4-lerp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Interpolate all 4 elements of a vector. Alpha is not clamped." + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.mov vf4 arg3) + (.sub.vf vf2 vf2 vf1) + (.mul.x.vf vf2 vf2 vf4) + (.add.vf vf3 vf1 vf2) + (.svf (&-> arg0 quad) vf3) + arg0 + ) + ) + +;; definition for function vector4-lerp-clamp! +;; INFO: Used lq/sq +(defun vector4-lerp-clamp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Interpolate all 4 elements of a vector. Alpha is clamped to [0, 1]." + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (cond + ((>= 0.0 arg3) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + ((>= arg3 1.0) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + (else + (let ((v1-3 arg0)) + (let ((f0-2 arg3)) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (let ((a1-1 f0-2)) + (.mov vf4 a1-1) + ) + ) + (.sub.vf vf2 vf2 vf1) + (.mul.x.vf vf2 vf2 vf4) + (.add.vf vf3 vf1 vf2) + (.svf (&-> v1-3 quad) vf3) + ) + ) + ) + arg0 + ) + ) + +;; definition for function vector4w-lerp! +(defun vector4w-lerp! ((arg0 vector4w) (arg1 vector4w) (arg2 vector4w) (arg3 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.itof.vf vf1 vf1) + (.itof.vf vf2 vf2) + (.mov vf3 arg3) + (.sub.vf vf4 vf2 vf1) + (.mul.w.vf acc vf1 vf0) + (.add.mul.x.vf vf5 vf4 vf3 acc) + (.ftoi.vf vf5 vf5) + (.svf (&-> arg0 quad) vf5) + arg0 + ) + ) + +;; definition for function vector-degi +;; INFO: Used lq/sq +(defun vector-degi ((arg0 vector) (arg1 vector)) + "Convert a vector (in _rotations_) to degrees units, stored in an int. + Truncates to the nearest _rotation_. + Neither the input or output is a commonly used form. + Unsurprisingly, this strange function is never used." + (local-vars (v1-0 uint128) (v1-1 uint128)) + (rlet ((vf1 :class vf)) + (.lvf vf1 (&-> arg1 quad)) + (.ftoi.vf vf1 vf1) + (.mov v1-0 vf1) + (.pw.sll v1-1 v1-0 16) + (set! (-> arg0 quad) v1-1) + arg0 + ) + ) + +;; definition for function vector-degf +;; INFO: Used lq/sq +(defun vector-degf ((arg0 vector) (arg1 vector)) + "Convert a vector (in integer degree units) to floating point rotations. + Truncates to the nearest _rotation_. + Like the previous function, this is stupid and unused." + (local-vars (v1-1 uint128)) + (rlet ((vf1 :class vf)) + (let ((v1-0 (-> arg1 quad))) + (.pw.sra v1-1 v1-0 16) + ) + (.mov vf1 v1-1) + (.itof.vf vf1 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function vector-degmod +(defun vector-degmod ((arg0 vector) (arg1 vector)) + "This one is actually right. Wraps degrees units (in floats, like they should be) + to +/- half a rotation." + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) + (rlet ((vf1 :class vf)) + (.lvf vf1 (&-> arg1 quad)) + (.ftoi.vf vf1 vf1) + (.mov v1-0 vf1) + (.pw.sll v1-1 v1-0 16) + (.pw.sra v1-2 v1-1 16) + (.mov vf1 v1-2) + (.itof.vf vf1 vf1) + (.svf (&-> arg0 quad) vf1) + arg0 + ) + ) + +;; definition for function vector-deg-diff +;; WARN: Return type mismatch float vs none. +(defun vector-deg-diff ((arg0 vector) (arg1 vector) (arg2 vector)) + "Wrapped difference, degrees units. Will have the usual 16-bit accuracy issue." + (local-vars + (v0-0 float) + (v1-0 uint128) + (v1-1 uint128) + (v1-2 uint128) + (v1-3 uint128) + (a1-1 uint128) + (a1-2 uint128) + ) + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.ftoi.vf vf1 vf1) + (.ftoi.vf vf2 vf2) + (.mov a1-1 vf1) + (.mov v1-0 vf2) + (.pw.sll a1-2 a1-1 16) + (.pw.sll v1-1 v1-0 16) + (.psubw v1-2 a1-2 v1-1) + (.pw.sra v1-3 v1-2 16) + (.mov vf1 v1-3) + (.itof.vf vf1 vf1) + (.svf (&-> arg0 quad) vf1) + (.mov v0-0 vf1) + (none) + ) + ) + +;; definition for function vector-deg-lerp-clamp! +;; INFO: Used lq/sq +(defun vector-deg-lerp-clamp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + "Apply deg-lerp-clamp to the xyz components of a vector. Sets w = 1." + (cond + ((>= 0.0 arg3) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + ((>= arg3 1.0) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + (else + (set! (-> arg0 x) (deg-lerp-clamp (-> arg1 x) (-> arg2 x) arg3)) + (set! (-> arg0 y) (deg-lerp-clamp (-> arg1 y) (-> arg2 y) arg3)) + (set! (-> arg0 z) (deg-lerp-clamp (-> arg1 z) (-> arg2 z) arg3)) + (set! (-> arg0 w) 1.0) + ) + ) + arg0 + ) + +;; definition for function vector3s-copy! +(defun vector3s-copy! ((arg0 vector) (arg1 vector)) + "Copy a vector3s" + (set! (-> arg0 x) (-> arg1 x)) + (set! (-> arg0 y) (-> arg1 y)) + (set! (-> arg0 z) (-> arg1 z)) + arg0 + ) + +;; definition for function vector3s+! +(defun vector3s+! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Add 2 vectors3." + (set! (-> arg0 x) (+ (-> arg1 x) (-> arg2 x))) + (set! (-> arg0 y) (+ (-> arg1 y) (-> arg2 y))) + (set! (-> arg0 z) (+ (-> arg1 z) (-> arg2 z))) + arg0 + ) + +;; definition for function vector3s*float! +(defun vector3s*float! ((arg0 vector) (arg1 vector) (arg2 float)) + "mult vectors3 by float" + (set! (-> arg0 x) (* (-> arg1 x) arg2)) + (set! (-> arg0 y) (* (-> arg1 y) arg2)) + (set! (-> arg0 z) (* (-> arg1 z) arg2)) + arg0 + ) + +;; definition for function vector3s-! +(defun vector3s-! ((arg0 vector) (arg1 vector) (arg2 vector)) + "Subtract 2 vectors3: c = (a - b)." + (set! (-> arg0 x) (- (-> arg1 x) (-> arg2 x))) + (set! (-> arg0 y) (- (-> arg1 y) (-> arg2 y))) + (set! (-> arg0 z) (- (-> arg1 z) (-> arg2 z))) + arg0 + ) + +;; definition for function vector4-add! +;; WARN: Return type mismatch float vs none. +(defun vector4-add! ((arg0 vector4) (arg1 vector4) (arg2 vector4)) + "Add 2 vector4s." + (local-vars (v0-0 float)) + (rlet ((vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (.lvf vf5 (&-> arg1 quad)) + (.lvf vf6 (&-> arg2 quad)) + (.add.vf vf4 vf5 vf6) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; definition for function vector4-sub! +;; WARN: Return type mismatch float vs none. +(defun vector4-sub! ((arg0 vector4) (arg1 vector4) (arg2 vector4)) + "Subtract 2 vector4s." + (local-vars (v0-0 float)) + (rlet ((vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (.lvf vf5 (&-> arg1 quad)) + (.lvf vf6 (&-> arg2 quad)) + (.sub.vf vf4 vf5 vf6) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; definition for function vector4-mul! +;; WARN: Return type mismatch float vs none. +(defun vector4-mul! ((arg0 vector4) (arg1 vector4) (arg2 vector4)) + "Multiple 2 vector4s." + (local-vars (v0-0 float)) + (rlet ((vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (.lvf vf5 (&-> arg1 quad)) + (.lvf vf6 (&-> arg2 quad)) + (.mul.vf vf4 vf5 vf6) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; definition for function vector4-scale! +;; WARN: Return type mismatch float vs none. +(defun vector4-scale! ((arg0 vector4) (arg1 vector4) (arg2 float)) + "arg0 = arg1 * arg2." + (local-vars (v0-0 float)) + (rlet ((vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (.mov vf6 arg2) + (.lvf vf5 (&-> arg1 quad)) + (.mul.x.vf vf4 vf5 vf6) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; definition for function vector4-madd! +;; WARN: Return type mismatch float vs none. +(defun vector4-madd! ((arg0 vector4) (arg1 vector4) (arg2 vector4) (arg3 float)) + "arg0 = arg1 + arg2 * arg3." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (.mov vf7 arg3) + (.lvf vf5 (&-> arg1 quad)) + (.lvf vf6 (&-> arg2 quad)) + (.mul.w.vf acc vf5 vf0) + (.add.mul.x.vf vf4 vf6 vf7 acc) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; definition for function vector4-msub! +;; WARN: Return type mismatch float vs none. +(defun vector4-msub! ((arg0 vector4) (arg1 vector4) (arg2 vector4) (arg3 float)) + "arg0 = arg1 - arg2 * arg3." + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (.mov vf7 arg3) + (.lvf vf5 (&-> arg1 quad)) + (.lvf vf6 (&-> arg2 quad)) + (.mul.w.vf acc vf5 vf0) + (.sub.mul.x.vf vf4 vf6 vf7 acc) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + (none) + ) + ) + +;; definition for function vector4-array-add! +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-add! ((arg0 (inline-array vector4)) (arg1 (inline-array vector4)) (arg2 (inline-array vector4)) (arg3 int)) + "Apply vector4-add! to all arrays." + (dotimes (s2-0 arg3) + (vector4-add! (the-as vector4 arg0) (the-as vector4 arg1) (the-as vector4 arg2)) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +;; definition for function vector4-array-sub! +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-sub! ((arg0 (inline-array vector4)) (arg1 (inline-array vector4)) (arg2 (inline-array vector4)) (arg3 int)) + "Apply vector4-sub! to all arrays." + (dotimes (s2-0 arg3) + (vector4-sub! (the-as vector4 arg0) (the-as vector4 arg1) (the-as vector4 arg2)) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +;; definition for function vector4-array-mul! +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-mul! ((arg0 (inline-array vector4)) (arg1 (inline-array vector4)) (arg2 (inline-array vector4)) (arg3 int)) + "Apply vector4-mul! to all arrays." + (dotimes (s2-0 arg3) + (vector4-mul! (the-as vector4 arg0) (the-as vector4 arg1) (the-as vector4 arg2)) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +;; definition for function vector4-array-scale! +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-scale! ((arg0 (inline-array vector4)) (arg1 (inline-array vector4)) (arg2 float) (arg3 int)) + "Apply vector4-scale! to all arrays." + (dotimes (s2-0 arg3) + (vector4-scale! (the-as vector4 arg0) (the-as vector4 arg1) arg2) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +;; definition for function vector4-array-madd! +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-madd! ((arg0 (inline-array vector4)) + (arg1 (inline-array vector4)) + (arg2 (inline-array vector4)) + (arg3 float) + (arg4 int) + ) + "Apply vector4-madd! to all arrays." + (dotimes (s1-0 arg4) + (vector4-madd! (the-as vector4 arg0) (the-as vector4 arg1) (the-as vector4 arg2) arg3) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +;; definition for function vector4-array-msub! +;; WARN: Return type mismatch symbol vs none. +(defun vector4-array-msub! ((arg0 (inline-array vector4)) + (arg1 (inline-array vector4)) + (arg2 (inline-array vector4)) + (arg3 float) + (arg4 int) + ) + "Apply vector4-msub! to all arrays." + (dotimes (s1-0 arg4) + (vector4-msub! (the-as vector4 arg0) (the-as vector4 arg1) (the-as vector4 arg2) arg3) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + (none) + ) + +;; definition for function vector4-array-lerp! +(defun vector4-array-lerp! ((arg0 (inline-array vector4)) + (arg1 (inline-array vector4)) + (arg2 (inline-array vector4)) + (arg3 float) + (arg4 int) + ) + "Apply vector4-lerp! to all arrays." + (dotimes (s1-0 arg4) + (vector4-lerp! (the-as vector arg0) (the-as vector arg1) (the-as vector arg2) arg3) + (set! arg1 (the-as (inline-array vector4) (-> arg1 1))) + (set! arg2 (the-as (inline-array vector4) (-> arg2 1))) + (set! arg0 (the-as (inline-array vector4) (-> arg0 1))) + ) + #f + ) + +;; definition for function spheres-overlap? +(defun spheres-overlap? ((arg0 sphere) (arg1 sphere)) + "Do the spheres overlap?" + (local-vars (v1-0 float) (a0-1 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (.lvf vf1 (&-> arg0 quad)) + (.lvf vf2 (&-> arg1 quad)) + (.sub.vf.xyz vf3 vf1 vf2) + (.mul.vf.xyz vf3 vf3 vf3) + (.add.w.vf.w vf4 vf1 vf2) + (.mul.w.vf.w vf4 vf4 vf4) + (.add.y.vf.x vf3 vf3 vf3) + (.add.z.vf.x vf3 vf3 vf3) + (.add.w.vf.x vf4 vf0 vf4) + (.mov a0-1 vf4) + (.mov v1-0 vf3) + (>= a0-1 v1-0) + ) + ) + +;; definition for function sphere<-vector! +;; INFO: Used lq/sq +(defun sphere<-vector! ((arg0 sphere) (arg1 vector)) + "Set the position of the sphere to arg1. Does not change the radius." + (let ((f0-0 (-> arg0 r))) + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 r) f0-0) + ) + arg0 + ) + +;; definition for function sphere<-vector+r! +;; INFO: Used lq/sq +(defun sphere<-vector+r! ((arg0 sphere) (arg1 vector) (arg2 float)) + "Set the position of the sphere from arg1 and the radius from arg2." + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 r) arg2) + arg0 + ) + +;; definition for function rand-vu-sphere-point! +(defun rand-vu-sphere-point! ((arg0 vector) (arg1 float)) + "Get a random point on the sphere at the origin with radius arg1. + The point is on the surface of the sphere." + (set-vector! + arg0 + (rand-vu-float-range -1.0 1.0) + (rand-vu-float-range -1.0 1.0) + (rand-vu-float-range -1.0 1.0) + 1.0 + ) + (vector-normalize! arg0 (rand-vu-float-range 0.0 arg1)) + ) + +;; definition for function rand-vu-sphere-point-uniform! +(defun rand-vu-sphere-point-uniform! ((arg0 vector) (arg1 float)) + (local-vars (v1-3 float) (f0-5 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + 666.6 + (until (>= 1.0 f0-5) + (set-vector! + arg0 + (rand-vu-float-range -1.0 1.0) + (rand-vu-float-range -1.0 1.0) + (rand-vu-float-range -1.0 1.0) + 1.0 + ) + (.lvf vf1 (&-> arg0 quad)) + (.add.w.vf.x vf2 vf0 vf0) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf.x acc vf2 vf1) + (.add.mul.y.vf.x acc vf2 vf1 acc) + (.add.mul.z.vf.x vf1 vf2 vf1 acc) + (.mov v1-3 vf1) + (set! f0-5 v1-3) + ) + (vector-float*! arg0 arg0 arg1) + ) + ) + +;; definition for method 2 of type vector2 +(defmethod print ((this vector2)) + (format #t "#" (-> this x) (-> this y) this) + this + ) + +;; definition for function vector-vector-angle-safe +(defun vector-vector-angle-safe ((arg0 vector) (arg1 vector)) + "Get the angle between two vectors, with some 'safety' applied..." + (let ((f0-1 (vector-dot + (vector-normalize-copy! (new 'stack-no-clear 'vector) arg0 1.0) + (vector-normalize-copy! (new 'stack-no-clear 'vector) arg1 1.0) + ) + ) + ) + (cond + ((>= f0-1 1.0) + 0.0 + ) + ((>= -1.0 f0-1) + 0.017257283 + ) + (else + (acos f0-1) + ) + ) + ) + ) + +;; definition for function vector-get-unique! +;; INFO: Used lq/sq +(defun vector-get-unique! ((arg0 vector) (arg1 vector)) + (let ((v1-0 0)) + (let ((f0-0 (-> arg1 x))) + (when (< (-> arg1 y) f0-0) + (set! f0-0 (-> arg1 y)) + (set! v1-0 1) + ) + (when (< (-> arg1 z) f0-0) + (-> arg1 z) + (set! v1-0 2) + ) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (set! (-> arg0 data v1-0) 1.0) + ) + arg0 + ) + +;; definition for function vector-get-closest-perpendicular! +;; INFO: Used lq/sq +(defun vector-get-closest-perpendicular! ((arg0 vector) (arg1 vector) (arg2 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector))) + 0.0 + (let ((f0-2 (vector-dot arg1 arg2))) + (vector-float*! s5-0 arg1 f0-2) + ) + (vector-! s5-0 arg2 s5-0) + (vector-normalize! s5-0 1.0) + (set! (-> arg0 quad) (-> s5-0 quad)) + ) + arg0 + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/net/scert-1-h_REF.gc b/test/decompiler/reference/jakx/engine/net/scert-1-h_REF.gc new file mode 100644 index 0000000000..8e4b1f21d4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/net/scert-1-h_REF.gc @@ -0,0 +1,9 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/net/scert-2-h_REF.gc b/test/decompiler/reference/jakx/engine/net/scert-2-h_REF.gc new file mode 100644 index 0000000000..8e4b1f21d4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/net/scert-2-h_REF.gc @@ -0,0 +1,9 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/physics/dynamics-h_REF.gc b/test/decompiler/reference/jakx/engine/physics/dynamics-h_REF.gc new file mode 100644 index 0000000000..c7438de302 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/physics/dynamics-h_REF.gc @@ -0,0 +1,82 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type dynamics +(deftype dynamics (basic) + ((name symbol) + (gravity-max meters) + (gravity-length meters) + (gravity vector :inline) + (gravity-normal vector :inline) + (walk-distance meters) + (run-distance meters) + ) + (:methods + (set-gravity-length (_type_ float) none) + ) + ) + +;; definition for method 3 of type dynamics +(defmethod inspect ((this dynamics)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tgravity-max: (meters ~m)~%" (-> this gravity-max)) + (format #t "~1Tgravity-length: (meters ~m)~%" (-> this gravity-length)) + (format #t "~1Tgravity: ~`vector`P~%" (-> this gravity)) + (format #t "~1Tgravity-normal: ~`vector`P~%" (-> this gravity-normal)) + (format #t "~1Twalk-distance: (meters ~m)~%" (-> this walk-distance)) + (format #t "~1Trun-distance: (meters ~m)~%" (-> this run-distance)) + (label cfg-4) + this + ) + +;; definition for method 9 of type dynamics +;; WARN: Return type mismatch int vs none. +(defmethod set-gravity-length ((this dynamics) (arg0 float)) + (set! (-> this gravity-length) arg0) + (vector-float*! (-> this gravity) (-> this gravity-normal) arg0) + 0 + (none) + ) + +;; definition for function time-to-apex +(defun time-to-apex ((arg0 float) (arg1 float)) + (the int (/ arg0 (- (/ arg1 300)))) + ) + +;; definition for function time-to-ground +(defun time-to-ground ((arg0 float) (arg1 float) (arg2 float)) + (let ((f0-0 0.0) + (v0-0 0) + ) + (while (< (- arg2) f0-0) + (set! arg0 (- arg0 (/ arg1 300))) + (+! f0-0 (/ arg0 300)) + (+! v0-0 1) + ) + v0-0 + ) + ) + +;; definition for symbol *standard-dynamics*, type dynamics +(define *standard-dynamics* (new 'static 'dynamics + :name 'standard + :gravity-max (meters 40) + :gravity-length (meters 60) + :gravity (new 'static 'vector :data (new 'static 'array float 4 0.0 245760.0 0.0 1.0)) + :gravity-normal (new 'static 'vector :data (new 'static 'array float 4 0.0 1.0 0.0 1.0)) + :walk-distance (meters 2) + :run-distance (meters 5) + ) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/physics/gravity-h_REF.gc b/test/decompiler/reference/jakx/engine/physics/gravity-h_REF.gc new file mode 100644 index 0000000000..8e4b1f21d4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/physics/gravity-h_REF.gc @@ -0,0 +1,9 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/physics/ragdoll-h_REF.gc b/test/decompiler/reference/jakx/engine/physics/ragdoll-h_REF.gc new file mode 100644 index 0000000000..e7b19d0ba7 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/physics/ragdoll-h_REF.gc @@ -0,0 +1,316 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type ragdoll-edit-info +(deftype ragdoll-edit-info (structure) + ((editing symbol) + (current-func uint64) + (analog-func uint64) + (affect uint64) + (single-step uint64) + (collision symbol) + (gravity symbol) + (skel-visible uint64) + (current-joint int8) + (auto-setup-now basic) + (child-stack ragdoll-joint 60) + (child-stack-num int8) + (last-frame time-frame) + (last-frame-dur time-frame) + ) + (:methods + (has-joint? (_type_ ragdoll-joint) symbol) + (ragdoll-edit-info-method-10 (_type_ object ragdoll-joint) symbol) + (fill-child-stack! (_type_ ragdoll) none) + (ragdoll-edit-info-method-12 (_type_) none) + (cycle-joints! (_type_ ragdoll) none) + (ragdoll-edit-info-method-14 (_type_ matrix vector (inline-array ragdoll-joint) ragdoll process-drawable) vector) + (ragdoll-edit-info-method-15 (_type_) none) + (ragdoll-edit-info-method-16 (_type_ ragdoll process-drawable) none) + (ragdoll-edit-info-method-17 (_type_ ragdoll process-drawable) none) + ) + ) + +;; definition for method 3 of type ragdoll-edit-info +(defmethod inspect ((this ragdoll-edit-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ragdoll-edit-info) + (format #t "~1Tediting: ~A~%" (-> this editing)) + (format #t "~1Tcurrent-func: ~D~%" (-> this current-func)) + (format #t "~1Tanalog-func: ~D~%" (-> this analog-func)) + (format #t "~1Taffect: ~D~%" (-> this affect)) + (format #t "~1Tsingle-step: ~D~%" (-> this single-step)) + (format #t "~1Tcollision: ~A~%" (-> this collision)) + (format #t "~1Tgravity: ~A~%" (-> this gravity)) + (format #t "~1Tskel-visible: ~D~%" (-> this skel-visible)) + (format #t "~1Tcurrent-joint: ~D~%" (-> this current-joint)) + (format #t "~1Tauto-setup-now: ~A~%" (-> this auto-setup-now)) + (format #t "~1Tchild-stack[60] @ #x~X~%" (-> this child-stack)) + (format #t "~1Tchild-stack-num: ~D~%" (-> this child-stack-num)) + (format #t "~1Tlast-frame: ~D~%" (-> this last-frame)) + (format #t "~1Tlast-frame-dur: ~D~%" (-> this last-frame-dur)) + (label cfg-4) + this + ) + +;; definition for symbol *ragdoll-edit-info*, type ragdoll-edit-info +(define *ragdoll-edit-info* (the-as ragdoll-edit-info 0)) + +;; definition for symbol *ragdoll-edit-info*, type ragdoll-edit-info +(define *ragdoll-edit-info* (new 'static 'ragdoll-edit-info + :editing #t + :current-func #x9 + :single-step #x2 + :collision #t + :gravity #t + :skel-visible #x1 + ) + ) + +;; definition of type ragdoll-joint-setup +(deftype ragdoll-joint-setup (structure) + ((joint-index int32) + (parent-joint int32) + (joint-type uint64) + (pre-tform vector :inline) + (geo-tform vector :inline) + (axial-slop float) + (max-angle float) + (coll-rad float) + (hit-sound uint16) + ) + ) + +;; definition for method 3 of type ragdoll-joint-setup +(defmethod inspect ((this ragdoll-joint-setup)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ragdoll-joint-setup) + (format #t "~1Tjoint-index: ~D~%" (-> this joint-index)) + (format #t "~1Tparent-joint: ~D~%" (-> this parent-joint)) + (format #t "~1Tjoint-type: ~D~%" (-> this joint-type)) + (format #t "~1Tpre-tform: #~%" (-> this pre-tform)) + (format #t "~1Tgeo-tform: #~%" (-> this geo-tform)) + (format #t "~1Taxial-slop: ~f~%" (-> this axial-slop)) + (format #t "~1Tmax-angle: ~f~%" (-> this max-angle)) + (format #t "~1Tcoll-rad: ~f~%" (-> this coll-rad)) + (format #t "~1Thit-sound: ~D~%" (-> this hit-sound)) + (label cfg-4) + this + ) + +;; definition of type ragdoll-setup +(deftype ragdoll-setup (structure) + ((orient-tform vector :inline) + (scale vector :inline) + (bg-collide-with collide-spec) + (joint-setup (array ragdoll-joint-setup)) + ) + ) + +;; definition for method 3 of type ragdoll-setup +(defmethod inspect ((this ragdoll-setup)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ragdoll-setup) + (format #t "~1Torient-tform: #~%" (-> this orient-tform)) + (format #t "~1Tscale: #~%" (-> this scale)) + (format #t "~1Tbg-collide-with: ~D~%" (-> this bg-collide-with)) + (format #t "~1Tjoint-setup: ~A~%" (-> this joint-setup)) + (label cfg-4) + this + ) + +;; definition of type ragdoll-joint +(deftype ragdoll-joint (structure) + ((quat quaternion :inline) + (position vector :inline) + (velocity vector :inline) + (bounce vector :inline) + (old-x vector :inline) + (pre-tform vector :inline) + (geo-tform vector :inline) + (axial-slop float) + (max-angle degrees) + (joint-length float) + (coll-rad float) + (ragdoll-joint-flags ragdoll-joint-flag) + (joint-type uint64) + (joint-index int8) + (parent-joint int8) + (parent-index int8) + (num-children int8) + (old-param0 basic) + (hit-sound sound-name) + (ground-pat pat-surface) + (user0 int32) + (original-speed float) + ) + ) + +;; definition for method 3 of type ragdoll-joint +;; INFO: Used lq/sq +(defmethod inspect ((this ragdoll-joint)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ragdoll-joint) + (format #t "~1Tquat: #~%" (-> this quat)) + (format #t "~1Tposition: #~%" (-> this position)) + (format #t "~1Tvelocity: #~%" (-> this velocity)) + (format #t "~1Tbounce: #~%" (-> this bounce)) + (format #t "~1Told-x: #~%" (-> this old-x)) + (format #t "~1Tpre-tform: #~%" (-> this pre-tform)) + (format #t "~1Tgeo-tform: #~%" (-> this geo-tform)) + (format #t "~1Taxial-slop: ~f~%" (-> this axial-slop)) + (format #t "~1Tmax-angle: ~f~%" (-> this max-angle)) + (format #t "~1Tjoint-length: ~f~%" (-> this joint-length)) + (format #t "~1Tcoll-rad: ~f~%" (-> this coll-rad)) + (format #t "~1Tragdoll-joint-flags: ~D~%" (-> this ragdoll-joint-flags)) + (format #t "~1Tjoint-type: ~D~%" (-> this joint-type)) + (format #t "~1Tjoint-index: ~D~%" (-> this joint-index)) + (format #t "~1Tparent-joint: ~D~%" (-> this parent-joint)) + (format #t "~1Tparent-index: ~D~%" (-> this parent-index)) + (format #t "~1Tnum-children: ~D~%" (-> this num-children)) + (format #t "~1Told-param0: ~A~%" (-> this old-param0)) + (format #t "~1Thit-sound: ~D~%" (-> this hit-sound)) + (format #t "~1Tground-pat: #x~X~%" (-> this ground-pat)) + (format #t "~1Tuser0: ~D~%" (-> this user0)) + (format #t "~1Toriginal-speed: ~f~%" (-> this original-speed)) + (label cfg-4) + this + ) + +;; definition of type ragdoll +(deftype ragdoll (basic) + ((ragdoll-joints ragdoll-joint 60 :inline) + (num-joints uint8) + (mirror matrix :inline) + (gravity vector :inline) + (gravity-target vector :inline) + (orient-tform vector :inline) + (scale vector :inline) + (stretch-vel float) + (stretch-vel-parallel float) + (compress-vel float) + (compress-vel-parallel float) + (momentum float) + (maximum-stretch float) + (turn-off-start time-frame) + (turn-off-duration time-frame) + (copy-velocity-start time-frame) + (root-offset vector :inline) + (rotate-vel quaternion :inline) + (rotate-adj quaternion :inline) + (rotate-adj-count int8) + (ragdoll-flags ragdoll-flag) + (flex-blend float) + (stable-joints int8) + (ragdoll-joint-remap uint8 100) + (allow-destabilize uint64) + (bg-collide-with uint32) + (water-info water-info :inline) + ) + (:methods + (ragdoll-method-9 (_type_ matrix process-drawable) none) + (ragdoll-method-10 (_type_ process-drawable symbol vector symbol) none) + (turn-off-for-duration! (_type_ time-frame) none) + (get-parent-joint (_type_ (inline-array ragdoll-joint)) ragdoll-joint) + (ragdoll-method-13 (_type_ ragdoll-edit-info ragdoll-joint matrix matrix) none) + (ragdoll-method-14 (_type_ process-drawable ragdoll-joint object matrix) none) + (ragdoll-method-15 (_type_ process-drawable ragdoll-edit-info) none) + (ragdoll-setup! (_type_ process-drawable ragdoll-setup) none) + (ragdoll-method-17 (_type_ process-drawable) none) + (ragdoll-method-18 (_type_) none) + (ragdoll-method-19 (_type_ vector int object matrix) none) + (reset-vec! (_type_ vector) none) + (ragdoll-method-21 (_type_ vector vector float) vector) + (get-max-angle-for-joint-idx (_type_ int) degrees) + (ragdoll-method-23 (_type_ vector vector float symbol) none) + (ragdoll-method-24 (_type_ vector int) none) + (enable-ragdoll! (_type_ process-drawable) none) + ) + ) + +;; definition for method 3 of type ragdoll +(defmethod inspect ((this ragdoll)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tragdoll-joints[60] @ #x~X~%" (-> this ragdoll-joints)) + (format #t "~1Tnum-joints: ~D~%" (-> this num-joints)) + (format #t "~1Tmirror: #~%" (-> this mirror)) + (format #t "~1Tgravity: #~%" (-> this gravity)) + (format #t "~1Tgravity-target: #~%" (-> this gravity-target)) + (format #t "~1Torient-tform: #~%" (-> this orient-tform)) + (format #t "~1Tscale: #~%" (-> this scale)) + (format #t "~1Tstretch-vel: ~f~%" (-> this stretch-vel)) + (format #t "~1Tstretch-vel-parallel: ~f~%" (-> this stretch-vel-parallel)) + (format #t "~1Tcompress-vel: ~f~%" (-> this compress-vel)) + (format #t "~1Tcompress-vel-parallel: ~f~%" (-> this compress-vel-parallel)) + (format #t "~1Tmomentum: ~f~%" (-> this momentum)) + (format #t "~1Tmaximum-stretch: ~f~%" (-> this maximum-stretch)) + (format #t "~1Tturn-off-start: ~D~%" (-> this turn-off-start)) + (format #t "~1Tturn-off-duration: ~D~%" (-> this turn-off-duration)) + (format #t "~1Tcopy-velocity-start: ~D~%" (-> this copy-velocity-start)) + (format #t "~1Troot-offset: #~%" (-> this root-offset)) + (format #t "~1Trotate-vel: #~%" (-> this rotate-vel)) + (format #t "~1Trotate-adj: #~%" (-> this rotate-adj)) + (format #t "~1Trotate-adj-count: ~D~%" (-> this rotate-adj-count)) + (format #t "~1Tragdoll-flags: ~D~%" (-> this ragdoll-flags)) + (format #t "~1Tflex-blend: ~f~%" (-> this flex-blend)) + (format #t "~1Tstable-joints: ~D~%" (-> this stable-joints)) + (format #t "~1Tragdoll-joint-remap[100] @ #x~X~%" (-> this ragdoll-joint-remap)) + (format #t "~1Tallow-destabilize: ~D~%" (-> this allow-destabilize)) + (format #t "~1Tbg-collide-with: ~D~%" (-> this bg-collide-with)) + (format #t "~1Twater-info: #~%" (-> this water-info)) + (label cfg-4) + this + ) + +;; definition of type ragdoll-proc +(deftype ragdoll-proc (process) + ((ragdoll ragdoll) + (last-attack-id uint32) + ) + (:methods + (ragdoll-proc-method-15 () none) + (ragdoll-proc-method-16 () none) + (ragdoll-proc-method-17 () none) + (ragdoll-proc-method-18 () none) + (ragdoll-proc-method-19 () none) + (ragdoll-proc-method-20 () none) + ) + ) + +;; definition for method 3 of type ragdoll-proc +(defmethod inspect ((this ragdoll-proc)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Tragdoll: ~A~%" (-> this ragdoll)) + (format #t "~2Tlast-attack-id: ~D~%" (-> this last-attack-id)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/physics/trajectory-h_REF.gc b/test/decompiler/reference/jakx/engine/physics/trajectory-h_REF.gc new file mode 100644 index 0000000000..78314b903b --- /dev/null +++ b/test/decompiler/reference/jakx/engine/physics/trajectory-h_REF.gc @@ -0,0 +1,250 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type trajectory +(deftype trajectory (structure) + ((initial-position vector :inline) + (initial-velocity vector :inline) + (time float) + (gravity meters) + ) + (:methods + (compute-trans-at-time (_type_ float vector) vector) + (compute-transv-at-time (_type_ float vector) vector) + (compute-time-until-apex (_type_) float) + (setup-from-to-duration! (_type_ vector vector float float) none) + (setup-from-to-xz-vel! (_type_ vector vector float float) none) + (setup-from-to-y-vel! (_type_ vector vector float float) none) + (setup-from-to-height! (_type_ vector vector float float) none) + (setup-from-to-duration-and-height! (_type_ vector vector float float) none) + (debug-draw (_type_) none) + ) + ) + +;; definition for method 3 of type trajectory +(defmethod inspect ((this trajectory)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'trajectory) + (format #t "~1Tinitial-position: ~`vector`P~%" (-> this initial-position)) + (format #t "~1Tinitial-velocity: ~`vector`P~%" (-> this initial-velocity)) + (format #t "~1Ttime: ~f~%" (-> this time)) + (format #t "~1Tgravity: (meters ~m)~%" (-> this gravity)) + (label cfg-4) + this + ) + +;; definition of type impact-control +(deftype impact-control (structure) + ((process (pointer process-drawable)) + (radius meters) + (joint int32) + (collide-with collide-spec) + (start-time uint64) + (trans vector 2 :inline) + (dir vector :inline) + ) + (:methods + (new (symbol type process-drawable int float collide-spec) _type_) + (initialize (_type_ process-drawable int float collide-spec) impact-control) + (update-from-cspace (_type_) none) + (impact-control-method-11 (_type_ collide-query process pat-surface) float) + ) + ) + +;; definition for method 3 of type impact-control +(defmethod inspect ((this impact-control)) + (when (not this) + (set! this this) + (goto cfg-7) + ) + (format #t "[~8x] ~A~%" this 'impact-control) + (format #t "~1Tprocess: #x~X~%" (-> this process)) + (format #t "~1Tradius: (meters ~m)~%" (-> this radius)) + (format #t "~1Tjoint: ~D~%" (-> this joint)) + (format #t "~1Tcollide-with: ~D~%" (-> this collide-with)) + (format #t "~1Tstart-time: ~D~%" (-> this start-time)) + (format #t "~1Ttrans[2] @ #x~X~%" (-> this trans)) + (dotimes (s5-0 2) + (format #t "~T [~D]~1Ttrans: ~`vector`P~%" s5-0 (-> this trans s5-0)) + ) + (format #t "~1Tdir: ~`vector`P~%" (-> this dir)) + (label cfg-7) + this + ) + +;; definition for method 0 of type impact-control +(defmethod new impact-control ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 float) (arg3 collide-spec)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + ((method-of-type impact-control initialize) + (the-as impact-control (t9-0 allocation v1-1)) + arg0 + arg1 + arg2 + arg3 + ) + ) + ) + +;; definition of type point-tracker +(deftype point-tracker (structure) + ((trans vector 2 :inline) + ) + (:methods + (new (symbol type vector vector) _type_) + (initialize (_type_ vector vector) point-tracker) + (point-tracker-method-10 (_type_ vector vector vector float) vector) + (point-tracker-method-11 (_type_ vector vector vector float) vector) + ) + ) + +;; definition for method 3 of type point-tracker +(defmethod inspect ((this point-tracker)) + (when (not this) + (set! this this) + (goto cfg-7) + ) + (format #t "[~8x] ~A~%" this 'point-tracker) + (format #t "~1Ttrans[2] @ #x~X~%" (-> this trans)) + (dotimes (s5-0 2) + (format #t "~T [~D]~1Ttrans: ~`vector`P~%" s5-0 (-> this trans s5-0)) + ) + (label cfg-7) + this + ) + +;; definition for method 0 of type point-tracker +(defmethod new point-tracker ((allocation symbol) (type-to-make type) (arg0 vector) (arg1 vector)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + ((method-of-type point-tracker initialize) (the-as point-tracker (t9-0 allocation v1-1)) arg0 arg1) + ) + ) + +;; definition of type combo-tracker +(deftype combo-tracker (point-tracker) + ((target handle) + (move-start-time time-frame) + ) + (:methods + (combo-tracker-method-12 (_type_ vector vector process time-frame) combo-tracker) + (combo-tracker-method-13 (_type_ handle vector float vector float) process-focusable) + ) + ) + +;; definition for method 3 of type combo-tracker +(defmethod inspect ((this combo-tracker)) + (when (not this) + (set! this this) + (goto cfg-7) + ) + (format #t "[~8x] ~A~%" this 'combo-tracker) + (format #t "~1Ttrans[2] @ #x~X~%" (-> this trans)) + (dotimes (s5-0 2) + (format #t "~T [~D]~1Ttrans: ~`vector`P~%" s5-0 (-> this trans s5-0)) + ) + (format #t "~1Ttarget: ~D~%" (-> this target)) + (format #t "~1Tmove-start-time: ~D~%" (-> this move-start-time)) + (label cfg-7) + this + ) + +;; definition of type traj2d-params +(deftype traj2d-params (structure) + ((x float) + (y float) + (gravity float) + (initial-tilt float) + (initial-speed float) + (time float) + ) + ) + +;; definition for method 3 of type traj2d-params +(defmethod inspect ((this traj2d-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'traj2d-params) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tgravity: ~f~%" (-> this gravity)) + (format #t "~1Tinitial-tilt: ~f~%" (-> this initial-tilt)) + (format #t "~1Tinitial-speed: ~f~%" (-> this initial-speed)) + (format #t "~1Ttime: ~f~%" (-> this time)) + (label cfg-4) + this + ) + +;; definition of type traj3d-params +(deftype traj3d-params (structure) + ((gravity float) + (initial-tilt float) + (initial-speed float) + (time float) + (src vector :inline) + (dest vector :inline) + (diff vector :inline) + (initial-velocity vector :inline) + ) + ) + +;; definition for method 3 of type traj3d-params +(defmethod inspect ((this traj3d-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'traj3d-params) + (format #t "~1Tgravity: ~f~%" (-> this gravity)) + (format #t "~1Tinitial-tilt: ~f~%" (-> this initial-tilt)) + (format #t "~1Tinitial-speed: ~f~%" (-> this initial-speed)) + (format #t "~1Ttime: ~f~%" (-> this time)) + (format #t "~1Tsrc: #~%" (-> this src)) + (format #t "~1Tdest: #~%" (-> this dest)) + (format #t "~1Tdiff: #~%" (-> this diff)) + (format #t "~1Tinitial-velocity: #~%" (-> this initial-velocity)) + (label cfg-4) + this + ) + +;; definition of type cubic-curve +(deftype cubic-curve (structure) + ((mat matrix :inline) + (vec vector 4 :inline :overlay-at (-> mat data 0)) + ) + (:methods + (cubic-curve-method-9 (_type_ vector vector vector vector) none) + (cubic-curve-method-10 (_type_ vector float) vector) + (cubic-curve-method-11 (_type_ vector float) vector) + (cubic-curve-method-12 (_type_ vector float) vector) + (debug-draw-curve (_type_) none) + ) + ) + +;; definition for method 3 of type cubic-curve +(defmethod inspect ((this cubic-curve)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cubic-curve) + (format #t "~1Tmat: #~%" (-> this vec)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/process-drawable/focus_REF.gc b/test/decompiler/reference/jakx/engine/process-drawable/focus_REF.gc new file mode 100644 index 0000000000..d65de3f2e2 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/process-drawable/focus_REF.gc @@ -0,0 +1,72 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type focus +(deftype focus (structure) + "A structure that keeps a handle to a [[process-focusable]]." + ((handle handle) + (collide-with collide-spec) + ) + (:methods + (clear-focused (_type_) none) + (collide-spec-match? (_type_ process-focusable) object) + (reset-to-collide-spec (_type_ collide-spec) none) + (focus-on! (_type_ process-focusable) symbol) + ) + ) + +;; definition for method 3 of type focus +(defmethod inspect ((this focus)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'focus) + (format #t "~1Thandle: ~D~%" (-> this handle)) + (format #t "~1Tcollide-with: ~D~%" (-> this collide-with)) + (label cfg-4) + this + ) + +;; definition for method 11 of type focus +;; WARN: Return type mismatch int vs none. +(defmethod reset-to-collide-spec ((this focus) (cspec collide-spec)) + "Reset this focus with the given [[collide-spec]]." + (set! (-> this collide-with) cspec) + (set! (-> this handle) (the-as handle #f)) + 0 + (none) + ) + +;; definition for method 10 of type focus +(defmethod collide-spec-match? ((this focus) (arg0 process-focusable)) + "If the focused process is not dead, + check that the [[collide-spec]] of the focus and the process match." + (when (and arg0 (not (logtest? (-> arg0 focus-status) (focus-status disable dead)))) + (let ((v1-2 (as-type (-> arg0 root) collide-shape))) + (and v1-2 (logtest? (-> this collide-with) (-> v1-2 root-prim prim-core collide-as))) + ) + ) + ) + +;; definition for method 12 of type focus +(defmethod focus-on! ((this focus) (arg0 process-focusable)) + "Set the `handle` of this focus to the given process. Return if the handle changed." + (when (!= (handle->process (-> this handle)) arg0) + (set! (-> this handle) (process->handle arg0)) + #t + ) + ) + +;; definition for method 9 of type focus +;; WARN: Return type mismatch int vs none. +(defmethod clear-focused ((this focus)) + "Reset the focus' handle." + (set! (-> this handle) (the-as handle #f)) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/process-drawable/process-drawable-h_REF.gc b/test/decompiler/reference/jakx/engine/process-drawable/process-drawable-h_REF.gc new file mode 100644 index 0000000000..0e1a8fea7f --- /dev/null +++ b/test/decompiler/reference/jakx/engine/process-drawable/process-drawable-h_REF.gc @@ -0,0 +1,191 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function cspace-by-name-no-fail +;; WARN: Return type mismatch object vs cspace. +(defun cspace-by-name-no-fail ((arg0 process-drawable) (arg1 string)) + (let ((v0-0 (the-as object (cspace-by-name arg0 arg1)))) + (the-as cspace (cond + ((the-as cspace v0-0) + (empty) + v0-0 + ) + (else + (format 0 "no cspace (~A)~%" arg1) + (-> arg0 node-list data) + ) + ) + ) + ) + ) + +;; definition for function cspace-index-by-name-no-fail +(defun cspace-index-by-name-no-fail ((proc process-drawable) (name string)) + (let ((idx (cspace-index-by-name proc name))) + (cond + ((< idx 0) + (format 0 "no cspace[ndx] (~A)~%" name) + 0 + ) + (else + (empty) + idx + ) + ) + ) + ) + +;; definition for function num-func-none +(defbehavior num-func-none process ((chan joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (-> chan frame-num) + ) + +;; definition for function num-func-+! +(defbehavior num-func-+! process ((chan joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (set! (-> chan frame-num) + (+ (-> chan frame-num) (* arg1 (* (-> chan frame-group speed) (-> self clock time-adjust-ratio)))) + ) + ) + +;; definition for function num-func--! +(defbehavior num-func--! process ((chan joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (set! (-> chan frame-num) + (- (-> chan frame-num) (* arg1 (* (-> chan frame-group speed) (-> self clock time-adjust-ratio)))) + ) + ) + +;; definition for function num-func-loop! +(defbehavior num-func-loop! process ((chan joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let* ((f0-1 (the float (+ (-> chan frame-group frames num-frames) -1))) + (f1-2 (+ (-> chan frame-num) f0-1 (* arg1 (* (-> chan frame-group speed) (-> self clock time-adjust-ratio))))) + ) + (set! (-> chan frame-num) (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1))) + ) + ) + +;; definition for function num-func-loop-speedless! +(defbehavior num-func-loop-speedless! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let* ((f0-1 (the float (+ (-> arg0 frame-group frames num-frames) -1))) + (f1-2 (+ (-> arg0 frame-num) f0-1 arg1)) + ) + (set! (-> arg0 frame-num) (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1))) + ) + ) + +;; definition for function num-func-loop-set! +(defbehavior num-func-loop-set! process ((chan joint-control-channel) (frame float) (arg2 float) (arg3 float)) + (set! (-> chan frame-num) frame) + frame + ) + +;; definition for function num-func-seek! +(defbehavior num-func-seek! process ((chan joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (set! (-> chan frame-num) + (seek (-> chan frame-num) arg1 (* arg2 (* (-> chan frame-group speed) (-> self clock time-adjust-ratio)))) + ) + ) + +;; definition for function num-func-blend-in! +(defbehavior num-func-blend-in! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let ((f30-0 (seek (-> arg0 frame-interp 0) 1.0 (* arg1 (-> self clock time-adjust-ratio))))) + (set! (-> arg0 frame-interp 0) f30-0) + (set! (-> arg0 frame-interp 1) f30-0) + (if (= f30-0 1.0) + (joint-control-reset! (-> arg0 parent) arg0) + ) + f30-0 + ) + ) + +;; definition for function joint-channel-float-delete! +;; WARN: Return type mismatch int vs none. +(defun joint-channel-float-delete! ((chan joint-control-channel)) + (let ((v1-0 (-> chan parent))) + (+! (-> v1-0 float-channels) -1) + (when (nonzero? (-> v1-0 float-channels)) + (let ((a1-5 (/ (&- (the-as pointer chan) (the-as uint (the-as pointer (-> v1-0 channel)))) 64))) + (if (< a1-5 (the-as int (+ (-> v1-0 active-channels) (-> v1-0 float-channels)))) + (qmem-copy<-! + (the-as pointer (-> v1-0 channel a1-5)) + (the-as pointer (-> v1-0 channel (+ a1-5 1))) + (the-as int (* (-> v1-0 float-channels) 64)) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function num-func-interp-play! +(defbehavior num-func-interp-play! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let ((f30-0 (the float (+ (-> arg0 frame-group frames num-frames) -1))) + (f28-0 (* arg3 (-> arg0 frame-group speed))) + ) + (seek! (-> arg0 frame-num) f30-0 (* arg1 (* (-> arg0 frame-group speed) (-> self clock time-adjust-ratio)))) + (cond + ((< (-> arg0 frame-num) f28-0) + (set! (-> arg0 frame-interp 0) (/ (* (-> arg0 frame-num) arg2) f28-0)) + ) + ((< (- f30-0 f28-0) (-> arg0 frame-num)) + (set! (-> arg0 frame-interp 0) (/ (* (- f30-0 (-> arg0 frame-num)) arg2) f28-0)) + (when (and (= (-> arg0 frame-num) f30-0) (logtest? (-> arg0 command) (joint-control-command eight))) + (joint-channel-float-delete! arg0) + (return 0.0) + ) + ) + (else + (set! (-> arg0 frame-interp 0) arg2) + ) + ) + ) + (set! (-> arg0 frame-interp 1) (-> arg0 frame-interp 0)) + (-> arg0 frame-num) + ) + +;; definition for function num-func-interp1-play! +(defbehavior num-func-interp1-play! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let ((f30-0 (the float (+ (-> arg0 frame-group frames num-frames) -1))) + (f28-0 (* arg3 (-> arg0 frame-group speed))) + ) + (seek! (-> arg0 frame-num) f30-0 (* arg1 (* (-> arg0 frame-group speed) (-> self clock time-adjust-ratio)))) + (cond + ((< (-> arg0 frame-num) f28-0) + (set! (-> arg0 frame-interp 1) (/ (* (-> arg0 frame-num) arg2) f28-0)) + ) + ((< (- f30-0 f28-0) (-> arg0 frame-num)) + (set! (-> arg0 frame-interp 1) (/ (* (- f30-0 (-> arg0 frame-num)) arg2) f28-0)) + (when (and (= (-> arg0 frame-num) f30-0) (logtest? (-> arg0 command) (joint-control-command eight))) + (joint-channel-float-delete! arg0) + (return 0.0) + ) + ) + (else + (set! (-> arg0 frame-interp 1) arg2) + ) + ) + ) + (-> arg0 frame-num) + ) + +;; definition for function num-func-chan +(defbehavior num-func-chan process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (set! (-> arg0 frame-num) + (-> (the-as joint-control-channel (+ (the-as uint arg0) (* (- (the int arg1) (-> arg0 group-sub-index)) 64))) + frame-num + ) + ) + ) + +;; definition for function num-func-identity +(defbehavior num-func-identity process ((chan joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (-> chan frame-num) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/ps2/rpc-h_REF.gc b/test/decompiler/reference/jakx/engine/ps2/rpc-h_REF.gc new file mode 100644 index 0000000000..b94e2497fa --- /dev/null +++ b/test/decompiler/reference/jakx/engine/ps2/rpc-h_REF.gc @@ -0,0 +1,239 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type rpc-buffer +(deftype rpc-buffer (basic) + "Buffer for storing input/output data for a remote procedure call to the overlord driver on the IOP." + ((elt-size uint32) + (elt-count uint32) + (elt-used uint32) + (busy symbol) + (base pointer) + (data uint8 :dynamic :offset 32) + ) + (:methods + (new (symbol type uint uint) _type_) + ) + ) + +;; definition for method 3 of type rpc-buffer +(defmethod inspect ((this rpc-buffer)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Telt-size: ~D~%" (-> this elt-size)) + (format #t "~1Telt-count: ~D~%" (-> this elt-count)) + (format #t "~1Telt-used: ~D~%" (-> this elt-used)) + (format #t "~1Tbusy: ~A~%" (-> this busy)) + (format #t "~1Tbase: ~D~%" (-> this base)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition for method 0 of type rpc-buffer +(defmethod new rpc-buffer ((allocation symbol) (type-to-make type) (elt-size uint) (elt-count uint)) + (let* ((a2-2 (+ (-> type-to-make size) 63 (* (the-as int elt-size) (the-as int elt-count)))) + (v0-0 (object-new allocation type-to-make (the-as int a2-2))) + ) + (set! (-> v0-0 elt-size) elt-size) + (set! (-> v0-0 elt-count) elt-count) + (set! (-> v0-0 elt-used) (the-as uint 0)) + (set! (-> v0-0 busy) #f) + (set! (-> v0-0 base) (logand -64 (&-> v0-0 data 63))) + v0-0 + ) + ) + +;; definition of type rpc-buffer-pair +(deftype rpc-buffer-pair (basic) + "A double buffer of RPC buffers. This is used to let the game queue up data in one buffer while +the other is being read/written by overlord." + ((buffer rpc-buffer 2) + (current rpc-buffer) + (last-recv-buffer pointer) + (rpc-port int32) + ) + (:methods + (new (symbol type uint uint int) rpc-buffer-pair) + (call (rpc-buffer-pair uint pointer uint) int) + (add-element (rpc-buffer-pair) pointer) + (decrement-elt-used (rpc-buffer-pair) int) + (sync (rpc-buffer-pair symbol) int) + (check-busy (rpc-buffer-pair) symbol) + (pop-last-received (rpc-buffer-pair) pointer) + ) + ) + +;; definition for method 3 of type rpc-buffer-pair +(defmethod inspect ((this rpc-buffer-pair)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tbuffer[2] @ #x~X~%" (-> this buffer)) + (format #t "~1Tcurrent: ~A~%" (-> this current)) + (format #t "~1Tlast-recv-buffer: #x~X~%" (-> this last-recv-buffer)) + (format #t "~1Trpc-port: ~D~%" (-> this rpc-port)) + (label cfg-4) + this + ) + +;; definition for method 0 of type rpc-buffer-pair +(defmethod new rpc-buffer-pair ((allocation symbol) (type-to-make type) (elt-size uint) (elt-count uint) (rpc-port int)) + (let ((s3-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s3-0 buffer 0) (new 'global 'rpc-buffer elt-size elt-count)) + (set! (-> s3-0 buffer 1) (new 'global 'rpc-buffer elt-size elt-count)) + (set! (-> s3-0 current) (-> s3-0 buffer 0)) + (set! (-> s3-0 last-recv-buffer) (the-as pointer #f)) + (set! (-> s3-0 rpc-port) rpc-port) + s3-0 + ) + ) + +;; definition for method 12 of type rpc-buffer-pair +(defmethod sync ((this rpc-buffer-pair) (print-stall-warning symbol)) + "Wait for an in-progress rpc to finish." + (let ((s5-0 (if (= (-> this current) (-> this buffer 0)) + (-> this buffer 1) + (-> this buffer 0) + ) + ) + ) + (when (-> s5-0 busy) + (when (nonzero? (rpc-busy? (-> this rpc-port))) + (if print-stall-warning + (format 0 "STALL: waiting for IOP on RPC port #~D~%" (-> this rpc-port)) + ) + (while (nonzero? (rpc-busy? (-> this rpc-port))) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + ) + ) + (set! (-> s5-0 busy) #f) + (set! (-> s5-0 elt-used) (the-as uint 0)) + 0 + ) + ) + 0 + ) + +;; definition for method 13 of type rpc-buffer-pair +(defmethod check-busy ((this rpc-buffer-pair)) + "Check to see if an rpc is in progress." + (let ((gp-0 (if (= (-> this current) (-> this buffer 0)) + (-> this buffer 1) + (-> this buffer 0) + ) + ) + ) + (when (-> gp-0 busy) + (if (nonzero? (rpc-busy? (-> this rpc-port))) + (return #t) + ) + (set! (-> gp-0 busy) #f) + (set! (-> gp-0 elt-used) (the-as uint 0)) + 0 + ) + ) + #f + ) + +;; definition for method 9 of type rpc-buffer-pair +(defmethod call ((this rpc-buffer-pair) (fno uint) (recv-buffer pointer) (recv-buffer-size uint)) + "Start an async RPC call. If there is already one in progress, stall and wait for it to finish." + (when (nonzero? (-> this current elt-used)) + (let ((s2-0 (if (= (-> this current) (-> this buffer 0)) + (-> this buffer 1) + (-> this buffer 0) + ) + ) + ) + (when (-> s2-0 busy) + (when (nonzero? (rpc-busy? (-> this rpc-port))) + (format 0 "STALL: waiting for IOP on RPC port #~D~%" (-> this rpc-port)) + (while (nonzero? (rpc-busy? (-> this rpc-port))) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + ) + ) + (set! (-> s2-0 busy) #f) + (set! (-> s2-0 elt-used) (the-as uint 0)) + 0 + ) + (let ((s1-0 (-> this current))) + (rpc-call + (-> this rpc-port) + fno + (the-as uint 1) + (the-as uint (-> s1-0 base)) + (the-as int (* (-> s1-0 elt-size) (-> s1-0 elt-used))) + (the-as uint recv-buffer) + (the-as int recv-buffer-size) + ) + (set! (-> s1-0 busy) #t) + ) + (set! (-> this last-recv-buffer) recv-buffer) + (set! (-> this current) s2-0) + ) + ) + 0 + ) + +;; definition for method 14 of type rpc-buffer-pair +(defmethod pop-last-received ((this rpc-buffer-pair)) + "Pop the response from the most recently completed rpc call." + (let ((v0-0 (-> this last-recv-buffer))) + (set! (-> this last-recv-buffer) (the-as pointer #f)) + v0-0 + ) + ) + +;; definition for method 10 of type rpc-buffer-pair +(defmethod add-element ((this rpc-buffer-pair)) + "Add an element. If the buffer is full, flush it!" + (let ((v1-0 (-> this current))) + (when (= (-> v1-0 elt-used) (-> v1-0 elt-count)) + (if (= (-> this rpc-port) 1) + (format 0 "WARNING: too many sound commands queued~%") + ) + (call this (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + (set! v1-0 (-> this current)) + ) + (let ((v0-2 (&+ (-> v1-0 base) (* (-> v1-0 elt-used) (-> v1-0 elt-size))))) + (+! (-> v1-0 elt-used) 1) + v0-2 + ) + ) + ) + +;; definition for method 11 of type rpc-buffer-pair +(defmethod decrement-elt-used ((this rpc-buffer-pair)) + "Remove the most recently queued element." + (if (> (-> this current elt-used) 0) + (+! (-> this current elt-used) -1) + ) + 0 + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/ps2/timer-h_REF.gc b/test/decompiler/reference/jakx/engine/ps2/timer-h_REF.gc new file mode 100644 index 0000000000..ec6d526985 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/ps2/timer-h_REF.gc @@ -0,0 +1,196 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type timer-mode +(deftype timer-mode (uint32) + "This matches the Tn_MODE register structure of the ps2 EE timers. +Only the lower 32 bits of these registers are usable, and the upper 16 hardwired to zero." + ((clks timer-clock-selection :offset 0 :size 2) + (gate uint8 :offset 2 :size 1) + (gats uint8 :offset 3 :size 1) + (gatm uint8 :offset 4 :size 2) + (zret uint8 :offset 6 :size 1) + (cue uint8 :offset 7 :size 1) + (cmpe uint8 :offset 8 :size 1) + (ovfe uint8 :offset 9 :size 1) + (equf uint8 :offset 10 :size 1) + (ovff uint8 :offset 11 :size 1) + ) + ) + +;; definition of type timer-bank +(deftype timer-bank (structure) + "This matches an EE timer (without a HOLD register, timers 2 and 3). +Each register is 128-bits wide, but only the lower 32-bits are usable, and the upper +16-bits of that are hardwired to zero." + ((count uint32) + (mode timer-mode :offset 16) + (comp uint32 :offset 32) + ) + ) + +;; definition for method 3 of type timer-bank +(defmethod inspect ((this timer-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'timer-bank) + (format #t "~1Tcount: #x~X~%" (-> this count)) + (format #t "~1Tmode: #x~X~%" (-> this mode)) + (format #t "~1Tcomp: #x~X~%" (-> this comp)) + (label cfg-4) + this + ) + +;; definition of type timer-hold-bank +(deftype timer-hold-bank (timer-bank) + "This matches an EE timer (with a HOLD register, timers 0 and 1)." + ((hold uint32 :offset 48) + ) + ) + +;; definition for method 3 of type timer-hold-bank +(defmethod inspect ((this timer-hold-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'timer-hold-bank) + (format #t "~1Tcount: #x~X~%" (-> this count)) + (format #t "~1Tmode: #x~X~%" (-> this mode)) + (format #t "~1Tcomp: #x~X~%" (-> this comp)) + (format #t "~1Thold: #x~X~%" (-> this hold)) + (label cfg-4) + this + ) + +;; definition of type stopwatch +(deftype stopwatch (basic) + "Stopwatches are used to measure CPU clock cycles. +They don't use the timer above, but instead the Count COP0 register, +which counts CPU clock cycles directly." + ((prev-time-elapsed time-frame) + (start-time time-frame) + (begin-level int32) + ) + ) + +;; definition for method 3 of type stopwatch +(defmethod inspect ((this stopwatch)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tprev-time-elapsed: ~D~%" (-> this prev-time-elapsed)) + (format #t "~1Tstart-time: ~D~%" (-> this start-time)) + (format #t "~1Tbegin-level: ~D~%" (-> this begin-level)) + (label cfg-4) + this + ) + +;; definition for symbol *ticks-per-frame*, type int +(define *ticks-per-frame* 9765) + +;; definition for function timer-init +(defun timer-init ((arg0 timer-bank) (arg1 timer-mode)) + "Initiate a timer, start counting at a rate of 1 every 256 bus clocks (BUSCLK: ~147.456MHz)." + (set! (-> arg0 mode) arg1) + (set! (-> arg0 count) (the-as uint 0)) + 0 + ) + +;; failed to figure out what this is: +(timer-init + (the-as timer-bank #x10000800) + (new 'static 'timer-mode :clks (timer-clock-selection busclk/256) :cue #x1) + ) + +;; definition of type sce-cd-clock +(deftype sce-cd-clock (structure) + ((stat uint8) + (second uint8) + (minute uint8) + (hour uint8) + (pad uint8) + (day uint8) + (month uint8) + (year uint8) + ) + ) + +;; definition for method 3 of type sce-cd-clock +(defmethod inspect ((this sce-cd-clock)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sce-cd-clock) + (format #t "~1Tstat: ~D~%" (-> this stat)) + (format #t "~1Tsecond: ~D~%" (-> this second)) + (format #t "~1Tminute: ~D~%" (-> this minute)) + (format #t "~1Thour: ~D~%" (-> this hour)) + (format #t "~1Tpad: ~D~%" (-> this pad)) + (format #t "~1Tday: ~D~%" (-> this day)) + (format #t "~1Tmonth: ~D~%" (-> this month)) + (format #t "~1Tyear: ~D~%" (-> this year)) + (label cfg-4) + this + ) + +;; definition for function bcd-conv +(defun bcd-conv ((arg0 uint)) + "Binary coded decimal to integer" + (+ (* 10 (the-as int (/ (the-as int arg0) 16))) (logand arg0 15)) + ) + +;; definition for symbol *month-days*, type (pointer uint32) +(define *month-days* + (new 'static 'array uint32 12 #x1f #x1c #x1f #x1e #x1f #x1e #x1f #x1f #x1e #x1f #x1e #x1f) + ) + +;; definition for function is-leap +(defun is-leap ((arg0 uint)) + (or (zero? (mod (the-as int arg0) 400)) (and (not (logtest? arg0 3)) (nonzero? (mod (the-as int arg0) 100)))) + ) + +;; definition for function mdy-to-day +(defun mdy-to-day ((arg0 int) (arg1 int) (arg2 uint)) + (if (is-leap arg2) + (set! (-> *month-days* 1) (the-as uint 29)) + (set! (-> *month-days* 1) (the-as uint 28)) + ) + (let ((v1-2 (+ arg0 -1)) + (v0-1 (+ arg1 -1)) + ) + (dotimes (a0-4 v1-2) + (+! v0-1 (-> (the-as (pointer int32) (&+ *month-days* (* a0-4 4))))) + ) + v0-1 + ) + ) + +;; definition for function rtclock-to-secs +(defun rtclock-to-secs ((arg0 sce-cd-clock)) + (let ((s5-0 0) + (s4-0 (bcd-conv (-> arg0 year))) + ) + (if (< s4-0 2000) + (+! s4-0 2000) + ) + (dotimes (s3-0 (+ s4-0 -1970)) + (+! s5-0 (* #x15180 (mdy-to-day 12 32 (the-as uint (+ s3-0 1970))))) + ) + (+ s5-0 + (* #x15180 (mdy-to-day (bcd-conv (-> arg0 month)) (bcd-conv (-> arg0 day)) (the-as uint s4-0))) + (* 3600 (bcd-conv (-> arg0 hour))) + (* 60 (bcd-conv (-> arg0 minute))) + (bcd-conv (-> arg0 second)) + ) + ) + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/ps2/timer_REF.gc b/test/decompiler/reference/jakx/engine/ps2/timer_REF.gc new file mode 100644 index 0000000000..36a33aae80 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/ps2/timer_REF.gc @@ -0,0 +1,246 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function timer-count +(defun timer-count ((arg0 timer-bank)) + (.sync.l) + (let ((v0-0 (-> arg0 count))) + (.sync.l) + v0-0 + ) + ) + +;; definition for function disable-irq +;; WARN: Return type mismatch int vs none. +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v0, Status] +(defun disable-irq () + (local-vars (v0-0 int)) + (let ((v1-0 (the-as uint #xfffffffe))) + (.mfc0 v0-0 Status) + (let ((v0-1 (logand v0-0 v1-0))) + (.mtc0 Status v0-1) + ) + ) + (.sync.p) + 0 + (none) + ) + +;; definition for function enable-irq +;; WARN: Return type mismatch int vs none. +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v0, Status] +(defun enable-irq () + (local-vars (v0-0 int)) + (.mfc0 v0-0 Status) + (let ((v0-1 (logior v0-0 1))) + (.mtc0 Status v0-1) + ) + (.sync.p) + 0 + (none) + ) + +;; definition for function stopwatch-init +(defun stopwatch-init ((arg0 stopwatch)) + (set! (-> arg0 begin-level) 0) + (set! (-> arg0 prev-time-elapsed) 0) + 0 + ) + +;; definition for function stopwatch-reset +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count] +(defun stopwatch-reset ((arg0 stopwatch)) + (local-vars (v1-3 int)) + (set! (-> arg0 prev-time-elapsed) 0) + (when (> (-> arg0 begin-level) 0) + 0 + (.mfc0 v1-3 Count) + (set! (-> arg0 start-time) (the-as time-frame v1-3)) + ) + 0 + ) + +;; definition for function stopwatch-start +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count] +(defun stopwatch-start ((arg0 stopwatch)) + (local-vars (v1-4 int)) + (when (zero? (-> arg0 begin-level)) + (set! (-> arg0 begin-level) 1) + 0 + (.mfc0 v1-4 Count) + (set! (-> arg0 start-time) (the-as time-frame v1-4)) + ) + 0 + ) + +;; definition for function stopwatch-stop +;; WARN: Return type mismatch int vs none. +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 a1, Count] +(defun stopwatch-stop ((arg0 stopwatch)) + (local-vars (a1-0 int)) + (when (> (-> arg0 begin-level) 0) + (set! (-> arg0 begin-level) 0) + 0 + (.mfc0 a1-0 Count) + (+! (-> arg0 prev-time-elapsed) (- (the-as time-frame a1-0) (-> arg0 start-time))) + ) + 0 + (none) + ) + +;; definition for function stopwatch-begin +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count] +(defun stopwatch-begin ((arg0 stopwatch)) + (local-vars (v1-3 int)) + (when (zero? (-> arg0 begin-level)) + 0 + (.mfc0 v1-3 Count) + (set! (-> arg0 start-time) (the-as time-frame v1-3)) + ) + (+! (-> arg0 begin-level) 1) + 0 + ) + +;; definition for function stopwatch-end +;; WARN: Return type mismatch int vs none. +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 a1, Count] +(defun stopwatch-end ((arg0 stopwatch)) + (local-vars (a1-0 int)) + (+! (-> arg0 begin-level) -1) + (when (zero? (-> arg0 begin-level)) + 0 + (.mfc0 a1-0 Count) + (+! (-> arg0 prev-time-elapsed) (- (the-as time-frame a1-0) (-> arg0 start-time))) + ) + 0 + (none) + ) + +;; definition for function stopwatch-elapsed-ticks +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count] +(defun stopwatch-elapsed-ticks ((arg0 stopwatch)) + (local-vars (v1-3 int)) + (let ((v0-0 (-> arg0 prev-time-elapsed))) + (when (> (-> arg0 begin-level) 0) + 0 + (.mfc0 v1-3 Count) + (+! v0-0 (- (the-as time-frame v1-3) (-> arg0 start-time))) + ) + v0-0 + ) + ) + +;; definition for function stopwatch-elapsed-seconds +(defun stopwatch-elapsed-seconds ((arg0 stopwatch)) + (let ((v1-0 (stopwatch-elapsed-ticks arg0))) + (* 0.0000000033333334 (the float v1-0)) + ) + ) + +;; definition for method 9 of type clock +(defmethod update-rates! ((this clock) (rate float)) + "Recompute all clock values for the given clock ratio (arg0)." + (set! (-> this clock-ratio) rate) + (let ((f0-6 (if (nonzero? *display*) + (* (-> *display* time-factor) (-> *display* dog-ratio) rate) + (* 5.0 rate) + ) + ) + ) + (set! (-> this time-adjust-ratio) (/ f0-6 5)) + ) + (set! (-> this seconds-per-frame) (/ (-> this time-adjust-ratio) 60)) + (set! (-> this frames-per-second) (if (= (-> this time-adjust-ratio) 0.0) + 0.0 + (* 60.0 (/ 1.0 (-> this time-adjust-ratio))) + ) + ) + (let* ((v1-12 (the-as number (- (-> this frame-counter) (-> this old-frame-counter)))) + (f0-14 (the-as float v1-12)) + (f1-9 (* 0.2 (the float v1-12))) + ) + (set-vector! (-> this sparticle-data) f0-14 (* 5.0 f1-9) f1-9 f1-9) + ) + rate + ) + +;; definition for method 10 of type clock +(defmethod advance-by! ((this clock) (arg0 float)) + "Advance the clock by arg0 timeframes (as a float). + Both counters keep a separate fractional and integer counter." + (the int (+ arg0 (-> this accum))) + (+! (-> this integral-accum) arg0) + (set! (-> this old-integral-frame-counter) (-> this integral-frame-counter)) + (while (>= (-> this integral-accum) (-> *display* time-factor)) + (+! (-> this integral-frame-counter) 1) + (set! (-> this integral-accum) (- (-> this integral-accum) (-> *display* time-factor))) + ) + (let ((v1-7 (the int (+ arg0 (-> this accum))))) + (set! (-> this accum) (- (+ arg0 (-> this accum)) (the float v1-7))) + (set! (-> this old-frame-counter) (-> this frame-counter)) + (+! (-> this frame-counter) v1-7) + ) + (update-rates! this (-> this clock-ratio)) + this + ) + +;; definition for method 11 of type clock +(defmethod tick! ((this clock)) + "Per-game-frame clock tick forward." + (if (not (logtest? (-> this mask) (-> *kernel-context* prevent-from-run))) + (advance-by! this (* (-> *display* time-factor) (-> *display* dog-ratio) (-> this clock-ratio))) + (set! (-> this sparticle-data x) 0.0) + ) + this + ) + +;; definition for method 15 of type clock +;; WARN: Return type mismatch int vs none. +(defmethod reset! ((this clock)) + "Reset a clock to 1000s, rate of 1." + (set! (-> this frame-counter) (seconds 1000)) + (set! (-> this integral-frame-counter) (seconds 1000)) + (set! (-> this accum) 0.0) + (set! (-> this old-frame-counter) (+ (-> this frame-counter) -1)) + (set! (-> this old-integral-frame-counter) (+ (-> this integral-frame-counter) -1)) + (update-rates! this 1.0) + 0 + (none) + ) + +;; definition for method 12 of type clock +(defmethod save! ((this clock) (arg0 (pointer uint64))) + "Save a clock's state to a buffer, return bytes used." + (set! (-> arg0 0) (the-as uint (-> this frame-counter))) + (set! (-> arg0 1) (the-as uint (-> this integral-frame-counter))) + 16 + ) + +;; definition for method 13 of type clock +(defmethod load! ((this clock) (arg0 (pointer uint64))) + "Load a clock's state from a buffer, return bytes used." + (set! (-> this frame-counter) (the-as time-frame (-> arg0 0))) + (set! (-> this integral-frame-counter) (the-as time-frame (-> arg0 1))) + (set! (-> this accum) 0.0) + (set! (-> this integral-accum) 0.0) + (set! (-> this old-frame-counter) (-> this frame-counter)) + (set! (-> this old-integral-frame-counter) (-> this integral-frame-counter)) + 16 + ) + +;; definition for method 14 of type clock +(defmethod copy! ((this clock) (arg0 clock)) + "Copy the frame counters and ratio from arg0." + (set! (-> this frame-counter) (-> arg0 frame-counter)) + (set! (-> this integral-frame-counter) (-> arg0 integral-frame-counter)) + (set! (-> this accum) (-> arg0 accum)) + (set! (-> this integral-accum) (-> arg0 integral-accum)) + (set! (-> this old-frame-counter) (-> arg0 old-frame-counter)) + (set! (-> this old-integral-frame-counter) (-> arg0 old-integral-frame-counter)) + (set! (-> this clock-ratio) (-> arg0 clock-ratio)) + this + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/ps2/vif-h_REF.gc b/test/decompiler/reference/jakx/engine/ps2/vif-h_REF.gc new file mode 100644 index 0000000000..265ab38f87 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/ps2/vif-h_REF.gc @@ -0,0 +1,124 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type vif-stat +(deftype vif-stat (uint32) + ((vps uint8 :offset 0 :size 2) + (vew uint8 :offset 2 :size 1) + (mrk uint8 :offset 6 :size 1) + (vss uint8 :offset 8 :size 1) + (vfs uint8 :offset 9 :size 1) + (vis uint8 :offset 10 :size 1) + (int uint8 :offset 11 :size 1) + (er0 uint8 :offset 12 :size 1) + (er1 uint8 :offset 13 :size 1) + (fqc uint8 :offset 24 :size 4) + ) + ) + +;; definition for method 3 of type vif-stat +(defmethod inspect ((this vif-stat)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'vif-stat) + (format #t "~1Tvps: ~D~%" (-> this vps)) + (format #t "~1Tvew: ~D~%" (-> this vew)) + (format #t "~1Tmrk: ~D~%" (-> this mrk)) + (format #t "~1Tvss: ~D~%" (-> this vss)) + (format #t "~1Tvfs: ~D~%" (-> this vfs)) + (format #t "~1Tvis: ~D~%" (-> this vis)) + (format #t "~1Tint: ~D~%" (-> this int)) + (format #t "~1Ter0: ~D~%" (-> this er0)) + (format #t "~1Ter1: ~D~%" (-> this er1)) + (format #t "~1Tfqc: ~D~%" (-> this fqc)) + (label cfg-4) + this + ) + +;; definition of type vif-fbrst +(deftype vif-fbrst (uint32) + ((rst uint8 :offset 0 :size 1) + (fbk uint8 :offset 1 :size 1) + (stp uint8 :offset 2 :size 1) + (stc uint8 :offset 3 :size 1) + ) + ) + +;; definition of type vif-err +(deftype vif-err (uint32) + ((mii uint8 :offset 0 :size 1) + (me0 uint8 :offset 1 :size 1) + (me1 uint8 :offset 2 :size 1) + ) + ) + +;; definition of type vif-bank +(deftype vif-bank (structure) + ((stat uint32) + (fbrst uint32 :offset 16) + (err vif-err :offset 32) + (mark uint32 :offset 48) + (cycle uint32 :offset 64) + (mode uint32 :offset 80) + (num uint32 :offset 96) + (mask uint32 :offset 112) + (code uint32 :offset 128) + (itops uint32 :offset 144) + (base uint32 :offset 160) + (offset uint32 :offset 176) + (tops uint32 :offset 192) + (itop uint32 :offset 208) + (top uint32 :offset 224) + (r0 uint32 :offset 256) + (r1 uint32 :offset 272) + (r2 uint32 :offset 288) + (r3 uint32 :offset 304) + (c0 uint32 :offset 320) + (c1 uint32 :offset 336) + (c2 uint32 :offset 352) + (c3 uint32 :offset 368) + ) + ) + +;; definition for method 3 of type vif-bank +(defmethod inspect ((this vif-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'vif-bank) + (format #t "~1Tstat: #x~X~%" (-> this stat)) + (format #t "~1Tfbrst: #x~X~%" (-> this fbrst)) + (format #t "~1Terr: #x~X~%" (-> this err)) + (format #t "~1Tmark: #x~X~%" (-> this mark)) + (format #t "~1Tcycle: #x~X~%" (-> this cycle)) + (format #t "~1Tmode: #x~X~%" (-> this mode)) + (format #t "~1Tnum: #x~X~%" (-> this num)) + (format #t "~1Tmask: #x~X~%" (-> this mask)) + (format #t "~1Tcode: #x~X~%" (-> this code)) + (format #t "~1Titops: #x~X~%" (-> this itops)) + (format #t "~1Tbase: #x~X~%" (-> this base)) + (format #t "~1Toffset: #x~X~%" (-> this offset)) + (format #t "~1Ttops: #x~X~%" (-> this tops)) + (format #t "~1Titop: #x~X~%" (-> this itop)) + (format #t "~1Ttop: #x~X~%" (-> this top)) + (format #t "~1Tr0: #x~X~%" (-> this r0)) + (format #t "~1Tr1: #x~X~%" (-> this r1)) + (format #t "~1Tr2: #x~X~%" (-> this r2)) + (format #t "~1Tr3: #x~X~%" (-> this r3)) + (format #t "~1Tc0: #x~X~%" (-> this c0)) + (format #t "~1Tc1: #x~X~%" (-> this c1)) + (format #t "~1Tc2: #x~X~%" (-> this c2)) + (format #t "~1Tc3: #x~X~%" (-> this c3)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/ps2/vu1-macros_REF.gc b/test/decompiler/reference/jakx/engine/ps2/vu1-macros_REF.gc new file mode 100644 index 0000000000..8e4b1f21d4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/ps2/vu1-macros_REF.gc @@ -0,0 +1,9 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/sound/speech-h_REF.gc b/test/decompiler/reference/jakx/engine/sound/speech-h_REF.gc new file mode 100644 index 0000000000..9de0ac9f9c --- /dev/null +++ b/test/decompiler/reference/jakx/engine/sound/speech-h_REF.gc @@ -0,0 +1,173 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *music-volume-during-speech*, type float +(define *music-volume-during-speech* 0.85) + +;; definition for symbol *sfx-volume-during-speech*, type float +(define *sfx-volume-during-speech* 1.0) + +;; definition for function pecker-can-speak? +(defun pecker-can-speak? () + (or (!= *game-mode* 'adventure) (>= (get-task-cup-score 128) 22)) + ) + +;; definition of type speech-info-item +(deftype speech-info-item (structure) + ((name basic) + (flags speech-info-flag) + ) + :pack-me + ) + +;; definition for method 3 of type speech-info-item +(defmethod inspect ((this speech-info-item)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'speech-info-item) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (label cfg-4) + this + ) + +;; definition of type speech-info +(deftype speech-info (structure) + ((list basic) + (flags speech-info-flag) + ) + (:methods + (speech-info-method-9 () none) + (speech-info-method-10 () none) + (speech-info-method-11 () none) + (speech-info-method-12 () none) + ) + ) + +;; definition for method 3 of type speech-info +(defmethod inspect ((this speech-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'speech-info) + (format #t "~1Tlist: ~A~%" (-> this list)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (label cfg-4) + this + ) + +;; definition of type speech-request +(deftype speech-request (structure) + ((handle handle) + (req-time time-frame) + (start-time time-frame) + (name basic) + (speech-type speech-type) + (flags uint8) + (max-delay uint64) + ) + ) + +;; definition for method 3 of type speech-request +(defmethod inspect ((this speech-request)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'speech-request) + (format #t "~1Thandle: ~D~%" (-> this handle)) + (format #t "~1Treq-time: ~D~%" (-> this req-time)) + (format #t "~1Tstart-time: ~D~%" (-> this start-time)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tspeech-type: ~D~%" (-> this speech-type)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tmax-delay: ~D~%" (-> this max-delay)) + (label cfg-4) + this + ) + +;; definition of type speech-channel +(deftype speech-channel (structure) + ((flags speech-channel-flag) + (gui-channel gui-channel) + (delay uint16) + (id sound-id) + (time uint64) + (current-request speech-request) + (requests basic) + (speeches speech-info-item 31) + ) + (:methods + (speech-channel-method-9 () none) + (speech-channel-method-10 () none) + (speech-channel-method-11 () none) + (speech-channel-method-12 () none) + (speech-channel-method-13 () none) + (speech-channel-method-14 () none) + (speech-channel-method-15 () none) + (speech-channel-method-16 () none) + ) + ) + +;; definition for method 3 of type speech-channel +(defmethod inspect ((this speech-channel)) + (when (not this) + (set! this this) + (goto cfg-6) + ) + (format #t "[~8x] ~A~%" this 'speech-channel) + (format #t "~1Tflags: #x~X : (speech-channel-flag " (-> this flags)) + (let ((a0-3 (-> this flags))) + (if (= (logand a0-3 (speech-channel-flag disable)) (speech-channel-flag disable)) + (format #t "disable ") + ) + ) + (format #t ")~%") + (format #t "~1Tgui-channel: ~D~%" (-> this gui-channel)) + (format #t "~1Tdelay: ~D~%" (-> this delay)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Ttime: ~D~%" (-> this time)) + (format #t "~1Tcurrent-request: #~%" (-> this current-request)) + (format #t "~1Trequests: ~A~%" (-> this requests)) + (format #t "~1Tspeeches[31] @ #x~X~%" (-> this speeches)) + (label cfg-6) + this + ) + +;; definition of type speech-control +(deftype speech-control (structure) + ((channels speech-channel 22 :inline) + ) + (:methods + (speech-control-method-9 () none) + (speech-control-method-10 () none) + (speech-control-method-11 () none) + (speech-control-method-12 () none) + (speech-control-method-13 () none) + (speech-control-method-14 () none) + (speech-control-method-15 () none) + (speech-control-method-16 () none) + ) + ) + +;; definition for method 3 of type speech-control +(defmethod inspect ((this speech-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'speech-control) + (format #t "~1Tchannels[22] @ #x~X~%" (-> this channels)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/spatial-hash/actor-hash-h_REF.gc b/test/decompiler/reference/jakx/engine/spatial-hash/actor-hash-h_REF.gc new file mode 100644 index 0000000000..8b715a01d3 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/spatial-hash/actor-hash-h_REF.gc @@ -0,0 +1,15 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *actor-list*, type (pointer collide-shape) +(define *actor-list* (the-as (pointer collide-shape) (malloc 'global 2048))) + +;; definition for symbol *actor-list-length*, type int +(define *actor-list-length* 0) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/spatial-hash/collide-hash-h_REF.gc b/test/decompiler/reference/jakx/engine/spatial-hash/collide-hash-h_REF.gc new file mode 100644 index 0000000000..73f454da3c --- /dev/null +++ b/test/decompiler/reference/jakx/engine/spatial-hash/collide-hash-h_REF.gc @@ -0,0 +1,268 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *collide-list-boxes*, type symbol +(define *collide-list-boxes* #f) + +;; definition for symbol *collide-hash-fragments*, type int +(define *collide-hash-fragments* 0) + +;; definition for symbol *collide-hash-fragments-tfrag*, type int +(define *collide-hash-fragments-tfrag* 0) + +;; definition for symbol *collide-hash-fragments-instance*, type int +(define *collide-hash-fragments-instance* 0) + +;; definition for symbol *already-printed-exeeded-max-cache-tris*, type symbol +(define *already-printed-exeeded-max-cache-tris* #f) + +;; definition of type collide-hash-scratch +(deftype collide-hash-scratch (structure) + "Scratchpad memory layout for collide-hash. Bitmask of things that have already been checked" + ((collidable-bits uint128 128) + (poly-bits uint64 2 :overlay-at (-> collidable-bits 0)) + (id-bits uint32 512 :overlay-at (-> collidable-bits 0)) + (tris uint32) + ) + ) + +;; definition for method 3 of type collide-hash-scratch +(defmethod inspect ((this collide-hash-scratch)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-hash-scratch) + (format #t "~1Tcollidable-bits[128] @ #x~X~%" (-> this collidable-bits)) + (format #t "~1Tpoly-bits[2] @ #x~X~%" (-> this collidable-bits)) + (format #t "~1Tid-bits[512] @ #x~X~%" (-> this collidable-bits)) + (format #t "~1Ttris: ~D~%" (-> this tris)) + (label cfg-4) + this + ) + +;; definition of type collide-hash-bucket +(deftype collide-hash-bucket (structure) + "A bucket is a reference to a list of items that intersect a grid cell. +For the broadphase, the items are collide-hash-item (wrapper of collide-hash-fragment). +For the narrowphase, the items are entries in the index list, which contains poly indices." + ((index int16) + (count int16) + ) + ) + +;; definition for method 3 of type collide-hash-bucket +(defmethod inspect ((this collide-hash-bucket)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-hash-bucket) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tcount: ~D~%" (-> this count)) + (label cfg-4) + this + ) + +;; definition of type collide-hash-item +(deftype collide-hash-item (structure) + "Items that are 'hashed' in the broadphase. Contains unique ID for checking against already-visited-bitmask +and a pointer to the actual collide-hash-fragment, or possibly a TIE." + ((id uint32) + (collidable basic) + ) + :pack-me + ) + +;; definition for method 3 of type collide-hash-item +(defmethod inspect ((this collide-hash-item)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-hash-item) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tcollidable: ~A~%" (-> this collidable)) + (label cfg-4) + this + ) + +;; definition of type collide-hash-poly +(deftype collide-hash-poly (structure) + "A polygon in the narrow-phase data. This is just indices into the vertex and PAT tables." + ((data uint8 4) + (vert-index0 uint8 :overlay-at (-> data 0)) + (vert-index1 uint8 :overlay-at (-> data 1)) + (vert-index2 uint8 :overlay-at (-> data 2)) + (pat-index uint8 :overlay-at (-> data 3)) + (word uint32 :overlay-at (-> data 0)) + ) + ) + +;; definition for method 3 of type collide-hash-poly +(defmethod inspect ((this collide-hash-poly)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-hash-poly) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (format #t "~1Tvert-index0: ~D~%" (-> this vert-index0)) + (format #t "~1Tvert-index1: ~D~%" (-> this vert-index1)) + (format #t "~1Tvert-index2: ~D~%" (-> this vert-index2)) + (format #t "~1Tpat-index: ~D~%" (-> this pat-index)) + (format #t "~1Tword: ~D~%" (-> this word)) + (label cfg-4) + this + ) + +;; definition of type collide-hash-fragment-stats +(deftype collide-hash-fragment-stats (structure) + ((num-verts uint16) + (num-polys uint8) + (poly-count uint8) + ) + :pack-me + ) + +;; definition for method 3 of type collide-hash-fragment-stats +(defmethod inspect ((this collide-hash-fragment-stats)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-hash-fragment-stats) + (format #t "~1Tnum-verts: ~D~%" (-> this num-verts)) + (format #t "~1Tnum-polys: ~D~%" (-> this num-polys)) + (format #t "~1Tpoly-count: ~D~%" (-> this poly-count)) + (label cfg-4) + this + ) + +;; definition of type collide-hash-fragment +(deftype collide-hash-fragment (drawable) + "A mesh fragment for the Jak2/Jak3 collision system. This is a 'hash' of triangles into a grid +where the 'hash' function is just identity." + ((num-buckets uint16 :overlay-at id) + (num-indices uint16 :offset 6) + (pat-array uint32 :offset 8) + (bucket-array uint32 :offset 12) + (grid-step vector :inline) + (bbox bounding-box :inline) + (bbox4w bounding-box4w :inline) + (axis-scale vector :inline :overlay-at (-> bbox max)) + (avg-extents vector :inline :overlay-at (-> bbox4w min data 0)) + (dimension-array uint32 4 :overlay-at (-> grid-step data 3)) + (stats collide-hash-fragment-stats :inline :overlay-at (-> bbox min data 3)) + (num-verts uint16 :overlay-at (-> bbox min data 3)) + (num-polys uint8 :offset 62) + (poly-count uint8 :offset 63) + (poly-array uint32 :overlay-at (-> bbox max data 3)) + (vert-array uint32 :overlay-at (-> bbox4w min data 3)) + (index-array uint32 :overlay-at (-> bbox4w max data 3)) + ) + ) + +;; definition for method 3 of type collide-hash-fragment +(defmethod inspect ((this collide-hash-fragment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tnum-buckets: ~D~%" (-> this num-buckets)) + (format #t "~1Tnum-indices: ~D~%" (-> this num-indices)) + (format #t "~1Tpat-array: #x~X~%" (-> this pat-array)) + (format #t "~1Tbucket-array: #x~X~%" (-> this bucket-array)) + (format #t "~1Tgrid-step: #~%" (-> this grid-step)) + (format #t "~1Tbbox: #~%" (-> this bbox)) + (format #t "~1Tbbox4w: #~%" (-> this bbox4w)) + (format #t "~1Taxis-scale: #~%" (-> this bbox max)) + (format #t "~1Tavg-extents: #~%" (-> this bbox4w)) + (format #t "~1Tdimension-array[4] @ #x~X~%" (&-> this grid-step w)) + (format #t "~1Tstats: #~%" (&-> this bbox min w)) + (format #t "~1Tnum-verts: ~D~%" (-> this stats num-verts)) + (format #t "~1Tnum-polys: ~D~%" (-> this stats num-polys)) + (format #t "~1Tpoly-count: ~D~%" (-> this stats poly-count)) + (format #t "~1Tpoly-array: #x~X~%" (-> this bbox max w)) + (format #t "~1Tvert-array: #x~X~%" (-> this avg-extents w)) + (format #t "~1Tindex-array: #x~X~%" (-> this index-array)) + (label cfg-4) + this + ) + +;; definition of type collide-hash-fragment-array +(deftype collide-hash-fragment-array (array) + "A collection of collide-hash-fragments. These are used by the instanced collision if a single instance +needs more than 1 collide-hash-fragment worth of triangles." + ((fragments collide-hash-fragment :dynamic :offset 16) + ) + ) + +;; definition for method 3 of type collide-hash-fragment-array +(defmethod inspect ((this collide-hash-fragment-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttype: ~A~%" (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tcontent-type: ~A~%" (-> this content-type)) + (label cfg-4) + this + ) + +;; definition of type collide-hash +(deftype collide-hash (drawable) + ((num-ids uint16 :overlay-at id) + (id-count uint16 :offset 6) + (num-buckets uint32 :offset 8) + (qwc-id-bits uint32 :offset 12) + (grid-step vector :inline :overlay-at bsphere) + (bbox bounding-box :inline :offset 32) + (bbox4w bounding-box4w :inline :offset 64) + (axis-scale vector :inline :offset 48) + (avg-extents vector :inline :offset 64) + (bucket-array uint32 :offset 44) + (item-array (inline-array collide-hash-item) :overlay-at (-> axis-scale w)) + (dimension-array uint32 3 :overlay-at (-> avg-extents w)) + (num-items uint32 :offset 92) + ) + ) + +;; definition for method 3 of type collide-hash +(defmethod inspect ((this collide-hash)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) + (format #t "~1Tnum-ids: ~D~%" (-> this num-ids)) + (format #t "~1Tid-count: ~D~%" (-> this id-count)) + (format #t "~1Tnum-buckets: ~D~%" (-> this num-buckets)) + (format #t "~1Tqwc-id-bits: ~D~%" (-> this qwc-id-bits)) + (format #t "~1Tgrid-step: #~%" (-> this bsphere)) + (format #t "~1Tbbox: #~%" (-> this bbox)) + (format #t "~1Tbbox4w: #~%" (-> this bbox4w)) + (format #t "~1Taxis-scale: #~%" (-> this bbox max)) + (format #t "~1Tavg-extents: #~%" (-> this bbox4w)) + (format #t "~1Tbucket-array: #x~X~%" (-> this bbox min w)) + (format #t "~1Titem-array: #x~X~%" (-> this item-array)) + (format #t "~1Tdimension-array[3] @ #x~X~%" (&-> this bbox4w min w)) + (format #t "~1Tnum-items: ~D~%" (-> this num-items)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/spatial-hash/spatial-hash-h_REF.gc b/test/decompiler/reference/jakx/engine/spatial-hash/spatial-hash-h_REF.gc new file mode 100644 index 0000000000..df1774a7b6 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/spatial-hash/spatial-hash-h_REF.gc @@ -0,0 +1,263 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type grid-hash-word +(deftype grid-hash-word (uint8) + () + ) + +;; definition of type grid-hash-box +(deftype grid-hash-box (structure) + "Integer coordinate box for the spatial hash grid." + ((min int8 3) + (max int8 3) + ) + :pack-me + ) + +;; definition for method 3 of type grid-hash-box +(defmethod inspect ((this grid-hash-box)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'grid-hash-box) + (format #t "~1Tmin[3] @ #x~X~%" (-> this min)) + (format #t "~1Tmax[3] @ #x~X~%" (-> this max)) + (label cfg-4) + this + ) + +;; definition of type grid-hash +(deftype grid-hash (basic) + ((work grid-hash-work) + (search-box grid-hash-box :inline) + (bucket-size int16) + (axis-scale float 3) + (dimension-array int8 3) + (vertical-cell-count int8) + (bucket-array (pointer grid-hash-word)) + (box-min float 3) + (box-max float 3) + (object-count int16) + (bucket-count int16) + (min-cell-size float) + (bucket-memory-size int32) + (mem-bucket-array (pointer grid-hash-word)) + (spr-bucket-array (pointer grid-hash-word)) + (debug-draw symbol) + (use-scratch-ram symbol) + ) + (:methods + (new (symbol type) _type_) + (grid-hash-method-9 () none) + (grid-hash-method-10 () none) + (grid-hash-method-11 () none) + (grid-hash-method-12 () none) + (grid-hash-method-13 () none) + (grid-hash-method-14 () none) + (grid-hash-method-15 () none) + (grid-hash-method-16 () none) + (grid-hash-method-17 () none) + (grid-hash-method-18 () none) + (grid-hash-method-19 () none) + (grid-hash-method-20 () none) + (grid-hash-method-21 () none) + (grid-hash-method-22 () none) + (grid-hash-method-23 () none) + (grid-hash-method-24 () none) + (grid-hash-method-25 () none) + (grid-hash-method-26 () none) + ) + ) + +;; definition for method 3 of type grid-hash +(defmethod inspect ((this grid-hash)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Twork: ~A~%" (-> this work)) + (format #t "~1Tsearch-box: #~%" (-> this search-box)) + (format #t "~1Tbucket-size: ~D~%" (-> this bucket-size)) + (format #t "~1Taxis-scale[3] @ #x~X~%" (-> this axis-scale)) + (format #t "~1Tdimension-array[3] @ #x~X~%" (-> this dimension-array)) + (format #t "~1Tvertical-cell-count: ~D~%" (-> this vertical-cell-count)) + (format #t "~1Tbucket-array: #x~X~%" (-> this bucket-array)) + (format #t "~1Tbox-min[3] @ #x~X~%" (-> this box-min)) + (format #t "~1Tbox-max[3] @ #x~X~%" (-> this box-max)) + (format #t "~1Tobject-count: ~D~%" (-> this object-count)) + (format #t "~1Tbucket-count: ~D~%" (-> this bucket-count)) + (format #t "~1Tmin-cell-size: ~f~%" (-> this min-cell-size)) + (format #t "~1Tbucket-memory-size: ~D~%" (-> this bucket-memory-size)) + (format #t "~1Tmem-bucket-array: #x~X~%" (-> this mem-bucket-array)) + (format #t "~1Tspr-bucket-array: #x~X~%" (-> this spr-bucket-array)) + (format #t "~1Tdebug-draw: ~A~%" (-> this debug-draw)) + (format #t "~1Tuse-scratch-ram: ~A~%" (-> this use-scratch-ram)) + (label cfg-4) + this + ) + +;; definition of type find-nav-sphere-ids-params +(deftype find-nav-sphere-ids-params (structure) + ((bsphere sphere :inline) + (y-threshold float) + (len int16) + (max-len int16) + (mask uint8) + (array (pointer uint8)) + ) + ) + +;; definition for method 3 of type find-nav-sphere-ids-params +(defmethod inspect ((this find-nav-sphere-ids-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'find-nav-sphere-ids-params) + (format #t "~1Tbsphere: #~%" (-> this bsphere)) + (format #t "~1Ty-threshold: ~f~%" (-> this y-threshold)) + (format #t "~1Tlen: ~D~%" (-> this len)) + (format #t "~1Tmax-len: ~D~%" (-> this max-len)) + (format #t "~1Tmask: ~D~%" (-> this mask)) + (format #t "~1Tarray: #x~X~%" (-> this array)) + (label cfg-4) + this + ) + +;; definition of type sphere-hash +(deftype sphere-hash (grid-hash) + "An extension of grid hash that holds spheres inside of the grid." + ((sphere-array (inline-array sphere)) + (max-object-count int16) + (pad int16) + (mem-sphere-array uint32) + (spr-sphere-array uint32) + ) + (:methods + (new (symbol type) _type_) + (sphere-hash-method-27 () none) + (sphere-hash-method-28 () none) + (sphere-hash-method-29 () none) + (sphere-hash-method-30 () none) + (sphere-hash-method-31 () none) + (sphere-hash-method-32 () none) + (sphere-hash-method-33 () none) + (sphere-hash-method-34 () none) + (sphere-hash-method-35 () none) + ) + ) + +;; definition for method 3 of type sphere-hash +(defmethod inspect ((this sphere-hash)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Twork: ~A~%" (-> this work)) + (format #t "~1Tsearch-box: #~%" (-> this search-box)) + (format #t "~1Tbucket-size: ~D~%" (-> this bucket-size)) + (format #t "~1Taxis-scale[3] @ #x~X~%" (-> this axis-scale)) + (format #t "~1Tdimension-array[3] @ #x~X~%" (-> this dimension-array)) + (format #t "~1Tvertical-cell-count: ~D~%" (-> this vertical-cell-count)) + (format #t "~1Tbucket-array: #x~X~%" (-> this bucket-array)) + (format #t "~1Tbox-min[3] @ #x~X~%" (-> this box-min)) + (format #t "~1Tbox-max[3] @ #x~X~%" (-> this box-max)) + (format #t "~1Tobject-count: ~D~%" (-> this object-count)) + (format #t "~1Tbucket-count: ~D~%" (-> this bucket-count)) + (format #t "~1Tmin-cell-size: ~f~%" (-> this min-cell-size)) + (format #t "~1Tbucket-memory-size: ~D~%" (-> this bucket-memory-size)) + (format #t "~1Tmem-bucket-array: #x~X~%" (-> this mem-bucket-array)) + (format #t "~1Tspr-bucket-array: #x~X~%" (-> this spr-bucket-array)) + (format #t "~1Tdebug-draw: ~A~%" (-> this debug-draw)) + (format #t "~1Tuse-scratch-ram: ~A~%" (-> this use-scratch-ram)) + (format #t "~1Tsphere-array: #x~X~%" (-> this sphere-array)) + (format #t "~1Tmax-object-count: ~D~%" (-> this max-object-count)) + (format #t "~1Tpad: ~D~%" (-> this pad)) + (format #t "~1Tmem-sphere-array: #x~X~%" (-> this mem-sphere-array)) + (format #t "~1Tspr-sphere-array: #x~X~%" (-> this spr-sphere-array)) + (label cfg-4) + this + ) + +;; definition of type hash-object-info +(deftype hash-object-info (structure) + ((object basic) + ) + ) + +;; definition for method 3 of type hash-object-info +(defmethod inspect ((this hash-object-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hash-object-info) + (format #t "~1Tobject: ~A~%" (-> this object)) + (label cfg-4) + this + ) + +;; definition of type spatial-hash +(deftype spatial-hash (sphere-hash) + "An extension of sphere-hash that associates an object with each sphere." + ((object-array (inline-array hash-object-info)) + (mem-object-array (inline-array hash-object-info)) + (spr-object-array (inline-array hash-object-info)) + ) + (:methods + (new (symbol type) _type_) + (spatial-hash-method-36 () none) + (spatial-hash-method-37 () none) + (spatial-hash-method-38 () none) + (spatial-hash-method-39 () none) + (spatial-hash-method-40 () none) + (spatial-hash-method-41 () none) + ) + ) + +;; definition for method 3 of type spatial-hash +(defmethod inspect ((this spatial-hash)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Twork: ~A~%" (-> this work)) + (format #t "~1Tsearch-box: #~%" (-> this search-box)) + (format #t "~1Tbucket-size: ~D~%" (-> this bucket-size)) + (format #t "~1Taxis-scale[3] @ #x~X~%" (-> this axis-scale)) + (format #t "~1Tdimension-array[3] @ #x~X~%" (-> this dimension-array)) + (format #t "~1Tvertical-cell-count: ~D~%" (-> this vertical-cell-count)) + (format #t "~1Tbucket-array: #x~X~%" (-> this bucket-array)) + (format #t "~1Tbox-min[3] @ #x~X~%" (-> this box-min)) + (format #t "~1Tbox-max[3] @ #x~X~%" (-> this box-max)) + (format #t "~1Tobject-count: ~D~%" (-> this object-count)) + (format #t "~1Tbucket-count: ~D~%" (-> this bucket-count)) + (format #t "~1Tmin-cell-size: ~f~%" (-> this min-cell-size)) + (format #t "~1Tbucket-memory-size: ~D~%" (-> this bucket-memory-size)) + (format #t "~1Tmem-bucket-array: #x~X~%" (-> this mem-bucket-array)) + (format #t "~1Tspr-bucket-array: #x~X~%" (-> this spr-bucket-array)) + (format #t "~1Tdebug-draw: ~A~%" (-> this debug-draw)) + (format #t "~1Tuse-scratch-ram: ~A~%" (-> this use-scratch-ram)) + (format #t "~1Tsphere-array: #x~X~%" (-> this sphere-array)) + (format #t "~1Tmax-object-count: ~D~%" (-> this max-object-count)) + (format #t "~1Tpad: ~D~%" (-> this pad)) + (format #t "~1Tmem-sphere-array: #x~X~%" (-> this mem-sphere-array)) + (format #t "~1Tspr-sphere-array: #x~X~%" (-> this spr-sphere-array)) + (format #t "~1Tobject-array: #x~X~%" (-> this object-array)) + (format #t "~1Tmem-object-array: #x~X~%" (-> this mem-object-array)) + (format #t "~1Tspr-object-array: #x~X~%" (-> this spr-object-array)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/ui/gui-h_REF.gc b/test/decompiler/reference/jakx/engine/ui/gui-h_REF.gc new file mode 100644 index 0000000000..246de4f063 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/ui/gui-h_REF.gc @@ -0,0 +1,302 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type gui-connection +(deftype gui-connection (connection) + ((priority float :overlay-at param0) + (action gui-action :overlay-at param1) + (channel gui-channel :offset 21) + (anim-part uint8 :offset 22) + (flags gui-connection-flags :offset 23) + (name string :overlay-at param2) + (id sound-id :overlay-at param3) + (handle handle :overlay-at next0) + (time-stamp time-frame :overlay-at next1) + (hold-time time-frame) + (fo-min float) + (fo-max float) + (fo-power float) + (fade uint8) + (volume float) + (qw-pad int8 4) + ) + ) + +;; definition for method 3 of type gui-connection +(defmethod inspect ((this gui-connection)) + (when (not this) + (set! this this) + (goto cfg-146) + ) + (format #t "[~8x] ~A~%" this 'gui-connection) + (format #t "~1Tnext0: ~`connectable`P~%" (-> this next0)) + (format #t "~1Tprev0: ~`connectable`P~%" (-> this prev0)) + (format #t "~1Tnext1: ~`connectable`P~%" (-> this next1)) + (format #t "~1Tprev1: ~`connectable`P~%" (-> this prev1)) + (format #t "~1Tparam0: ~A~%" (-> this priority)) + (format #t "~1Tparam1: ~A~%" (-> this param1)) + (format #t "~1Tparam2: ~A~%" (-> this param2)) + (format #t "~1Tparam3: ~A~%" (-> this param3)) + (format #t "~1Tquad[2] @ #x~X~%" (&-> this next0)) + (format #t "~1Tpriority: ~f~%" (-> this priority)) + (let ((t9-11 format) + (a0-12 #t) + (a1-11 "~1Taction: #x~X : ~S~%") + (a2-11 (-> this action)) + (v1-2 (-> this action)) + ) + (t9-11 a0-12 a1-11 a2-11 (cond + ((= v1-2 (gui-action queue)) + "queue" + ) + ((= v1-2 (gui-action stop)) + "stop" + ) + ((= v1-2 (gui-action play)) + "play" + ) + ((= v1-2 (gui-action hide)) + "hide" + ) + ((= v1-2 (gui-action fade)) + "fade" + ) + ((= v1-2 (gui-action none)) + "none" + ) + ((= v1-2 (gui-action abort)) + "abort" + ) + ((= v1-2 (gui-action stopping)) + "stopping" + ) + ((= v1-2 (gui-action hidden)) + "hidden" + ) + ((= v1-2 (gui-action playing)) + "playing" + ) + (else + "*unknown*" + ) + ) + ) + ) + (let ((t9-12 format) + (a0-13 #t) + (a1-12 "~1Tchannel: #x~X : ~S~%") + (a2-12 (-> this channel)) + (v1-3 (-> this channel)) + ) + (t9-12 a0-13 a1-12 a2-12 (cond + ((= v1-3 (gui-channel hud-mp-race-1)) + "hud-mp-race-1" + ) + ((= v1-3 (gui-channel hud-lower-left)) + "hud-lower-left" + ) + ((= v1-3 (gui-channel citizen)) + "citizen" + ) + ((= v1-3 (gui-channel pecker)) + "pecker" + ) + ((= v1-3 (gui-channel jak-effect-1)) + "jak-effect-1" + ) + ((= v1-3 (gui-channel ashelin)) + "ashelin" + ) + ((= v1-3 (gui-channel hud-lower-left-1)) + "hud-lower-left-1" + ) + ((= v1-3 (gui-channel hud-mp-race-2)) + "hud-mp-race-2" + ) + ((= v1-3 (gui-channel message)) + "message" + ) + ((= v1-3 (gui-channel hud-middle-left)) + "hud-middle-left" + ) + ((= v1-3 (gui-channel gun)) + "gun" + ) + ((= v1-3 (gui-channel hud-upper-center-2)) + "hud-upper-center-2" + ) + ((= v1-3 (gui-channel subtitle)) + "subtitle" + ) + ((= v1-3 (gui-channel hud-middle-right)) + "hud-middle-right" + ) + ((= v1-3 (gui-channel art-load-next)) + "art-load-next" + ) + ((= v1-3 (gui-channel notice)) + "notice" + ) + ((= v1-3 (gui-channel sig)) + "sig" + ) + ((= v1-3 (gui-channel hud-mp-vehicle-main-1)) + "hud-mp-vehicle-main-1" + ) + ((= v1-3 (gui-channel hud-center-left)) + "hud-center-left" + ) + ((= v1-3 (gui-channel task)) + "task" + ) + ((= v1-3 (gui-channel hud-upper-right)) + "hud-upper-right" + ) + ((= v1-3 (gui-channel hud-center-right)) + "hud-center-right" + ) + ((= v1-3 (gui-channel alert)) + "alert" + ) + ((= v1-3 (gui-channel hud-mp-player-indicators-0)) + "hud-mp-player-indicators-0" + ) + ((= v1-3 (gui-channel hud-mp-player-indicators-1)) + "hud-mp-player-indicators-1" + ) + ((= v1-3 (gui-channel hud-mp-race-0)) + "hud-mp-race-0" + ) + ((= v1-3 (gui-channel hud-upper-left)) + "hud-upper-left" + ) + ((= v1-3 (gui-channel speech)) + "speech" + ) + ((= v1-3 (gui-channel query)) + "query" + ) + ((= v1-3 (gui-channel hud-lower-right)) + "hud-lower-right" + ) + ((= v1-3 (gui-channel screen)) + "screen" + ) + ((= v1-3 (gui-channel guard)) + "guard" + ) + ((= v1-3 (gui-channel hud-mp-race-3)) + "hud-mp-race-3" + ) + ((= v1-3 (gui-channel supertitle)) + "supertitle" + ) + ((= v1-3 (gui-channel hal)) + "hal" + ) + ((= v1-3 (gui-channel hud-upper-center)) + "hud-upper-center" + ) + ((= v1-3 (gui-channel blackout)) + "blackout" + ) + ((= v1-3 (gui-channel bbush)) + "bbush" + ) + ((= v1-3 (gui-channel hud)) + "hud" + ) + ((= v1-3 (gui-channel voice)) + "voice" + ) + ((= v1-3 (gui-channel jak-mode)) + "jak-mode" + ) + ((= v1-3 (gui-channel max)) + "max" + ) + ((= v1-3 (gui-channel none)) + "none" + ) + ((= v1-3 (gui-channel freeze)) + "freeze" + ) + ((= v1-3 (gui-channel notice-low)) + "notice-low" + ) + ((= v1-3 (gui-channel art-load)) + "art-load" + ) + ((= v1-3 (gui-channel hud-auto-save-message)) + "hud-auto-save-message" + ) + ((= v1-3 (gui-channel jak)) + "jak" + ) + ((= v1-3 (gui-channel progress)) + "progress" + ) + ((= v1-3 (gui-channel resetter)) + "resetter" + ) + ((= v1-3 (gui-channel jak-effect-2)) + "jak-effect-2" + ) + ((= v1-3 (gui-channel daxter)) + "daxter" + ) + ((= v1-3 (gui-channel hud-lower-left-2)) + "hud-lower-left-2" + ) + ((= v1-3 (gui-channel background)) + "background" + ) + ((= v1-3 (gui-channel beast)) + "beast" + ) + ((= v1-3 (gui-channel hud-mp-vehicle-main-0)) + "hud-mp-vehicle-main-0" + ) + ((= v1-3 (gui-channel hud-auto-save)) + "hud-auto-save" + ) + ((= v1-3 (gui-channel hud-lower-center)) + "hud-lower-center" + ) + ((= v1-3 (gui-channel rider)) + "rider" + ) + ((= v1-3 (gui-channel movie)) + "movie" + ) + (else + "*unknown*" + ) + ) + ) + ) + (format #t "~1Tanim-part: ~D~%" (-> this anim-part)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Thandle: ~D~%" (-> this handle)) + (format #t "~1Ttime-stamp: ~D~%" (-> this time-stamp)) + (format #t "~1Thold-time: ~D~%" (-> this hold-time)) + (format #t "~1Tfo-min: ~f~%" (-> this fo-min)) + (format #t "~1Tfo-max: ~f~%" (-> this fo-max)) + (format #t "~1Tfo-power: ~f~%" (-> this fo-power)) + (format #t "~1Tfade: ~D~%" (-> this fade)) + (format #t "~1Tvolume: ~f~%" (-> this volume)) + (format #t "~1Tqw-pad[4] @ #x~X~%" (-> this qw-pad)) + (label cfg-146) + this + ) + +;; type gui-control is defined here, but it is unknown to the decompiler + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/ui/hud-h_REF.gc b/test/decompiler/reference/jakx/engine/ui/hud-h_REF.gc new file mode 100644 index 0000000000..45992af3a1 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/ui/hud-h_REF.gc @@ -0,0 +1,248 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type hud-string +(deftype hud-string (structure) + ((text string) + (scale float) + (width float) + (height float) + (color font-color) + (flags font-flags) + (pos vector4w :inline) + (alpha float) + (time float) + (effect uint8) + (effect-color uint8) + (text-length int32) + ) + (:methods + (hud-string-method-9 () none) + ) + ) + +;; definition for method 3 of type hud-string +(defmethod inspect ((this hud-string)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hud-string) + (format #t "~1Ttext: ~A~%" (-> this text)) + (format #t "~1Tscale: ~f~%" (-> this scale)) + (format #t "~1Twidth: ~f~%" (-> this width)) + (format #t "~1Theight: ~f~%" (-> this height)) + (format #t "~1Tcolor: ~D~%" (-> this color)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tpos: #~%" (-> this pos)) + (format #t "~1Talpha: ~f~%" (-> this alpha)) + (format #t "~1Ttime: ~f~%" (-> this time)) + (format #t "~1Teffect: ~D~%" (-> this effect)) + (format #t "~1Teffect-color: ~D~%" (-> this effect-color)) + (format #t "~1Ttext-length: ~D~%" (-> this text-length)) + (label cfg-4) + this + ) + +;; definition of type hud-corners +(deftype hud-corners (structure) + ((data uint64 4) + ) + (:methods + (hud-corners-method-9 () none) + ) + ) + +;; definition for method 3 of type hud-corners +(defmethod inspect ((this hud-corners)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hud-corners) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type hud-sprite +(deftype hud-sprite (structure) + ((pos vector4w :inline) + (offset-x float :overlay-at (-> pos data 0)) + (offset-y float :overlay-at (-> pos data 1)) + (color vector4w :inline) + (flags hud-sprite-flags) + (scale-x float) + (width float :overlay-at scale-x) + (scale-y float) + (height float :overlay-at scale-y) + (angle float) + (tex texture) + (tid texture-id :overlay-at tex) + ) + (:methods + (hud-sprite-method-9 () none) + (hud-sprite-method-10 () none) + ) + ) + +;; definition for method 3 of type hud-sprite +(defmethod inspect ((this hud-sprite)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hud-sprite) + (format #t "~1Tpos: #~%" (-> this pos)) + (format #t "~1Toffset-x: ~f~%" (-> this offset-x)) + (format #t "~1Toffset-y: ~f~%" (-> this offset-y)) + (format #t "~1Tcolor: #~%" (-> this color)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tscale-x: ~f~%" (-> this scale-x)) + (format #t "~1Twidth: ~f~%" (-> this scale-x)) + (format #t "~1Tscale-y: ~f~%" (-> this scale-y)) + (format #t "~1Theight: ~f~%" (-> this scale-y)) + (format #t "~1Tangle: ~f~%" (-> this angle)) + (format #t "~1Ttex: ~A~%" (-> this tex)) + (format #t "~1Ttid: ~D~%" (-> this tex)) + (label cfg-4) + this + ) + +;; definition of type hud-box +(deftype hud-box (structure) + ((box bounding-box2 :inline) + (min vector2 :inline :overlay-at (-> box min)) + (max vector2 :inline :overlay-at (-> box max)) + (color vector4w :inline) + ) + (:methods + (hud-box-method-9 () none) + (hud-box-method-10 () none) + (hud-box-method-11 () none) + (hud-box-method-12 () none) + ) + ) + +;; definition for method 3 of type hud-box +(defmethod inspect ((this hud-box)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hud-box) + (format #t "~1Tbox: #~%" (-> this box)) + (format #t "~1Tmin: #~%" (-> this box)) + (format #t "~1Tmax: #~%" (-> this box max)) + (format #t "~1Tcolor: #~%" (-> this color)) + (label cfg-4) + this + ) + +;; definition of type hud-icon +(deftype hud-icon (structure) + ((icon (pointer manipy)) + (pos vector4w :inline) + (scale-x float) + (scale-y float) + ) + ) + +;; definition for method 3 of type hud-icon +(defmethod inspect ((this hud-icon)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hud-icon) + (format #t "~1Ticon: #x~X~%" (-> this icon)) + (format #t "~1Tpos: #~%" (-> this pos)) + (format #t "~1Tscale-x: ~f~%" (-> this scale-x)) + (format #t "~1Tscale-y: ~f~%" (-> this scale-y)) + (label cfg-4) + this + ) + +;; definition of type hud +(deftype hud (process) + ((trigger-time uint64) + (last-hide-time uint64) + (offset float) + (flags hud-flags) + (strings hud-string 45 :inline) + (sprites hud-sprite 50 :inline) + (icons hud-icon 2 :inline) + (num-strings int32) + (num-sprites int32) + (gui-id sound-id) + ) + (:methods + (hud-method-15 () none) + (hud-method-16 () none) + (hud-method-17 () none) + (hud-method-18 () none) + (hud-method-19 () none) + (hud-method-20 () none) + (hud-method-21 () none) + (hud-method-22 () none) + (hud-method-23 () none) + (hud-method-24 () none) + (hud-method-25 () none) + (hud-method-26 () none) + (hud-method-27 () none) + (hud-method-28 () none) + (hud-method-29 () none) + ) + ) + +;; definition for method 3 of type hud +(defmethod inspect ((this hud)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Ttrigger-time: ~D~%" (-> this trigger-time)) + (format #t "~2Tlast-hide-time: ~D~%" (-> this last-hide-time)) + (format #t "~2Toffset: ~f~%" (-> this offset)) + (format #t "~2Tflags: ~D~%" (-> this flags)) + (format #t "~2Tstrings[45] @ #x~X~%" (-> this strings)) + (format #t "~2Tsprites[50] @ #x~X~%" (-> this sprites)) + (format #t "~2Ticons[2] @ #x~X~%" (-> this icons)) + (format #t "~2Tnum-strings: ~D~%" (-> this num-strings)) + (format #t "~2Tnum-sprites: ~D~%" (-> this num-sprites)) + (format #t "~2Tgui-id: ~D~%" (-> this gui-id)) + (label cfg-4) + this + ) + +;; definition of type hud-map +(deftype hud-map (hud) + ((x float) + (y float) + ) + ) + +;; definition for method 3 of type hud-map +(defmethod inspect ((this hud-map)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type hud inspect))) + (t9-0 this) + ) + (format #t "~2Tx: ~f~%" (-> this x)) + (format #t "~2Ty: ~f~%" (-> this y)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/ui/minimap-h_REF.gc b/test/decompiler/reference/jakx/engine/ui/minimap-h_REF.gc new file mode 100644 index 0000000000..c44bec5b79 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/ui/minimap-h_REF.gc @@ -0,0 +1,318 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type minimap-class-node +(deftype minimap-class-node (structure) + ((default-position vector :inline) + (flags minimap-flag) + (name string) + (icon-xy vector2ub :inline) + (class minimap-class) + (scale float) + (color rgba) + ) + (:methods + (minimap-class-node-method-9 (_type_) symbol) + ) + ) + +;; definition for method 3 of type minimap-class-node +(defmethod inspect ((this minimap-class-node)) + (when (not this) + (set! this this) + (goto cfg-49) + ) + (format #t "[~8x] ~A~%" this 'minimap-class-node) + (format #t "~1Tdefault-position: ~`vector`P~%" (-> this default-position)) + (format #t "~1Tflags: #x~X : (minimap-flag " (-> this flags)) + (let ((s5-0 (-> this flags))) + (if (= (logand s5-0 (minimap-flag active)) (minimap-flag active)) + (format #t "active ") + ) + (if (= (logand s5-0 (minimap-flag fade-in)) (minimap-flag fade-in)) + (format #t "fade-in ") + ) + (if (= (logand s5-0 (minimap-flag racer)) (minimap-flag racer)) + (format #t "racer ") + ) + (if (= (logand s5-0 (minimap-flag minimap)) (minimap-flag minimap)) + (format #t "minimap ") + ) + (if (= (logand s5-0 (minimap-flag flash)) (minimap-flag flash)) + (format #t "flash ") + ) + (if (= (logand s5-0 (minimap-flag task-graph)) (minimap-flag task-graph)) + (format #t "task-graph ") + ) + (if (= (logand s5-0 (minimap-flag fade-out)) (minimap-flag fade-out)) + (format #t "fade-out ") + ) + ) + (format #t ")~%") + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Ticon-xy: #~%" (-> this icon-xy)) + (let ((t9-13 format) + (a0-21 #t) + (a1-13 "~1Tclass: #x~X : ~S~%") + (a2-5 (-> this class)) + (v1-23 (-> this class)) + ) + (t9-13 a0-21 a1-13 a2-5 (cond + ((= v1-23 (minimap-class raptor)) + "raptor" + ) + ((= v1-23 (minimap-class blue-flag)) + "blue-flag" + ) + ((= v1-23 (minimap-class racer-4)) + "racer-4" + ) + ((= v1-23 (minimap-class chicken-drone)) + "chicken-drone" + ) + ((= v1-23 (minimap-class racer-0)) + "racer-0" + ) + ((= v1-23 (minimap-class racer-5)) + "racer-5" + ) + ((= v1-23 (minimap-class success-seeker)) + "success-seeker" + ) + ((= v1-23 (minimap-class racer-1)) + "racer-1" + ) + ((= v1-23 (minimap-class red-flag)) + "red-flag" + ) + ((= v1-23 (minimap-class racer-6)) + "racer-6" + ) + ((= v1-23 (minimap-class none)) + "none" + ) + ((= v1-23 (minimap-class racer-2)) + "racer-2" + ) + ((= v1-23 (minimap-class neutral-flag)) + "neutral-flag" + ) + ((= v1-23 (minimap-class goal)) + "goal" + ) + ((= v1-23 (minimap-class racer-3)) + "racer-3" + ) + (else + "*unknown*" + ) + ) + ) + ) + (format #t "~1Tscale: ~f~%" (-> this scale)) + (format #t "~1Tcolor: #x~X~%" (-> this color)) + (label cfg-49) + this + ) + +;; definition of type connection-minimap +(deftype connection-minimap (connection-pers) + ((next connection-minimap :override) + (handle handle :overlay-at update-time) + (position vector :overlay-at (-> param 0)) + (alpha float :overlay-at (-> param 1)) + (flags minimap-flag :overlay-at (-> param 2)) + (class minimap-class-node :overlay-at (-> param 3)) + (node uint16) + (edge-ry int16) + (last-world-pos vector :inline) + ) + ) + +;; definition for method 3 of type connection-minimap +;; INFO: Used lq/sq +(defmethod inspect ((this connection-minimap)) + (when (not this) + (set! this this) + (goto cfg-30) + ) + (format #t "[~8x] ~A~%" this 'connection-minimap) + (format #t "~1Tnext: #~%" (-> this next)) + (format #t "~1Tkey: ~A~%" (-> this key)) + (format #t "~1Tupdate-time: ~D~%" (-> this handle)) + (format #t "~1Tparam[4] @ #x~X~%" (-> this param)) + (dotimes (s5-0 4) + (format #t "~T [~D]~1Tparam: ~A~%" s5-0 (-> this param s5-0)) + ) + (format #t "~1Tparam-int32[4] @ #x~X~%" (-> this param)) + (dotimes (s5-1 4) + (format #t "~T [~D]~1Tparam-int32: ~D~%" s5-1 (-> this param s5-1)) + ) + (format #t "~1Tparam-int64[2] @ #x~X~%" (-> this param)) + (dotimes (s5-2 2) + (format #t "~T [~D]~1Tparam-int64: ~D~%" s5-2 (-> this param-int64 s5-2)) + ) + (format #t "~1Tparam-float[4] @ #x~X~%" (-> this param)) + (dotimes (s5-3 4) + (format #t "~T [~D]~1Tparam-float: ~f~%" s5-3 (the-as float (-> this param s5-3))) + ) + (format #t "~1Tparam-quat: #x~X~%" (-> this param-quat)) + (format #t "~1Thandle: ~D~%" (-> this handle)) + (format #t "~1Tposition: #~%" (-> this position)) + (format #t "~1Talpha: ~f~%" (-> this alpha)) + (format #t "~1Tflags: #x~X : (minimap-flag " (-> this flags)) + (let ((s5-4 (-> this flags))) + (if (= (logand s5-4 (minimap-flag active)) (minimap-flag active)) + (format #t "active ") + ) + (if (= (logand s5-4 (minimap-flag fade-in)) (minimap-flag fade-in)) + (format #t "fade-in ") + ) + (if (= (logand s5-4 (minimap-flag racer)) (minimap-flag racer)) + (format #t "racer ") + ) + (if (= (logand s5-4 (minimap-flag minimap)) (minimap-flag minimap)) + (format #t "minimap ") + ) + (if (= (logand s5-4 (minimap-flag flash)) (minimap-flag flash)) + (format #t "flash ") + ) + (if (= (logand s5-4 (minimap-flag task-graph)) (minimap-flag task-graph)) + (format #t "task-graph ") + ) + (if (= (logand s5-4 (minimap-flag fade-out)) (minimap-flag fade-out)) + (format #t "fade-out ") + ) + ) + (format #t ")~%") + (format #t "~1Tclass: #~%" (-> this class)) + (format #t "~1Tnode: ~D~%" (-> this node)) + (format #t "~1Tedge-ry: ~D~%" (-> this edge-ry)) + (format #t "~1Tlast-world-pos: ~`vector`P~%" (-> this last-world-pos)) + (label cfg-30) + this + ) + +;; definition of type engine-minimap +(deftype engine-minimap (engine-pers) + ((alive-list connection-minimap :override) + (dead-list connection-minimap :override) + ) + ) + +;; definition for method 3 of type engine-minimap +(defmethod inspect ((this engine-minimap)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Telement-type: ~A~%" (-> this element-type)) + (format #t "~1Texecute-time: ~D~%" (-> this execute-time)) + (format #t "~1Talive-list: #~%" (-> this alive-list)) + (format #t "~1Tdead-list: #~%" (-> this dead-list)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type minimap-draw-work +(deftype minimap-draw-work (structure) + ((buf dma-buffer) + (global-flags uint32) + (draw-pos vector4w :inline) + (mat matrix :inline) + (corner vector 4 :inline) + (vec vector :inline) + (pos vector :inline) + (mid-val float) + ) + ) + +;; definition for method 3 of type minimap-draw-work +(defmethod inspect ((this minimap-draw-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'minimap-draw-work) + (format #t "~1Tbuf: ~A~%" (-> this buf)) + (format #t "~1Tglobal-flags: ~D~%" (-> this global-flags)) + (format #t "~1Tdraw-pos: #~%" (-> this draw-pos)) + (format #t "~1Tmat: #~%" (-> this mat)) + (format #t "~1Tcorner[4] @ #x~X~%" (-> this corner)) + (format #t "~1Tvec: #~%" (-> this vec)) + (format #t "~1Tpos: #~%" (-> this pos)) + (format #t "~1Tmid-val: ~f~%" (-> this mid-val)) + (label cfg-4) + this + ) + +;; definition of type minimap +(deftype minimap (structure) + ((draw-tmpl dma-gif-packet :inline) + (sprite-tmpl dma-gif-packet :inline) + (sprite2-tmpl dma-gif-packet :inline) + (adgif-tmpl dma-gif-packet :inline) + (color vector4w :inline) + (tex-coords bounding-box2 :inline) + (race-corner vector :inline) + (mat matrix :inline) + (tex-offset vector2 :inline) + (race-tex texture) + (race-scale float) + (meters-per-texel float) + (icon-inv-scale float) + (fade float) + (goal-time float) + (engine engine-minimap) + (engine-key uint32) + ) + (:methods + (minimap-method-9 () none) + (minimap-method-10 () none) + (minimap-method-11 () none) + (minimap-method-12 () none) + (minimap-method-13 () none) + (minimap-method-14 () none) + (minimap-method-15 () none) + ) + ) + +;; definition for method 3 of type minimap +(defmethod inspect ((this minimap)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'minimap) + (format #t "~1Tdraw-tmpl: #~%" (-> this draw-tmpl)) + (format #t "~1Tsprite-tmpl: #~%" (-> this sprite-tmpl)) + (format #t "~1Tsprite2-tmpl: #~%" (-> this sprite2-tmpl)) + (format #t "~1Tadgif-tmpl: #~%" (-> this adgif-tmpl)) + (format #t "~1Tcolor: #~%" (-> this color)) + (format #t "~1Ttex-coords: #~%" (-> this tex-coords)) + (format #t "~1Trace-corner: #~%" (-> this race-corner)) + (format #t "~1Tmat: #~%" (-> this mat)) + (format #t "~1Ttex-offset: #~%" (-> this tex-offset)) + (format #t "~1Trace-tex: ~A~%" (-> this race-tex)) + (format #t "~1Trace-scale: ~f~%" (-> this race-scale)) + (format #t "~1Tmeters-per-texel: ~f~%" (-> this meters-per-texel)) + (format #t "~1Ticon-inv-scale: ~f~%" (-> this icon-inv-scale)) + (format #t "~1Tfade: ~f~%" (-> this fade)) + (format #t "~1Tgoal-time: ~f~%" (-> this goal-time)) + (format #t "~1Tengine: ~A~%" (-> this engine)) + (format #t "~1Tengine-key: ~D~%" (-> this engine-key)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/ui/progress/progress-h_REF.gc b/test/decompiler/reference/jakx/engine/ui/progress/progress-h_REF.gc new file mode 100644 index 0000000000..8e4b1f21d4 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/ui/progress/progress-h_REF.gc @@ -0,0 +1,9 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/ui/text-h_REF.gc b/test/decompiler/reference/jakx/engine/ui/text-h_REF.gc new file mode 100644 index 0000000000..6b68d33837 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/ui/text-h_REF.gc @@ -0,0 +1,75 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type game-text +(deftype game-text (structure) + ((id text-id) + (text string) + ) + :pack-me + ) + +;; definition for method 3 of type game-text +(defmethod inspect ((this game-text)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'game-text) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tindex: ~D~%" (-> this text)) + (label cfg-4) + this + ) + +;; definition of type game-text-info +(deftype game-text-info (basic) + ((length int32) + (language-id int32) + (group-name string) + (dic-index uint32) + (dic-data uint32) + (text uint32) + (text-data uint32) + ) + (:methods + (game-text-info-method-9 () none) + (game-text-info-method-10 () none) + (game-text-info-method-11 () none) + (game-text-info-method-12 () none) + ) + ) + +;; definition for method 3 of type game-text-info +(defmethod inspect ((this game-text-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tlanguage-id: ~D~%" (-> this language-id)) + (format #t "~1Tgroup-name: ~A~%" (-> this group-name)) + (format #t "~1Tdic-index: #x~X~%" (-> this dic-index)) + (format #t "~1Tdic-data: #x~X~%" (-> this dic-data)) + (format #t "~1Ttext: #x~X~%" (-> this text)) + (format #t "~1Ttext-data: #x~X~%" (-> this text-data)) + (label cfg-4) + this + ) + +;; definition for symbol *text-group-names*, type (array string) +(define *text-group-names* (new 'static 'boxed-array :type string "common")) + +;; definition for symbol *common-text-heap*, type kheap +(define *common-text-heap* (new 'global 'kheap)) + +;; definition for symbol *common-text*, type game-text-info +(define *common-text* (the-as game-text-info #f)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/util/capture-h_REF.gc b/test/decompiler/reference/jakx/engine/util/capture-h_REF.gc new file mode 100644 index 0000000000..e9425af35f --- /dev/null +++ b/test/decompiler/reference/jakx/engine/util/capture-h_REF.gc @@ -0,0 +1,125 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) + +;; definition of type gs-store-image-packet +(deftype gs-store-image-packet (structure) + ((vifcode vif-tag 4) + (giftag gif-tag) + (bitbltbuf gs-bitbltbuf) + (bitbltbuf-addr gs-reg64) + (trxpos gs-trxpos) + (trxpos-addr gs-reg64) + (trxreg gs-trxreg) + (trxreg-addr gs-reg64) + (finish uint64) + (finish-addr gs-reg64) + (trxdir gs-trxdir) + (trxdir-addr gs-reg64) + ) + ) + +;; definition for method 3 of type gs-store-image-packet +;; INFO: Used lq/sq +(defmethod inspect ((this gs-store-image-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-store-image-packet) + (format #t "~1Tvifcode[4] @ #x~X~%" (-> this vifcode)) + (format #t "~1Tgiftag: ~D~%" (-> this giftag)) + (format #t "~1Tbitbltbuf: ~D~%" (-> this bitbltbuf)) + (format #t "~1Tbitbltbuf-addr: ~D~%" (-> this bitbltbuf-addr)) + (format #t "~1Ttrxpos: ~D~%" (-> this trxpos)) + (format #t "~1Ttrxpos-addr: ~D~%" (-> this trxpos-addr)) + (format #t "~1Ttrxreg: ~D~%" (-> this trxreg)) + (format #t "~1Ttrxreg-addr: ~D~%" (-> this trxreg-addr)) + (format #t "~1Tfinish: ~D~%" (-> this finish)) + (format #t "~1Tfinish-addr: ~D~%" (-> this finish-addr)) + (format #t "~1Ttrxdir: ~D~%" (-> this trxdir)) + (format #t "~1Ttrxdir-addr: ~D~%" (-> this trxdir-addr)) + (label cfg-4) + this + ) + +;; definition of type screen-shot-work +(deftype screen-shot-work (structure) + ((count int16) + (size int16) + (name string) + (highres-enable symbol) + (highres-objects-enable symbol) + (hud-enable symbol) + (letterbox-enable symbol) + (debug-enable symbol) + (dir basic) + (dir-checked? symbol) + ) + ) + +;; definition for method 3 of type screen-shot-work +(defmethod inspect ((this screen-shot-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'screen-shot-work) + (format #t "~1Tcount: ~D~%" (-> this count)) + (format #t "~1Tsize: ~D~%" (-> this size)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Thighres-enable: ~A~%" (-> this highres-enable)) + (format #t "~1Thighres-objects-enable: ~A~%" (-> this highres-objects-enable)) + (format #t "~1Thud-enable: ~A~%" (-> this hud-enable)) + (format #t "~1Tletterbox-enable: ~A~%" (-> this letterbox-enable)) + (format #t "~1Tdebug-enable: ~A~%" (-> this debug-enable)) + (format #t "~1Tdir: ~A~%" (-> this dir)) + (format #t "~1Tdir-checked?: ~A~%" (-> this dir-checked?)) + (label cfg-4) + this + ) + +;; definition for symbol *screen-shot-work*, type screen-shot-work +(define *screen-shot-work* (new 'global 'screen-shot-work)) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* count) -1) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* size) -1) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* highres-enable) #f) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* highres-objects-enable) #f) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* hud-enable) #f) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* letterbox-enable) #f) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* debug-enable) #f) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* dir) #f) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* dir-checked?) #f) + +;; definition for symbol *image-name*, type string +(define *image-name* (new 'global 'string 128 (the-as string #f))) + +;; definition for symbol *capture-tga-buffer*, type object +(define *capture-tga-buffer* (the-as object #f)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/util/profile-h_REF.gc b/test/decompiler/reference/jakx/engine/util/profile-h_REF.gc new file mode 100644 index 0000000000..4e17ad6c69 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/util/profile-h_REF.gc @@ -0,0 +1,242 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type profile-segment +(deftype profile-segment (structure) + "Confusingly, this has two uses. Either a single event, or a summary of all events within a category." + ((name symbol) + (start-time int16) + (end-time int16) + (count uint8) + (vu-count uint8) + (depth uint16) + (color rgba) + (code-time uint16 :overlay-at start-time) + (vu-time uint16 :overlay-at end-time) + ) + :allow-misaligned + ) + +;; definition for method 3 of type profile-segment +(defmethod inspect ((this profile-segment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'profile-segment) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tstart-time: ~D~%" (-> this start-time)) + (format #t "~1Tend-time: ~D~%" (-> this end-time)) + (format #t "~1Tcount: ~D~%" (-> this count)) + (format #t "~1Tvu-count: ~D~%" (-> this vu-count)) + (format #t "~1Tdepth: ~D~%" (-> this depth)) + (format #t "~1Tcolor: #x~X~%" (-> this color)) + (format #t "~1Tcode-time: ~D~%" (-> this code-time)) + (format #t "~1Tvu-time: ~D~%" (-> this vu-time)) + (label cfg-4) + this + ) + +;; definition of type profile-collapse +(deftype profile-collapse (structure) + "An array of 'summaries'. Each entry in data is a summary of all events within a category." + ((count int32) + (data profile-segment 48 :inline) + ) + ) + +;; definition for method 3 of type profile-collapse +(defmethod inspect ((this profile-collapse)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'profile-collapse) + (format #t "~1Tcount: ~D~%" (-> this count)) + (format #t "~1Tdata[48] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type profile-segment-array +(deftype profile-segment-array (basic) + "All profiling data for a frame, stored as a tree of events. There is one for the VU, and one for the EE." + ((count int16) + (depth int8) + (max-depth int8) + (base-time int16) + (segment profile-segment 9) + (data profile-segment 1024 :inline) + ) + (:methods + (get-total-time (_type_) int) + (start-frame! (_type_) none) + (start-segment! (_type_ symbol rgba) none) + (end-segment! (_type_) none) + ) + ) + +;; definition for method 3 of type profile-segment-array +(defmethod inspect ((this profile-segment-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tcount: ~D~%" (-> this count)) + (format #t "~1Tdepth: ~D~%" (-> this depth)) + (format #t "~1Tmax-depth: ~D~%" (-> this max-depth)) + (format #t "~1Tbase-time: ~D~%" (-> this base-time)) + (format #t "~1Tsegment[9] @ #x~X~%" (-> this segment)) + (format #t "~1Tdata[2100] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type profile-array +(deftype profile-array (structure) + "The EE and VU profilers, and the drawing code." + ((data profile-segment-array 2) + ) + (:methods + (postprocess-data! (_type_) none) + (draw-bars! (_type_ dma-buffer int) none) + (draw-text! (_type_) none) + ) + ) + +;; definition for method 3 of type profile-array +(defmethod inspect ((this profile-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'profile-array) + (format #t "~1Tdata[2] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition for method 9 of type profile-segment-array +(defmethod get-total-time ((this profile-segment-array)) + "Get the duration of the top-level event (typically, the whole frame)" + (- (-> this data 0 end-time) (-> this data 0 start-time)) + ) + +;; definition of type profile-spec +(deftype profile-spec (structure) + "Specification for a profile category." + ((name symbol) + (color rgba) + ) + ) + +;; definition for method 3 of type profile-spec +(defmethod inspect ((this profile-spec)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'profile-spec) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tcolor: ~D~%" (-> this color)) + (label cfg-4) + this + ) + +;; definition for symbol *profile-gap-color*, type rgba +(define *profile-gap-color* (new 'static 'rgba :r #x30 :g #x30 :b #x30 :a #x80)) + +;; definition for symbol *profile-all-color*, type rgba +(define *profile-all-color* (new 'static 'rgba :r #x55 :g #x55 :b #x55 :a #x80)) + +;; definition for symbol *profile-blit-color*, type rgba +(define *profile-blit-color* (new 'static 'rgba :r #x20 :g #x20 :b #x80 :a #x80)) + +;; definition for symbol *profile-sky-color*, type rgba +(define *profile-sky-color* (new 'static 'rgba :r #x20 :g #x80 :b #x20 :a #x80)) + +;; definition for symbol *profile-ocean-color*, type rgba +(define *profile-ocean-color* (new 'static 'rgba :r #x20 :g #x80 :b #x80 :a #x80)) + +;; definition for symbol *profile-tfrag-color*, type rgba +(define *profile-tfrag-color* (new 'static 'rgba :r #x80 :g #x20 :b #x80 :a #x80)) + +;; definition for symbol *profile-texture-color*, type rgba +(define *profile-texture-color* (new 'static 'rgba :r #x80 :g #x80 :b #x20 :a #x80)) + +;; definition for symbol *profile-tie-color*, type rgba +(define *profile-tie-color* (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)) + +;; definition for symbol *profile-generic-color*, type rgba +(define *profile-generic-color* (new 'static 'rgba :r #x70 :g #x70 :a #x80)) + +;; definition for symbol *profile-merc-color*, type rgba +(define *profile-merc-color* (new 'static 'rgba :r #x70 :b #x70 :a #x80)) + +;; definition for symbol *profile-shrubbery-color*, type rgba +(define *profile-shrubbery-color* (new 'static 'rgba :r #x70 :a #x80)) + +;; definition for symbol *profile-particle-color*, type rgba +(define *profile-particle-color* (new 'static 'rgba :g #x70 :b #x70 :a #x80)) + +;; definition for symbol *profile-debug-color*, type rgba +(define *profile-debug-color* (new 'static 'rgba :g #x70 :a #x80)) + +;; definition for symbol *profile-other-color*, type rgba +(define *profile-other-color* (new 'static 'rgba :g #x70 :b #x70 :a #x80)) + +;; definition for symbol *profile-joints-color*, type rgba +(define *profile-joints-color* (new 'static 'rgba :r #x70 :g #x70 :b #x20 :a #x80)) + +;; definition for symbol *profile-draw-hook-color*, type rgba +(define *profile-draw-hook-color* (new 'static 'rgba :r #x20 :g #x70 :b #x70 :a #x80)) + +;; definition for symbol *profile-background-color*, type rgba +(define *profile-background-color* (new 'static 'rgba :r #x60 :g #x60 :b #x40 :a #x80)) + +;; definition for symbol *profile-foreground-color*, type rgba +(define *profile-foreground-color* (new 'static 'rgba :r #x40 :g #x60 :b #x60 :a #x80)) + +;; definition for symbol *profile-bones-color*, type rgba +(define *profile-bones-color* (new 'static 'rgba :r #x20 :g #x80 :b #x60 :a #x80)) + +;; definition for symbol *profile-actors-color*, type rgba +(define *profile-actors-color* (new 'static 'rgba :r #x80 :g #x10 :b #x70 :a #x80)) + +;; definition for symbol *profile-collide-color*, type rgba +(define *profile-collide-color* (new 'static 'rgba :r #x80 :g #x40 :b #x80 :a #x80)) + +;; definition for symbol *profile-nav-color*, type rgba +(define *profile-nav-color* (new 'static 'rgba :r #x38 :g #x48 :b #x80 :a #x80)) + +;; definition for symbol *profile-camera-color*, type rgba +(define *profile-camera-color* (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)) + +;; definition for symbol *profile-gs-sync-color*, type rgba +(define *profile-gs-sync-color* (new 'static 'rgba :r #x70 :g #x70 :b #x70 :a #x80)) + +;; this part is debug only +(when *debug-segment* +;; definition for symbol *profile-array*, type profile-array +(define *profile-array* (new 'debug 'profile-array)) + +;; failed to figure out what this is: +(set! (-> *profile-array* data 0) (new 'debug 'profile-segment-array)) + +;; failed to figure out what this is: +(set! (-> *profile-array* data 1) (new 'debug 'profile-segment-array)) + +;; definition for symbol *profile-collapse*, type profile-collapse +(define *profile-collapse* (new 'debug 'profile-collapse)) + +;; definition for symbol *profile-interrupt-segment*, type profile-segment-array +(define *profile-interrupt-segment* (-> *profile-array* data 1)) + +;; definition for symbol *profile-interrupt-start*, type symbol +(define *profile-interrupt-start* #f) + +) + + + diff --git a/test/decompiler/reference/jakx/engine/util/script-h_REF.gc b/test/decompiler/reference/jakx/engine/util/script-h_REF.gc new file mode 100644 index 0000000000..b825927c80 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/util/script-h_REF.gc @@ -0,0 +1,102 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type script-form +(deftype script-form (structure) + ((name symbol) + (spec pair) + (func (function script-context object)) + ) + :pack-me + (:methods + (script-form-method-9 () none) + ) + ) + +;; definition for method 3 of type script-form +(defmethod inspect ((this script-form)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'script-form) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tspec: ~A~%" (-> this spec)) + (format #t "~1Tfunc: ~A~%" (-> this func)) + (label cfg-4) + this + ) + +;; definition of type script-context +(deftype script-context (structure) + ((load-state load-state) + (key object) + (process process) + (trans vector) + (side-effect? symbol) + (got-error? symbol) + (expr pair) + (param-count int32) + (param object 16) + (param-type object 16) + ) + (:methods + (new (symbol type object process vector) _type_) + (eval! (_type_ pair) object) + (script-context-method-10 (_type_ object pair) object) + (script-context-method-11 (_type_ pair pair symbol) symbol) + ) + ) + +;; definition for method 3 of type script-context +(defmethod inspect ((this script-context)) + (when (not this) + (set! this this) + (goto cfg-10) + ) + (format #t "[~8x] ~A~%" this 'script-context) + (format #t "~1Tload-state: ~A~%" (-> this load-state)) + (format #t "~1Tkey: ~A~%" (-> this key)) + (format #t "~1Tprocess: ~A~%" (-> this process)) + (format #t "~1Ttrans: #~%" (-> this trans)) + (format #t "~1Tside-effect?: ~A~%" (-> this side-effect?)) + (format #t "~1Tgot-error?: ~A~%" (-> this got-error?)) + (format #t "~1Texpr: ~A~%" (-> this expr)) + (format #t "~1Tparam-count: ~D~%" (-> this param-count)) + (format #t "~1Tparam[16] @ #x~X~%" (-> this param)) + (dotimes (s5-0 (-> this param-count)) + (format #t "~T [~D]~1Tparam: ~`object`P~%" s5-0 (-> this param s5-0)) + ) + (format #t "~1Tparam-type[16] @ #x~X~%" (-> this param-type)) + (dotimes (s5-1 (-> this param-count)) + (format #t "~T [~D]~1Tparam-type: ~`object`P~%" s5-1 (-> this param-type s5-1)) + ) + (label cfg-10) + this + ) + +;; definition for method 0 of type script-context +;; WARN: Return type mismatch structure vs script-context. +(defmethod new script-context ((allocation symbol) (type-to-make type) (arg0 object) (arg1 process) (arg2 vector)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + (let ((v0-0 (t9-0 allocation v1-1))) + (set! (-> (the-as script-context v0-0) key) arg0) + (set! (-> (the-as script-context v0-0) process) arg1) + (set! (-> (the-as script-context v0-0) load-state) *load-state*) + (set! (-> (the-as script-context v0-0) side-effect?) #t) + (set! (-> (the-as script-context v0-0) got-error?) #f) + (set! (-> (the-as script-context v0-0) trans) arg2) + (the-as script-context v0-0) + ) + ) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jakx/engine/util/smush-control-h_REF.gc b/test/decompiler/reference/jakx/engine/util/smush-control-h_REF.gc new file mode 100644 index 0000000000..0dd767f256 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/util/smush-control-h_REF.gc @@ -0,0 +1,145 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type smush-control +(deftype smush-control (structure) + "This holds information about the current state of an object's smush." + ((start-time time-frame) + (period float) + (duration float) + (amp float) + (damp-amp float) + (damp-period float) + (ticks float) + ) + (:methods + (set-zero! (_type_) _type_) + (update! (_type_) float) + (get-no-update (_type_) float) + (activate! (_type_ float int int float float clock) _type_) + (nonzero-amplitude? (_type_) symbol) + (die-on-next-update! (_type_) _type_) + ) + ) + +;; definition for method 3 of type smush-control +(defmethod inspect ((this smush-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'smush-control) + (format #t "~1Tstart-time: ~D~%" (-> this start-time)) + (format #t "~1Tperiod: ~f~%" (-> this period)) + (format #t "~1Tduration: ~f~%" (-> this duration)) + (format #t "~1Tamp: ~f~%" (-> this amp)) + (format #t "~1Tdamp-amp: ~f~%" (-> this damp-amp)) + (format #t "~1Tdamp-period: ~f~%" (-> this damp-period)) + (format #t "~1Tticks: ~f~%" (-> this ticks)) + (label cfg-4) + this + ) + +;; definition for method 13 of type smush-control +(defmethod nonzero-amplitude? ((this smush-control)) + "Is the smush currently active?" + (!= (-> this amp) 0.0) + ) + +;; definition for method 9 of type smush-control +(defmethod set-zero! ((this smush-control)) + "Reset this [[smush-control]]." + (set! (-> this period) 0.0) + (set! (-> this duration) 0.0) + (set! (-> this amp) 0.0) + (set! (-> this damp-amp) 0.0) + (set! (-> this damp-period) 0.0) + (set! (-> this ticks) 0.0) + this + ) + +;; definition for method 10 of type smush-control +(defmethod update! ((this smush-control)) + "Calculate the next smush amplitude and update the smush state." + (cond + ((!= (-> this amp) 0.0) + (let* ((elapsed-time (the float (- (current-time) (-> this start-time)))) + (period (-> this period)) + (f28-0 (- elapsed-time (* (the float (the int (/ elapsed-time period))) period))) + ) + (when (>= (- elapsed-time (-> this ticks)) (-> this period)) + (set! (-> this amp) (* (-> this amp) (-> this damp-amp))) + (set! (-> this period) (* (-> this period) (-> this damp-period))) + (set! (-> this ticks) elapsed-time) + (if (< (-> this damp-period) 0.0) + (set-zero! this) + ) + ) + (if (>= elapsed-time (-> this duration)) + (set-zero! this) + ) + (* (sin (/ (* 65536.0 f28-0) (-> this period))) + (* (-> this amp) (/ (- (-> this duration) elapsed-time) (-> this duration))) + ) + ) + ) + (else + 0.0 + ) + ) + ) + +;; definition for method 11 of type smush-control +(defmethod get-no-update ((this smush-control)) + "Get the next amplitude, but do not update the smush state." + (cond + ((!= (-> this amp) 0.0) + (let* ((elapsed-time (the float (- (current-time) (-> this start-time)))) + (period (-> this period)) + (f0-4 (- elapsed-time (* (the float (the int (/ elapsed-time period))) period))) + ) + (* (sin (/ (* 65536.0 f0-4) (-> this period))) + (* (-> this amp) (/ (- (-> this duration) elapsed-time) (-> this duration))) + ) + ) + ) + (else + 0.0 + ) + ) + ) + +;; definition for method 14 of type smush-control +(defmethod die-on-next-update! ((this smush-control)) + "Set the dampening period so the smush stops on the next update." + (if (!= (-> this amp) 0.0) + (set! (-> this damp-period) -1.0) + ) + this + ) + +;; definition for method 12 of type smush-control +(defmethod activate! ((this smush-control) + (amplitude float) + (period int) + (duration int) + (damp-amplitude float) + (damp-period float) + (clock clock) + ) + "Start the smush with the given parameters." + (when (>= (fabs (/ (-> this amp) 5)) (fabs (get-no-update this))) + (set! (-> this amp) amplitude) + (set! (-> this period) (the float period)) + (set! (-> this duration) (the float duration)) + (set! (-> this damp-amp) damp-amplitude) + (set! (-> this damp-period) damp-period) + (set! (-> this ticks) 0.0) + (set! (-> this start-time) (-> clock frame-counter)) + ) + this + ) + + + + diff --git a/test/decompiler/reference/jakx/engine/util/types-h_REF.gc b/test/decompiler/reference/jakx/engine/util/types-h_REF.gc new file mode 100644 index 0000000000..ba3c614bf1 --- /dev/null +++ b/test/decompiler/reference/jakx/engine/util/types-h_REF.gc @@ -0,0 +1,57 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type basic-reserved +(deftype basic-reserved (basic) + () + (:methods + (basic-reserved-method-9 () none) + (basic-reserved-method-10 () none) + (basic-reserved-method-11 () none) + (basic-reserved-method-12 () none) + (basic-reserved-method-13 () none) + (basic-reserved-method-14 () none) + (basic-reserved-method-15 () none) + (basic-reserved-method-16 () none) + (basic-reserved-method-17 () none) + (basic-reserved-method-18 () none) + (basic-reserved-method-19 () none) + (basic-reserved-method-20 () none) + (basic-reserved-method-21 () none) + (basic-reserved-method-22 () none) + (basic-reserved-method-23 () none) + (basic-reserved-method-24 () none) + (basic-reserved-method-25 () none) + (basic-reserved-method-26 () none) + (basic-reserved-method-27 () none) + (basic-reserved-method-28 () none) + ) + ) + +;; definition for method 3 of type basic-reserved +(defmethod inspect ((this basic-reserved)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (label cfg-4) + this + ) + +;; type part-id is defined here, but it is unknown to the decompiler + +;; failed to figure out what this is: +(new 'static 'boxed-array :type type + pilot-info + flut-info + mech-info + turret-info + indax-info + tube-info + race-mesh + ) + + + + diff --git a/test/decompiler/reference/jakx/levels/city/common/trail-h_REF.gc b/test/decompiler/reference/jakx/levels/city/common/trail-h_REF.gc new file mode 100644 index 0000000000..93c48d9432 --- /dev/null +++ b/test/decompiler/reference/jakx/levels/city/common/trail-h_REF.gc @@ -0,0 +1,365 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type trail-node +(deftype trail-node (structure) + ((next-id int16) + (prev-id int16) + (parent-id int16) + (x int16) + (y int16) + (z int16) + (first-conn uint16) + (cost-from-start uint16) + (cost-to-goal uint16) + (flags trail-node-flag) + (conn-count uint8) + ) + :pack-me + (:methods + (get-dist-score (_type_ vector) uint) + (debug-draw (_type_ int) symbol) + (get-position (_type_ vector) vector) + ) + ) + +;; definition for method 3 of type trail-node +(defmethod inspect ((this trail-node)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'trail-node) + (format #t "~1Tnext-id: ~D~%" (-> this next-id)) + (format #t "~1Tprev-id: ~D~%" (-> this prev-id)) + (format #t "~1Tparent-id: ~D~%" (-> this parent-id)) + (format #t "~1Tx: ~D~%" (-> this x)) + (format #t "~1Ty: ~D~%" (-> this y)) + (format #t "~1Tz: ~D~%" (-> this z)) + (format #t "~1Tfirst-conn: ~D~%" (-> this first-conn)) + (format #t "~1Tcost-from-start: ~D~%" (-> this cost-from-start)) + (format #t "~1Tcost-to-goal: ~D~%" (-> this cost-to-goal)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tconn-count: ~D~%" (-> this conn-count)) + (label cfg-4) + this + ) + +;; definition of type trail-visgroup +(deftype trail-visgroup (structure) + ((first-node uint16) + (node-count uint8) + (pad uint8) + ) + ) + +;; definition for method 3 of type trail-visgroup +(defmethod inspect ((this trail-visgroup)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'trail-visgroup) + (format #t "~1Tfirst-node: ~D~%" (-> this first-node)) + (format #t "~1Tnode-count: ~D~%" (-> this node-count)) + (format #t "~1Tpad: ~D~%" (-> this pad)) + (label cfg-4) + this + ) + +;; definition of type trail-blocker +(deftype trail-blocker (structure) + ((plane plane :inline) + (center vector :inline) + (radius-squared float :overlay-at (-> center data 3)) + ) + ) + +;; definition for method 3 of type trail-blocker +(defmethod inspect ((this trail-blocker)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'trail-blocker) + (format #t "~1Tplane: #~%" (-> this plane)) + (format #t "~1Tcenter: #~%" (-> this center)) + (format #t "~1Tradius-squared: ~f~%" (-> this center w)) + (label cfg-4) + this + ) + +;; definition of type trail-conn +(deftype trail-conn (structure) + ((head-id uint16) + (tail-id uint16) + (flags conn-flag) + (visgroup-id uint8) + (cost uint16) + ) + :pack-me + (:methods + (debug-draw (_type_ trail-graph int) none) + ) + ) + +;; definition for method 3 of type trail-conn +(defmethod inspect ((this trail-conn)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'trail-conn) + (format #t "~1Thead-id: ~D~%" (-> this head-id)) + (format #t "~1Ttail-id: ~D~%" (-> this tail-id)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tvisgroup-id: ~D~%" (-> this visgroup-id)) + (format #t "~1Tcost: ~D~%" (-> this cost)) + (label cfg-4) + this + ) + +;; definition of type trail-conn-hash-cell +(deftype trail-conn-hash-cell (structure) + ((first-conn uint16) + (conn-count uint8) + (pov-count uint8) + (first-pov uint16) + ) + :pack-me + ) + +;; definition for method 3 of type trail-conn-hash-cell +(defmethod inspect ((this trail-conn-hash-cell)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'trail-conn-hash-cell) + (format #t "~1Tfirst-conn: ~D~%" (-> this first-conn)) + (format #t "~1Tconn-count: ~D~%" (-> this conn-count)) + (format #t "~1Tpov-count: ~D~%" (-> this pov-count)) + (format #t "~1Tfirst-pov: ~D~%" (-> this first-pov)) + (label cfg-4) + this + ) + +;; definition of type trail-conn-search +(deftype trail-conn-search (structure) + ((best-conn-id int32) + (best-dist float) + (src-pos vector) + (conn-pos vector) + (debug-cells-searched int32) + (debug-conns-searched int32) + (bounds bounding-box4w :inline) + (cell-quads qword 2 :inline) + (conn-quads qword 7 :inline) + (cell-bits vector16ub 2 :inline :overlay-at cell-quads) + (conn-bits vector16ub 2 :inline :overlay-at conn-quads) + ) + ) + +;; definition for method 3 of type trail-conn-search +(defmethod inspect ((this trail-conn-search)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'trail-conn-search) + (format #t "~1Tbest-conn-id: ~D~%" (-> this best-conn-id)) + (format #t "~1Tbest-dist: ~f~%" (-> this best-dist)) + (format #t "~1Tsrc-pos: #~%" (-> this src-pos)) + (format #t "~1Tconn-pos: #~%" (-> this conn-pos)) + (format #t "~1Tdebug-cells-searched: ~D~%" (-> this debug-cells-searched)) + (format #t "~1Tdebug-conns-searched: ~D~%" (-> this debug-conns-searched)) + (format #t "~1Tbounds: #~%" (-> this bounds)) + (format #t "~1Tcell-quads[2] @ #x~X~%" (-> this cell-quads)) + (format #t "~1Tconn-quads[7] @ #x~X~%" (-> this conn-quads)) + (format #t "~1Tcell-bits[2] @ #x~X~%" (-> this cell-quads)) + (format #t "~1Tconn-bits[2] @ #x~X~%" (-> this conn-quads)) + (label cfg-4) + this + ) + +;; definition of type trail-conn-hash +(deftype trail-conn-hash (basic) + ((cell-width meters) + (origin vector :inline) + (cell (inline-array trail-conn-hash-cell)) + (conn-ids (pointer uint16)) + ) + ) + +;; definition for method 3 of type trail-conn-hash +(defmethod inspect ((this trail-conn-hash)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tcell-width: (meters ~m)~%" (-> this cell-width)) + (format #t "~1Torigin: #~%" (-> this origin)) + (format #t "~1Tcell: #x~X~%" (-> this cell)) + (format #t "~1Tconn-ids: #x~X~%" (-> this conn-ids)) + (label cfg-4) + this + ) + +;; definition of type trail-cached-search-info +(deftype trail-cached-search-info (structure) + ((goal-conn-id int16) + (orig-goal-pos vector :inline) + (conn-goal-pos vector :inline) + ) + ) + +;; definition for method 3 of type trail-cached-search-info +(defmethod inspect ((this trail-cached-search-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'trail-cached-search-info) + (format #t "~1Tgoal-conn-id: ~D~%" (-> this goal-conn-id)) + (format #t "~1Torig-goal-pos: #~%" (-> this orig-goal-pos)) + (format #t "~1Tconn-goal-pos: #~%" (-> this conn-goal-pos)) + (label cfg-4) + this + ) + +;; definition of type trail-cached-start-pov +(deftype trail-cached-start-pov (structure) + ((last-updated time-frame) + (pov-can-see-start uint64) + (next-node-id int32) + (start-pos vector :inline) + ) + ) + +;; definition for method 3 of type trail-cached-start-pov +(defmethod inspect ((this trail-cached-start-pov)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'trail-cached-start-pov) + (format #t "~1Tlast-updated: ~D~%" (-> this last-updated)) + (format #t "~1Tpov-can-see-start: ~D~%" (-> this pov-can-see-start)) + (format #t "~1Tnext-node-id: ~D~%" (-> this next-node-id)) + (format #t "~1Tstart-pos: #~%" (-> this start-pos)) + (label cfg-4) + this + ) + +;; definition of type trail-graph +(deftype trail-graph (basic) + ((mode uint8) + (search-id uint32) + (open-head-id int16) + (goal-conn-id int16) + (goal-node-id int16) + (over-under-thresh float) + (over-under-above-too-low float) + (over-under-below-too-high float) + (pov-node-count uint16) + (node-count uint16) + (conn-count uint16) + (blocker-count uint16) + (conn-mask uint8) + (node (inline-array trail-node)) + (conn (inline-array trail-conn)) + (blocker (inline-array trail-blocker)) + (conn-ids (pointer uint16)) + (visgroup (inline-array trail-conn-hash-cell)) + (visnode-ids (pointer uint16)) + (conn-hash trail-conn-hash) + (cell-pov-bit-arrays (pointer uint64)) + (pov-can-see-goal uint64) + (cached-start-pov trail-cached-start-pov :inline) + (orig-start-pos vector :inline) + (orig-goal-pos vector :inline) + (conn-start-pos vector :inline) + (conn-goal-pos vector :inline) + (open-quads qword 6 :inline) + (closed-quads qword 6 :inline) + (open-bits vector16ub 2 :inline :overlay-at open-quads) + (closed-bits vector16ub 2 :inline :overlay-at closed-quads) + ) + (:methods + (trail-graph-method-9 (_type_ int) int) + (trail-graph-method-10 (_type_ int) symbol) + (trail-graph-method-11 (_type_ int int) trail-node) + (trail-graph-method-12 (_type_ trail-node vector) symbol) + (trail-graph-method-13 (_type_ vector vector) symbol) + (debug-draw (_type_) symbol) + (trail-graph-method-15 (_type_ int) symbol) + (trail-graph-method-16 (_type_ int (pointer uint16) vector vector rgba float) symbol) + (trail-graph-method-17 (_type_ vector vector) int) + (trail-graph-method-18 (_type_ vector) int) + (trail-graph-method-19 (_type_) none) + (trail-graph-method-20 (_type_ uint vector) vector) + (trail-graph-method-21 (_type_ (pointer uint16) int (pointer int32) (pointer float)) int) + (trail-graph-method-22 (_type_ int int) symbol) + (trail-graph-method-23 (_type_) symbol) + (trail-graph-method-24 (_type_ uint vector int int) symbol) + (trail-graph-method-25 (_type_ int) int) + (trail-graph-method-26 (_type_) int) + (trail-graph-method-27 (_type_) int) + (trail-graph-method-28 (_type_ trail-conn-search int int) symbol) + (trail-graph-method-29 (_type_ vector vector trail-cached-search-info) int) + (trail-graph-method-30 (_type_) int) + (trail-graph-method-31 (_type_ int) none) + (trail-graph-method-32 (_type_) uint) + (trail-graph-method-33 (_type_ int) symbol) + ) + ) + +;; definition for method 3 of type trail-graph +(defmethod inspect ((this trail-graph)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tmode: ~D~%" (-> this mode)) + (format #t "~1Tsearch-id: ~D~%" (-> this search-id)) + (format #t "~1Topen-head-id: ~D~%" (-> this open-head-id)) + (format #t "~1Tgoal-conn-id: ~D~%" (-> this goal-conn-id)) + (format #t "~1Tgoal-node-id: ~D~%" (-> this goal-node-id)) + (format #t "~1Tover-under-thresh: ~f~%" (-> this over-under-thresh)) + (format #t "~1Tover-under-above-too-low: ~f~%" (-> this over-under-above-too-low)) + (format #t "~1Tover-under-below-too-high: ~f~%" (-> this over-under-below-too-high)) + (format #t "~1Tpov-node-count: ~D~%" (-> this pov-node-count)) + (format #t "~1Tnode-count: ~D~%" (-> this node-count)) + (format #t "~1Tconn-count: ~D~%" (-> this conn-count)) + (format #t "~1Tblocker-count: ~D~%" (-> this blocker-count)) + (format #t "~1Tconn-mask: ~D~%" (-> this conn-mask)) + (format #t "~1Tnode: #x~X~%" (-> this node)) + (format #t "~1Tconn: #x~X~%" (-> this conn)) + (format #t "~1Tblocker: #x~X~%" (-> this blocker)) + (format #t "~1Tconn-ids: #x~X~%" (-> this conn-ids)) + (format #t "~1Tvisgroup: #x~X~%" (-> this visgroup)) + (format #t "~1Tvisnode-ids: #x~X~%" (-> this visnode-ids)) + (format #t "~1Tconn-hash: ~A~%" (-> this conn-hash)) + (format #t "~1Tcell-pov-bit-arrays: #x~X~%" (-> this cell-pov-bit-arrays)) + (format #t "~1Tpov-can-see-goal: ~D~%" (-> this pov-can-see-goal)) + (format #t "~1Tcached-start-pov: #~%" (-> this cached-start-pov)) + (format #t "~1Torig-start-pos: #~%" (-> this orig-start-pos)) + (format #t "~1Torig-goal-pos: #~%" (-> this orig-goal-pos)) + (format #t "~1Tconn-start-pos: #~%" (-> this conn-start-pos)) + (format #t "~1Tconn-goal-pos: #~%" (-> this conn-goal-pos)) + (format #t "~1Topen-quads[6] @ #x~X~%" (-> this open-quads)) + (format #t "~1Tclosed-quads[6] @ #x~X~%" (-> this closed-quads)) + (format #t "~1Topen-bits[2] @ #x~X~%" (-> this open-quads)) + (format #t "~1Tclosed-bits[2] @ #x~X~%" (-> this closed-quads)) + (label cfg-4) + this + ) + +;; definition for symbol *trail-graph*, type trail-graph +(define *trail-graph* (the-as trail-graph #f)) + + + + diff --git a/test/goalc/test_type_consistency.cpp b/test/goalc/test_type_consistency.cpp index 8fdb59b39f..6c7cb21c72 100644 --- a/test/goalc/test_type_consistency.cpp +++ b/test/goalc/test_type_consistency.cpp @@ -39,7 +39,7 @@ TEST(Jak2TypeConsistency, MANUAL_TEST_TypeConsistencyWithBuildFirst) { compiler.run_test_no_load("decompiler/config/jak2/all-types.gc"); } -TEST(Jak3TypeConsistency, TypeConsistencyWithBuildFirst) { +TEST(Jak3TypeConsistency, MANUAL_TEST_TypeConsistencyWithBuildFirst) { Compiler compiler(GameVersion::Jak3, emitter::InstructionSet::X86); compiler.enable_throw_on_redefines(); add_common_expected_type_mismatches(compiler); @@ -48,14 +48,14 @@ TEST(Jak3TypeConsistency, TypeConsistencyWithBuildFirst) { compiler.run_test_no_load("decompiler/config/jak3/all-types.gc"); } -// TEST(JakXTypeConsistency, TypeConsistencyWithBuildFirst) { -// Compiler compiler(GameVersion::JakX, emitter::InstructionSet::X86); -// compiler.enable_throw_on_redefines(); -// add_common_expected_type_mismatches(compiler); -// add_jakx_expected_type_mismatches(compiler); -// compiler.run_test_no_load("test/goalc/source_templates/with_game/test-build-all-code.gc"); -// compiler.run_test_no_load("decompiler/config/jakx/all-types.gc"); -// } +TEST(JakXTypeConsistency, TypeConsistencyWithBuildFirst) { + Compiler compiler(GameVersion::JakX, emitter::InstructionSet::X86); + compiler.enable_throw_on_redefines(); + add_common_expected_type_mismatches(compiler); + add_jakx_expected_type_mismatches(compiler); + compiler.run_test_no_load("test/goalc/source_templates/with_game/test-build-all-code.gc"); + compiler.run_test_no_load("decompiler/config/jakx/all-types.gc"); +} TEST(Jak1TypeConsistency, TypeConsistency) { Compiler compiler(GameVersion::Jak1, emitter::InstructionSet::X86); @@ -84,11 +84,11 @@ TEST(Jak3TypeConsistency, TypeConsistency) { compiler.run_test_no_load("test/goalc/source_templates/with_game/test-build-all-code.gc"); } -// TEST(JakXTypeConsistency, TypeConsistency) { -// Compiler compiler(GameVersion::JakX, emitter::InstructionSet::X86); -// compiler.enable_throw_on_redefines(); -// add_common_expected_type_mismatches(compiler); -// add_jakx_expected_type_mismatches(compiler); -// compiler.run_test_no_load("decompiler/config/jakx/all-types.gc"); -// compiler.run_test_no_load("test/goalc/source_templates/with_game/test-build-all-code.gc"); -// } +TEST(JakXTypeConsistency, TypeConsistency) { + Compiler compiler(GameVersion::JakX, emitter::InstructionSet::X86); + compiler.enable_throw_on_redefines(); + add_common_expected_type_mismatches(compiler); + add_jakx_expected_type_mismatches(compiler); + compiler.run_test_no_load("decompiler/config/jakx/all-types.gc"); + compiler.run_test_no_load("test/goalc/source_templates/with_game/test-build-all-code.gc"); +} diff --git a/test/offline/config/jakx/config.jsonc b/test/offline/config/jakx/config.jsonc new file mode 100644 index 0000000000..cbc9b984e2 --- /dev/null +++ b/test/offline/config/jakx/config.jsonc @@ -0,0 +1,404 @@ +{ + "dgos": [ + "CGO/KERNEL.CGO", + "CGO/GAME.CGO", + "DGO/ASHCRED.DGO", + "DGO/ASHLEV.DGO", + "DGO/ASHVL.DGO", + "DGO/ASHVL2.DGO", + "DGO/ASHVL3.DGO", + "DGO/ATL.DGO", + "DGO/ATOLLART.DGO", + "DGO/ATOLLCTF.DGO", + "DGO/ATOLLS.DGO", + "DGO/ATOPLOW.DGO", + "DGO/ATX.DGO", + "DGO/BEARL.DGO", + "DGO/BOBCL.DGO", + "DGO/BRDROOM.DGO", + "DGO/BRDROOMF.DGO", + "DGO/CANFOOT.DGO", + "DGO/CANSPARS.DGO", + "DGO/CANSPARW.DGO", + "DGO/CANTBOX.DGO", + "DGO/CANYONS.DGO", + "DGO/CANYONTT.DGO", + "DGO/CANYONW.DGO", + "DGO/CARS.DGO", + "DGO/CHEEL.DGO", + "DGO/CLF.DGO", + "DGO/CLFX.DGO", + "DGO/CLIFCTF.DGO", + "DGO/CLIFFART.DGO", + "DGO/CLIFFSS.DGO", + "DGO/CLIFHUNT.DGO", + "DGO/CLIFTRN.DGO", + "DGO/CNSPFOOT.DGO", + "DGO/CNSPTBOX.DGO", + "DGO/CNSPTT.DGO", + "DGO/COL.DGO", + "DGO/COLART.DGO", + "DGO/COLICLCT.DGO", + "DGO/COLICTF.DGO", + "DGO/COLIREV.DGO", + "DGO/COLISEUS.DGO", + "DGO/COLX.DGO", + "DGO/COUGL.DGO", + "DGO/CREDITS.DGO", + "DGO/CSX.DGO", + "DGO/CSY.DGO", + "DGO/CYA.DGO", + "DGO/CYB.DGO", + "DGO/CYC.DGO", + "DGO/CYD.DGO", + "DGO/CYE.DGO", + "DGO/CYX.DGO", + "DGO/CYY.DGO", + "DGO/DAXCRED.DGO", + "DGO/DAXLEV.DGO", + "DGO/DAXTL.DGO", + "DGO/DESACTF.DGO", + "DGO/DESARENS.DGO", + "DGO/DESART.DGO", + "DGO/DESCLCT.DGO", + "DGO/DESHUNT.DGO", + "DGO/DESHUNT2.DGO", + "DGO/DESISLES.DGO", + "DGO/DESRAPT.DGO", + "DGO/DESREV.DGO", + "DGO/DETHRACE.DGO", + "DGO/DISLEART.DGO", + "DGO/DISLECTF.DGO", + "DGO/DKA.DGO", + "DGO/DKB.DGO", + "DGO/DKC.DGO", + "DGO/DKD.DGO", + "DGO/DKE.DGO", + "DGO/DKKRFOOT.DGO", + "DGO/DKKRTBOX.DGO", + "DGO/DKKRTT.DGO", + "DGO/DKKX.DGO", + "DGO/DKKY.DGO", + "DGO/DKX.DGO", + "DGO/DOCKFOOT.DGO", + "DGO/DOCKKRAS.DGO", + "DGO/DOCKKRAW.DGO", + "DGO/DOCKSS.DGO", + "DGO/DOCKSTT.DGO", + "DGO/DOCKSW.DGO", + "DGO/DOCKTBOX.DGO", + "DGO/DRA.DGO", + "DGO/DRB.DGO", + "DGO/DRC.DGO", + "DGO/DRD.DGO", + "DGO/DRDKFOOT.DGO", + "DGO/DRDKTBOX.DGO", + "DGO/DRDKTT.DGO", + "DGO/DRDX.DGO", + "DGO/DRDY.DGO", + "DGO/DROMDOCS.DGO", + "DGO/DROMDOCW.DGO", + "DGO/DROMES.DGO", + "DGO/DROMETT.DGO", + "DGO/DROMEW.DGO", + "DGO/DROMEX.DGO", + "DGO/DROMFOOT.DGO", + "DGO/DROMTBOX.DGO", + "DGO/DRONE.DGO", + "DGO/DRX.DGO", + "DGO/DRY.DGO", + "DGO/DSI.DGO", + "DGO/DSR.DGO", + "DGO/DSRX.DGO", + "DGO/DSX.DGO", + "DGO/EIGHT.DGO", + "DGO/EIGHTB.DGO", + "DGO/FALCL.DGO", + "DGO/FMVLEV.DGO", + "DGO/FOXL.DGO", + "DGO/GARAGE.DGO", + "DGO/GARAGEB.DGO", + "DGO/GILAL.DGO", + "DGO/GTBCRED.DGO", + "DGO/GTBLEV.DGO", + "DGO/GTBVL.DGO", + "DGO/HAVENS.DGO", + "DGO/HAVENW.DGO", + "DGO/HAVJUNGS.DGO", + "DGO/HAVJUNGW.DGO", + "DGO/HAVNFOOT.DGO", + "DGO/HAVNTBOX.DGO", + "DGO/HAVSEWS.DGO", + "DGO/HAVSEWW.DGO", + "DGO/HAVTFOOT.DGO", + "DGO/HAVTOURS.DGO", + "DGO/HAVTOURW.DGO", + "DGO/HAVTT.DGO", + "DGO/HAVTTBOX.DGO", + "DGO/HJNGFOOT.DGO", + "DGO/HJX.DGO", + "DGO/HJY.DGO", + "DGO/HSX.DGO", + "DGO/HSY.DGO", + "DGO/HVA.DGO", + "DGO/HVB.DGO", + "DGO/HVC.DGO", + "DGO/HVD.DGO", + "DGO/HVE.DGO", + "DGO/HVJGTBOX.DGO", + "DGO/HVJGTT.DGO", + "DGO/HVSWFOOT.DGO", + "DGO/HVSWTBOX.DGO", + "DGO/HVSWTT.DGO", + "DGO/HVTRTT.DGO", + "DGO/HVX.DGO", + "DGO/HVY.DGO", + "DGO/IBX.DGO", + "DGO/IBY.DGO", + "DGO/ICA.DGO", + "DGO/ICB.DGO", + "DGO/ICBGTT.DGO", + "DGO/ICC.DGO", + "DGO/ICD.DGO", + "DGO/ICEBERGS.DGO", + "DGO/ICEBERGW.DGO", + "DGO/ICEBFOOT.DGO", + "DGO/ICEBTBOX.DGO", + "DGO/ICEFOOT.DGO", + "DGO/ICEPASSS.DGO", + "DGO/ICEPASSW.DGO", + "DGO/ICEPFOOT.DGO", + "DGO/ICEPTBOX.DGO", + "DGO/ICES.DGO", + "DGO/ICETBOX.DGO", + "DGO/ICETFOOT.DGO", + "DGO/ICETOURS.DGO", + "DGO/ICETOURW.DGO", + "DGO/ICETRN.DGO", + "DGO/ICETT.DGO", + "DGO/ICETTBOX.DGO", + "DGO/ICEW.DGO", + "DGO/ICPSTT.DGO", + "DGO/ICTRTT.DGO", + "DGO/ICX.DGO", + "DGO/ICY.DGO", + "DGO/IPX.DGO", + "DGO/IPY.DGO", + "DGO/JAKCRED.DGO", + "DGO/JAKLEV.DGO", + "DGO/JAKVL.DGO", + "DGO/JGA.DGO", + "DGO/JGB.DGO", + "DGO/JGC.DGO", + "DGO/JGD.DGO", + "DGO/JGE.DGO", + "DGO/JGF.DGO", + "DGO/JGG.DGO", + "DGO/JGX.DGO", + "DGO/JGY.DGO", + "DGO/JKALEV.DGO", + "DGO/JKBLEV.DGO", + "DGO/JKCLEV.DGO", + "DGO/JUNGFOOT.DGO", + "DGO/JUNGLES.DGO", + "DGO/JUNGLETT.DGO", + "DGO/JUNGLEW.DGO", + "DGO/JUNGTBOX.DGO", + "DGO/JUNGTRN.DGO", + "DGO/KAELEV.DGO", + "DGO/KCR.DGO", + "DGO/KCROSART.DGO", + "DGO/KCROSCTF.DGO", + "DGO/KCROSSS.DGO", + "DGO/KCRSCLCT.DGO", + "DGO/KCRSPLOW.DGO", + "DGO/KCRX.DGO", + "DGO/KEICRED.DGO", + "DGO/KIELEV.DGO", + "DGO/KIEVL.DGO", + "DGO/KLECRED.DGO", + "DGO/KLELEV.DGO", + "DGO/KLEVL.DGO", + "DGO/KLEVL2.DGO", + "DGO/KRA.DGO", + "DGO/KRASFOOT.DGO", + "DGO/KRASS.DGO", + "DGO/KRASTBOX.DGO", + "DGO/KRASTRN.DGO", + "DGO/KRASTT.DGO", + "DGO/KRASW.DGO", + "DGO/KRATFOOT.DGO", + "DGO/KRATOURS.DGO", + "DGO/KRATOURW.DGO", + "DGO/KRATTBOX.DGO", + "DGO/KRB.DGO", + "DGO/KRC.DGO", + "DGO/KRTRTT.DGO", + "DGO/KRX.DGO", + "DGO/KRY.DGO", + "DGO/LEOPL.DGO", + "DGO/MENU2.DGO", + "DGO/MENUMAP.DGO", + "DGO/MONGL.DGO", + "DGO/OSMLEV.DGO", + "DGO/PANTL.DGO", + "DGO/PEAKFOOT.DGO", + "DGO/PEAKS.DGO", + "DGO/PEAKTBOX.DGO", + "DGO/PEAKTT.DGO", + "DGO/PEAKW.DGO", + "DGO/PECCRED.DGO", + "DGO/PECLEV.DGO", + "DGO/PECVL.DGO", + "DGO/PKA.DGO", + "DGO/PKB.DGO", + "DGO/PKC.DGO", + "DGO/PKD.DGO", + "DGO/PKE.DGO", + "DGO/PKX.DGO", + "DGO/POSSL.DGO", + "DGO/RACEWEAP.DGO", + "DGO/RATLEV.DGO", + "DGO/RAYCRED.DGO", + "DGO/RAYLEV.DGO", + "DGO/RAYVL.DGO", + "DGO/RAYVL2.DGO", + "DGO/RAZCRED.DGO", + "DGO/RAZLEV.DGO", + "DGO/RAZVL.DGO", + "DGO/RTH.DGO", + "DGO/RUSTYH.DGO", + "DGO/S2A.DGO", + "DGO/S3A.DGO", + "DGO/SBWLCTF.DGO", + "DGO/SEWERS.DGO", + "DGO/SEWERTT.DGO", + "DGO/SEWERW.DGO", + "DGO/SEWFOOT.DGO", + "DGO/SEWTBOX.DGO", + "DGO/SIGCRED.DGO", + "DGO/SIGLEV.DGO", + "DGO/SIGVL.DGO", + "DGO/SIGVL2.DGO", + "DGO/SIGVL3.DGO", + "DGO/SNAKL.DGO", + "DGO/SNO.DGO", + "DGO/SNOBART.DGO", + "DGO/SNOBOWLS.DGO", + "DGO/SNOWFOOT.DGO", + "DGO/SNOWS.DGO", + "DGO/SNOWTBOX.DGO", + "DGO/SNOWTRN2.DGO", + "DGO/SNOWTT.DGO", + "DGO/SNOX.DGO", + "DGO/SNW.DGO", + "DGO/SNWX.DGO", + "DGO/SPA.DGO", + "DGO/SPARFOOT.DGO", + "DGO/SPARGUSS.DGO", + "DGO/SPARGUSW.DGO", + "DGO/SPARTEMS.DGO", + "DGO/SPARTEMW.DGO", + "DGO/SPARTT.DGO", + "DGO/SPATFOOT.DGO", + "DGO/SPATOURS.DGO", + "DGO/SPATOURW.DGO", + "DGO/SPATTBOX.DGO", + "DGO/SPB.DGO", + "DGO/SPC.DGO", + "DGO/SPD.DGO", + "DGO/SPE.DGO", + "DGO/SPRGSTBX.DGO", + "DGO/SPTMFOOT.DGO", + "DGO/SPTMTBOX.DGO", + "DGO/SPTMTT.DGO", + "DGO/SPTRTT.DGO", + "DGO/SPX.DGO", + "DGO/SPY.DGO", + "DGO/STX.DGO", + "DGO/STY.DGO", + "DGO/SWA.DGO", + "DGO/SWB.DGO", + "DGO/SWC.DGO", + "DGO/SWD.DGO", + "DGO/SWE.DGO", + "DGO/SWF.DGO", + "DGO/SWX.DGO", + "DGO/TARLEV.DGO", + "DGO/TEMPFOOT.DGO", + "DGO/TEMPLES.DGO", + "DGO/TEMPLETT.DGO", + "DGO/TEMPLEW.DGO", + "DGO/TEMPTBOX.DGO", + "DGO/THACRED.DGO", + "DGO/THALEV.DGO", + "DGO/THAVL.DGO", + "DGO/THAVL2.DGO", + "DGO/THAVL3.DGO", + "DGO/THBCRED.DGO", + "DGO/THBLEV.DGO", + "DGO/THBVL.DGO", + "DGO/THBVL2.DGO", + "DGO/THBVL3.DGO", + "DGO/THCCRED.DGO", + "DGO/THCLEV.DGO", + "DGO/THCVL.DGO", + "DGO/THCVL2.DGO", + "DGO/THCVL3.DGO", + "DGO/TIGEL.DGO", + "DGO/TOADL.DGO", + "DGO/TORCRED.DGO", + "DGO/TORLEV.DGO", + "DGO/TORVL.DGO", + "DGO/TORVL2.DGO", + "DGO/TORVL3.DGO", + "DGO/TPA.DGO", + "DGO/TPB.DGO", + "DGO/TPC.DGO", + "DGO/TPD.DGO", + "DGO/TPE.DGO", + "DGO/TPX.DGO", + "DGO/TPY.DGO", + "DGO/TURTL.DGO", + "DGO/UR8CRED.DGO", + "DGO/UR8LEV.DGO", + "DGO/UR8VL.DGO", + "DGO/UR8VL2.DGO", + "DGO/UR8VL3.DGO", + "DGO/WOLFL.DGO", + "DGO/WOMBL.DGO", + "DGO/XIMLEV.DGO" + ], + "skip_compile_files": [ + "types-h", // weird array of types. + // "hfrag-h", // weird duplicate type + // "joint", + // "subdivide", + "shadow-cpu-h" + // "foreground", + // "tie-methods", + // "scene-actor" // top level lambda that defines a type + ], + "skip_compile_functions": [ + // cache stuff + "invalidate-cache-line", + // dma + "dma-buffer-add-vu-function", + // math + "logf", + "log2f", + "cube-root", + "lerp-scale", + "rand-vu-init", + "rand-vu", + "rand-vu-nostep", + // connect + "(method 0 engine)", + "(method 0 engine-pers)", + // sky (multiple definition) + "(method 3 sky-vertex)", + // timer + "(method 9 clock)" + ], + "skip_compile_states": {} +} \ No newline at end of file diff --git a/test/offline/framework/execution.cpp b/test/offline/framework/execution.cpp index b95c19b565..ec1cbf6c56 100644 --- a/test/offline/framework/execution.cpp +++ b/test/offline/framework/execution.cpp @@ -126,10 +126,11 @@ OfflineTestCompileResult compile(OfflineTestDecompiler& dc, compiler.run_front_end_on_file({"goal_src", "jak3", "engine", "data", "textures.gc"}); compiler.run_front_end_on_file({"goal_src", "jak3", "engine", "data", "part-groups.gc"}); } else if (config.game_name == "jakx") { - compiler.run_front_end_on_file({"goal_src", "jakx", "engine", "data", "art-elts.gc"}); + // TODO JAKX - not added yet + /*compiler.run_front_end_on_file({"goal_src", "jakx", "engine", "data", "art-elts.gc"}); compiler.run_front_end_on_file({"goal_src", "jakx", "engine", "data", "joint-nodes.gc"}); compiler.run_front_end_on_file({"goal_src", "jakx", "engine", "data", "textures.gc"}); - compiler.run_front_end_on_file({"goal_src", "jakx", "engine", "data", "part-groups.gc"}); + compiler.run_front_end_on_file({"goal_src", "jakx", "engine", "data", "part-groups.gc"});*/ } int total_lines = 0;