diff --git a/decompiler/analysis/insert_lets.cpp b/decompiler/analysis/insert_lets.cpp index 2e7c2ec1d6..5bb77b1bf6 100644 --- a/decompiler/analysis/insert_lets.cpp +++ b/decompiler/analysis/insert_lets.cpp @@ -1630,6 +1630,7 @@ FormElement* rewrite_proc_new(LetElement* in, const Env& env, FormPool& pool) { expected_name = fmt::format("'{}", proc_type); break; case GameVersion::Jak2: + case GameVersion::Jak3: expected_name = fmt::format("(symbol->string (-> {} symbol))", proc_type); break; default: diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index 30db12b6ea..a1062625f7 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -2532,6 +2532,57 @@ (defenum sound-command :type uint16 + (iop-store) + (iop-free) + (load-bank) + (load-bank-from-iop) + (load-bank-from-ee) + (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-midi-reg) + (set-reverb) + (set-ear-trans) + (shutdown) + (list-sounds) + (unload-music) + (set-fps) + (boot-load) + (game-load) + (num-tests) + (num-testruns) + (num-sectors) + (num-streamsectors) + (num-streambanks) + (track-pitch) + (linvel-nom) + (linvel-stm) + (seek-nom) + (seek-stm) + (read-seq-nom) + (read-seq-stm) + (read-spr-nom) + (read-spr-stm) + (read-spr-strn-nom) + (rand-stm-abort) + (rand-nom-abort) + (iop-mem) + (cancel-dgo) + (set-stereo-mode) ) (defenum sound-group @@ -2542,16 +2593,35 @@ (defenum sound-mask :bitfield #t :type uint16 + (volume) ;; 1 + (pitch) ;; 2 + (bend) ;; 4 + (unused) ;; 8 + (time) ;; 10 + (trans) ;; 20 + (fo-min) ;; 40 + (fo-max) ;; 80 + (fo-curve) ;; 100 + (sm-unk1) + (sm-unk2) + (reg0) + (reg1) + (reg2) + (unk) ) (defenum stream-status :type uint32 :bitfield #t + (ss1 1) ;; id-is-playing + (ss4 4) ;; is-playing + (ss6 6) ;; id-is-playing ) (deftype sound-stream-name (structure) ((name uint8 48 :offset-assert 0) ;; guessed by decompiler ) + :pack-me :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 @@ -2571,13 +2641,15 @@ ) (deftype sound-name (uint128) - () + ((lo uint64 :offset 0) ;; added to help with cases where they access it by u64. + (hi uint64 :offset 64) + ) :flag-assert #x900000010 ) (deftype sound-rpc-cmd (structure) ((rsvd1 uint16 :offset-assert 0) - (command uint16 :offset-assert 2) ;; sound-command + (command sound-command :offset-assert 2) ;; sound-command ) :method-count-assert 9 :size-assert #x4 @@ -2596,6 +2668,7 @@ (trans int32 3 :offset-assert 16) ;; guessed by decompiler (group uint8 :offset-assert 28) (reg uint8 3 :offset-assert 29) ;; guessed by decompiler + (group-and-reg uint32 :overlay-at group) ) :pack-me :method-count-assert 9 @@ -2865,10 +2938,12 @@ ) (deftype sound-spec (basic) - ((mask sound-mask :offset-assert 4) ;; sound-mask + ( + (mask sound-mask :offset-assert 4) ;; sound-mask (num float :offset-assert 8) (group sound-group :offset-assert 12) ;; (reg uint8 3 :offset-assert 13) ;; guessed by decompiler + (group-and-reg uint32 :offset 12) ;; (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (sound-name-char uint8 16 :offset-assert 16) (sound-name sound-name :offset-assert 16 :overlay-at sound-name-char) ;; @@ -2889,7 +2964,7 @@ ) (deftype sound-bank-state (structure) - ((name basic :offset-assert 0) + ((name symbol :offset-assert 0) (mode uint32 :offset-assert 4) ) :pack-me @@ -2902,10 +2977,10 @@ ((spec sound-spec :offset-assert 4) ;; guessed by decompiler (playing-id sound-id :offset-assert 8) ;; guessed by decompiler (trans vector :inline :offset-assert 16) - (name uint128 :offset-assert 32) ;; sound-name - (play-time uint64 :offset-assert 48) ;; time-frame - (time-base uint64 :offset-assert 56) ;; time-frame - (time-random uint64 :offset-assert 64) ;; time-frame + (name sound-name :offset-assert 32) ;; sound-name + (play-time time-frame :offset-assert 48) ;; time-frame + (time-base time-frame :offset-assert 56) ;; time-frame + (time-random time-frame :offset-assert 64) ;; time-frame (volume int32 :offset-assert 72) (pitch int32 :offset-assert 76) (falloff-near int32 :offset-assert 80) @@ -2921,15 +2996,15 @@ :size-assert #x70 :flag-assert #x1100000070 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type basic vector) _type_) - (ambient-sound-method-9 () none) ;; 9 ;; (update! (_type_) int) - (ambient-sound-method-10 () none) ;; 10 ;; (change-sound! (_type_ sound-name) int) - (ambient-sound-method-11 () none) ;; 11 ;; (update-trans! (_type_ vector) int) - (ambient-sound-method-12 () none) ;; 12 ;; (update-vol! (_type_ float) int) - (ambient-sound-method-13 () none) ;; 13 ;; (update-pitch-mod! (_type_ float) none) - (ambient-sound-method-14 () none) ;; 14 ;; (set-falloff-far! (_type_ float) none) - (ambient-sound-method-15 () none) ;; 15 ;; (stop! (_type_) int) - (ambient-sound-method-16 () none) ;; 16 + (new "Set up ambient-sound. Can use an entity-actor (grabs from lump), sound-spec, or name as a string." (symbol type basic vector float) _type_) ;; 0 + (update! "Per-frame update of ambient sound." (_type_) int) ;; 9 + (change-sound! "Change the sound being played." (_type_ sound-name) int) ;; 10 + (update-trans! "Change the trans of the sound." (_type_ vector) int) ;; 11 + (update-vol! "Change the volume of the sound." (_type_ float) int) ;; 12 + (update-pitch-mod! (_type_ float) none) ;; 13 + (set-falloff-far! (_type_ float) none) ;; 14 + (set-falloff-mode! (_type_ int) none) ;; 15 + (stop! (_type_) int) ;; 16 ) ) @@ -10049,7 +10124,7 @@ (gs12 12) (gs13 13) (gs14 14) - (gs15 15) + (screen-flip 15) (gs16 16) (gs17 17) (gs18 18) @@ -10210,6 +10285,7 @@ (borrow-city-count uint32 :offset 620) (borrow-city pair 3 :offset-assert 624) (audio-language language-enum :offset 748) + (ear-handle handle :offset 784) ;; added, used in gsound. (special-volume float :offset 796) (pad uint8 108 :offset 800) ;; added ) @@ -15722,7 +15798,7 @@ (load-state-method-9 () none) ;; 9 ;; (reset! (_type_) _type_) (load-state-method-10 () none) ;; 10 ;; (update! (_type_) int) (load-state-method-11 () none) ;; 11 ;; (want-levels (_type_ (pointer symbol)) int) - (load-state-method-12 () none) ;; 12 ;; (want-sound-banks (_type_ (pointer symbol)) none) + (want-sound-banks (_type_ (pointer symbol)) none) ;; 12 (load-state-method-13 () none) ;; 13 ;; (want-display-level (_type_ symbol symbol) int) (load-state-method-14 () none) ;; 14 ;; (want-vis-level (_type_ symbol) none) (load-state-method-15 () none) ;; 15 ;; (want-force-vis (_type_ symbol symbol) int) @@ -27171,8 +27247,8 @@ ;; ramdisk ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype ramdisk-rpc-fill (structure) + "Unused RAMDISK rpc to load files from DVD to the IOP RAM." ((rsvd1 int32 :offset-assert 0) (ee-id int32 :offset-assert 4) (rsvd2 int32 2 :offset-assert 8) ;; guessed by decompiler @@ -27182,10 +27258,9 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype ramdisk-rpc-load (structure) + "Unused RAMDISK rpc to load files from DVD to the IOP RAM." ((rsvd int32 :offset-assert 0) (ee-id int32 :offset-assert 4) (offset uint32 :offset-assert 8) @@ -27195,10 +27270,9 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype ramdisk-rpc-load-to-ee (structure) + "Unused RAMDISK rpc to load files from DVD to the IOP RAM." ((rsvd int32 :offset-assert 0) (addr int32 :offset-assert 4) (offset int32 :offset-assert 8) @@ -27209,32 +27283,28 @@ :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 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype engine-sound-pers (engine-pers) () :method-count-assert 15 :size-assert #x20 :flag-assert #xf00000020 ) -|# -#| (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-assert 8) + (str-id-sign int32 :offset 8) (freemem uint32 :offset-assert 12) (chinfo uint8 48 :offset-assert 16) ;; guessed by decompiler (freemem2 uint32 :offset-assert 64) @@ -27246,91 +27316,90 @@ (times int32 41 :offset-assert 92) ;; guessed by decompiler (times-seq uint32 :offset-assert 256) (iop-ticks uint32 :offset-assert 260) - (stream-position uint32 4 :offset-assert 272) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (stream-position uint32 4 :offset 272) ;; guessed by decompiler + ; (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (stream-status stream-status 4 :offset-assert 288) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (stream-name sound-stream-name 4 :offset-assert 304) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ; (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (stream-name sound-stream-name 4 :inline :offset-assert 304) ;; guessed by decompiler + ; (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. (stream-id sound-id 4 :offset-assert 496) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (music-register uint8 17 :offset-assert 512) ;; guessed by decompiler - (music-excite int8 :offset-assert 528) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ; (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (music-register uint8 17 :offset 512) ;; guessed by decompiler + (music-excite int8 :offset 528) + (ramdisk-name uint8 16 :offset-assert 529) + (sound-bank0 uint8 16 :offset 592) + (sound-bank1 uint8 16) + (sound-bank2 uint8 16) + (sound-bank3 uint8 16) + (sound-bank4 uint8 16) + (sound-bank5 uint8 16) + (sound-bank6 uint8 16) + (sound-bank7 uint8 16) ) :method-count-assert 9 :size-assert #x2d0 :flag-assert #x9000002d0 ) -|# -;; (define-extern *sound-loop-engine* object) ;; engine-sound-pers -;; (define-extern *sound-player-rpc* object) ;; 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) ;; (function int symbol) -;; (define-extern current-str-pos function) ;; (function sound-id int) -;; (define-extern current-str-status function) -;; (define-extern is-ramdisk-loaded? function) ;; (function symbol symbol) -;; (define-extern is-cd-in? function) ;; (function symbol) -;; (define-extern new-sound-id function) ;; (function sound-id) -;; (define-extern check-irx-version function) ;; (function int) -;; (define-extern sound-bank-iop-store function) ;; (function sound-name sound-id) -;; (define-extern sound-bank-iop-free function) ;; (function sound-name sound-id) -;; (define-extern sound-bank-load function) ;; (function sound-name sound-id) -;; (define-extern sound-bank-load-from-iop function) ;; (function sound-name sound-id) -;; (define-extern sound-bank-load-from-ee function) ;; (function sound-name pointer sound-id) -;; (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) ;; (function stereo-mode none) -;; (define-extern list-sounds function) ;; (function none) -;; (define-extern sound-command->string function) ;; (function sound-command string) -;; (define-extern sound-buffer-dump function) ;; (function int) -;; (define-extern *sound-player-enable* object) ;; symbol -;; (define-extern swap-sound-buffers function) ;; (function vector vector vector float int) -(define-extern get-sound-buffer-entry (function pointer)) -;; (define-extern free-last-sound-buffer-entry function) ;; (function none) -;; (define-extern sound-basic-cb function) ;; (function int (pointer int32) none) -;; (define-extern sound-trans-convert function) ;; (function vector3w vector int) -;; (define-extern sound-unit-vector-convert function) -;; (define-extern sound-angle-convert function) ;; (function float int) -(define-extern string->sound-name (function string sound-name)) -;; (define-extern sound-name->string function) -;; (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 vector float int) -;; (define-extern sound-play-by-name function) ;; (function sound-name sound-id int int int sound-group object sound-id :behavior process-drawable) -;; (define-extern sound-play-by-spec function) ;; (function sound-spec sound-id vector sound-id :behavior process-drawable) -;; (define-extern sound-pause function) ;; (function sound-id int) -;; (define-extern sound-stop function) ;; (function sound-id int) -;; (define-extern sound-continue function) ;; (function sound-id int) -;; (define-extern sound-group-pause function) ;; (function sound-group int) -;; (define-extern sound-group-stop function) ;; (function sound-group int) -;; (define-extern sound-group-continue function) ;; (function sound-group int) -;; (define-extern sound-set-flava function) ;; (function uint uint int) -;; (define-extern sound-set-midi-reg function) ;; (function int int int) -;; (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 show-iop-info function) ;; (function dma-buffer int) -;; (define-extern show-iop-memory function) ;; (function dma-buffer int) -;; (define-extern ear-trans function) ;; (function int vector) -;; (define-extern make-sqrt-table function) ;; (function int) -;; (define-extern loader-test-command function) ;; (function sound-command uint none) -;; (define-extern doppler-pitch-shift function) ;; (function vector vector float) -;; (define-extern sound-bank-reload function) ;; (function none) +(define-extern *sound-loop-engine* engine-sound-pers) +(define-extern *sound-player-rpc* rpc-buffer-pair) +(define-extern *sound-loader-rpc* rpc-buffer-pair) +(define-extern sound-name= "Are two sound names the same?" (function sound-name sound-name symbol)) +(define-extern *sound-iop-info* sound-iop-info) +(define-extern str-is-playing? "Is any streaming audio playing?" (function symbol)) +(define-extern str-id-is-playing? "Is any streaming audio with the given ID playing?" (function sound-id symbol)) +(define-extern current-str-pos "Get the current stream position of the given sound ID, or -1 if it is not playing." (function sound-id int)) +(define-extern current-str-status "Get the status of the stream playing the given sound, or 0 if it is not playing." (function sound-id stream-status)) +(define-extern is-ramdisk-loaded? "Check if the ramdisk-name is set to this (unused)." (function symbol symbol)) +(define-extern is-cd-in? "Is the CD/DVD in the ps2?" (function symbol)) +(define-extern new-sound-id "Allocate a new sound ID, used to identify a unique playback of a sound." (function sound-id)) +(define-extern check-irx-version "Confirm OVERLORD version is correct and set up the sound-iop-info address so the OVERLORD can report back to the EE." (function int)) +(define-extern sound-bank-iop-store "Send a iop-store RPC to loader with the given name" (function sound-name sound-id)) +(define-extern sound-bank-iop-free "Send a iop-free RPC to loader with the given name" (function sound-name sound-id)) +(define-extern sound-bank-load "Send RPC to load a sound bank." (function sound-name int int sound-id)) +(define-extern sound-bank-load-from-iop "Send load-bank-from-iop rpc to loader" (function sound-name sound-id)) +(define-extern sound-bank-load-from-ee "Send load-bank-from-ee rpc to loader" (function sound-name pointer sound-id)) +(define-extern sound-bank-unload "Send unload-bank rpc to loader" (function sound-name int)) +(define-extern sound-music-load "Send load-music rpc to loader" (function sound-name int)) +(define-extern sound-music-unload "Send unload-music rpc to loader." (function int)) +(define-extern set-language "Send set-language rpc to loader. Note this is only for sound, no game text is changed." (function language-enum int)) +(define-extern sound-set-stereo-mode "Send set-stereo-mode rpc to loader." (function int none)) +(define-extern list-sounds "Send list-sounds rpc to loader." (function none)) +(define-extern sound-command->string "Convert sound-command enum to string." (function sound-command string)) +(define-extern sound-buffer-dump "Print out all sound-commands in the buffer." (function int)) +(define-extern *sound-player-enable* symbol) +(define-extern swap-sound-buffers "Per-frame update of sound system - update loop-engine, update ear trans, send player RPC, check for missing/dirty CD." (function vector vector vector vector vector float int)) +(define-extern get-sound-buffer-entry "Allocate a new entry in the player RPC queue, to be flushed on the next frame." (function pointer)) +(define-extern free-last-sound-buffer-entry "Remove the last thing added with get-sound-buffer-entry." (function none)) +(define-extern sound-basic-cb "Unknown and unused callback." (function int (pointer int32) none)) +(define-extern sound-trans-convert "Convert a GOAL translation (meters) to integer format for the IOP" (function (pointer int32) vector int)) +(define-extern sound-unit-vector-convert "Convert a GOAL unit-vector (float) to integer format for the IOP" (function (pointer int32) vector none)) +(define-extern sound-angle-convert "Convert a GOAL angle to integer format for the iop" (function float int)) +(define-extern string->sound-name "Create a sound-name from a string" (function string sound-name)) +(define-extern sound-name->string "Create a string from a sound-name. Returns pointer to a single shared static string." (function sound-name string)) +(define-extern sound-set-volume "Send set-master-volume rpc." (function sound-group float int)) +(define-extern sound-set-reverb "Send set-reverb rpc" (function int float float uint int)) +(define-extern sound-set-ear-trans "Send set-ear-trans rpc" (function vector vector vector vector vector float int)) +(define-extern sound-play-by-name "Send play rpc to play a sound!" (function sound-name sound-id int int int sound-group object sound-id :behavior process-drawable)) ; +(define-extern sound-play-by-spec "Send play rpc to play a sound!" (function sound-spec sound-id vector sound-id :behavior process-drawable)) +(define-extern sound-pause "Send pause-sound rpc to pause by id" (function sound-id int)) +(define-extern sound-stop "Send stop-sound rpc to stop by id" (function sound-id int)) +(define-extern sound-continue "Send continue-sound rpc to continue by id" (function sound-id int)) +(define-extern sound-group-pause "Send pause-group rpc" (function sound-group int)) +(define-extern sound-group-stop "Send stop-group rpc" (function sound-group int)) +(define-extern sound-group-continue "Send continue-group rpc" (function sound-group int)) +(define-extern sound-set-flava "Send set-flava rpc" (function uint uint int)) +(define-extern sound-set-midi-reg "Send set-midi-reg rpc" (function int int int)) +(define-extern sound-set-fps "Send set-fps rpc" (function int int)) +(define-extern sound-volume-off "Adjust settings to turn all sound volume off" (function int)) +(define-extern *ambient-spec* sound-spec) +(define-extern show-iop-info "Display iop info on screen." (function dma-buffer int)) +(define-extern show-iop-memory "Display iop memory stats on screen" (function dma-buffer int)) +(define-extern ear-trans "Get the current location of the ear. Use 1 for the settings ear-handle, or 0 for the camera." (function int vector)) +(define-extern make-sqrt-table "Generate integer square-root table used in the IOP." (function none)) +(define-extern loader-test-command "Send a command to loader by ID." (function sound-command uint none)) +(define-extern doppler-pitch-shift "Compute pitch shift for the doppler effect. This is done assuming the listener is *target* and has *target*'s velocity." (function vector vector float)) +(define-extern sound-bank-reload "Start a background process to unload all sound banks, then load them again." (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; transformq ;; @@ -29404,7 +29473,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-extern get-current-language (function language-enum)) -;; (define-extern *setting-control* object) ;; setting-control +(define-extern *setting-control* setting-control) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; mood-tables ;; @@ -30664,7 +30733,7 @@ ;; (define-extern matrix-world->local function) ;; (function symbol object matrix) ;; (define-extern *camera-dummy-vector* object) ;; vector (define-extern camera-pos (function vector)) -;; (define-extern math-camera-pos function) ;; (function vector) +(define-extern math-camera-pos (function vector)) ;; (define-extern camera-matrix function) ;; (function matrix) (define-extern math-camera-matrix (function matrix)) ;; (define-extern camera-angle function) ;; (function float) @@ -33439,7 +33508,7 @@ ;; (define-extern target-log-attack function) ;; (function attack-info symbol symbol :behavior target) ;; (define-extern ground-tween-initialize function) ;; (function ground-tween-info uint uint uint uint uint uint float ground-tween-info :behavior target) ;; (define-extern ground-tween-update function) ;; (function ground-tween-info float float float none :behavior target) -;; (define-extern target-pos function) ;; (function int vector) +(define-extern target-pos (function int vector)) ;; (define-extern target-cam-pos function) ;; (function vector) ;; (define-extern target-rot function) ;; (function quaternion) ;; (define-extern external-target-spawn function) @@ -35849,9 +35918,9 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (define-extern *footstep-surface* object) ;; pat-surface -;; (define-extern *debug-effect-control* object) ;; symbol +(define-extern *debug-effect-control* symbol) ;; (define-extern sound-name-with-material function) ;; (function string pat-surface string sound-name) -;; (define-extern effect-param->sound-spec function) ;; (function sound-spec (pointer float) int process-focusable sound-spec) +(define-extern effect-param->sound-spec (function sound-spec (pointer float) int process-focusable sound-spec)) ;; (define-extern target-land-effect function) ;; (function none :behavior target) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -36684,7 +36753,7 @@ |# ;; (define-extern *progress-stack* object) ;; (pointer uint8) -;; (define-extern *progress-process* object) ;; (pointer progress) +(define-extern *progress-process* (pointer progress)) ;; (define-extern *progress-save-info* object) ;; mc-slot-info ;; (define-extern *progress-work* object) ;; (define-extern min-max-wrap-around function) ;; (function int int int int) @@ -36693,7 +36762,7 @@ ;; (define-extern hud-ring-cell-init-by-other function) ;; (function int float int object :behavior hud-ring-cell) ;; (define-extern progress-init-by-other function) ;; (function symbol object :behavior progress) ;; (define-extern set-ring-position function) ;; (function progress float) -;; (define-extern activate-progress function) ;; (function process symbol none) +(define-extern activate-progress (function process symbol none)) ;; (define-extern deactivate-progress function) ;; (function none) ;; (define-extern hide-progress-screen function) ;; (function none) ;; (define-extern progress-allowed? function) ;; (function symbol) diff --git a/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc b/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc index 7319794923..1ff89ee204 100644 --- a/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc +++ b/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc @@ -13,5 +13,6 @@ [0, "(function none)"], [1, "(function none)"], [2, "(function none)"] - ] + ], + "gsound": [[1, "(function none)"]] } diff --git a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc index 127b3bdd1d..e5d1e2a1a9 100644 --- a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc +++ b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc @@ -14,6 +14,14 @@ "show-mc-info": [[16, "mc-slot-info"]], "joint-mod-blend-world-callback": [[16, "joint-mod-blend-world-work"]], "(method 42 nav-mesh)": [[16, "vector"], [32, "vector"]], - "(method 44 nav-mesh)": [[16, "vector"], [32, "vector"]] + "(method 44 nav-mesh)": [[16, "vector"], [32, "vector"]], + "string->sound-name": [[16, ["array", "sound-name", 1]]], + "sound-name->string": [[16, ["array", "uint8", 16]]], + "doppler-pitch-shift": [[16, ["inline-array", "vector", 2]]], + "(anon-function 1 gsound)": [ + [16, ["array", "symbol", 4]], + [32, ["array", "symbol", 4]] + ] + } diff --git a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc index a8572d8acf..06efb2e04b 100644 --- a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc @@ -372,6 +372,59 @@ [27, "s4", "uint"], [37, "s4", "uint"], [60, "s4", "pointer"] - ] + ], + "ramdisk-load": [[[7, 12], "v1", "ramdisk-rpc-load"]], + "sound-buffer-dump": [[[13, 39], "s3", "sound-rpc-play"]], + "(method 10 engine-sound-pers)": [[[2, 17], "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": [[[11, 16], "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": [[[6, 9], "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, 45], "gp", "sound-rpc-set-ear-trans"]], + "sound-name->string": [[2, "a1", "(pointer sound-name)"]], + "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)": [ + [143, "v1", "sound-spec"], + [147, "v1", "sound-spec"], + [150, "v1", "sound-spec"], + [154, "v1", "sound-spec"], + ["_stack_", 16, "sound-spec"], + ["_stack_", 64, "res-tag"], + ["_stack_", 48, "(pointer float)"], + ["_stack_", 32, "sound-name"], + [[117, 183], "s5", "ambient-sound"] + ], + "ear-trans": [ + [32, "s5", "process-focusable"] + ], + "loader-test-command": [[[5, 10], "v1", "sound-rpc-test-cmd"]] + } diff --git a/decompiler/config/jak3/ntsc_v1/var_names.jsonc b/decompiler/config/jak3/ntsc_v1/var_names.jsonc index aa2c5516d3..0ada052f4a 100644 --- a/decompiler/config/jak3/ntsc_v1/var_names.jsonc +++ b/decompiler/config/jak3/ntsc_v1/var_names.jsonc @@ -979,5 +979,254 @@ "start", "end" ] + }, + "sound-name=": { + "args": [ + "a", + "b" + ] + }, + "str-id-is-playing?": { + "args": [ + "id" + ] + }, + "current-str-pos": { + "args": [ + "id" + ] + }, + "current-str-status": { + "args": [ + "id" + ] + }, + "is-ramdisk-loaded?": { + "args": [ + "name" + ] + }, + "sound-bank-iop-store": { + "args": [ + "name" + ] + }, + "sound-bank-iop-free": { + "args": [ + "name" + ] + }, + "sound-bank-load": { + "args": [ + "name", + "mode", + "priority" + ] + }, + "sound-bank-load-from-iop": { + "args": [ + "name" + ] + }, + "sound-bank-load-from-ee": { + "args": [ + "name", + "addr" + ] + }, + "sound-bank-unload": { + "args": [ + "name" + ] + }, + "sound-music-load": { + "args": [ + "name" + ] + }, + "set-language": { + "args": [ + "lang" + ] + }, + "sound-set-stereo-mode": { + "args": [ + "mode" + ] + }, + "sound-command->string": { + "args": [ + "cmd" + ] + }, + "sound-trans-convert": { + "args": [ + "int-trans", + "meter-trans" + ] + }, + "sound-unit-vector-convert": { + "args": [ + "int-unit-vector", + "float-unit-vector" + ] + }, + "sound-angle-convert": { + "args": [ + "float-angle" + ] + }, + "string->sound-name": { + "args": [ + "str" + ] + }, + "sound-name->string": { + "args": [ + "name" + ] + }, + "sound-set-volume": { + "args": [ + "group", + "vol" + ] + }, + "sound-set-reverb": { + "args": [ + "reverb", + "left", + "right", + "core" + ] + }, + "sound-set-ear-trans": { + "args": [ + "ear0", + "ear1", + "cam", + "fwd", + "left", + "scale" + ] + }, + "sound-play-by-name": { + "args": [ + "name", + "id", + "vol", + "pitch", + "bend", + "group", + "trans" + ] + }, + "sound-play-by-spec": { + "args": [ + "spec", + "name", + "trans" + ] + }, + "sound-pause": { + "args": [ + "id" + ] + }, + "sound-stop": { + "args": [ + "id" + ] + }, + "sound-continue": { + "args": [ + "id" + ] + }, + "sound-group-pause": { + "args": [ + "group" + ] + }, + "sound-group-stop": { + "args": [ + "group" + ] + }, + "sound-group-continue": { + "args": [ + "group" + ] + }, + "sound-set-flava": { + "args": [ + "flava", + "excitement" + ] + }, + "sound-set-midi-reg": { + "args": [ + "reg", + "val" + ] + }, + "sound-set-fps": { + "args": [ + "fps" + ] + }, + "show-iop-info": { + "args": [ + "dma" + ] + }, + "show-iop-memory": { + "args": [ + "dma" + ] + }, + "ear-trans": { + "args": [ + "mode" + ] + }, + "loader-test-command": { + "args": [ + "cmd", + "param" + ] + }, + "doppler-pitch-shift": { + "args": [ + "sound-pos", + "sound-vel" + ] + }, + "(method 0 ambient-sound)": { + "args": [ + "allocation", + "type-to-make", + "spec", + "trans", + "lump-time" + ] + }, + "(method 10 ambient-sound)": { + "args": [ + "this", + "new-sound" + ] + }, + "(method 11 ambient-sound)": { + "args": [ + "this", + "new-trans" + ] + }, + "(method 12 ambient-sound)": { + "args": [ + "this", + "new-vol" + ] } } diff --git a/goal_src/jak3/engine/camera/cam-interface-h.gc b/goal_src/jak3/engine/camera/cam-interface-h.gc index 3588ecb47d..2c7452edda 100644 --- a/goal_src/jak3/engine/camera/cam-interface-h.gc +++ b/goal_src/jak3/engine/camera/cam-interface-h.gc @@ -7,6 +7,7 @@ (define-extern math-camera-matrix (function matrix)) (define-extern camera-pos (function vector)) +(define-extern math-camera-pos (function vector)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/game/effect-control-h.gc b/goal_src/jak3/engine/game/effect-control-h.gc index f6b1d55649..8446acb4aa 100644 --- a/goal_src/jak3/engine/game/effect-control-h.gc +++ b/goal_src/jak3/engine/game/effect-control-h.gc @@ -12,6 +12,8 @@ ) ;; ---effect-control-flag +(define-extern effect-param->sound-spec (function sound-spec (pointer float) int process-focusable sound-spec)) +(define-extern *debug-effect-control* symbol) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/game/game-info-h.gc b/goal_src/jak3/engine/game/game-info-h.gc index 69963c0957..b0c81974c8 100644 --- a/goal_src/jak3/engine/game/game-info-h.gc +++ b/goal_src/jak3/engine/game/game-info-h.gc @@ -239,7 +239,7 @@ (load-state-method-9 () none) (load-state-method-10 () none) (load-state-method-11 () none) - (load-state-method-12 () none) + (want-sound-banks (_type_ (pointer symbol)) none) (load-state-method-13 () none) (load-state-method-14 () none) (load-state-method-15 () none) diff --git a/goal_src/jak3/engine/game/main-h.gc b/goal_src/jak3/engine/game/main-h.gc index efc9fb580f..0f2b42c6b7 100644 --- a/goal_src/jak3/engine/game/main-h.gc +++ b/goal_src/jak3/engine/game/main-h.gc @@ -6,6 +6,7 @@ ;; dgos: GAME (declare-type debug-menu-context basic) +(define-extern movie? (function symbol)) ;; +++main-h:collide-spec (defenum collide-spec diff --git a/goal_src/jak3/engine/game/settings-h.gc b/goal_src/jak3/engine/game/settings-h.gc index e520637044..cfa025c6e6 100644 --- a/goal_src/jak3/engine/game/settings-h.gc +++ b/goal_src/jak3/engine/game/settings-h.gc @@ -5,6 +5,9 @@ ;; name in dgo: settings-h ;; dgos: GAME +(declare-type setting-control structure) +(define-extern *setting-control* setting-control) + ;; +++cam-master-options (defenum cam-master-options :type uint64 @@ -148,7 +151,7 @@ (gs12 12) (gs13 13) (gs14 14) - (gs15 15) + (screen-flip 15) (gs16 16) (gs17 17) (gs18 18) @@ -200,6 +203,31 @@ ) ;; ---game-secrets +(defmacro setting-control-func! (func s &rest args) + (let ((argb #f) + (argi 0) + (argf 0.0) + (setting (car s))) + (cond + (#t + (set! argb (car args)) + (set! argf (cadr args)) + (set! argi (caddr args)) + ) + ) + `(,func *setting-control* (with-pp pp) ,s ,argb ,argf ,argi) + ) + ) + +(defmacro add-setting! (s &rest args) + `(setting-control-func! add-setting ,s ,@args) + ) +(defmacro set-setting! (s &rest args) + `(setting-control-func! set-setting ,s ,@args) + ) +(defmacro remove-setting! (s) + `(remove-setting *setting-control* (with-pp pp) ,s) + ) ;; DECOMP BEGINS @@ -312,6 +340,7 @@ (borrow-city-count uint32 :offset 620) (borrow-city pair 3) (audio-language language-enum :offset 748) + (ear-handle handle :offset 784) (special-volume float :offset 796) (pad uint8 108 :offset 800) ) diff --git a/goal_src/jak3/engine/load/load-dgo.gc b/goal_src/jak3/engine/load/load-dgo.gc index 7320c1dccd..4c5424e718 100644 --- a/goal_src/jak3/engine/load/load-dgo.gc +++ b/goal_src/jak3/engine/load/load-dgo.gc @@ -293,7 +293,7 @@ (defun dgo-load-cancel ((arg0 int)) "Abort a DGO load." (let ((v1-0 (the-as sound-rpc-cancel-dgo (get-sound-buffer-entry)))) - (set! (-> v1-0 command) (the-as uint 49)) + (set! (-> v1-0 command) (sound-command cancel-dgo)) (set! (-> v1-0 id) (the-as uint arg0)) ) 0 diff --git a/goal_src/jak3/engine/load/ramdisk.gc b/goal_src/jak3/engine/load/ramdisk.gc index 68700443b9..c79483f68c 100644 --- a/goal_src/jak3/engine/load/ramdisk.gc +++ b/goal_src/jak3/engine/load/ramdisk.gc @@ -7,3 +7,53 @@ ;; DECOMP BEGINS +(deftype ramdisk-rpc-fill (structure) + "Unused RAMDISK rpc to load files from DVD to the IOP RAM." + ((rsvd1 int32) + (ee-id int32) + (rsvd2 int32 2) + (filename uint128) + ) + ) + + +(deftype ramdisk-rpc-load (structure) + "Unused RAMDISK rpc to load files from DVD to the IOP RAM." + ((rsvd int32) + (ee-id int32) + (offset uint32) + (length uint32) + ) + ) + + +(deftype ramdisk-rpc-load-to-ee (structure) + "Unused RAMDISK rpc to load files from DVD to the IOP RAM." + ((rsvd int32) + (addr int32) + (offset int32) + (length int32) + (filename uint128) + ) + ) + + +(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/jak3/engine/sound/gsound-h.gc b/goal_src/jak3/engine/sound/gsound-h.gc index 1e8d3a7cd5..f90fcba562 100644 --- a/goal_src/jak3/engine/sound/gsound-h.gc +++ b/goal_src/jak3/engine/sound/gsound-h.gc @@ -7,6 +7,57 @@ (defenum sound-command :type uint16 + (iop-store) + (iop-free) + (load-bank) + (load-bank-from-iop) + (load-bank-from-ee) + (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-midi-reg) + (set-reverb) + (set-ear-trans) + (shutdown) + (list-sounds) + (unload-music) + (set-fps) + (boot-load) + (game-load) + (num-tests) + (num-testruns) + (num-sectors) + (num-streamsectors) + (num-streambanks) + (track-pitch) + (linvel-nom) + (linvel-stm) + (seek-nom) + (seek-stm) + (read-seq-nom) + (read-seq-stm) + (read-spr-nom) + (read-spr-stm) + (read-spr-strn-nom) + (rand-stm-abort) + (rand-nom-abort) + (iop-mem) + (cancel-dgo) + (set-stereo-mode) ) (defenum sound-group @@ -17,20 +68,63 @@ (defenum sound-mask :bitfield #t :type uint16 + (volume) ;; 1 + (pitch) ;; 2 + (bend) ;; 4 + (unused) ;; 8 + (time) ;; 10 + (trans) ;; 20 + (fo-min) ;; 40 + (fo-max) ;; 80 + (fo-curve) ;; 100 + (sm-unk1) + (sm-unk2) + (reg0) + (reg1) + (reg2) + (unk) ) (defenum stream-status :type uint32 :bitfield #t + (ss1 1) ;; id-is-playing + (ss4 4) ;; is-playing + (ss6 6) ;; id-is-playing ) +(defmacro static-sound-name (str) + "Convert a string constant to a static sound-name." + + ;; all this is done at compile-time so we can come up with 2 + ;; 64-bit constants to use + (when (> (string-length str) 16) + (error "static-sound-name got a string that is too long") + ) + (let ((lo-val 0) + (hi-val 0) + ) + (dotimes (i (string-length str)) + (if (>= i 8) + (+! hi-val (ash (string-ref str i) (* 8 (- i 8)))) + (+! lo-val (ash (string-ref str i) (* 8 i))) + ) + ) + `(new 'static 'sound-name :lo ,lo-val :hi ,hi-val) + ) + ) + + (define-extern get-sound-buffer-entry (function pointer)) +(define-extern sound-set-ear-trans (function vector vector vector vector vector float int)) +(define-extern ear-trans (function int vector)) ;; DECOMP BEGINS (deftype sound-stream-name (structure) ((name uint8 48) ) + :pack-me ) @@ -46,14 +140,16 @@ ) (deftype sound-name (uint128) - () + ((lo uint64 :offset 0) ;; added to help with cases where they access it by u64. + (hi uint64 :offset 64) + ) ) (define-extern string->sound-name (function string sound-name)) (deftype sound-rpc-cmd (structure) ((rsvd1 uint16) - (command uint16) + (command sound-command) ) ) @@ -70,6 +166,7 @@ (trans int32 3) (group uint8) (reg uint8 3) + (group-and-reg uint32 :overlay-at group) ) :pack-me ) @@ -283,6 +380,7 @@ (num float) (group sound-group) (reg uint8 3) + (group-and-reg uint32 :overlay-at group) (sound-name-char uint8 16) (sound-name sound-name :overlay-at (-> sound-name-char 0)) (trans int32 4) @@ -300,7 +398,7 @@ (deftype sound-bank-state (structure) - ((name basic) + ((name symbol) (mode uint32) ) :pack-me @@ -313,10 +411,10 @@ ((spec sound-spec) (playing-id sound-id) (trans vector :inline) - (name uint128) - (play-time uint64) - (time-base uint64) - (time-random uint64) + (name sound-name) + (play-time time-frame) + (time-base time-frame) + (time-random time-frame) (volume int32) (pitch int32) (falloff-near int32) @@ -329,14 +427,14 @@ (sound-state int32) ) (:methods - (new (symbol type) _type_) - (ambient-sound-method-9 () none) - (ambient-sound-method-10 () none) - (ambient-sound-method-11 () none) - (ambient-sound-method-12 () none) - (ambient-sound-method-13 () none) - (ambient-sound-method-14 () none) - (ambient-sound-method-15 () none) - (ambient-sound-method-16 () none) + (new (symbol type basic vector float) _type_) + (update! (_type_) int) + (change-sound! (_type_ sound-name) int) + (update-trans! (_type_ vector) int) + (update-vol! (_type_ float) int) + (update-pitch-mod! (_type_ float) none) + (set-falloff-far! (_type_ float) none) + (set-falloff-mode! (_type_ int) none) + (stop! (_type_) int) ) ) diff --git a/goal_src/jak3/engine/sound/gsound.gc b/goal_src/jak3/engine/sound/gsound.gc index d801b5fd1d..d1d6edc7f6 100644 --- a/goal_src/jak3/engine/sound/gsound.gc +++ b/goal_src/jak3/engine/sound/gsound.gc @@ -7,3 +7,1305 @@ ;; DECOMP BEGINS +(deftype engine-sound-pers (engine-pers) + () + ) + + +(defmethod kill-callback ((this engine-sound-pers) (arg0 connection-pers)) + "Called when a connection is removed." + (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)) + (-> 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= ((a sound-name) (b sound-name)) + "Are two sound names the same?" + (and (= (the-as uint a) (the-as uint b)) (= (-> a hi) (-> b hi))) + ) + +(deftype sound-iop-info (structure) + ((frame uint32) + (strpos int32) + (str-id uint32) + (str-id-sign int32 :overlay-at str-id) + (freemem uint32) + (chinfo uint8 48) + (freemem2 uint32) + (nocd uint32) + (dirtycd uint32) + (diskspeed uint32 2) + (lastspeed uint32) + (dupseg int32) + (times int32 41) + (times-seq uint32) + (iop-ticks uint32) + (stream-position uint32 4 :offset 272) + (stream-status stream-status 4) + (stream-name sound-stream-name 4 :inline) + (stream-id sound-id 4) + (music-register uint8 17 :offset 512) + (music-excite int8 :overlay-at (-> music-register 16)) + (ramdisk-name uint8 16) + (sound-bank0 uint8 16 :offset 592) + (sound-bank1 uint8 16) + (sound-bank2 uint8 16) + (sound-bank3 uint8 16) + (sound-bank4 uint8 16) + (sound-bank5 uint8 16) + (sound-bank6 uint8 16) + (sound-bank7 uint8 16) + ) + ) + + +(define *sound-iop-info* (new 'global 'sound-iop-info)) + +(defun str-is-playing? () + "Is any streaming audio playing?" + (countdown (v1-0 4) + (if (and (>= (the-as uint (-> *sound-iop-info* stream-id v1-0)) 0) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status ss4)) + ) + (return #t) + ) + ) + #f + ) + +(defun str-id-is-playing? ((id sound-id)) + "Is any streaming audio with the given ID playing?" + (countdown (v1-0 4) + (if (and (= id (-> *sound-iop-info* stream-id v1-0)) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status ss1 ss6)) + ) + (return #t) + ) + ) + #f + ) + +(defun current-str-pos ((id sound-id)) + "Get the current stream position of the given sound ID, or -1 if it is not playing." + (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 (= id (-> *sound-iop-info* stream-id v1-5)) + (return (the-as int (-> *sound-iop-info* stream-position v1-5))) + ) + ) + -1 + ) + +;; WARN: Return type mismatch int vs stream-status. +(defun current-str-status ((id sound-id)) + "Get the status of the stream playing the given sound, or 0 if it is not playing." + (dotimes (v1-0 4) + (if (= id (-> *sound-iop-info* stream-id v1-0)) + (return (the-as stream-status (-> *sound-iop-info* stream-status v1-0))) + ) + ) + (the-as stream-status 0) + ) + +(defun is-ramdisk-loaded? ((name symbol)) + "Check if the ramdisk-name is set to this (unused)." + (let ((gp-0 (-> *sound-iop-info* ramdisk-name)) + (s5-0 (symbol->string name)) + ) + (and (charp-prefix= (-> s5-0 data) gp-0) (= (-> gp-0 (length s5-0)) 46)) + ) + ) + +(defun is-cd-in? () + "Is the CD/DVD in the ps2?" + (zero? (-> *sound-iop-info* nocd)) + ) + +(defun new-sound-id () + "Allocate a new sound ID, used to identify a unique playback of a sound." + (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 () + "Confirm OVERLORD version is correct and set up the sound-iop-info address so the OVERLORD can report back to the EE." + (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 ((name sound-name)) + "Send a iop-store RPC to loader with the given 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) name) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +(defun sound-bank-iop-free ((name sound-name)) + "Send a iop-free RPC to loader with the given 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) name) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +(defun sound-bank-load ((name sound-name) (mode int) (priority int)) + "Send RPC to load a sound bank." + (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) name) + (set! (-> v1-1 mode) (the-as uint mode)) + (set! (-> v1-1 priority) (the-as uint priority)) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +(defun sound-bank-load-from-iop ((name sound-name)) + "Send load-bank-from-iop rpc to loader" + (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) name) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +(defun sound-bank-load-from-ee ((name sound-name) (addr pointer)) + "Send load-bank-from-ee rpc to loader" + (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) name) + (set! (-> v1-1 ee-addr) addr) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + gp-0 + ) + ) + +(defun sound-bank-unload ((name sound-name)) + "Send unload-bank rpc to loader" + (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) name) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +(defun sound-music-load ((name sound-name)) + "Send load-music rpc to loader" + (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) name) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +(defun sound-music-unload () + "Send unload-music rpc to loader." + (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 ((lang language-enum)) + "Send set-language rpc to loader. Note this is only for sound, no game text is changed." + (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 lang)) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +(defun sound-set-stereo-mode ((mode int)) + "Send set-stereo-mode rpc to loader." + (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) mode) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + (none) + ) + +(defun list-sounds () + "Send list-sounds rpc to loader." + (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)) + "Convert sound-command enum to string." + (case cmd + (((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*" + ) + ) + ) + +(defun sound-buffer-dump () + "Print out all sound-commands in the buffer." + (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 vector) (arg4 vector) (arg5 float)) + "Per-frame update of sound system - update loop-engine, update ear trans, send player RPC, check for missing/dirty CD." + (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 arg4 arg5) + ) + ) + (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 () + "Allocate a new entry in the player RPC queue, to be flushed on the next frame." + (add-element *sound-player-rpc*) + ) + +(defun free-last-sound-buffer-entry () + "Remove the last thing added with get-sound-buffer-entry." + (decrement-elt-used *sound-player-rpc*) + 0 + (none) + ) + +(defun sound-basic-cb ((arg0 int) (arg1 (pointer int32))) + "Unknown and unused callback." + (set! (-> arg1 0) arg0) + 0 + (none) + ) + +(defun sound-trans-convert ((int-trans (pointer int32)) (meter-trans vector)) + "Convert a GOAL translation (meters) to integer format for the IOP" + (let ((v1-0 (if meter-trans + meter-trans + (ear-trans 0) + ) + ) + ) + (set! (-> int-trans 0) (the int (* 0.0625 (-> v1-0 x)))) + (set! (-> int-trans 1) (the int (* 0.0625 (-> v1-0 y)))) + (set! (-> int-trans 2) (the int (* 0.0625 (-> v1-0 z)))) + ) + 0 + ) + +(defun sound-unit-vector-convert ((int-unit-vector (pointer int32)) (float-unit-vector vector)) + "Convert a GOAL unit-vector (float) to integer format for the IOP" + (set! (-> int-unit-vector 0) (the int (* 256.0 (-> float-unit-vector x)))) + (set! (-> int-unit-vector 1) (the int (* 256.0 (-> float-unit-vector y)))) + (set! (-> int-unit-vector 2) (the int (* 256.0 (-> float-unit-vector z)))) + 0 + (none) + ) + +(defun sound-angle-convert ((float-angle float)) + "Convert a GOAL angle to integer format for the iop" + (let* ((f0-3 (the float (sar (shl (the int float-angle) 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 ((str string)) + "Create a sound-name from a string" + (let ((v1-0 (new 'stack-no-clear 'array 'sound-name 1))) + (set! (-> v1-0 0) (the-as sound-name 0)) + (let ((a1-0 (the-as (pointer uint8) v1-0)) + (a2-0 (-> str data)) + ) + (while (and (nonzero? (-> a2-0 0)) (< (&- a2-0 (the-as uint (-> str data))) 15)) + (set! (-> a1-0 0) (-> a2-0 0)) + (set! a1-0 (&-> a1-0 1)) + (set! a2-0 (&-> a2-0 1)) + ) + ) + (-> v1-0 0) + ) + ) + +(defun sound-name->string ((name sound-name)) + "Create a string from a sound-name. Returns pointer to a single shared static string." + (let ((v1-0 (new 'static 'boxed-array :type string "0123456789abcdef"))) + (let ((a1-0 (the-as (pointer uinteger) (new 'stack-no-clear 'array 'uint8 16)))) + (set! (-> (the-as (pointer sound-name) a1-0) 0) name) + (let ((a0-2 (-> v1-0 0 data))) + (while (and (nonzero? (-> (the-as (pointer uint8) a1-0) 0)) (< (&- a0-2 (the-as uint (-> v1-0 0 data))) 15)) + (set! (-> a0-2 0) (-> (the-as (pointer uint8) a1-0) 0)) + (set! a0-2 (&-> a0-2 1)) + (set! a1-0 (&-> (the-as (pointer uint8) a1-0) 1)) + ) + (while (< (&- a0-2 (the-as uint (-> v1-0 0 data))) 16) + (set! (-> a0-2 0) (the-as uint 0)) + (set! a0-2 (&-> a0-2 1)) + ) + ) + ) + (-> v1-0 0) + ) + ) + +(defun sound-set-volume ((group sound-group) (vol float)) + "Send set-master-volume rpc." + (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) (the-as uint group)) + (set! (-> v1-0 volume) (the int (* 1024.0 vol))) + ) + 0 + ) + +(defun sound-set-reverb ((reverb int) (left float) (right float) (core uint)) + "Send set-reverb rpc" + (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) core) + (set! (-> v1-0 reverb) reverb) + (set! (-> v1-0 left) (the-as uint (the int (* 32767.0 left)))) + (set! (-> v1-0 right) (the-as uint (the int (* 32767.0 right)))) + ) + 0 + ) + +(defun sound-set-ear-trans ((ear0 vector) (ear1 vector) (cam vector) (fwd vector) (left vector) (scale float)) + "Send set-ear-trans rpc" + (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 (-> gp-0 ear-trans0) ear0) + (sound-trans-convert (-> gp-0 ear-trans1) ear1) + (sound-trans-convert (-> gp-0 cam-trans) cam) + (sound-unit-vector-convert (-> gp-0 cam-forward) fwd) + (sound-unit-vector-convert (-> gp-0 cam-left) left) + (set! (-> gp-0 cam-scale) (the int (* 65536.0 scale))) + (set! (-> gp-0 cam-inverted) (if (logtest? (-> *game-info* secrets) (game-secrets screen-flip)) + 1 + 0 + ) + ) + ) + 0 + ) + +(defbehavior sound-play-by-name process-drawable ((name sound-name) (id sound-id) (vol int) (pitch int) (bend int) (group sound-group) (trans object)) + "Send play rpc to play a sound!" + (local-vars (sv-16 sound-group)) + (set! sv-16 group) + (let ((s4-0 trans)) + (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) id) + (set! (-> s5-0 name) name) + (set! (-> s5-0 params mask) (the-as uint 0)) + (set! (-> s5-0 params group) (the-as uint sv-16)) + (set! (-> s5-0 params volume) vol) + (set! (-> s5-0 params pitch-mod) pitch) + (set! (-> s5-0 params bend) bend) + (let ((s3-1 self)) + (when (= 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 (-> s5-0 params trans) (the-as vector s4-0)) + ) + ) + ) + id + ) + +(defbehavior sound-play-by-spec process-drawable ((spec sound-spec) (name sound-id) (trans vector)) + "Send play rpc to play a sound!" + (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) name) + (set! (-> s5-0 name) (-> spec sound-name)) + (set! (-> s5-0 params mask) (the-as uint (-> spec mask))) + (set! (-> s5-0 params group-and-reg) (-> spec group-and-reg)) + (set! (-> s5-0 params volume) (-> spec volume)) + (set! (-> s5-0 params pitch-mod) (-> spec pitch-mod)) + (set! (-> s5-0 params bend) (-> spec bend)) + (set! (-> s5-0 params fo-min) (-> spec fo-min)) + (set! (-> s5-0 params fo-max) (-> spec fo-max)) + (set! (-> s5-0 params fo-curve) (-> spec fo-curve)) + (set! (-> s5-0 params priority) (-> spec priority)) + (let ((s3-1 self)) + (when (= trans #t) + (if (and s3-1 (type? s3-1 process-drawable) (nonzero? (-> s3-1 root))) + (set! trans (-> s3-1 root trans)) + (set! trans (the-as vector #f)) + ) + ) + ) + (sound-trans-convert (-> s5-0 params trans) trans) + ) + ) + name + ) + +(defun sound-pause ((id sound-id)) + "Send pause-sound rpc to pause by id" + (when (nonzero? id) + (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) id) + ) + ) + 0 + ) + +(defun sound-stop ((id sound-id)) + "Send stop-sound rpc to stop by id" + (when (nonzero? id) + (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) id) + ) + ) + 0 + ) + +(defun sound-continue ((id sound-id)) + "Send continue-sound rpc to continue by id" + (when (nonzero? id) + (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) id) + ) + ) + 0 + ) + +(defun sound-group-pause ((group sound-group)) + "Send pause-group rpc" + (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) (the-as uint group)) + ) + 0 + ) + +(defun sound-group-stop ((group sound-group)) + "Send stop-group rpc" + (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) (the-as uint group)) + ) + 0 + ) + +(defun sound-group-continue ((group sound-group)) + "Send continue-group rpc" + (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) (the-as uint group)) + ) + 0 + ) + +(defun sound-set-flava ((flava uint) (excitement uint)) + "Send set-flava rpc" + (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) flava) + (set! (-> v1-0 excitement) excitement) + ) + 0 + ) + +(defun sound-set-midi-reg ((reg int) (val int)) + "Send set-midi-reg rpc" + (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) reg) + (set! (-> v1-0 value) val) + ) + 0 + ) + +(defun sound-set-fps ((fps int)) + "Send set-fps rpc" + (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 fps)) + ) + 0 + ) + +(defun sound-volume-off () + "Adjust settings to turn all sound volume off" + (set-setting! 'music-volume 'abs 0.0 0) + (set-setting! 'sfx-volume 'abs 0.0 0) + (set-setting! 'ambient-volume 'abs 0.0 0) + 0 + ) + +(define *ambient-spec* (new 'static 'sound-spec)) + +(defmethod new ambient-sound ((allocation symbol) (type-to-make type) (spec basic) (trans vector) (lump-time float)) + "Set up ambient-sound. Can use an entity-actor (grabs from lump), sound-spec, or name as a string." + (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 (-> spec type) + ((entity-actor) + (let* ((a0-3 ((method-of-type res-lump get-property-struct) + (the-as res-lump spec) + 'effect-name + 'exact + lump-time + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (v1-2 (when a0-3 + (case (rtype-of a0-3) + ((symbol) + (symbol->string (the-as symbol a0-3)) + ) + ((string) + a0-3 + ) + (else + "unknown" + ) + ) + ) + ) + ) + (when v1-2 + (set! sv-32 (string->sound-name (the-as string v1-2))) + (set! sv-48 (res-lump-data (the-as res-lump spec) 'cycle-speed (pointer float))) + (set! sv-16 *ambient-spec*) + (set! sv-64 (new 'static 'res-tag)) + (let ((v1-9 ((method-of-type res-lump get-property-data) + (the-as res-lump spec) + 'effect-param + 'exact + lump-time + (the-as pointer #f) + (& sv-64) + *res-static-buf* + ) + ) + ) + (when v1-9 + (set! sv-52 v1-9) + (set! sv-56 (the-as int (-> sv-64 elt-count))) + ) + ) + ) + ) + ) + ((sound-spec) + (set! sv-16 (the-as sound-spec spec)) + ) + ((string) + (set! sv-32 (string->sound-name (the-as string spec))) + ) + (else + (format 0 "ERROR: ambient sound was told to play an unknown ~A.~%" spec) + ) + ) + (cond + ((or sv-16 (nonzero? sv-32)) + (let ((s5-1 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s5-1 spec) sv-16) + (set! (-> s5-1 name) sv-32) + (set! (-> s5-1 playing-id) (new-sound-id)) + (set! (-> s5-1 params) (the-as (pointer float) sv-52)) + (set! (-> s5-1 param-count) sv-56) + (set! (-> s5-1 entity) #f) + (set! (-> s5-1 sound-count) 1) + (set! (-> s5-1 volume) 1024) + (set! (-> 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! (-> s5-1 volume) (-> (the-as sound-spec sv-16) volume)) + ) + (if (logtest? (-> (the-as sound-spec sv-16) mask) (sound-mask pitch)) + (set! (-> s5-1 pitch) (-> (the-as sound-spec sv-16) pitch-mod)) + ) + ) + (cond + (sv-48 + (set! (-> s5-1 time-base) (the-as time-frame (the int (* 300.0 (-> sv-48 0))))) + (set! (-> s5-1 time-random) (the-as time-frame (the int (* 300.0 (-> sv-48 1))))) + ) + (else + (set! (-> s5-1 time-base) -1) + ) + ) + (set! (-> s5-1 trans quad) (-> trans quad)) + s5-1 + ) + ) + (else + (the-as ambient-sound 0) + ) + ) + ) + +(defmethod update! ((this ambient-sound)) + "Per-frame update of ambient sound." + (local-vars (a0-9 vector) (a0-18 vector)) + (with-pp + (if (not *ambient-sound-class*) + (return (the-as int #f)) + ) + (cond + ((-> this spec) + (when (or (< (-> this time-base) 0) (>= (current-time) (-> this play-time))) + (when (>= (-> this time-base) 0) + (set! (-> this play-time) + (+ (current-time) (-> this time-base) (rand-vu-int-count (the-as int (-> this time-random)))) + ) + (set! (-> this playing-id) (new-sound-id)) + ) + (let ((s5-1 (-> this spec))) + (when (= s5-1 *ambient-spec*) + (set! (-> s5-1 volume) (-> this volume)) + (set! (-> s5-1 pitch-mod) (-> this pitch)) + (set! (-> s5-1 bend) 0) + (set! (-> s5-1 sound-name) (-> this name)) + (set! (-> s5-1 fo-max) (-> this falloff-far)) + (set! (-> s5-1 fo-curve) (-> this falloff-mode)) + (set! (-> s5-1 mask) (sound-mask)) + (if (-> this params) + (effect-param->sound-spec s5-1 (-> this params) (-> this param-count) (the-as process-focusable pp)) + ) + ) + (case (-> s5-1 fo-curve) + ((9 11) + (set! a0-9 (ear-trans 1)) + ) + (else + (set! a0-9 (ear-trans 0)) + ) + ) + (let ((v1-29 (-> s5-1 fo-max))) + (when (and (nonzero? v1-29) (< (* 4096.0 (the float v1-29)) (vector-vector-distance a0-9 (-> this trans)))) + (when (zero? (-> this sound-state)) + (sound-stop (-> this playing-id)) + (set! (-> this sound-state) 1) + ) + (return 0) + ) + ) + (when (and *debug-effect-control* (>= (-> this time-base) 0)) + (format #t "(~5D) effect sound ~A ~G " (current-time) (-> pp name) (-> s5-1 sound-name-char)) + (format + #t + "volume: ~f pitch-mod: ~f~%" + (* 0.09765625 (the float (-> s5-1 volume))) + (* 0.000656168 (the float (-> s5-1 pitch-mod))) + ) + ) + (let ((s4-1 (-> s5-1 volume))) + (set! (-> s5-1 volume) (-> this volume)) + (set! (-> this sound-state) 0) + (set! (-> this playing-id) (sound-play-by-spec s5-1 (-> this playing-id) (-> this trans))) + (set! (-> s5-1 volume) s4-1) + ) + ) + ) + ) + ((< (-> this time-base) 0) + (let ((s5-2 (-> this falloff-far))) + (case (-> this falloff-mode) + ((9 11) + (set! a0-18 (ear-trans 1)) + ) + (else + (set! a0-18 (ear-trans 0)) + ) + ) + (when (and (nonzero? s5-2) (< (* 4096.0 (the float s5-2)) (vector-vector-distance a0-18 (-> this trans)))) + (when (zero? (-> this sound-state)) + (sound-stop (-> this playing-id)) + (set! (-> this sound-state) 1) + ) + (return 0) + ) + ) + (set! (-> this sound-state) 0) + (set! (-> this playing-id) (sound-play-by-name + (-> this name) + (-> this playing-id) + (-> this volume) + (-> this pitch) + 0 + (sound-group) + (-> this trans) + ) + ) + ) + (else + (when (>= (current-time) (-> this play-time)) + (set! (-> this sound-state) 0) + (set! (-> this playing-id) + (sound-play-by-name + (-> this name) + (new-sound-id) + (-> this volume) + (-> this pitch) + 0 + (sound-group) + (-> this trans) + ) + ) + (set! (-> this play-time) + (+ (current-time) (-> this time-base) (rand-vu-int-count (the-as int (-> this time-random)))) + ) + ) + ) + ) + 0 + ) + ) + +(defmethod stop! ((this ambient-sound)) + (sound-stop (-> this playing-id)) + 0 + ) + +(defmethod update-trans! ((this ambient-sound) (new-trans vector)) + "Change the trans of the sound." + (set! (-> this trans quad) (-> new-trans quad)) + 0 + ) + +(defmethod update-vol! ((this ambient-sound) (new-vol float)) + "Change the volume of the sound." + (set! (-> this volume) (the int (* 1024.0 new-vol))) + 0 + ) + +(defmethod update-pitch-mod! ((this ambient-sound) (arg0 float)) + (set! (-> this pitch) (the int (* 1524.0 arg0))) + 0 + (none) + ) + +(defmethod set-falloff-far! ((this ambient-sound) (arg0 float)) + (set! (-> this falloff-far) (the int (* 0.00024414062 arg0))) + 0 + (none) + ) + +(defmethod set-falloff-mode! ((this ambient-sound) (arg0 int)) + (set! (-> this falloff-mode) arg0) + 0 + (none) + ) + +(defmethod change-sound! ((this ambient-sound) (new-sound sound-name)) + "Change the sound being played." + (when (not (and (= (the-as uint (-> this name)) (the-as uint new-sound)) (= (-> new-sound hi) (-> this name hi)))) + (stop! this) + (set! (-> this playing-id) (new-sound-id)) + (set! (-> this name) new-sound) + ) + 0 + ) + +(defun show-iop-info ((dma dma-buffer)) + "Display iop info on screen." + (dotimes (s5-0 24) + (draw-string-xy + (if (zero? (-> *sound-iop-info* chinfo s5-0)) + "." + "X" + ) + dma + (+ (* 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" + ) + dma + (+ (* 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 name) + (-> *level* sound-bank 2 name) + (-> *level* sound-bank 4 name) + ) + (s5-2 *temp-string* dma 16 88 (font-color default) (font-flags shadow)) + ) + (let ((s5-3 draw-string-xy)) + (format + (clear *temp-string*) + " ~15S ~15S ~15S" + (-> *level* sound-bank 1 name) + (-> *level* sound-bank 3 name) + (-> *level* sound-bank 5 name) + ) + (s5-3 *temp-string* dma 16 104 (font-color default) (font-flags shadow)) + ) + (let ((s5-4 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-4 *temp-string* dma 16 118 (font-color default) (font-flags shadow)) + ) + 0 + ) + +(defun show-iop-memory ((dma dma-buffer)) + "Display iop memory stats on screen" + (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* dma 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* dma 32 64 (font-color default) (font-flags shadow)) + ) + 0 + ) + +(defun ear-trans ((mode int)) + "Get the current location of the ear. Use 1 for the settings ear-handle, or 0 for the camera." + (let ((gp-0 (the-as process-focusable #f))) + (cond + ((or (movie?) *external-cam-mode*) + (math-camera-pos) + ) + ((and (= mode 1) (begin + (let ((s5-1 (handle->process (-> *setting-control* user-current ear-handle)))) + (set! gp-0 (if (type? s5-1 process-focusable) + (the-as process-focusable s5-1) + ) + ) + ) + gp-0 + ) + ) + (get-trans gp-0 11) + ) + (else + (camera-pos) + ) + ) + ) + ) + +(defun-debug make-sqrt-table () + "Generate integer square-root table used in the IOP." + (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 + (none) + ) + +(check-irx-version) + +(sound-bank-load (static-sound-name "common") 2 10) + +(dotimes (gp-0 3) + (let* ((v1-61 gp-0) + (s5-0 (cond + ((zero? v1-61) + 'empty0 + ) + ((= v1-61 1) + 'empty1 + ) + ((= v1-61 2) + 'empty2 + ) + ((= v1-61 3) + 'empty3 + ) + ) + ) + ) + (sound-bank-load (string->sound-name (symbol->string s5-0)) 4 10) + (set! (-> *level* sound-bank (* gp-0 2) name) s5-0) + ) + (set! (-> *level* sound-bank (* gp-0 2) mode) (the-as uint 4)) + ) + +(defun loader-test-command ((cmd sound-command) (param uint)) + "Send a command to loader by ID." + (let ((v1-1 (the-as sound-rpc-test-cmd (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) cmd) + (set! (-> v1-1 ee-addr) (the-as pointer 0)) + (set! (-> v1-1 param0) param) + ) + (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 ((sound-pos vector) (sound-vel vector)) + "Compute pitch shift for the doppler effect. This is done assuming the listener is *target* and has *target*'s velocity." + (let ((gp-0 (new 'stack-no-clear 'inline-array 'vector 2))) + (vector-! (-> gp-0 0) (target-pos 0) sound-pos) + (if *target* + (vector-! (-> gp-0 1) sound-vel (-> *target* control transv)) + (set! (-> gp-0 1 quad) (-> sound-vel 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 () + "Start a background process to unload all sound banks, then load them again." + (process-spawn-function + process + (lambda () + (let ((gp-0 (new 'static 'boxed-array :type symbol :length 0 :allocated-length 6))) + (dotimes (v1-0 6) + (set! (-> gp-0 v1-0) (-> *level* sound-bank v1-0 name)) + ) + (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 (current-time))) + (until (time-elapsed? s5-0 (seconds 1)) + (suspend) + ) + ) + (let ((a1-4 (new 'stack-no-clear 'array 'symbol 4))) + (set! (-> a1-4 2) (-> gp-0 4)) + (set! (-> a1-4 1) (-> gp-0 2)) + (set! (-> a1-4 0) (-> gp-0 0)) + (want-sound-banks *load-state* a1-4) + ) + ) + (none) + ) + :to *display-pool* + ) + 0 + (none) + ) diff --git a/goal_src/jak3/engine/target/target-h.gc b/goal_src/jak3/engine/target/target-h.gc index 8fe60c06e9..fdc6b4ceea 100644 --- a/goal_src/jak3/engine/target/target-h.gc +++ b/goal_src/jak3/engine/target/target-h.gc @@ -27,6 +27,9 @@ (declare-type darkjak-info basic) (declare-type lightjak-info basic) +(define-extern target-pos (function int vector)) + + ;; DECOMP BEGINS (deftype target (process-focusable) diff --git a/goal_src/jak3/engine/ui/progress/progress-h.gc b/goal_src/jak3/engine/ui/progress/progress-h.gc index 30df2fe8e6..75a7862595 100644 --- a/goal_src/jak3/engine/ui/progress/progress-h.gc +++ b/goal_src/jak3/engine/ui/progress/progress-h.gc @@ -5,6 +5,10 @@ ;; name in dgo: progress-h ;; dgos: GAME +(declare-type progress process) +(define-extern *progress-process* (pointer progress)) +(define-extern activate-progress (function process symbol none)) + ;; +++progress-icon-flags (defenum progress-icon-flags :type uint32 diff --git a/goal_src/jak3/kernel/gstate.gc b/goal_src/jak3/kernel/gstate.gc index 99d9f535ba..440704abf8 100644 --- a/goal_src/jak3/kernel/gstate.gc +++ b/goal_src/jak3/kernel/gstate.gc @@ -14,21 +14,21 @@ ) ) -;; disable for now, since the extra arg to get-process is unknown. -; (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)." +(defmacro process-spawn-function (proc-type func &key (from *default-dead-pool*) &key (to *default-pool*) &key (name #f) &key (stack-size #x4000) &key (stack *scratch-memory-top*) &rest args) + "Start a new process that runs a function on its main thread. + Returns a pointer to the new process (or #f? on error). + Note that the extra jak 3 arg is so far always 1 (checked in decompiler)" -; (with-gensyms (new-proc) -; `(let ((,new-proc (the-as ,proc-type (get-process ,from ,proc-type ,stack-size)))) -; (when ,new-proc -; ((method-of-type ,proc-type activate) ,new-proc ,to ,(if name name `(symbol->string ',proc-type)) ,stack) -; (run-next-time-in-process ,new-proc ,func ,@args) -; (the (pointer ,proc-type) (-> ,new-proc ppointer)) -; ) -; ) -; ) -; ) + (with-gensyms (new-proc) + `(let ((,new-proc (the-as ,proc-type (get-process ,from ,proc-type ,stack-size 1)))) + (when ,new-proc + ((method-of-type ,proc-type activate) ,new-proc ,to ,(if name name `(symbol->string ',proc-type)) ,stack) + (run-next-time-in-process ,new-proc ,func ,@args) + (the (pointer ,proc-type) (-> ,new-proc ppointer)) + ) + ) + ) + ) ; (defmacro process-spawn (proc-type &key (init #f) &key (from *default-dead-pool*) &key (to *default-pool*) &key (name #f) &key (stack-size #x4000) &key (stack *scratch-memory-top*) &rest args) ; "Start a new process and run an init function on it. diff --git a/test/decompiler/reference/jak3/decompiler-macros.gc b/test/decompiler/reference/jak3/decompiler-macros.gc index df8326fc29..f3e28fb427 100644 --- a/test/decompiler/reference/jak3/decompiler-macros.gc +++ b/test/decompiler/reference/jak3/decompiler-macros.gc @@ -819,4 +819,73 @@ ,@(apply-i (lambda (x i) `(set! (-> event-data param ,i) (the-as uint ,x))) params) (send-event-function ,proc event-data) ) + ) + +(defmacro setting-control-func! (func s &rest args) + (let ((argb #f) + (argi 0) + (argf 0.0) + (setting (cadr s))) + (cond + (#t + (set! argb (car args)) + (set! argf (cadr args)) + (set! argi (caddr args)) + ) + ) + `(,func *setting-control* (with-pp pp) ,s ,argb ,argf ,argi) + ) + ) + +(defmacro add-setting! (s &rest args) + `(setting-control-func! add-setting ,s ,@args) + ) +(defmacro set-setting! (s &rest args) + `(setting-control-func! set-setting ,s ,@args) + ) +(defmacro remove-setting! (s) + `(remove-setting *setting-control* (with-pp pp) ,s) + ) + +(defmacro static-sound-name (str) + "Convert a string constant to a static sound-name." + + ;; all this is done at compile-time so we can come up with 2 + ;; 64-bit constants to use + (when (> (string-length str) 16) + (error "static-sound-name got a string that is too long") + ) + (let ((lo-val 0) + (hi-val 0) + ) + (dotimes (i (string-length str)) + (if (>= i 8) + (+! hi-val (ash (string-ref str i) (* 8 (- i 8)))) + (+! lo-val (ash (string-ref str i) (* 8 i))) + ) + ) + `(new 'static 'sound-name :lo ,lo-val :hi ,hi-val) + ) + ) + +(defmacro time-elapsed? (time duration) + `(>= (- (current-time) ,time) ,duration) + ) + +(defconstant *scratch-memory-top* (the pointer #x70004000)) +(defconstant DPROCESS_STACK_SIZE #x8000) + +(defmacro process-spawn-function (proc-type func &key (from *default-dead-pool*) &key (to *default-pool*) &key (name #f) &key (stack-size #x4000) &key (stack *scratch-memory-top*) &rest args) + "Start a new process that runs a function on its main thread. + Returns a pointer to the new process (or #f? on error)." + + (with-gensyms (new-proc) + `(let ((,new-proc (the-as ,proc-type (get-process ,from ,proc-type ,stack-size 1)))) + (when ,new-proc + ((method-of-type ,proc-type activate) ,new-proc ,to ,(if name name `(symbol->string (-> ,proc-type symbol))) ,stack) + (run-next-time-in-process ,new-proc ,func ,@args) + (the (pointer ,proc-type) (-> ,new-proc ppointer)) + ) + ) + ) ) \ No newline at end of file diff --git a/test/decompiler/reference/jak3/engine/game/game-info-h_REF.gc b/test/decompiler/reference/jak3/engine/game/game-info-h_REF.gc index 14ef2b31cd..813451ffa6 100644 --- a/test/decompiler/reference/jak3/engine/game/game-info-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/game/game-info-h_REF.gc @@ -137,7 +137,7 @@ (load-state-method-9 () none) (load-state-method-10 () none) (load-state-method-11 () none) - (load-state-method-12 () none) + (want-sound-banks (_type_ (pointer symbol)) none) (load-state-method-13 () none) (load-state-method-14 () none) (load-state-method-15 () none) diff --git a/test/decompiler/reference/jak3/engine/game/settings-h_REF.gc b/test/decompiler/reference/jak3/engine/game/settings-h_REF.gc index 2ded36aa6e..a2b1caf5a8 100644 --- a/test/decompiler/reference/jak3/engine/game/settings-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/game/settings-h_REF.gc @@ -111,6 +111,7 @@ (borrow-city-count uint32 :offset 620) (borrow-city pair 3) (audio-language language-enum :offset 748) + (ear-handle handle :offset 784) (special-volume float :offset 796) (pad uint8 108 :offset 800) ) @@ -673,7 +674,3 @@ ;; failed to figure out what this is: 0 - - - - diff --git a/test/decompiler/reference/jak3/engine/load/load-dgo_REF.gc b/test/decompiler/reference/jak3/engine/load/load-dgo_REF.gc index b800db6a5b..57b4d59671 100644 --- a/test/decompiler/reference/jak3/engine/load/load-dgo_REF.gc +++ b/test/decompiler/reference/jak3/engine/load/load-dgo_REF.gc @@ -353,7 +353,7 @@ (defun dgo-load-cancel ((arg0 int)) "Abort a DGO load." (let ((v1-0 (the-as sound-rpc-cancel-dgo (get-sound-buffer-entry)))) - (set! (-> v1-0 command) (the-as uint 49)) + (set! (-> v1-0 command) (sound-command cancel-dgo)) (set! (-> v1-0 id) (the-as uint arg0)) ) 0 @@ -448,7 +448,3 @@ 0 (none) ) - - - - diff --git a/test/decompiler/reference/jak3/engine/load/ramdisk_REF.gc b/test/decompiler/reference/jak3/engine/load/ramdisk_REF.gc new file mode 100644 index 0000000000..6aa17ec01c --- /dev/null +++ b/test/decompiler/reference/jak3/engine/load/ramdisk_REF.gc @@ -0,0 +1,113 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type ramdisk-rpc-fill +(deftype ramdisk-rpc-fill (structure) + "Unused RAMDISK rpc to load files from DVD to the IOP RAM." + ((rsvd1 int32) + (ee-id int32) + (rsvd2 int32 2) + (filename uint128) + ) + ) + +;; definition for method 3 of type ramdisk-rpc-fill +;; INFO: Used lq/sq +(defmethod inspect ((this ramdisk-rpc-fill)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ramdisk-rpc-fill) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tee-id: ~D~%" (-> this ee-id)) + (format #t "~1Trsvd2[2] @ #x~X~%" (-> this rsvd2)) + (format #t "~1Tfilename: ~D~%" (-> this filename)) + (label cfg-4) + this + ) + +;; definition of type ramdisk-rpc-load +(deftype ramdisk-rpc-load (structure) + "Unused RAMDISK rpc to load files from DVD to the IOP RAM." + ((rsvd int32) + (ee-id int32) + (offset uint32) + (length uint32) + ) + ) + +;; definition for method 3 of type ramdisk-rpc-load +(defmethod inspect ((this ramdisk-rpc-load)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ramdisk-rpc-load) + (format #t "~1Trsvd: ~D~%" (-> this rsvd)) + (format #t "~1Tee-id: ~D~%" (-> this ee-id)) + (format #t "~1Toffset: ~D~%" (-> this offset)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (label cfg-4) + this + ) + +;; definition of type ramdisk-rpc-load-to-ee +(deftype ramdisk-rpc-load-to-ee (structure) + "Unused RAMDISK rpc to load files from DVD to the IOP RAM." + ((rsvd int32) + (addr int32) + (offset int32) + (length int32) + (filename uint128) + ) + ) + +;; definition for method 3 of type ramdisk-rpc-load-to-ee +;; INFO: Used lq/sq +(defmethod inspect ((this ramdisk-rpc-load-to-ee)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'ramdisk-rpc-load-to-ee) + (format #t "~1Trsvd: ~D~%" (-> this rsvd)) + (format #t "~1Taddr: ~D~%" (-> this addr)) + (format #t "~1Toffset: ~D~%" (-> this offset)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tfilename: ~D~%" (-> this filename)) + (label cfg-4) + this + ) + +;; 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 +;; WARN: 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/jak3/engine/sound/gsound-h_REF.gc b/test/decompiler/reference/jak3/engine/sound/gsound-h_REF.gc new file mode 100644 index 0000000000..9183f1e966 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/sound/gsound-h_REF.gc @@ -0,0 +1,894 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type sound-stream-name +(deftype sound-stream-name (structure) + ((name uint8 48) + ) + :pack-me + ) + +;; definition for method 3 of type sound-stream-name +(defmethod inspect ((this sound-stream-name)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-stream-name) + (format #t "~1Tname[48] @ #x~X~%" (-> this name)) + (label cfg-4) + this + ) + +;; definition of type sound-id +(deftype sound-id (uint32) + () + (:methods + (unknown () none) + ) + ) + +;; definition of type sound-bank-id +(deftype sound-bank-id (uint32) + () + ) + +;; definition of type sound-name +(deftype sound-name (uint128) + ((lo uint64 :offset 0 :size 64) + (hi uint64 :offset 64 :size 64) + ) + ) + +;; definition of type sound-rpc-cmd +(deftype sound-rpc-cmd (structure) + ((rsvd1 uint16) + (command sound-command) + ) + ) + +;; definition for method 3 of type sound-rpc-cmd +(defmethod inspect ((this sound-rpc-cmd)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-cmd) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (label cfg-4) + this + ) + +;; definition of type sound-play-params +(deftype sound-play-params (structure) + ((mask uint16) + (pitch-mod int16) + (bend int16) + (fo-min int16) + (fo-max int16) + (fo-curve int8) + (priority int8) + (volume int32) + (trans int32 3) + (group uint8) + (reg uint8 3) + (group-and-reg uint32 :overlay-at group) + ) + :pack-me + ) + +;; definition for method 3 of type sound-play-params +(defmethod inspect ((this sound-play-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-play-params) + (format #t "~1Tmask: ~D~%" (-> this mask)) + (format #t "~1Tpitch-mod: ~D~%" (-> this pitch-mod)) + (format #t "~1Tbend: ~D~%" (-> this bend)) + (format #t "~1Tfo-min: ~D~%" (-> this fo-min)) + (format #t "~1Tfo-max: ~D~%" (-> this fo-max)) + (format #t "~1Tfo-curve: ~D~%" (-> this fo-curve)) + (format #t "~1Tpriority: ~D~%" (-> this priority)) + (format #t "~1Tvolume: ~D~%" (-> this volume)) + (format #t "~1Ttrans[3] @ #x~X~%" (-> this trans)) + (format #t "~1Tgroup: ~D~%" (-> this group)) + (format #t "~1Treg[3] @ #x~X~%" (-> this reg)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-bank-cmd +(deftype sound-rpc-bank-cmd (sound-rpc-cmd) + ((bank-name sound-name) + ) + ) + +;; definition for method 3 of type sound-rpc-bank-cmd +;; INFO: Used lq/sq +(defmethod inspect ((this sound-rpc-bank-cmd)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-bank-cmd) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tbank-name: ~D~%" (-> this bank-name)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-test-cmd +(deftype sound-rpc-test-cmd (sound-rpc-cmd) + ((ee-addr pointer) + (param0 uint16) + ) + ) + +;; definition for method 3 of type sound-rpc-test-cmd +(defmethod inspect ((this sound-rpc-test-cmd)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-test-cmd) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tee-addr: ~D~%" (-> this ee-addr)) + (format #t "~1Tparam0: ~D~%" (-> this param0)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-sound-cmd +(deftype sound-rpc-sound-cmd (sound-rpc-cmd) + ((id sound-id) + ) + ) + +;; definition for method 3 of type sound-rpc-sound-cmd +(defmethod inspect ((this sound-rpc-sound-cmd)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-sound-cmd) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tid: ~D~%" (-> this id)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-group-cmd +(deftype sound-rpc-group-cmd (sound-rpc-cmd) + ((group uint32) + ) + ) + +;; definition for method 3 of type sound-rpc-group-cmd +(defmethod inspect ((this sound-rpc-group-cmd)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-group-cmd) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tgroup: ~D~%" (-> this group)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-load-bank +(deftype sound-rpc-load-bank (sound-rpc-bank-cmd) + ((ee-addr pointer) + (mode uint32) + (priority uint32) + ) + ) + +;; definition for method 3 of type sound-rpc-load-bank +;; INFO: Used lq/sq +(defmethod inspect ((this sound-rpc-load-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-load-bank) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tbank-name: ~D~%" (-> this bank-name)) + (format #t "~1Tee-addr: ~D~%" (-> this ee-addr)) + (format #t "~1Tmode: ~D~%" (-> this mode)) + (format #t "~1Tpriority: ~D~%" (-> this priority)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-load-music +(deftype sound-rpc-load-music (sound-rpc-bank-cmd) + () + ) + +;; definition for method 3 of type sound-rpc-load-music +;; INFO: Used lq/sq +(defmethod inspect ((this sound-rpc-load-music)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-load-music) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tbank-name: ~D~%" (-> this bank-name)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-unload-bank +(deftype sound-rpc-unload-bank (sound-rpc-bank-cmd) + () + ) + +;; definition for method 3 of type sound-rpc-unload-bank +;; INFO: Used lq/sq +(defmethod inspect ((this sound-rpc-unload-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-unload-bank) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tbank-name: ~D~%" (-> this bank-name)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-play +(deftype sound-rpc-play (sound-rpc-sound-cmd) + ((name sound-name) + (params sound-play-params :inline) + ) + ) + +;; definition for method 3 of type sound-rpc-play +;; INFO: Used lq/sq +(defmethod inspect ((this sound-rpc-play)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-play) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tname: ~D~%" (-> this name)) + (format #t "~1Tparams: #~%" (-> this params)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-pause-sound +(deftype sound-rpc-pause-sound (sound-rpc-sound-cmd) + () + ) + +;; definition for method 3 of type sound-rpc-pause-sound +(defmethod inspect ((this sound-rpc-pause-sound)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-pause-sound) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tid: ~D~%" (-> this id)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-stop-sound +(deftype sound-rpc-stop-sound (sound-rpc-sound-cmd) + () + ) + +;; definition for method 3 of type sound-rpc-stop-sound +(defmethod inspect ((this sound-rpc-stop-sound)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-stop-sound) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tid: ~D~%" (-> this id)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-continue-sound +(deftype sound-rpc-continue-sound (sound-rpc-sound-cmd) + () + ) + +;; definition for method 3 of type sound-rpc-continue-sound +(defmethod inspect ((this sound-rpc-continue-sound)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-continue-sound) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tid: ~D~%" (-> this id)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-set-param +(deftype sound-rpc-set-param (sound-rpc-sound-cmd) + ((params sound-play-params :inline) + (auto-time int32) + (auto-from int32) + ) + ) + +;; definition for method 3 of type sound-rpc-set-param +(defmethod inspect ((this sound-rpc-set-param)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-set-param) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tparams: #~%" (-> this params)) + (format #t "~1Tauto-time: ~D~%" (-> this auto-time)) + (format #t "~1Tauto-from: ~D~%" (-> this auto-from)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-set-master-volume +(deftype sound-rpc-set-master-volume (sound-rpc-group-cmd) + ((volume int32) + ) + ) + +;; definition for method 3 of type sound-rpc-set-master-volume +(defmethod inspect ((this sound-rpc-set-master-volume)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-set-master-volume) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tgroup: ~D~%" (-> this group)) + (format #t "~1Tvolume: ~D~%" (-> this volume)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-pause-group +(deftype sound-rpc-pause-group (sound-rpc-group-cmd) + () + ) + +;; definition for method 3 of type sound-rpc-pause-group +(defmethod inspect ((this sound-rpc-pause-group)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-pause-group) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tgroup: ~D~%" (-> this group)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-stop-group +(deftype sound-rpc-stop-group (sound-rpc-group-cmd) + () + ) + +;; definition for method 3 of type sound-rpc-stop-group +(defmethod inspect ((this sound-rpc-stop-group)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-stop-group) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tgroup: ~D~%" (-> this group)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-continue-group +(deftype sound-rpc-continue-group (sound-rpc-group-cmd) + () + ) + +;; definition for method 3 of type sound-rpc-continue-group +(defmethod inspect ((this sound-rpc-continue-group)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-continue-group) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tgroup: ~D~%" (-> this group)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-cancel-dgo +(deftype sound-rpc-cancel-dgo (sound-rpc-group-cmd) + ((id uint32) + ) + ) + +;; definition for method 3 of type sound-rpc-cancel-dgo +(defmethod inspect ((this sound-rpc-cancel-dgo)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-cancel-dgo) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tgroup: ~D~%" (-> this group)) + (format #t "~1Tid: ~D~%" (-> this id)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-get-irx-version +(deftype sound-rpc-get-irx-version (sound-rpc-cmd) + ((major uint32) + (minor uint32) + (ee-addr pointer) + ) + ) + +;; definition for method 3 of type sound-rpc-get-irx-version +(defmethod inspect ((this sound-rpc-get-irx-version)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-get-irx-version) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tmajor: ~D~%" (-> this major)) + (format #t "~1Tminor: ~D~%" (-> this minor)) + (format #t "~1Tee-addr: ~D~%" (-> this ee-addr)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-set-language +(deftype sound-rpc-set-language (sound-rpc-cmd) + ((lang uint32) + ) + ) + +;; definition for method 3 of type sound-rpc-set-language +(defmethod inspect ((this sound-rpc-set-language)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-set-language) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tlang: ~D~%" (-> this lang)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-set-stereo-mode +(deftype sound-rpc-set-stereo-mode (sound-rpc-cmd) + ((mode int32) + ) + ) + +;; definition for method 3 of type sound-rpc-set-stereo-mode +(defmethod inspect ((this sound-rpc-set-stereo-mode)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-set-stereo-mode) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tmode: ~D~%" (-> this mode)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-set-reverb +(deftype sound-rpc-set-reverb (sound-rpc-cmd) + ((core uint8) + (reverb int32) + (left uint32) + (right uint32) + ) + ) + +;; definition for method 3 of type sound-rpc-set-reverb +(defmethod inspect ((this sound-rpc-set-reverb)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-set-reverb) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tcore: ~D~%" (-> this core)) + (format #t "~1Treverb: ~D~%" (-> this reverb)) + (format #t "~1Tleft: ~D~%" (-> this left)) + (format #t "~1Tright: ~D~%" (-> this right)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-set-ear-trans +(deftype sound-rpc-set-ear-trans (sound-rpc-cmd) + ((ear-trans1 int32 3) + (ear-trans0 int32 3) + (cam-trans int32 3) + (cam-forward int32 3) + (cam-left int32 3) + (cam-scale int32) + (cam-inverted int32) + ) + ) + +;; definition for method 3 of type sound-rpc-set-ear-trans +(defmethod inspect ((this sound-rpc-set-ear-trans)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-set-ear-trans) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tear-trans1[3] @ #x~X~%" (-> this ear-trans1)) + (format #t "~1Tear-trans0[3] @ #x~X~%" (-> this ear-trans0)) + (format #t "~1Tcam-trans[3] @ #x~X~%" (-> this cam-trans)) + (format #t "~1Tcam-forward[3] @ #x~X~%" (-> this cam-forward)) + (format #t "~1Tcam-left[3] @ #x~X~%" (-> this cam-left)) + (format #t "~1Tcam-scale: ~D~%" (-> this cam-scale)) + (format #t "~1Tcam-inverted: ~D~%" (-> this cam-inverted)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-set-flava +(deftype sound-rpc-set-flava (sound-rpc-cmd) + ((flava uint8) + (excitement uint8) + ) + ) + +;; definition for method 3 of type sound-rpc-set-flava +(defmethod inspect ((this sound-rpc-set-flava)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-set-flava) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tflava: ~D~%" (-> this flava)) + (format #t "~1Texcitement: ~D~%" (-> this excitement)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-set-midi-reg +(deftype sound-rpc-set-midi-reg (sound-rpc-cmd) + ((reg int32) + (value int16) + ) + ) + +;; definition for method 3 of type sound-rpc-set-midi-reg +(defmethod inspect ((this sound-rpc-set-midi-reg)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-set-midi-reg) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Treg: ~D~%" (-> this reg)) + (format #t "~1Tvalue: ~D~%" (-> this value)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-shutdown +(deftype sound-rpc-shutdown (sound-rpc-cmd) + () + ) + +;; definition for method 3 of type sound-rpc-shutdown +(defmethod inspect ((this sound-rpc-shutdown)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-shutdown) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-set-fps +(deftype sound-rpc-set-fps (sound-rpc-cmd) + ((fps uint8) + ) + ) + +;; definition for method 3 of type sound-rpc-set-fps +(defmethod inspect ((this sound-rpc-set-fps)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-set-fps) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (format #t "~1Tfps: ~D~%" (-> this fps)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-list-sounds +(deftype sound-rpc-list-sounds (sound-rpc-cmd) + () + ) + +;; definition for method 3 of type sound-rpc-list-sounds +(defmethod inspect ((this sound-rpc-list-sounds)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-list-sounds) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-unload-music +(deftype sound-rpc-unload-music (sound-rpc-cmd) + () + ) + +;; definition for method 3 of type sound-rpc-unload-music +(defmethod inspect ((this sound-rpc-unload-music)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-unload-music) + (format #t "~1Trsvd1: ~D~%" (-> this rsvd1)) + (format #t "~1Tcommand: ~D~%" (-> this command)) + (label cfg-4) + this + ) + +;; definition of type sound-rpc-union +(deftype sound-rpc-union (structure) + ((data uint32 20) + (load-bank sound-rpc-load-bank :overlay-at (-> data 0)) + (unload-bank sound-rpc-unload-bank :overlay-at (-> data 0)) + (play sound-rpc-play :overlay-at (-> data 0)) + (pause-sound sound-rpc-pause-sound :overlay-at (-> data 0)) + (stop-sound sound-rpc-stop-sound :overlay-at (-> data 0)) + (continue-sound sound-rpc-continue-sound :overlay-at (-> data 0)) + (set-param sound-rpc-set-param :overlay-at (-> data 0)) + (set-master-volume sound-rpc-set-master-volume :overlay-at (-> data 0)) + (pause-group sound-rpc-pause-group :overlay-at (-> data 0)) + (stop-group sound-rpc-stop-group :overlay-at (-> data 0)) + (continue-group sound-rpc-continue-group :overlay-at (-> data 0)) + (get-irx-version sound-rpc-get-irx-version :overlay-at (-> data 0)) + (set-language sound-rpc-set-language :overlay-at (-> data 0)) + (set-reverb sound-rpc-set-reverb :overlay-at (-> data 0)) + (set-ear-trans sound-rpc-set-ear-trans :overlay-at (-> data 0)) + (set-flava sound-rpc-set-flava :overlay-at (-> data 0)) + (set-midi-reg sound-rpc-set-midi-reg :overlay-at (-> data 0)) + (set-fps sound-rpc-set-fps :overlay-at (-> data 0)) + (shutdown sound-rpc-shutdown :overlay-at (-> data 0)) + (list-sounds sound-rpc-list-sounds :overlay-at (-> data 0)) + (unload-music sound-rpc-unload-music :overlay-at (-> data 0)) + ) + ) + +;; definition for method 3 of type sound-rpc-union +(defmethod inspect ((this sound-rpc-union)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-rpc-union) + (format #t "~1Tdata[20] @ #x~X~%" (-> this data)) + (format #t "~1Tload-bank: #~%" (-> this load-bank)) + (format #t "~1Tunload-bank: #~%" (-> this load-bank)) + (format #t "~1Tplay: #~%" (-> this load-bank)) + (format #t "~1Tpause-sound: #~%" (-> this load-bank)) + (format #t "~1Tstop-sound: #~%" (-> this load-bank)) + (format #t "~1Tcontinue-sound: #~%" (-> this load-bank)) + (format #t "~1Tset-param: #~%" (-> this load-bank)) + (format #t "~1Tset-master-volume: #~%" (-> this load-bank)) + (format #t "~1Tpause-group: #~%" (-> this load-bank)) + (format #t "~1Tstop-group: #~%" (-> this load-bank)) + (format #t "~1Tcontinue-group: #~%" (-> this load-bank)) + (format #t "~1Tget-irx-version: #~%" (-> this load-bank)) + (format #t "~1Tset-language: #~%" (-> this load-bank)) + (format #t "~1Tset-reverb: #~%" (-> this load-bank)) + (format #t "~1Tset-ear-trans: #~%" (-> this load-bank)) + (format #t "~1Tset-flava: #~%" (-> this load-bank)) + (format #t "~1Tset-midi-reg: #~%" (-> this load-bank)) + (format #t "~1Tset-fps: #~%" (-> this load-bank)) + (format #t "~1Tshutdown: #~%" (-> this load-bank)) + (format #t "~1Tlist-sounds: #~%" (-> this load-bank)) + (format #t "~1Tunload-music: #~%" (-> this load-bank)) + (label cfg-4) + this + ) + +;; definition of type sound-spec +(deftype sound-spec (basic) + ((mask sound-mask) + (num float) + (group sound-group) + (reg uint8 3) + (group-and-reg uint32 :overlay-at group) + (sound-name-char uint8 16) + (sound-name sound-name :overlay-at (-> sound-name-char 0)) + (trans int32 4) + (volume int32) + (pitch-mod int32) + (bend int32) + (fo-min int16) + (fo-max int16) + (fo-curve int8) + (priority int8) + (auto-time int32) + (auto-from int32) + ) + ) + +;; definition for method 3 of type sound-spec +;; INFO: Used lq/sq +(defmethod inspect ((this sound-spec)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tmask: ~D~%" (-> this mask)) + (format #t "~1Tnum: ~f~%" (-> this num)) + (format #t "~1Tgroup: ~D~%" (-> this group)) + (format #t "~1Treg[3] @ #x~X~%" (-> this reg)) + (format #t "~1Tsound-name-char: ~g~%" (-> this sound-name-char)) + (format #t "~1Tsound-name: ~D~%" (-> this sound-name)) + (format #t "~1Ttrans[4] @ #x~X~%" (-> this trans)) + (format #t "~1Tvolume: ~D~%" (-> this volume)) + (format #t "~1Tpitch-mod: ~D~%" (-> this pitch-mod)) + (format #t "~1Tbend: ~D~%" (-> this bend)) + (format #t "~1Tfo-min: ~D~%" (-> this fo-min)) + (format #t "~1Tfo-max: ~D~%" (-> this fo-max)) + (format #t "~1Tfo-curve: ~D~%" (-> this fo-curve)) + (format #t "~1Tpriority: ~D~%" (-> this priority)) + (format #t "~1Tauto-time: ~D~%" (-> this auto-time)) + (format #t "~1Tauto-from: ~D~%" (-> this auto-from)) + (label cfg-4) + this + ) + +;; definition of type sound-bank-state +(deftype sound-bank-state (structure) + ((name symbol) + (mode uint32) + ) + :pack-me + ) + +;; definition for method 3 of type sound-bank-state +(defmethod inspect ((this sound-bank-state)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'sound-bank-state) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tmode: ~D~%" (-> this mode)) + (label cfg-4) + this + ) + +;; definition for symbol *current-sound-id*, type sound-id +(define *current-sound-id* (the-as sound-id #x10000)) + +;; definition of type ambient-sound +(deftype ambient-sound (basic) + ((spec sound-spec) + (playing-id sound-id) + (trans vector :inline) + (name sound-name) + (play-time time-frame) + (time-base time-frame) + (time-random time-frame) + (volume int32) + (pitch int32) + (falloff-near int32) + (falloff-far int32) + (falloff-mode int32) + (params (pointer float)) + (param-count int32) + (entity entity) + (sound-count int32) + (sound-state int32) + ) + (:methods + (new (symbol type basic vector float) _type_) + (update! (_type_) int) + (change-sound! (_type_ sound-name) int) + (update-trans! (_type_ vector) int) + (update-vol! (_type_ float) int) + (update-pitch-mod! (_type_ float) none) + (set-falloff-far! (_type_ float) none) + (set-falloff-mode! (_type_ int) none) + (stop! (_type_) int) + ) + ) + +;; definition for method 3 of type ambient-sound +;; INFO: Used lq/sq +(defmethod inspect ((this ambient-sound)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tspec: ~A~%" (-> this spec)) + (format #t "~1Tplaying-id: ~D~%" (-> this playing-id)) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Tname: ~D~%" (-> this name)) + (format #t "~1Tplay-time: ~D~%" (-> this play-time)) + (format #t "~1Ttime-base: ~D~%" (-> this time-base)) + (format #t "~1Ttime-random: ~D~%" (-> this time-random)) + (format #t "~1Tvolume: ~D~%" (-> this volume)) + (format #t "~1Tpitch: ~D~%" (-> this pitch)) + (format #t "~1Tfalloff-near: ~D~%" (-> this falloff-near)) + (format #t "~1Tfalloff-far: ~D~%" (-> this falloff-far)) + (format #t "~1Tfalloff-mode: ~D~%" (-> this falloff-mode)) + (format #t "~1Tparams: #x~X~%" (-> this params)) + (format #t "~1Tparam-count: ~D~%" (-> this param-count)) + (format #t "~1Tentity: ~A~%" (-> this entity)) + (format #t "~1Tsound-count: ~D~%" (-> this sound-count)) + (format #t "~1Tsound-state: ~D~%" (-> this sound-state)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 diff --git a/test/decompiler/reference/jak3/engine/sound/gsound_REF.gc b/test/decompiler/reference/jak3/engine/sound/gsound_REF.gc new file mode 100644 index 0000000000..eba549144f --- /dev/null +++ b/test/decompiler/reference/jak3/engine/sound/gsound_REF.gc @@ -0,0 +1,1485 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type engine-sound-pers +(deftype engine-sound-pers (engine-pers) + () + ) + +;; definition for method 3 of type engine-sound-pers +(defmethod inspect ((this engine-sound-pers)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Telement-type: ~A~%" (-> this element-type)) + (format #t "~1Texecute-time: ~D~%" (-> this execute-time)) + (format #t "~1Talive-list: #~%" (-> this alive-list)) + (format #t "~1Tdead-list: #~%" (-> this dead-list)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition for method 10 of type engine-sound-pers +;; WARN: Return type mismatch int vs none. +(defmethod kill-callback ((this engine-sound-pers) (arg0 connection-pers)) + "Called when a connection is removed." + (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)) + (-> 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= ((a sound-name) (b sound-name)) + "Are two sound names the same?" + (and (= (the-as uint a) (the-as uint b)) (= (-> a hi) (-> b hi))) + ) + +;; definition of type sound-iop-info +(deftype sound-iop-info (structure) + ((frame uint32) + (strpos int32) + (str-id uint32) + (str-id-sign int32 :overlay-at str-id) + (freemem uint32) + (chinfo uint8 48) + (freemem2 uint32) + (nocd uint32) + (dirtycd uint32) + (diskspeed uint32 2) + (lastspeed uint32) + (dupseg int32) + (times int32 41) + (times-seq uint32) + (iop-ticks uint32) + (stream-position uint32 4 :offset 272) + (stream-status stream-status 4) + (stream-name sound-stream-name 4 :inline) + (stream-id sound-id 4) + (music-register uint8 17 :offset 512) + (music-excite int8 :overlay-at (-> music-register 16)) + (ramdisk-name uint8 16) + (sound-bank0 uint8 16 :offset 592) + (sound-bank1 uint8 16) + (sound-bank2 uint8 16) + (sound-bank3 uint8 16) + (sound-bank4 uint8 16) + (sound-bank5 uint8 16) + (sound-bank6 uint8 16) + (sound-bank7 uint8 16) + ) + ) + +;; definition for method 3 of type sound-iop-info +(defmethod inspect ((this sound-iop-info)) + (when (not this) + (set! this this) + (goto cfg-16) + ) + (format #t "[~8x] ~A~%" this 'sound-iop-info) + (format #t "~1Tframe: ~D~%" (-> this frame)) + (format #t "~1Tstrpos: ~D~%" (-> this strpos)) + (format #t "~1Tstr-id: ~D~%" (-> this str-id)) + (format #t "~1Tstr-id-sign: ~D~%" (-> this str-id-sign)) + (format #t "~1Tfreemem: ~D~%" (-> this freemem)) + (format #t "~1Tchinfo[48] @ #x~X~%" (-> this chinfo)) + (format #t "~1Tfreemem2: ~D~%" (-> this freemem2)) + (format #t "~1Tnocd: ~D~%" (-> this nocd)) + (format #t "~1Tdirtycd: ~D~%" (-> this dirtycd)) + (format #t "~1Tdiskspeed[2] @ #x~X~%" (-> this diskspeed)) + (format #t "~1Tlastspeed: ~D~%" (-> this lastspeed)) + (format #t "~1Tdupseg: ~D~%" (-> this dupseg)) + (format #t "~1Ttimes[41] @ #x~X~%" (-> this times)) + (format #t "~1Ttimes-seq: ~D~%" (-> this times-seq)) + (format #t "~1Tiop-ticks: ~D~%" (-> this iop-ticks)) + (format #t "~1Tstream-position[4] @ #x~X~%" (-> this stream-position)) + (dotimes (s5-0 4) + (format #t "~T [~D]~1Tstream-position: ~`integer`P~%" s5-0 (-> this stream-position s5-0)) + ) + (format #t "~1Tstream-status[4] @ #x~X~%" (-> this stream-status)) + (dotimes (s5-1 4) + (format #t "~T [~D]~1Tstream-status: #x~X~%" s5-1 (-> this stream-status s5-1)) + ) + (format #t "~1Tstream-name[4] @ #x~X~%" (-> this stream-name)) + (dotimes (s5-2 4) + (format #t "~T [~D]~1Tstream-name: ~g~%" s5-2 (-> this stream-name s5-2)) + ) + (format #t "~1Tstream-id[4] @ #x~X~%" (-> this stream-id)) + (dotimes (s5-3 4) + (format #t "~T [~D]~1Tstream-id: ~`uint32`P~%" s5-3 (-> this stream-id s5-3)) + ) + (format #t "~1Tmusic-register[17] @ #x~X~%" (-> this music-register)) + (format #t "~1Tmusic-excite: ~D~%" (-> this music-excite)) + (format #t "~1Tramdisk-name: ~g~%" (-> this ramdisk-name)) + (format #t "~1Tsound-bank0: ~g~%" (-> this sound-bank0)) + (format #t "~1Tsound-bank1: ~g~%" (-> this sound-bank1)) + (format #t "~1Tsound-bank2: ~g~%" (-> this sound-bank2)) + (format #t "~1Tsound-bank3: ~g~%" (-> this sound-bank3)) + (format #t "~1Tsound-bank4: ~g~%" (-> this sound-bank4)) + (format #t "~1Tsound-bank5: ~g~%" (-> this sound-bank5)) + (format #t "~1Tsound-bank6: ~g~%" (-> this sound-bank6)) + (format #t "~1Tsound-bank7: ~g~%" (-> this sound-bank7)) + (label cfg-16) + this + ) + +;; 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? () + "Is any streaming audio playing?" + (countdown (v1-0 4) + (if (and (>= (the-as uint (-> *sound-iop-info* stream-id v1-0)) 0) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status ss4)) + ) + (return #t) + ) + ) + #f + ) + +;; definition for function str-id-is-playing? +(defun str-id-is-playing? ((id sound-id)) + "Is any streaming audio with the given ID playing?" + (countdown (v1-0 4) + (if (and (= id (-> *sound-iop-info* stream-id v1-0)) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status ss1 ss6)) + ) + (return #t) + ) + ) + #f + ) + +;; definition for function current-str-pos +(defun current-str-pos ((id sound-id)) + "Get the current stream position of the given sound ID, or -1 if it is not playing." + (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 (= id (-> *sound-iop-info* stream-id v1-5)) + (return (the-as int (-> *sound-iop-info* stream-position v1-5))) + ) + ) + -1 + ) + +;; definition for function current-str-status +;; WARN: Return type mismatch int vs stream-status. +(defun current-str-status ((id sound-id)) + "Get the status of the stream playing the given sound, or 0 if it is not playing." + (dotimes (v1-0 4) + (if (= id (-> *sound-iop-info* stream-id v1-0)) + (return (the-as stream-status (-> *sound-iop-info* stream-status v1-0))) + ) + ) + (the-as stream-status 0) + ) + +;; definition for function is-ramdisk-loaded? +(defun is-ramdisk-loaded? ((name symbol)) + "Check if the ramdisk-name is set to this (unused)." + (let ((gp-0 (-> *sound-iop-info* ramdisk-name)) + (s5-0 (symbol->string name)) + ) + (and (charp-prefix= (-> s5-0 data) gp-0) (= (-> gp-0 (length s5-0)) 46)) + ) + ) + +;; definition for function is-cd-in? +(defun is-cd-in? () + "Is the CD/DVD in the ps2?" + (zero? (-> *sound-iop-info* nocd)) + ) + +;; definition for function new-sound-id +(defun new-sound-id () + "Allocate a new sound ID, used to identify a unique playback of a sound." + (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 () + "Confirm OVERLORD version is correct and set up the sound-iop-info address so the OVERLORD can report back to the EE." + (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 ((name sound-name)) + "Send a iop-store RPC to loader with the given 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) name) + ) + (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 ((name sound-name)) + "Send a iop-free RPC to loader with the given 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) name) + ) + (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 ((name sound-name) (mode int) (priority int)) + "Send RPC to load a sound bank." + (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) name) + (set! (-> v1-1 mode) (the-as uint mode)) + (set! (-> v1-1 priority) (the-as uint priority)) + ) + (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 ((name sound-name)) + "Send load-bank-from-iop rpc to loader" + (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) name) + ) + (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 ((name sound-name) (addr pointer)) + "Send load-bank-from-ee rpc to loader" + (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) name) + (set! (-> v1-1 ee-addr) addr) + ) + (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 ((name sound-name)) + "Send unload-bank rpc to loader" + (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) name) + ) + (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 ((name sound-name)) + "Send load-music rpc to loader" + (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) name) + ) + (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 () + "Send unload-music rpc to loader." + (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 ((lang language-enum)) + "Send set-language rpc to loader. Note this is only for sound, no game text is changed." + (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 lang)) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + ) + +;; definition for function sound-set-stereo-mode +;; WARN: Return type mismatch int vs none. +(defun sound-set-stereo-mode ((mode int)) + "Send set-stereo-mode rpc to loader." + (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) mode) + ) + (call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0)) + 0 + (none) + ) + +;; definition for function list-sounds +;; WARN: Return type mismatch int vs none. +(defun list-sounds () + "Send list-sounds rpc to loader." + (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 ((cmd sound-command)) + "Convert sound-command enum to string." + (case cmd + (((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 () + "Print out all sound-commands in the buffer." + (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 vector) (arg4 vector) (arg5 float)) + "Per-frame update of sound system - update loop-engine, update ear trans, send player RPC, check for missing/dirty CD." + (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 arg4 arg5) + ) + ) + (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 () + "Allocate a new entry in the player RPC queue, to be flushed on the next frame." + (add-element *sound-player-rpc*) + ) + +;; definition for function free-last-sound-buffer-entry +;; WARN: Return type mismatch int vs none. +(defun free-last-sound-buffer-entry () + "Remove the last thing added with get-sound-buffer-entry." + (decrement-elt-used *sound-player-rpc*) + 0 + (none) + ) + +;; definition for function sound-basic-cb +;; WARN: Return type mismatch int vs none. +(defun sound-basic-cb ((arg0 int) (arg1 (pointer int32))) + "Unknown and unused callback." + (set! (-> arg1 0) arg0) + 0 + (none) + ) + +;; definition for function sound-trans-convert +(defun sound-trans-convert ((int-trans (pointer int32)) (meter-trans vector)) + "Convert a GOAL translation (meters) to integer format for the IOP" + (let ((v1-0 (if meter-trans + meter-trans + (ear-trans 0) + ) + ) + ) + (set! (-> int-trans 0) (the int (* 0.0625 (-> v1-0 x)))) + (set! (-> int-trans 1) (the int (* 0.0625 (-> v1-0 y)))) + (set! (-> int-trans 2) (the int (* 0.0625 (-> v1-0 z)))) + ) + 0 + ) + +;; definition for function sound-unit-vector-convert +;; WARN: Return type mismatch int vs none. +(defun sound-unit-vector-convert ((int-unit-vector (pointer int32)) (float-unit-vector vector)) + "Convert a GOAL unit-vector (float) to integer format for the IOP" + (set! (-> int-unit-vector 0) (the int (* 256.0 (-> float-unit-vector x)))) + (set! (-> int-unit-vector 1) (the int (* 256.0 (-> float-unit-vector y)))) + (set! (-> int-unit-vector 2) (the int (* 256.0 (-> float-unit-vector z)))) + 0 + (none) + ) + +;; definition for function sound-angle-convert +(defun sound-angle-convert ((float-angle float)) + "Convert a GOAL angle to integer format for the iop" + (let* ((f0-3 (the float (sar (shl (the int float-angle) 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 +(defun string->sound-name ((str string)) + "Create a sound-name from a string" + (let ((v1-0 (new 'stack-no-clear 'array 'sound-name 1))) + (set! (-> v1-0 0) (the-as sound-name 0)) + (let ((a1-0 (the-as (pointer uint8) v1-0)) + (a2-0 (-> str data)) + ) + (while (and (nonzero? (-> a2-0 0)) (< (&- a2-0 (the-as uint (-> str data))) 15)) + (set! (-> a1-0 0) (-> a2-0 0)) + (set! a1-0 (&-> a1-0 1)) + (set! a2-0 (&-> a2-0 1)) + ) + ) + (-> v1-0 0) + ) + ) + +;; definition for function sound-name->string +;; INFO: Used lq/sq +(defun sound-name->string ((name sound-name)) + "Create a string from a sound-name. Returns pointer to a single shared static string." + (let ((v1-0 (new 'static 'boxed-array :type string "0123456789abcdef"))) + (let ((a1-0 (the-as (pointer uinteger) (new 'stack-no-clear 'array 'uint8 16)))) + (set! (-> (the-as (pointer sound-name) a1-0) 0) name) + (let ((a0-2 (-> v1-0 0 data))) + (while (and (nonzero? (-> (the-as (pointer uint8) a1-0) 0)) (< (&- a0-2 (the-as uint (-> v1-0 0 data))) 15)) + (set! (-> a0-2 0) (-> (the-as (pointer uint8) a1-0) 0)) + (set! a0-2 (&-> a0-2 1)) + (set! a1-0 (&-> (the-as (pointer uint8) a1-0) 1)) + ) + (while (< (&- a0-2 (the-as uint (-> v1-0 0 data))) 16) + (set! (-> a0-2 0) (the-as uint 0)) + (set! a0-2 (&-> a0-2 1)) + ) + ) + ) + (-> v1-0 0) + ) + ) + +;; definition for function sound-set-volume +(defun sound-set-volume ((group sound-group) (vol float)) + "Send set-master-volume rpc." + (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) (the-as uint group)) + (set! (-> v1-0 volume) (the int (* 1024.0 vol))) + ) + 0 + ) + +;; definition for function sound-set-reverb +(defun sound-set-reverb ((reverb int) (left float) (right float) (core uint)) + "Send set-reverb rpc" + (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) core) + (set! (-> v1-0 reverb) reverb) + (set! (-> v1-0 left) (the-as uint (the int (* 32767.0 left)))) + (set! (-> v1-0 right) (the-as uint (the int (* 32767.0 right)))) + ) + 0 + ) + +;; definition for function sound-set-ear-trans +(defun sound-set-ear-trans ((ear0 vector) (ear1 vector) (cam vector) (fwd vector) (left vector) (scale float)) + "Send set-ear-trans rpc" + (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 (-> gp-0 ear-trans0) ear0) + (sound-trans-convert (-> gp-0 ear-trans1) ear1) + (sound-trans-convert (-> gp-0 cam-trans) cam) + (sound-unit-vector-convert (-> gp-0 cam-forward) fwd) + (sound-unit-vector-convert (-> gp-0 cam-left) left) + (set! (-> gp-0 cam-scale) (the int (* 65536.0 scale))) + (set! (-> gp-0 cam-inverted) (if (logtest? (-> *game-info* secrets) (game-secrets screen-flip)) + 1 + 0 + ) + ) + ) + 0 + ) + +;; definition for function sound-play-by-name +;; INFO: Used lq/sq +(defbehavior sound-play-by-name process-drawable ((name sound-name) (id sound-id) (vol int) (pitch int) (bend int) (group sound-group) (trans object)) + "Send play rpc to play a sound!" + (local-vars (sv-16 sound-group)) + (set! sv-16 group) + (let ((s4-0 trans)) + (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) id) + (set! (-> s5-0 name) name) + (set! (-> s5-0 params mask) (the-as uint 0)) + (set! (-> s5-0 params group) (the-as uint sv-16)) + (set! (-> s5-0 params volume) vol) + (set! (-> s5-0 params pitch-mod) pitch) + (set! (-> s5-0 params bend) bend) + (let ((s3-1 self)) + (when (= 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 (-> s5-0 params trans) (the-as vector s4-0)) + ) + ) + ) + id + ) + +;; definition for function sound-play-by-spec +;; INFO: Used lq/sq +(defbehavior sound-play-by-spec process-drawable ((spec sound-spec) (name sound-id) (trans vector)) + "Send play rpc to play a sound!" + (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) name) + (set! (-> s5-0 name) (-> spec sound-name)) + (set! (-> s5-0 params mask) (the-as uint (-> spec mask))) + (set! (-> s5-0 params group-and-reg) (-> spec group-and-reg)) + (set! (-> s5-0 params volume) (-> spec volume)) + (set! (-> s5-0 params pitch-mod) (-> spec pitch-mod)) + (set! (-> s5-0 params bend) (-> spec bend)) + (set! (-> s5-0 params fo-min) (-> spec fo-min)) + (set! (-> s5-0 params fo-max) (-> spec fo-max)) + (set! (-> s5-0 params fo-curve) (-> spec fo-curve)) + (set! (-> s5-0 params priority) (-> spec priority)) + (let ((s3-1 self)) + (when (= trans #t) + (if (and s3-1 (type? s3-1 process-drawable) (nonzero? (-> s3-1 root))) + (set! trans (-> s3-1 root trans)) + (set! trans (the-as vector #f)) + ) + ) + ) + (sound-trans-convert (-> s5-0 params trans) trans) + ) + ) + name + ) + +;; definition for function sound-pause +(defun sound-pause ((id sound-id)) + "Send pause-sound rpc to pause by id" + (when (nonzero? id) + (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) id) + ) + ) + 0 + ) + +;; definition for function sound-stop +(defun sound-stop ((id sound-id)) + "Send stop-sound rpc to stop by id" + (when (nonzero? id) + (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) id) + ) + ) + 0 + ) + +;; definition for function sound-continue +(defun sound-continue ((id sound-id)) + "Send continue-sound rpc to continue by id" + (when (nonzero? id) + (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) id) + ) + ) + 0 + ) + +;; definition for function sound-group-pause +(defun sound-group-pause ((group sound-group)) + "Send pause-group rpc" + (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) (the-as uint group)) + ) + 0 + ) + +;; definition for function sound-group-stop +(defun sound-group-stop ((group sound-group)) + "Send stop-group rpc" + (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) (the-as uint group)) + ) + 0 + ) + +;; definition for function sound-group-continue +(defun sound-group-continue ((group sound-group)) + "Send continue-group rpc" + (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) (the-as uint group)) + ) + 0 + ) + +;; definition for function sound-set-flava +(defun sound-set-flava ((flava uint) (excitement uint)) + "Send set-flava rpc" + (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) flava) + (set! (-> v1-0 excitement) excitement) + ) + 0 + ) + +;; definition for function sound-set-midi-reg +(defun sound-set-midi-reg ((reg int) (val int)) + "Send set-midi-reg rpc" + (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) reg) + (set! (-> v1-0 value) val) + ) + 0 + ) + +;; definition for function sound-set-fps +(defun sound-set-fps ((fps int)) + "Send set-fps rpc" + (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 fps)) + ) + 0 + ) + +;; definition for function sound-volume-off +(defun sound-volume-off () + "Adjust settings to turn all sound volume off" + (set-setting! 'music-volume 'abs 0.0 0) + (set-setting! 'sfx-volume 'abs 0.0 0) + (set-setting! 'ambient-volume 'abs 0.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 +(defmethod new ambient-sound ((allocation symbol) (type-to-make type) (spec basic) (trans vector) (lump-time float)) + "Set up ambient-sound. Can use an entity-actor (grabs from lump), sound-spec, or name as a string." + (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 (-> spec type) + ((entity-actor) + (let* ((a0-3 ((method-of-type res-lump get-property-struct) + (the-as res-lump spec) + 'effect-name + 'exact + lump-time + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (v1-2 (when a0-3 + (case (rtype-of a0-3) + ((symbol) + (symbol->string (the-as symbol a0-3)) + ) + ((string) + a0-3 + ) + (else + "unknown" + ) + ) + ) + ) + ) + (when v1-2 + (set! sv-32 (string->sound-name (the-as string v1-2))) + (set! sv-48 (res-lump-data (the-as res-lump spec) 'cycle-speed (pointer float))) + (set! sv-16 *ambient-spec*) + (set! sv-64 (new 'static 'res-tag)) + (let ((v1-9 ((method-of-type res-lump get-property-data) + (the-as res-lump spec) + 'effect-param + 'exact + lump-time + (the-as pointer #f) + (& sv-64) + *res-static-buf* + ) + ) + ) + (when v1-9 + (set! sv-52 v1-9) + (set! sv-56 (the-as int (-> sv-64 elt-count))) + ) + ) + ) + ) + ) + ((sound-spec) + (set! sv-16 (the-as sound-spec spec)) + ) + ((string) + (set! sv-32 (string->sound-name (the-as string spec))) + ) + (else + (format 0 "ERROR: ambient sound was told to play an unknown ~A.~%" spec) + ) + ) + (cond + ((or sv-16 (nonzero? sv-32)) + (let ((s5-1 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s5-1 spec) sv-16) + (set! (-> s5-1 name) sv-32) + (set! (-> s5-1 playing-id) (new-sound-id)) + (set! (-> s5-1 params) (the-as (pointer float) sv-52)) + (set! (-> s5-1 param-count) sv-56) + (set! (-> s5-1 entity) #f) + (set! (-> s5-1 sound-count) 1) + (set! (-> s5-1 volume) 1024) + (set! (-> 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! (-> s5-1 volume) (-> (the-as sound-spec sv-16) volume)) + ) + (if (logtest? (-> (the-as sound-spec sv-16) mask) (sound-mask pitch)) + (set! (-> s5-1 pitch) (-> (the-as sound-spec sv-16) pitch-mod)) + ) + ) + (cond + (sv-48 + (set! (-> s5-1 time-base) (the-as time-frame (the int (* 300.0 (-> sv-48 0))))) + (set! (-> s5-1 time-random) (the-as time-frame (the int (* 300.0 (-> sv-48 1))))) + ) + (else + (set! (-> s5-1 time-base) -1) + ) + ) + (set! (-> s5-1 trans quad) (-> trans quad)) + s5-1 + ) + ) + (else + (the-as ambient-sound 0) + ) + ) + ) + +;; definition for method 9 of type ambient-sound +;; INFO: Used lq/sq +(defmethod update! ((this ambient-sound)) + "Per-frame update of ambient sound." + (local-vars (a0-9 vector) (a0-18 vector)) + (with-pp + (if (not *ambient-sound-class*) + (return (the-as int #f)) + ) + (cond + ((-> this spec) + (when (or (< (-> this time-base) 0) (>= (current-time) (-> this play-time))) + (when (>= (-> this time-base) 0) + (set! (-> this play-time) + (+ (current-time) (-> this time-base) (rand-vu-int-count (the-as int (-> this time-random)))) + ) + (set! (-> this playing-id) (new-sound-id)) + ) + (let ((s5-1 (-> this spec))) + (when (= s5-1 *ambient-spec*) + (set! (-> s5-1 volume) (-> this volume)) + (set! (-> s5-1 pitch-mod) (-> this pitch)) + (set! (-> s5-1 bend) 0) + (set! (-> s5-1 sound-name) (-> this name)) + (set! (-> s5-1 fo-max) (-> this falloff-far)) + (set! (-> s5-1 fo-curve) (-> this falloff-mode)) + (set! (-> s5-1 mask) (sound-mask)) + (if (-> this params) + (effect-param->sound-spec s5-1 (-> this params) (-> this param-count) (the-as process-focusable pp)) + ) + ) + (case (-> s5-1 fo-curve) + ((9 11) + (set! a0-9 (ear-trans 1)) + ) + (else + (set! a0-9 (ear-trans 0)) + ) + ) + (let ((v1-29 (-> s5-1 fo-max))) + (when (and (nonzero? v1-29) (< (* 4096.0 (the float v1-29)) (vector-vector-distance a0-9 (-> this trans)))) + (when (zero? (-> this sound-state)) + (sound-stop (-> this playing-id)) + (set! (-> this sound-state) 1) + ) + (return 0) + ) + ) + (when (and *debug-effect-control* (>= (-> this time-base) 0)) + (format #t "(~5D) effect sound ~A ~G " (current-time) (-> pp name) (-> s5-1 sound-name-char)) + (format + #t + "volume: ~f pitch-mod: ~f~%" + (* 0.09765625 (the float (-> s5-1 volume))) + (* 0.000656168 (the float (-> s5-1 pitch-mod))) + ) + ) + (let ((s4-1 (-> s5-1 volume))) + (set! (-> s5-1 volume) (-> this volume)) + (set! (-> this sound-state) 0) + (set! (-> this playing-id) (sound-play-by-spec s5-1 (-> this playing-id) (-> this trans))) + (set! (-> s5-1 volume) s4-1) + ) + ) + ) + ) + ((< (-> this time-base) 0) + (let ((s5-2 (-> this falloff-far))) + (case (-> this falloff-mode) + ((9 11) + (set! a0-18 (ear-trans 1)) + ) + (else + (set! a0-18 (ear-trans 0)) + ) + ) + (when (and (nonzero? s5-2) (< (* 4096.0 (the float s5-2)) (vector-vector-distance a0-18 (-> this trans)))) + (when (zero? (-> this sound-state)) + (sound-stop (-> this playing-id)) + (set! (-> this sound-state) 1) + ) + (return 0) + ) + ) + (set! (-> this sound-state) 0) + (set! (-> this playing-id) (sound-play-by-name + (-> this name) + (-> this playing-id) + (-> this volume) + (-> this pitch) + 0 + (sound-group) + (-> this trans) + ) + ) + ) + (else + (when (>= (current-time) (-> this play-time)) + (set! (-> this sound-state) 0) + (set! (-> this playing-id) + (sound-play-by-name + (-> this name) + (new-sound-id) + (-> this volume) + (-> this pitch) + 0 + (sound-group) + (-> this trans) + ) + ) + (set! (-> this play-time) + (+ (current-time) (-> this time-base) (rand-vu-int-count (the-as int (-> this time-random)))) + ) + ) + ) + ) + 0 + ) + ) + +;; definition for method 16 of type ambient-sound +(defmethod stop! ((this ambient-sound)) + (sound-stop (-> this playing-id)) + 0 + ) + +;; definition for method 11 of type ambient-sound +;; INFO: Used lq/sq +(defmethod update-trans! ((this ambient-sound) (new-trans vector)) + "Change the trans of the sound." + (set! (-> this trans quad) (-> new-trans quad)) + 0 + ) + +;; definition for method 12 of type ambient-sound +(defmethod update-vol! ((this ambient-sound) (new-vol float)) + "Change the volume of the sound." + (set! (-> this volume) (the int (* 1024.0 new-vol))) + 0 + ) + +;; definition for method 13 of type ambient-sound +;; WARN: Return type mismatch int vs none. +(defmethod update-pitch-mod! ((this ambient-sound) (arg0 float)) + (set! (-> this pitch) (the int (* 1524.0 arg0))) + 0 + (none) + ) + +;; definition for method 14 of type ambient-sound +;; WARN: Return type mismatch int vs none. +(defmethod set-falloff-far! ((this ambient-sound) (arg0 float)) + (set! (-> this falloff-far) (the int (* 0.00024414062 arg0))) + 0 + (none) + ) + +;; definition for method 15 of type ambient-sound +;; WARN: Return type mismatch int vs none. +(defmethod set-falloff-mode! ((this ambient-sound) (arg0 int)) + (set! (-> this falloff-mode) arg0) + 0 + (none) + ) + +;; definition for method 10 of type ambient-sound +;; INFO: Used lq/sq +(defmethod change-sound! ((this ambient-sound) (new-sound sound-name)) + "Change the sound being played." + (when (not (and (= (the-as uint (-> this name)) (the-as uint new-sound)) (= (-> new-sound hi) (-> this name hi)))) + (stop! this) + (set! (-> this playing-id) (new-sound-id)) + (set! (-> this name) new-sound) + ) + 0 + ) + +;; definition for function show-iop-info +(defun show-iop-info ((dma dma-buffer)) + "Display iop info on screen." + (dotimes (s5-0 24) + (draw-string-xy + (if (zero? (-> *sound-iop-info* chinfo s5-0)) + "." + "X" + ) + dma + (+ (* 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" + ) + dma + (+ (* 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 name) + (-> *level* sound-bank 2 name) + (-> *level* sound-bank 4 name) + ) + (s5-2 *temp-string* dma 16 88 (font-color default) (font-flags shadow)) + ) + (let ((s5-3 draw-string-xy)) + (format + (clear *temp-string*) + " ~15S ~15S ~15S" + (-> *level* sound-bank 1 name) + (-> *level* sound-bank 3 name) + (-> *level* sound-bank 5 name) + ) + (s5-3 *temp-string* dma 16 104 (font-color default) (font-flags shadow)) + ) + (let ((s5-4 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-4 *temp-string* dma 16 118 (font-color default) (font-flags shadow)) + ) + 0 + ) + +;; definition for function show-iop-memory +(defun show-iop-memory ((dma dma-buffer)) + "Display iop memory stats on screen" + (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* dma 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* dma 32 64 (font-color default) (font-flags shadow)) + ) + 0 + ) + +;; definition for function ear-trans +(defun ear-trans ((mode int)) + "Get the current location of the ear. Use 1 for the settings ear-handle, or 0 for the camera." + (let ((gp-0 (the-as process-focusable #f))) + (cond + ((or (movie?) *external-cam-mode*) + (math-camera-pos) + ) + ((and (= mode 1) (begin + (let ((s5-1 (handle->process (-> *setting-control* user-current ear-handle)))) + (set! gp-0 (if (type? s5-1 process-focusable) + (the-as process-focusable s5-1) + ) + ) + ) + gp-0 + ) + ) + (get-trans gp-0 11) + ) + (else + (camera-pos) + ) + ) + ) + ) + +;; definition (debug) for function make-sqrt-table +;; WARN: Return type mismatch int vs none. +(defun-debug make-sqrt-table () + "Generate integer square-root table used in the IOP." + (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 + (none) + ) + +;; failed to figure out what this is: +(check-irx-version) + +;; failed to figure out what this is: +(sound-bank-load (static-sound-name "common") 2 10) + +;; failed to figure out what this is: +(dotimes (gp-0 3) + (let* ((v1-61 gp-0) + (s5-0 (cond + ((zero? v1-61) + 'empty0 + ) + ((= v1-61 1) + 'empty1 + ) + ((= v1-61 2) + 'empty2 + ) + ((= v1-61 3) + 'empty3 + ) + ) + ) + ) + (sound-bank-load (string->sound-name (symbol->string s5-0)) 4 10) + (set! (-> *level* sound-bank (* gp-0 2) name) s5-0) + ) + (set! (-> *level* sound-bank (* gp-0 2) mode) (the-as uint 4)) + ) + +;; definition for function loader-test-command +;; WARN: Return type mismatch int vs none. +(defun loader-test-command ((cmd sound-command) (param uint)) + "Send a command to loader by ID." + (let ((v1-1 (the-as sound-rpc-test-cmd (add-element *sound-loader-rpc*)))) + (set! (-> v1-1 command) cmd) + (set! (-> v1-1 ee-addr) (the-as pointer 0)) + (set! (-> v1-1 param0) param) + ) + (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 ((sound-pos vector) (sound-vel vector)) + "Compute pitch shift for the doppler effect. This is done assuming the listener is *target* and has *target*'s velocity." + (let ((gp-0 (new 'stack-no-clear 'inline-array 'vector 2))) + (vector-! (-> gp-0 0) (target-pos 0) sound-pos) + (if *target* + (vector-! (-> gp-0 1) sound-vel (-> *target* control transv)) + (set! (-> gp-0 1 quad) (-> sound-vel 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 +;; WARN: Return type mismatch int vs none. +(defun sound-bank-reload () + "Start a background process to unload all sound banks, then load them again." + (process-spawn-function + process + (lambda () + (let ((gp-0 (new 'static 'boxed-array :type symbol :length 0 :allocated-length 6))) + (dotimes (v1-0 6) + (set! (-> gp-0 v1-0) (-> *level* sound-bank v1-0 name)) + ) + (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 (current-time))) + (until (time-elapsed? s5-0 (seconds 1)) + (suspend) + ) + ) + (let ((a1-4 (new 'stack-no-clear 'array 'symbol 4))) + (set! (-> a1-4 2) (-> gp-0 4)) + (set! (-> a1-4 1) (-> gp-0 2)) + (set! (-> a1-4 0) (-> gp-0 0)) + (want-sound-banks *load-state* a1-4) + ) + ) + (none) + ) + :to *display-pool* + ) + 0 + (none) + ) + + + +