diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 7a3d7a31ad..a1a3ba1882 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -47,6 +47,19 @@ (force-debug 4) (fast-link 5) ) + +(defenum language-enum + :type int64 + (english) + (french) + (german) + (spanish) + (italian) + (japanese) + (korean) + (uk-english) + ) + (define-extern *debug-segment* symbol) (define-extern nothing (function none)) (define-extern _format (function _varargs_ object)) @@ -82,6 +95,7 @@ (define-extern link-begin (function pointer (pointer uint8) int kheap link-flag int)) (define-extern link-resume (function int)) (define-extern link-reset (function none)) +(define-extern kset-language (function language-enum int)) (define-extern loading-level kheap) @@ -1552,7 +1566,7 @@ (set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion 14) (set-roll-to-grav! (_type_ float) quaternion 15) (set-roll-to-grav-2! (_type_ float) quaternion 16) - (rotate-toward-orientation! (_type_ quaternion float float) quaternion 17) + (rotate-toward-orientation! (_type_ quaternion float float int float float) quaternion 17) (set-quaternion! (_type_ quaternion) quaternion 18) (set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion 19) (point-toward-point-clear-roll-pitch! (_type_ vector) quaternion 20) @@ -1778,30 +1792,57 @@ (defenum sound-command :type uint16 - ; (load-bank) - ; (load-music) - ; (unload-bank) - ; (play) - ; (pause-sound) - ; (stop-sound) - ; (continue-sound) - ; (set-param) - ; (set-master-volume) - ; (pause-group) - ; (stop-group) - ; (continue-group) - ; (get-irx-version) - ; (set-falloff-curve) - ; (set-sound-falloff) - ; (reload-info) - ; (set-language) - ; (set-flava) - ; (set-reverb) - ; (set-ear-trans) - ; (shutdown) - ; (list-sounds) - ; (unload-music) - ; (set-fps) + (iop-store 0) ;; sound-rpc-bank-cmd + (iop-free 1) ;; sound-rpc-bank-cmd + (load-bank 2) ;; sound-rpc-load-bank + (load-bank-from-iop 3) ;; sound-rpc-load-bank + (load-bank-from-ee 4) ;; sound-rpc-load-bank + (load-music 5) ;; sound-rpc-load-music + (unload-bank 6) ;; sound-rpc-bank-cmd + (play 7) ;; sound-rpc-play + (pause-sound 8) ;; sound-rpc-pause-sound + (stop-sound 9) ;; sound-rpc-stop-sound + (continue-sound 10) ;; sound-rpc-continue-sound + (set-param 11) + (set-master-volume 12) ;; sound-rpc-set-master-volume + (pause-group 13) ;; sound-rpc-pause-group + (stop-group 14) ;; sound-rpc-stop-group + (continue-group 15) ;; sound-rpc-continue-group + (get-irx-version 16) + (set-falloff-curve 17) + (set-sound-falloff 18) + (reload-info 19) + (set-language 20) ;; sound-rpc-set-language + (set-flava 21) ;; sound-rpc-set-flava + (set-midi-reg 22) ;; sound-rpc-set-midi-reg + (set-reverb 23) ;; sound-rpc-set-reverb + (set-ear-trans 24) ;; sound-rpc-set-ear-trans + (shutdown 25) + (list-sounds 26) ;; sound-rpc-list-sounds + (unload-music 27) ;; sound-rpc-unload-music + (set-fps 28) ;; sound-rpc-set-fps + (boot-load 29) + (game-load 30) + (num-tests 31) + (num-testruns 32) + (num-sectors 33) + (num-streamsectors 34) + (num-streambanks 35) + (track-pitch 36) + (linvel-nom 37) + (linvel-stm 38) + (seek-nom 39) + (seek-stm 40) + (read-seq-nom 41) + (read-seq-stm 42) + (read-spr-nom 43) + (read-spr-stm 44) + (read-spr-strn-nom 45) + (rand-stm-abort 46) + (rand-nom-abort 47) + (iop-mem 48) + (cancel-dgo 49) + (set-stereo-mode 50) ;; sound-rpc-set-stereo-mode ) (defenum sound-group @@ -1844,6 +1885,7 @@ (deftype sound-stream-name (structure) ((name uint8 48 :offset-assert 0) ) + :pack-me :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 @@ -1870,6 +1912,7 @@ (trans int32 3 :offset-assert 16) (group uint8 :offset-assert 28) (reg uint8 3 :offset-assert 29) + (group-and-regs uint32 :offset 28) ) :allow-misaligned :method-count-assert 9 @@ -1906,8 +1949,8 @@ ) (deftype sound-rpc-test-cmd (sound-rpc-cmd) - ((ee-addr uint32 :offset-assert 4) - (param0 uint16 :offset-assert 8) + ((ee-addr pointer :offset-assert 4) + (param0 uint16 :offset-assert 8) ) :method-count-assert 9 :size-assert #xa @@ -1931,7 +1974,7 @@ ) (deftype sound-rpc-load-bank (sound-rpc-bank-cmd) - ((ee-addr uint32 :offset-assert 32) + ((ee-addr pointer :offset-assert 32) ) :method-count-assert 9 :size-assert #x24 @@ -2150,6 +2193,7 @@ (num float :offset-assert 8) (group sound-group :offset-assert 12) (reg uint8 3 :offset-assert 13) + (group-and-regs uint32 :offset 12) (sound-name-char uint8 16 :offset-assert 16) (sound-name sound-name :offset 16 :score 1) (trans int32 4 :offset-assert 32) @@ -2190,14 +2234,14 @@ :size-assert #x6c :flag-assert #x100000006c (:methods - ;; (new (symbol type basic vector) _type_ 0) - (ambient-sound-method-9 () none 9) ;; (update! (_type_) int 9) - (ambient-sound-method-10 () none 10) ;; (change-sound! (_type_ sound-name) int 10) - (ambient-sound-method-11 () none 11) ;; (update-trans! (_type_ vector) int 11) - (ambient-sound-method-12 () none 12) ;; (update-vol! (_type_ int) int 12) - (ambient-sound-method-13 () none 13) ;; (stop! (_type_) int 13) - (ambient-sound-method-14 () none 14) - (ambient-sound-method-15 () none 15) + (new (symbol type basic vector) _type_ 0) + (update! (_type_) int 9) + (change-sound! (_type_ sound-name) int 10) + (update-trans! (_type_ vector) int 11) + (update-vol! (_type_ float) int 12) + (update-pitch-mod! (_type_ float) none 13) + (set-falloff-far! (_type_ float) none 14) + (stop! (_type_) int 15) ) ) @@ -6016,7 +6060,7 @@ (defenum font-color :type uint32 - (zero 0) + (default 0) (one 1) (orange-red 3) ) @@ -6308,7 +6352,7 @@ (:methods (new (symbol type symbol int type) _type_ 0) (schedule-callback (_type_ object time-frame) connection-pers 9) - (kill-callback (_type_) none 10) + (kill-callback (_type_ connection-pers) none 10) (kill-by-key (_type_ object) none 11) (kill-matching (_type_ (function engine-pers connection-pers object object symbol) object object) none 12) (update-callback (_type_) none 13) @@ -7202,8 +7246,8 @@ (:methods (new (symbol type int) _type_ 0) (setting-control-method-9 () none 9) ;; (add-setting (_type_ process symbol object object object) none 9) - (setting-control-method-10 () none 10) ;; (set-setting (_type_ process symbol object object object) none 10) - (setting-control-method-11 () none 11) ;; (remove-setting (_type_ process symbol) none 11) + (setting-control-method-10 () none 10) ;; + (set-setting (_type_ process symbol object object object) none 11) ;; (remove-setting (_type_ process symbol) none 11) (setting-control-method-12 () none 12) ;; (apply-settings (_type_) setting-data 12) (setting-control-method-13 () none 13) ;; (update (_type_) setting-data 13) (setting-control-method-14 () none 14) @@ -11221,7 +11265,7 @@ (reset! (_type_) _type_ 9) (update! (_type_) int 10) (want-levels (_type_ (pointer symbol)) int 11) - (load-state-method-12 () none 12) ;; (want-display-level (_type_ symbol symbol) int 12) + (want-sound-banks (_type_ (pointer symbol)) none 12) ;; (want-display-level (_type_ symbol symbol) int 12) (want-display-level (_type_ symbol symbol) int 13) (want-vis-level (_type_ symbol) none 14) ;; (want-force-vis (_type_ symbol symbol) int 14) (load-state-method-15 () none 15) ;; (execute-command (_type_ pair) none 15) @@ -13051,7 +13095,7 @@ :flag-assert #xd00000110 ;; Failed to read fields. (:methods - ;; (new (symbol type process-drawable pickup-type float) _type_ 0) + (new (symbol type process pickup-type float) _type_ 0) (fact-info-target-method-12 () none 12) ) ) @@ -13119,6 +13163,7 @@ :flag-assert #xc0000002c ;; Failed to read fields. (:methods + (new (symbol type process pickup-type float) _type_ 0) ) ) @@ -14718,6 +14763,7 @@ :flag-assert #x44000001dc ;; Failed to read fields. (:methods + (new (symbol type process-drawable collide-list-enum) _type_ 0) (collide-shape-moving-method-55 () none 55) (collide-shape-moving-method-56 () none 56) ;; (set-and-handle-pat! (_type_ pat-surface) none 56) (collide-shape-moving-method-57 () none 57) ;; (integrate-no-collide! (_type_ vector) none 57) @@ -15135,7 +15181,7 @@ :size-assert #x3c10 :flag-assert #xd00003c10 (:methods - ;; (new (symbol type) _type_ 0) + (new (symbol type) _type_ 0) (touching-prims-entry-pool-method-9 () none 9) ;; (alloc-node (_type_) touching-prims-entry 9) (touching-prims-entry-pool-method-10 () none 10) ;; (get-free-node-count (_type_) int 10) (init-list! (_type_) none 11) @@ -15174,7 +15220,7 @@ :size-assert #x408 :flag-assert #xe00000408 (:methods - ;; (new (symbol type) _type_ 0) + (new (symbol type) _type_ 0) (touching-list-method-9 () none 9) ;; (add-touching-prims (_type_ collide-shape-prim collide-shape-prim float collide-tri-result collide-tri-result) none 9) (touching-list-method-10 () none 10) ;; (dummy-10 () none 10) (touching-list-method-11 () none 11) ;; (update-from-step-size (_type_ float) none 11) @@ -20476,7 +20522,6 @@ ;; ramdisk ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype ramdisk-rpc-fill (structure) ((rsvd1 int32 :offset-assert 0) (ee-id int32 :offset-assert 4) @@ -20487,9 +20532,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype ramdisk-rpc-load (structure) ((rsvd int32 :offset-assert 0) (ee-id int32 :offset-assert 4) @@ -20500,9 +20543,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype ramdisk-rpc-load-to-ee (structure) ((rsvd int32 :offset-assert 0) (addr int32 :offset-assert 4) @@ -20514,18 +20555,20 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -;; (define-extern *ramdisk-rpc* object) ;; rpc-buffer-pair -;; (define-extern *current-ramdisk-id* object) ;; int -;; (define-extern ramdisk-load function) ;; (function int uint uint pointer int) -;; (define-extern ramdisk-sync function) ;; (function none) +(define-extern *ramdisk-rpc* rpc-buffer-pair) +(define-extern *current-ramdisk-id* int) +(define-extern ramdisk-load (function int uint uint pointer int)) +(define-extern ramdisk-sync (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gsound ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; ghost function +(define-extern *debug-effect-control* symbol) +(define-extern effect-param->sound-spec (function sound-spec (pointer float) int sound-spec)) + (deftype engine-sound-pers (engine-pers) () :method-count-assert 15 @@ -20534,86 +20577,122 @@ (:methods ) ) -|# -#| +(defenum stream-status + :type uint32 + :bitfield #t + (zero 0) + (one 1) ;; another way to be playing + (two 2) + (three 3) + (four 4) ;; is playing? + (five 5) + (six 6) ;; another way to be playing. + (seven 7) + ) + +(defenum stereo-mode + :type int32 + ) + (deftype sound-iop-info (structure) - () + ((frame uint32 :offset-assert 0) + (strpos int32 :offset-assert 4) + (str-id uint32 :offset-assert 8) + (str-id-sign int32 :offset 8) + (freemem uint32 :offset-assert 12) + (chinfo uint8 48 :offset-assert 16) + (freemem2 uint32 :offset-assert 64) + (nocd uint32 :offset-assert 68) + (dirtycd uint32 :offset-assert 72) + (diskspeed uint32 2 :offset-assert 76) + (lastspeed uint32 :offset-assert 84) + (dupseg int32 :offset-assert 88) + (times int32 41 :offset-assert 92) + (times-seq uint32 :offset-assert 256) + (iop-ticks uint32 :offset-assert 260) + (stream-position uint32 4 :offset 272) + (stream-status stream-status 4 :offset-assert 288) + (stream-name sound-stream-name 4 :inline :offset-assert 304) + (stream-id uint32 4 :offset-assert 496) + (music-register uint8 17 :offset-assert 512) + (music-excite int8 :offset 528) + (ramdisk-name uint8 48 :offset-assert 529) + ) :method-count-assert 9 :size-assert #x241 :flag-assert #x900000241 ;; Failed to read fields. ) -|# -;; (define-extern *sound-loop-engine* object) +(define-extern *sound-loop-engine* engine-sound-pers) (define-extern *sound-player-rpc* rpc-buffer-pair) -;; (define-extern *sound-loader-rpc* object) ;; rpc-buffer-pair -;; (define-extern sound-name= function) ;; (function sound-name sound-name symbol) -;; (define-extern *sound-iop-info* object) ;; sound-iop-info -;; (define-extern str-is-playing? function) ;; (function symbol) -;; (define-extern str-id-is-playing? function) -;; (define-extern current-str-pos function) ;; (function sound-id int) -;; (define-extern is-ramdisk-loaded? function) -;; (define-extern is-cd-in? function) ;; (function symbol) +(define-extern *sound-loader-rpc* rpc-buffer-pair) +(define-extern sound-name= (function sound-name sound-name symbol)) +(define-extern *sound-iop-info* sound-iop-info) +(define-extern str-is-playing? (function symbol)) +(define-extern str-id-is-playing? (function int symbol)) +(define-extern current-str-pos (function sound-id int)) +(define-extern is-ramdisk-loaded? (function symbol symbol)) +(define-extern is-cd-in? (function symbol)) (define-extern new-sound-id (function sound-id)) -;; (define-extern check-irx-version function) ;; (function int) -;; (define-extern sound-bank-iop-store function) -;; (define-extern sound-bank-iop-free function) -;; (define-extern sound-bank-load function) ;; (function sound-name sound-id) -;; (define-extern sound-bank-load-from-iop function) -;; (define-extern sound-bank-load-from-ee function) -;; (define-extern sound-bank-unload function) ;; (function sound-name int) -;; (define-extern sound-music-load function) ;; (function sound-name int) -;; (define-extern sound-music-unload function) ;; (function int) -;; (define-extern set-language function) ;; (function language-enum int) -;; (define-extern sound-set-stereo-mode function) -;; (define-extern list-sounds function) ;; (function int) -;; (define-extern sound-command->string function) ;; (function sound-command string) -;; (define-extern sound-buffer-dump function) ;; (function int) +(define-extern check-irx-version (function int)) +(define-extern sound-bank-iop-store (function sound-name sound-id)) +(define-extern sound-bank-iop-free (function sound-name sound-id)) +(define-extern sound-bank-load (function sound-name sound-id)) +(define-extern sound-bank-load-from-iop (function sound-name sound-id)) +(define-extern sound-bank-load-from-ee (function sound-name pointer sound-id)) +(define-extern sound-bank-unload (function sound-name int)) +(define-extern sound-music-load (function sound-name int)) +(define-extern sound-music-unload (function int)) +(define-extern set-language (function language-enum int)) +(define-extern sound-set-stereo-mode (function stereo-mode none)) +(define-extern list-sounds (function none)) +(define-extern sound-command->string (function sound-command string)) +(define-extern sound-buffer-dump (function int)) (define-extern *sound-player-enable* symbol) -(define-extern swap-sound-buffers (function vector vector float int)) +(define-extern swap-sound-buffers (function vector vector vector float int)) (define-extern get-sound-buffer-entry (function pointer)) -;; (define-extern free-last-sound-buffer-entry function) ;; (function int) -;; (define-extern sound-basic-cb function) ;; (function int (pointer int32) none) -;; (define-extern sound-trans-convert function) ;; (function vector3w vector int) -;; (define-extern sound-angle-convert function) ;; (function float int) +(define-extern free-last-sound-buffer-entry (function none)) +(define-extern sound-basic-cb (function int (pointer int32) none)) +(define-extern sound-trans-convert (function vector3w vector int)) +(define-extern sound-angle-convert (function float int)) (define-extern string->sound-name (function string sound-name)) -;; (define-extern sound-set-volume function) ;; (function sound-group float int) -;; (define-extern sound-set-reverb function) ;; (function int float float uint int) -;; (define-extern sound-set-ear-trans function) ;; (function vector vector float int) +(define-extern sound-set-volume (function sound-group float int)) +(define-extern sound-set-reverb (function int float float uint int)) +(define-extern sound-set-ear-trans (function vector vector vector float int)) (define-extern sound-play-by-name (function sound-name sound-id int int int sound-group symbol sound-id)) (define-extern sound-play-by-spec (function sound-spec sound-id vector sound-id)) -;; (define-extern sound-pause function) ;; (function sound-id int) -(define-extern sound-stop "Stops a sound identified by the given id" (function sound-id int)) -;; (define-extern sound-continue function) ;; (function sound-id int) +(define-extern sound-pause (function sound-id int)) +(define-extern sound-stop (function sound-id int)) +(define-extern sound-continue (function sound-id int)) (define-extern sound-group-pause (function sound-group int)) -;; (define-extern sound-group-stop function) ;; (function sound-group int) +(define-extern sound-group-stop (function sound-group int)) (define-extern sound-group-continue (function sound-group int)) -;; (define-extern sound-set-flava function) ;; (function uint int) -;; (define-extern sound-set-midi-reg function) -;; (define-extern sound-set-fps function) ;; (function int int) -;; (define-extern sound-volume-off function) ;; (function int) -;; (define-extern *ambient-spec* sound-spec) ;; sound-spec +(define-extern sound-set-flava (function uint uint int)) +(define-extern sound-set-midi-reg (function int int int)) +(define-extern sound-set-fps (function int int)) +(define-extern sound-volume-off (function int)) +(define-extern *ambient-spec* sound-spec) (define-extern show-iop-info (function dma-buffer int)) (define-extern show-iop-memory (function dma-buffer int)) -(define-extern ear-trans (function vector)) -;; (define-extern make-sqrt-table function) ;; (function int) -;; (define-extern loader-test-command function) -;; (define-extern doppler-pitch-shift function) -;; (define-extern sound-bank-reload function) +(define-extern ear-trans (function int vector)) +(define-extern make-sqrt-table (function int)) +(define-extern loader-test-command (function sound-command uint none)) +(define-extern doppler-pitch-shift (function vector vector float)) +(define-extern sound-bank-reload (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; transformq ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern transformq-copy! function) ;; (function transformq transformq transformq) +(define-extern transformq-copy! (function transformq transformq transformq)) (define-extern matrix<-transformq! (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<-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) +(define-extern matrix<-transformq+rot-offset! (function matrix transformq vector matrix)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-func ;; diff --git a/decompiler/config/jak2/anonymous_function_types.jsonc b/decompiler/config/jak2/anonymous_function_types.jsonc index 30d69fd0ec..58634d2129 100644 --- a/decompiler/config/jak2/anonymous_function_types.jsonc +++ b/decompiler/config/jak2/anonymous_function_types.jsonc @@ -36,5 +36,9 @@ "level": [ [5, "(function none)"], [24, "(function level-group int symbol)"] + ], + + "gsound": [ + [1, "(function none)"] ] } diff --git a/decompiler/config/jak2/stack_structures.jsonc b/decompiler/config/jak2/stack_structures.jsonc index 2365acc1aa..1416e90ac6 100644 --- a/decompiler/config/jak2/stack_structures.jsonc +++ b/decompiler/config/jak2/stack_structures.jsonc @@ -164,5 +164,18 @@ "(method 9 mood-control)": [[16, "mood-control-work "]], + "string->sound-name": [[16, "qword"]], + + "doppler-pitch-shift": [ + [16, ["inline-array", "vector", 2]] + ], + + "(anon-function 1 gsound)": [ + [16, ["array", "symbol", 4]], + [32, ["array", "symbol", 4]] + ], + "matrix<-parented-transformq!": [[16, "vector"]], + + "placeholder-do-not-add-below!": [] } diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index cd879cf932..36ddce3b01 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -496,7 +496,6 @@ ], "update-mood-ruins": [[[30, 46], "gp", "(pointer float)"]], "update-mood-strip": [[[63, 80], "s4", "(pointer float)"]], - "placeholder-do-not-add-below": [], "update-mood-ctysluma": [[[23, 81], "gp", "(pointer float)"]], "update-mood-ctyslumb": [[[19, 59], "s5", "(pointer float)"]], "update-mood-ctyslumc": [[[19, 47], "s5", "(pointer float)"]], @@ -510,5 +509,94 @@ "update-mood-nest": [[[21, 74], "s5", "(pointer float)"]], "update-mood-village1": [[[21, 66], "gp", "(pointer float)"]], "update-mood-consite": [[[84, 110], "s4", "(pointer float)"]], - "desaturate-mood-colors": [[[20, 92], "a0", "(inline-array mood-color)"]] + "desaturate-mood-colors": [[[20, 92], "a0", "(inline-array mood-color)"]], + "ramdisk-load": [ + [[7, 12], "v1", "ramdisk-rpc-load"] + ], + "(method 10 engine-sound-pers)": [ + [[2, 19], "v1", "sound-rpc-set-param"] + ], + + "check-irx-version": [ + [[3, 51], "gp", "sound-rpc-get-irx-version"] + ], + + "sound-bank-iop-store": [ + [[7, 11], "v1", "sound-rpc-bank-cmd"] + ], + "sound-bank-iop-free": [ + [[7, 12], "v1", "sound-rpc-bank-cmd"] + ], + "sound-bank-load": [ + [[7, 12], "v1", "sound-rpc-load-bank"] + ], + "sound-bank-load-from-iop": [ + [[7, 12], "v1", "sound-rpc-load-bank"] + ], + "sound-bank-load-from-ee": [ + [[8, 14], "v1", "sound-rpc-load-bank"] + ], + "sound-bank-unload": [ + [[6, 11], "v1", "sound-rpc-unload-bank"] + ], + "sound-music-load": [ + [[6, 11], "v1", "sound-rpc-load-music"] + ], + "sound-music-unload": [ + [[3, 8], "v1", "sound-rpc-unload-music"] + ], + "set-language": [ + [[7, 12], "v1", "sound-rpc-set-language"] + ], + "sound-set-stereo-mode": [ + [[4, 9], "v1", "sound-rpc-set-stereo-mode"] + ], + "list-sounds": [ + [[3, 7], "v1", "sound-rpc-list-sounds"] + ], + "string->sound-name": [[[2, 18], "a1", "(pointer uint8)"]], + "sound-set-volume": [[[3, 16], "v1", "sound-rpc-set-master-volume"]], + "sound-set-reverb": [[[5, 25], "v1", "sound-rpc-set-reverb"]], + "sound-set-ear-trans": [[[7, 26], "gp", "sound-rpc-set-ear-trans"]], + "sound-play-by-name": [ + [[12, 45], "s5", "sound-rpc-play"], + [[22, 39], "s3", "process-drawable"] + ], + "sound-play-by-spec": [ + [[4, 54], "s5", "sound-rpc-play"], + [[31, 47], "s3", "process-drawable"] + ], + "sound-pause": [[[3, 8], "v1", "sound-rpc-pause-sound"]], + "sound-stop": [[[3, 8], "v1", "sound-rpc-stop-sound"]], + "sound-continue": [[[3, 8], "v1", "sound-rpc-continue-sound"]], + "sound-group-pause": [[[3, 7], "v1", "sound-rpc-pause-group"]], + "sound-group-stop": [[[3, 7], "v1", "sound-rpc-stop-group"]], + "sound-group-continue": [[[3, 7], "v1", "sound-rpc-continue-group"]], + "sound-set-flava": [[[3, 10], "v1", "sound-rpc-set-flava"]], + "sound-set-midi-reg": [[[3, 10], "v1", "sound-rpc-set-midi-reg"]], + "sound-set-fps": [[[3, 10], "v1", "sound-rpc-set-fps"]], + "(method 0 ambient-sound)": [ + [121, "v1", "sound-spec"], + [125, "v1", "sound-spec"], + [128, "v1", "sound-spec"], + [132, "v1", "sound-spec"], + // [143, "v1", "sound-spec"], + // [140, "v1", "sound-spec"], + // [147, "v1", "sound-spec"], + ["_stack_", 16, "sound-spec"], + ["_stack_", 32, "sound-name"], + ["_stack_", 48, "(pointer float)"], + // ["_stack_", 52, "sound-play-parms"], + ["_stack_", 64, "res-tag"] + ], + "(method 11 ambient-sound)": [ + [[18, 33], "s4", "process-drawable"], + [[11, 47], "s5", "sound-rpc-set-param"] + ], + "(method 12 ambient-sound)": [[[7, 22], "v1", "sound-rpc-set-param"]], + "(method 13 ambient-sound)": [[[7, 23], "v1", "sound-rpc-set-param"]], + "loader-test-command": [[[5, 10], "v1", "sound-rpc-test-cmd"]], + "(anon-function 1 gsound)": [[[0, 45], "gp", "(array symbol)"]], + "sound-buffer-dump": [[[12, 39], "s3", "sound-rpc-play"]], + "placeholder-do-not-add-below": [] } diff --git a/goal_src/jak2/engine/camera/cam-interface-h.gc b/goal_src/jak2/engine/camera/cam-interface-h.gc index c80ced9d9a..c7ae89403a 100644 --- a/goal_src/jak2/engine/camera/cam-interface-h.gc +++ b/goal_src/jak2/engine/camera/cam-interface-h.gc @@ -15,3 +15,4 @@ (define-perm *camera-combiner* camera-combiner #f) +(define-extern math-camera-pos (function vector)) diff --git a/goal_src/jak2/engine/collide/collide-shape-h.gc b/goal_src/jak2/engine/collide/collide-shape-h.gc index 2f9a59508b..529570bc58 100644 --- a/goal_src/jak2/engine/collide/collide-shape-h.gc +++ b/goal_src/jak2/engine/collide/collide-shape-h.gc @@ -450,6 +450,7 @@ :size-assert #x1dc :flag-assert #x44000001dc (:methods + (new (symbol type process-drawable collide-list-enum) _type_ 0) (collide-shape-moving-method-55 () none 55) (collide-shape-moving-method-56 () none 56) (collide-shape-moving-method-57 () none 57) diff --git a/goal_src/jak2/engine/collide/collide-touch-h.gc b/goal_src/jak2/engine/collide/collide-touch-h.gc index ffbb4a30cb..58336dedd4 100644 --- a/goal_src/jak2/engine/collide/collide-touch-h.gc +++ b/goal_src/jak2/engine/collide/collide-touch-h.gc @@ -43,6 +43,7 @@ :size-assert #x3c10 :flag-assert #xd00003c10 (:methods + (new (symbol type) _type_ 0) (touching-prims-entry-pool-method-9 () none 9) (touching-prims-entry-pool-method-10 () none 10) (init-list! (_type_) none 11) @@ -113,6 +114,7 @@ :size-assert #x408 :flag-assert #xe00000408 (:methods + (new (symbol type) _type_ 0) (touching-list-method-9 () none 9) (touching-list-method-10 () none 10) (touching-list-method-11 () none 11) diff --git a/goal_src/jak2/engine/engine/connect.gc b/goal_src/jak2/engine/engine/connect.gc index dece2c30fc..c27d5f51c8 100644 --- a/goal_src/jak2/engine/engine/connect.gc +++ b/goal_src/jak2/engine/engine/connect.gc @@ -609,7 +609,7 @@ (:methods (new (symbol type symbol int type) _type_ 0) (schedule-callback (_type_ object time-frame) connection-pers 9) - (kill-callback (_type_) none 10) + (kill-callback (_type_ connection-pers) none 10) (kill-by-key (_type_ object) none 11) (kill-matching (_type_ (function engine-pers connection-pers object object symbol) object object) none 12) (update-callback (_type_) none 13) @@ -617,6 +617,7 @@ ) ) + (defmethod new engine-pers ((allocation symbol) (type-to-make type) (arg0 symbol) (arg1 int) (arg2 type)) (let ((v0-0 (object-new allocation @@ -683,7 +684,7 @@ v0-0 ) -(defmethod kill-callback engine-pers ((obj engine-pers)) +(defmethod kill-callback engine-pers ((obj engine-pers) (arg0 connection-pers)) "Called when a connection is removed." 0 (none) @@ -708,7 +709,7 @@ (set! s4-0 (&-> s2-0 next)) ) (else - (kill-callback obj) + (kill-callback obj s2-0) (set! (-> s4-0 0) (-> s2-0 next)) (set! (-> s2-0 next) (-> obj dead-list)) (set! (-> obj dead-list) s2-0) @@ -739,7 +740,7 @@ (set! s2-0 (&-> s0-0 next)) ) (else - (kill-callback obj) + (kill-callback obj s0-0) (set! (-> s2-0 0) (-> s0-0 next)) (set! (-> s0-0 next) (-> obj dead-list)) (set! (-> obj dead-list) s0-0) @@ -771,7 +772,7 @@ (set! s2-0 (&-> s1-0 next)) ) (else - (kill-callback obj) + (kill-callback obj s1-0) (set! (-> s2-0 0) (-> s1-0 next)) (set! (-> s1-0 next) (-> obj dead-list)) (set! (-> obj dead-list) s1-0) diff --git a/goal_src/jak2/engine/game/fact-h.gc b/goal_src/jak2/engine/game/fact-h.gc index 4192fc717d..fd51775599 100644 --- a/goal_src/jak2/engine/game/fact-h.gc +++ b/goal_src/jak2/engine/game/fact-h.gc @@ -256,6 +256,7 @@ :size-assert #x110 :flag-assert #xd00000110 (:methods + (new (symbol type process pickup-type float) _type_ 0) (fact-info-target-method-12 () none 12) ) ) @@ -286,6 +287,9 @@ (deftype fact-info-crate (fact-info) ((suck-count int32 :offset-assert 40) ) + (:methods + (new (symbol type process pickup-type float) _type_ 0) + ) :method-count-assert 12 :size-assert #x2c :flag-assert #xc0000002c diff --git a/goal_src/jak2/engine/game/game-info-h.gc b/goal_src/jak2/engine/game/game-info-h.gc index d187d5f0f0..c2491f9d0a 100644 --- a/goal_src/jak2/engine/game/game-info-h.gc +++ b/goal_src/jak2/engine/game/game-info-h.gc @@ -141,7 +141,7 @@ (reset! (_type_) _type_ 9) (update! (_type_) int 10) (want-levels (_type_ (pointer symbol)) int 11) - (load-state-method-12 () none 12) + (want-sound-banks (_type_ (pointer symbol)) none 12) (want-display-level (_type_ symbol symbol) int 13) (want-vis-level (_type_ symbol) none 14) (load-state-method-15 () none 15) diff --git a/goal_src/jak2/engine/game/main-h.gc b/goal_src/jak2/engine/game/main-h.gc index be1d877a98..7b816827b3 100644 --- a/goal_src/jak2/engine/game/main-h.gc +++ b/goal_src/jak2/engine/game/main-h.gc @@ -213,3 +213,4 @@ (= arg0 *debug-actor*) ) +(define-extern movie? (function symbol)) diff --git a/goal_src/jak2/engine/game/settings-h.gc b/goal_src/jak2/engine/game/settings-h.gc index c2fe7a9d35..12ef53bb5f 100644 --- a/goal_src/jak2/engine/game/settings-h.gc +++ b/goal_src/jak2/engine/game/settings-h.gc @@ -423,7 +423,7 @@ (new (symbol type int) _type_ 0) (setting-control-method-9 () none 9) (setting-control-method-10 () none 10) - (setting-control-method-11 () none 11) + (set-setting (_type_ process symbol object object object) none 11) (setting-control-method-12 () none 12) (setting-control-method-13 () none 13) (setting-control-method-14 () none 14) @@ -446,3 +446,32 @@ ) ) +;; DECOMP ENDS +(define-extern *setting-control* setting-control) + + +(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) + ) \ No newline at end of file diff --git a/goal_src/jak2/engine/gfx/font-h.gc b/goal_src/jak2/engine/gfx/font-h.gc index 5e5d1a4e1c..654f034cec 100644 --- a/goal_src/jak2/engine/gfx/font-h.gc +++ b/goal_src/jak2/engine/gfx/font-h.gc @@ -11,7 +11,7 @@ (defenum font-color :type uint32 - (zero 0) + (default 0) (one 1) (orange-red 3) ) diff --git a/goal_src/jak2/engine/gfx/hw/display.gc b/goal_src/jak2/engine/gfx/hw/display.gc index 504a6c3b4d..6951a91d15 100644 --- a/goal_src/jak2/engine/gfx/hw/display.gc +++ b/goal_src/jak2/engine/gfx/hw/display.gc @@ -80,7 +80,7 @@ ) (define *font-context* - (new 'global 'font-context *font-default-matrix* 0 0 0.0 (font-color zero) (font-flags shadow kerning)) + (new 'global 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning)) ) (defun draw-sprite2d-xy ((arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 int) (arg4 int) (arg5 rgba)) diff --git a/goal_src/jak2/engine/load/load-dgo.gc b/goal_src/jak2/engine/load/load-dgo.gc index 7464cd1e19..e981243875 100644 --- a/goal_src/jak2/engine/load/load-dgo.gc +++ b/goal_src/jak2/engine/load/load-dgo.gc @@ -5,5 +5,366 @@ ;; name in dgo: load-dgo ;; dgos: ENGINE, GAME +;; status flag sent from OVERLORD about a DGO load. +(defenum load-msg-result + :type uint16 + :bitfield #f + (done 0) ;; dgo fully loaded! + (error 1) ;; loading failed (file not found, etc) + (more 2) ;; more files exist! + (aborted 3) ;; status returned after a request to cancel. + (invalid 666) ;; invalid status indicating a communication error. + ) + ;; DECOMP BEGINS +(deftype load-dgo-msg (structure) + ((rsvd uint16 :offset-assert 0) + (result load-msg-result :offset-assert 2) + (b1 pointer :offset-assert 4) + (b2 pointer :offset-assert 8) + (bt pointer :offset-assert 12) + (name uint128 :offset-assert 16) + (address uint32 :offset 4) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +(deftype load-chunk-msg (structure) + ((rsvd uint16 :offset-assert 0) + (result load-msg-result :offset-assert 2) + (address pointer :offset-assert 4) + (section uint32 :offset-assert 8) + (maxlen uint32 :offset-assert 12) + (dummy uint32 4 :offset-assert 16) + (basename sound-stream-name :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + ) + +(deftype play-chunk-msg (structure) + ((rsvd uint16 :offset-assert 0) + (result uint16 :offset-assert 2) + (address pointer :offset-assert 4) + (section uint32 :offset-assert 8) + (maxlen uint32 :offset-assert 12) + (id uint32 4 :offset-assert 16) + (basename sound-stream-name 4 :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #xe0 + :flag-assert #x9000000e0 + ) + +(deftype dgo-header (structure) + ((length uint32 :offset-assert 0) + (rootname uint8 60 :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x40 + :flag-assert #x900000040 + ) + +(define-extern *load-dgo-rpc* rpc-buffer-pair) +(when (zero? *load-dgo-rpc*) + (define *load-dgo-rpc* (new 'global 'rpc-buffer-pair (the-as uint 32) (the-as uint 1) 3)) + (define *load-str-rpc* (new 'global 'rpc-buffer-pair (the-as uint 64) (the-as uint 1) 4)) + (define *play-str-rpc* (new 'global 'rpc-buffer-pair (the-as uint 256) (the-as uint 2) 5)) + (define *load-str-lock* #f) + (define *que-str-lock* #f) + (define *dgo-name* (new 'global 'string 64 (the-as string #f))) + ) + +(defun str-load ((arg0 string) (arg1 int) (arg2 pointer) (arg3 int)) + (if (or (check-busy *load-str-rpc*) *load-str-lock*) + (return #f) + ) + (let ((s2-0 (the-as load-chunk-msg (add-element *load-str-rpc*)))) + (set! (-> s2-0 result) (load-msg-result invalid)) + (set! (-> s2-0 address) arg2) + (set! (-> s2-0 section) (the-as uint arg1)) + (set! (-> s2-0 maxlen) (the-as uint arg3)) + (copyn-charp<-string (the-as (pointer uint8) (-> s2-0 basename)) arg0 48) + (call *load-str-rpc* (the-as uint 0) (the-as pointer s2-0) (the-as uint 32)) + ) + (set! *load-str-lock* #t) + (set! *que-str-lock* #t) + #t + ) + +(defun str-load-status ((arg0 (pointer int32))) + (if (check-busy *load-str-rpc*) + (return 'busy) + ) + (set! *load-str-lock* #f) + (set! *que-str-lock* #t) + (let ((v1-7 (the-as load-chunk-msg (pop-last-received *load-str-rpc*)))) + (if (= (-> v1-7 result) (load-msg-result error)) + (return 'error) + ) + (set! (-> arg0 0) (the-as int (-> v1-7 maxlen))) + ) + 'complete + ) + +(defun str-load-cancel () + (set! *load-str-lock* #f) + (set! *que-str-lock* #t) + 0 + (none) + ) + +(defun str-play-async ((arg0 string) (arg1 sound-id)) + (set! *que-str-lock* #t) + (let ((s4-0 (the-as play-chunk-msg (add-element *play-str-rpc*)))) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename)) arg0 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 1)) "" 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 2)) "" 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 3)) "" 48) + (set! (-> s4-0 id 0) (the-as uint arg1)) + (set! (-> s4-0 id 1) (the-as uint 0)) + (set! (-> s4-0 id 2) (the-as uint 0)) + (set! (-> s4-0 id 3) (the-as uint 0)) + (set! (-> s4-0 result) (the-as uint 0)) + ) + 0 + 0 + (none) + ) + +(defun str-play-stop ((arg0 string) (arg1 sound-id)) + (set! *que-str-lock* #t) + (let ((s4-0 (the-as play-chunk-msg (add-element *play-str-rpc*)))) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename)) arg0 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 1)) "" 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 2)) "" 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 3)) "" 48) + (set! (-> s4-0 id 0) (the-as uint arg1)) + (set! (-> s4-0 id 1) (the-as uint 0)) + (set! (-> s4-0 id 2) (the-as uint 0)) + (set! (-> s4-0 id 3) (the-as uint 0)) + (set! (-> s4-0 result) (the-as uint 1)) + ) + 0 + (none) + ) + +(defun str-play-queue ((arg0 string) (arg1 string) (arg2 string) (arg3 string) (arg4 (pointer uint32)) (arg5 pointer)) + (when (and (not (check-busy *play-str-rpc*)) (not *load-str-lock*) (not *que-str-lock*)) + (let ((s4-0 (the-as play-chunk-msg (add-element *play-str-rpc*)))) + (if arg0 + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename)) arg0 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename)) "" 48) + ) + (if arg1 + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 1)) arg1 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 1)) "" 48) + ) + (if arg2 + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 2)) arg2 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 2)) "" 48) + ) + (if arg3 + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 3)) arg3 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 3)) "" 48) + ) + (dotimes (v1-15 4) + (set! (-> s4-0 id v1-15) (-> arg4 v1-15)) + ) + (set! (-> s4-0 address) arg5) + (set! (-> s4-0 result) (the-as uint 2)) + ) + ) + (set! *que-str-lock* #f) + 0 + (none) + ) + +(defun str-ambient-play ((arg0 string)) + (set! *que-str-lock* #t) + (let ((s5-0 (the-as load-chunk-msg (add-element *play-str-rpc*)))) + (set! (-> s5-0 basename name 0) (the-as uint 36)) + (copyn-charp<-string (&-> s5-0 basename name 1) arg0 48) + (set! (-> s5-0 result) (load-msg-result done)) + ) + 0 + 0 + (none) + ) + +(defun str-ambient-stop ((arg0 string)) + (set! *que-str-lock* #t) + (let ((s5-0 (the-as load-chunk-msg (add-element *play-str-rpc*)))) + (set! (-> s5-0 basename name 0) (the-as uint 36)) + (copyn-charp<-string (&-> s5-0 basename name 1) arg0 48) + (set! (-> s5-0 result) (load-msg-result error)) + ) + 0 + (none) + ) + +(defun str-play-kick () + (cond + ((check-busy *play-str-rpc*) + ) + (else + (call *play-str-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + ) + ) + 0 + (none) + ) + +(define *dgo-time* (the-as time-frame 0)) + +(defun dgo-load-begin ((arg0 string) (arg1 pointer) (arg2 pointer) (arg3 pointer)) + (set! *dgo-time* (the-as time-frame (-> *display* real-clock integral-frame-counter))) + (format 0 "Starting level load clock~%") + (sync *load-dgo-rpc* #t) + (let ((s2-0 (the-as load-dgo-msg (add-element *load-dgo-rpc*)))) + (set! (-> s2-0 result) (load-msg-result invalid)) + (set! (-> s2-0 b1) arg1) + (set! (-> s2-0 b2) arg2) + (set! (-> s2-0 bt) arg3) + (set! (-> s2-0 name) (string->sound-name arg0)) + (call *load-dgo-rpc* (the-as uint 0) (the-as pointer s2-0) (the-as uint 32)) + s2-0 + ) + ) + +(defun dgo-load-get-next ((arg0 (pointer symbol))) + (set! (-> arg0 0) #f) + (let ((gp-0 (the-as pointer #f))) + (when (not (check-busy *load-dgo-rpc*)) + (let ((v1-4 (the-as load-dgo-msg (pop-last-received *load-dgo-rpc*)))) + (when v1-4 + (when (or (= (-> v1-4 result) (load-msg-result done)) (= (-> v1-4 result) (load-msg-result more))) + (set! gp-0 (-> v1-4 b1)) + (set! (-> arg0 0) #t) + ) + (if (= (-> v1-4 result) (load-msg-result more)) + (set! (-> arg0 0) #f) + ) + (if (= (-> v1-4 result) (load-msg-result done)) + (format + 0 + "Elapsed time for level = ~Fs~%" + (* 0.016666668 (the float (- (-> *display* real-clock integral-frame-counter) (the-as uint *dgo-time*)))) + ) + ) + ) + ) + ) + gp-0 + ) + ) + +(defun dgo-load-continue ((arg0 pointer) (arg1 pointer) (arg2 pointer)) + (let ((gp-0 (the-as load-dgo-msg (add-element *load-dgo-rpc*)))) + (set! (-> gp-0 result) (load-msg-result invalid)) + (set! (-> gp-0 b1) arg0) + (set! (-> gp-0 b2) arg1) + (set! (-> gp-0 bt) arg2) + (set! (-> gp-0 name) (the-as uint128 0)) + (call *load-dgo-rpc* (the-as uint 1) (the-as pointer gp-0) (the-as uint 32)) + gp-0 + ) + ) + +(defun dgo-load-cancel () + (sync *load-dgo-rpc* #t) + (let ((a2-0 (add-element *load-dgo-rpc*))) + (call *load-dgo-rpc* (the-as uint 2) a2-0 (the-as uint 32)) + ) + 0 + (none) + ) + +(defun find-temp-buffer ((arg0 int)) + (let ((gp-0 (+ (/ arg0 16) 2))) + (cond + ((< (the-as uint gp-0) + (the-as uint (dma-buffer-free (-> *display* frames (-> *display* on-screen) global-buf))) + ) + (logand -16 (&+ (-> *display* frames (-> *display* on-screen) global-buf base) 15)) + ) + ((< (the-as uint gp-0) + (the-as uint (dma-buffer-free (-> *display* frames (-> *display* on-screen) global-buf))) + ) + (logand -16 (&+ (-> *display* frames (-> *display* on-screen) global-buf base) 15)) + ) + ) + ) + ) + +(defun dgo-load-link ((arg0 dgo-header) (arg1 kheap) (arg2 uint) (arg3 symbol) (arg4 symbol)) + (let ((s4-0 (the-as object (&+ arg0 64)))) + (let ((v1-0 arg2)) + (cond + ((>= (the-as int (+ (the-as uint s4-0) (-> arg0 length))) (the-as int (-> arg1 top-base))) + (format + 0 + "ERROR: -----> dgo file header ~g #x~X has overrun heap #x~X by ~D bytes. This is very bad!~%" + (-> arg0 rootname) + arg0 + arg1 + (- (+ (the-as uint s4-0) (-> arg0 length)) (the-as uint (-> arg1 top-base))) + ) + ) + ((and (< (the-as int arg0) (the-as int v1-0)) + (>= (the-as int (+ (the-as uint s4-0) (-> arg0 length))) (the-as int v1-0)) + ) + (format + 0 + "ERROR: -----> dgo file header ~g #x~X has overrun heap #x~X by ~D bytes. This is very bad!~%" + (-> arg0 rootname) + arg0 + arg1 + (- (+ (the-as uint s4-0) (-> arg0 length)) v1-0) + ) + ) + ) + ) + (if arg4 + (format + 0 + "NOTICE: loaded ~g, ~D bytes (~f K) at top ~D at #x~X~%" + (-> arg0 rootname) + (-> arg0 length) + (* 0.0009765625 (the float (-> arg0 length))) + (- (+ (the-as uint s4-0) (-> arg0 length)) (the-as uint (-> arg1 base))) + arg0 + ) + ) + (string<-charp (clear *dgo-name*) (-> arg0 rootname)) + (nonzero? (link-begin + (the-as pointer s4-0) + (-> *dgo-name* data) + (the-as int (-> arg0 length)) + arg1 + (the-as link-flag (if arg3 + 47 + 39 + ) + ) + ) + ) + ) + ) + +(defun destroy-mem ((arg0 (pointer uint32)) (arg1 (pointer uint32))) + (while (< (the-as int arg0) (the-as int arg1)) + (set! (-> arg0 0) (the-as uint #xffffffff)) + (set! arg0 (&-> arg0 1)) + ) + 0 + (none) + ) + + + + diff --git a/goal_src/jak2/engine/load/ramdisk.gc b/goal_src/jak2/engine/load/ramdisk.gc index 32738daa3a..2eb804f0fc 100644 --- a/goal_src/jak2/engine/load/ramdisk.gc +++ b/goal_src/jak2/engine/load/ramdisk.gc @@ -7,3 +7,57 @@ ;; DECOMP BEGINS +(deftype ramdisk-rpc-fill (structure) + ((rsvd1 int32 :offset-assert 0) + (ee-id int32 :offset-assert 4) + (rsvd2 int32 2 :offset-assert 8) + (filename uint128 :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +(deftype ramdisk-rpc-load (structure) + ((rsvd int32 :offset-assert 0) + (ee-id int32 :offset-assert 4) + (offset uint32 :offset-assert 8) + (length uint32 :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(deftype ramdisk-rpc-load-to-ee (structure) + ((rsvd int32 :offset-assert 0) + (addr int32 :offset-assert 4) + (offset int32 :offset-assert 8) + (length int32 :offset-assert 12) + (filename uint128 :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +(define *ramdisk-rpc* (new 'global 'rpc-buffer-pair (the-as uint 32) (the-as uint 1) 2)) + +(define *current-ramdisk-id* 0) + +(defun ramdisk-load ((arg0 int) (arg1 uint) (arg2 uint) (arg3 pointer)) + (let ((v1-1 (the-as ramdisk-rpc-load (add-element *ramdisk-rpc*)))) + (set! (-> v1-1 offset) arg1) + (set! (-> v1-1 ee-id) arg0) + (set! (-> v1-1 length) arg2) + ) + (call *ramdisk-rpc* (the-as uint 0) arg3 arg2) + 0 + ) + +(defun ramdisk-sync () + (sync *ramdisk-rpc* #t) + 0 + (none) + ) + diff --git a/goal_src/jak2/engine/math/transformq-h.gc b/goal_src/jak2/engine/math/transformq-h.gc index 0c3ecc7229..2951b42b97 100644 --- a/goal_src/jak2/engine/math/transformq-h.gc +++ b/goal_src/jak2/engine/math/transformq-h.gc @@ -64,7 +64,7 @@ (set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion 14) (set-roll-to-grav! (_type_ float) quaternion 15) (set-roll-to-grav-2! (_type_ float) quaternion 16) - (rotate-toward-orientation! (_type_ quaternion float float) quaternion 17) + (rotate-toward-orientation! (_type_ quaternion float float int float float) quaternion 17) (set-quaternion! (_type_ quaternion) quaternion 18) (set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion 19) (point-toward-point-clear-roll-pitch! (_type_ vector) quaternion 20) diff --git a/goal_src/jak2/engine/math/transformq.gc b/goal_src/jak2/engine/math/transformq.gc index 5cef27b03d..683bf104e6 100644 --- a/goal_src/jak2/engine/math/transformq.gc +++ b/goal_src/jak2/engine/math/transformq.gc @@ -7,3 +7,472 @@ ;; DECOMP BEGINS +(defmethod print transformq ((obj transformq)) + "Print a transformq" + (format #t "# obj trans x) (-> obj trans y) (-> obj trans z) (-> obj trans w)) + (format #t "~T~Tquat: ~F ~F ~F ~F ~%" (-> obj quat x) (-> obj quat y) (-> obj quat z) (-> obj quat w)) + (format #t "~T~Tscale:~F ~F ~F ~F>" (-> obj scale x) (-> obj scale y) (-> obj scale z) (-> obj scale w)) + obj + ) + +(defmethod get-quaternion trsqv ((obj trsqv)) + "Get the rotation as a quaternion." + (-> obj quat) + ) + +(defmethod set-quaternion! trsqv ((obj trsqv) (arg0 quaternion)) + "Set the rotation as a quaternion" + (quaternion-copy! (get-quaternion obj) arg0) + ) + +(defmethod rot->dir-targ! trsqv ((obj trsqv)) + "Set the dir-targ to our current orientation" + (quaternion-copy! (-> obj dir-targ) (get-quaternion obj)) + ) + +(defmethod y-angle trsqv ((obj trsqv)) + "Get our current y-angle (y is up, so yaw)" + (quaternion-y-angle (get-quaternion obj)) + ) + +(defmethod seek-toward-heading-vec! trsqv ((obj trsqv) (arg0 vector) (arg1 float) (arg2 time-frame)) + "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" + (with-pp + (let* ((f0-0 (deg-diff (quaternion-y-angle (-> obj quat)) (vector-y-angle arg0))) + (f1-2 (fmin (* arg1 (-> pp clock seconds-per-frame)) (/ (* 5.0 (fabs f0-0)) (the float arg2)))) + (f30-0 (fmax (fmin f0-0 f1-2) (- f1-2))) + ) + (let ((f0-2 (-> obj old-y-angle-diff))) + (set! f30-0 (cond + ((or (= f0-2 0.0) + (and (< 0.0 f30-0) (< 0.0 f0-2)) + (or (and (< f30-0 0.0) (< f0-2 0.0)) + (>= (- (-> pp clock frame-counter) (-> obj angle-change-time)) (seconds 0.2)) + ) + ) + (set! (-> obj angle-change-time) (-> pp clock frame-counter)) + f30-0 + ) + (else + (* 0.000000001 f30-0) + ) + ) + ) + ) + (set! (-> obj old-y-angle-diff) f30-0) + (let ((a1-2 (get-quaternion obj))) + (quaternion-rotate-y! a1-2 a1-2 f30-0) + ) + ) + ) + ) + +(defmethod set-heading-vec! trsqv ((obj trsqv) (arg0 vector)) + "Makes us look in the arg0 direction immediately. Pitch will be unchanged." + (let ((s3-0 (get-quaternion obj))) + (forward-up-nopitch->quaternion + s3-0 + (vector-normalize-copy! (new 'stack-no-clear 'vector) arg0 1.0) + (vector-y-quaternion! (new 'stack-no-clear 'vector) s3-0) + ) + ) + ) + +(defmethod seek-to-point-toward-point! trsqv ((obj trsqv) (arg0 vector) (arg1 float) (arg2 time-frame)) + "Seek toward pointing toward arg0 from our current location." + (seek-toward-heading-vec! obj (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj trans)) arg1 arg2) + ) + +(defmethod point-toward-point! trsqv ((obj trsqv) (arg0 vector)) + "Immediately point toward arg0" + (let ((s3-0 (get-quaternion obj))) + (forward-up-nopitch->quaternion + s3-0 + (vector-normalize! (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj trans)) 1.0) + (vector-y-quaternion! (new 'stack-no-clear 'vector) s3-0) + ) + ) + ) + +(defmethod seek-toward-yaw-angle! trsqv ((obj trsqv) (arg0 float) (arg1 float) (arg2 time-frame)) + "Seek toward the given yaw angle." + (let ((s3-0 (method-of-object obj seek-toward-heading-vec!)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s2-0 x) (sin arg0)) + (set! (-> s2-0 y) 0.0) + (set! (-> s2-0 z) (cos arg0)) + (set! (-> s2-0 w) 1.0) + (s3-0 obj s2-0 arg1 arg2) + ) + ) + +(defmethod set-yaw-angle-clear-roll-pitch! trsqv ((obj trsqv) (arg0 float)) + "Immediately clear our roll and pitch and set yaw to the given angle" + (let ((s5-0 (method-of-object obj set-heading-vec-clear-roll-pitch!)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s4-0 x) (sin arg0)) + (set! (-> s4-0 y) 0.0) + (set! (-> s4-0 z) (cos arg0)) + (set! (-> s4-0 w) 1.0) + (s5-0 obj s4-0) + ) + ) + +(defmethod set-roll-to-grav! trsqv ((obj trsqv) (arg0 float)) + "Set our roll so that our local down aligns with standard gravity" + (set-roll-to-grav-2! obj arg0) + ) + +(defmethod set-roll-to-grav-2! trsqv ((obj trsqv) (arg0 float)) + "Set our roll so that our local down aligns with standard gravity" + (let* ((s5-0 (get-quaternion obj)) + (s1-0 (-> *standard-dynamics* gravity-normal)) + (s3-0 (quaternion->matrix (new 'stack-no-clear 'matrix) s5-0)) + ) + (let ((s4-0 (&-> s3-0 data 8))) + (vector-normalize! (vector-flatten! (the-as vector (&-> s3-0 data 4)) s1-0 (the-as vector s4-0)) 1.0) + (vector-cross! (the-as vector (-> s3-0 data)) (the-as vector (&-> s3-0 data 4)) (the-as vector s4-0)) + ) + (let ((a1-5 (matrix-rotate-z! (new 'stack-no-clear 'matrix) arg0))) + (matrix*! s3-0 a1-5 s3-0) + ) + (matrix->quaternion s5-0 s3-0) + ) + ) + +(defmethod roll-relative-to-gravity trsqv ((obj trsqv)) + "Get our roll, relative to 'down' from gravity" + (let* ((s5-0 (get-quaternion obj)) + (gp-0 (vector-z-quaternion! (new 'stack-no-clear 'vector) s5-0)) + (s5-1 (vector-y-quaternion! (new 'stack-no-clear 'vector) s5-0)) + (a1-2 (-> *standard-dynamics* gravity-normal)) + (v1-2 (vector-normalize! (vector-flatten! (new 'stack-no-clear 'vector) a1-2 gp-0) 1.0)) + (f0-1 (vector-dot v1-2 s5-1)) + ) + (if (< (vector-dot (vector-cross! (new 'stack-no-clear 'vector) v1-2 s5-1) gp-0) 0.0) + (- (acos f0-1)) + (acos f0-1) + ) + ) + ) + +(defmethod rotate-toward-orientation! trsqv ((obj trsqv) (arg0 quaternion) (arg1 float) (arg2 float) (arg3 int) (arg4 float) (arg5 float)) + "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." + (local-vars + (f0-4 float) + (sv-192 (function quaternion vector vector float int quaternion)) + (sv-208 quaternion) + (sv-224 vector) + (sv-240 float) + (sv-256 vector) + (sv-272 vector) + ) + (set! sv-240 arg4) + (let ((s2-0 arg5) + (s5-0 (get-quaternion obj)) + ) + (let ((gp-0 (new 'stack-no-clear 'quaternion))) + (when (< 0.0 arg2) + (set! sv-192 quaternion-from-two-vectors-smooth!) + (set! sv-208 gp-0) + (set! sv-224 (vector-y-quaternion! (new 'stack-no-clear 'vector) s5-0)) + (let ((a2-1 (vector-y-quaternion! (new 'stack-no-clear 'vector) arg0))) + (sv-192 sv-208 sv-224 a2-1 arg2 (the-as int sv-240)) + ) + (quaternion-normalize! (quaternion*! s5-0 gp-0 s5-0)) + ) + (when (< 0.0 arg1) + (set! sv-256 (vector-y-quaternion! (new 'stack-no-clear 'vector) s5-0)) + (let ((s1-2 (vector-z-quaternion! (new 'stack-no-clear 'vector) s5-0))) + (set! sv-272 (vector-z-quaternion! (new 'stack-no-clear 'vector) arg0)) + (let ((s0-1 (new 'stack-no-clear 'matrix))) + (vector-flatten! s1-2 s1-2 sv-256) + (vector-flatten! sv-272 sv-272 sv-256) + (vector-normalize! s1-2 1.0) + (vector-normalize! sv-272 1.0) + (cond + ((!= s2-0 0.0) + (let* ((v1-5 (vector-cross! (new 'stack-no-clear 'vector) s1-2 sv-272)) + ; (f0-3 (-> sv-256 x)) + ; (f1-3 (-> sv-256 y)) + ; (f2-0 (-> sv-256 z)) + ; (f3-0 (-> v1-5 x)) + ; (f4-0 (-> v1-5 y)) + ; (f5-0 (-> v1-5 z)) + ) + (set! f0-4 (vector-dot sv-256 v1-5)) + ; (.mula.s f0-3 f3-0) + ; (.madda.s f1-3 f4-0) + ; (.madd.s f0-4 f2-0 f5-0) + ) + (if (< (* f0-4 s2-0) 0.0) + (matrix-from-two-vectors-the-long-way-smooth! s0-1 s1-2 sv-272 arg1 arg3) + (matrix-from-two-vectors-smooth! s0-1 s1-2 sv-272 arg1 arg3) + ) + ) + (else + (matrix-from-two-vectors-smooth! s0-1 s1-2 sv-272 arg1 arg3) + ) + ) + (matrix->quaternion gp-0 s0-1) + ) + ) + (quaternion-normalize! (quaternion*! s5-0 gp-0 s5-0)) + ) + ) + s5-0 + ) + ) + +(defmethod set-heading-vec-clear-roll-pitch! trsqv ((obj trsqv) (arg0 vector)) + "Set our rotation to point along the given heading, with no roll or pitch." + (forward-up->quaternion + (get-quaternion obj) + (vector-normalize-copy! (new 'stack-no-clear 'vector) arg0 1.0) + (new 'static 'vector :y 1.0 :w 1.0) + ) + ) + +(defmethod point-toward-point-clear-roll-pitch! trsqv ((obj trsqv) (arg0 vector)) + "Set our orientation to point toward arg0, clearing roll and pitch" + (forward-up->quaternion + (get-quaternion obj) + (vector-normalize! (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj trans)) 1.0) + (new 'static 'vector :y 1.0 :w 1.0) + ) + ) + +(defun transformq-copy! ((arg0 transformq) (arg1 transformq)) + "Set arg0 = arg1" + (let ((v1-0 (-> arg1 trans quad)) + (a2-0 (-> arg1 quat vec quad)) + (a1-1 (-> arg1 scale quad)) + ) + (set! (-> arg0 trans quad) v1-0) + (set! (-> arg0 quat vec quad) a2-0) + (set! (-> arg0 scale quad) a1-1) + ) + arg0 + ) + +(defun matrix<-transformq! ((arg0 matrix) (arg1 transformq)) + "Convert to 4x4 affine transform." + (local-vars (v1-1 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (quaternion->matrix arg0 (-> arg1 quat)) + (cond + (#f + (set! (-> arg0 trans quad) (-> arg1 trans quad)) + ) + (else + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf2 (&-> arg1 trans quad)) + (.lvf vf3 (&-> arg0 vector 0 quad)) + (.lvf vf4 (&-> arg0 vector 1 quad)) + (.lvf vf5 (&-> arg0 vector 2 quad)) + (.mov.vf vf2 vf0 :mask #b1000) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf3) + (.svf (&-> arg0 vector 1 quad) vf4) + (.svf (&-> arg0 vector 2 quad) vf5) + (.mov v1-1 vf5) + ) + ) + arg0 + ) + ) + +(defun matrix<-no-trans-transformq! ((arg0 matrix) (arg1 transformq)) + "Create 4x4 affine transform with no translation." + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (quaternion->matrix arg0 (-> arg1 quat)) + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf3 (&-> arg0 vector 0 quad)) + (.lvf vf4 (&-> arg0 vector 1 quad)) + (.lvf vf5 (&-> arg0 vector 2 quad)) + (.mov.vf vf2 vf0) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf3) + (.svf (&-> arg0 vector 1 quad) vf4) + (.svf (&-> arg0 vector 2 quad) vf5) + arg0 + ) + ) + +(defun matrix<-transformq+trans! ((arg0 matrix) (arg1 transformq) (arg2 vector)) + "Convert to affine transform with an additional translation (in the local frame)." + (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) + (quaternion->matrix arg0 (-> arg1 quat)) + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf2 (&-> arg1 trans quad)) + (.lvf vf6 (&-> arg2 quad)) + (.lvf vf3 (&-> arg0 vector 0 quad)) + (.lvf vf4 (&-> arg0 vector 1 quad)) + (.lvf vf5 (&-> arg0 vector 2 quad)) + (.mov.vf vf2 vf0 :mask #b1000) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.mul.x.vf acc vf3 vf6) + (.add.mul.y.vf acc vf4 vf6 acc) + (.add.mul.z.vf acc vf5 vf6 acc) + (.add.mul.w.vf vf2 vf2 vf0 acc :mask #b111) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf3) + (.svf (&-> arg0 vector 1 quad) vf4) + (.svf (&-> arg0 vector 2 quad) vf5) + arg0 + ) + ) + +(defun matrix<-transformq+world-trans! ((arg0 matrix) (arg1 transformq) (arg2 vector)) + "Convert to affine transform with an additional translation in the world frame (not rotated)" + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (quaternion->matrix arg0 (-> arg1 quat)) + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf2 (&-> arg1 trans quad)) + (.lvf vf6 (&-> arg2 quad)) + (.lvf vf3 (&-> arg0 vector 0 quad)) + (.lvf vf4 (&-> arg0 vector 1 quad)) + (.lvf vf5 (&-> arg0 vector 2 quad)) + (.mov.vf vf2 vf0 :mask #b1000) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.add.vf vf2 vf2 vf6 :mask #b111) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf3) + (.svf (&-> arg0 vector 1 quad) vf4) + (.svf (&-> arg0 vector 2 quad) vf5) + arg0 + ) + ) + +(defun matrix<-parented-transformq! ((arg0 matrix) (arg1 transformq) (arg2 vector)) + "Unused. Seems like the parented thing means there's an inverse scale in arg2." + (local-vars (v1-1 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (quaternion->matrix arg0 (-> arg1 quat)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (set! (-> v1-0 x) (/ 1.0 (-> arg2 x))) + (set! (-> v1-0 y) (/ 1.0 (-> arg2 y))) + (set! (-> v1-0 z) (/ 1.0 (-> arg2 z))) + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf2 (&-> arg1 trans quad)) + (.mov.vf vf2 vf0 :mask #b1000) + (.lvf vf4 (&-> arg0 vector 0 quad)) + (.lvf vf5 (&-> arg0 vector 1 quad)) + (.lvf vf6 (&-> arg0 vector 2 quad)) + (.mul.x.vf vf4 vf4 vf1) + (.mul.y.vf vf5 vf5 vf1) + (.mul.z.vf vf6 vf6 vf1) + (.lvf vf3 (&-> v1-0 quad)) + ) + (.mul.vf vf4 vf4 vf3) + (.mul.vf vf5 vf5 vf3) + (.mul.vf vf6 vf6 vf3) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf4) + (.svf (&-> arg0 vector 1 quad) vf5) + (.svf (&-> arg0 vector 2 quad) vf6) + (.mov v1-1 vf6) + arg0 + ) + ) + +(defun matrix<-transformq+rot-offset! ((arg0 matrix) (arg1 transformq) (arg2 vector)) + "Affine transform for a point offset in the destination frame of the transformq (rather than just + adding an offset at the end)" + (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) + (quaternion->matrix arg0 (-> arg1 quat)) + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf2 (&-> arg1 trans quad)) + (.lvf vf6 (&-> arg2 quad)) + (.lvf vf3 (&-> arg0 vector 0 quad)) + (.lvf vf4 (&-> arg0 vector 1 quad)) + (.lvf vf5 (&-> arg0 vector 2 quad)) + (.mov.vf vf2 vf0 :mask #b1000) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.mul.x.vf acc vf3 vf6) + (.add.mul.y.vf acc vf4 vf6 acc) + (.add.mul.z.vf acc vf5 vf6 acc) + (.sub.mul.w.vf acc vf6 vf0 acc) ;; this line is added compared to the +trans! one + (.add.mul.w.vf vf2 vf2 vf0 acc :mask #b111) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf3) + (.svf (&-> arg0 vector 1 quad) vf4) + (.svf (&-> arg0 vector 2 quad) vf5) + arg0 + ) + ) + + + + diff --git a/goal_src/jak2/engine/sound/gsound-h.gc b/goal_src/jak2/engine/sound/gsound-h.gc index 42bfbc0b5b..6fd01dbbe8 100644 --- a/goal_src/jak2/engine/sound/gsound-h.gc +++ b/goal_src/jak2/engine/sound/gsound-h.gc @@ -5,34 +5,59 @@ ;; name in dgo: gsound-h ;; dgos: ENGINE, GAME -;; TODO: methods for ambient-sound. - (defenum sound-command :type uint16 - ; (load-bank) - ; (load-music) - ; (unload-bank) - ; (play) - ; (pause-sound) - ; (stop-sound) - ; (continue-sound) - ; (set-param) - ; (set-master-volume) - ; (pause-group) - ; (stop-group) - ; (continue-group) - ; (get-irx-version) - ; (set-falloff-curve) - ; (set-sound-falloff) - ; (reload-info) - ; (set-language) - ; (set-flava) - ; (set-reverb) - ; (set-ear-trans) - ; (shutdown) - ; (list-sounds) - ; (unload-music) - ; (set-fps) + (iop-store 0) ;; sound-rpc-bank-cmd + (iop-free 1) ;; sound-rpc-bank-cmd + (load-bank 2) ;; sound-rpc-load-bank + (load-bank-from-iop 3) ;; sound-rpc-load-bank + (load-bank-from-ee 4) ;; sound-rpc-load-bank + (load-music 5) ;; sound-rpc-load-music + (unload-bank 6) ;; sound-rpc-bank-cmd + (play 7) ;; sound-rpc-play + (pause-sound 8) ;; sound-rpc-pause-sound + (stop-sound 9) ;; sound-rpc-stop-sound + (continue-sound 10) ;; sound-rpc-continue-sound + (set-param 11) + (set-master-volume 12) ;; sound-rpc-set-master-volume + (pause-group 13) ;; sound-rpc-pause-group + (stop-group 14) ;; sound-rpc-stop-group + (continue-group 15) ;; sound-rpc-continue-group + (get-irx-version 16) + (set-falloff-curve 17) + (set-sound-falloff 18) + (reload-info 19) + (set-language 20) ;; sound-rpc-set-language + (set-flava 21) ;; sound-rpc-set-flava + (set-midi-reg 22) ;; sound-rpc-set-midi-reg + (set-reverb 23) ;; sound-rpc-set-reverb + (set-ear-trans 24) ;; sound-rpc-set-ear-trans + (shutdown 25) + (list-sounds 26) ;; sound-rpc-list-sounds + (unload-music 27) ;; sound-rpc-unload-music + (set-fps 28) ;; sound-rpc-set-fps + (boot-load 29) + (game-load 30) + (num-tests 31) + (num-testruns 32) + (num-sectors 33) + (num-streamsectors 34) + (num-streambanks 35) + (track-pitch 36) + (linvel-nom 37) + (linvel-stm 38) + (seek-nom 39) + (seek-stm 40) + (read-seq-nom 41) + (read-seq-stm 42) + (read-spr-nom 43) + (read-spr-stm 44) + (read-spr-strn-nom 45) + (rand-stm-abort 46) + (rand-nom-abort 47) + (iop-mem 48) + (cancel-dgo 49) + (set-stereo-mode 50) ;; sound-rpc-set-stereo-mode ) (defenum sound-group @@ -70,12 +95,30 @@ (fo-curve) ) +(defenum stream-status + :type uint32 + :bitfield #t + (zero 0) + (one 1) ;; another way to be playing + (two 2) + (three 3) + (four 4) ;; is playing? + (five 5) + (six 6) ;; another way to be playing. + (seven 7) + ) + +(defenum stereo-mode + :type int32 + ) + ;; DECOMP BEGINS (deftype sound-stream-name (structure) ((name uint8 48 :offset-assert 0) ) + :pack-me :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 @@ -117,17 +160,18 @@ ) (deftype sound-play-params (structure) - ((mask uint16 :offset-assert 0) - (pitch-mod int16 :offset-assert 2) - (bend int16 :offset-assert 4) - (fo-min int16 :offset-assert 6) - (fo-max int16 :offset-assert 8) - (fo-curve int8 :offset-assert 10) - (priority int8 :offset-assert 11) - (volume int32 :offset-assert 12) - (trans int32 3 :offset-assert 16) - (group uint8 :offset-assert 28) - (reg uint8 3 :offset-assert 29) + ((mask uint16 :offset-assert 0) + (pitch-mod int16 :offset-assert 2) + (bend int16 :offset-assert 4) + (fo-min int16 :offset-assert 6) + (fo-max int16 :offset-assert 8) + (fo-curve int8 :offset-assert 10) + (priority int8 :offset-assert 11) + (volume int32 :offset-assert 12) + (trans int32 3 :offset-assert 16) + (group uint8 :offset-assert 28) + (reg uint8 3 :offset-assert 29) + (group-and-regs uint32 :offset 28) ) :allow-misaligned :method-count-assert 9 @@ -135,7 +179,6 @@ :flag-assert #x900000020 ) - (deftype sound-rpc-bank-cmd (sound-rpc-cmd) ((bank-name sound-name :offset-assert 16) ) @@ -145,8 +188,8 @@ ) (deftype sound-rpc-test-cmd (sound-rpc-cmd) - ((ee-addr uint32 :offset-assert 4) - (param0 uint16 :offset-assert 8) + ((ee-addr pointer :offset-assert 4) + (param0 uint16 :offset-assert 8) ) :method-count-assert 9 :size-assert #xa @@ -170,7 +213,7 @@ ) (deftype sound-rpc-load-bank (sound-rpc-bank-cmd) - ((ee-addr uint32 :offset-assert 32) + ((ee-addr pointer :offset-assert 32) ) :method-count-assert 9 :size-assert #x24 @@ -389,6 +432,7 @@ (num float :offset-assert 8) (group sound-group :offset-assert 12) (reg uint8 3 :offset-assert 13) + (group-and-regs uint32 :offset 12) (sound-name-char uint8 16 :offset-assert 16) (sound-name sound-name :offset 16) (trans int32 4 :offset-assert 32) @@ -406,7 +450,6 @@ :size-assert #x4c :flag-assert #x90000004c ) - (define *current-sound-id* (the-as sound-id #x10000)) (deftype ambient-sound (basic) @@ -431,16 +474,25 @@ :size-assert #x6c :flag-assert #x100000006c (:methods - (ambient-sound-method-9 () none 9) - (ambient-sound-method-10 () none 10) - (ambient-sound-method-11 () none 11) - (ambient-sound-method-12 () none 12) - (ambient-sound-method-13 () none 13) - (ambient-sound-method-14 () none 14) - (ambient-sound-method-15 () none 15) + (new (symbol type basic vector) _type_ 0) + (update! (_type_) int 9) + (change-sound! (_type_ sound-name) int 10) + (update-trans! (_type_ vector) int 11) + (update-vol! (_type_ float) int 12) + (update-pitch-mod! (_type_ float) none 13) + (set-falloff-far! (_type_ float) none 14) + (stop! (_type_) int 15) ) ) +;; DECOMP ENDS +(define-extern string->sound-name (function string sound-name)) +(define-extern get-sound-buffer-entry (function pointer)) +(define-extern sound-set-ear-trans (function vector vector vector float int)) +(define-extern ear-trans (function int vector)) +;; ghost function +(define-extern *debug-effect-control* symbol) +(define-extern effect-param->sound-spec (function sound-spec (pointer float) int sound-spec)) \ No newline at end of file diff --git a/goal_src/jak2/engine/sound/gsound.gc b/goal_src/jak2/engine/sound/gsound.gc index f022f90d37..417f463335 100644 --- a/goal_src/jak2/engine/sound/gsound.gc +++ b/goal_src/jak2/engine/sound/gsound.gc @@ -7,3 +7,1017 @@ ;; DECOMP BEGINS +(deftype engine-sound-pers (engine-pers) + () + :method-count-assert 15 + :size-assert #x20 + :flag-assert #xf00000020 + ) + +(defmethod kill-callback engine-sound-pers ((obj engine-sound-pers) (arg0 connection-pers)) + (let ((v1-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-param)) + (set! (-> v1-0 id) (the-as sound-id (-> arg0 param-int64 0))) + (set! (-> v1-0 params volume) -4) + (set! (-> v1-0 auto-time) 120) + (set! (-> v1-0 auto-from) 2) + (set! (-> v1-0 params mask) (the-as uint 17)) + (the-as sound-rpc-set-param (-> v1-0 id)) + ) + 0 + (none) + ) + +(kmemopen global "sound-loop-engine") +(define *sound-loop-engine* (new 'global 'engine-sound-pers '*sound-loop-engine* 32 connection-pers)) +(kmemclose) + +(kmemopen global "sound-rpc") +(define *sound-player-rpc* (new 'global 'rpc-buffer-pair (the-as uint 80) (the-as uint 128) 0)) +(define *sound-loader-rpc* (new 'global 'rpc-buffer-pair (the-as uint 80) (the-as uint 1) 1)) +(kmemclose) + +(defun sound-name= ((arg0 sound-name) (arg1 sound-name)) + (and (= (the-as uint arg0) (the-as uint arg1)) (= (-> arg0 hi) (-> arg1 hi))) + ) + +(deftype sound-iop-info (structure) + ((frame uint32 :offset-assert 0) + (strpos int32 :offset-assert 4) + (str-id uint32 :offset-assert 8) + (str-id-sign int32 :offset 8) + (freemem uint32 :offset-assert 12) + (chinfo uint8 48 :offset-assert 16) + (freemem2 uint32 :offset-assert 64) + (nocd uint32 :offset-assert 68) + (dirtycd uint32 :offset-assert 72) + (diskspeed uint32 2 :offset-assert 76) + (lastspeed uint32 :offset-assert 84) + (dupseg int32 :offset-assert 88) + (times int32 41 :offset-assert 92) + (times-seq uint32 :offset-assert 256) + (iop-ticks uint32 :offset-assert 260) + (stream-position uint32 4 :offset 272) + (stream-status stream-status 4 :offset-assert 288) + (stream-name sound-stream-name 4 :inline :offset-assert 304) + (stream-id uint32 4 :offset-assert 496) + (music-register uint8 17 :offset-assert 512) + (music-excite int8 :offset 528) + (ramdisk-name uint8 48 :offset-assert 529) + ) + :method-count-assert 9 + :size-assert #x241 + :flag-assert #x900000241 + ) + +(define *sound-iop-info* (new 'global 'sound-iop-info)) + +(defun str-is-playing? () + (countdown (v1-0 4) + (if (and (>= (-> *sound-iop-info* stream-id v1-0) 0) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status four)) + ) + (return #t) + ) + ) + #f + ) + +(defun str-id-is-playing? ((arg0 int)) + (countdown (v1-0 4) + (if (and (= arg0 (-> *sound-iop-info* stream-id v1-0)) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status one six)) + ) + (return #t) + ) + ) + #f + ) + +(defun current-str-pos ((arg0 sound-id)) + (if (>= (-> *setting-control* user-current movie-skip-frame) 0.0) + (return (the int (* 34.133335 (-> *setting-control* user-current movie-skip-frame)))) + ) + (dotimes (v1-5 4) + (if (= arg0 (-> *sound-iop-info* stream-id v1-5)) + (return (the-as int (-> *sound-iop-info* stream-position v1-5))) + ) + ) + -1 + ) + +(defun is-ramdisk-loaded? ((arg0 symbol)) + (let ((gp-0 (-> *sound-iop-info* ramdisk-name)) + (s5-0 (symbol->string arg0)) + ) + (and (charp-prefix= (-> s5-0 data) gp-0) (= (-> gp-0 (length s5-0)) 46)) + ) + ) + +(defun is-cd-in? () + (zero? (-> *sound-iop-info* nocd)) + ) + +(defun new-sound-id () + (set! *current-sound-id* (+ *current-sound-id* 1)) + (if (< (the-as int *current-sound-id*) #x10000) + (set! *current-sound-id* (the-as sound-id #x10000)) + ) + *current-sound-id* + ) + +(defun check-irx-version () + (let ((gp-0 (the-as sound-rpc-get-irx-version (add-element *sound-loader-rpc*)))) + (set! (-> gp-0 command) (sound-command get-irx-version)) + (set! (-> gp-0 ee-addr) (&-> *sound-iop-info* frame)) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer gp-0) (the-as uint 80)) + (sync *sound-loader-rpc* #f) + (format 0 "IRX version ~D.~D~%" (-> gp-0 major) (-> gp-0 minor)) + (when (or (!= (-> gp-0 major) 4) (nonzero? (-> gp-0 minor))) + (format 0 "ERROR: IRX is the wrong version - need ~D.~D~%" 4 0) + (format 0 "~%~%Please do (:mch) then mkee on linux-dog~%~%~%") + (crash!) + 0 + ) + ) + 0 + ) + +(defun sound-bank-iop-store ((arg0 sound-name)) + (let ((gp-0 (new-sound-id))) + (let ((v1-1 (the-as sound-rpc-bank-cmd (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command iop-store)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +(defun sound-bank-iop-free ((arg0 sound-name)) + (let ((gp-0 (new-sound-id))) + (let ((v1-1 (the-as sound-rpc-bank-cmd (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command iop-free)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +(defun sound-bank-load ((arg0 sound-name)) + (let ((gp-0 (new-sound-id))) + (let ((v1-1 (the-as sound-rpc-load-bank (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command load-bank)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +(defun sound-bank-load-from-iop ((arg0 sound-name)) + (let ((gp-0 (new-sound-id))) + (let ((v1-1 (the-as sound-rpc-load-bank (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command load-bank-from-iop)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +(defun sound-bank-load-from-ee ((arg0 sound-name) (arg1 pointer)) + (let ((gp-0 (new-sound-id))) + (let ((v1-1 (the-as sound-rpc-load-bank (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command load-bank-from-ee)) + (set! (-> v1-1 bank-name) arg0) + (set! (-> v1-1 ee-addr) arg1) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +(defun sound-bank-unload ((arg0 sound-name)) + (let ((v1-1 (the-as sound-rpc-unload-bank (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command unload-bank)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +(defun sound-music-load ((arg0 sound-name)) + (let ((v1-1 (the-as sound-rpc-load-music (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command load-music)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +(defun sound-music-unload () + (let ((v1-1 (the-as sound-rpc-unload-music (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command unload-music)) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +(defun set-language ((arg0 language-enum)) + (kset-language arg0) + (let ((v1-1 (the-as sound-rpc-set-language (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command set-language)) + (set! (-> v1-1 lang) (the-as uint arg0)) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +(defun sound-set-stereo-mode ((arg0 stereo-mode)) + (let ((v1-1 (the-as sound-rpc-set-stereo-mode (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command set-stereo-mode)) + (set! (-> v1-1 mode) (the-as int arg0)) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + (none) + ) + +(defun list-sounds () + (let ((v1-1 (the-as sound-rpc-list-sounds (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command list-sounds)) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + (syncv 0) + 0 + (none) + ) + +(defun sound-command->string ((cmd sound-command)) + (enum->string sound-command cmd) + ) + +(defun sound-buffer-dump () + (let ((gp-0 (-> *sound-player-rpc* current elt-used)) + (s5-0 (-> *sound-player-rpc* current elt-size)) + ) + (dotimes (s4-0 (the-as int gp-0)) + (let* ((s3-0 (the-as sound-rpc-play (&+ (-> *sound-player-rpc* current base) (* s5-0 (the-as uint s4-0))))) + (a3-0 (sound-command->string (-> s3-0 command))) + ) + (case (-> s3-0 command) + (((sound-command play)) + (format #t "~D ~A ~G~%" s4-0 a3-0 (&-> s3-0 name)) + ) + (else + (format #t "~D ~A~%" s4-0 a3-0) + ) + ) + ) + ) + ) + 0 + ) + +(define *sound-player-enable* #t) + +(defun swap-sound-buffers ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (run-pending-updates! *sound-loop-engine* (-> *display* base-clock frame-counter)) + (cond + ((check-busy *sound-player-rpc*) + (set! *sound-player-enable* #f) + ) + (else + (let ((a0-3 (-> *sound-player-rpc* current))) + (if (< (-> a0-3 elt-used) (-> a0-3 elt-count)) + (sound-set-ear-trans arg0 arg1 arg2 arg3) + ) + ) + (call *sound-player-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + (set! *sound-player-enable* #t) + ) + ) + (cond + ((not (-> *setting-control* user-current allow-error)) + ) + ((nonzero? (-> *sound-iop-info* nocd)) + (if (or (not *progress-process*) (!= (-> *progress-process* 0 current) 'error-disc-removed)) + (activate-progress *dproc* 'error-disc-removed) + ) + ) + ((nonzero? (-> *sound-iop-info* dirtycd)) + (if (or (not *progress-process*) (!= (-> *progress-process* 0 current) 'error-reading)) + (activate-progress *dproc* 'error-reading) + ) + ) + ) + 0 + ) + +(defun get-sound-buffer-entry () + (add-element *sound-player-rpc*) + ) + +(defun free-last-sound-buffer-entry () + (decrement-elt-used *sound-player-rpc*) + 0 + (none) + ) + +(defun sound-basic-cb ((arg0 int) (arg1 (pointer int32))) + (set! (-> arg1 0) arg0) + 0 + (none) + ) + +(defun sound-trans-convert ((arg0 vector3w) (arg1 vector)) + (let ((v1-0 (if arg1 + arg1 + (ear-trans 0) + ) + ) + ) + (set! (-> arg0 x) (the int (* 0.0625 (-> v1-0 x)))) + (set! (-> arg0 y) (the int (* 0.0625 (-> v1-0 y)))) + (set! (-> arg0 z) (the int (* 0.0625 (-> v1-0 z)))) + ) + 0 + ) + +(defun sound-angle-convert ((arg0 float)) + (let* ((f0-3 (the float (sar (shl (the int arg0) 48) 48))) + (v0-0 (the int (* 0.005493164 f0-3))) + ) + (if (< v0-0 0) + (+! v0-0 360) + ) + (if (< 359 v0-0) + (+! v0-0 -360) + ) + v0-0 + ) + ) + +(defun string->sound-name ((arg0 string)) + (let ((v1-0 (new 'stack-no-clear 'qword))) + (set! (-> v1-0 quad) (the-as uint128 0)) + (let ((a1-0 (the-as (pointer uint8) v1-0)) + (a2-0 (-> arg0 data)) + ) + (while (and (nonzero? (-> a2-0 0)) (< (&- a2-0 (the-as uint (-> arg0 data))) 15)) + (set! (-> a1-0 0) (-> a2-0 0)) + (set! a1-0 (&-> a1-0 1)) + (set! a2-0 (&-> a2-0 1)) + ) + ) + (the-as sound-name (-> v1-0 quad)) + ) + ) + +(defun sound-set-volume ((arg0 sound-group) (arg1 float)) + (let ((v1-0 (the-as sound-rpc-set-master-volume (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-master-volume)) + (set! (-> v1-0 group) arg0) + (set! (-> v1-0 volume) (the int (* 1024.0 arg1))) + ) + 0 + ) + +(defun sound-set-reverb ((arg0 int) (arg1 float) (arg2 float) (arg3 uint)) + (let ((v1-0 (the-as sound-rpc-set-reverb (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-reverb)) + (set! (-> v1-0 core) arg3) + (set! (-> v1-0 reverb) arg0) + (set! (-> v1-0 left) (the-as uint (the int (* 32767.0 arg1)))) + (set! (-> v1-0 right) (the-as uint (the int (* 32767.0 arg2)))) + ) + 0 + ) + +(defun sound-set-ear-trans ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (let ((gp-0 (the-as sound-rpc-set-ear-trans (get-sound-buffer-entry)))) + (set! (-> gp-0 command) (sound-command set-ear-trans)) + (sound-trans-convert (the-as vector3w (-> gp-0 ear-trans0)) arg0) + (sound-trans-convert (the-as vector3w (-> gp-0 ear-trans1)) arg1) + (sound-trans-convert (the-as vector3w (-> gp-0 cam-trans)) arg2) + (set! (-> gp-0 cam-angle) (sound-angle-convert arg3)) + ) + 0 + ) + +(defun sound-play-by-name ((arg0 sound-name) (arg1 sound-id) (arg2 int) (arg3 int) (arg4 int) (arg5 sound-group) (arg6 symbol)) + (local-vars (sv-16 sound-group)) + (with-pp + (set! sv-16 arg5) + (let ((s4-0 (the-as object arg6))) + (when *sound-player-enable* + (let ((s5-0 (the-as sound-rpc-play (get-sound-buffer-entry)))) + (set! (-> s5-0 command) (sound-command play)) + (set! (-> s5-0 id) arg1) + (set! (-> s5-0 name) arg0) + (set! (-> s5-0 params mask) (the-as uint 0)) + (set! (-> s5-0 params group) (the-as uint sv-16)) + (set! (-> s5-0 params volume) arg2) + (set! (-> s5-0 params pitch-mod) arg3) + (set! (-> s5-0 params bend) arg4) + (let ((s3-1 (the-as process-drawable pp))) + (when (= (the-as symbol s4-0) #t) + (if (and s3-1 (type? s3-1 process-drawable) (nonzero? (-> s3-1 root))) + (set! s4-0 (-> s3-1 root trans)) + (set! s4-0 #f) + ) + ) + ) + (sound-trans-convert (the-as vector3w (-> s5-0 params trans)) (the-as vector s4-0)) + ) + ) + ) + arg1 + ) + ) + +(defun sound-play-by-spec ((arg0 sound-spec) (arg1 sound-id) (arg2 vector)) + (with-pp + (when *sound-player-enable* + (let ((s5-0 (the-as sound-rpc-play (get-sound-buffer-entry)))) + (set! (-> s5-0 command) (sound-command play)) + (set! (-> s5-0 id) arg1) + (set! (-> s5-0 name) (-> arg0 sound-name)) + (set! (-> s5-0 params mask) (the-as uint (-> arg0 mask))) + (set! (-> s5-0 params group-and-regs) (-> arg0 group-and-regs)) + (set! (-> s5-0 params volume) (-> arg0 volume)) + (set! (-> s5-0 params pitch-mod) (-> arg0 pitch-mod)) + (set! (-> s5-0 params bend) (-> arg0 bend)) + (set! (-> s5-0 params fo-min) (-> arg0 fo-min)) + (set! (-> s5-0 params fo-max) (-> arg0 fo-max)) + (set! (-> s5-0 params fo-curve) (-> arg0 fo-curve)) + (set! (-> s5-0 params priority) (-> arg0 priority)) + (let ((s3-1 (the-as process-drawable pp))) + (when (= arg2 #t) + (if (and s3-1 (type? s3-1 process-drawable) (nonzero? (-> s3-1 root))) + (set! arg2 (-> s3-1 root trans)) + (set! arg2 (the-as vector #f)) + ) + ) + ) + (sound-trans-convert (the-as vector3w (-> s5-0 params trans)) arg2) + ) + ) + arg1 + ) + ) + +(defun sound-pause ((arg0 sound-id)) + (when (nonzero? arg0) + (let ((v1-1 (the-as sound-rpc-pause-sound (get-sound-buffer-entry)))) + (set! (-> v1-1 command) (sound-command pause-sound)) + (set! (-> v1-1 id) arg0) + ) + ) + 0 + ) + +(defun sound-stop ((arg0 sound-id)) + (when (nonzero? arg0) + (let ((v1-1 (the-as sound-rpc-stop-sound (get-sound-buffer-entry)))) + (set! (-> v1-1 command) (sound-command stop-sound)) + (set! (-> v1-1 id) arg0) + ) + ) + 0 + ) + +(defun sound-continue ((arg0 sound-id)) + (when (nonzero? arg0) + (let ((v1-1 (the-as sound-rpc-continue-sound (get-sound-buffer-entry)))) + (set! (-> v1-1 command) (sound-command continue-sound)) + (set! (-> v1-1 id) arg0) + ) + ) + 0 + ) + +(defun sound-group-pause ((arg0 sound-group)) + (let ((v1-0 (the-as sound-rpc-pause-group (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command pause-group)) + (set! (-> v1-0 group) arg0) + ) + 0 + ) + +(defun sound-group-stop ((arg0 sound-group)) + (let ((v1-0 (the-as sound-rpc-stop-group (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command stop-group)) + (set! (-> v1-0 group) arg0) + ) + 0 + ) + +(defun sound-group-continue ((arg0 sound-group)) + (let ((v1-0 (the-as sound-rpc-continue-group (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command continue-group)) + (set! (-> v1-0 group) arg0) + ) + 0 + ) + +(defun sound-set-flava ((arg0 uint) (arg1 uint)) + (let ((v1-0 (the-as sound-rpc-set-flava (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-flava)) + (set! (-> v1-0 flava) arg0) + (set! (-> v1-0 excitement) arg1) + ) + 0 + ) + +(defun sound-set-midi-reg ((arg0 int) (arg1 int)) + (let ((v1-0 (the-as sound-rpc-set-midi-reg (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-midi-reg)) + (set! (-> v1-0 reg) arg0) + (set! (-> v1-0 value) arg1) + ) + 0 + ) + +(defun sound-set-fps ((arg0 int)) + (let ((v1-0 (the-as sound-rpc-set-fps (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-fps)) + (set! (-> v1-0 fps) (the-as uint arg0)) + ) + 0 + ) + +(defun sound-volume-off () + (set-setting! 'music-volume 'abs 0 0) + (set-setting! 'sfx-volume 'abs 0 0) + (set-setting! 'ambient-volume 'abs 0 0) + 0 + ) + +(define *ambient-spec* (new 'static 'sound-spec)) + +(defmethod new ambient-sound ((allocation symbol) (type-to-make type) (arg0 basic) (arg1 vector)) + (local-vars + (sv-16 sound-spec) + (sv-32 sound-name) + (sv-48 (pointer float)) + (sv-52 pointer) + (sv-56 int) + (sv-64 res-tag) + ) + (set! sv-16 (the-as sound-spec #f)) + (set! sv-32 (the-as sound-name 0)) + (set! sv-48 (the-as (pointer float) #f)) + (set! sv-52 (the-as pointer #f)) + (set! sv-56 0) + (case (-> arg0 type) + ((entity-actor) + (let ((v1-2 + ((method-of-type res-lump get-property-struct) + (the-as res-lump arg0) + 'effect-name + 'exact + 0.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (when v1-2 + (set! sv-32 (string->sound-name (the-as string (-> (the-as (pointer uint32) (+ #xff37 (the-as int v1-2))))))) + (set! sv-48 (res-lump-data (the-as res-lump arg0) 'cycle-speed (pointer float))) + (set! sv-16 *ambient-spec*) + (set! sv-64 (new 'static 'res-tag)) + (let ((v1-7 + ((method-of-type res-lump get-property-data) + (the-as res-lump arg0) + 'effect-param + 'exact + 0.0 + (the-as pointer #f) + (& sv-64) + *res-static-buf* + ) + ) + ) + (when v1-7 + (set! sv-52 v1-7) + (set! sv-56 (the-as int (-> sv-64 elt-count))) + ) + ) + ) + ) + ) + ((sound-spec) + (set! sv-16 (the-as sound-spec arg0)) + ) + ((string) + (set! sv-32 (string->sound-name (the-as string arg0))) + ) + (else + (format 0 "ERROR: ambient sound was told to play an unknown ~A.~%" arg0) + ) + ) + (the-as + ambient-sound + (cond + ((or sv-16 (nonzero? sv-32)) + (let ((s5-1 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (set! (-> (the-as ambient-sound s5-1) spec) sv-16) + (set! (-> (the-as ambient-sound s5-1) name) sv-32) + (set! (-> (the-as ambient-sound s5-1) playing-id) (new-sound-id)) + (set! (-> (the-as ambient-sound s5-1) params) (the-as (pointer float) sv-52)) + (set! (-> (the-as ambient-sound s5-1) param-count) sv-56) + (set! (-> (the-as ambient-sound s5-1) entity) #f) + (set! (-> (the-as ambient-sound s5-1) sound-count) 1) + (set! (-> (the-as ambient-sound s5-1) volume) 1024) + (set! (-> (the-as ambient-sound s5-1) pitch) 0) + (when (and sv-16 (!= sv-16 *ambient-spec*)) + (if (logtest? (-> (the-as sound-spec sv-16) mask) (sound-mask volume)) + (set! (-> (the-as ambient-sound s5-1) volume) (-> (the-as sound-spec sv-16) volume)) + ) + (if (logtest? (-> (the-as sound-spec sv-16) mask) (sound-mask pitch)) + (set! (-> (the-as ambient-sound s5-1) pitch) (-> (the-as sound-spec sv-16) pitch-mod)) + ) + ) + (cond + (sv-48 + (set! (-> (the-as ambient-sound s5-1) time-base) (the-as time-frame (the int (* 300.0 (-> sv-48 0))))) + (set! (-> (the-as ambient-sound s5-1) time-random) (the-as time-frame (the int (* 300.0 (-> sv-48 1))))) + ) + (else + (set! (-> (the-as ambient-sound s5-1) time-base) -1) + ) + ) + (set! (-> (the-as ambient-sound s5-1) trans quad) (-> arg1 quad)) + s5-1 + ) + ) + (else + 0 + ) + ) + ) + ) + +(defmethod update! ambient-sound ((obj ambient-sound)) + (with-pp + (if (not *ambient-sound-class*) + (return (the-as int #f)) + ) + (cond + ((-> obj spec) + (when (or (< (-> obj time-base) 0) (>= (-> pp clock frame-counter) (-> obj play-time))) + (when (>= (-> obj time-base) 0) + (set! (-> obj play-time) + (+ (-> pp clock frame-counter) (-> obj time-base) (rand-vu-int-count (the-as int (-> obj time-random)))) + ) + (set! (-> obj playing-id) (new-sound-id)) + ) + (let ((s5-1 (-> obj spec))) + (when (= s5-1 *ambient-spec*) + (set! (-> s5-1 volume) (-> obj volume)) + (set! (-> s5-1 pitch-mod) (-> obj pitch)) + (set! (-> s5-1 bend) 0) + (set! (-> s5-1 sound-name) (-> obj name)) + (set! (-> s5-1 fo-max) (-> obj falloff-far)) + (set! (-> s5-1 mask) (sound-mask)) + (when (-> obj params) + ;; ADDED - the function after this has been removed in jak 2, and calling it will crash. + (format 0 "bad case in update! ambient-sound~%") + pp + (effect-param->sound-spec s5-1 (-> obj params) (-> obj param-count)) + ) + ) + (let ((v1-23 (-> s5-1 fo-max))) + (if (and (nonzero? v1-23) (< (* 4096.0 (the float v1-23)) (vector-vector-distance (ear-trans 0) (-> obj trans)))) + (return 0) + ) + ) + (when (and *debug-effect-control* (>= (-> obj time-base) 0)) + (format #t "(~5D) effect sound ~A ~G " (-> pp clock frame-counter) (-> pp name) (&-> s5-1 sound-name)) + (format + #t + "volume: ~f pitch-mod: ~f~%" + (* 0.09765625 (the float (-> s5-1 volume))) + (* 0.000656168 (the float (-> s5-1 pitch-mod))) + ) + ) + (let ((s4-2 (-> s5-1 volume))) + (set! (-> s5-1 volume) (-> obj volume)) + (set! (-> obj playing-id) (sound-play-by-spec s5-1 (-> obj playing-id) (-> obj trans))) + (set! (-> s5-1 volume) s4-2) + ) + ) + ) + ) + ((< (-> obj time-base) 0) + (let ((v1-39 (-> obj falloff-far))) + (if (and (nonzero? v1-39) (< (* 4096.0 (the float v1-39)) (vector-vector-distance (ear-trans 0) (-> obj trans)))) + (return 0) + ) + ) + (set! (-> obj playing-id) (sound-play-by-name + (-> obj name) + (-> obj playing-id) + (-> obj volume) + (-> obj pitch) + 0 + (sound-group sfx) + (the-as symbol (-> obj trans)) + ) + ) + ) + (else + (when (>= (-> pp clock frame-counter) (-> obj play-time)) + (set! (-> obj playing-id) + (sound-play-by-name + (-> obj name) + (new-sound-id) + (-> obj volume) + (-> obj pitch) + 0 + (sound-group sfx) + (the-as symbol (-> obj trans)) + ) + ) + (set! (-> obj play-time) + (+ (-> pp clock frame-counter) (-> obj time-base) (rand-vu-int-count (the-as int (-> obj time-random)))) + ) + ) + ) + ) + 0 + ) + ) + +(defmethod stop! ambient-sound ((obj ambient-sound)) + (sound-stop (-> obj playing-id)) + 0 + ) + +(defmethod update-trans! ambient-sound ((obj ambient-sound) (arg0 vector)) + (with-pp + (set! (-> obj trans quad) (-> arg0 quad)) + (when (nonzero? (-> obj playing-id)) + (when *sound-player-enable* + (let ((s5-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> s5-0 command) (sound-command set-param)) + (set! (-> s5-0 id) (-> obj playing-id)) + (let ((s4-1 (the-as process-drawable pp))) + (when (= arg0 #t) + (if (and s4-1 (type? s4-1 process-drawable) (nonzero? (-> s4-1 root))) + (set! arg0 (-> s4-1 root trans)) + (set! arg0 (the-as vector #f)) + ) + ) + ) + (sound-trans-convert (the-as vector3w (-> s5-0 params trans)) arg0) + (set! (-> s5-0 params mask) (the-as uint 32)) + (-> s5-0 id) + ) + ) + ) + 0 + ) + ) + +(defmethod update-vol! ambient-sound ((obj ambient-sound) (arg0 float)) + (when (nonzero? (-> obj playing-id)) + (when *sound-player-enable* + (let ((v1-4 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-4 command) (sound-command set-param)) + (set! (-> v1-4 id) (-> obj playing-id)) + (set! (-> v1-4 params volume) (the int (* 1024.0 arg0))) + (set! (-> v1-4 params mask) (the-as uint 1)) + (-> v1-4 id) + ) + ) + ) + (set! (-> obj volume) (the int (* 1024.0 arg0))) + 0 + ) + +(defmethod update-pitch-mod! ambient-sound ((obj ambient-sound) (arg0 float)) + (when (nonzero? (-> obj playing-id)) + (when *sound-player-enable* + (let ((v1-4 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-4 command) (sound-command set-param)) + (set! (-> v1-4 id) (-> obj playing-id)) + (set! (-> v1-4 params pitch-mod) (the int (* 1524.0 arg0))) + (set! (-> v1-4 params mask) (the-as uint 2)) + (-> v1-4 id) + ) + ) + ) + (set! (-> obj pitch) (the int (* 1524.0 arg0))) + 0 + (none) + ) + +(defmethod set-falloff-far! ambient-sound ((obj ambient-sound) (arg0 float)) + (set! (-> obj falloff-far) (the int (* 0.00024414062 arg0))) + 0 + (none) + ) + +(defmethod change-sound! ambient-sound ((obj ambient-sound) (arg0 sound-name)) + (when (not (and (= (the-as uint (-> obj name)) (the-as uint arg0)) (= (-> arg0 hi) (-> obj name hi)))) + (stop! obj) + (set! (-> obj playing-id) (new-sound-id)) + (set! (-> obj name) arg0) + ) + 0 + ) + +(defun show-iop-info ((arg0 dma-buffer)) + (dotimes (s5-0 24) + (draw-string-xy + (if (zero? (-> *sound-iop-info* chinfo s5-0)) + "." + "X" + ) + arg0 + (+ (* s5-0 16) 16) + 48 + (font-color default) + (font-flags shadow) + ) + ) + (dotimes (s5-1 24) + (draw-string-xy + (if (zero? (-> *sound-iop-info* chinfo (+ s5-1 24))) + "." + "X" + ) + arg0 + (+ (* s5-1 16) 16) + 64 + (font-color default) + (font-flags shadow) + ) + ) + (let ((s5-2 draw-string-xy)) + (format + (clear *temp-string*) + "banks: ~15S ~15S ~15S" + (-> *level* sound-bank 0) + (-> *level* sound-bank 1) + (-> *level* sound-bank 2) + ) + (s5-2 *temp-string* arg0 16 88 (font-color default) (font-flags shadow)) + ) + (let ((s5-3 draw-string-xy)) + (format + (clear *temp-string*) + "music: ~15S fl:~1D/~2D ex:~4,,2f/~4,,2f ~10S" + (-> *setting-control* user-current music) + (-> *setting-control* user-current sound-flava) + (-> *setting-control* user-current sound-stinger) + (-> *setting-control* user-target sound-excitement) + (-> *setting-control* user-current sound-excitement) + (-> *setting-control* user-current mode-sound-bank) + ) + (s5-3 *temp-string* arg0 16 104 (font-color default) (font-flags shadow)) + ) + 0 + ) + +(defun show-iop-memory ((arg0 dma-buffer)) + (let ((s5-0 draw-string-xy)) + (format + (clear *temp-string*) + "~8D [~4D]" + (-> *sound-iop-info* freemem) + (shr (-> *sound-iop-info* freemem) 10) + ) + (s5-0 *temp-string* arg0 32 96 (font-color default) (font-flags shadow)) + ) + (let ((s5-1 draw-string-xy)) + (format + (clear *temp-string*) + "~8D [~4D]" + (-> *sound-iop-info* freemem2) + (shr (-> *sound-iop-info* freemem2) 10) + ) + (s5-1 *temp-string* arg0 32 64 (font-color default) (font-flags shadow)) + ) + 0 + ) + +;; definition for function ear-trans +(defun ear-trans ((arg0 int)) + (cond + ((or (movie?) *external-cam-mode*) + (math-camera-pos) + ) + ((and *target* (= arg0 1)) + (target-pos 0) + ) + (else + (camera-pos) + ) + ) + ) + +(defun-debug make-sqrt-table () + (format #t "static int sqrt_table[256] =~%{~%") + (dotimes (gp-0 256) + (let* ((f0-2 (sqrtf (* 16777216.0 (the float gp-0)))) (a2-0 (the int (+ 0.5 f0-2)))) (format #t "~D,~%" a2-0)) + ) + (format #t "};~%") + 0 + ) + +;; temporarily removed, will crash on startup +(format 0 "HACK: skipping check-irx-version and common soundbank load.~%") +#| +(check-irx-version) + +(case (scf-get-territory) + ((2) + (sound-bank-load (static-sound-name "commonj")) + ) + (else + (sound-bank-load (static-sound-name "common")) + ) + ) + +(dotimes (gp-0 3) + (let ((s5-0 string->symbol)) + (format (clear *temp-string*) "empty~D" gp-0) + (let ((s5-1 (s5-0 *temp-string*))) + (sound-bank-load (string->sound-name (symbol->string s5-1))) + (set! (-> *level* sound-bank gp-0) (the-as basic s5-1)) + ) + ) + ) +|# + + + +(defun loader-test-command ((arg0 sound-command) (arg1 uint)) + (let ((v1-1 (the-as sound-rpc-test-cmd (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) arg0) + (set! (-> v1-1 ee-addr) (the-as pointer 0)) + (set! (-> v1-1 param0) arg1) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + (sync *sound-loader-rpc* #f) + 0 + (none) + ) + +(defun doppler-pitch-shift ((arg0 vector) (arg1 vector)) + (let ((gp-0 (new 'stack-no-clear 'inline-array 'vector 2))) + (vector-! (-> gp-0 0) (target-pos 0) arg0) + (if *target* + (vector-! (-> gp-0 1) arg1 (-> *target* root transv)) + (set! (-> gp-0 1 quad) (-> arg1 quad)) + ) + (vector-normalize! (-> gp-0 0) 1.0) + (let ((f0-1 (/ 1228800.0 (fmax 0.1 (- 1228800.0 (vector-dot (-> gp-0 0) (-> gp-0 1))))))) + (log2f f0-1) + ) + ) + ) + +(defun sound-bank-reload () + (process-spawn-function + process + (lambda () + (with-pp + (let ((gp-0 (the-as (array symbol) (new 'static 'boxed-array :type symbol :length 0 :allocated-length 3)))) + (dotimes (v1-0 3) + (set! (-> gp-0 v1-0) (the-as symbol (-> *level* sound-bank v1-0))) + ) + (let ((a1-3 (new 'stack-no-clear 'array 'symbol 4))) + (set! (-> a1-3 2) 'empty2) + (set! (-> a1-3 1) 'empty1) + (set! (-> a1-3 0) 'empty0) + (want-sound-banks *load-state* a1-3) + ) + (let ((s5-0 (-> pp clock frame-counter))) + (until (>= (- (-> pp clock frame-counter) s5-0) (seconds 1)) + (suspend) + ) + ) + (let ((a1-4 (new 'stack-no-clear 'array 'symbol 4))) + (set! (-> a1-4 2) (-> gp-0 2)) + (set! (-> a1-4 1) (-> gp-0 1)) + (set! (-> a1-4 0) (-> gp-0 0)) + (want-sound-banks *load-state* a1-4) + ) + ) + (none) + ) + ) + :name (symbol->string (-> process symbol)) + :to *display-pool* + ) + 0 + (none) + ) diff --git a/goal_src/jak2/engine/target/target-h.gc b/goal_src/jak2/engine/target/target-h.gc index e801545aa7..c1e853b54a 100644 --- a/goal_src/jak2/engine/target/target-h.gc +++ b/goal_src/jak2/engine/target/target-h.gc @@ -111,3 +111,4 @@ ; what is this. ;(new 'static 'boxed-array :type type pilot-info mech-info turret-info indax-info tube-info) +(define-extern target-pos (function int vector)) diff --git a/goal_src/jak2/engine/ui/progress/progress-h.gc b/goal_src/jak2/engine/ui/progress/progress-h.gc index d2a160a942..b92793692a 100644 --- a/goal_src/jak2/engine/ui/progress/progress-h.gc +++ b/goal_src/jak2/engine/ui/progress/progress-h.gc @@ -504,3 +504,8 @@ :size-assert #x54 :flag-assert #xc00000054 ) + +;; DECOMP ENDS + +(define-extern *progress-process* (pointer progress)) +(define-extern activate-progress (function process symbol none)) diff --git a/goal_src/jak2/kernel-defs.gc b/goal_src/jak2/kernel-defs.gc index 876c723fa4..7da91bafd0 100644 --- a/goal_src/jak2/kernel-defs.gc +++ b/goal_src/jak2/kernel-defs.gc @@ -140,6 +140,11 @@ (define-extern rpc-call (function int uint uint uint int uint int uint)) (define-extern string->symbol (function string symbol)) +(define-extern link-begin (function pointer (pointer uint8) int kheap link-flag int)) +(define-extern kset-language (function language-enum int)) +(define-extern syncv (function int int)) + + ;; PC stuff (defenum pc-prof-event (begin 0) diff --git a/test/decompiler/reference/jak2/decompiler-macros.gc b/test/decompiler/reference/jak2/decompiler-macros.gc index f6ff064fc8..9a73f7c0be 100644 --- a/test/decompiler/reference/jak2/decompiler-macros.gc +++ b/test/decompiler/reference/jak2/decompiler-macros.gc @@ -145,6 +145,30 @@ ) ) + +(defconstant *scratch-memory-top* (the pointer #x70004000)) +(defconstant DPROCESS_STACK_SIZE #x8000) + +;; gkernel + +(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)))) + (when ,new-proc + ((method-of-type ,proc-type activate) ,new-proc ,to ,(if name name `(quote ,proc-type)) ,stack) + (run-next-time-in-process ,new-proc ,func ,@args) + (the (pointer ,proc-type) (-> ,new-proc ppointer)) + ) + ) + ) + ) + + (defmacro b! (pred destination &key (delay '()) &key (likely-delay '())) "Branch!" ;; evaluate the predicate @@ -695,4 +719,77 @@ ,@(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 + ; ((or (eq? setting 'border-mode) + ; (eq? setting 'allow-look-around) + ; (eq? setting 'ocean-off) + ; (eq? setting 'music) + ; (eq? setting 'vibration) + ; (eq? setting 'auto-save) + ; (eq? setting 'allow-pause) + ; (eq? setting 'allow-progress) + ; (eq? setting 'play-hints) + ; (eq? setting 'movie) + ; (eq? setting 'talking) + ; (eq? setting 'spooling) + ; (eq? setting 'hint) + ; (eq? setting 'ambient) + ; ) + ; (set! argb (car args)) + ; ) + ; ((or (eq? setting 'bg-r) + ; (eq? setting 'bg-g) + ; (eq? setting 'bg-b) + ; (eq? setting 'bg-a) + ; (eq? setting 'bg-a-speed) + ; (eq? setting 'bg-a-force) + ; ) + ; (set! argf (car args)) + ; ) + ; ((or (eq? setting 'language) + ; ) + ; (set! argi (car args)) + ; ) + ; ((or (eq? setting 'sound-flava) + ; ) + ; (set! argi (car args)) + ; (set! argf (cadr args)) + ; ) + ; ((or (eq? setting 'process-mask) + ; (eq? setting 'common-page) + ; ) + ; (set! argb (car args)) + ; (set! argi (cadr args)) + ; ) + ; ((or (eq? setting 'sfx-volume) + ; (eq? setting 'music-volume) + ; (eq? setting 'ambient-volume) + ; (eq? setting 'dialog-volume) + ; (eq? setting 'sfx-volume-movie) + ; (eq? setting 'music-volume-movie) + ; (eq? setting 'ambient-volume-movie) + ; (eq? setting 'dialog-volume-hint) + ; ) + ; (set! argb (car args)) + ; (set! argf (cadr args)) + ; ) + (#t + (set! argb (car args)) + (set! argf (cadr args)) + (set! argi (caddr args)) + ) + ) + `(,func *setting-control* (with-pp pp) ,s ,argb ,argf ,argi) + ) + ) + +(defmacro set-setting! (s &rest args) + `(setting-control-func! set-setting ,s ,@args) ) \ No newline at end of file diff --git a/test/decompiler/reference/jak2/engine/collide/collide-shape-h_REF.gc b/test/decompiler/reference/jak2/engine/collide/collide-shape-h_REF.gc index 88abb5bf44..d5332a246a 100644 --- a/test/decompiler/reference/jak2/engine/collide/collide-shape-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/collide/collide-shape-h_REF.gc @@ -1613,6 +1613,7 @@ :size-assert #x1dc :flag-assert #x44000001dc (:methods + (new (symbol type process-drawable collide-list-enum) _type_ 0) (collide-shape-moving-method-55 () none 55) (collide-shape-moving-method-56 () none 56) (collide-shape-moving-method-57 () none 57) diff --git a/test/decompiler/reference/jak2/engine/collide/collide-touch-h_REF.gc b/test/decompiler/reference/jak2/engine/collide/collide-touch-h_REF.gc index 385c704f7d..969d4611f3 100644 --- a/test/decompiler/reference/jak2/engine/collide/collide-touch-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/collide/collide-touch-h_REF.gc @@ -71,6 +71,7 @@ :size-assert #x3c10 :flag-assert #xd00003c10 (:methods + (new (symbol type) _type_ 0) (touching-prims-entry-pool-method-9 () none 9) (touching-prims-entry-pool-method-10 () none 10) (init-list! (_type_) none 11) @@ -177,6 +178,7 @@ :size-assert #x408 :flag-assert #xe00000408 (:methods + (new (symbol type) _type_ 0) (touching-list-method-9 () none 9) (touching-list-method-10 () none 10) (touching-list-method-11 () none 11) @@ -236,7 +238,3 @@ ;; failed to figure out what this is: (kmemclose) - - - - diff --git a/test/decompiler/reference/jak2/engine/game/fact-h_REF.gc b/test/decompiler/reference/jak2/engine/game/fact-h_REF.gc index 506ea84d2b..5ca7875f53 100644 --- a/test/decompiler/reference/jak2/engine/game/fact-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/fact-h_REF.gc @@ -515,6 +515,7 @@ :size-assert #x110 :flag-assert #xd00000110 (:methods + (new (symbol type process pickup-type float) _type_ 0) (fact-info-target-method-12 () none 12) ) ) @@ -1113,6 +1114,9 @@ :method-count-assert 12 :size-assert #x2c :flag-assert #xc0000002c + (:methods + (new (symbol type process pickup-type float) _type_ 0) + ) ) ;; definition for method 3 of type fact-info-crate diff --git a/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc b/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc index fe0fcd0691..f0942c1dbf 100644 --- a/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc @@ -127,7 +127,7 @@ (reset! (_type_) _type_ 9) (update! (_type_) int 10) (want-levels (_type_ (pointer symbol)) int 11) - (load-state-method-12 () none 12) + (want-sound-banks (_type_ (pointer symbol)) none 12) (want-display-level (_type_ symbol symbol) int 13) (want-vis-level (_type_ symbol) none 14) (load-state-method-15 () none 15) diff --git a/test/decompiler/reference/jak2/engine/game/settings-h_REF.gc b/test/decompiler/reference/jak2/engine/game/settings-h_REF.gc index a2c623b33e..d7bf534ebe 100644 --- a/test/decompiler/reference/jak2/engine/game/settings-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/settings-h_REF.gc @@ -549,7 +549,7 @@ (new (symbol type int) _type_ 0) (setting-control-method-9 () none 9) (setting-control-method-10 () none 10) - (setting-control-method-11 () none 11) + (set-setting (_type_ process symbol object object object) none 11) (setting-control-method-12 () none 12) (setting-control-method-13 () none 13) (setting-control-method-14 () none 14) diff --git a/test/decompiler/reference/jak2/engine/gfx/hw/display_REF.gc b/test/decompiler/reference/jak2/engine/gfx/hw/display_REF.gc index ec3af31414..fc672a8b83 100644 --- a/test/decompiler/reference/jak2/engine/gfx/hw/display_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/hw/display_REF.gc @@ -70,7 +70,7 @@ ;; definition for symbol *font-context*, type font-context (define *font-context* - (new 'global 'font-context *font-default-matrix* 0 0 0.0 (font-color zero) (font-flags shadow kerning)) + (new 'global 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning)) ) ;; definition for function draw-sprite2d-xy @@ -491,7 +491,3 @@ ;; failed to figure out what this is: (kmemclose) - - - - diff --git a/test/decompiler/reference/jak2/engine/load/load-dgo_REF.gc b/test/decompiler/reference/jak2/engine/load/load-dgo_REF.gc new file mode 100644 index 0000000000..345eb51148 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/load/load-dgo_REF.gc @@ -0,0 +1,453 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type load-dgo-msg +(deftype load-dgo-msg (structure) + ((rsvd uint16 :offset-assert 0) + (result load-msg-result :offset-assert 2) + (b1 pointer :offset-assert 4) + (b2 pointer :offset-assert 8) + (bt pointer :offset-assert 12) + (name uint128 :offset-assert 16) + (address uint32 :offset 4) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +;; definition for method 3 of type load-dgo-msg +;; INFO: Used lq/sq +(defmethod inspect load-dgo-msg ((obj load-dgo-msg)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'load-dgo-msg) + (format #t "~1Trsvd: ~D~%" (-> obj rsvd)) + (format #t "~1Tresult: ~D~%" (-> obj result)) + (format #t "~1Tb1: #x~X~%" (-> obj b1)) + (format #t "~1Tb2: #x~X~%" (-> obj b2)) + (format #t "~1Tbt: #x~X~%" (-> obj bt)) + (format #t "~1Tname: ~D~%" (-> obj name)) + (format #t "~1Taddress: ~D~%" (-> obj b1)) + (label cfg-4) + obj + ) + +;; definition of type load-chunk-msg +(deftype load-chunk-msg (structure) + ((rsvd uint16 :offset-assert 0) + (result load-msg-result :offset-assert 2) + (address pointer :offset-assert 4) + (section uint32 :offset-assert 8) + (maxlen uint32 :offset-assert 12) + (dummy uint32 4 :offset-assert 16) + (basename sound-stream-name :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + ) + +;; definition for method 3 of type load-chunk-msg +(defmethod inspect load-chunk-msg ((obj load-chunk-msg)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'load-chunk-msg) + (format #t "~1Trsvd: ~D~%" (-> obj rsvd)) + (format #t "~1Tresult: ~D~%" (-> obj result)) + (format #t "~1Taddress: ~D~%" (-> obj address)) + (format #t "~1Tsection: ~D~%" (-> obj section)) + (format #t "~1Tmaxlen: ~D~%" (-> obj maxlen)) + (format #t "~1Tdummy[4] @ #x~X~%" (-> obj dummy)) + (format #t "~1Tbasename: #~%" (-> obj basename)) + (label cfg-4) + obj + ) + +;; definition of type play-chunk-msg +(deftype play-chunk-msg (structure) + ((rsvd uint16 :offset-assert 0) + (result uint16 :offset-assert 2) + (address pointer :offset-assert 4) + (section uint32 :offset-assert 8) + (maxlen uint32 :offset-assert 12) + (id uint32 4 :offset-assert 16) + (basename sound-stream-name 4 :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #xe0 + :flag-assert #x9000000e0 + ) + +;; definition for method 3 of type play-chunk-msg +(defmethod inspect play-chunk-msg ((obj play-chunk-msg)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'play-chunk-msg) + (format #t "~1Trsvd: ~D~%" (-> obj rsvd)) + (format #t "~1Tresult: ~D~%" (-> obj result)) + (format #t "~1Taddress: ~D~%" (-> obj address)) + (format #t "~1Tsection: ~D~%" (-> obj section)) + (format #t "~1Tmaxlen: ~D~%" (-> obj maxlen)) + (format #t "~1Tid[4] @ #x~X~%" (-> obj id)) + (format #t "~1Tbasename[4] @ #x~X~%" (-> obj basename)) + (label cfg-4) + obj + ) + +;; definition of type dgo-header +(deftype dgo-header (structure) + ((length uint32 :offset-assert 0) + (rootname uint8 60 :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x40 + :flag-assert #x900000040 + ) + +;; definition for method 3 of type dgo-header +(defmethod inspect dgo-header ((obj dgo-header)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'dgo-header) + (format #t "~1Tlength: ~D~%" (-> obj length)) + (format #t "~1Trootname[60] @ #x~X~%" (-> obj rootname)) + (label cfg-4) + obj + ) + +;; failed to figure out what this is: +(when (zero? *load-dgo-rpc*) + (set! *load-dgo-rpc* (new 'global 'rpc-buffer-pair (the-as uint 32) (the-as uint 1) 3)) + (set! *load-str-rpc* (new 'global 'rpc-buffer-pair (the-as uint 64) (the-as uint 1) 4)) + (set! *play-str-rpc* (new 'global 'rpc-buffer-pair (the-as uint 256) (the-as uint 2) 5)) + (set! *load-str-lock* #f) + (set! *que-str-lock* #f) + (set! *dgo-name* (new 'global 'string 64 (the-as string #f))) + ) + +;; definition for function str-load +(defun str-load ((arg0 string) (arg1 int) (arg2 pointer) (arg3 int)) + (if (or (check-busy *load-str-rpc*) *load-str-lock*) + (return #f) + ) + (let ((s2-0 (the-as load-chunk-msg (add-element *load-str-rpc*)))) + (set! (-> s2-0 result) (load-msg-result invalid)) + (set! (-> s2-0 address) arg2) + (set! (-> s2-0 section) (the-as uint arg1)) + (set! (-> s2-0 maxlen) (the-as uint arg3)) + (copyn-charp<-string (the-as (pointer uint8) (-> s2-0 basename)) arg0 48) + (call *load-str-rpc* (the-as uint 0) (the-as pointer s2-0) (the-as uint 32)) + ) + (set! *load-str-lock* #t) + (set! *que-str-lock* #t) + #t + ) + +;; definition for function str-load-status +(defun str-load-status ((arg0 (pointer int32))) + (if (check-busy *load-str-rpc*) + (return 'busy) + ) + (set! *load-str-lock* #f) + (set! *que-str-lock* #t) + (let ((v1-7 (the-as load-chunk-msg (pop-last-received *load-str-rpc*)))) + (if (= (-> v1-7 result) (load-msg-result error)) + (return 'error) + ) + (set! (-> arg0 0) (the-as int (-> v1-7 maxlen))) + ) + 'complete + ) + +;; definition for function str-load-cancel +;; INFO: Return type mismatch int vs none. +(defun str-load-cancel () + (set! *load-str-lock* #f) + (set! *que-str-lock* #t) + 0 + (none) + ) + +;; definition for function str-play-async +;; INFO: Return type mismatch int vs none. +(defun str-play-async ((arg0 string) (arg1 sound-id)) + (set! *que-str-lock* #t) + (let ((s4-0 (the-as play-chunk-msg (add-element *play-str-rpc*)))) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename)) arg0 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 1)) "" 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 2)) "" 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 3)) "" 48) + (set! (-> s4-0 id 0) (the-as uint arg1)) + (set! (-> s4-0 id 1) (the-as uint 0)) + (set! (-> s4-0 id 2) (the-as uint 0)) + (set! (-> s4-0 id 3) (the-as uint 0)) + (set! (-> s4-0 result) (the-as uint 0)) + ) + 0 + 0 + (none) + ) + +;; definition for function str-play-stop +;; INFO: Return type mismatch int vs none. +(defun str-play-stop ((arg0 string) (arg1 sound-id)) + (set! *que-str-lock* #t) + (let ((s4-0 (the-as play-chunk-msg (add-element *play-str-rpc*)))) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename)) arg0 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 1)) "" 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 2)) "" 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 3)) "" 48) + (set! (-> s4-0 id 0) (the-as uint arg1)) + (set! (-> s4-0 id 1) (the-as uint 0)) + (set! (-> s4-0 id 2) (the-as uint 0)) + (set! (-> s4-0 id 3) (the-as uint 0)) + (set! (-> s4-0 result) (the-as uint 1)) + ) + 0 + (none) + ) + +;; definition for function str-play-queue +;; INFO: Return type mismatch int vs none. +(defun str-play-queue ((arg0 string) (arg1 string) (arg2 string) (arg3 string) (arg4 (pointer uint32)) (arg5 pointer)) + (when (and (not (check-busy *play-str-rpc*)) (not *load-str-lock*) (not *que-str-lock*)) + (let ((s4-0 (the-as play-chunk-msg (add-element *play-str-rpc*)))) + (if arg0 + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename)) arg0 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename)) "" 48) + ) + (if arg1 + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 1)) arg1 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 1)) "" 48) + ) + (if arg2 + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 2)) arg2 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 2)) "" 48) + ) + (if arg3 + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 3)) arg3 48) + (copyn-charp<-string (the-as (pointer uint8) (-> s4-0 basename 3)) "" 48) + ) + (dotimes (v1-15 4) + (set! (-> s4-0 id v1-15) (-> arg4 v1-15)) + ) + (set! (-> s4-0 address) arg5) + (set! (-> s4-0 result) (the-as uint 2)) + ) + ) + (set! *que-str-lock* #f) + 0 + (none) + ) + +;; definition for function str-ambient-play +;; INFO: Return type mismatch int vs none. +(defun str-ambient-play ((arg0 string)) + (set! *que-str-lock* #t) + (let ((s5-0 (the-as load-chunk-msg (add-element *play-str-rpc*)))) + (set! (-> s5-0 basename name 0) (the-as uint 36)) + (copyn-charp<-string (&-> s5-0 basename name 1) arg0 48) + (set! (-> s5-0 result) (load-msg-result done)) + ) + 0 + 0 + (none) + ) + +;; definition for function str-ambient-stop +;; INFO: Return type mismatch int vs none. +(defun str-ambient-stop ((arg0 string)) + (set! *que-str-lock* #t) + (let ((s5-0 (the-as load-chunk-msg (add-element *play-str-rpc*)))) + (set! (-> s5-0 basename name 0) (the-as uint 36)) + (copyn-charp<-string (&-> s5-0 basename name 1) arg0 48) + (set! (-> s5-0 result) (load-msg-result error)) + ) + 0 + (none) + ) + +;; definition for function str-play-kick +;; INFO: Return type mismatch int vs none. +(defun str-play-kick () + (cond + ((check-busy *play-str-rpc*) + ) + (else + (call *play-str-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + ) + ) + 0 + (none) + ) + +;; definition for symbol *dgo-time*, type time-frame +(define *dgo-time* (the-as time-frame 0)) + +;; definition for function dgo-load-begin +;; INFO: Used lq/sq +(defun dgo-load-begin ((arg0 string) (arg1 pointer) (arg2 pointer) (arg3 pointer)) + (set! *dgo-time* (the-as time-frame (-> *display* real-clock integral-frame-counter))) + (format 0 "Starting level load clock~%") + (sync *load-dgo-rpc* #t) + (let ((s2-0 (the-as load-dgo-msg (add-element *load-dgo-rpc*)))) + (set! (-> s2-0 result) (load-msg-result invalid)) + (set! (-> s2-0 b1) arg1) + (set! (-> s2-0 b2) arg2) + (set! (-> s2-0 bt) arg3) + (set! (-> s2-0 name) (string->sound-name arg0)) + (call *load-dgo-rpc* (the-as uint 0) (the-as pointer s2-0) (the-as uint 32)) + s2-0 + ) + ) + +;; definition for function dgo-load-get-next +(defun dgo-load-get-next ((arg0 (pointer symbol))) + (set! (-> arg0 0) #f) + (let ((gp-0 (the-as pointer #f))) + (when (not (check-busy *load-dgo-rpc*)) + (let ((v1-4 (the-as load-dgo-msg (pop-last-received *load-dgo-rpc*)))) + (when v1-4 + (when (or (= (-> v1-4 result) (load-msg-result done)) (= (-> v1-4 result) (load-msg-result more))) + (set! gp-0 (-> v1-4 b1)) + (set! (-> arg0 0) #t) + ) + (if (= (-> v1-4 result) (load-msg-result more)) + (set! (-> arg0 0) #f) + ) + (if (= (-> v1-4 result) (load-msg-result done)) + (format + 0 + "Elapsed time for level = ~Fs~%" + (* 0.016666668 (the float (- (-> *display* real-clock integral-frame-counter) (the-as uint *dgo-time*)))) + ) + ) + ) + ) + ) + gp-0 + ) + ) + +;; definition for function dgo-load-continue +;; INFO: Used lq/sq +(defun dgo-load-continue ((arg0 pointer) (arg1 pointer) (arg2 pointer)) + (let ((gp-0 (the-as load-dgo-msg (add-element *load-dgo-rpc*)))) + (set! (-> gp-0 result) (load-msg-result invalid)) + (set! (-> gp-0 b1) arg0) + (set! (-> gp-0 b2) arg1) + (set! (-> gp-0 bt) arg2) + (set! (-> gp-0 name) (the-as uint128 0)) + (call *load-dgo-rpc* (the-as uint 1) (the-as pointer gp-0) (the-as uint 32)) + gp-0 + ) + ) + +;; definition for function dgo-load-cancel +;; INFO: Return type mismatch int vs none. +(defun dgo-load-cancel () + (sync *load-dgo-rpc* #t) + (let ((a2-0 (add-element *load-dgo-rpc*))) + (call *load-dgo-rpc* (the-as uint 2) a2-0 (the-as uint 32)) + ) + 0 + (none) + ) + +;; definition for function find-temp-buffer +(defun find-temp-buffer ((arg0 int)) + (let ((gp-0 (+ (/ arg0 16) 2))) + (cond + ((< (the-as uint gp-0) + (the-as uint (dma-buffer-free (-> *display* frames (-> *display* on-screen) global-buf))) + ) + (logand -16 (&+ (-> *display* frames (-> *display* on-screen) global-buf base) 15)) + ) + ((< (the-as uint gp-0) + (the-as uint (dma-buffer-free (-> *display* frames (-> *display* on-screen) global-buf))) + ) + (logand -16 (&+ (-> *display* frames (-> *display* on-screen) global-buf base) 15)) + ) + ) + ) + ) + +;; definition for function dgo-load-link +(defun dgo-load-link ((arg0 dgo-header) (arg1 kheap) (arg2 uint) (arg3 symbol) (arg4 symbol)) + (let ((s4-0 (the-as object (&+ arg0 64)))) + (let ((v1-0 arg2)) + (cond + ((>= (the-as int (+ (the-as uint s4-0) (-> arg0 length))) (the-as int (-> arg1 top-base))) + (format + 0 + "ERROR: -----> dgo file header ~g #x~X has overrun heap #x~X by ~D bytes. This is very bad!~%" + (-> arg0 rootname) + arg0 + arg1 + (- (+ (the-as uint s4-0) (-> arg0 length)) (the-as uint (-> arg1 top-base))) + ) + ) + ((and (< (the-as int arg0) (the-as int v1-0)) + (>= (the-as int (+ (the-as uint s4-0) (-> arg0 length))) (the-as int v1-0)) + ) + (format + 0 + "ERROR: -----> dgo file header ~g #x~X has overrun heap #x~X by ~D bytes. This is very bad!~%" + (-> arg0 rootname) + arg0 + arg1 + (- (+ (the-as uint s4-0) (-> arg0 length)) v1-0) + ) + ) + ) + ) + (if arg4 + (format + 0 + "NOTICE: loaded ~g, ~D bytes (~f K) at top ~D at #x~X~%" + (-> arg0 rootname) + (-> arg0 length) + (* 0.0009765625 (the float (-> arg0 length))) + (- (+ (the-as uint s4-0) (-> arg0 length)) (the-as uint (-> arg1 base))) + arg0 + ) + ) + (string<-charp (clear *dgo-name*) (-> arg0 rootname)) + (nonzero? (link-begin + (the-as pointer s4-0) + (-> *dgo-name* data) + (the-as int (-> arg0 length)) + arg1 + (the-as link-flag (if arg3 + 47 + 39 + ) + ) + ) + ) + ) + ) + +;; definition for function destroy-mem +;; INFO: Return type mismatch int vs none. +(defun destroy-mem ((arg0 (pointer uint32)) (arg1 (pointer uint32))) + (while (< (the-as int arg0) (the-as int arg1)) + (set! (-> arg0 0) (the-as uint #xffffffff)) + (set! arg0 (&-> arg0 1)) + ) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak2/engine/load/ramdisk_REF.gc b/test/decompiler/reference/jak2/engine/load/ramdisk_REF.gc new file mode 100644 index 0000000000..401bf86dc3 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/load/ramdisk_REF.gc @@ -0,0 +1,119 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type ramdisk-rpc-fill +(deftype ramdisk-rpc-fill (structure) + ((rsvd1 int32 :offset-assert 0) + (ee-id int32 :offset-assert 4) + (rsvd2 int32 2 :offset-assert 8) + (filename uint128 :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +;; definition for method 3 of type ramdisk-rpc-fill +;; INFO: Used lq/sq +(defmethod inspect ramdisk-rpc-fill ((obj ramdisk-rpc-fill)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'ramdisk-rpc-fill) + (format #t "~1Trsvd1: ~D~%" (-> obj rsvd1)) + (format #t "~1Tee-id: ~D~%" (-> obj ee-id)) + (format #t "~1Trsvd2[2] @ #x~X~%" (-> obj rsvd2)) + (format #t "~1Tfilename: ~D~%" (-> obj filename)) + (label cfg-4) + obj + ) + +;; definition of type ramdisk-rpc-load +(deftype ramdisk-rpc-load (structure) + ((rsvd int32 :offset-assert 0) + (ee-id int32 :offset-assert 4) + (offset uint32 :offset-assert 8) + (length uint32 :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +;; definition for method 3 of type ramdisk-rpc-load +(defmethod inspect ramdisk-rpc-load ((obj ramdisk-rpc-load)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'ramdisk-rpc-load) + (format #t "~1Trsvd: ~D~%" (-> obj rsvd)) + (format #t "~1Tee-id: ~D~%" (-> obj ee-id)) + (format #t "~1Toffset: ~D~%" (-> obj offset)) + (format #t "~1Tlength: ~D~%" (-> obj length)) + (label cfg-4) + obj + ) + +;; definition of type ramdisk-rpc-load-to-ee +(deftype ramdisk-rpc-load-to-ee (structure) + ((rsvd int32 :offset-assert 0) + (addr int32 :offset-assert 4) + (offset int32 :offset-assert 8) + (length int32 :offset-assert 12) + (filename uint128 :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +;; definition for method 3 of type ramdisk-rpc-load-to-ee +;; INFO: Used lq/sq +(defmethod inspect ramdisk-rpc-load-to-ee ((obj ramdisk-rpc-load-to-ee)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'ramdisk-rpc-load-to-ee) + (format #t "~1Trsvd: ~D~%" (-> obj rsvd)) + (format #t "~1Taddr: ~D~%" (-> obj addr)) + (format #t "~1Toffset: ~D~%" (-> obj offset)) + (format #t "~1Tlength: ~D~%" (-> obj length)) + (format #t "~1Tfilename: ~D~%" (-> obj filename)) + (label cfg-4) + obj + ) + +;; definition for symbol *ramdisk-rpc*, type rpc-buffer-pair +(define *ramdisk-rpc* (new 'global 'rpc-buffer-pair (the-as uint 32) (the-as uint 1) 2)) + +;; definition for symbol *current-ramdisk-id*, type int +(define *current-ramdisk-id* 0) + +;; definition for function ramdisk-load +(defun ramdisk-load ((arg0 int) (arg1 uint) (arg2 uint) (arg3 pointer)) + (let ((v1-1 (the-as ramdisk-rpc-load (add-element *ramdisk-rpc*)))) + (set! (-> v1-1 offset) arg1) + (set! (-> v1-1 ee-id) arg0) + (set! (-> v1-1 length) arg2) + ) + (call *ramdisk-rpc* (the-as uint 0) arg3 arg2) + 0 + ) + +;; definition for function ramdisk-sync +;; INFO: Return type mismatch int vs none. +(defun ramdisk-sync () + (sync *ramdisk-rpc* #t) + 0 + (none) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jak2/engine/math/transformq-h_REF.gc b/test/decompiler/reference/jak2/engine/math/transformq-h_REF.gc index d44e3ef74a..0ea261db90 100644 --- a/test/decompiler/reference/jak2/engine/math/transformq-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/math/transformq-h_REF.gc @@ -72,7 +72,7 @@ (set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion 14) (set-roll-to-grav! (_type_ float) quaternion 15) (set-roll-to-grav-2! (_type_ float) quaternion 16) - (rotate-toward-orientation! (_type_ quaternion float float) quaternion 17) + (rotate-toward-orientation! (_type_ quaternion float float int float float) quaternion 17) (set-quaternion! (_type_ quaternion) quaternion 18) (set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion 19) (point-toward-point-clear-roll-pitch! (_type_ vector) quaternion 20) diff --git a/test/decompiler/reference/jak2/engine/math/transformq_REF.gc b/test/decompiler/reference/jak2/engine/math/transformq_REF.gc new file mode 100644 index 0000000000..aad9715f56 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/math/transformq_REF.gc @@ -0,0 +1,468 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 2 of type transformq +(defmethod print transformq ((obj transformq)) + (format #t "# obj trans x) (-> obj trans y) (-> obj trans z) (-> obj trans w)) + (format #t "~T~Tquat: ~F ~F ~F ~F ~%" (-> obj quat x) (-> obj quat y) (-> obj quat z) (-> obj quat w)) + (format #t "~T~Tscale:~F ~F ~F ~F>" (-> obj scale x) (-> obj scale y) (-> obj scale z) (-> obj scale w)) + obj + ) + +;; definition for method 27 of type trsqv +(defmethod get-quaternion trsqv ((obj trsqv)) + (-> obj quat) + ) + +;; definition for method 18 of type trsqv +(defmethod set-quaternion! trsqv ((obj trsqv) (arg0 quaternion)) + (quaternion-copy! (get-quaternion obj) arg0) + ) + +;; definition for method 21 of type trsqv +(defmethod rot->dir-targ! trsqv ((obj trsqv)) + (quaternion-copy! (-> obj dir-targ) (get-quaternion obj)) + ) + +;; definition for method 22 of type trsqv +(defmethod y-angle trsqv ((obj trsqv)) + (quaternion-y-angle (get-quaternion obj)) + ) + +;; definition for method 9 of type trsqv +(defmethod seek-toward-heading-vec! trsqv ((obj trsqv) (arg0 vector) (arg1 float) (arg2 time-frame)) + (with-pp + (let* ((f0-0 (deg-diff (quaternion-y-angle (-> obj quat)) (vector-y-angle arg0))) + (f1-2 (fmin (* arg1 (-> pp clock seconds-per-frame)) (/ (* 5.0 (fabs f0-0)) (the float arg2)))) + (f30-0 (fmax (fmin f0-0 f1-2) (- f1-2))) + ) + (let ((f0-2 (-> obj old-y-angle-diff))) + (set! f30-0 (cond + ((or (= f0-2 0.0) + (and (< 0.0 f30-0) (< 0.0 f0-2)) + (or (and (< f30-0 0.0) (< f0-2 0.0)) + (>= (- (-> pp clock frame-counter) (-> obj angle-change-time)) (seconds 0.2)) + ) + ) + (set! (-> obj angle-change-time) (-> pp clock frame-counter)) + f30-0 + ) + (else + (* 0.000000001 f30-0) + ) + ) + ) + ) + (set! (-> obj old-y-angle-diff) f30-0) + (let ((a1-2 (get-quaternion obj))) + (quaternion-rotate-y! a1-2 a1-2 f30-0) + ) + ) + ) + ) + +;; definition for method 10 of type trsqv +(defmethod set-heading-vec! trsqv ((obj trsqv) (arg0 vector)) + (let ((s3-0 (get-quaternion obj))) + (forward-up-nopitch->quaternion + s3-0 + (vector-normalize-copy! (new 'stack-no-clear 'vector) arg0 1.0) + (vector-y-quaternion! (new 'stack-no-clear 'vector) s3-0) + ) + ) + ) + +;; definition for method 11 of type trsqv +(defmethod seek-to-point-toward-point! trsqv ((obj trsqv) (arg0 vector) (arg1 float) (arg2 time-frame)) + (seek-toward-heading-vec! obj (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj trans)) arg1 arg2) + ) + +;; definition for method 12 of type trsqv +(defmethod point-toward-point! trsqv ((obj trsqv) (arg0 vector)) + (let ((s3-0 (get-quaternion obj))) + (forward-up-nopitch->quaternion + s3-0 + (vector-normalize! (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj trans)) 1.0) + (vector-y-quaternion! (new 'stack-no-clear 'vector) s3-0) + ) + ) + ) + +;; definition for method 13 of type trsqv +(defmethod seek-toward-yaw-angle! trsqv ((obj trsqv) (arg0 float) (arg1 float) (arg2 time-frame)) + (let ((s3-0 (method-of-object obj seek-toward-heading-vec!)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s2-0 x) (sin arg0)) + (set! (-> s2-0 y) 0.0) + (set! (-> s2-0 z) (cos arg0)) + (set! (-> s2-0 w) 1.0) + (s3-0 obj s2-0 arg1 arg2) + ) + ) + +;; definition for method 14 of type trsqv +(defmethod set-yaw-angle-clear-roll-pitch! trsqv ((obj trsqv) (arg0 float)) + (let ((s5-0 (method-of-object obj set-heading-vec-clear-roll-pitch!)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s4-0 x) (sin arg0)) + (set! (-> s4-0 y) 0.0) + (set! (-> s4-0 z) (cos arg0)) + (set! (-> s4-0 w) 1.0) + (s5-0 obj s4-0) + ) + ) + +;; definition for method 15 of type trsqv +(defmethod set-roll-to-grav! trsqv ((obj trsqv) (arg0 float)) + (set-roll-to-grav-2! obj arg0) + ) + +;; definition for method 16 of type trsqv +(defmethod set-roll-to-grav-2! trsqv ((obj trsqv) (arg0 float)) + (let* ((s5-0 (get-quaternion obj)) + (s1-0 (-> *standard-dynamics* gravity-normal)) + (s3-0 (quaternion->matrix (new 'stack-no-clear 'matrix) s5-0)) + ) + (let ((s4-0 (&-> s3-0 data 8))) + (vector-normalize! (vector-flatten! (the-as vector (&-> s3-0 data 4)) s1-0 (the-as vector s4-0)) 1.0) + (vector-cross! (the-as vector (-> s3-0 data)) (the-as vector (&-> s3-0 data 4)) (the-as vector s4-0)) + ) + (let ((a1-5 (matrix-rotate-z! (new 'stack-no-clear 'matrix) arg0))) + (matrix*! s3-0 a1-5 s3-0) + ) + (matrix->quaternion s5-0 s3-0) + ) + ) + +;; definition for method 25 of type trsqv +(defmethod roll-relative-to-gravity trsqv ((obj trsqv)) + (let* ((s5-0 (get-quaternion obj)) + (gp-0 (vector-z-quaternion! (new 'stack-no-clear 'vector) s5-0)) + (s5-1 (vector-y-quaternion! (new 'stack-no-clear 'vector) s5-0)) + (a1-2 (-> *standard-dynamics* gravity-normal)) + (v1-2 (vector-normalize! (vector-flatten! (new 'stack-no-clear 'vector) a1-2 gp-0) 1.0)) + (f0-1 (vector-dot v1-2 s5-1)) + ) + (if (< (vector-dot (vector-cross! (new 'stack-no-clear 'vector) v1-2 s5-1) gp-0) 0.0) + (- (acos f0-1)) + (acos f0-1) + ) + ) + ) + +;; definition for method 17 of type trsqv +;; INFO: Used lq/sq +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f0, f3] +;; ERROR: Unsupported inline assembly instruction kind - [madda.s f1, f4] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] +(defmethod rotate-toward-orientation! trsqv ((obj trsqv) (arg0 quaternion) (arg1 float) (arg2 float) (arg3 int) (arg4 float) (arg5 float)) + (local-vars + (f0-4 float) + (sv-192 (function quaternion vector vector float int quaternion)) + (sv-208 quaternion) + (sv-224 vector) + (sv-240 float) + (sv-256 vector) + (sv-272 vector) + ) + (set! sv-240 arg4) + (let ((s2-0 arg5) + (s5-0 (get-quaternion obj)) + ) + (let ((gp-0 (new 'stack-no-clear 'quaternion))) + (when (< 0.0 arg2) + (set! sv-192 quaternion-from-two-vectors-smooth!) + (set! sv-208 gp-0) + (set! sv-224 (vector-y-quaternion! (new 'stack-no-clear 'vector) s5-0)) + (let ((a2-1 (vector-y-quaternion! (new 'stack-no-clear 'vector) arg0))) + (sv-192 sv-208 sv-224 a2-1 arg2 (the-as int sv-240)) + ) + (quaternion-normalize! (quaternion*! s5-0 gp-0 s5-0)) + ) + (when (< 0.0 arg1) + (set! sv-256 (vector-y-quaternion! (new 'stack-no-clear 'vector) s5-0)) + (let ((s1-2 (vector-z-quaternion! (new 'stack-no-clear 'vector) s5-0))) + (set! sv-272 (vector-z-quaternion! (new 'stack-no-clear 'vector) arg0)) + (let ((s0-1 (new 'stack-no-clear 'matrix))) + (vector-flatten! s1-2 s1-2 sv-256) + (vector-flatten! sv-272 sv-272 sv-256) + (vector-normalize! s1-2 1.0) + (vector-normalize! sv-272 1.0) + (cond + ((!= s2-0 0.0) + (let* ((v1-5 (vector-cross! (new 'stack-no-clear 'vector) s1-2 sv-272)) + (f0-3 (-> sv-256 x)) + (f1-3 (-> sv-256 y)) + (f2-0 (-> sv-256 z)) + (f3-0 (-> v1-5 x)) + (f4-0 (-> v1-5 y)) + (f5-0 (-> v1-5 z)) + ) + (.mula.s f0-3 f3-0) + (.madda.s f1-3 f4-0) + (.madd.s f0-4 f2-0 f5-0) + ) + (if (< (* f0-4 s2-0) 0.0) + (matrix-from-two-vectors-the-long-way-smooth! s0-1 s1-2 sv-272 arg1 arg3) + (matrix-from-two-vectors-smooth! s0-1 s1-2 sv-272 arg1 arg3) + ) + ) + (else + (matrix-from-two-vectors-smooth! s0-1 s1-2 sv-272 arg1 arg3) + ) + ) + (matrix->quaternion gp-0 s0-1) + ) + ) + (quaternion-normalize! (quaternion*! s5-0 gp-0 s5-0)) + ) + ) + s5-0 + ) + ) + +;; definition for method 19 of type trsqv +(defmethod set-heading-vec-clear-roll-pitch! trsqv ((obj trsqv) (arg0 vector)) + (forward-up->quaternion + (get-quaternion obj) + (vector-normalize-copy! (new 'stack-no-clear 'vector) arg0 1.0) + (new 'static 'vector :y 1.0 :w 1.0) + ) + ) + +;; definition for method 20 of type trsqv +(defmethod point-toward-point-clear-roll-pitch! trsqv ((obj trsqv) (arg0 vector)) + (forward-up->quaternion + (get-quaternion obj) + (vector-normalize! (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj trans)) 1.0) + (new 'static 'vector :y 1.0 :w 1.0) + ) + ) + +;; definition for function transformq-copy! +;; INFO: Used lq/sq +(defun transformq-copy! ((arg0 transformq) (arg1 transformq)) + (let ((v1-0 (-> arg1 trans quad)) + (a2-0 (-> arg1 quat vec quad)) + (a1-1 (-> arg1 scale quad)) + ) + (set! (-> arg0 trans quad) v1-0) + (set! (-> arg0 quat vec quad) a2-0) + (set! (-> arg0 scale quad) a1-1) + ) + arg0 + ) + +;; definition for function matrix<-transformq! +;; INFO: Used lq/sq +(defun matrix<-transformq! ((arg0 matrix) (arg1 transformq)) + (local-vars (v1-1 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (quaternion->matrix arg0 (-> arg1 quat)) + (cond + (#f + (set! (-> arg0 trans quad) (-> arg1 trans quad)) + ) + (else + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf2 (&-> arg1 trans quad)) + (.lvf vf3 (&-> arg0 vector 0 quad)) + (.lvf vf4 (&-> arg0 vector 1 quad)) + (.lvf vf5 (&-> arg0 vector 2 quad)) + (.mov.vf vf2 vf0 :mask #b1000) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf3) + (.svf (&-> arg0 vector 1 quad) vf4) + (.svf (&-> arg0 vector 2 quad) vf5) + (.mov v1-1 vf5) + ) + ) + arg0 + ) + ) + +;; definition for function matrix<-no-trans-transformq! +(defun matrix<-no-trans-transformq! ((arg0 matrix) (arg1 transformq)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (quaternion->matrix arg0 (-> arg1 quat)) + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf3 (&-> arg0 vector 0 quad)) + (.lvf vf4 (&-> arg0 vector 1 quad)) + (.lvf vf5 (&-> arg0 vector 2 quad)) + (.mov.vf vf2 vf0) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf3) + (.svf (&-> arg0 vector 1 quad) vf4) + (.svf (&-> arg0 vector 2 quad) vf5) + arg0 + ) + ) + +;; definition for function matrix<-transformq+trans! +(defun matrix<-transformq+trans! ((arg0 matrix) (arg1 transformq) (arg2 vector)) + (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) + (quaternion->matrix arg0 (-> arg1 quat)) + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf2 (&-> arg1 trans quad)) + (.lvf vf6 (&-> arg2 quad)) + (.lvf vf3 (&-> arg0 vector 0 quad)) + (.lvf vf4 (&-> arg0 vector 1 quad)) + (.lvf vf5 (&-> arg0 vector 2 quad)) + (.mov.vf vf2 vf0 :mask #b1000) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.mul.x.vf acc vf3 vf6) + (.add.mul.y.vf acc vf4 vf6 acc) + (.add.mul.z.vf acc vf5 vf6 acc) + (.add.mul.w.vf vf2 vf2 vf0 acc :mask #b111) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf3) + (.svf (&-> arg0 vector 1 quad) vf4) + (.svf (&-> arg0 vector 2 quad) vf5) + arg0 + ) + ) + +;; definition for function matrix<-transformq+world-trans! +(defun matrix<-transformq+world-trans! ((arg0 matrix) (arg1 transformq) (arg2 vector)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (quaternion->matrix arg0 (-> arg1 quat)) + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf2 (&-> arg1 trans quad)) + (.lvf vf6 (&-> arg2 quad)) + (.lvf vf3 (&-> arg0 vector 0 quad)) + (.lvf vf4 (&-> arg0 vector 1 quad)) + (.lvf vf5 (&-> arg0 vector 2 quad)) + (.mov.vf vf2 vf0 :mask #b1000) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.add.vf vf2 vf2 vf6 :mask #b111) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf3) + (.svf (&-> arg0 vector 1 quad) vf4) + (.svf (&-> arg0 vector 2 quad) vf5) + arg0 + ) + ) + +;; definition for function matrix<-parented-transformq! +(defun matrix<-parented-transformq! ((arg0 matrix) (arg1 transformq) (arg2 vector)) + (local-vars (v1-1 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (quaternion->matrix arg0 (-> arg1 quat)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (set! (-> v1-0 x) (/ 1.0 (-> arg2 x))) + (set! (-> v1-0 y) (/ 1.0 (-> arg2 y))) + (set! (-> v1-0 z) (/ 1.0 (-> arg2 z))) + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf2 (&-> arg1 trans quad)) + (.mov.vf vf2 vf0 :mask #b1000) + (.lvf vf4 (&-> arg0 vector 0 quad)) + (.lvf vf5 (&-> arg0 vector 1 quad)) + (.lvf vf6 (&-> arg0 vector 2 quad)) + (.mul.x.vf vf4 vf4 vf1) + (.mul.y.vf vf5 vf5 vf1) + (.mul.z.vf vf6 vf6 vf1) + (.lvf vf3 (&-> v1-0 quad)) + ) + (.mul.vf vf4 vf4 vf3) + (.mul.vf vf5 vf5 vf3) + (.mul.vf vf6 vf6 vf3) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf4) + (.svf (&-> arg0 vector 1 quad) vf5) + (.svf (&-> arg0 vector 2 quad) vf6) + (.mov v1-1 vf6) + arg0 + ) + ) + +;; definition for function matrix<-transformq+rot-offset! +(defun matrix<-transformq+rot-offset! ((arg0 matrix) (arg1 transformq) (arg2 vector)) + (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) + (quaternion->matrix arg0 (-> arg1 quat)) + (.lvf vf1 (&-> arg1 scale quad)) + (.lvf vf2 (&-> arg1 trans quad)) + (.lvf vf6 (&-> arg2 quad)) + (.lvf vf3 (&-> arg0 vector 0 quad)) + (.lvf vf4 (&-> arg0 vector 1 quad)) + (.lvf vf5 (&-> arg0 vector 2 quad)) + (.mov.vf vf2 vf0 :mask #b1000) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.mul.x.vf acc vf3 vf6) + (.add.mul.y.vf acc vf4 vf6 acc) + (.add.mul.z.vf acc vf5 vf6 acc) + (.sub.mul.w.vf acc vf6 vf0 acc) + (.add.mul.w.vf vf2 vf2 vf0 acc :mask #b111) + (.svf (&-> arg0 trans quad) vf2) + (.svf (&-> arg0 vector 0 quad) vf3) + (.svf (&-> arg0 vector 1 quad) vf4) + (.svf (&-> arg0 vector 2 quad) vf5) + arg0 + ) + ) + + + + diff --git a/test/decompiler/reference/jak2/engine/sound/gsound-h_REF.gc b/test/decompiler/reference/jak2/engine/sound/gsound-h_REF.gc index f599cd7711..9723eb1ae1 100644 --- a/test/decompiler/reference/jak2/engine/sound/gsound-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/sound/gsound-h_REF.gc @@ -5,6 +5,7 @@ (deftype sound-stream-name (structure) ((name uint8 48 :offset-assert 0) ) + :pack-me :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 @@ -76,17 +77,18 @@ ;; definition of type sound-play-params (deftype sound-play-params (structure) - ((mask uint16 :offset-assert 0) - (pitch-mod int16 :offset-assert 2) - (bend int16 :offset-assert 4) - (fo-min int16 :offset-assert 6) - (fo-max int16 :offset-assert 8) - (fo-curve int8 :offset-assert 10) - (priority int8 :offset-assert 11) - (volume int32 :offset-assert 12) - (trans int32 3 :offset-assert 16) - (group uint8 :offset-assert 28) - (reg uint8 3 :offset-assert 29) + ((mask uint16 :offset-assert 0) + (pitch-mod int16 :offset-assert 2) + (bend int16 :offset-assert 4) + (fo-min int16 :offset-assert 6) + (fo-max int16 :offset-assert 8) + (fo-curve int8 :offset-assert 10) + (priority int8 :offset-assert 11) + (volume int32 :offset-assert 12) + (trans int32 3 :offset-assert 16) + (group uint8 :offset-assert 28) + (reg uint8 3 :offset-assert 29) + (group-and-regs uint32 :offset 28) ) :allow-misaligned :method-count-assert 9 @@ -142,8 +144,8 @@ ;; definition of type sound-rpc-test-cmd (deftype sound-rpc-test-cmd (sound-rpc-cmd) - ((ee-addr uint32 :offset-assert 4) - (param0 uint16 :offset-assert 8) + ((ee-addr pointer :offset-assert 4) + (param0 uint16 :offset-assert 8) ) :method-count-assert 9 :size-assert #xa @@ -213,7 +215,7 @@ ;; definition of type sound-rpc-load-bank (deftype sound-rpc-load-bank (sound-rpc-bank-cmd) - ((ee-addr uint32 :offset-assert 32) + ((ee-addr pointer :offset-assert 32) ) :method-count-assert 9 :size-assert #x24 @@ -829,6 +831,7 @@ (num float :offset-assert 8) (group sound-group :offset-assert 12) (reg uint8 3 :offset-assert 13) + (group-and-regs uint32 :offset 12) (sound-name-char uint8 16 :offset-assert 16) (sound-name sound-name :offset 16) (trans int32 4 :offset-assert 32) @@ -901,13 +904,14 @@ :size-assert #x6c :flag-assert #x100000006c (:methods - (ambient-sound-method-9 () none 9) - (ambient-sound-method-10 () none 10) - (ambient-sound-method-11 () none 11) - (ambient-sound-method-12 () none 12) - (ambient-sound-method-13 () none 13) - (ambient-sound-method-14 () none 14) - (ambient-sound-method-15 () none 15) + (new (symbol type basic vector) _type_ 0) + (update! (_type_) int 9) + (change-sound! (_type_ sound-name) int 10) + (update-trans! (_type_ vector) int 11) + (update-vol! (_type_ float) int 12) + (update-pitch-mod! (_type_ float) none 13) + (set-falloff-far! (_type_ float) none 14) + (stop! (_type_) int 15) ) ) diff --git a/test/decompiler/reference/jak2/engine/sound/gsound_REF.gc b/test/decompiler/reference/jak2/engine/sound/gsound_REF.gc new file mode 100644 index 0000000000..71c4c7250d --- /dev/null +++ b/test/decompiler/reference/jak2/engine/sound/gsound_REF.gc @@ -0,0 +1,1334 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type engine-sound-pers +(deftype engine-sound-pers (engine-pers) + () + :method-count-assert 15 + :size-assert #x20 + :flag-assert #xf00000020 + ) + +;; definition for method 3 of type engine-sound-pers +(defmethod inspect engine-sound-pers ((obj engine-sound-pers)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~1Tname: ~A~%" (-> obj name)) + (format #t "~1Tlength: ~D~%" (-> obj length)) + (format #t "~1Tallocated-length: ~D~%" (-> obj allocated-length)) + (format #t "~1Telement-type: ~A~%" (-> obj element-type)) + (format #t "~1Texecute-time: ~D~%" (-> obj execute-time)) + (format #t "~1Talive-list: #~%" (-> obj alive-list)) + (format #t "~1Tdead-list: #~%" (-> obj dead-list)) + (format #t "~1Tdata[0] @ #x~X~%" (-> obj data)) + (label cfg-4) + obj + ) + +;; definition for method 10 of type engine-sound-pers +;; INFO: Return type mismatch int vs none. +(defmethod kill-callback engine-sound-pers ((obj engine-sound-pers) (arg0 connection-pers)) + (let ((v1-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-param)) + (set! (-> v1-0 id) (the-as sound-id (-> arg0 param-int64 0))) + (set! (-> v1-0 params volume) -4) + (set! (-> v1-0 auto-time) 120) + (set! (-> v1-0 auto-from) 2) + (set! (-> v1-0 params mask) (the-as uint 17)) + (the-as sound-rpc-set-param (-> v1-0 id)) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(kmemopen global "sound-loop-engine") + +;; definition for symbol *sound-loop-engine*, type engine-sound-pers +(define *sound-loop-engine* (new 'global 'engine-sound-pers '*sound-loop-engine* 32 connection-pers)) + +;; failed to figure out what this is: +(kmemclose) + +;; failed to figure out what this is: +(kmemopen global "sound-rpc") + +;; definition for symbol *sound-player-rpc*, type rpc-buffer-pair +(define *sound-player-rpc* (new 'global 'rpc-buffer-pair (the-as uint 80) (the-as uint 128) 0)) + +;; definition for symbol *sound-loader-rpc*, type rpc-buffer-pair +(define *sound-loader-rpc* (new 'global 'rpc-buffer-pair (the-as uint 80) (the-as uint 1) 1)) + +;; failed to figure out what this is: +(kmemclose) + +;; definition for function sound-name= +(defun sound-name= ((arg0 sound-name) (arg1 sound-name)) + (and (= (the-as uint arg0) (the-as uint arg1)) (= (-> arg0 hi) (-> arg1 hi))) + ) + +;; definition of type sound-iop-info +(deftype sound-iop-info (structure) + ((frame uint32 :offset-assert 0) + (strpos int32 :offset-assert 4) + (str-id uint32 :offset-assert 8) + (str-id-sign int32 :offset 8) + (freemem uint32 :offset-assert 12) + (chinfo uint8 48 :offset-assert 16) + (freemem2 uint32 :offset-assert 64) + (nocd uint32 :offset-assert 68) + (dirtycd uint32 :offset-assert 72) + (diskspeed uint32 2 :offset-assert 76) + (lastspeed uint32 :offset-assert 84) + (dupseg int32 :offset-assert 88) + (times int32 41 :offset-assert 92) + (times-seq uint32 :offset-assert 256) + (iop-ticks uint32 :offset-assert 260) + (stream-position uint32 4 :offset 272) + (stream-status stream-status 4 :offset-assert 288) + (stream-name sound-stream-name 4 :inline :offset-assert 304) + (stream-id uint32 4 :offset-assert 496) + (music-register uint8 17 :offset-assert 512) + (music-excite int8 :offset 528) + (ramdisk-name uint8 48 :offset-assert 529) + ) + :method-count-assert 9 + :size-assert #x241 + :flag-assert #x900000241 + ) + +;; definition for method 3 of type sound-iop-info +(defmethod inspect sound-iop-info ((obj sound-iop-info)) + (when (not obj) + (set! obj obj) + (goto cfg-16) + ) + (format #t "[~8x] ~A~%" obj 'sound-iop-info) + (format #t "~1Tframe: ~D~%" (-> obj frame)) + (format #t "~1Tstrpos: ~D~%" (-> obj strpos)) + (format #t "~1Tstr-id: ~D~%" (-> obj str-id)) + (format #t "~1Tstr-id-sign: ~D~%" (-> obj str-id-sign)) + (format #t "~1Tfreemem: ~D~%" (-> obj freemem)) + (format #t "~1Tchinfo[48] @ #x~X~%" (-> obj chinfo)) + (format #t "~1Tfreemem2: ~D~%" (-> obj freemem2)) + (format #t "~1Tnocd: ~D~%" (-> obj nocd)) + (format #t "~1Tdirtycd: ~D~%" (-> obj dirtycd)) + (format #t "~1Tdiskspeed[2] @ #x~X~%" (-> obj diskspeed)) + (format #t "~1Tlastspeed: ~D~%" (-> obj lastspeed)) + (format #t "~1Tdupseg: ~D~%" (-> obj dupseg)) + (format #t "~1Ttimes[41] @ #x~X~%" (-> obj times)) + (format #t "~1Ttimes-seq: ~D~%" (-> obj times-seq)) + (format #t "~1Tiop-ticks: ~D~%" (-> obj iop-ticks)) + (format #t "~1Tstream-position[4] @ #x~X~%" (-> obj stream-position)) + (dotimes (s5-0 4) + (format #t "~T [~D]~1Tstream-position: ~`integer`P~%" s5-0 (-> obj stream-position s5-0)) + ) + (format #t "~1Tstream-status[4] @ #x~X~%" (-> obj stream-status)) + (dotimes (s5-1 4) + (format #t "~T [~D]~1Tstream-status: #x~X~%" s5-1 (-> obj stream-status s5-1)) + ) + (format #t "~1Tstream-name[4] @ #x~X~%" (-> obj stream-name)) + (dotimes (s5-2 4) + (format #t "~T [~D]~1Tstream-name: ~g~%" s5-2 (-> obj stream-name s5-2)) + ) + (format #t "~1Tstream-id[4] @ #x~X~%" (-> obj stream-id)) + (dotimes (s5-3 4) + (format #t "~T [~D]~1Tstream-id: ~`uint32`P~%" s5-3 (-> obj stream-id s5-3)) + ) + (format #t "~1Tmusic-register[17] @ #x~X~%" (-> obj music-register)) + (format #t "~1Tmusic-excite: ~D~%" (-> obj music-excite)) + (format #t "~1Tramdisk-name: ~g~%" (-> obj ramdisk-name)) + (label cfg-16) + obj + ) + +;; definition for symbol *sound-iop-info*, type sound-iop-info +(define *sound-iop-info* (new 'global 'sound-iop-info)) + +;; definition for function str-is-playing? +(defun str-is-playing? () + (countdown (v1-0 4) + (if (and (>= (-> *sound-iop-info* stream-id v1-0) 0) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status four)) + ) + (return #t) + ) + ) + #f + ) + +;; definition for function str-id-is-playing? +(defun str-id-is-playing? ((arg0 int)) + (countdown (v1-0 4) + (if (and (= arg0 (-> *sound-iop-info* stream-id v1-0)) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status one six)) + ) + (return #t) + ) + ) + #f + ) + +;; definition for function current-str-pos +(defun current-str-pos ((arg0 sound-id)) + (if (>= (-> *setting-control* user-current movie-skip-frame) 0.0) + (return (the int (* 34.133335 (-> *setting-control* user-current movie-skip-frame)))) + ) + (dotimes (v1-5 4) + (if (= arg0 (-> *sound-iop-info* stream-id v1-5)) + (return (the-as int (-> *sound-iop-info* stream-position v1-5))) + ) + ) + -1 + ) + +;; definition for function is-ramdisk-loaded? +(defun is-ramdisk-loaded? ((arg0 symbol)) + (let ((gp-0 (-> *sound-iop-info* ramdisk-name)) + (s5-0 (symbol->string arg0)) + ) + (and (charp-prefix= (-> s5-0 data) gp-0) (= (-> gp-0 (length s5-0)) 46)) + ) + ) + +;; definition for function is-cd-in? +(defun is-cd-in? () + (zero? (-> *sound-iop-info* nocd)) + ) + +;; definition for function new-sound-id +(defun new-sound-id () + (set! *current-sound-id* (+ *current-sound-id* 1)) + (if (< (the-as int *current-sound-id*) #x10000) + (set! *current-sound-id* (the-as sound-id #x10000)) + ) + *current-sound-id* + ) + +;; definition for function check-irx-version +(defun check-irx-version () + (let ((gp-0 (the-as sound-rpc-get-irx-version (add-element *sound-loader-rpc*)))) + (set! (-> gp-0 command) (sound-command get-irx-version)) + (set! (-> gp-0 ee-addr) (&-> *sound-iop-info* frame)) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer gp-0) (the-as uint 80)) + (sync *sound-loader-rpc* #f) + (format 0 "IRX version ~D.~D~%" (-> gp-0 major) (-> gp-0 minor)) + (when (or (!= (-> gp-0 major) 4) (nonzero? (-> gp-0 minor))) + (format 0 "ERROR: IRX is the wrong version - need ~D.~D~%" 4 0) + (format 0 "~%~%Please do (:mch) then mkee on linux-dog~%~%~%") + (crash!) + 0 + ) + ) + 0 + ) + +;; definition for function sound-bank-iop-store +;; INFO: Used lq/sq +(defun sound-bank-iop-store ((arg0 sound-name)) + (let ((gp-0 (new-sound-id))) + (let ((v1-1 (the-as sound-rpc-bank-cmd (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command iop-store)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +;; definition for function sound-bank-iop-free +;; INFO: Used lq/sq +(defun sound-bank-iop-free ((arg0 sound-name)) + (let ((gp-0 (new-sound-id))) + (let ((v1-1 (the-as sound-rpc-bank-cmd (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command iop-free)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +;; definition for function sound-bank-load +;; INFO: Used lq/sq +(defun sound-bank-load ((arg0 sound-name)) + (let ((gp-0 (new-sound-id))) + (let ((v1-1 (the-as sound-rpc-load-bank (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command load-bank)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +;; definition for function sound-bank-load-from-iop +;; INFO: Used lq/sq +(defun sound-bank-load-from-iop ((arg0 sound-name)) + (let ((gp-0 (new-sound-id))) + (let ((v1-1 (the-as sound-rpc-load-bank (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command load-bank-from-iop)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +;; definition for function sound-bank-load-from-ee +;; INFO: Used lq/sq +(defun sound-bank-load-from-ee ((arg0 sound-name) (arg1 pointer)) + (let ((gp-0 (new-sound-id))) + (let ((v1-1 (the-as sound-rpc-load-bank (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command load-bank-from-ee)) + (set! (-> v1-1 bank-name) arg0) + (set! (-> v1-1 ee-addr) arg1) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +;; definition for function sound-bank-unload +;; INFO: Used lq/sq +(defun sound-bank-unload ((arg0 sound-name)) + (let ((v1-1 (the-as sound-rpc-unload-bank (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command unload-bank)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +;; definition for function sound-music-load +;; INFO: Used lq/sq +(defun sound-music-load ((arg0 sound-name)) + (let ((v1-1 (the-as sound-rpc-load-music (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command load-music)) + (set! (-> v1-1 bank-name) arg0) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +;; definition for function sound-music-unload +(defun sound-music-unload () + (let ((v1-1 (the-as sound-rpc-unload-music (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command unload-music)) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +;; definition for function set-language +(defun set-language ((arg0 language-enum)) + (kset-language arg0) + (let ((v1-1 (the-as sound-rpc-set-language (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command set-language)) + (set! (-> v1-1 lang) (the-as uint arg0)) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +;; definition for function sound-set-stereo-mode +;; INFO: Return type mismatch int vs none. +(defun sound-set-stereo-mode ((arg0 stereo-mode)) + (let ((v1-1 (the-as sound-rpc-set-stereo-mode (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command set-stereo-mode)) + (set! (-> v1-1 mode) (the-as int arg0)) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + (none) + ) + +;; definition for function list-sounds +;; INFO: Return type mismatch int vs none. +(defun list-sounds () + (let ((v1-1 (the-as sound-rpc-list-sounds (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) (sound-command list-sounds)) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + (syncv 0) + 0 + (none) + ) + +;; definition for function sound-command->string +(defun sound-command->string ((arg0 sound-command)) + (case arg0 + (((sound-command num-sectors)) + "num-sectors" + ) + (((sound-command read-spr-nom)) + "read-spr-nom" + ) + (((sound-command shutdown)) + "shutdown" + ) + (((sound-command set-flava)) + "set-flava" + ) + (((sound-command set-language)) + "set-language" + ) + (((sound-command set-falloff-curve)) + "set-falloff-curve" + ) + (((sound-command set-sound-falloff)) + "set-sound-falloff" + ) + (((sound-command get-irx-version)) + "get-irx-version" + ) + (((sound-command stop-group)) + "stop-group" + ) + (((sound-command set-param)) + "set-param" + ) + (((sound-command play)) + "play" + ) + (((sound-command continue-group)) + "continue-group" + ) + (((sound-command set-stereo-mode)) + "set-stereo-mode" + ) + (((sound-command load-music)) + "load-music" + ) + (((sound-command track-pitch)) + "track-pitch" + ) + (((sound-command num-tests)) + "num-tests" + ) + (((sound-command unload-music)) + "unload-music" + ) + (((sound-command continue-sound)) + "continue-sound" + ) + (((sound-command load-bank-from-ee)) + "load-bank-from-ee" + ) + (((sound-command seek-stm)) + "seek-stm" + ) + (((sound-command seek-nom)) + "seek-nom" + ) + (((sound-command set-reverb)) + "set-reverb" + ) + (((sound-command read-spr-stm)) + "read-spr-stm" + ) + (((sound-command linvel-stm)) + "linvel-stm" + ) + (((sound-command boot-load)) + "boot-load" + ) + (((sound-command rand-nom-abort)) + "rand-nom-abort" + ) + (((sound-command read-seq-nom)) + "read-seq-nom" + ) + (((sound-command cancel-dgo)) + "cancel-dgo" + ) + (((sound-command iop-store)) + "iop-store" + ) + (((sound-command read-spr-strn-nom)) + "read-spr-strn-nom" + ) + (((sound-command num-streamsectors)) + "num-streamsectors" + ) + (((sound-command game-load)) + "game-load" + ) + (((sound-command set-fps)) + "set-fps" + ) + (((sound-command stop-sound)) + "stop-sound" + ) + (((sound-command pause-sound)) + "pause-sound" + ) + (((sound-command load-bank)) + "load-bank" + ) + (((sound-command load-bank-from-iop)) + "load-bank-from-iop" + ) + (((sound-command unload-bank)) + "unload-bank" + ) + (((sound-command set-midi-reg)) + "set-midi-reg" + ) + (((sound-command num-streambanks)) + "num-streambanks" + ) + (((sound-command set-ear-trans)) + "set-ear-trans" + ) + (((sound-command read-seq-stm)) + "read-seq-stm" + ) + (((sound-command iop-free)) + "iop-free" + ) + (((sound-command list-sounds)) + "list-sounds" + ) + (((sound-command set-master-volume)) + "set-master-volume" + ) + (((sound-command rand-stm-abort)) + "rand-stm-abort" + ) + (((sound-command iop-mem)) + "iop-mem" + ) + (((sound-command linvel-nom)) + "linvel-nom" + ) + (((sound-command reload-info)) + "reload-info" + ) + (((sound-command pause-group)) + "pause-group" + ) + (((sound-command num-testruns)) + "num-testruns" + ) + (else + "*unknown*" + ) + ) + ) + +;; definition for function sound-buffer-dump +(defun sound-buffer-dump () + (let ((gp-0 (-> *sound-player-rpc* current elt-used)) + (s5-0 (-> *sound-player-rpc* current elt-size)) + ) + (dotimes (s4-0 (the-as int gp-0)) + (let* ((s3-0 (the-as sound-rpc-play (&+ (-> *sound-player-rpc* current base) (* s5-0 (the-as uint s4-0))))) + (a3-0 (sound-command->string (-> s3-0 command))) + ) + (case (-> s3-0 command) + (((sound-command play)) + (format #t "~D ~A ~G~%" s4-0 a3-0 (&-> s3-0 name)) + ) + (else + (format #t "~D ~A~%" s4-0 a3-0) + ) + ) + ) + ) + ) + 0 + ) + +;; definition for symbol *sound-player-enable*, type symbol +(define *sound-player-enable* #t) + +;; definition for function swap-sound-buffers +(defun swap-sound-buffers ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (run-pending-updates! *sound-loop-engine* (-> *display* base-clock frame-counter)) + (cond + ((check-busy *sound-player-rpc*) + (set! *sound-player-enable* #f) + ) + (else + (let ((a0-3 (-> *sound-player-rpc* current))) + (if (< (-> a0-3 elt-used) (-> a0-3 elt-count)) + (sound-set-ear-trans arg0 arg1 arg2 arg3) + ) + ) + (call *sound-player-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + (set! *sound-player-enable* #t) + ) + ) + (cond + ((not (-> *setting-control* user-current allow-error)) + ) + ((nonzero? (-> *sound-iop-info* nocd)) + (if (or (not *progress-process*) (!= (-> *progress-process* 0 current) 'error-disc-removed)) + (activate-progress *dproc* 'error-disc-removed) + ) + ) + ((nonzero? (-> *sound-iop-info* dirtycd)) + (if (or (not *progress-process*) (!= (-> *progress-process* 0 current) 'error-reading)) + (activate-progress *dproc* 'error-reading) + ) + ) + ) + 0 + ) + +;; definition for function get-sound-buffer-entry +(defun get-sound-buffer-entry () + (add-element *sound-player-rpc*) + ) + +;; definition for function free-last-sound-buffer-entry +;; INFO: Return type mismatch int vs none. +(defun free-last-sound-buffer-entry () + (decrement-elt-used *sound-player-rpc*) + 0 + (none) + ) + +;; definition for function sound-basic-cb +;; INFO: Return type mismatch int vs none. +(defun sound-basic-cb ((arg0 int) (arg1 (pointer int32))) + (set! (-> arg1 0) arg0) + 0 + (none) + ) + +;; definition for function sound-trans-convert +(defun sound-trans-convert ((arg0 vector3w) (arg1 vector)) + (let ((v1-0 (if arg1 + arg1 + (ear-trans 0) + ) + ) + ) + (set! (-> arg0 x) (the int (* 0.0625 (-> v1-0 x)))) + (set! (-> arg0 y) (the int (* 0.0625 (-> v1-0 y)))) + (set! (-> arg0 z) (the int (* 0.0625 (-> v1-0 z)))) + ) + 0 + ) + +;; definition for function sound-angle-convert +(defun sound-angle-convert ((arg0 float)) + (let* ((f0-3 (the float (sar (shl (the int arg0) 48) 48))) + (v0-0 (the int (* 0.005493164 f0-3))) + ) + (if (< v0-0 0) + (+! v0-0 360) + ) + (if (< 359 v0-0) + (+! v0-0 -360) + ) + v0-0 + ) + ) + +;; definition for function string->sound-name +;; INFO: Used lq/sq +;; INFO: Return type mismatch uint128 vs sound-name. +(defun string->sound-name ((arg0 string)) + (let ((v1-0 (new 'stack-no-clear 'qword))) + (set! (-> v1-0 quad) (the-as uint128 0)) + (let ((a1-0 (the-as (pointer uint8) v1-0)) + (a2-0 (-> arg0 data)) + ) + (while (and (nonzero? (-> a2-0 0)) (< (&- a2-0 (the-as uint (-> arg0 data))) 15)) + (set! (-> a1-0 0) (-> a2-0 0)) + (set! a1-0 (&-> a1-0 1)) + (set! a2-0 (&-> a2-0 1)) + ) + ) + (the-as sound-name (-> v1-0 quad)) + ) + ) + +;; definition for function sound-set-volume +(defun sound-set-volume ((arg0 sound-group) (arg1 float)) + (let ((v1-0 (the-as sound-rpc-set-master-volume (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-master-volume)) + (set! (-> v1-0 group) arg0) + (set! (-> v1-0 volume) (the int (* 1024.0 arg1))) + ) + 0 + ) + +;; definition for function sound-set-reverb +(defun sound-set-reverb ((arg0 int) (arg1 float) (arg2 float) (arg3 uint)) + (let ((v1-0 (the-as sound-rpc-set-reverb (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-reverb)) + (set! (-> v1-0 core) arg3) + (set! (-> v1-0 reverb) arg0) + (set! (-> v1-0 left) (the-as uint (the int (* 32767.0 arg1)))) + (set! (-> v1-0 right) (the-as uint (the int (* 32767.0 arg2)))) + ) + 0 + ) + +;; definition for function sound-set-ear-trans +(defun sound-set-ear-trans ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (let ((gp-0 (the-as sound-rpc-set-ear-trans (get-sound-buffer-entry)))) + (set! (-> gp-0 command) (sound-command set-ear-trans)) + (sound-trans-convert (the-as vector3w (-> gp-0 ear-trans0)) arg0) + (sound-trans-convert (the-as vector3w (-> gp-0 ear-trans1)) arg1) + (sound-trans-convert (the-as vector3w (-> gp-0 cam-trans)) arg2) + (set! (-> gp-0 cam-angle) (sound-angle-convert arg3)) + ) + 0 + ) + +;; definition for function sound-play-by-name +;; INFO: Used lq/sq +(defun sound-play-by-name ((arg0 sound-name) (arg1 sound-id) (arg2 int) (arg3 int) (arg4 int) (arg5 sound-group) (arg6 symbol)) + (local-vars (sv-16 sound-group)) + (with-pp + (set! sv-16 arg5) + (let ((s4-0 (the-as object arg6))) + (when *sound-player-enable* + (let ((s5-0 (the-as sound-rpc-play (get-sound-buffer-entry)))) + (set! (-> s5-0 command) (sound-command play)) + (set! (-> s5-0 id) arg1) + (set! (-> s5-0 name) arg0) + (set! (-> s5-0 params mask) (the-as uint 0)) + (set! (-> s5-0 params group) (the-as uint sv-16)) + (set! (-> s5-0 params volume) arg2) + (set! (-> s5-0 params pitch-mod) arg3) + (set! (-> s5-0 params bend) arg4) + (let ((s3-1 (the-as process-drawable pp))) + (when (= (the-as symbol s4-0) #t) + (if (and s3-1 (type? s3-1 process-drawable) (nonzero? (-> s3-1 root))) + (set! s4-0 (-> s3-1 root trans)) + (set! s4-0 #f) + ) + ) + ) + (sound-trans-convert (the-as vector3w (-> s5-0 params trans)) (the-as vector s4-0)) + ) + ) + ) + arg1 + ) + ) + +;; definition for function sound-play-by-spec +;; INFO: Used lq/sq +(defun sound-play-by-spec ((arg0 sound-spec) (arg1 sound-id) (arg2 vector)) + (with-pp + (when *sound-player-enable* + (let ((s5-0 (the-as sound-rpc-play (get-sound-buffer-entry)))) + (set! (-> s5-0 command) (sound-command play)) + (set! (-> s5-0 id) arg1) + (set! (-> s5-0 name) (-> arg0 sound-name)) + (set! (-> s5-0 params mask) (the-as uint (-> arg0 mask))) + (set! (-> s5-0 params group-and-regs) (-> arg0 group-and-regs)) + (set! (-> s5-0 params volume) (-> arg0 volume)) + (set! (-> s5-0 params pitch-mod) (-> arg0 pitch-mod)) + (set! (-> s5-0 params bend) (-> arg0 bend)) + (set! (-> s5-0 params fo-min) (-> arg0 fo-min)) + (set! (-> s5-0 params fo-max) (-> arg0 fo-max)) + (set! (-> s5-0 params fo-curve) (-> arg0 fo-curve)) + (set! (-> s5-0 params priority) (-> arg0 priority)) + (let ((s3-1 (the-as process-drawable pp))) + (when (= arg2 #t) + (if (and s3-1 (type? s3-1 process-drawable) (nonzero? (-> s3-1 root))) + (set! arg2 (-> s3-1 root trans)) + (set! arg2 (the-as vector #f)) + ) + ) + ) + (sound-trans-convert (the-as vector3w (-> s5-0 params trans)) arg2) + ) + ) + arg1 + ) + ) + +;; definition for function sound-pause +(defun sound-pause ((arg0 sound-id)) + (when (nonzero? arg0) + (let ((v1-1 (the-as sound-rpc-pause-sound (get-sound-buffer-entry)))) + (set! (-> v1-1 command) (sound-command pause-sound)) + (set! (-> v1-1 id) arg0) + ) + ) + 0 + ) + +;; definition for function sound-stop +(defun sound-stop ((arg0 sound-id)) + (when (nonzero? arg0) + (let ((v1-1 (the-as sound-rpc-stop-sound (get-sound-buffer-entry)))) + (set! (-> v1-1 command) (sound-command stop-sound)) + (set! (-> v1-1 id) arg0) + ) + ) + 0 + ) + +;; definition for function sound-continue +(defun sound-continue ((arg0 sound-id)) + (when (nonzero? arg0) + (let ((v1-1 (the-as sound-rpc-continue-sound (get-sound-buffer-entry)))) + (set! (-> v1-1 command) (sound-command continue-sound)) + (set! (-> v1-1 id) arg0) + ) + ) + 0 + ) + +;; definition for function sound-group-pause +(defun sound-group-pause ((arg0 sound-group)) + (let ((v1-0 (the-as sound-rpc-pause-group (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command pause-group)) + (set! (-> v1-0 group) arg0) + ) + 0 + ) + +;; definition for function sound-group-stop +(defun sound-group-stop ((arg0 sound-group)) + (let ((v1-0 (the-as sound-rpc-stop-group (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command stop-group)) + (set! (-> v1-0 group) arg0) + ) + 0 + ) + +;; definition for function sound-group-continue +(defun sound-group-continue ((arg0 sound-group)) + (let ((v1-0 (the-as sound-rpc-continue-group (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command continue-group)) + (set! (-> v1-0 group) arg0) + ) + 0 + ) + +;; definition for function sound-set-flava +(defun sound-set-flava ((arg0 uint) (arg1 uint)) + (let ((v1-0 (the-as sound-rpc-set-flava (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-flava)) + (set! (-> v1-0 flava) arg0) + (set! (-> v1-0 excitement) arg1) + ) + 0 + ) + +;; definition for function sound-set-midi-reg +(defun sound-set-midi-reg ((arg0 int) (arg1 int)) + (let ((v1-0 (the-as sound-rpc-set-midi-reg (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-midi-reg)) + (set! (-> v1-0 reg) arg0) + (set! (-> v1-0 value) arg1) + ) + 0 + ) + +;; definition for function sound-set-fps +(defun sound-set-fps ((arg0 int)) + (let ((v1-0 (the-as sound-rpc-set-fps (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-fps)) + (set! (-> v1-0 fps) (the-as uint arg0)) + ) + 0 + ) + +;; definition for function sound-volume-off +(defun sound-volume-off () + (set-setting! 'music-volume 'abs 0 0) + (set-setting! 'sfx-volume 'abs 0 0) + (set-setting! 'ambient-volume 'abs 0 0) + 0 + ) + +;; definition for symbol *ambient-spec*, type sound-spec +(define *ambient-spec* (new 'static 'sound-spec)) + +;; definition for method 0 of type ambient-sound +;; INFO: Used lq/sq +;; INFO: Return type mismatch object vs ambient-sound. +(defmethod new ambient-sound ((allocation symbol) (type-to-make type) (arg0 basic) (arg1 vector)) + (local-vars + (sv-16 sound-spec) + (sv-32 sound-name) + (sv-48 (pointer float)) + (sv-52 pointer) + (sv-56 int) + (sv-64 res-tag) + ) + (set! sv-16 (the-as sound-spec #f)) + (set! sv-32 (the-as sound-name 0)) + (set! sv-48 (the-as (pointer float) #f)) + (set! sv-52 (the-as pointer #f)) + (set! sv-56 0) + (case (-> arg0 type) + ((entity-actor) + (let ((v1-2 + ((method-of-type res-lump get-property-struct) + (the-as res-lump arg0) + 'effect-name + 'exact + 0.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (when v1-2 + (set! sv-32 (string->sound-name (the-as string (-> (the-as (pointer uint32) (+ #xff37 (the-as int v1-2))))))) + (set! sv-48 (res-lump-data (the-as res-lump arg0) 'cycle-speed (pointer float))) + (set! sv-16 *ambient-spec*) + (set! sv-64 (new 'static 'res-tag)) + (let ((v1-7 + ((method-of-type res-lump get-property-data) + (the-as res-lump arg0) + 'effect-param + 'exact + 0.0 + (the-as pointer #f) + (& sv-64) + *res-static-buf* + ) + ) + ) + (when v1-7 + (set! sv-52 v1-7) + (set! sv-56 (the-as int (-> sv-64 elt-count))) + ) + ) + ) + ) + ) + ((sound-spec) + (set! sv-16 (the-as sound-spec arg0)) + ) + ((string) + (set! sv-32 (string->sound-name (the-as string arg0))) + ) + (else + (format 0 "ERROR: ambient sound was told to play an unknown ~A.~%" arg0) + ) + ) + (the-as + ambient-sound + (cond + ((or sv-16 (nonzero? sv-32)) + (let ((s5-1 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (set! (-> (the-as ambient-sound s5-1) spec) sv-16) + (set! (-> (the-as ambient-sound s5-1) name) sv-32) + (set! (-> (the-as ambient-sound s5-1) playing-id) (new-sound-id)) + (set! (-> (the-as ambient-sound s5-1) params) (the-as (pointer float) sv-52)) + (set! (-> (the-as ambient-sound s5-1) param-count) sv-56) + (set! (-> (the-as ambient-sound s5-1) entity) #f) + (set! (-> (the-as ambient-sound s5-1) sound-count) 1) + (set! (-> (the-as ambient-sound s5-1) volume) 1024) + (set! (-> (the-as ambient-sound s5-1) pitch) 0) + (when (and sv-16 (!= sv-16 *ambient-spec*)) + (if (logtest? (-> (the-as sound-spec sv-16) mask) (sound-mask volume)) + (set! (-> (the-as ambient-sound s5-1) volume) (-> (the-as sound-spec sv-16) volume)) + ) + (if (logtest? (-> (the-as sound-spec sv-16) mask) (sound-mask pitch)) + (set! (-> (the-as ambient-sound s5-1) pitch) (-> (the-as sound-spec sv-16) pitch-mod)) + ) + ) + (cond + (sv-48 + (set! (-> (the-as ambient-sound s5-1) time-base) (the-as time-frame (the int (* 300.0 (-> sv-48 0))))) + (set! (-> (the-as ambient-sound s5-1) time-random) (the-as time-frame (the int (* 300.0 (-> sv-48 1))))) + ) + (else + (set! (-> (the-as ambient-sound s5-1) time-base) -1) + ) + ) + (set! (-> (the-as ambient-sound s5-1) trans quad) (-> arg1 quad)) + s5-1 + ) + ) + (else + 0 + ) + ) + ) + ) + +;; definition for method 9 of type ambient-sound +;; INFO: Used lq/sq +(defmethod update! ambient-sound ((obj ambient-sound)) + (with-pp + (if (not *ambient-sound-class*) + (return (the-as int #f)) + ) + (cond + ((-> obj spec) + (when (or (< (-> obj time-base) 0) (>= (-> pp clock frame-counter) (-> obj play-time))) + (when (>= (-> obj time-base) 0) + (set! (-> obj play-time) + (+ (-> pp clock frame-counter) (-> obj time-base) (rand-vu-int-count (the-as int (-> obj time-random)))) + ) + (set! (-> obj playing-id) (new-sound-id)) + ) + (let ((s5-1 (-> obj spec))) + (when (= s5-1 *ambient-spec*) + (set! (-> s5-1 volume) (-> obj volume)) + (set! (-> s5-1 pitch-mod) (-> obj pitch)) + (set! (-> s5-1 bend) 0) + (set! (-> s5-1 sound-name) (-> obj name)) + (set! (-> s5-1 fo-max) (-> obj falloff-far)) + (set! (-> s5-1 mask) (sound-mask)) + (when (-> obj params) + pp + (effect-param->sound-spec s5-1 (-> obj params) (-> obj param-count)) + ) + ) + (let ((v1-23 (-> s5-1 fo-max))) + (if (and (nonzero? v1-23) (< (* 4096.0 (the float v1-23)) (vector-vector-distance (ear-trans 0) (-> obj trans)))) + (return 0) + ) + ) + (when (and *debug-effect-control* (>= (-> obj time-base) 0)) + (format #t "(~5D) effect sound ~A ~G " (-> pp clock frame-counter) (-> pp name) (&-> s5-1 sound-name)) + (format + #t + "volume: ~f pitch-mod: ~f~%" + (* 0.09765625 (the float (-> s5-1 volume))) + (* 0.000656168 (the float (-> s5-1 pitch-mod))) + ) + ) + (let ((s4-2 (-> s5-1 volume))) + (set! (-> s5-1 volume) (-> obj volume)) + (set! (-> obj playing-id) (sound-play-by-spec s5-1 (-> obj playing-id) (-> obj trans))) + (set! (-> s5-1 volume) s4-2) + ) + ) + ) + ) + ((< (-> obj time-base) 0) + (let ((v1-39 (-> obj falloff-far))) + (if (and (nonzero? v1-39) (< (* 4096.0 (the float v1-39)) (vector-vector-distance (ear-trans 0) (-> obj trans)))) + (return 0) + ) + ) + (set! (-> obj playing-id) (sound-play-by-name + (-> obj name) + (-> obj playing-id) + (-> obj volume) + (-> obj pitch) + 0 + (sound-group sfx) + (the-as symbol (-> obj trans)) + ) + ) + ) + (else + (when (>= (-> pp clock frame-counter) (-> obj play-time)) + (set! (-> obj playing-id) + (sound-play-by-name + (-> obj name) + (new-sound-id) + (-> obj volume) + (-> obj pitch) + 0 + (sound-group sfx) + (the-as symbol (-> obj trans)) + ) + ) + (set! (-> obj play-time) + (+ (-> pp clock frame-counter) (-> obj time-base) (rand-vu-int-count (the-as int (-> obj time-random)))) + ) + ) + ) + ) + 0 + ) + ) + +;; definition for method 15 of type ambient-sound +(defmethod stop! ambient-sound ((obj ambient-sound)) + (sound-stop (-> obj playing-id)) + 0 + ) + +;; definition for method 11 of type ambient-sound +;; INFO: Used lq/sq +(defmethod update-trans! ambient-sound ((obj ambient-sound) (arg0 vector)) + (with-pp + (set! (-> obj trans quad) (-> arg0 quad)) + (when (nonzero? (-> obj playing-id)) + (when *sound-player-enable* + (let ((s5-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> s5-0 command) (sound-command set-param)) + (set! (-> s5-0 id) (-> obj playing-id)) + (let ((s4-1 (the-as process-drawable pp))) + (when (= arg0 #t) + (if (and s4-1 (type? s4-1 process-drawable) (nonzero? (-> s4-1 root))) + (set! arg0 (-> s4-1 root trans)) + (set! arg0 (the-as vector #f)) + ) + ) + ) + (sound-trans-convert (the-as vector3w (-> s5-0 params trans)) arg0) + (set! (-> s5-0 params mask) (the-as uint 32)) + (-> s5-0 id) + ) + ) + ) + 0 + ) + ) + +;; definition for method 12 of type ambient-sound +(defmethod update-vol! ambient-sound ((obj ambient-sound) (arg0 float)) + (when (nonzero? (-> obj playing-id)) + (when *sound-player-enable* + (let ((v1-4 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-4 command) (sound-command set-param)) + (set! (-> v1-4 id) (-> obj playing-id)) + (set! (-> v1-4 params volume) (the int (* 1024.0 arg0))) + (set! (-> v1-4 params mask) (the-as uint 1)) + (-> v1-4 id) + ) + ) + ) + (set! (-> obj volume) (the int (* 1024.0 arg0))) + 0 + ) + +;; definition for method 13 of type ambient-sound +;; INFO: Return type mismatch int vs none. +(defmethod update-pitch-mod! ambient-sound ((obj ambient-sound) (arg0 float)) + (when (nonzero? (-> obj playing-id)) + (when *sound-player-enable* + (let ((v1-4 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-4 command) (sound-command set-param)) + (set! (-> v1-4 id) (-> obj playing-id)) + (set! (-> v1-4 params pitch-mod) (the int (* 1524.0 arg0))) + (set! (-> v1-4 params mask) (the-as uint 2)) + (-> v1-4 id) + ) + ) + ) + (set! (-> obj pitch) (the int (* 1524.0 arg0))) + 0 + (none) + ) + +;; definition for method 14 of type ambient-sound +;; INFO: Return type mismatch int vs none. +(defmethod set-falloff-far! ambient-sound ((obj ambient-sound) (arg0 float)) + (set! (-> obj falloff-far) (the int (* 0.00024414062 arg0))) + 0 + (none) + ) + +;; definition for method 10 of type ambient-sound +;; INFO: Used lq/sq +(defmethod change-sound! ambient-sound ((obj ambient-sound) (arg0 sound-name)) + (when (not (and (= (the-as uint (-> obj name)) (the-as uint arg0)) (= (-> arg0 hi) (-> obj name hi)))) + (stop! obj) + (set! (-> obj playing-id) (new-sound-id)) + (set! (-> obj name) arg0) + ) + 0 + ) + +;; definition for function show-iop-info +(defun show-iop-info ((arg0 dma-buffer)) + (dotimes (s5-0 24) + (draw-string-xy + (if (zero? (-> *sound-iop-info* chinfo s5-0)) + "." + "X" + ) + arg0 + (+ (* s5-0 16) 16) + 48 + (font-color default) + (font-flags shadow) + ) + ) + (dotimes (s5-1 24) + (draw-string-xy + (if (zero? (-> *sound-iop-info* chinfo (+ s5-1 24))) + "." + "X" + ) + arg0 + (+ (* s5-1 16) 16) + 64 + (font-color default) + (font-flags shadow) + ) + ) + (let ((s5-2 draw-string-xy)) + (format + (clear *temp-string*) + "banks: ~15S ~15S ~15S" + (-> *level* sound-bank 0) + (-> *level* sound-bank 1) + (-> *level* sound-bank 2) + ) + (s5-2 *temp-string* arg0 16 88 (font-color default) (font-flags shadow)) + ) + (let ((s5-3 draw-string-xy)) + (format + (clear *temp-string*) + "music: ~15S fl:~1D/~2D ex:~4,,2f/~4,,2f ~10S" + (-> *setting-control* user-current music) + (-> *setting-control* user-current sound-flava) + (-> *setting-control* user-current sound-stinger) + (-> *setting-control* user-target sound-excitement) + (-> *setting-control* user-current sound-excitement) + (-> *setting-control* user-current mode-sound-bank) + ) + (s5-3 *temp-string* arg0 16 104 (font-color default) (font-flags shadow)) + ) + 0 + ) + +;; definition for function show-iop-memory +(defun show-iop-memory ((arg0 dma-buffer)) + (let ((s5-0 draw-string-xy)) + (format + (clear *temp-string*) + "~8D [~4D]" + (-> *sound-iop-info* freemem) + (shr (-> *sound-iop-info* freemem) 10) + ) + (s5-0 *temp-string* arg0 32 96 (font-color default) (font-flags shadow)) + ) + (let ((s5-1 draw-string-xy)) + (format + (clear *temp-string*) + "~8D [~4D]" + (-> *sound-iop-info* freemem2) + (shr (-> *sound-iop-info* freemem2) 10) + ) + (s5-1 *temp-string* arg0 32 64 (font-color default) (font-flags shadow)) + ) + 0 + ) + +;; definition for function ear-trans +(defun ear-trans ((arg0 int)) + (cond + ((or (movie?) *external-cam-mode*) + (math-camera-pos) + ) + ((and *target* (= arg0 1)) + (target-pos 0) + ) + (else + (camera-pos) + ) + ) + ) + +;; definition (debug) for function make-sqrt-table +(defun-debug make-sqrt-table () + (format #t "static int sqrt_table[256] =~%{~%") + (dotimes (gp-0 256) + (let* ((f0-2 (sqrtf (* 16777216.0 (the float gp-0)))) (a2-0 (the int (+ 0.5 f0-2)))) (format #t "~D,~%" a2-0)) + ) + (format #t "};~%") + 0 + ) + +;; failed to figure out what this is: +(check-irx-version) + +;; failed to figure out what this is: +(case (scf-get-territory) + ((2) + (sound-bank-load (static-sound-name "commonj")) + ) + (else + (sound-bank-load (static-sound-name "common")) + ) + ) + +;; failed to figure out what this is: +(dotimes (gp-0 3) + (let ((s5-0 string->symbol)) + (format (clear *temp-string*) "empty~D" gp-0) + (let ((s5-1 (s5-0 *temp-string*))) + (sound-bank-load (string->sound-name (symbol->string s5-1))) + (set! (-> *level* sound-bank gp-0) (the-as basic s5-1)) + ) + ) + ) + +;; definition for function loader-test-command +;; INFO: Return type mismatch int vs none. +(defun loader-test-command ((arg0 sound-command) (arg1 uint)) + (let ((v1-1 (the-as sound-rpc-test-cmd (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) arg0) + (set! (-> v1-1 ee-addr) (the-as pointer 0)) + (set! (-> v1-1 param0) arg1) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + (sync *sound-loader-rpc* #f) + 0 + (none) + ) + +;; definition for function doppler-pitch-shift +;; INFO: Used lq/sq +(defun doppler-pitch-shift ((arg0 vector) (arg1 vector)) + (let ((gp-0 (new 'stack-no-clear 'inline-array 'vector 2))) + (vector-! (-> gp-0 0) (target-pos 0) arg0) + (if *target* + (vector-! (-> gp-0 1) arg1 (-> *target* root transv)) + (set! (-> gp-0 1 quad) (-> arg1 quad)) + ) + (vector-normalize! (-> gp-0 0) 1.0) + (let ((f0-1 (/ 1228800.0 (fmax 0.1 (- 1228800.0 (vector-dot (-> gp-0 0) (-> gp-0 1))))))) + (log2f f0-1) + ) + ) + ) + +;; definition for function sound-bank-reload +;; INFO: Return type mismatch int vs none. +(defun sound-bank-reload () + (process-spawn-function + process + (lambda () + (with-pp + (let ((gp-0 (the-as (array symbol) (new 'static 'boxed-array :type symbol :length 0 :allocated-length 3)))) + (dotimes (v1-0 3) + (set! (-> gp-0 v1-0) (the-as symbol (-> *level* sound-bank v1-0))) + ) + (let ((a1-3 (new 'stack-no-clear 'array 'symbol 4))) + (set! (-> a1-3 2) 'empty2) + (set! (-> a1-3 1) 'empty1) + (set! (-> a1-3 0) 'empty0) + (want-sound-banks *load-state* a1-3) + ) + (let ((s5-0 (-> pp clock frame-counter))) + (until (>= (- (-> pp clock frame-counter) s5-0) (seconds 1)) + (suspend) + ) + ) + (let ((a1-4 (new 'stack-no-clear 'array 'symbol 4))) + (set! (-> a1-4 2) (-> gp-0 2)) + (set! (-> a1-4 1) (-> gp-0 1)) + (set! (-> a1-4 0) (-> gp-0 0)) + (want-sound-banks *load-state* a1-4) + ) + ) + (none) + ) + ) + :name (symbol->string (-> process symbol)) + :to *display-pool* + ) + 0 + (none) + ) diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index 2390abf35f..33cc65df85 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -34,7 +34,10 @@ "(method 3 connection-minimap)", "(method 3 sky-vertex)", // cache asm - "invalidate-cache-line" + "invalidate-cache-line", + // asm, weird vector dot + "(method 17 trsqv)" + ], "skip_compile_states": {}