From 7ebbe812b18f1374e92c3514dd598aa2b27e4d1b Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Tue, 28 Sep 2021 21:17:38 -0400 Subject: [PATCH] Cleanup sparticle, add ref tests, name a few methods (#863) * temp * add reference tests --- decompiler/config/all-types.gc | 16 +- .../config/jak1_ntsc_black_label/hacks.jsonc | 4 + .../jak1_ntsc_black_label/var_names.jsonc | 4 + goal_src/engine/game/game-info-h.gc | 10 +- goal_src/engine/load/loader-h.gc | 7 +- goal_src/engine/load/loader.gc | 73 +- goal_src/engine/sparticle/sparticle.gc | 86 +- .../decompiler/reference/decompiler-macros.gc | 18 + .../reference/engine/game/game-info-h_REF.gc | 10 +- .../gfx/sparticle/sparticle-launcher-h_REF.gc | 1 + .../gfx/sparticle/sparticle-launcher_REF.gc | 1598 +++++++++++++++++ .../engine/gfx/sparticle/sparticle_REF.gc | 869 +++++++++ .../reference/engine/load/loader-h_REF.gc | 4 +- .../reference/engine/load/loader_REF.gc | 27 +- test/offline/offline_test_main.cpp | 8 +- 15 files changed, 2598 insertions(+), 137 deletions(-) create mode 100644 test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher_REF.gc create mode 100644 test/decompiler/reference/engine/gfx/sparticle/sparticle_REF.gc diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 2eaa0ad378..234a95e3c4 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -4604,8 +4604,8 @@ (:methods (new (symbol type int basic) _type_ 0) ;; these methods dont exist - (dummy-9 (_type_ string symbol kheap int) art-group 9) - (dummy-10 (_type_ art-group) art-group 10) + (load-to-heap-by-name (_type_ string symbol kheap int) art-group 9) + (set-loaded-art (_type_ art-group) art-group 10) ) ) @@ -4616,8 +4616,6 @@ :flag-assert #xb00000010 (:methods (new (symbol type int basic) _type_ 0) - (dummy-9 (_type_ string symbol kheap int) art-group 9) - (dummy-10 (_type_ art-group) art-group 10) ) ) @@ -9065,11 +9063,11 @@ (want-display-level (_type_ symbol symbol) int 12) (want-vis (_type_ symbol) int 13) (want-force-vis (_type_ symbol symbol) int 14) - (dummy-15 (_type_ pair) none 15) - (dummy-16 (_type_ float) int 16) - (dummy-17 (_type_ pair) int 17) - (dummy-18 (_type_) int 18) - (dummy-19 (_type_) int 19) + (execute-command (_type_ pair) none 15) + (execute-commands-up-to (_type_ float) int 16) + (backup-load-state-and-set-cmds (_type_ pair) int 17) + (restore-load-state-and-cleanup (_type_) int 18) + (restore-load-state (_type_) int 19) (dummy-20 () none 20) ) ) diff --git a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc index a0005cf15e..ea32a33117 100644 --- a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc @@ -215,6 +215,10 @@ "memcpy", "sp-process-block-3d", "sp-process-block-2d", + "sp-launch-particles-var", + "particle-adgif", + "sp-init-fields!", + // mood BUG "update-mood-lava", // BUG: diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index b8f745d98f..5135fecc0f 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -3531,5 +3531,9 @@ } }, + "(method 9 load-dir-art-group)":{ + "args":["obj", "art-name", "do-reload", "heap", "version"] + }, + "aaaaaaaaaaaaaaaaaaaaaaa": {} } diff --git a/goal_src/engine/game/game-info-h.gc b/goal_src/engine/game/game-info-h.gc index 1340cf1601..afa19a2022 100644 --- a/goal_src/engine/game/game-info-h.gc +++ b/goal_src/engine/game/game-info-h.gc @@ -64,11 +64,11 @@ (want-display-level (_type_ symbol symbol) int 12) (want-vis (_type_ symbol) int 13) (want-force-vis (_type_ symbol symbol) int 14) - (dummy-15 (_type_ pair) none 15) - (dummy-16 (_type_ float) int 16) - (dummy-17 (_type_ pair) int 17) - (dummy-18 (_type_) int 18) - (dummy-19 (_type_) int 19) + (execute-command (_type_ pair) none 15) + (execute-commands-up-to (_type_ float) int 16) + (backup-load-state-and-set-cmds (_type_ pair) int 17) + (restore-load-state-and-cleanup (_type_) int 18) + (restore-load-state (_type_) int 19) (dummy-20 () none 20) ) ) diff --git a/goal_src/engine/load/loader-h.gc b/goal_src/engine/load/loader-h.gc index aa83901fc5..b12dc4090d 100644 --- a/goal_src/engine/load/loader-h.gc +++ b/goal_src/engine/load/loader-h.gc @@ -15,6 +15,7 @@ (defconstant SPOOL_PRIORITY_HIGH -10.0) +;; A load-dir is a collection of references to loaded art. ;; This type didn't have an inspect method, so these field names are made up. (declare-type art-group basic) (deftype load-dir (basic) @@ -25,8 +26,8 @@ :flag-assert #xb00000010 (:methods (new (symbol type int basic) _type_ 0) - (dummy-9 (_type_ string symbol kheap int) art-group 9) - (dummy-10 (_type_ art-group) art-group 10) + (load-to-heap-by-name (_type_ string symbol kheap int) art-group 9) + (set-loaded-art (_type_ art-group) art-group 10) ) ) @@ -37,8 +38,6 @@ :flag-assert #xb00000010 (:methods (new (symbol type int basic) _type_ 0) - (dummy-9 (_type_ string symbol kheap int) art-group 9) - (dummy-10 (_type_ art-group) art-group 10) ) ) diff --git a/goal_src/engine/load/loader.gc b/goal_src/engine/load/loader.gc index f812361ebe..8761ca4336 100644 --- a/goal_src/engine/load/loader.gc +++ b/goal_src/engine/load/loader.gc @@ -57,36 +57,42 @@ (the-as load-dir #f) ) -(defmethod dummy-9 load-dir-art-group ((obj load-dir-art-group) (arg0 string) (arg1 symbol) (arg2 kheap) (arg3 int)) - "This is not understood." - +(defmethod load-to-heap-by-name load-dir-art-group ((obj load-dir-art-group) (art-name string) (do-reload symbol) (heap kheap) (version int)) + "Load the art with the given name to the heap and return the art. + Won't load a thing if it's already loaded, unless you set do-reload. + This is intended for debug only." + + ;; see if we already have it. (let ((s5-0 (-> obj string-array))) - (dotimes (s3-0 (-> s5-0 length)) - (when (string= arg0 (-> s5-0 s3-0)) - (when arg1 - (let ((v1-4 (art-group-load-check arg0 arg2 arg3))) - (if v1-4 - (set! (-> obj art-group-array s3-0) v1-4) + (dotimes (s3-0 (-> s5-0 length)) + (when (string= art-name (-> s5-0 s3-0)) + (when do-reload + ;; we have it, reload it if requested + (let ((v1-4 (art-group-load-check art-name heap version))) + (if v1-4 + (set! (-> obj art-group-array s3-0) v1-4) + ) + ) + ) + (return (-> obj art-group-array s3-0)) ) - ) ) - (return (-> obj art-group-array s3-0)) - ) + + ;; nope, we don't have it,add it to the list. + (let ((v0-2 (art-group-load-check art-name heap version))) + (when v0-2 + (set! (-> s5-0 (-> s5-0 length)) art-name) + (set! (-> obj art-group-array (-> s5-0 length)) v0-2) + (+! (-> s5-0 length) 1) + (+! (-> obj art-group-array length) 1) + ) + v0-2 + ) ) - (let ((v0-2 (art-group-load-check arg0 arg2 arg3))) - (when v0-2 - (set! (-> s5-0 (-> s5-0 length)) arg0) - (set! (-> obj art-group-array (-> s5-0 length)) v0-2) - (1+! (-> s5-0 length)) - (1+! (-> obj art-group-array length)) - ) - v0-2 - ) - ) ) -(defmethod dummy-10 load-dir-art-group ((obj load-dir-art-group) (arg0 art-group)) - "This is not understood." +(defmethod set-loaded-art load-dir-art-group ((obj load-dir-art-group) (arg0 art-group)) + "Add some already loaded art to the load-dir." (let ((s4-0 (-> obj string-array))) (dotimes (s3-0 (-> s4-0 length)) @@ -160,6 +166,7 @@ (the-as art-group #f) ) ((not (file-info-correct-version? (-> s3-1 info) (file-kind art-group) arg2)) + ;; ^ prints a detailed error if it fails. ;;(format 0 "ERROR: art-group ~A is not the correct version.~%" arg0) (the-as art-group #f) ) @@ -541,7 +548,7 @@ ) (defmethod update external-art-control ((obj external-art-control) (debug-print symbol)) - "Update this external-art-control. This validates the spool buffers, sorts the spools, and does some other things. + "Update this external-art-control. This validates the spool buffers, sorts the spools, advances str-play-queue, and does some other things. If debug-print, also prints some text to the display console" (if (nonzero? (-> obj reserve-buffer-count)) @@ -842,13 +849,15 @@ (sv-56 0) (spool-sound (new-sound-id)) ) - (dummy-17 *load-state* (-> arg0 command-list)) + (backup-load-state-and-set-cmds *load-state* (-> arg0 command-list)) (set-setting! *setting-control* self 'spooling (the-as symbol (process->ppointer self)) 0.0 0) (logior! (-> self skel status) #x7) (kill-current-level-hint '() '() 'die) (level-hint-surpress!) (copy-settings-from-target! *setting-control*) + ;; the spool lock is active (or we're not in game mode for some reason?) + ;; we can't nest or do multiple spooled joint animations. (when (or (handle->process (-> *art-control* spool-lock)) (!= *master-mode* 'game) ) @@ -889,9 +898,14 @@ ) ) ) + + ;; grab the lock (set! (-> *art-control* spool-lock) (process->handle self)) (set! sv-48 (the-as int (-> *display* base-frame-counter))) + + ;; iterate through parts (this loop suspends, so it lasts the whole animation) (while (< spool-part (-> arg0 parts)) + ;; run the loader (spool-push *art-control* (-> arg0 name) spool-part self -20.0) (update *art-control* #f) (spool-push *art-control* (-> arg0 name) spool-part self -20.0) @@ -961,7 +975,10 @@ (logclear! (-> self skel status) #x4) ) ) - (dummy-16 *load-state* (ja-aframe-num 0)) + + ;; execute sequence commands for loading/spawning/etc. + (execute-commands-up-to *load-state* (ja-aframe-num 0)) + (cond ((and (< sv-32 sv-72) (= (current-str-id) spool-sound)) (+! sv-56 (the-as int (- (-> *display* base-frame-counter) (-> *display* old-base-frame-counter)))) @@ -1021,7 +1038,7 @@ (defbehavior ja-abort-spooled-anim process-drawable ((arg0 spool-anim) (arg1 art-joint-anim) (arg2 int)) "Abort a spooled animation." - (dummy-18 *load-state*) + (restore-load-state-and-cleanup *load-state*) (str-play-stop (-> arg0 name)) (set! (-> *art-control* active-stream) #f) (logclear! (-> self skel status) #x6) ;; #x4 and #x2 diff --git a/goal_src/engine/sparticle/sparticle.gc b/goal_src/engine/sparticle/sparticle.gc index 69675d6e15..3df64fb5c1 100644 --- a/goal_src/engine/sparticle/sparticle.gc +++ b/goal_src/engine/sparticle/sparticle.gc @@ -419,55 +419,6 @@ ;; TODO memcpy (unused) -; (defun sp-process-block ((arg0 sparticle-system) (arg1 int) (arg2 sprite-array-2d) (arg3 int)) -; "update the given block of particles" -; (local-vars -; (sv-16 int) -; (sv-32 int) -; (sv-80 int) -; (sv-96 int) -; ) -; (let ((s3-0 16) -; (s2-0 (* 144 arg3)) -; (s5-0 (* 48 arg3)) -; ) -; (set! sv-32 (* 80 arg3)) -; (let ((s1-0 (+ s3-0 s2-0))) -; (set! sv-16 (+ s1-0 s5-0)) -; (sp-copy-to-spr s3-0 (the-as pointer (-> arg0 cpuinfo-table arg1)) s2-0) -; (sp-copy-to-spr s1-0 (&+ (-> arg0 vecdata-table) (* 48 arg1)) s5-0) -; (let ((t9-2 sp-copy-to-spr) -; (a1-7 (-> arg0 adgifdata-table arg1)) -; ) -; (t9-2 sv-16 (the-as pointer a1-7) sv-32) -; ) -; (set! sv-80 (+ (the int (scratchpad-start)) s3-0)) ;; spad -; (set! sv-96 (+ (the int (scratchpad-start)) s1-0)) ;; spad -; (cond -; ((-> arg0 is-3d) -; (sp-process-block-3d arg0 sv-80 sv-96 arg1 arg3 (paused?)) -; ) -; (else -; (sp-process-block-2d arg0 sv-80 sv-96 arg1 arg3 (paused?)) -; ) -; ) -; (sp-copy-from-spr s3-0 (the-as pointer (-> arg0 cpuinfo-table arg1)) s2-0) -; (sp-copy-from-spr s1-0 (&+ (-> arg0 vecdata-table) (* 48 arg1)) s5-0) -; ) -; ) - -; ; (dotimes (i arg3) -; ; (let ((cpuinfo (-> arg0 cpuinfo-table (+ i arg1)))) -; ; (when (and cpuinfo (-> cpuinfo valid)) -; ; (inspect cpuinfo) -; ; (inspect (-> cpuinfo sprite r-g-b-a)) -; ; ) -; ; ) -; ; ) -; 0 -; (none) -; ) - (defun sp-process-block ((arg0 sparticle-system) (arg1 int) (arg2 sprite-array-2d) (arg3 int)) "update the given block of particles" (local-vars @@ -483,17 +434,19 @@ (set! sv-32 (* 80 arg3)) (let ((s1-0 (+ s3-0 s2-0))) (set! sv-16 (+ s1-0 s5-0)) - ; (sp-copy-to-spr s3-0 (the-as pointer (-> arg0 cpuinfo-table arg1)) s2-0) - ; (sp-copy-to-spr s1-0 (&+ (-> arg0 vecdata-table) (* 48 arg1)) s5-0) - ; (let ((t9-2 sp-copy-to-spr) - ; (a1-7 (-> arg0 adgifdata-table arg1)) - ; ) - ; (t9-2 sv-16 (the-as pointer a1-7) sv-32) - ; ) - (set! sv-80 (the-as int (-> arg0 cpuinfo-table arg1))) - (set! sv-96 (the-as int (&+ (-> arg0 vecdata-table) (* 48 arg1)))) - ; (set! sv-80 (+ (the int (scratchpad-start)) s3-0)) ;; spad - ; (set! sv-96 (+ (the int (scratchpad-start)) s1-0)) ;; spad + (sp-copy-to-spr s3-0 (the-as pointer (-> arg0 cpuinfo-table arg1)) s2-0) + (sp-copy-to-spr s1-0 (&+ (-> arg0 vecdata-table) (* 48 arg1)) s5-0) + (let ((t9-2 sp-copy-to-spr) + (a1-7 (-> arg0 adgifdata-table arg1)) + ) + (t9-2 sv-16 (the-as pointer a1-7) sv-32) + ) + + ;; alternate to run without doing scratchpad (will change behavior of kill, but at least works for hud) + ; (set! sv-80 (the-as int (-> arg0 cpuinfo-table arg1))) + ; (set! sv-96 (the-as int (&+ (-> arg0 vecdata-table) (* 48 arg1)))) + (set! sv-80 (+ (the int (scratchpad-start)) s3-0)) ;; spad + (set! sv-96 (+ (the int (scratchpad-start)) s1-0)) ;; spad (cond ((-> arg0 is-3d) (sp-process-block-3d arg0 sv-80 sv-96 arg1 arg3 (paused?)) @@ -502,19 +455,10 @@ (sp-process-block-2d arg0 sv-80 sv-96 arg1 arg3 (paused?)) ) ) - ; (sp-copy-from-spr s3-0 (the-as pointer (-> arg0 cpuinfo-table arg1)) s2-0) - ; (sp-copy-from-spr s1-0 (&+ (-> arg0 vecdata-table) (* 48 arg1)) s5-0) + (sp-copy-from-spr s3-0 (the-as pointer (-> arg0 cpuinfo-table arg1)) s2-0) + (sp-copy-from-spr s1-0 (&+ (-> arg0 vecdata-table) (* 48 arg1)) s5-0) ) ) - - ; (dotimes (i arg3) - ; (let ((cpuinfo (-> arg0 cpuinfo-table (+ i arg1)))) - ; (when (and cpuinfo (-> cpuinfo valid)) - ; (inspect cpuinfo) - ; (inspect (-> cpuinfo sprite r-g-b-a)) - ; ) - ; ) - ; ) 0 (none) ) diff --git a/test/decompiler/reference/decompiler-macros.gc b/test/decompiler/reference/decompiler-macros.gc index c8c7b337a4..3594fa4d71 100644 --- a/test/decompiler/reference/decompiler-macros.gc +++ b/test/decompiler/reference/decompiler-macros.gc @@ -511,6 +511,24 @@ `(set! ,result (sext32 (sar (logand #xffffffff (the-as int ,in)) ,sa))) ) +(defmacro .movn (result value check original) + `(if (!= ,check 0) + (set! ,result (the-as int ,value)) + (set! ,result (the-as int ,original)) + ) + ) + +(defmacro .movz (result value check original) + `(if (= ,check 0) + (set! ,result (the-as int ,value)) + (set! ,result (the-as int ,original)) + ) + ) + +(defmacro .mfc0 (&rest stuff) + `(empty) + ) + (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) diff --git a/test/decompiler/reference/engine/game/game-info-h_REF.gc b/test/decompiler/reference/engine/game/game-info-h_REF.gc index 5b5b94d7af..f5d81cc152 100644 --- a/test/decompiler/reference/engine/game/game-info-h_REF.gc +++ b/test/decompiler/reference/engine/game/game-info-h_REF.gc @@ -89,11 +89,11 @@ (want-display-level (_type_ symbol symbol) int 12) (want-vis (_type_ symbol) int 13) (want-force-vis (_type_ symbol symbol) int 14) - (dummy-15 (_type_ pair) none 15) - (dummy-16 (_type_ float) int 16) - (dummy-17 (_type_ pair) int 17) - (dummy-18 (_type_) int 18) - (dummy-19 (_type_) int 19) + (execute-command (_type_ pair) none 15) + (execute-commands-up-to (_type_ float) int 16) + (backup-load-state-and-set-cmds (_type_ pair) int 17) + (restore-load-state-and-cleanup (_type_) int 18) + (restore-load-state (_type_) int 19) (dummy-20 () none 20) ) ) diff --git a/test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher-h_REF.gc b/test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher-h_REF.gc index cda67d733e..d699988cab 100644 --- a/test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher-h_REF.gc +++ b/test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher-h_REF.gc @@ -53,6 +53,7 @@ ) ;; definition for method 3 of type sparticle-launcher +;; INFO: this function exists in multiple non-identical object files (defmethod inspect sparticle-launcher ((obj sparticle-launcher)) (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tbirthaccum: ~f~%" (-> obj birthaccum)) diff --git a/test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher_REF.gc b/test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher_REF.gc new file mode 100644 index 0000000000..c5c383b9d4 --- /dev/null +++ b/test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher_REF.gc @@ -0,0 +1,1598 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *particle-300hz-timer*, type int +(define *particle-300hz-timer* 0) + +;; definition of type sparticle-birthinfo +(deftype sparticle-birthinfo (structure) + ((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) + (sound basic :offset-assert 24) + (dataf float 1 :offset 0) + (data uint32 1 :offset 0) + ) + :method-count-assert 9 + :size-assert #x1c + :flag-assert #x90000001c + ) + +;; definition for method 3 of type sparticle-birthinfo +(defmethod inspect sparticle-birthinfo ((obj sparticle-birthinfo)) + (format #t "[~8x] ~A~%" obj 'sparticle-birthinfo) + (format #t "~Tsprite: ~D~%" (-> obj sprite)) + (format #t "~Tanim: ~D~%" (-> obj anim)) + (format #t "~Tanim-speed: ~f~%" (-> obj anim-speed)) + (format #t "~Tbirth-func: ~A~%" (-> obj birth-func)) + (format #t "~Tjoint-ppoint: ~D~%" (-> obj joint-ppoint)) + (format #t "~Tnum-to-birth: ~f~%" (-> obj num-to-birth)) + (format #t "~Tsound: ~A~%" (-> obj sound)) + (format #t "~Tdataf[1] @ #x~X~%" (&-> obj sprite)) + (format #t "~Tdata[1] @ #x~X~%" (&-> obj sprite)) + obj + ) + +;; definition for method 3 of type sparticle-launcher +;; INFO: this function exists in multiple non-identical object files +;; INFO: Return type mismatch int vs sparticle-launcher. +(defmethod inspect sparticle-launcher ((obj sparticle-launcher)) + (format #t "~X: sparticle-launcher~%" obj) + (let ((s5-0 0)) + (while (!= (-> obj init-specs s5-0 field) (sp-field-id spt-end)) + (let* ((v1-1 (-> obj init-specs s5-0)) + (t9-1 format) + (a0-3 #t) + (a1-1 "~T~S : ~F / #x~X / ~D~%") + (a2-1 (-> v1-1 field)) + ) + (t9-1 a0-3 a1-1 (cond + ((= a2-1 (sp-field-id spt-end)) + "spt-end" + ) + ((= a2-1 (sp-field-id spt-scalevel)) + "spt-scalevel" + ) + ((= a2-1 (sp-field-id spt-scale)) + "spt-scale" + ) + ((= a2-1 (sp-field-id launch-fields-end)) + "launch-fields-end" + ) + ((= a2-1 (sp-field-id spt-rotate-y)) + "spt-rotate-y" + ) + ((= a2-1 (sp-field-id spt-conerot-radius)) + "spt-conerot-radius" + ) + ((= a2-1 (sp-field-id spt-conerot-w)) + "spt-conerot-w" + ) + ((= a2-1 (sp-field-id spt-conerot-z)) + "spt-conerot-z" + ) + ((= a2-1 (sp-field-id spt-conerot-y)) + "spt-conerot-y" + ) + ((= a2-1 (sp-field-id spt-conerot-x)) + "spt-conerot-x" + ) + ((= a2-1 (sp-field-id spt-launchrot-w)) + "spt-launchrot-w" + ) + ((= a2-1 (sp-field-id spt-launchrot-z)) + "spt-launchrot-z" + ) + ((= a2-1 (sp-field-id spt-launchrot-y)) + "spt-launchrot-y" + ) + ((= a2-1 (sp-field-id spt-launchrot-x)) + "spt-launchrot-x" + ) + ((= a2-1 (sp-field-id launch-fields-start)) + "launch-fields-start" + ) + ((= a2-1 (sp-field-id cpu-fields-end)) + "cpu-fields-end" + ) + ((= a2-1 (sp-field-id spt-next-launcher)) + "spt-next-launcher" + ) + ((= a2-1 (sp-field-id spt-next-time)) + "spt-next-time" + ) + ((= a2-1 (sp-field-id spt-func)) + "spt-func" + ) + ((= a2-1 (sp-field-id spt-userdata)) + "spt-userdata" + ) + ((= a2-1 (sp-field-id spt-flags)) + "spt-flags" + ) + ((= a2-1 (sp-field-id spt-timer)) + "spt-timer" + ) + ((= a2-1 (sp-field-id spt-friction)) + "spt-friction" + ) + ((= a2-1 (sp-field-id spt-quad-w)) + "spt-quad-w" + ) + ((= a2-1 (sp-field-id spt-quat-z)) + "spt-quat-z" + ) + ((= a2-1 (sp-field-id spt-quat-y)) + "spt-quat-y" + ) + ((= a2-1 (sp-field-id spt-quat-x)) + "spt-quat-x" + ) + ((= a2-1 (sp-field-id spt-dummy)) + "spt-dummy" + ) + ((= a2-1 (sp-field-id spt-accel-z)) + "spt-accel-z" + ) + ((= a2-1 (sp-field-id spt-accel-y)) + "spt-accel-y" + ) + ((= a2-1 (sp-field-id spt-accel-x)) + "spt-accel-x" + ) + ((= a2-1 (sp-field-id spt-fade-a)) + "spt-fade-a" + ) + ((= a2-1 (sp-field-id spt-fade-b)) + "spt-fade-b" + ) + ((= a2-1 (sp-field-id spt-fade-g)) + "spt-fade-g" + ) + ((= a2-1 (sp-field-id spt-fade-r)) + "spt-fade-r" + ) + ((= a2-1 (sp-field-id spt-scalevel-y)) + "spt-scalevel-y" + ) + ((= a2-1 (sp-field-id spt-rotvel-z)) + "spt-rotvel-z" + ) + ((= a2-1 (sp-field-id spt-rotvel-y)) + "spt-rotvel-y" + ) + ((= a2-1 (sp-field-id spt-rotvel-x)) + "spt-rotvel-x" + ) + ((= a2-1 (sp-field-id spt-scalevel-x)) + "spt-scalevel-x" + ) + ((= a2-1 (sp-field-id spt-vel-z)) + "spt-vel-z" + ) + ((= a2-1 (sp-field-id spt-vel-y)) + "spt-vel-y" + ) + ((= a2-1 (sp-field-id spt-vel-x)) + "spt-vel-x" + ) + ((= a2-1 (sp-field-id spt-omega)) + "spt-omega" + ) + ((= a2-1 (sp-field-id cpu-fields-start)) + "cpu-fields-start" + ) + ((= a2-1 (sp-field-id sprite-fields-end)) + "sprite-fields-end" + ) + ((= a2-1 (sp-field-id spt-a)) + "spt-a" + ) + ((= a2-1 (sp-field-id spt-b)) + "spt-b" + ) + ((= a2-1 (sp-field-id spt-g)) + "spt-g" + ) + ((= a2-1 (sp-field-id spt-r)) + "spt-r" + ) + ((= a2-1 (sp-field-id spt-scale-y)) + "spt-scale-y" + ) + ((= a2-1 (sp-field-id spt-rot-z)) + "spt-rot-z" + ) + ((= a2-1 (sp-field-id spt-rot-y)) + "spt-rot-y" + ) + ((= a2-1 (sp-field-id spt-rot-x)) + "spt-rot-x" + ) + ((= a2-1 (sp-field-id spt-scale-x)) + "spt-scale-x" + ) + ((= a2-1 (sp-field-id spt-z)) + "spt-z" + ) + ((= a2-1 (sp-field-id spt-y)) + "spt-y" + ) + ((= a2-1 (sp-field-id spt-x)) + "spt-x" + ) + ((= a2-1 (sp-field-id sprite-fields-start)) + "sprite-fields-start" + ) + ((= a2-1 (sp-field-id misc-fields-end)) + "misc-fields-end" + ) + ((= a2-1 (sp-field-id spt-sound)) + "spt-sound" + ) + ((= a2-1 (sp-field-id spt-num)) + "spt-num" + ) + ((= a2-1 (sp-field-id spt-joint/refpoint)) + "spt-joint/refpoint" + ) + ((= a2-1 (sp-field-id spt-birth-func)) + "spt-birth-func" + ) + ((= a2-1 (sp-field-id spt-anim-speed)) + "spt-anim-speed" + ) + ((= a2-1 (sp-field-id spt-anim)) + "spt-anim" + ) + ((= a2-1 (sp-field-id spt-texture)) + "spt-texture" + ) + ((= a2-1 (sp-field-id misc-fields-start)) + "misc-fields-start" + ) + (else + "*unknown*" + ) + ) + (-> v1-1 initial-valuef) (-> v1-1 initial-valuef) (-> v1-1 initial-valuef) + ) + ) + (+! s5-0 1) + ) + ) + (the-as sparticle-launcher 0) + ) + +;; definition for symbol *part-id-table*, type (array sparticle-launcher) +(define + *part-id-table* + (the-as (array sparticle-launcher) + (new 'global 'boxed-array sparticle-launcher 3584) + ) + ) + +;; definition for symbol *part-group-id-table*, type (array sparticle-launch-group) +(define + *part-group-id-table* + (the-as (array sparticle-launch-group) + (new 'global 'boxed-array sparticle-launch-group 1024) + ) + ) + +;; definition for function lookup-part-group-by-name +;; INFO: Return type mismatch sparticle-launch-group vs basic. +(defun lookup-part-group-by-name ((arg0 string)) + (let* ((s5-0 *part-group-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 (the-as basic s2-0)) + ) + ) + ) + ) + (the-as sparticle-launch-group #f) + ) + +;; definition for function lookup-part-group-pointer-by-name +(defun lookup-part-group-pointer-by-name ((arg0 string)) + (let* ((s4-0 *part-group-id-table*) + (s3-0 (-> s4-0 length)) + ) + (dotimes (gp-0 s3-0) + (let ((v1-2 (-> s4-0 gp-0))) + (if (and (nonzero? v1-2) (string= arg0 (-> v1-2 name))) + (return (&+ (-> s4-0 data) (* gp-0 4))) + ) + ) + ) + ) + (the-as (pointer sparticle-launch-group) #f) + ) + +;; definition for function part-group-pointer? +(defun part-group-pointer? ((arg0 pointer)) + (let ((v1-0 *part-group-id-table*)) + (and + (>= (the-as int arg0) (the-as int (-> v1-0 data))) + (< (the-as int arg0) (the-as int (&-> v1-0 1024))) + ) + ) + ) + +;; definition for function unlink-part-group-by-heap +(defun unlink-part-group-by-heap ((arg0 kheap)) + (let* ((v1-0 *part-group-id-table*) + (a2-0 (-> v1-0 length)) + (a1-0 (-> arg0 base)) + (a0-1 (-> arg0 top-base)) + ) + (while (nonzero? a2-0) + (+! a2-0 -1) + (let ((a3-2 (-> v1-0 a2-0))) + (when + (and + (>= (the-as int a3-2) (the-as int a1-0)) + (< (the-as int a3-2) (the-as int a0-1)) + ) + (set! (-> v1-0 a2-0) (the-as sparticle-launch-group 0)) + 0 + ) + ) + ) + ) + 0 + ) + +;; definition for function sp-init-fields! +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition of type sp-queued-launch-particles +(deftype sp-queued-launch-particles (structure) + ((sp-system sparticle-system :offset-assert 0) + (sp-launcher sparticle-launcher :offset-assert 4) + (pos vector :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +;; definition for method 3 of type sp-queued-launch-particles +(defmethod inspect sp-queued-launch-particles ((obj sp-queued-launch-particles)) + (format #t "[~8x] ~A~%" obj 'sp-queued-launch-particles) + (format #t "~Tsp-system: ~A~%" (-> obj sp-system)) + (format #t "~Tsp-launcher: ~A~%" (-> obj sp-launcher)) + (format #t "~Tpos: #~%" (-> obj pos)) + obj + ) + +;; definition of type sp-launch-queue +(deftype sp-launch-queue (basic) + ((in-use int32 :offset-assert 4) + (queue sp-queued-launch-particles 32 :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x410 + :flag-assert #x900000410 + ) + +;; definition for method 3 of type sp-launch-queue +(defmethod inspect sp-launch-queue ((obj sp-launch-queue)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tin-use: ~D~%" (-> obj in-use)) + (format #t "~Tqueue[32] @ #x~X~%" (-> obj queue)) + obj + ) + +;; definition for symbol *sp-launcher-lock*, type symbol +(define *sp-launcher-lock* #f) + +;; definition for symbol *sp-launch-queue*, type sp-launch-queue +(define *sp-launch-queue* (new 'global 'sp-launch-queue)) + +;; definition for symbol *sp-launcher-enable*, type symbol +(define *sp-launcher-enable* #t) + +;; definition for function particle-setup-adgif +;; INFO: Return type mismatch int vs none. +(defun particle-setup-adgif ((arg0 adgif-shader) (arg1 texture-id)) + (let ((a1-1 (lookup-texture-by-id arg1))) + (set! (-> arg0 tex1) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> arg0 tex0 tfx) 0) + (if a1-1 + (adgif-shader<-texture! arg0 a1-1) + ) + ) + (set! (-> arg0 prims 1) (gs-reg64 tex0-1)) + (set! (-> arg0 prims 3) (gs-reg64 tex1-1)) + (set! (-> arg0 prims 5) (gs-reg64 miptbp1-1)) + (set! (-> arg0 clamp-reg) (gs-reg64 zbuf-1)) + (set! (-> arg0 prims 9) (gs-reg64 alpha-1)) + (set! (-> arg0 alpha) (new 'static 'gs-miptbp :tbp1 #x44)) + (set! (-> arg0 clamp) (new 'static 'gs-clamp :minu #x1c :minv #x101)) + 0 + (none) + ) + +;; definition of type particle-adgif-cache +(deftype particle-adgif-cache (basic) + ((used int32 :offset-assert 4) + (last uint16 :offset-assert 8) + (lastgif adgif-shader :offset-assert 12) + (tidhash uint16 80 :offset-assert 16) + (spadgif adgif-shader 80 :inline :offset-assert 176) + ) + :method-count-assert 9 + :size-assert #x19b0 + :flag-assert #x9000019b0 + ) + +;; definition for method 3 of type particle-adgif-cache +(defmethod inspect particle-adgif-cache ((obj particle-adgif-cache)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tused: ~D~%" (-> obj used)) + (format #t "~Tlast: ~D~%" (-> obj last)) + (format #t "~Tlastgif: #~%" (-> obj lastgif)) + (format #t "~Ttidhash[80] @ #x~X~%" (-> obj tidhash)) + (format #t "~Tspadgif[80] @ #x~X~%" (-> obj spadgif)) + obj + ) + +;; definition for symbol *particle-adgif-cache*, type particle-adgif-cache +(define *particle-adgif-cache* (new 'global 'particle-adgif-cache)) + +;; failed to figure out what this is: +(set! (-> *particle-adgif-cache* used) 0) + +;; definition for function particle-adgif +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function sp-queue-launch +;; Used lq/sq +(defun + sp-queue-launch + ((arg0 sparticle-system) (arg1 sparticle-launcher) (arg2 vector)) + (let ((v1-0 *sp-launch-queue*)) + (when (= (-> v1-0 in-use) 32) + (format + 0 + "ERROR: sp-launch-particles called during processing, and queue is full~%" + ) + (return 0) + ) + (let ((a3-5 (-> v1-0 queue (-> v1-0 in-use)))) + (set! (-> a3-5 sp-system) arg0) + (set! (-> a3-5 sp-launcher) arg1) + (set! (-> a3-5 pos quad) (-> arg2 quad)) + ) + (let ((v0-1 (+ (-> v1-0 in-use) 1))) + (set! (-> v1-0 in-use) v0-1) + v0-1 + ) + ) + ) + +;; definition for function sp-adjust-launch +;; INFO: Return type mismatch int vs none. +(defun + sp-adjust-launch + ((arg0 sparticle-launchinfo) + (arg1 sparticle-cpuinfo) + (arg2 (inline-array sp-field-init-spec)) + ) + (let ((s5-0 (new 'stack-no-clear 'sparticle-launchinfo))) + (let ((s2-0 (new 'stack-no-clear 'matrix)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (sp-init-fields! + (-> s5-0 launchrot) + arg2 + (sp-field-id launch-fields-start) + (sp-field-id launch-fields-end) + #t + ) + (matrix-rotate-xyz! s2-0 (-> s5-0 launchrot)) + (vector3s-matrix*! + (the-as vector3s (-> arg1 vel-sxvel)) + (the-as vector3s (-> arg1 vel-sxvel)) + s2-0 + ) + (matrix-rotate-xyz! s2-0 (-> s5-0 conerot)) + (vector3s-matrix*! + (the-as vector3s (-> arg1 vel-sxvel)) + (the-as vector3s (-> arg1 vel-sxvel)) + s2-0 + ) + (if (logtest? (sp-cpuinfo-flag launch-along-z) (-> arg1 flags)) + (set-vector! s3-0 0.0 0.0 (-> s5-0 coneradius) 1.0) + (set-vector! s3-0 0.0 (-> s5-0 coneradius) 0.0 1.0) + ) + (vector-matrix*! s3-0 s3-0 s2-0) + (+! (-> arg0 launchrot x) (-> s3-0 x)) + (+! (-> arg0 launchrot y) (-> s3-0 y)) + (+! (-> arg0 launchrot z) (-> s3-0 z)) + ) + (when (!= (-> s5-0 rotate-y) 0.0) + (let ((s3-1 (new 'stack-no-clear 'matrix))) + (matrix-rotate-y! s3-1 (-> s5-0 rotate-y)) + (vector3s-rotate*! + (the-as vector3s (-> arg0 launchrot)) + (the-as vector3s (-> arg0 launchrot)) + s3-1 + ) + (vector3s-rotate*! + (the-as vector3s (-> arg1 vel-sxvel)) + (the-as vector3s (-> arg1 vel-sxvel)) + s3-1 + ) + (if (zero? (logand (sp-cpuinfo-flag use-global-acc) (-> arg1 flags))) + (vector3s-rotate*! + (the-as vector3s (-> arg1 acc)) + (the-as vector3s (-> arg1 acc)) + s3-1 + ) + ) + ) + (if (logtest? (sp-cpuinfo-flag set-conerot) (-> arg1 flags)) + (set! (-> arg0 conerot y) (+ 16384.0 (-> s5-0 rotate-y))) + ) + ) + ) + 0 + (none) + ) + +;; definition for function sp-euler-convert +;; INFO: Return type mismatch int vs none. +(defun sp-euler-convert ((arg0 sparticle-launchinfo) (arg1 sparticle-cpuinfo)) + (local-vars (v1-1 float) (v1-2 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((a1-1 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'quaternion)) + ) + (set-vector! + a1-1 + (-> arg0 conerot x) + (-> arg0 conerot y) + (-> arg0 conerot z) + 1.0 + ) + (quaternion-zxy! s5-0 a1-1) + (cond + ((< (-> s5-0 w) 0.0) + (.lvf vf1 (&-> arg0 conerot quad)) + (.lvf vf2 (&-> s5-0 vec quad)) + (.sub.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg0 conerot quad) vf1) + (.mov v1-1 vf1) + ) + (else + (.lvf vf1 (&-> arg0 conerot quad)) + (.lvf vf2 (&-> s5-0 vec quad)) + (.add.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg0 conerot quad) vf1) + (.mov v1-2 vf1) + ) + ) + ) + (cond + (*sp-60-hz* + (set! (-> arg1 rot-syvel x) (* 5.0 (-> arg1 rot-syvel x))) + (set! (-> arg1 rot-syvel y) (* 5.0 (-> arg1 rot-syvel y))) + (set! (-> arg1 rot-syvel z) (* 5.0 (-> arg1 rot-syvel z))) + ) + (else + (set! (-> arg1 rot-syvel x) (* 6.0 (-> arg1 rot-syvel x))) + (set! (-> arg1 rot-syvel y) (* 6.0 (-> arg1 rot-syvel y))) + (set! (-> arg1 rot-syvel z) (* 6.0 (-> arg1 rot-syvel z))) + ) + ) + (quaternion-zxy! (-> arg1 rotvel3d) (-> arg1 rot-syvel)) + 0 + (none) + ) + ) + +;; definition for function sp-rotate-system +;; INFO: Return type mismatch int vs none. +(defun + sp-rotate-system + ((arg0 sparticle-launchinfo) (arg1 sparticle-cpuinfo) (arg2 transformq)) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (let ((a1-1 (new 'stack-no-clear 'quaternion))) + (let* ((v1-0 a1-1) + (a0-1 arg2) + (f0-0 (-> a0-1 quat x)) + (f1-0 (-> a0-1 quat y)) + (f3-0 (-> a0-1 quat z)) + ) + (set! (-> v1-0 x) f0-0) + (set! (-> v1-0 y) f1-0) + (set! (-> v1-0 z) f3-0) + (set! + (-> v1-0 w) + (sqrtf (- (- (- 1.0 (* f3-0 f3-0)) (* f1-0 f1-0)) (* f0-0 f0-0))) + ) + ) + (quaternion->matrix s5-0 a1-1) + ) + (vector3s-rotate*! + (the-as vector3s (-> arg0 launchrot)) + (the-as vector3s (-> arg0 launchrot)) + s5-0 + ) + (vector3s-rotate*! + (the-as vector3s (-> arg1 vel-sxvel)) + (the-as vector3s (-> arg1 vel-sxvel)) + s5-0 + ) + (if (zero? (logand (sp-cpuinfo-flag use-global-acc) (-> arg1 flags))) + (vector3s-rotate*! + (the-as vector3s (-> arg1 acc)) + (the-as vector3s (-> arg1 acc)) + s5-0 + ) + ) + ) + 0 + (none) + ) + +;; definition for function sp-launch-particles-var +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for symbol *death-adgif*, type adgif-shader +(define *death-adgif* (the-as adgif-shader #f)) + +;; definition for function sp-launch-particles-death +;; INFO: Return type mismatch int vs none. +;; WARN: Expression building failed: Function sp-launch-particles-death has a return type of none, but the expression builder found a return statement. +;; Used lq/sq +(defun + sp-launch-particles-death + ((arg0 sparticle-system) + (arg1 sparticle-launcher) + (arg2 sparticle-launchinfo) + ) + (local-vars (v1-25 float) (v1-27 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf30 :class vf) + (vf31 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (.lvf vf30 (&-> arg2 launchrot quad)) + (let ((v1-0 #x437f0000)) + (.mov vf31 v1-0) + ) + (let ((s5-0 (new 'stack-no-clear 'sprite-vec-data-2d)) + (gp-0 (sp-get-particle arg0 0 (the-as sparticle-launch-state #f))) + ) + (if (not gp-0) + (return 0) + ) + (let* ((a1-2 (-> arg1 init-specs 0)) + (a1-3 + (sp-init-fields! + (&-> s5-0 x) + (the-as (inline-array sp-field-init-spec) a1-2) + (sp-field-id sprite-fields-start) + (sp-field-id sprite-fields-end) + #t + ) + ) + ) + (sp-init-fields! + (&-> gp-0 omega) + (the-as (inline-array sp-field-init-spec) a1-3) + (sp-field-id cpu-fields-start) + (sp-field-id cpu-fields-end) + #t + ) + ) + (set! (-> s5-0 matrix) 0) + (set! (-> s5-0 rot) (the float (sar (shl (the int (-> s5-0 rot)) 48) 48))) + (.lvf vf4 (&-> s5-0 color quad)) + (.lvf vf5 (&-> s5-0 x-y-z-sx quad)) + (.min.x.vf vf4 vf4 vf31 :mask #b111) + (.add.vf vf5 vf5 vf30 :mask #b111) + (.svf (&-> s5-0 color quad) vf4) + (.svf (&-> s5-0 x-y-z-sx quad) vf5) + (when (not *death-adgif*) + (set! *death-adgif* (new 'static 'adgif-shader)) + (particle-adgif + *death-adgif* + (new 'static 'texture-id :index #x18 :page #x2) + ) + (set! (-> *death-adgif* alpha) (new 'static 'gs-miptbp :tbp1 #x48)) + ) + (let ((v1-14 (-> *death-adgif* quad 0 quad))) + (set! (-> gp-0 adgif quad 0 quad) v1-14) + ) + (let ((v1-16 (-> *death-adgif* quad 1 quad))) + (set! (-> gp-0 adgif quad 1 quad) v1-16) + ) + (let ((v1-18 (-> *death-adgif* quad 2 quad))) + (set! (-> gp-0 adgif quad 2 quad) v1-18) + ) + (let ((v1-20 (-> *death-adgif* quad 3 quad))) + (set! (-> gp-0 adgif quad 3 quad) v1-20) + ) + (let ((v1-22 (-> *death-adgif* quad 4 quad))) + (set! (-> gp-0 adgif quad 4 quad) v1-22) + ) + (.lvf vf4 (&-> (-> *time-of-day-context* current-prt-color) quad)) + (.lvf vf5 (&-> s5-0 color quad)) + (.lvf vf6 (&-> gp-0 fade quad)) + (.mul.vf vf5 vf5 vf4 :mask #b111) + (.mul.vf vf6 vf6 vf4 :mask #b111) + (.svf (&-> s5-0 color quad) vf5) + (.svf (&-> gp-0 fade quad) vf6) + (.mov v1-25 vf6) + (set! (-> gp-0 key) (the-as sparticle-launch-control 0)) + (set! (-> gp-0 binding) #f) + (let ((v1-26 (-> gp-0 sprite))) + (.lvf vf1 (&-> s5-0 x-y-z-sx quad)) + (.lvf vf2 (&-> s5-0 flag-rot-sy quad)) + (.lvf vf3 (&-> s5-0 color quad)) + (.svf (&-> v1-26 x-y-z-sx quad) vf1) + (.svf (&-> v1-26 flag-rot-sy quad) vf2) + (.sub.w.vf vf3 vf0 vf0 :mask #b1000) + (.svf (&-> v1-26 color quad) vf3) + ) + (.mov v1-27 vf3) + (logior! (-> gp-0 flags) (sp-cpuinfo-flag ready-to-launch)) + (set! (-> gp-0 cache-alpha) (-> s5-0 a)) + ) + 0 + (none) + ) + ) + +;; definition for function sp-clear-queue +;; INFO: Return type mismatch int vs none. +(defun sp-clear-queue () + (let ((gp-0 *sp-launch-queue*)) + (when (> (-> gp-0 in-use) 0) + (dotimes (s5-0 (-> gp-0 in-use)) + (let ((v1-4 (-> gp-0 queue s5-0))) + (sp-launch-particles-var + (-> v1-4 sp-system) + (-> v1-4 sp-launcher) + (-> v1-4 pos) + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + ) + (set! (-> gp-0 in-use) 0) + 0 + ) + ) + 0 + (none) + ) + +;; definition for function sp-relaunch-setup-fields +;; INFO: Return type mismatch int vs none. +(defun + sp-relaunch-setup-fields + ((arg0 object) + (arg1 sparticle-launcher) + (arg2 sparticle-cpuinfo) + (arg3 sprite-vec-data-3d) + ) + (let ((a1-1 (-> arg1 init-specs 0)) + (s4-0 (logand (-> arg2 flags) (sp-cpuinfo-flag level0 level1))) + ) + (set! (-> arg2 next-launcher) (the-as basic 0)) + (cond + ((and + (logtest? (-> arg2 flags) (sp-cpuinfo-flag bit12)) + (zero? (logand (-> arg2 flags) (sp-cpuinfo-flag aux-list))) + ) + (let ((f20-0 (-> arg3 r-g-b-a x)) + (f22-0 (-> arg3 r-g-b-a y)) + (f24-0 (-> arg3 r-g-b-a z)) + (f26-0 (-> arg2 fade x)) + (f28-0 (-> arg2 fade y)) + (f30-0 (-> arg2 fade z)) + ) + (set! (-> arg3 r-g-b-a x) 99999.0) + (set! (-> arg3 r-g-b-a y) 99999.0) + (set! (-> arg3 r-g-b-a z) 99999.0) + (set! (-> arg2 fade x) 99999.0) + (set! (-> arg2 fade y) 99999.0) + (set! (-> arg2 fade z) 99999.0) + (let + ((a1-2 + (sp-init-fields! + (-> arg3 x-y-z-sx) + (the-as (inline-array sp-field-init-spec) a1-1) + (sp-field-id sprite-fields-start) + (sp-field-id sprite-fields-end) + #f + ) + ) + ) + (sp-init-fields! + (&-> arg2 omega) + (the-as (inline-array sp-field-init-spec) a1-2) + (sp-field-id cpu-fields-start) + (sp-field-id cpu-fields-end) + #f + ) + ) + (logior! (-> arg2 flags) s4-0) + (if (logtest? (-> arg2 flags) (sp-cpuinfo-flag level1)) + (-> *level* level1) + (-> *level* level0) + ) + (let ((v1-16 (-> *time-of-day-context* current-prt-color))) + (if (= (-> arg3 r-g-b-a x) 99999.0) + (set! (-> arg3 r-g-b-a x) f20-0) + (set! (-> arg3 r-g-b-a x) (* (-> arg3 r-g-b-a x) (-> v1-16 x))) + ) + (if (= (-> arg3 r-g-b-a y) 99999.0) + (set! (-> arg3 r-g-b-a y) f22-0) + (set! (-> arg3 r-g-b-a y) (* (-> arg3 r-g-b-a y) (-> v1-16 y))) + ) + (if (= (-> arg3 r-g-b-a z) 99999.0) + (set! (-> arg3 r-g-b-a z) f24-0) + (set! (-> arg3 r-g-b-a z) (* (-> arg3 r-g-b-a z) (-> v1-16 z))) + ) + (if (= (-> arg2 fade x) 99999.0) + (set! (-> arg2 fade x) f26-0) + (set! (-> arg2 fade x) (* (-> arg2 fade x) (-> v1-16 x))) + ) + (if (= (-> arg2 fade y) 99999.0) + (set! (-> arg2 fade y) f28-0) + (set! (-> arg2 fade y) (* (-> arg2 fade y) (-> v1-16 y))) + ) + (if (= (-> arg2 fade z) 99999.0) + (set! (-> arg2 fade z) f30-0) + (set! (-> arg2 fade z) (* (-> arg2 fade z) (-> v1-16 z))) + ) + ) + ) + ) + (else + (let + ((a1-3 + (sp-init-fields! + (-> arg3 x-y-z-sx) + (the-as (inline-array sp-field-init-spec) a1-1) + (sp-field-id sprite-fields-start) + (sp-field-id sprite-fields-end) + #f + ) + ) + ) + (sp-init-fields! + (&-> arg2 omega) + (the-as (inline-array sp-field-init-spec) a1-3) + (sp-field-id cpu-fields-start) + (sp-field-id cpu-fields-end) + #f + ) + ) + ) + ) + ) + 0 + 0 + (none) + ) + +;; definition for function sp-relaunch-particle-2d +;; INFO: Return type mismatch int vs none. +(defun + sp-relaunch-particle-2d + ((arg0 object) + (arg1 sparticle-launcher) + (arg2 sparticle-cpuinfo) + (arg3 sprite-vec-data-3d) + ) + (sp-relaunch-setup-fields arg0 arg1 arg2 arg3) + (when (logtest? (-> arg2 flags) (sp-cpuinfo-flag aux-list)) + (set! (-> arg2 func) add-to-sprite-aux-list) + (set! (-> arg3 r-g-b-a w) 0.0) + (set! (-> arg2 fade w) 0.0) + (logclear! (-> arg2 flags) (sp-cpuinfo-flag bit2)) + ) + 0 + (none) + ) + +;; definition for function sp-relaunch-particle-3d +;; INFO: Return type mismatch int vs none. +(defun + sp-relaunch-particle-3d + ((arg0 object) + (arg1 sparticle-launcher) + (arg2 sparticle-cpuinfo) + (arg3 sprite-vec-data-3d) + ) + (local-vars (v1-9 float) (v1-10 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (new 'stack-no-clear 'quaternion))) + (let* ((v1-0 s4-0) + (a2-1 arg3) + (f0-0 (-> a2-1 qx-qy-qz-sy x)) + (f1-0 (-> a2-1 qx-qy-qz-sy y)) + (f3-0 (-> a2-1 qx-qy-qz-sy z)) + ) + (set! (-> v1-0 x) f0-0) + (set! (-> v1-0 y) f1-0) + (set! (-> v1-0 z) f3-0) + (set! + (-> v1-0 w) + (sqrtf (- (- (- 1.0 (* f3-0 f3-0)) (* f1-0 f1-0)) (* f0-0 f0-0))) + ) + ) + (set! (-> arg3 qx-qy-qz-sy x) 0.0) + (set! (-> arg3 qx-qy-qz-sy y) 0.0) + (set! (-> arg3 qx-qy-qz-sy z) 0.0) + (sp-relaunch-setup-fields arg0 arg1 arg2 arg3) + (let ((a1-1 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'quaternion)) + ) + (set-vector! + a1-1 + (-> arg3 qx-qy-qz-sy x) + (-> arg3 qx-qy-qz-sy y) + (-> arg3 qx-qy-qz-sy z) + 1.0 + ) + (quaternion-zxy! s3-0 a1-1) + (cond + ((logtest? (sp-cpuinfo-flag left-multiply-quat) (-> arg2 flags)) + (quaternion*! s3-0 s4-0 s3-0) + ) + (else + (if (logtest? (sp-cpuinfo-flag right-multiply-quat) (-> arg2 flags)) + (quaternion*! s3-0 s3-0 s4-0) + ) + ) + ) + (cond + ((< (-> s3-0 w) 0.0) + (.lvf vf1 (&-> arg3 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> s3-0 vec quad)) + (.sub.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg3 qx-qy-qz-sy quad) vf1) + (.mov v1-9 vf1) + ) + (else + (.lvf vf1 (&-> arg3 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> s3-0 vec quad)) + (.add.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg3 qx-qy-qz-sy quad) vf1) + (.mov v1-10 vf1) + ) + ) + ) + ) + (cond + (*sp-60-hz* + (set! (-> arg2 rot-syvel x) (* 5.0 (-> arg2 rot-syvel x))) + (set! (-> arg2 rot-syvel y) (* 5.0 (-> arg2 rot-syvel y))) + (set! (-> arg2 rot-syvel z) (* 5.0 (-> arg2 rot-syvel z))) + ) + (else + (set! (-> arg2 rot-syvel x) (* 6.0 (-> arg2 rot-syvel x))) + (set! (-> arg2 rot-syvel y) (* 6.0 (-> arg2 rot-syvel y))) + (set! (-> arg2 rot-syvel z) (* 6.0 (-> arg2 rot-syvel z))) + ) + ) + (quaternion-zxy! (-> arg2 rotvel3d) (-> arg2 rot-syvel)) + 0 + (none) + ) + ) + +;; definition for method 9 of type sparticle-launch-control +;; INFO: Return type mismatch int vs none. +(defmethod + initialize + sparticle-launch-control + ((obj sparticle-launch-control) (arg0 sparticle-launch-group) (arg1 process)) + (let ((s5-0 0)) + (set! (-> obj group) arg0) + (set! (-> obj proc) arg1) + (set! (-> obj local-clock) 0) + (set! (-> obj fade) 1.0) + (set! (-> obj matrix) 0) + (set! + (-> obj last-spawn-frame) + (+ (-> *display* real-actual-frame-counter) -2) + ) + (set! (-> obj last-spawn-time) 0) + (dotimes (s3-0 (-> arg0 length)) + (let* ((a0-2 (-> arg0 launcher s3-0)) + (a1-2 (-> *part-id-table* (-> a0-2 launcher))) + (v1-9 (-> obj data s5-0)) + ) + (when (nonzero? a1-2) + (set! (-> v1-9 group-item) a0-2) + (cond + ((= (-> a1-2 type) sparticle-launcher) + (set! (-> v1-9 accum) 0.0) + (set! + (-> v1-9 spawn-time) + (the-as uint (+ *particle-300hz-timer* -30000)) + ) + (set! (-> v1-9 offset) (-> a0-2 offset)) + (set! (-> v1-9 randomize) (the-as uint 0)) + (cond + ((logtest? (-> a0-2 flags) (sp-group-item-flag start-dead)) + (logclear! (-> v1-9 flags) (sp-launch-state-flags launcher-active)) + (set! (-> v1-9 origin) #f) + (set! (-> v1-9 sprite3d) #f) + (set! (-> v1-9 sprite) #f) + ) + (else + (logior! (-> v1-9 flags) (sp-launch-state-flags launcher-active)) + (set! (-> v1-9 origin) (-> obj center)) + (set! (-> v1-9 sprite3d) #f) + (set! (-> v1-9 sprite) #f) + ) + ) + (+! s5-0 1) + ) + (else + (format 0 "initialize called with non-particle-launcher~%") + ) + ) + ) + ) + ) + (set! (-> obj length) s5-0) + ) + 0 + (none) + ) + +;; definition for method 9 of type sparticle-launch-group +;; INFO: Return type mismatch object vs sparticle-launch-control. +(defmethod + create-launch-control + sparticle-launch-group + ((obj sparticle-launch-group) (arg0 process)) + (let + ((gp-0 + (the-as object (new 'process 'sparticle-launch-control (-> obj length))) + ) + ) + (when (zero? (the-as sparticle-launch-control gp-0)) + (go process-drawable-art-error "memory") + (set! gp-0 0) + (goto cfg-4) + ) + (initialize (the-as sparticle-launch-control gp-0) obj arg0) + (label cfg-4) + (the-as sparticle-launch-control gp-0) + ) + ) + +;; definition for method 12 of type sparticle-launch-control +;; INFO: Return type mismatch int vs none. +(defmethod + kill-and-free-particles + sparticle-launch-control + ((obj sparticle-launch-control)) + (countdown (v1-0 (-> obj length)) + (let ((a0-3 (-> obj data v1-0))) + (logclear! (-> a0-3 flags) (sp-launch-state-flags particles-active)) + ) + ) + (set! (-> obj local-clock) 0) + (set! (-> obj fade) 1.0) + (kill-all-particles-with-key obj) + (if (> (-> obj matrix) 0) + (sprite-release-user-hvdf (-> obj matrix)) + ) + 0 + (none) + ) + +;; definition for method 13 of type sparticle-launch-control +;; INFO: Return type mismatch int vs none. +(defmethod + kill-particles + sparticle-launch-control + ((obj sparticle-launch-control)) + (kill-all-particles-with-key obj) + 0 + (none) + ) + +;; definition for method 10 of type sparticle-launch-control +(defmethod + is-visible? + sparticle-launch-control + ((obj sparticle-launch-control) (arg0 vector)) + (let* ((v1-0 (-> obj group)) + (f0-0 (-> v1-0 bounds w)) + ) + (cond + ((= f0-0 0.0) + #t + ) + ((nonzero? (-> obj matrix)) + #t + ) + (else + (let + ((gp-1 + (vector+! + (new 'stack-no-clear 'vector) + arg0 + (the-as vector (-> v1-0 bounds)) + ) + ) + ) + (set! (-> gp-1 w) f0-0) + (if + (and + *display-actor-vis* + (or + (not *display-actor-anim*) + (name= *display-actor-anim* (-> obj proc name)) + ) + ) + (add-debug-sphere + *display-actor-vis* + (bucket-id debug-draw0) + gp-1 + (-> gp-1 w) + (new 'static 'rgba :g #xff :a #x80) + ) + ) + (sphere-in-view-frustum? (the-as sphere gp-1)) + ) + ) + ) + ) + ) + +;; definition for method 11 of type sparticle-launch-control +;; INFO: Return type mismatch int vs object. +;; Used lq/sq +(defmethod + spawn + sparticle-launch-control + ((obj sparticle-launch-control) (arg0 vector)) + (set! (-> obj center quad) (-> arg0 quad)) + (if + (not + (or + (is-visible? obj arg0) + (logtest? (-> obj group flags) (sp-group-flag always-draw screen-space)) + ) + ) + (return (the-as object 0)) + ) + (let ((s4-0 *particle-300hz-timer*) + (s5-0 (-> obj last-spawn-time)) + ) + (let ((v1-8 (-> *display* real-actual-frame-counter))) + (if (!= v1-8 (+ (-> obj last-spawn-frame) 1)) + (set! s5-0 (- s4-0 (logand (the-as int (-> *sp-frame-time* x)) 255))) + ) + ) + (set! (-> obj last-spawn-frame) (-> *display* real-actual-frame-counter)) + (set! (-> obj last-spawn-time) s4-0) + (when (logtest? (-> obj group flags) (sp-group-flag use-local-clock)) + (set! s5-0 (-> obj local-clock)) + (+! (-> obj local-clock) (logand (the-as int (-> *sp-frame-time* x)) 255)) + (set! s4-0 (-> obj local-clock)) + ) + (let ((f30-0 (vector-vector-distance arg0 (math-camera-pos))) + (s3-1 (ash 1 (if *time-of-day-proc* + (-> *time-of-day-proc* 0 hour) + 0 + ) + ) + ) + ) + (if (nonzero? (-> obj matrix)) + (set! f30-0 0.0) + ) + (let ((s2-1 (-> obj length))) + (while (begin + (label cfg-79) + (nonzero? s2-1) + ) + (+! s2-1 -1) + (let* ((a3-0 (-> obj data s2-1)) + (v1-29 (-> a3-0 group-item)) + (a1-4 (-> *part-id-table* (-> v1-29 launcher))) + ) + (when + (and + a1-4 + (nonzero? a1-4) + (logtest? (-> a3-0 flags) (sp-launch-state-flags launcher-active)) + ) + (let ((f0-2 1.0)) + (if (!= (-> v1-29 falloff-to) 0.0) + (set! f0-2 (- 1.0 (/ f30-0 (-> v1-29 falloff-to)))) + ) + (let ((a0-26 sparticle-launcher)) + (b! (!= (-> a1-4 type) a0-26) cfg-78 :delay (nop!)) + ) + (b! + (zero? (logand (-> v1-29 flags) (sp-group-item-flag launch-asap))) + cfg-36 + :delay + (nop!) + ) + (when + (zero? + (logand (-> a3-0 flags) (sp-launch-state-flags particles-active)) + ) + (set! (-> a3-0 spawn-time) (the-as uint s4-0)) + (logior! (-> a3-0 flags) (sp-launch-state-flags particles-active)) + (if (< 0.0 f0-2) + (sp-launch-particles-var + (if (logtest? (-> v1-29 flags) (sp-group-item-flag is-3d)) + *sp-particle-system-3d* + *sp-particle-system-2d* + ) + a1-4 + (-> a3-0 origin) + a3-0 + obj + f0-2 + ) + ) + ) + (b! #t cfg-77 :delay (nop!)) + (label cfg-36) + (when (logtest? s3-1 (-> v1-29 hour-mask)) + 0 + (goto cfg-77) + ) + (when + (not + (or (= (-> v1-29 fade-after) 0.0) (< f30-0 (-> v1-29 fade-after))) + ) + 0 + (b! #t cfg-77 :delay (nop!)) + (set! v1-29 (the-as sparticle-group-item 0)) + ) + (b! (nonzero? (-> v1-29 period)) cfg-50 :delay (empty-form)) + (let ((f0-4 (* 0.2 (the float (- s4-0 s5-0)) f0-2))) + (b! #t cfg-72 :delay (nop!)) + (label cfg-50) + (let + ((a2-5 + (mod + (+ s5-0 (-> obj data s2-1 offset)) + (the-as int (-> v1-29 period)) + ) + ) + (a0-56 + (mod + (the-as uint (+ s4-0 (-> obj data s2-1 offset))) + (-> v1-29 period) + ) + ) + (t0-2 (-> v1-29 length)) + ) + (set! f0-4 (cond + ((and (< a2-5 (the-as int t0-2)) (< a0-56 t0-2)) + (* 0.2 (the float (- s4-0 s5-0)) f0-2) + ) + ((and (< a2-5 (the-as int t0-2)) (>= a0-56 t0-2)) + (* 0.2 (the float (- t0-2 (the-as uint a2-5))) f0-2) + ) + ((and (>= a2-5 (the-as int t0-2)) (< a0-56 t0-2)) + (* 0.2 (the float a0-56) f0-2) + ) + (else + (when + (zero? + (logand (-> v1-29 flags) (sp-group-item-flag bit1)) + ) + 0 + (goto cfg-77) + ) + (when + (< + (the-as + uint + (- s4-0 (the-as int (-> obj data s2-1 spawn-time))) + ) + (-> v1-29 period) + ) + 0 + (goto cfg-77) + ) + (set! + (-> obj data s2-1 offset) + (- (-> v1-29 period) a0-56) + ) + (* 0.2 (the float (- s4-0 s5-0)) f0-2) + ) + ) + ) + ) + (label cfg-72) + (set! (-> a3-0 spawn-time) (the-as uint s4-0)) + (logior! (-> a3-0 flags) (sp-launch-state-flags particles-active)) + (if (< 0.0 f0-4) + (sp-launch-particles-var + (if (logtest? (-> v1-29 flags) (sp-group-item-flag is-3d)) + *sp-particle-system-3d* + *sp-particle-system-2d* + ) + a1-4 + (-> a3-0 origin) + a3-0 + obj + f0-4 + ) + ) + ) + ) + (label cfg-77) + (b! #t cfg-79 :delay (nop!)) + (label cfg-78) + (format 0 "spawn called for non-sparticle-launcher~%") + ) + ) + ) + ) + ) + ) + 0 + ) + +;; definition for function sparticle-track-root +;; INFO: Return type mismatch int vs none. +(defun + sparticle-track-root + ((arg0 object) (arg1 sparticle-cpuinfo) (arg2 vector)) + (let ((v1-3 (-> (the-as process-drawable (-> arg1 key proc)) root trans))) + (set! (-> arg2 x) (-> v1-3 x)) + (set! (-> arg2 y) (-> v1-3 y)) + (set! (-> arg2 z) (-> v1-3 z)) + ) + 0 + (none) + ) + +;; definition for function sparticle-track-root-prim +;; INFO: Return type mismatch int vs none. +(defun + sparticle-track-root-prim + ((arg0 object) (arg1 sparticle-cpuinfo) (arg2 vector)) + (let + ((v1-4 + (-> + (the-as + collide-shape + (-> (the-as process-drawable (-> arg1 key proc)) root) + ) + root-prim + prim-core + ) + ) + ) + (set! (-> arg2 x) (-> v1-4 world-sphere x)) + (set! (-> arg2 y) (-> v1-4 world-sphere y)) + (set! (-> arg2 z) (-> v1-4 world-sphere z)) + ) + 0 + (none) + ) + +;; definition for function birth-func-copy-rot-color +;; INFO: Return type mismatch int vs none. +(defun + birth-func-copy-rot-color + ((arg0 sparticle-system) + (arg1 sparticle-cpuinfo) + (arg2 sprite-vec-data-3d) + (arg3 sparticle-launcher) + (arg4 sparticle-launch-state) + ) + (local-vars (v1-4 float) (v1-5 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (-> arg4 sprite))) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (let* ((v1-0 arg2) + (f0-0 (-> v1-0 qx-qy-qz-sy x)) + (f1-0 (-> v1-0 qx-qy-qz-sy y)) + (f3-0 (-> v1-0 qx-qy-qz-sy z)) + ) + (set! (-> s4-0 x) f0-0) + (set! (-> s4-0 y) f1-0) + (set! (-> s4-0 z) f3-0) + (set! + (-> s4-0 w) + (sqrtf (- (- (- 1.0 (* f3-0 f3-0)) (* f1-0 f1-0)) (* f0-0 f0-0))) + ) + ) + (quaternion-rotate-y! + (the-as quaternion s4-0) + (the-as quaternion s4-0) + (-> s5-0 sprite rot) + ) + (let ((v1-3 arg2)) + (cond + ((< (-> s4-0 w) 0.0) + (.lvf vf1 (&-> v1-3 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> s4-0 quad)) + (.sub.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> v1-3 qx-qy-qz-sy quad) vf1) + (.mov v1-4 vf1) + ) + (else + (.lvf vf1 (&-> v1-3 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> s4-0 quad)) + (.add.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> v1-3 qx-qy-qz-sy quad) vf1) + (.mov v1-5 vf1) + ) + ) + ) + ) + (set! (-> arg2 r-g-b-a x) (-> s5-0 sprite r)) + (set! (-> arg2 r-g-b-a y) (-> s5-0 sprite g)) + (set! (-> arg2 r-g-b-a z) (-> s5-0 sprite b)) + ) + 0 + (none) + ) + ) + +;; definition for symbol *global-toggle*, type int +(define *global-toggle* 0) + +;; definition for function birth-func-copy2-rot-color +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defun + birth-func-copy2-rot-color + ((arg0 sparticle-system) + (arg1 sparticle-cpuinfo) + (arg2 sprite-vec-data-3d) + (arg3 sparticle-launcher) + (arg4 sparticle-launch-state) + ) + (local-vars (v1-15 float) (v1-16 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (-> arg4 sprite))) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (let* ((v1-0 arg2) + (f0-0 (-> v1-0 qx-qy-qz-sy x)) + (f1-0 (-> v1-0 qx-qy-qz-sy y)) + (f3-0 (-> v1-0 qx-qy-qz-sy z)) + ) + (set! (-> s4-0 x) f0-0) + (set! (-> s4-0 y) f1-0) + (set! (-> s4-0 z) f3-0) + (set! + (-> s4-0 w) + (sqrtf (- (- (- 1.0 (* f3-0 f3-0)) (* f1-0 f1-0)) (* f0-0 f0-0))) + ) + ) + (let ((a1-1 (new-stack-vector0))) + (set! (-> a1-1 y) (-> s5-0 sprite rot)) + (set! (-> a1-1 z) (if (logtest? *global-toggle* 1) + (the + float + (sar + (shl (the int (- 16384.0 (-> s5-0 sprite sx))) 48) + 48 + ) + ) + (the + float + (sar + (shl (the int (+ 16384.0 (-> s5-0 sprite sx))) 48) + 48 + ) + ) + ) + ) + (quaternion-zxy! (the-as quaternion s4-0) a1-1) + ) + (let ((v1-14 arg2)) + (cond + ((< (-> s4-0 w) 0.0) + (.lvf vf1 (&-> v1-14 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> s4-0 quad)) + (.sub.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> v1-14 qx-qy-qz-sy quad) vf1) + (.mov v1-15 vf1) + ) + (else + (.lvf vf1 (&-> v1-14 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> s4-0 quad)) + (.add.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> v1-14 qx-qy-qz-sy quad) vf1) + (.mov v1-16 vf1) + ) + ) + ) + ) + (set! (-> arg2 r-g-b-a x) (-> s5-0 sprite r)) + (set! (-> arg2 r-g-b-a y) (-> s5-0 sprite g)) + (set! (-> arg2 r-g-b-a z) (-> s5-0 sprite b)) + ) + (set! *global-toggle* (+ *global-toggle* 1)) + 0 + (none) + ) + ) + +;; definition for function birth-func-copy-omega-to-z +;; INFO: Return type mismatch int vs none. +(defun + birth-func-copy-omega-to-z + ((arg0 sparticle-system) + (arg1 sparticle-cpuinfo) + (arg2 sprite-vec-data-3d) + (arg3 sparticle-launcher) + (arg4 sparticle-launch-state) + ) + (set! (-> arg2 qx-qy-qz-sy z) (+ -16384.0 (-> arg1 omega))) + (set! (-> arg1 next-time) (-> arg4 sprite next-time)) + (set! + (-> arg2 x-y-z-sx w) + (* 163.85638 (the float (-> arg4 sprite next-time))) + ) + 0 + (none) + ) + +;; definition for function birth-func-random-next-time +;; INFO: Return type mismatch int vs none. +(defun + birth-func-random-next-time + ((arg0 sparticle-system) + (arg1 sparticle-cpuinfo) + (arg2 sprite-vec-data-3d) + (arg3 sparticle-launcher) + (arg4 sparticle-launch-state) + ) + (set! + (-> arg1 next-time) + (the-as uint (the int (rand-vu-float-range 0.0 (-> arg1 user-float)))) + ) + 0 + (none) + ) diff --git a/test/decompiler/reference/engine/gfx/sparticle/sparticle_REF.gc b/test/decompiler/reference/engine/gfx/sparticle/sparticle_REF.gc new file mode 100644 index 0000000000..16de2746ae --- /dev/null +++ b/test/decompiler/reference/engine/gfx/sparticle/sparticle_REF.gc @@ -0,0 +1,869 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 2 of type sparticle-cpuinfo +;; INFO: Return type mismatch object vs sparticle-cpuinfo. +(defmethod print sparticle-cpuinfo ((obj sparticle-cpuinfo)) + (format #t "~%") + (dotimes (s5-0 16) + (format #t "~D:~F~%" s5-0 (the-as float (-> obj data s5-0))) + ) + (format #t "TIMER:~D~%" (-> obj timer)) + (the-as sparticle-cpuinfo (format #t "FLAGS:~X~%" (-> obj flags))) + ) + +;; definition for function sp-particle-copy! +;; INFO: Return type mismatch basic vs none. +;; Used lq/sq +(defun sp-particle-copy! ((arg0 sparticle-cpuinfo) (arg1 sparticle-cpuinfo)) + (let ((v1-1 (-> arg1 sprite x-y-z-sx quad))) + (set! (-> arg0 sprite x-y-z-sx quad) v1-1) + ) + (let ((v1-3 (-> arg1 sprite flag-rot-sy quad))) + (set! (-> arg0 sprite flag-rot-sy quad) v1-3) + ) + (let ((v1-5 (-> arg1 sprite color quad))) + (set! (-> arg0 sprite color quad) v1-5) + ) + (dotimes (v1-6 10) + (set! (-> arg0 adgif prims v1-6) (-> arg1 adgif prims v1-6)) + ) + (set! (-> arg0 vel-sxvel quad) (-> arg1 vel-sxvel quad)) + (set! (-> arg0 rot-syvel quad) (-> arg1 rot-syvel quad)) + (set! (-> arg0 fade quad) (-> arg1 fade quad)) + (set! (-> arg0 acc quad) (-> arg1 acc quad)) + (set! (-> arg0 friction) (-> arg1 friction)) + (set! (-> arg0 timer) (-> arg1 timer)) + (set! (-> arg0 flags) (-> arg1 flags)) + (set! (-> arg0 user-float) (-> arg1 user-float)) + (set! (-> arg0 func) (-> arg1 func)) + (none) + ) + +;; definition for method 0 of type sparticle-system +(defmethod + new + sparticle-system + ((allocation symbol) + (type-to-make type) + (arg0 int) + (arg1 int) + (arg2 symbol) + (arg3 pointer) + (arg4 (inline-array adgif-shader)) + ) + (let + ((gp-0 + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) + ) + (let* ((v1-3 (/ (+ arg0 63) 64)) + (a0-2 (/ (+ arg1 63) 64)) + (a1-2 (* v1-3 64)) + (a2-2 (* a0-2 64)) + (s2-1 (+ v1-3 a0-2)) + (s5-1 (+ a1-2 a2-2)) + ) + (set! (-> gp-0 blocks 0) v1-3) + (set! (-> gp-0 length 0) a1-2) + (set! (-> gp-0 num-alloc 0) 0) + (set! (-> gp-0 blocks 1) a0-2) + (set! (-> gp-0 length 1) a2-2) + (set! (-> gp-0 num-alloc 1) 0) + (set! (-> gp-0 is-3d) arg2) + (set! + (-> gp-0 alloc-table) + (the-as (pointer uint64) (malloc 'global (* s2-1 8))) + ) + (set! + (-> gp-0 cpuinfo-table) + (the-as (inline-array sparticle-cpuinfo) (malloc 'global (* 144 s5-1))) + ) + (set! (-> gp-0 vecdata-table) arg3) + (set! (-> gp-0 adgifdata-table) arg4) + (dotimes (v1-5 s2-1) + (set! (-> gp-0 alloc-table v1-5) (the-as uint -1)) + ) + (dotimes (s4-1 s5-1) + (set! (-> gp-0 cpuinfo-table s4-1 valid) #f) + (set! + (-> gp-0 cpuinfo-table s4-1 sprite) + (the-as sprite-vec-data-2d (&+ (-> gp-0 vecdata-table) (* 48 s4-1))) + ) + (set! (-> gp-0 cpuinfo-table s4-1 adgif) (-> gp-0 adgifdata-table s4-1)) + (adgif-shader<-texture-simple! + (-> gp-0 adgifdata-table s4-1) + (the-as texture #f) + ) + (set! + (-> gp-0 adgifdata-table s4-1 alpha) + (new 'static 'gs-miptbp :tbp1 #x48) + ) + ) + ) + gp-0 + ) + ) + +;; definition for symbol *sp-particle-system-2d*, type sparticle-system +(define + *sp-particle-system-2d* + (new + 'global + 'sparticle-system + 1920 + 128 + #f + (-> *sprite-array-2d* vec-data) + (-> *sprite-array-2d* adgif-data) + ) + ) + +;; definition for symbol *sp-particle-system-3d*, type sparticle-system +(define + *sp-particle-system-3d* + (new + 'global + 'sparticle-system + 256 + 0 + #t + (-> *sprite-array-3d* vec-data) + (-> *sprite-array-3d* adgif-data) + ) + ) + +;; definition for function sp-get-block-size +(defun sp-get-block-size ((arg0 sparticle-system) (arg1 int)) + (let ((v0-0 0)) + (let ((v1-0 0) + (a2-0 (-> arg0 blocks 0)) + ) + (when (= arg1 1) + (set! v1-0 a2-0) + (set! a2-0 (-> arg0 blocks 1)) + ) + (dotimes (a1-3 a2-0) + (if (!= (-> arg0 alloc-table (+ v1-0 a1-3)) -1) + (set! v0-0 (+ a1-3 1)) + ) + ) + ) + v0-0 + ) + ) + +;; definition for function sp-get-approx-alloc-size +(defun sp-get-approx-alloc-size ((arg0 sparticle-system) (arg1 int)) + (let ((a3-0 arg1) + (v1-0 0) + ) + (let ((a1-1 0) + (a2-0 (-> arg0 blocks 0)) + ) + (when (= a3-0 1) + (set! a1-1 a2-0) + (set! a2-0 (-> arg0 blocks 1)) + ) + (dotimes (a3-3 a2-0) + (if (!= (-> arg0 alloc-table (+ a1-1 a3-3)) -1) + (set! v1-0 (+ a3-3 1)) + ) + ) + ) + (* v1-0 64) + ) + ) + +;; definition for function sp-free-particle +;; INFO: Return type mismatch int vs none. +(defun + sp-free-particle + ((arg0 sparticle-system) + (arg1 int) + (arg2 sparticle-cpuinfo) + (arg3 sprite-vec-data-2d) + ) + (if (and (-> arg2 binding) (nonzero? (-> arg2 binding))) + (logclear! + (-> arg2 binding flags) + (sp-launch-state-flags launcher-active particles-active) + ) + ) + (let ((v1-6 (/ arg1 64)) + (t0-4 (logand arg1 63)) + ) + (logior! (-> arg0 alloc-table v1-6) (ash 1 t0-4)) + ) + (if (< arg1 (-> arg0 length 0)) + (+! (-> arg0 num-alloc 0) -1) + (+! (-> arg0 num-alloc 1) -1) + ) + (set! (-> arg2 valid) #f) + (set! (-> arg3 a) 0.0) + 0 + (none) + ) + +;; definition for function sp-get-particle +;; WARN: Unsupported inline assembly instruction kind - [movn t1, t2, t2] +;; WARN: Unsupported inline assembly instruction kind - [movz a2, t3, t2] +;; WARN: Unsupported inline assembly instruction kind - [movn t1, t2, t2] +;; WARN: Unsupported inline assembly instruction kind - [movz a2, t3, t2] +;; WARN: Unsupported inline assembly instruction kind - [movn t1, t2, t2] +;; WARN: Unsupported inline assembly instruction kind - [movz a2, t3, t2] +;; WARN: Unsupported inline assembly instruction kind - [movn t1, t2, t2] +;; WARN: Unsupported inline assembly instruction kind - [movz a2, t3, t2] +;; WARN: Unsupported inline assembly instruction kind - [movn t1, t2, t2] +;; WARN: Unsupported inline assembly instruction kind - [movz a2, t3, t2] +;; WARN: Unsupported inline assembly instruction kind - [movn t3, t1, t1] +;; WARN: Unsupported inline assembly instruction kind - [movz a2, t2, t1] +(defun + sp-get-particle + ((arg0 sparticle-system) (arg1 int) (arg2 sparticle-launch-state)) + (local-vars + (a2-3 int) + (a2-4 int) + (a2-5 int) + (a2-6 int) + (a2-7 int) + (a2-8 int) + (t1-16 int) + (t1-17 int) + (t1-18 int) + (t1-19 int) + (t1-20 int) + (t3-5 int) + ) + (let ((v1-0 0) + (t0-0 (-> arg0 blocks 0)) + (a3-0 0) + ) + (when (= arg1 1) + (set! v1-0 t0-0) + (set! t0-0 (-> arg0 blocks 1)) + ) + (when arg2 + (set! a3-0 (the-as int (-> arg2 randomize))) + (+! (-> arg2 randomize) 1) + (when (= (-> arg2 randomize) t0-0) + (set! (-> arg2 randomize) (the-as uint 0)) + 0 + ) + ) + (dotimes (a2-1 t0-0) + (when (nonzero? (-> arg0 alloc-table (+ v1-0 a3-0))) + (let ((a2-2 0) + (t1-15 (-> arg0 alloc-table (+ v1-0 a3-0))) + (t0-4 (* (+ v1-0 a3-0) 64)) + ) + 0 + 0 + (let ((t2-4 (shl t1-15 32)) + (t3-0 (+ a2-2 32)) + ) + (.movn t1-16 t2-4 t2-4 t1-15) + (.movz a2-3 t3-0 t2-4 a2-2) + ) + (let ((t2-5 (shl t1-16 16)) + (t3-1 (+ a2-3 16)) + ) + (.movn t1-17 t2-5 t2-5 t1-16) + (.movz a2-4 t3-1 t2-5 a2-3) + ) + (let ((t2-6 (* t1-17 256)) + (t3-2 (+ a2-4 8)) + ) + (.movn t1-18 t2-6 t2-6 t1-17) + (.movz a2-5 t3-2 t2-6 a2-4) + ) + (let ((t2-7 (* t1-18 16)) + (t3-3 (+ a2-5 4)) + ) + (.movn t1-19 t2-7 t2-7 t1-18) + (.movz a2-6 t3-3 t2-7 a2-5) + ) + (let ((t2-8 (* t1-19 4)) + (t3-4 (+ a2-6 2)) + ) + (.movn t1-20 t2-8 t2-8 t1-19) + (.movz a2-7 t3-4 t2-8 a2-6) + (let ((t1-21 (* t1-20 2)) + (t2-9 (+ a2-7 1)) + ) + (.movn t3-5 t1-21 t1-21 t3-4) + (.movz a2-8 t2-9 t1-21 a2-7) + ) + ) + (let ((t0-5 (+ t0-4 a2-8))) + (set! + (-> arg0 alloc-table (+ v1-0 a3-0)) + (logxor (-> arg0 alloc-table (+ v1-0 a3-0)) (the-as uint (ash 1 a2-8))) + ) + (+! (-> arg0 num-alloc arg1) 1) + (let ((v1-9 (-> arg0 cpuinfo-table t0-5))) + (set! (-> v1-9 valid) #t) + (return v1-9) + ) + ) + ) + ) + (+! a3-0 1) + (if (= a3-0 t0-0) + (set! a3-0 0) + ) + ) + ) + (the-as sparticle-cpuinfo #f) + ) + +;; definition for function sp-kill-particle +;; INFO: Return type mismatch symbol vs none. +;; WARN: Expression building failed: Function sp-kill-particle has a return type of none, but the expression builder found a return statement. +(defun sp-kill-particle ((arg0 sparticle-system) (arg1 sparticle-cpuinfo)) + (cond + ((>= (the-as int arg1) #x70000000) + (set! (-> arg1 timer) 0) + 0 + ) + (else + (let + ((a2-1 + (/ + (the-as + int + (- (the-as uint arg1) (the-as uint (-> arg0 cpuinfo-table 0))) + ) + 144 + ) + ) + ) + (when (or (< a2-1 0) (>= a2-1 (+ (-> arg0 length 0) (-> arg0 length 1)))) + (format 0 "Tried to release particle ~D~%" a2-1) + (return #f) + ) + (sp-free-particle arg0 a2-1 arg1 (-> arg1 sprite)) + ) + ) + ) + #t + (none) + ) + +;; definition for function sp-orbiter +;; INFO: Return type mismatch int vs none. +(defun + sp-orbiter + ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (let* ((f2-0 (-> arg1 omega)) + (f0-0 (-> arg1 radius)) + (f4-0 (-> arg1 vel-sxvel x)) + (f24-0 (-> arg1 vel-sxvel y)) + (f1-0 (-> arg1 vel-sxvel z)) + (f3-0 (-> *sp-frame-time* y)) + (f28-0 (+ f2-0 (* f4-0 f3-0))) + ) + (set! (-> arg1 omega) f28-0) + (let ((f30-0 (+ f0-0 (* f1-0 f3-0)))) + (set! (-> arg1 radius) f30-0) + (let ((f26-0 (sin f28-0)) + (f28-1 (cos f28-0)) + (f22-0 (sin (* 0.5 f24-0))) + (f0-5 (cos (* 0.5 f24-0))) + (a1-1 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (let ((s3-0 (new 'stack-no-clear 'matrix))) + (set-vector! a1-1 (* f22-0 f28-1) 0.0 (* f22-0 f26-0) f0-5) + (quaternion*! + (-> arg1 rotvel3d) + (the-as quaternion a1-1) + (-> arg1 rotvel3d) + ) + (quaternion-normalize! (-> arg1 rotvel3d)) + (set-vector! s4-0 (* f26-0 f30-0) 0.0 (* f28-1 f30-0) 1.0) + (quaternion->matrix s3-0 (-> arg1 rotvel3d)) + (vector-matrix*! s4-0 s4-0 s3-0) + ) + (let ((v1-3 (the-as object (-> arg1 user-float)))) + (set! (-> arg2 x) (+ (-> s4-0 x) (-> (the-as sprite-vec-data-2d v1-3) x))) + (set! (-> arg2 y) (+ (-> s4-0 y) (-> (the-as sprite-vec-data-2d v1-3) y))) + (set! (-> arg2 z) (+ (-> s4-0 z) (-> (the-as sprite-vec-data-2d v1-3) z))) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function sp-process-block-2d +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function sp-process-block-3d +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function sp-copy-to-spr +;; INFO: Return type mismatch int vs none. +(defun sp-copy-to-spr ((arg0 int) (arg1 pointer) (arg2 int)) + (let ((a2-1 (/ (+ arg2 15) 16))) + (dma-send-to-spr-no-flush + (the-as uint arg0) + (the-as uint arg1) + (the-as uint a2-1) + #t + ) + ) + 0 + (none) + ) + +;; definition for function sp-copy-from-spr +;; INFO: Return type mismatch int vs none. +(defun sp-copy-from-spr ((arg0 int) (arg1 pointer) (arg2 int)) + (let ((a2-1 (/ (+ arg2 15) 16))) + (dma-send-from-spr-no-flush + (the-as uint arg1) + (the-as uint arg0) + (the-as uint a2-1) + #t + ) + ) + 0 + (none) + ) + +;; definition for function memcpy +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function sp-process-block +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defun + sp-process-block + ((arg0 sparticle-system) (arg1 int) (arg2 sprite-array-2d) (arg3 int)) + (local-vars + (sv-16 int) + (sv-32 int) + (sv-48 (function sparticle-system int int int int symbol none)) + (sv-64 sparticle-system) + (sv-80 int) + (sv-96 int) + (sv-112 int) + (sv-128 (function sparticle-system int int int int symbol none)) + (sv-144 sparticle-system) + (sv-160 int) + (sv-176 int) + (sv-192 int) + ) + (let ((s3-0 16) + (s2-0 (* 144 arg3)) + (s5-0 (* 48 arg3)) + ) + (set! sv-32 (* 80 arg3)) + (let ((s1-0 (+ s3-0 s2-0))) + (set! sv-16 (+ s1-0 s5-0)) + (sp-copy-to-spr s3-0 (the-as pointer (-> arg0 cpuinfo-table arg1)) s2-0) + (sp-copy-to-spr s1-0 (&+ (-> arg0 vecdata-table) (* 48 arg1)) s5-0) + (let ((t9-2 sp-copy-to-spr) + (a1-7 (-> arg0 adgifdata-table arg1)) + ) + (t9-2 sv-16 (the-as pointer a1-7) sv-32) + ) + (set! sv-80 (+ #x70000000 s3-0)) + (set! sv-96 (+ #x70000000 s1-0)) + (cond + ((-> arg0 is-3d) + (set! sv-48 sp-process-block-3d) + (set! sv-64 arg0) + (set! sv-112 arg1) + (let ((t1-0 (paused?))) + (sv-48 sv-64 sv-80 sv-96 sv-112 arg3 t1-0) + ) + ) + (else + (set! sv-128 sp-process-block-2d) + (set! sv-144 arg0) + (set! sv-160 sv-80) + (set! sv-176 sv-96) + (set! sv-192 arg1) + (let ((t1-1 (paused?))) + (sv-128 sv-144 sv-160 sv-176 sv-192 arg3 t1-1) + ) + ) + ) + (sp-copy-from-spr s3-0 (the-as pointer (-> arg0 cpuinfo-table arg1)) s2-0) + (sp-copy-from-spr s1-0 (&+ (-> arg0 vecdata-table) (* 48 arg1)) s5-0) + ) + ) + 0 + (none) + ) + +;; definition for function sp-process-particle-system +;; INFO: Return type mismatch int vs none. +(defun + sp-process-particle-system + ((arg0 sparticle-system) (arg1 int) (arg2 sprite-array-2d)) + (let* ((v1-0 16) + (s1-0 (/ (- #x4000 v1-0) 272)) + (s3-0 0) + (s4-0 (sp-get-approx-alloc-size arg0 arg1)) + ) + (if (= arg1 1) + (set! s3-0 (* (-> arg0 blocks 0) 64)) + ) + (set! (-> arg2 num-valid arg1) s4-0) + (flush-cache 0) + (while (>= s4-0 s1-0) + (sp-process-block arg0 s3-0 arg2 s1-0) + (set! s4-0 (- s4-0 s1-0)) + (+! s3-0 s1-0) + ) + (if (> s4-0 0) + (sp-process-block arg0 s3-0 arg2 s4-0) + ) + ) + 0 + (none) + ) + +;; definition (perm) for symbol *particles-flag*, type symbol +(define-perm *particles-flag* symbol #t) + +;; definition for function forall-particles-with-key-runner +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defun + forall-particles-with-key-runner + ((arg0 sparticle-launch-control) + (arg1 (function sparticle-system sparticle-cpuinfo none)) + (arg2 sparticle-system) + ) + (local-vars (sv-16 int)) + (let ((s3-0 (the-as object (-> arg2 cpuinfo-table 0))) + (s2-0 (&+ (-> arg2 vecdata-table) 0)) + (s1-0 (+ (-> arg2 blocks 0) (-> arg2 blocks 1))) + ) + (dotimes (s0-0 s1-0) + (cond + ((!= (-> arg2 alloc-table s0-0) -1) + (set! sv-16 0) + (while (< sv-16 64) + (if + (and + (-> (the-as sparticle-cpuinfo s3-0) valid) + (= (-> (the-as sparticle-cpuinfo s3-0) key) arg0) + ) + (arg1 arg2 (the-as sparticle-cpuinfo s3-0)) + ) + (set! s3-0 (-> (the-as (inline-array sparticle-cpuinfo) s3-0) 1)) + (&+! s2-0 48) + (set! sv-16 (+ sv-16 1)) + ) + ) + (else + (set! s3-0 (-> (the-as (inline-array sparticle-cpuinfo) s3-0) 64)) + (&+! s2-0 3072) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function forall-particles-with-key +;; INFO: Return type mismatch int vs none. +(defun + forall-particles-with-key + ((arg0 sparticle-launch-control) + (arg1 (function sparticle-system sparticle-cpuinfo none)) + (arg2 symbol) + (arg3 symbol) + ) + (if arg2 + (forall-particles-with-key-runner arg0 arg1 *sp-particle-system-2d*) + ) + (if arg3 + (forall-particles-with-key-runner arg0 arg1 *sp-particle-system-3d*) + ) + 0 + (none) + ) + +;; definition for function sparticle-kill-it +;; INFO: Return type mismatch int vs none. +(defun sparticle-kill-it ((arg0 sparticle-system) (arg1 sparticle-cpuinfo)) + (set! (-> arg1 timer) 0) + (set! (-> arg1 func) (the-as basic 0)) + (when (and (-> arg1 binding) (nonzero? (-> arg1 binding))) + (logclear! + (-> arg1 binding flags) + (sp-launch-state-flags launcher-active particles-active) + ) + (set! (-> arg1 binding) #f) + ) + 0 + (none) + ) + +;; definition for function sparticle-kill-it-level0 +;; INFO: Return type mismatch int vs none. +(defun + sparticle-kill-it-level0 + ((arg0 sparticle-system) (arg1 sparticle-cpuinfo)) + (if (logtest? (-> arg1 flags) (sp-cpuinfo-flag level0)) + (sparticle-kill-it arg0 arg1) + ) + 0 + (none) + ) + +;; definition for function sparticle-kill-it-level1 +;; INFO: Return type mismatch int vs none. +(defun + sparticle-kill-it-level1 + ((arg0 sparticle-system) (arg1 sparticle-cpuinfo)) + (if (logtest? (-> arg1 flags) (sp-cpuinfo-flag level1)) + (sparticle-kill-it arg0 arg1) + ) + 0 + (none) + ) + +;; definition for function sparticle-60-to-50 +;; INFO: Return type mismatch int vs none. +(defun + sparticle-60-to-50 + ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 pointer)) + (let ((gp-0 (-> arg1 rotvel3d)) + (s5-0 (new 'stack-no-clear 'quaternion)) + ) + (vector-angle<-quaternion! (the-as vector s5-0) gp-0) + (set! (-> s5-0 w) (* 12516.455 (-> s5-0 w))) + (quaternion-vector-angle! gp-0 (the-as vector s5-0) (-> s5-0 w)) + ) + 0 + (none) + ) + +;; definition for function sparticle-50-to-60 +;; INFO: Return type mismatch int vs none. +(defun + sparticle-50-to-60 + ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 pointer)) + (let ((gp-0 (-> arg1 rotvel3d)) + (s5-0 (new 'stack-no-clear 'quaternion)) + ) + (vector-angle<-quaternion! (the-as vector s5-0) gp-0) + (set! (-> s5-0 w) (* 8691.982 (-> s5-0 w))) + (quaternion-vector-angle! gp-0 (the-as vector s5-0) (-> s5-0 w)) + ) + 0 + (none) + ) + +;; definition for function kill-all-particles-with-key +;; INFO: Return type mismatch int vs none. +(defun kill-all-particles-with-key ((arg0 sparticle-launch-control)) + (forall-particles-with-key arg0 sparticle-kill-it #t #t) + 0 + (none) + ) + +;; definition for function forall-particles-runner +;; INFO: Return type mismatch int vs none. +(defun + forall-particles-runner + ((arg0 (function sparticle-system sparticle-cpuinfo pointer none)) + (arg1 sparticle-system) + ) + (let ((s4-0 (the-as object (-> arg1 cpuinfo-table 0))) + (s3-0 (&+ (-> arg1 vecdata-table) 0)) + (s2-0 (+ (-> arg1 blocks 0) (-> arg1 blocks 1))) + ) + (dotimes (s1-0 s2-0) + (cond + ((!= (-> arg1 alloc-table s1-0) -1) + (dotimes (s0-0 64) + (if (-> (the-as sparticle-cpuinfo s4-0) valid) + (arg0 arg1 (the-as sparticle-cpuinfo s4-0) s3-0) + ) + (set! s4-0 (+ (the-as uint s4-0) 144)) + (&+! s3-0 48) + ) + ) + (else + (set! s4-0 (&+ (the-as pointer s4-0) 9216)) + (&+! s3-0 3072) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function forall-particles +;; INFO: Return type mismatch int vs none. +(defun forall-particles ((arg0 function) (arg1 symbol) (arg2 symbol)) + (if arg1 + (forall-particles-runner + (the-as (function sparticle-system sparticle-cpuinfo pointer none) arg0) + *sp-particle-system-2d* + ) + ) + (if arg2 + (forall-particles-runner + (the-as (function sparticle-system sparticle-cpuinfo pointer none) arg0) + *sp-particle-system-3d* + ) + ) + 0 + (none) + ) + +;; definition for function kill-all-particles-in-level +(defun kill-all-particles-in-level ((arg0 level)) + (forall-particles (if (zero? (-> arg0 index)) + sparticle-kill-it-level0 + sparticle-kill-it-level1 + ) + #t + #t + ) + 0 + ) + +;; definition for function all-particles-50-to-60 +(defun all-particles-50-to-60 () + (forall-particles-runner sparticle-50-to-60 *sp-particle-system-3d*) + (none) + ) + +;; definition for function all-particles-60-to-50 +(defun all-particles-60-to-50 () + (forall-particles-runner sparticle-60-to-50 *sp-particle-system-3d*) + (none) + ) + +;; definition for function set-particle-frame-time +;; INFO: Return type mismatch int vs none. +(defun set-particle-frame-time ((arg0 int)) + (cond + ((= arg0 5) + (set-vector! + *sp-frame-time* + 0.00000000000000000000000000000000000001175495 + 5.0 + 1.0 + 1.0 + ) + ) + ((= arg0 6) + (set-vector! + *sp-frame-time* + 0.000000000000000000000000000000000000011754952 + 6.0 + 1.2 + 1.2 + ) + ) + ((= arg0 10) + (set-vector! + *sp-frame-time* + 0.000000000000000000000000000000000000011754958 + 10.0 + 2.0 + 2.0 + ) + ) + ((= arg0 12) + (set-vector! + *sp-frame-time* + 0.00000000000000000000000000000000000001175496 + 12.0 + 2.4 + 2.4 + ) + ) + ) + 0 + (none) + ) + +;; definition for function process-particles +;; INFO: Return type mismatch int vs none. +;; WARN: Unsupported inline assembly instruction kind - [mfc0 gp, Count] +;; WARN: Unsupported inline assembly instruction kind - [mfc0 v1, Count] +(defun process-particles () + (local-vars (v1-29 int) (gp-0 int)) + (when *particles-flag* + 0 + 0 + (.mfc0 gp-0 Count) + (set! *sp-launcher-lock* #t) + (if *debug-segment* + (add-frame + (-> *display* frames (-> *display* on-screen) frame profile-bar 0) + 'draw + (new 'static 'rgba :r #x40 :b #x40 :a #x80) + ) + ) + (let ((v1-14 (logand (the-as int (-> *sp-frame-time* x)) 255))) + (set! *particle-300hz-timer* (+ *particle-300hz-timer* v1-14)) + (cond + (*sp-60-hz* + (when (or (= v1-14 6) (= v1-14 12)) + (set! *sp-60-hz* #f) + (all-particles-60-to-50) + ) + ) + (else + (when (or (= v1-14 5) (= v1-14 10)) + (set! *sp-60-hz* #t) + (all-particles-50-to-60) + ) + ) + ) + ) + (clear-sprite-aux-list) + (sp-process-particle-system *sp-particle-system-2d* 0 *sprite-array-2d*) + (sp-process-particle-system *sp-particle-system-2d* 1 *sprite-array-2d*) + (sp-process-particle-system + *sp-particle-system-3d* + 0 + (the-as sprite-array-2d *sprite-array-3d*) + ) + (if *debug-segment* + (add-frame + (-> *display* frames (-> *display* on-screen) frame profile-bar 0) + 'draw + (new 'static 'rgba :r #x80 :g #x80 :b #xff :a #x80) + ) + ) + (set! *sp-launcher-lock* #f) + (sp-clear-queue) + (.mfc0 v1-29 Count) + (let ((a2-5 (- v1-29 gp-0))) + (if *display-sprite-info* + (format + *stdcon* + "Particle time = ~D cycles for ~D 2D [~D warp] and ~D HUD and ~D 3D~%" + a2-5 + (-> *sp-particle-system-2d* num-alloc 0) + (-> *sprite-aux-list* entry) + (-> *sp-particle-system-2d* num-alloc 1) + (-> *sp-particle-system-3d* num-alloc 0) + ) + ) + ) + ) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/engine/load/loader-h_REF.gc b/test/decompiler/reference/engine/load/loader-h_REF.gc index d043263488..a4d852647d 100644 --- a/test/decompiler/reference/engine/load/loader-h_REF.gc +++ b/test/decompiler/reference/engine/load/loader-h_REF.gc @@ -12,8 +12,8 @@ :flag-assert #xb00000010 (:methods (new (symbol type int basic) _type_ 0) - (dummy-9 (_type_ string symbol kheap int) art-group 9) - (dummy-10 (_type_ art-group) art-group 10) + (load-to-heap-by-name (_type_ string symbol kheap int) art-group 9) + (set-loaded-art (_type_ art-group) art-group 10) ) ) diff --git a/test/decompiler/reference/engine/load/loader_REF.gc b/test/decompiler/reference/engine/load/loader_REF.gc index a83d2fec24..68511fdf87 100644 --- a/test/decompiler/reference/engine/load/loader_REF.gc +++ b/test/decompiler/reference/engine/load/loader_REF.gc @@ -60,14 +60,19 @@ ;; definition for method 9 of type load-dir-art-group (defmethod - dummy-9 + load-to-heap-by-name load-dir-art-group - ((obj load-dir-art-group) (arg0 string) (arg1 symbol) (arg2 kheap) (arg3 int)) + ((obj load-dir-art-group) + (art-name string) + (do-reload symbol) + (heap kheap) + (version int) + ) (let ((s5-0 (-> obj string-array))) (dotimes (s3-0 (-> s5-0 length)) - (when (string= arg0 (-> s5-0 s3-0)) - (when arg1 - (let ((v1-4 (art-group-load-check arg0 arg2 arg3))) + (when (string= art-name (-> s5-0 s3-0)) + (when do-reload + (let ((v1-4 (art-group-load-check art-name heap version))) (if v1-4 (set! (-> obj art-group-array s3-0) v1-4) ) @@ -76,9 +81,9 @@ (return (-> obj art-group-array s3-0)) ) ) - (let ((v0-2 (art-group-load-check arg0 arg2 arg3))) + (let ((v0-2 (art-group-load-check art-name heap version))) (when v0-2 - (set! (-> s5-0 (-> s5-0 length)) arg0) + (set! (-> s5-0 (-> s5-0 length)) art-name) (set! (-> obj art-group-array (-> s5-0 length)) v0-2) (+! (-> s5-0 length) 1) (+! (-> obj art-group-array length) 1) @@ -90,7 +95,7 @@ ;; definition for method 10 of type load-dir-art-group (defmethod - dummy-10 + set-loaded-art load-dir-art-group ((obj load-dir-art-group) (arg0 art-group)) (let ((s4-0 (-> obj string-array))) @@ -1073,7 +1078,7 @@ (set! sv-48 0) (set! sv-56 0) (set! spool-sound (new-sound-id)) - (dummy-17 *load-state* (-> arg0 command-list)) + (backup-load-state-and-set-cmds *load-state* (-> arg0 command-list)) (set-setting! *setting-control* self @@ -1236,7 +1241,7 @@ (spool-push *art-control* (-> arg0 name) (+ spool-part 1) self -10.0) (set! (-> self skel status) (logand -5 (-> self skel status))) ) - (dummy-16 *load-state* (ja-aframe-num 0)) + (execute-commands-up-to *load-state* (ja-aframe-num 0)) (cond ((and (< sv-32 sv-72) (= (current-str-id) spool-sound)) (set! @@ -1305,7 +1310,7 @@ (defbehavior ja-abort-spooled-anim process-drawable ((arg0 spool-anim) (arg1 art-joint-anim) (arg2 int)) - (dummy-18 *load-state*) + (restore-load-state-and-cleanup *load-state*) (str-play-stop (-> arg0 name)) (set! (-> *art-control* active-stream) #f) (set! (-> self skel status) (logand -7 (-> self skel status))) diff --git a/test/offline/offline_test_main.cpp b/test/offline/offline_test_main.cpp index d7d9e6c1db..93a6cbef67 100644 --- a/test/offline/offline_test_main.cpp +++ b/test/offline/offline_test_main.cpp @@ -63,8 +63,9 @@ const std::unordered_set g_functions_expected_to_reject = { // display "vblank-handler", // asm "vif1-handler", "vif1-handler-debug", - // sprite. Don't know types yet. - "add-to-sprite-aux-list", + // sparticle + "sp-launch-particles-var", "particle-adgif", "sp-init-fields!", "memcpy", "sp-process-block-2d", + "sp-process-block-3d", // ripple - asm "ripple-execute-init", "ripple-create-wave-table", "ripple-apply-wave-table", "ripple-matrix-scale", @@ -145,6 +146,9 @@ const std::unordered_set g_functions_to_skip_compiling = { "(method 15 sync-info-eased)", // needs display stuff first "(method 15 sync-info-paused)", // needs display stuff first + // sparticle + "lookup-part-group-pointer-by-name", // address of element in array issue + // ripple - calls an asm function "ripple-execute",