From c99f9a4834e4d4d206432bf0091f7386cbdd0542 Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:38:58 +0000 Subject: [PATCH] decomp `loader` (#3373) fixes `defskelgroup` being broken in jak 2 switches jak 3 to the jak 3 font (currently identical to jak 2) --- common/util/FontUtils.cpp | 30 +- decompiler/IR2/Form.cpp | 24 +- decompiler/config/jak3/all-types.gc | 167 +- decompiler/config/jak3/jak3_config.jsonc | 6 +- decompiler/config/jak3/ntsc_v1/hacks.jsonc | 4 +- .../config/jak3/ntsc_v1/label_types.jsonc | 4 +- .../jak3/ntsc_v1/stack_structures.jsonc | 3 +- .../config/jak3/ntsc_v1/type_casts.jsonc | 53 +- .../config/jak3/ntsc_v1/var_names.jsonc | 287 +- goal_src/jak3/engine/ambient/ambient-h.gc | 1 + goal_src/jak3/engine/anim/joint-mod.gc | 10 +- goal_src/jak3/engine/data/art-h.gc | 4 +- goal_src/jak3/engine/game/game-info-h.gc | 8 +- goal_src/jak3/engine/game/main-h.gc | 2 + goal_src/jak3/engine/game/settings-h.gc | 4 +- goal_src/jak3/engine/level/level-h.gc | 2 +- goal_src/jak3/engine/load/load-dgo.gc | 4 +- goal_src/jak3/engine/load/loader.gc | 2728 ++++++++++++++++ .../process-drawable/process-drawable-h.gc | 5 + goal_src/jak3/engine/sound/gsound-h.gc | 9 + goal_src/jak3/engine/sound/gsound.gc | 61 +- goal_src/jak3/engine/ui/gui-h.gc | 35 +- scripts/batch/decomp-jak3.bat | 4 + scripts/batch/decomp-jak3_pal.bat | 4 + scripts/batch/extract-jak3.bat | 6 + scripts/batch/gc3.bat | 4 + scripts/batch/gk3.bat | 4 + scripts/batch/test3-offline-and-update.bat | 6 + scripts/batch/test3-types.bat | 4 + .../reference/jak3/decompiler-macros.gc | 129 + .../jak3/engine/anim/joint-mod_REF.gc | 14 +- .../reference/jak3/engine/data/art-h_REF.gc | 4 +- .../jak3/engine/game/game-info-h_REF.gc | 8 +- .../jak3/engine/game/settings-h_REF.gc | 4 +- .../jak3/engine/level/level-h_REF.gc | 2 +- .../jak3/engine/load/load-dgo_REF.gc | 4 +- .../reference/jak3/engine/load/loader_REF.gc | 2842 +++++++++++++++++ .../reference/jak3/engine/sound/gsound_REF.gc | 65 +- 38 files changed, 6130 insertions(+), 425 deletions(-) create mode 100644 scripts/batch/decomp-jak3.bat create mode 100644 scripts/batch/decomp-jak3_pal.bat create mode 100644 scripts/batch/extract-jak3.bat create mode 100644 scripts/batch/gc3.bat create mode 100644 scripts/batch/gk3.bat create mode 100644 scripts/batch/test3-offline-and-update.bat create mode 100644 scripts/batch/test3-types.bat create mode 100644 test/decompiler/reference/jak3/engine/load/loader_REF.gc diff --git a/common/util/FontUtils.cpp b/common/util/FontUtils.cpp index 4911258d69..67620e6756 100644 --- a/common/util/FontUtils.cpp +++ b/common/util/FontUtils.cpp @@ -22,7 +22,8 @@ const std::unordered_map sTextVerEnumMap = { {"jak1-v1", GameTextVersion::JAK1_V1}, {"jak1-v2", GameTextVersion::JAK1_V2}, - {"jak2", GameTextVersion::JAK2}}; + {"jak2", GameTextVersion::JAK2}, + {"jak3", GameTextVersion::JAK3}}; const std::string& get_text_version_name(GameTextVersion version) { for (auto& [name, ver] : sTextVerEnumMap) { @@ -261,7 +262,8 @@ bool GameTextFontBank::valid_char_range(const char in) const { return ((in >= '0' && in <= '9') || (in >= 'A' && in <= 'Z') || m_passthrus->find(in) != m_passthrus->end()) && in != '\\'; - } else if (m_version == GameTextVersion::JAK2) { + } else if (m_version == GameTextVersion::JAK2 || m_version == GameTextVersion::JAK3 || + m_version == GameTextVersion::JAKX) { return ((in >= '0' && in <= '9') || (in >= 'A' && in <= 'Z') || (in >= 'a' && in <= 'z') || m_passthrus->find(in) != m_passthrus->end()) && in != '\\'; @@ -913,7 +915,9 @@ GameTextFontBank g_font_bank_jak1_v2(GameTextVersion::JAK1_V2, * GAME TEXT FONT BANK - JAK 2 * ================================ * This font is used in: - * - Jak 2 - NTSC - v1 + * - Jak II + * - Jak II: Renegade + * - ジャックXダクスター2 */ static std::unordered_set s_passthrus_jak2 = {'~', ' ', ',', '.', '-', '+', '(', ')', @@ -1904,6 +1908,21 @@ GameTextFontBank g_font_bank_jak2(GameTextVersion::JAK2, &s_replace_info_jak2, &s_passthrus_jak2); +/*! + * ================================ + * GAME TEXT FONT BANK - JAK 3 + * ================================ + * This font is used in: + * - Jak 3 + */ + +// TODO cyrillic + +GameTextFontBank g_font_bank_jak3(GameTextVersion::JAK3, + &s_encode_info_jak2, + &s_replace_info_jak2, + &s_passthrus_jak2); + /*! * ======================== * GAME TEXT FONT BANK LIST @@ -1914,7 +1933,8 @@ GameTextFontBank g_font_bank_jak2(GameTextVersion::JAK2, std::map g_font_banks = { {GameTextVersion::JAK1_V1, &g_font_bank_jak1_v1}, {GameTextVersion::JAK1_V2, &g_font_bank_jak1_v2}, - {GameTextVersion::JAK2, &g_font_bank_jak2}}; + {GameTextVersion::JAK2, &g_font_bank_jak2}, + {GameTextVersion::JAK3, &g_font_bank_jak3}}; const GameTextFontBank* get_font_bank(GameTextVersion version) { return g_font_banks.at(version); @@ -1927,6 +1947,8 @@ const GameTextFontBank* get_font_bank_from_game_version(GameVersion version) { return get_font_bank(GameTextVersion::JAK1_V2); case GameVersion::Jak2: return get_font_bank(GameTextVersion::JAK2); + case GameVersion::Jak3: + return get_font_bank(GameTextVersion::JAK3); default: ASSERT_MSG(false, "Unsupported game for get_font_bank_from_game_version"); } diff --git a/decompiler/IR2/Form.cpp b/decompiler/IR2/Form.cpp index ec49738b11..2bccd03a86 100644 --- a/decompiler/IR2/Form.cpp +++ b/decompiler/IR2/Form.cpp @@ -3269,18 +3269,20 @@ goos::Object DefskelgroupElement::to_form_internal(const Env& env) const { forms.push_back( pretty_print::to_symbol(fmt::format(":light-index {}", m_static_info.light_index))); } - if (m_static_info.global_effects != 0) { - forms.push_back( - pretty_print::to_symbol(fmt::format(":global-effects {}", m_static_info.global_effects))); - } - if (!m_static_info.clothing.empty()) { - std::vector cloth_list; - forms.push_back(pretty_print::to_symbol(":clothing")); - for (const auto& p : m_static_info.clothing) { - auto macro = p.to_list(m_static_info.art_group_name + "-ag", env); - cloth_list.push_back(macro); + if (env.version != GameVersion::Jak2) { + if (m_static_info.global_effects != 0) { + forms.push_back(pretty_print::to_symbol( + fmt::format(":global-effects {}", m_static_info.global_effects))); + } + if (!m_static_info.clothing.empty()) { + std::vector cloth_list; + forms.push_back(pretty_print::to_symbol(":clothing")); + for (const auto& p : m_static_info.clothing) { + auto macro = p.to_list(m_static_info.art_group_name + "-ag", env); + cloth_list.push_back(macro); + } + forms.push_back(pretty_print::build_list(cloth_list)); } - forms.push_back(pretty_print::build_list(cloth_list)); } } diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index 830e58ceb9..da229e48b9 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -2616,6 +2616,14 @@ (defenum sound-group :bitfield #t :type uint8 + (sfx) + (music) + (dialog) ;; same as jak 1 dialog + (sog3) + (ambient) + (dialog2) ;; more dialog + (sog6) + (sog7) ) (defenum sound-mask @@ -2644,6 +2652,7 @@ (ss1 1) ;; id-is-playing (ss4 4) ;; is-playing (ss6 6) ;; id-is-playing + (ss9 9) ) (deftype sound-stream-name (structure) @@ -7527,7 +7536,7 @@ (level-method-18 () none) ;; 18 ;; (load-begin (_type_) _type_) (level-method-19 () none) ;; 19 ;; (login-begin (_type_) _type_) (level-method-20 () none) ;; 20 ;; (debug-print-region-splitbox (_type_ vector object) none) - (level-method-21 () none) ;; 21 ;; (get-art-group-by-name (_type_ string) art-group) + (get-art-group-by-name (_type_ string) art-group) ;; 21 (level-method-22 () none) ;; 22 ;; (level-method-22 (_type_ symbol) int) (level-method-23 () none) ;; 23 ;; (lookup-text (_type_ text-id symbol) string) (level-method-24 () none) ;; 24 ;; (level-method-24 () none) @@ -10460,8 +10469,8 @@ (setting-control-method-14 (_type_ object) connectable) ;; 14 (remove-setting-by-arg0 (_type_ object) none) ;; 15 (set-setting-by-param (_type_ symbol object object object) connection) ;; 16 - (setting-control-method-17 () none) ;; 17 ;; (apply-settings (_type_) user-setting-data) - (setting-control-method-18 () none) ;; 18 ;; (update (_type_) user-setting-data) + (apply-settings (_type_) user-setting-data) ;; 17 + (update (_type_) user-setting-data) ;; 18 (setting-control-method-19 () none) ;; 19 ) ) @@ -14179,8 +14188,8 @@ :flag-assert #x1000000020 (:methods (relocate (_type_ kheap (pointer uint8)) none :replace) ;; 7 - (link-art-to-master (_type_) none) - (unknown-1 () none) + (link-art-to-master (_type_) art-group) + (unlink-art-to-master (_type_) int) ) ) @@ -15882,10 +15891,10 @@ (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) (load-state-method-16 () none) ;; 16 ;; (want-force-inside (_type_ symbol symbol) none) - (load-state-method-17 () none) ;; 17 ;; (execute-commands-up-to (_type_ float) none) - (load-state-method-18 () none) ;; 18 ;; (backup-load-state-and-set-cmds (_type_ pair) int) - (load-state-method-19 () none) ;; 19 ;; (restore-load-state-and-cleanup (_type_) int) - (load-state-method-20 () none) ;; 20 ;; (restore-load-state (_type_) int) + (execute-commands-up-to (_type_ float) none) ;; 17 + (backup-load-state-and-set-cmds (_type_ pair) int) ;; 18 + (restore-load-state-and-cleanup (_type_) int) ;; 19 + (restore-load-state (_type_) int) ;; 20 (load-state-method-21 () none) ;; 21 ;; (add-borrow-levels (_type_) none) ) ) @@ -16322,6 +16331,7 @@ (fo-curve 2) (fo-min 3) (fo-max 4) + (volume 5) ) ;; ---gui-h:gui-connection-flags @@ -16348,11 +16358,6 @@ ;; field param1 uses ~A with a signed load. field param2 uses ~A with a signed load. field param3 uses ~A with a signed load. ) -;; (deftype gui-control (basic) -;; () -;; :flag-assert #x1a00000d30 -;; ) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ambient-h ;; @@ -27498,7 +27503,7 @@ (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. + (stream-id-signed int32 4 :offset 496) ;; guessed by decompiler (music-register uint8 17 :offset 512) ;; guessed by decompiler (music-excite int8 :offset 528) (ramdisk-name uint8 16 :offset-assert 529) @@ -29519,87 +29524,101 @@ ;; loader ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++loader:spooler-flags +(defenum spooler-flags + :bitfield #t + :type uint32 + (blackout-on-stall) + ) +;; ---loader:spooler-flags + (deftype spooler-block (basic) ((anim spool-anim :offset-assert 4) ;; guessed by decompiler (idle art-joint-anim :offset-assert 8) ;; guessed by decompiler (exit art-joint-anim :offset-assert 12) ;; guessed by decompiler (break-func (function process-drawable object) :offset-assert 16) ;; guessed by decompiler - (flags uint32 :offset-assert 20) + (flags spooler-flags :offset-assert 20) (part int32 :offset-assert 24) (part-audio-start float :offset-assert 28) (old-status uint16 :offset-assert 32) (old-pos int32 :offset-assert 36) - (good-time uint64 :offset-assert 40) ;; time-frame - (old-time uint64 :offset-assert 48) ;; time-frame + (good-time time-frame :offset-assert 40) ;; time-frame + (old-time time-frame :offset-assert 48) ;; time-frame (good-count int32 :offset-assert 56) (sid sound-id :offset-assert 60) ;; guessed by decompiler - (real-start-time uint64 :offset-assert 64) ;; time-frame + (real-start-time time-frame :offset-assert 64) ;; time-frame (paused? symbol :offset-assert 72) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x4c :flag-assert #x90000004c ) -|# -#| (deftype load-dir (basic) - ((level basic :offset-assert 4) - (allocated-length uint32 :offset-assert 8) + ;; copied from jak1. + ((lev level :offset-assert 4) + (string-array (array string) :offset-assert 8) ;; these are the names + (data-array (array basic) :score -50 :offset-assert 12) ;; this is the file data. ) :method-count-assert 11 :size-assert #x10 :flag-assert #xb00000010 ;; Failed to read some fields. (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type int level) _type_) - (load-dir-method-9 () none) ;; 9 ;; (load-to-heap-by-name (_type_ string symbol kheap int) art-group) - (load-dir-method-10 () none) ;; 10 ;; (set-loaded-art (_type_ art-group) art-group) + (new (symbol type int level) _type_) ;; 0 + (load-to-heap-by-name (_type_ string symbol kheap int) art-group) ;; 9 + (set-loaded-art (_type_ art-group) art-group) ;; 10 ) ) -|# -#| (deftype gui-control (basic) ((engine engine :offset-assert 4) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (update-time time-frame :offset-assert 8) + (connections gui-connection 32 :inline :offset-assert 16) + (spool-connections gui-connection 4 :inline :offset-assert 1552) + (ids sound-id 96 :offset-assert 1744) + (times time-frame 96 :offset-assert 2128) + (cmd pair 96 :offset-assert 2896) + (group sound-group 96 :offset-assert 3280) ) :method-count-assert 26 :size-assert #xd30 :flag-assert #x1a00000d30 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type int) _type_) - (gui-control-method-9 () none) ;; 9 ;; (add-process (_type_ process gui-channel gui-action string float time-frame) sound-id) - (gui-control-method-10 () none) ;; 10 ;; (remove-process (_type_ process gui-channel) none) - (gui-control-method-11 () none) ;; 11 ;; (stop-str (_type_ gui-connection) int) - (gui-control-method-12 () none) ;; 12 ;; (gui-control-method-12 (_type_ process gui-channel gui-action string int float sound-id) sound-id) - (gui-control-method-13 () none) ;; 13 ;; (update (_type_ symbol) int) - (gui-control-method-14 () none) ;; 14 ;; (lookup-gui-connection-id (_type_ string gui-channel gui-action) sound-id) - (gui-control-method-15 () none) ;; 15 ;; (lookup-gui-connection (_type_ process gui-channel string sound-id) gui-connection) - (gui-control-method-16 () none) ;; 16 ;; (set-action! (_type_ gui-action sound-id gui-channel gui-action string (function gui-connection symbol) process) int) - (gui-control-method-17 () none) ;; 17 ;; (get-status (_type_ sound-id) gui-status) - (gui-control-method-18 () none) ;; 18 ;; (gui-control-method-18 (_type_ gui-channel) symbol) - (gui-control-method-19 () none) ;; 19 ;; (handle-command-list (_type_ gui-channel gui-connection) symbol) - (gui-control-method-20 () none) ;; 20 ;; (set-falloff! (_type_ sound-id symbol int int int) gui-connection) - (gui-control-method-21 () none) ;; 21 ;; (gui-control-method-21 (_type_ gui-connection vector) int) - (gui-control-method-22 () none) ;; 22 ;; (gui-control-method-22 (_type_ gui-connection process symbol) none) - (gui-control-method-23 () none) ;; 23 ;; (handle-command (_type_ gui-channel gui-channel symbol gui-connection) symbol) - (gui-control-method-24 () none) ;; 24 ;; (channel-id-set! (_type_ gui-connection sound-id) int) - (gui-control-method-25 () none) ;; 25 + (new (symbol type int) _type_) ;; 0 + (add-process (_type_ process gui-channel gui-action string float time-frame) sound-id) ;; 9 + (remove-process (_type_ process gui-channel) int) ;; 10 + (stop-str (_type_ gui-connection) int) ;; 11 + (gui-control-method-12 (_type_ process gui-channel gui-action string int float sound-id) sound-id) ;; 12 + (update (_type_ symbol) int) ;; 13 + (lookup-gui-connection-id (_type_ string gui-channel gui-action) sound-id) ;; 14 + (lookup-gui-connection (_type_ process gui-channel string sound-id) gui-connection) ;; 15 + (set-action! (_type_ gui-action sound-id gui-channel gui-action string (function gui-connection symbol) process) int) ;; 16 + (get-status (_type_ sound-id) gui-status) ;; 17 ;; (get-status (_type_ sound-id) gui-status) + (gui-control-method-18 (_type_ gui-channel) symbol) ;; 18 + (handle-command-list (_type_ gui-channel gui-connection) symbol) ;; 19 + (sound-params-set! (_type_ sound-id symbol int int int float) gui-connection) ;; 20 + (gui-control-method-21 (_type_ gui-connection) int) ;; 21 + (gui-control-method-22 (_type_ gui-connection vector) int) ;; 22 + (update-connection (_type_ gui-connection process symbol) none) ;; 23 + (handle-command (_type_ gui-channel gui-channel symbol gui-connection) symbol) ;; 24 + (channel-id-set! (_type_ gui-connection sound-id) int) ;; 25 ) ) -|# -;; (define-extern drawable-load function) ;; (function drawable kheap drawable) -;; (define-extern art-load function) ;; (function string kheap art) -;; (define-extern art-group-load-check function) ;; (function string kheap int art-group) +(define-extern drawable-load (function drawable kheap drawable)) +(define-extern art-load (function string kheap art)) +(define-extern art-group-load-check (function string kheap int art-group)) (define-extern external-art-buffer-init (function external-art-buffer int)) -;; (define-extern *preload-spool-anims* object) ;; symbol -;; (define-extern ja-play-spooled-anim function) ;; (function spool-anim art-joint-anim art-joint-anim (function process-drawable symbol) int :behavior process-drawable) -;; (define-extern ja-abort-spooled-anim function) ;; (function spool-anim art-joint-anim int int :behavior process-drawable) -;; (define-extern *gui-control* object) ;; gui-control -;; (define-extern *art-control* object) ;; external-art-control +(define-extern *preload-spool-anims* symbol) +(define-extern ja-play-spooled-anim (function spool-anim art-joint-anim art-joint-anim (function process-drawable symbol) spooler-flags int :behavior process-drawable)) +(define-extern ja-abort-spooled-anim (function spool-anim art-joint-anim int int :behavior process-drawable)) +(define-extern *gui-control* gui-control) +(define-extern *art-control* external-art-control) +(define-extern *stack-top* pointer) +(define-extern *kernel-sp* pointer) +(define-extern loado (function string kheap object)) +(define-extern link (function pointer pointer int kheap int pointer)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; game-info ;; @@ -31905,20 +31924,20 @@ ;; (define-extern process-drawable-error-print function) ;; (define-extern skeleton-group->draw-control function) ;; (function process-drawable skeleton-group (pointer cspace-array) draw-control) ;; (define-extern ja-group-in-array? function) -;; (define-extern ja-done? function) ;; (function int symbol :behavior process-drawable) -;; (define-extern ja-min? function) ;; (function int symbol :behavior process-drawable) -;; (define-extern ja-max? function) ;; (function int symbol :behavior process-drawable) -;; (define-extern ja-num-frames function) ;; (function int int :behavior process-drawable) -;; (define-extern ja-frame-num function) ;; (function int float :behavior process-drawable) -;; (define-extern ja-aframe-num function) ;; (function int float :behavior process-drawable) -;; (define-extern ja-aframe function) ;; (function float int float :behavior process-drawable) -;; (define-extern ja-speed function) ;; (function int float :behavior process-drawable) -;; (define-extern ja-step function) ;; (function int float :behavior process-drawable) +(define-extern ja-done? (function int symbol :behavior process-drawable)) +(define-extern ja-min? (function int symbol :behavior process-drawable)) +(define-extern ja-max? (function int symbol :behavior process-drawable)) +(define-extern ja-num-frames (function int int :behavior process-drawable)) +(define-extern ja-frame-num (function int float :behavior process-drawable)) +(define-extern ja-aframe-num (function int float :behavior process-drawable)) +(define-extern ja-aframe (function float int float :behavior process-drawable)) +(define-extern ja-speed (function int float :behavior process-drawable)) +(define-extern ja-step (function int float :behavior process-drawable)) ;; (define-extern ja-rate function) ;; (define-extern ja-linear-vel function) -;; (define-extern ja-channel-set! function) ;; (function int int :behavior process-drawable) -;; (define-extern ja-channel-push! function) ;; (function int time-frame int :behavior process-drawable) -;; (define-extern ja-channel-float! function) ;; (function art-joint-anim float float float joint-control-channel :behavior process-drawable) +(define-extern ja-channel-set! (function int int :behavior process-drawable)) +(define-extern ja-channel-push! (function int time-frame int :behavior process-drawable)) +(define-extern ja-channel-float! (function art-joint-anim float float float joint-control-channel :behavior process-drawable)) (define-extern joint-control-reset! (function joint-control joint-control-channel none :behavior process-drawable)) ;; (define-extern ja-group-size function) ;; (function int :behavior process-drawable) ;; (define-extern ja-eval function) ;; (function int :behavior process-drawable) @@ -32091,7 +32110,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-extern can-display-query? (function process string float symbol)) -(define-extern talker-surpress! (function none)) +(define-extern talker-surpress! (function int)) (define-extern talker-displayed? (function symbol)) (define-extern kill-current-talker (function symbol pair symbol none)) (define-extern string->talker-speech (function string talker-speech-class)) @@ -35743,10 +35762,10 @@ ;; main ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern set-letterbox-frames function) ;; (function time-frame none) -;; (define-extern letterbox function) ;; (function none) -;; (define-extern set-blackout-frames function) ;; (function time-frame none) -;; (define-extern blackout function) ;; (function none) +(define-extern set-letterbox-frames (function time-frame none)) +(define-extern letterbox (function none)) +(define-extern set-blackout-frames (function time-frame none)) +(define-extern blackout (function none)) ;; (define-extern add-blackout function) (define-extern paused? (function symbol)) (define-extern movie? (function symbol)) diff --git a/decompiler/config/jak3/jak3_config.jsonc b/decompiler/config/jak3/jak3_config.jsonc index 5d1212c268..bc41146a9b 100644 --- a/decompiler/config/jak3/jak3_config.jsonc +++ b/decompiler/config/jak3/jak3_config.jsonc @@ -1,6 +1,6 @@ { "game_version": 3, - "text_version": 20, + "text_version": 30, "game_name": "jak3", "expected_elf_name": "SCUS_973.30", @@ -8,7 +8,7 @@ // if you want to filter to only some object names. // it will make the decompiler much faster. "allowed_objects": [], - "banned_objects": [], + "banned_objects": ["collide-shape", "spatial-hash", "entity"], //////////////////////////// // CODE ANALYSIS OPTIONS @@ -35,7 +35,7 @@ // unpack textures to assets folder "process_tpages": true, // unpack game text to assets folder - "process_game_text": false, + "process_game_text": true, // unpack game count to assets folder "process_game_count": false, // write goal imports for art groups diff --git a/decompiler/config/jak3/ntsc_v1/hacks.jsonc b/decompiler/config/jak3/ntsc_v1/hacks.jsonc index 9bb04c4ef5..6795eb4644 100644 --- a/decompiler/config/jak3/ntsc_v1/hacks.jsonc +++ b/decompiler/config/jak3/ntsc_v1/hacks.jsonc @@ -257,7 +257,9 @@ "bsp-camera-asm": [1, 2, 3, 4, 6, 7], "level-remap-texture": [2, 3, 4, 5, 6], "start-perf-stat-collection": [26], - "end-perf-stat-collection": [0] + "end-perf-stat-collection": [0], + + "(method 23 gui-control)": [10, 46, 50, 58, 81, 90, 101] }, // Sometimes the game might use format strings that are fetched dynamically, diff --git a/decompiler/config/jak3/ntsc_v1/label_types.jsonc b/decompiler/config/jak3/ntsc_v1/label_types.jsonc index 3d877a83cf..3b496d2afd 100644 --- a/decompiler/config/jak3/ntsc_v1/label_types.jsonc +++ b/decompiler/config/jak3/ntsc_v1/label_types.jsonc @@ -66,7 +66,5 @@ ["L303", "cloth-params"], ["L296", "cloth-params"] ], - "joint-mod": [ - ["L212", "(inline-array vector)", 3] - ] + "joint-mod": [["L212", "(inline-array vector)", 3]] } diff --git a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc index 1b286080cc..cc37db379f 100644 --- a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc +++ b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc @@ -95,5 +95,6 @@ "joint-mod-joint-set-world-handler": [ [32, "vector"], [48, "vector"] - ] + ], + "(method 13 gui-control)": [[16, ["array", "sound-id", 4]]] } diff --git a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc index 679a2d3d87..b064d461a2 100644 --- a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc @@ -322,9 +322,6 @@ [15, "gp", "collide-shape-moving"], [35, "gp", "collide-shape-moving"] ], - "joint-mod-rotate-world-callback": [ - [[0, 24], "s3", "joint-mod-rotate-world"] - ], "joint-mod-set-local-callback": [[[1, 24], "v1", "joint-mod-set-local"]], "joint-mod-add-local-callback": [[[1, 37], "s4", "joint-mod-add-local"]], "joint-mod-set-world-callback": [[[1, 4], "v1", "joint-mod-set-local"]], @@ -426,7 +423,6 @@ ], "ear-trans": [[32, "s5", "process-focusable"]], "loader-test-command": [[[5, 10], "v1", "sound-rpc-test-cmd"]], - "(method 11 connection)": [[5, "a1", "pointer"]], "update-light-hash": [ [[234, 239], "a1", "light-hash-bucket"], [[207, 211], "a0", "light-hash-bucket"] @@ -529,7 +525,6 @@ "texture-usage-init": [[27, "a1", "vector"]], "(method 9 art)": [[9, "v1", "pointer"]], "(code pov-camera-start-playing pov-camera)": [[24, "v0", "joint"]], - "(method 9 art)": [[9, "v1", "pointer"]], "(method 9 art-mesh-geo)": [ [20, "s4", "(pointer int16)"], [[14, 19], "a0", "drawable"], @@ -649,5 +644,51 @@ [[78, 79], "a1", "drawable-tree-instance-tie"], [123, "a1", "drawable-tree-instance-shrub"], [[129, 133], "a2", "(inline-array prototype-bucket-shrub)"] - ] + ], + "drawable-load": [[16, "v0", "drawable"]], + "art-load": [[7, "v0", "art"]], + "art-group-load-check": [[21, "v0", "art-group"]], + "(method 9 external-art-control)": [ + [[170, 191], "s4", "external-art-buffer"] + ], + "(method 11 external-art-control)": [[19, "s5", "process-drawable"]], + "(method 15 gui-control)": [ + [13, "s1", "gui-connection"], + [36, "s1", "gui-connection"], + [43, "s1", "gui-connection"], + [8, "s1", "gui-connection"] + ], + "(method 14 gui-control)": [[[7, 41], "s2", "gui-connection"]], + "(method 13 gui-control)": [ + [64, "s3", "gui-connection"], + [71, "s3", "gui-connection"] + ], + "(method 17 gui-control)": [ + [[45, 262], "gp", "gui-connection"], + [13, "v1", "gui-connection"] + ], + "(method 16 gui-control)": [[[19, 118], "s1", "gui-connection"]], + "(method 9 gui-control)": [ + [131, "v1", "gui-connection"], + [17, "v1", "gui-connection"], + [24, "v1", "gui-connection"], + [[115, 125], "v1", "gui-connection"], + [129, "v1", "gui-connection"], + [127, "a0", "gui-connection"] + ], + "(method 10 gui-control)": [[[9, 32], "s3", "gui-connection"]], + "(method 12 gui-control)": [ + [128, "v1", "gui-connection"], + [177, "v1", "process-drawable"], + [214, "v1", "gui-connection"] + ], + "(method 22 gui-control)": [[54, "v1", "process-drawable"]], + "(method 21 gui-control)": [ + [28, "v1", "process-drawable"], + [31, "v1", "process-drawable"], + [45, "s4", "process-drawable"], + [48, "s4", "process-drawable"], + [5, "v0", "sound-rpc-set-param"] + ], + "(method 23 gui-control)": [[285, "v0", "sound-rpc-set-param"]] } diff --git a/decompiler/config/jak3/ntsc_v1/var_names.jsonc b/decompiler/config/jak3/ntsc_v1/var_names.jsonc index 7c34c1ec64..992d178360 100644 --- a/decompiler/config/jak3/ntsc_v1/var_names.jsonc +++ b/decompiler/config/jak3/ntsc_v1/var_names.jsonc @@ -889,7 +889,7 @@ "args": ["maxlen-out"] }, "str-play-async": { - "args": ["name", "id", "chunk-idx", "group"] + "args": ["name", "id", "volume", "group"] }, "str-play-stop": { "args": ["name", "id"] @@ -1174,8 +1174,8 @@ "vars": { "v0-0": ["this", "align-control"] } - }, -"flatten-joint-control-to-spr": { + }, + "flatten-joint-control-to-spr": { "args": ["jc"], "vars": { "s5-0": "chan-count", @@ -1201,13 +1201,13 @@ "s0-0": "last-frame", "v1-20": "upload" } - }, - "matrix-from-joint-anim-frame": { - "args": ["jacc", "joint-idx", "frame-idx"], - "vars": { - "v1-1": "fixed-matrix", - "v0-0": "frame-matrix" - } + }, + "matrix-from-joint-anim-frame": { + "args": ["jacc", "joint-idx", "frame-idx"], + "vars": { + "v1-1": "fixed-matrix", + "v0-0": "frame-matrix" + } }, "matrix-from-control-channel!": { "args": ["dest-mat", "requested-joint", "chan"], @@ -1222,60 +1222,29 @@ } }, "joint-anim-login": { - "args": [ - "jad" - ] + "args": ["jad"] }, "joint-anim-inspect-elt": { - "args": [ - "ja", - "frame" - ] + "args": ["ja", "frame"] }, "jacc-mem-usage": { - "args": [ - "jacc", - "mem-block", - "flags" - ] + "args": ["jacc", "mem-block", "flags"] }, "joint-control-cleanup": { - "args": [ - "jc", - "heap", - "ja" - ] + "args": ["jc", "heap", "ja"] }, "joint-control-channel-eval": { - "args": [ - "jcc" - ] + "args": ["jcc"] }, "joint-control-channel-eval!": { - "args": [ - "jcc", - "num-func" - ] + "args": ["jcc", "num-func"] }, "joint-control-channel-group-eval!": { - "args": [ - "jcc", - "ja", - "num-func" - ] - }, - "joint-control-channel-group!": { - // "args": [ - // "jcc", - // "ja", - // "num-func" - // ] + "args": ["jcc", "ja", "num-func"] }, + "joint-control-channel-group!": {}, "joint-control-copy!": { - "args": [ - "dst", - "src" - ] + "args": ["dst", "src"] }, "joint-control-remap!": { "args": [ @@ -1288,146 +1257,70 @@ ] }, "matrix-from-control-pair!": { - "args": [ - "matrix-to-modify", - "jcc", - "jnt", - "active-frame-interp" - ] + "args": ["matrix-to-modify", "jcc", "jnt", "active-frame-interp"] }, "matrix-from-control!": { - "args": [ - "mat-stack", - "jnt", - "jc", - "mode" - ] + "args": ["mat-stack", "jnt", "jc", "mode"] }, "cspace<-cspace!": { - "args": [ - "dst", - "src" - ] + "args": ["dst", "src"] }, "cspace<-cspace-normalized!": { - "args": [ - "dst", - "src" - ] + "args": ["dst", "src"] }, "cspace<-parent-joint!": { - "args": [ - "dst", - "proc", - "parent-idx" - ] + "args": ["dst", "proc", "parent-idx"] }, "cspace<-rot-yxy!": { - "args": [ - "dst", - "src" - ] + "args": ["dst", "src"] }, "cspace<-transform-yxy!": { - "args": [ - "dst", - "src" - ] + "args": ["dst", "src"] }, "cspace<-transformq!": { - "args": [ - "dst", - "src" - ] + "args": ["dst", "src"] }, "cspace<-transformq+trans!": { - "args": [ - "dst", - "src", - "extra-trans" - ] + "args": ["dst", "src", "extra-trans"] }, "cspace<-transformq+world-trans!": { - "args": [ - "dst", - "src", - "extra-trans" - ] + "args": ["dst", "src", "extra-trans"] }, "cspace<-transformq+rot-offset!": { - "args": [ - "dst", - "src", - "extra-rot" - ] + "args": ["dst", "src", "extra-rot"] }, "cspace-calc-total-matrix!": { - "args": [ - "csp", - "dst" - ] + "args": ["csp", "dst"] }, "cspace<-matrix-no-push-joint!": { - "args": [ - "dst", - "jc" - ] + "args": ["dst", "jc"] }, "cspace<-matrix-joint!": { - "args": [ - "dst", - "src" - ] + "args": ["dst", "src"] }, "cspace<-parented-matrix-joint!": { - "args": [ - "dst", - "joint-mat" - ] + "args": ["dst", "joint-mat"] }, "cspace<-parented-matrix-mirror!": { - "args": [ - "dst", - "joint-mat" - ] + "args": ["dst", "joint-mat"] }, "cspace<-parented-matrix-joint-flip-z!": { - "args": [ - "dst", - "joint-mat" - ] + "args": ["dst", "joint-mat"] }, "cspace<-matrix-joint-flip-z!": { - "args": [ - "dst", - "src" - ] + "args": ["dst", "src"] }, "cspace<-parented-transformq-joint!": { - "args": [ - "dst", - "joint-transformq" - ] + "args": ["dst", "joint-transformq"] }, "cspace<-parented-transformq-joint-flip-z!": { - "args": [ - "dst", - "joint-transformq" - ] + "args": ["dst", "joint-transformq"] }, "create-interpolated-joint-animation-frame": { - "args": [ - "dst", - "num-joints", - "jc" - ] + "args": ["dst", "num-joints", "jc"] }, "create-interpolated2-joint-animation-frame": { - "args": [ - "dst", - "num-joints", - "jc" - ] + "args": ["dst", "num-joints", "jc"] }, "(method 37 cloth-system)": { "args": ["this", "command"], @@ -1488,104 +1381,56 @@ } }, "(method 9 joint-mod-polar-look-at)": { - "args": [ - "this", - "proc", - "joint-id" - ] + "args": ["this", "proc", "joint-id"] }, "(method 10 joint-mod-polar-look-at)": { - "args": [ - "this", - "pos" - ] + "args": ["this", "pos"] }, "(method 11 joint-mod-polar-look-at)": { - "args": [ - "this", - "other", - "pos" - ] + "args": ["this", "other", "pos"] }, "(method 12 joint-mod-polar-look-at)": { - "args": [ - "this", - "duration", - "final-val", - "restart-if-in-progress" - ] + "args": ["this", "duration", "final-val", "restart-if-in-progress"] }, "(method 13 joint-mod-polar-look-at)": { - "args": [ - "this", - "duration", - "restart-if-in-progress" - ] + "args": ["this", "duration", "restart-if-in-progress"] }, "(method 0 joint-mod-ik)": { - "args": [ - "allocation", - "type-to-make", - "proc", - "joint-id", - "hand-dist" - ] + "args": ["allocation", "type-to-make", "proc", "joint-id", "hand-dist"] }, "(method 9 joint-mod-ik)": { - "args": [ - "this", - "pos" - ] + "args": ["this", "pos"] }, "(method 10 joint-mod-ik)": { - "args": [ - "this", - "enable" - ] + "args": ["this", "enable"] }, "(method 0 joint-mod)": { - "args": [ - "allocation", - "type-to-make", - "mode", - "proc", - "base-joint-id" - ] + "args": ["allocation", "type-to-make", "mode", "proc", "base-joint-id"] }, "(method 9 joint-mod)": { - "args": [ - "this", - "mode" - ] + "args": ["this", "mode"] }, "(method 10 joint-mod)": { - "args": [ - "this", - "pos" - ] + "args": ["this", "pos"] }, "(method 11 joint-mod)": { - "args": [ - "this", - "target", - "mode", - "proc" - ] + "args": ["this", "target", "mode", "proc"] }, "(method 13 joint-mod)": { - "args": [ - "thix", - "x", - "y", - "z" - ] + "args": ["this", "x", "y", "z"] }, "(method 14 joint-mod)": { - "args": [ - "this", - "trans", - "quat", - "scale" - ] + "args": ["this", "trans", "quat", "scale"] + }, + "(method 13 gui-control)": { + "vars": { + "s3-0": ["con-i-0", "gui-connection"], + "a0-33": ["con-i-1", "gui-connection"] + } + }, + "(method 10 gui-control)": { + "vars": { + "s3-0": ["con-i-0", "gui-connection"] + } } } diff --git a/goal_src/jak3/engine/ambient/ambient-h.gc b/goal_src/jak3/engine/ambient/ambient-h.gc index f982ebb2d0..5a8692f739 100644 --- a/goal_src/jak3/engine/ambient/ambient-h.gc +++ b/goal_src/jak3/engine/ambient/ambient-h.gc @@ -21,6 +21,7 @@ ) ;; ---talker-flags +(define-extern talker-surpress! (function int)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/anim/joint-mod.gc b/goal_src/jak3/engine/anim/joint-mod.gc index 054fae950f..f5900d65df 100644 --- a/goal_src/jak3/engine/anim/joint-mod.gc +++ b/goal_src/jak3/engine/anim/joint-mod.gc @@ -663,18 +663,18 @@ (none) ) -(defmethod twist-set! ((thix joint-mod) (x float) (y float) (z float)) +(defmethod twist-set! ((this joint-mod) (x float) (y float) (z float)) "Set twist x,y,z. A value of #f will skip the set." (if x - (set! (-> thix twist x) x) + (set! (-> this twist x) x) ) (if y - (set! (-> thix twist y) y) + (set! (-> this twist y) y) ) (if z - (set! (-> thix twist z) z) + (set! (-> this twist z) z) ) - (-> thix twist) + (-> this twist) ) (defmethod trs-set! ((this joint-mod) (trans vector) (quat quaternion) (scale vector)) diff --git a/goal_src/jak3/engine/data/art-h.gc b/goal_src/jak3/engine/data/art-h.gc index 0712c1cf21..1fdf4ff02c 100644 --- a/goal_src/jak3/engine/data/art-h.gc +++ b/goal_src/jak3/engine/data/art-h.gc @@ -200,8 +200,8 @@ actor, like the mesh, animations, shadow mesh, skeleton, etc." ) (:methods (relocate (_type_ kheap (pointer uint8)) none :replace) - (link-art-to-master (_type_) none) - (unknown-1 () none) + (link-art-to-master (_type_) art-group) + (unlink-art-to-master (_type_) int) ) ) diff --git a/goal_src/jak3/engine/game/game-info-h.gc b/goal_src/jak3/engine/game/game-info-h.gc index b0c81974c8..74f0f9b7e6 100644 --- a/goal_src/jak3/engine/game/game-info-h.gc +++ b/goal_src/jak3/engine/game/game-info-h.gc @@ -244,10 +244,10 @@ (load-state-method-14 () none) (load-state-method-15 () none) (load-state-method-16 () none) - (load-state-method-17 () none) - (load-state-method-18 () none) - (load-state-method-19 () none) - (load-state-method-20 () none) + (execute-commands-up-to (_type_ float) none) + (backup-load-state-and-set-cmds (_type_ pair) int) + (restore-load-state-and-cleanup (_type_) int) + (restore-load-state (_type_) int) (load-state-method-21 () none) ) ) diff --git a/goal_src/jak3/engine/game/main-h.gc b/goal_src/jak3/engine/game/main-h.gc index 0f2b42c6b7..2532b8f0b3 100644 --- a/goal_src/jak3/engine/game/main-h.gc +++ b/goal_src/jak3/engine/game/main-h.gc @@ -7,6 +7,8 @@ (declare-type debug-menu-context basic) (define-extern movie? (function symbol)) +(define-extern paused? (function symbol)) +(define-extern set-blackout-frames (function time-frame none)) ;; +++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 040455c509..1ac6f5da8e 100644 --- a/goal_src/jak3/engine/game/settings-h.gc +++ b/goal_src/jak3/engine/game/settings-h.gc @@ -447,8 +447,8 @@ (setting-control-method-14 (_type_ object) connectable) (remove-setting-by-arg0 (_type_ object) none) (set-setting-by-param (_type_ symbol object object object) connection) - (setting-control-method-17 () none) - (setting-control-method-18 () none) + (apply-settings (_type_) user-setting-data) + (update (_type_) user-setting-data) (setting-control-method-19 () none) ) ) diff --git a/goal_src/jak3/engine/level/level-h.gc b/goal_src/jak3/engine/level/level-h.gc index 4bc98c7763..e2b3f4b9a8 100644 --- a/goal_src/jak3/engine/level/level-h.gc +++ b/goal_src/jak3/engine/level/level-h.gc @@ -306,7 +306,7 @@ (level-method-18 () none) (level-method-19 () none) (level-method-20 () none) - (level-method-21 () none) + (get-art-group-by-name (_type_ string) art-group) (level-method-22 () none) (level-method-23 () none) (level-method-24 () none) diff --git a/goal_src/jak3/engine/load/load-dgo.gc b/goal_src/jak3/engine/load/load-dgo.gc index 4c5424e718..88ad36cdfd 100644 --- a/goal_src/jak3/engine/load/load-dgo.gc +++ b/goal_src/jak3/engine/load/load-dgo.gc @@ -120,7 +120,7 @@ (none) ) -(defun str-play-async ((name string) (id sound-id) (chunk-idx int) (group int)) +(defun str-play-async ((name string) (id sound-id) (volume int) (group int)) "Start playing a streaming audio." (set! *que-str-lock* #t) (let ((s2-0 (the-as play-chunk-msg (add-element *play-str-rpc*)))) @@ -132,7 +132,7 @@ (set! (-> s2-0 id 1) (the-as uint 0)) (set! (-> s2-0 id 2) (the-as uint 0)) (set! (-> s2-0 id 3) (the-as uint 0)) - (set! (-> s2-0 section) (the-as uint chunk-idx)) + (set! (-> s2-0 section) (the-as uint volume)) (set! (-> s2-0 maxlen) (the-as uint 0)) (set! (-> s2-0 group) (the-as uint group)) (set! (-> s2-0 result) (the-as uint 0)) diff --git a/goal_src/jak3/engine/load/loader.gc b/goal_src/jak3/engine/load/loader.gc index 037f1e6613..ef6bbb56ef 100644 --- a/goal_src/jak3/engine/load/loader.gc +++ b/goal_src/jak3/engine/load/loader.gc @@ -5,5 +5,2733 @@ ;; name in dgo: loader ;; dgos: GAME +(define-extern art-group-load-check (function string kheap int art-group)) + +;; +++loader:spooler-flags +(defenum spooler-flags + :bitfield #t + :type uint32 + (blackout-on-stall) + ) +;; ---loader:spooler-flags + ;; DECOMP BEGINS +(defmethod mem-usage ((this subtitle-range) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 74 (-> usage length))) + (set! (-> usage data 73 name) "subtitle") + (+! (-> usage data 73 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 73 used) v1-6) + (+! (-> usage data 73 total) (logand -16 (+ v1-6 15))) + ) + this + ) + + +;; WARN: Return type mismatch symbol vs load-dir. +(defmethod mem-usage ((this load-dir) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 86 (-> usage length))) + (set! (-> usage data 85 name) "array") + (+! (-> usage data 85 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 85 used) v1-6) + (+! (-> usage data 85 total) (logand -16 (+ v1-6 15))) + ) + (set! (-> usage length) (max 86 (-> usage length))) + (set! (-> usage data 85 name) "array") + (set! (-> usage data 85 count) (-> usage data 85 count)) + (let ((v1-15 (asize-of (-> this string-array)))) + (+! (-> usage data 85 used) v1-15) + (+! (-> usage data 85 total) (logand -16 (+ v1-15 15))) + ) + (set! (-> usage length) (max 86 (-> usage length))) + (set! (-> usage data 85 name) "array") + (set! (-> usage data 85 count) (-> usage data 85 count)) + (let ((v1-24 (asize-of (-> this data-array)))) + (+! (-> usage data 85 used) v1-24) + (+! (-> usage data 85 total) (logand -16 (+ v1-24 15))) + ) + (dotimes (s3-0 (-> this data-array length)) + (mem-usage (-> this data-array s3-0) usage flags) + ) + (the-as load-dir #f) + ) + +(defmethod load-to-heap-by-name ((this load-dir-art-group) (arg0 string) (arg1 symbol) (arg2 kheap) (arg3 int)) + (let ((s5-0 (-> this string-array))) + (dotimes (s3-0 (-> s5-0 length)) + (when (string= arg0 (-> s5-0 s3-0)) + (when (= arg1 'reload) + (let ((v1-5 (art-group-load-check arg0 arg2 arg3))) + (if v1-5 + (set! (-> this art-group-array s3-0) v1-5) + ) + ) + ) + (return (-> this art-group-array s3-0)) + ) + ) + (when (= arg1 'load) + (let ((v0-2 (art-group-load-check arg0 arg2 arg3))) + (when v0-2 + (set! (-> s5-0 (-> s5-0 length)) arg0) + (set! (-> this art-group-array (-> s5-0 length)) v0-2) + (+! (-> s5-0 length) 1) + (+! (-> this art-group-array length) 1) + ) + v0-2 + ) + ) + ) + ) + +(defmethod set-loaded-art ((this load-dir-art-group) (arg0 art-group)) + (let ((s4-0 (-> this string-array))) + (dotimes (s3-0 (-> s4-0 length)) + (when (string= (-> arg0 name) (-> s4-0 s3-0)) + (set! (-> this art-group-array s3-0) arg0) + (set! arg0 (-> this art-group-array s3-0)) + (goto cfg-7) + ) + ) + (set! (-> s4-0 (-> s4-0 length)) (-> arg0 name)) + (set! (-> this art-group-array (-> s4-0 length)) arg0) + (+! (-> s4-0 length) 1) + ) + (+! (-> this art-group-array length) 1) + (label cfg-7) + arg0 + ) + +(defun drawable-load ((arg0 drawable) (arg1 kheap)) + (local-vars (sp-0 pointer)) + (cond + ((type? arg0 string) + (the-as none sp-0) + (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + (set! sp-0 (&+ *kernel-sp* -1024)) + ) + (let ((s5-1 (the-as drawable (loado (the-as string arg0) arg1)))) + (if (and s5-1 (type? s5-1 drawable)) + (login s5-1) + ) + ) + ) + ((type? arg0 drawable) + (login arg0) + ) + ) + ) + +(defun art-load ((arg0 string) (arg1 kheap)) + (local-vars (sp-0 pointer)) + (the-as none sp-0) + (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + (set! sp-0 (&+ *kernel-sp* -1024)) + ) + (let ((s5-0 (the-as art (loado arg0 arg1)))) + (if (type? s5-0 art) + (login s5-0) + (the-as art #f) + ) + ) + ) + +(defun art-group-load-check ((arg0 string) (arg1 kheap) (arg2 int)) + (local-vars (sp-0 pointer)) + (when *debug-segment* + (the-as none sp-0) + (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + (set! sp-0 (&+ *kernel-sp* -1024)) + ) + (let ((s3-1 (the-as art-group (loado (make-file-name (file-kind art-group) arg0 arg2 #f) arg1)))) + (cond + ((not s3-1) + (format 0 "ERROR: art-group ~A is not a valid file.~%" arg0) + (the-as art-group #f) + ) + ((not (type? s3-1 art-group)) + (format 0 "ERROR: art-group ~A is not a art-group.~%" arg0) + (the-as art-group #f) + ) + ((not (file-info-correct-version? (-> s3-1 info) (file-kind art-group) arg2)) + (the-as art-group #f) + ) + (else + (login s3-1) + ) + ) + ) + ) + ) + +(defmethod print ((this external-art-buffer)) + (format + #t + "#<~A ~S ~D ~A @ #x~X>" + (-> this type) + (-> this pending-load-file) + (-> this pending-load-file-part) + (-> this status) + this + ) + this + ) + +(defun external-art-buffer-init ((arg0 external-art-buffer)) + (let ((v1-0 (-> arg0 heap))) + (set! (-> v1-0 base) (the-as pointer (+ #x84000 (* #x3dc00 (-> arg0 index))))) + (set! (-> v1-0 current) (-> v1-0 base)) + (set! (-> v1-0 top-base) (&+ (-> v1-0 base) #x3dc00)) + (set! (-> v1-0 top) (-> v1-0 top-base)) + ) + 0 + ) + +(defmethod set-pending-file ((this external-art-buffer) (arg0 string) (arg1 int) (arg2 handle) (arg3 float)) + (set! (-> this pending-load-file) arg0) + (set! (-> this pending-load-file-part) arg1) + (set! (-> this pending-load-file-owner) arg2) + (set! (-> this pending-load-file-priority) arg3) + 0 + ) + +(defmethod unlock! ((this external-art-buffer)) + (set! (-> this locked?) #f) + 0 + ) + +(defmethod inactive? ((this external-art-buffer)) + (!= (-> this status) 'active) + ) + +(defmethod file-status ((this external-art-buffer) (arg0 string) (arg1 int)) + (when (and (name= (-> this pending-load-file) arg0) (= (-> this pending-load-file-part) arg1)) + (if (and (name= (-> this load-file) arg0) (= (-> this load-file-part) arg1)) + (-> this status) + 'pending + ) + ) + ) + +(defmethod link-art-to-master ((this art-group)) + (when this + (countdown (s5-0 (-> this length)) + (let* ((s3-0 (-> this data s5-0)) + (s4-0 (if (type? s3-0 art-element) + s3-0 + ) + ) + (s2-0 #f) + ) + (when s4-0 + (let ((s3-1 11)) + (while (begin (label cfg-24) (nonzero? s3-1)) + (+! s3-1 -1) + (let ((v1-8 (get-art-group-by-name (-> *level* level s3-1) (-> s4-0 master-art-group-name)))) + (when v1-8 + (countdown (a0-5 (-> v1-8 length)) + (if (= (-> v1-8 data a0-5) s4-0) + (goto cfg-24) + ) + ) + (cond + ((and (< (-> s4-0 master-art-group-index) (-> v1-8 length)) + (not (-> v1-8 data (-> s4-0 master-art-group-index))) + ) + (set! (-> v1-8 data (-> s4-0 master-art-group-index)) s4-0) + (set! s2-0 #t) + ) + (else + (countdown (a0-17 (-> v1-8 length)) + (when (not (-> v1-8 data a0-17)) + (set! (-> v1-8 data a0-17) s4-0) + (set! s2-0 #t) + (goto cfg-24) + ) + ) + ) + ) + ) + ) + ) + ) + (if (not s2-0) + (format 0 "ERROR: ~A could not find a master slot to link for ~A.~%" (-> this name) s4-0) + ) + ) + ) + ) + ) + this + ) + +(defmethod unlink-art-to-master ((this art-group)) + (when this + (countdown (s5-0 (-> this length)) + (let* ((s3-0 (-> this data s5-0)) + (s4-0 (if (type? s3-0 art-element) + s3-0 + ) + ) + (s3-1 #f) + ) + (when s4-0 + (let ((s2-0 11)) + (while (begin (label cfg-13) (nonzero? s2-0)) + (+! s2-0 -1) + (let ((v1-8 (get-art-group-by-name (-> *level* level s2-0) (-> s4-0 master-art-group-name)))) + (when v1-8 + (countdown (a0-5 (-> v1-8 length)) + (when (= s4-0 (-> v1-8 data a0-5)) + (set! (-> v1-8 data a0-5) #f) + (set! s3-1 #t) + (goto cfg-13) + ) + ) + ) + ) + ) + ) + (if (not s3-1) + (format 0 "ERROR: ~A could not find a master slot to unlink for ~A.~%" (-> this name) s4-0) + ) + ) + ) + ) + ) + 0 + ) + +(defmethod link-file ((this external-art-buffer) (arg0 art-group)) + (when arg0 + (link-art-to-master arg0) + (set! (-> this art-group) arg0) + ) + arg0 + ) + +(defmethod unlink-file ((this external-art-buffer) (arg0 art-group)) + (when arg0 + (unlink-art-to-master arg0) + (set! (-> this art-group) #f) + ) + 0 + ) + +;; WARN: Found some very strange gotos. Check result carefully, this is not well tested. +(defmethod update ((this external-art-buffer)) + (when (or (not (name= (-> this pending-load-file) (-> this load-file))) + (!= (-> this pending-load-file-part) (-> this load-file-part)) + ) + (when (not (handle->process (-> this pending-load-file-owner))) + (set! (-> this pending-load-file) #f) + (set! (-> this pending-load-file-part) -1) + (set! (-> this pending-load-file-owner) (the-as handle #f)) + (set! (-> this pending-load-file-priority) 100000000.0) + ) + (when (= (-> this status) 'initialize) + ((-> this init-heap) this) + (set! (-> this status) 'inactive) + ) + (cond + ((-> this load-file) + (if (= (-> this status) 'loading) + (str-load-cancel) + ) + (set! (-> this load-file) #f) + (set! (-> this load-file-part) -1) + (set! (-> this load-file-owner) (the-as handle #f)) + (set! (-> this load-file-priority) 100000000.0) + ) + (else + (set! (-> this load-file) (-> this pending-load-file)) + (set! (-> this load-file-part) (-> this pending-load-file-part)) + (set! (-> this load-file-owner) (-> this pending-load-file-owner)) + (set! (-> this load-file-priority) (-> this pending-load-file-priority)) + ) + ) + ) + (label cfg-18) + (cond + ((-> this load-file) + (case (-> this status) + (('active 'reserved) + ) + (('error) + (set! (-> this status) 'inactive) + (set! (-> this load-file) #f) + (set! (-> this load-file-part) -1) + (set! (-> this load-file-owner) (the-as handle #f)) + (set! (-> this load-file-priority) 100000000.0) + (set! (-> this pending-load-file) #f) + (set! (-> this pending-load-file-part) -1) + (set! (-> this pending-load-file-owner) (the-as handle #f)) + (set! (-> this pending-load-file-priority) 100000000.0) + (set! (-> this art-group) #f) + ) + (('inactive) + (let ((v1-31 (-> this heap))) + (set! (-> v1-31 current) (-> v1-31 base)) + ) + (cond + ((string= (-> this load-file) "reserved") + (cond + ((-> *art-control* reserve-buffer) + (format 0 "ERROR: trying double reserve ~A when ~A is reserved~%" this (-> *art-control* reserve-buffer)) + ) + (else + (set! (-> this status) 'reserved) + (set! (-> *art-control* reserve-buffer) this) + ) + ) + ) + ((and (!= (-> *level* loading-level) (-> *level* level-default)) + (or (< 81920.0 (-> this load-file-priority)) (logtest? (-> *level* loading-level info level-flags) 16)) + ) + ) + ((let ((v1-46 (logand -64 (&+ (-> this heap current) 63)))) + (str-load (-> this load-file) (-> this load-file-part) v1-46 (&- (-> this heap top) (the-as uint v1-46))) + ) + (set! (-> this status) 'loading) + 0 + ) + ) + ) + (('loading) + (case (str-load-status (&-> this len)) + (('error) + (set! (-> this status) 'error) + ) + (('busy) + ) + (else + (set! (-> this buf) (logand -64 (&+ (-> this heap current) 63))) + (set! (-> this status) 'loaded) + (goto cfg-18) + ) + ) + ) + (('loaded) + (let ((a0-39 (-> this buf))) + (cond + ((-> this login?) + (set! (-> this art-group) + (the-as art-group (link a0-39 (-> this load-file data) (-> this len) (-> this heap) (if *print-login* + 8 + 0 + ) + ) + ) + ) + (let ((s4-0 (-> this art-group)) + (s3-0 (-> this load-file)) + ) + (cond + ((not s4-0) + (format 0 "ERROR: art-group ~A part ~D is not a valid file.~%" s3-0 (-> this load-file-part)) + (set! (-> this status) 'error) + ) + ((not (type? s4-0 art-group)) + (format 0 "ERROR: art-group ~A part ~D is not a art-group.~%" s3-0 (-> this load-file-part)) + (set! (-> this status) 'error) + ) + ((not (file-info-correct-version? (-> s4-0 info) (file-kind art-group) 0)) + (set! (-> this status) 'error) + ) + (else + (login s4-0) + (set! (-> this status) 'locked) + ) + ) + ) + ) + (else + (set! (-> this status) 'locked) + (set! (-> this art-group) (the-as art-group a0-39)) + ) + ) + ) + ) + (('locked) + (when (and (not (-> this locked?)) (handle->process (-> this load-file-owner))) + (if (-> this login?) + (link-file this (-> this art-group)) + ) + (if (-> this other) + (set! (-> this other locked?) #t) + ) + (set! (-> this status) 'active) + (goto cfg-18) + ) + ) + ) + ) + (else + (case (-> this status) + (('initialize) + ) + (('reserved) + (cond + ((= (-> *art-control* reserve-buffer) this) + (set! (-> *art-control* reserve-buffer) #f) + (set! (-> this status) 'inactive) + ) + (else + (format 0 "ERROR: trying tro free ~A when ~A is reserved~%" this (-> *art-control* reserve-buffer)) + ) + ) + ) + (('active) + (if (-> this login?) + (unlink-file this (-> this art-group)) + ) + (let ((v1-89 (-> this heap))) + (set! (-> v1-89 current) (-> v1-89 base)) + ) + (set! (-> this art-group) #f) + (set! (-> this status) 'inactive) + (when (and (-> this other) (-> this other locked?)) + (unlock! (-> this other)) + (update (-> this other)) + ) + ) + (else + (let ((v1-99 (-> this heap))) + (set! (-> v1-99 current) (-> v1-99 base)) + ) + (set! (-> this art-group) #f) + (set! (-> this status) 'inactive) + ) + ) + ) + ) + 0 + ) + +(define *preload-spool-anims* #t) + +(defmethod file-status ((this external-art-control) (arg0 string) (arg1 int)) + (dotimes (s3-0 2) + (let ((v1-3 (file-status (-> this buffer s3-0) arg0 arg1))) + (if v1-3 + (return v1-3) + ) + ) + ) + #f + ) + +(defmethod update ((this external-art-control) (arg0 symbol)) + (if (nonzero? (-> this reserve-buffer-count)) + (spool-push this "reserved" 0 *dproc* (if (-> this reserve-buffer) + -110.0 + -0.5 + ) + ) + ) + (dotimes (v1-5 2) + (set! (-> this buffer v1-5 frame-lock) #f) + ) + (dotimes (v1-8 3) + (set! (-> this rec v1-8 anim-name) #f) + ) + (dotimes (s4-0 2) + (let ((s3-0 (-> this rec s4-0))) + (when (-> s3-0 name) + (dotimes (s2-0 2) + (when (and (file-status (-> this buffer s2-0) (-> s3-0 name) (-> s3-0 parts)) + (not (-> this buffer s2-0 frame-lock)) + ) + (set! (-> this buffer s2-0 frame-lock) #t) + (set! (-> s3-0 anim-name) (the-as string (-> this buffer s2-0))) + (set! (-> this buffer s2-0 pending-load-file-owner) (-> s3-0 owner)) + (set! (-> this buffer s2-0 load-file-owner) (-> s3-0 owner)) + (set! (-> this buffer s2-0 pending-load-file-priority) (-> s3-0 priority)) + (set! (-> this buffer s2-0 load-file-priority) (-> s3-0 priority)) + (goto cfg-24) + ) + ) + ) + ) + (label cfg-24) + ) + (dotimes (s4-1 2) + (let ((s3-1 (-> this rec s4-1))) + (when (and (-> s3-1 name) (not (-> s3-1 anim-name))) + (if (and (not *preload-spool-anims*) (>= (-> s3-1 priority) 0.0)) + (goto cfg-46) + ) + (dotimes (s2-1 2) + (when (not (-> this buffer s2-1 frame-lock)) + (set! (-> this buffer s2-1 frame-lock) #t) + (set-pending-file (-> this buffer s2-1) (-> s3-1 name) (-> s3-1 parts) (-> s3-1 owner) (-> s3-1 priority)) + (set! (-> s3-1 anim-name) (the-as string (-> this buffer s2-1))) + (goto cfg-46) + ) + ) + ) + ) + (label cfg-46) + ) + (when (not (-> this reserve-buffer)) + (let ((s4-2 (the-as external-art-buffer (-> this rec 0 anim-name)))) + (if (and s4-2 + (-> s4-2 locked?) + (not (string= (-> s4-2 pending-load-file) "reserved")) + (not (string= (-> s4-2 other pending-load-file) "reserved")) + ) + (set-pending-file (-> s4-2 other) (the-as string #f) -1 (the-as handle #f) 100000000.0) + ) + ) + ) + (dotimes (s4-3 2) + (update (-> this buffer s4-3)) + ) + (let ((s4-4 (-> this queue-stream))) + (set! (-> s4-4 length) 0) + (dotimes (s3-2 3) + (when (-> this rec s3-2 name) + (mem-copy! (&-> (-> s4-4 (-> s4-4 length)) type) (&-> (-> this rec s3-2) type) 44) + (+! (-> s4-4 length) 1) + ) + ) + ) + (when (and arg0 *display-art-control*) + (dotimes (s5-1 3) + (let ((t9-8 format) + (a0-27 *stdcon*) + (a1-8 "rec ~d ~S ~D ~f ~A~%") + (a2-5 s5-1) + (a3-3 (-> this rec s5-1 name)) + (t0-3 (-> this rec s5-1 parts)) + (t1-0 (-> this rec s5-1 priority)) + (v1-121 (handle->process (-> this rec s5-1 owner))) + ) + (t9-8 a0-27 a1-8 a2-5 a3-3 t0-3 t1-0 (if v1-121 + (-> v1-121 name) + ) + ) + ) + ) + (dotimes (s5-2 2) + (let ((t9-9 format) + (a0-28 *stdcon*) + (a1-9 "buf ~d ~C ~S ~D ~A ~A~%") + (a2-6 s5-2) + (a3-4 (if (-> this buffer s5-2 locked?) + 108 + 32 + ) + ) + (t0-4 (-> this buffer s5-2 pending-load-file)) + (t1-1 (-> this buffer s5-2 pending-load-file-part)) + (t2-5 (-> this buffer s5-2 status)) + (v1-142 (handle->process (-> this buffer s5-2 pending-load-file-owner))) + ) + (t9-9 a0-28 a1-9 a2-6 a3-4 t0-4 t1-1 t2-5 (if v1-142 + (-> v1-142 name) + ) + ) + ) + ) + (format *stdcon* " a: ~S~%" (-> this active-stream)) + ) + 0 + ) + +(defmethod none-reserved? ((this external-art-control)) + (zero? (-> this reserve-buffer-count)) + ) + +(defmethod reserve-alloc ((this external-art-control)) + (cond + ((or (nonzero? (-> this dma-reserve-buffer-count)) (= *master-mode* 'progress)) + (set! (-> this dma-reserve-buffer-count) 1) + (when (and (-> *bigmap* drawing-flag) (zero? (-> *blit-displays-work* count-down))) + (let ((v1-8 (-> this dma-reserve-heap))) + (set! (-> v1-8 base) (logand -64 (&+ (&+ (-> *display* frames 1 global-buf end) -252992) 63))) + (set! (-> v1-8 current) (-> v1-8 base)) + (set! (-> v1-8 top-base) (&+ (-> v1-8 base) #x3dc00)) + (set! (-> v1-8 top) (-> v1-8 top-base)) + ) + (set! (-> *display* frames 1 global-buf end) (-> this dma-reserve-heap base)) + (-> this dma-reserve-heap) + ) + ) + (else + (set! (-> this reserve-buffer-count) 1) + (if (and (-> this reserve-buffer) (not (check-busy *load-str-rpc*))) + (-> this reserve-buffer heap) + ) + ) + ) + ) + +(defmethod reserve-free ((this external-art-control) (arg0 kheap)) + (cond + ((nonzero? (-> this dma-reserve-buffer-count)) + (set! (-> this dma-reserve-buffer-count) 0) + (let ((v1-3 (-> *display* frames 1 global-buf))) + (set! (-> v1-3 end) (the-as pointer (+ (+ (-> v1-3 allocated-length) 28) (the-as int v1-3)))) + ) + ) + ((and (zero? (-> this reserve-buffer-count)) (zero? (-> this dma-reserve-buffer-count))) + (format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (none reserved).~%" arg0) + ) + ((not (-> this reserve-buffer)) + (set! (-> this reserve-buffer-count) 0) + 0 + ) + ((= (-> this reserve-buffer heap) arg0) + (set-pending-file (-> this reserve-buffer) (the-as string #f) -1 (the-as handle #f) 100000000.0) + (update (-> this reserve-buffer)) + (set! (-> this reserve-buffer-count) 0) + 0 + ) + (else + (format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (buffer unknown).~%" arg0) + ) + ) + 0 + ) + +(defmethod clear-rec ((this external-art-control)) + (dotimes (v1-0 3) + (set! (-> this rec v1-0 type) spool-anim) + (set! (-> this rec v1-0 name) #f) + (set! (-> this rec v1-0 priority) 100000000.0) + (set! (-> this rec v1-0 owner) (the-as handle #f)) + ) + (set! (-> this frame-mask) (the-as uint (-> *setting-control* user-current process-mask))) + 0 + ) + +(defmethod spool-push ((this external-art-control) (arg0 string) (arg1 int) (arg2 process) (arg3 float)) + (when (and (= arg3 -99.0) arg2) + (let ((a0-2 (target-pos 0))) + (set! arg3 (vector-vector-distance a0-2 (-> (the-as process-drawable arg2) root trans))) + ) + ) + (cond + ((and (= arg1 (-> this rec 0 parts)) (name= arg0 (-> this rec 0 name))) + (if (>= arg3 (-> this rec 0 priority)) + (return (the-as int #f)) + ) + (mem-copy! (&-> (-> this rec) 0 type) (&-> (-> this rec 1) type) 44) + (mem-copy! (&-> (-> this rec 1) type) (&-> (-> this rec 2) type) 44) + (set! (-> this rec 2 name) #f) + (set! (-> this rec 2 owner) (the-as handle #f)) + ) + ((and (= arg1 (-> this rec 1 parts)) (name= arg0 (-> this rec 1 name))) + (if (>= arg3 (-> this rec 1 priority)) + (return (the-as int #f)) + ) + (mem-copy! (&-> (-> this rec 1) type) (&-> (-> this rec 2) type) 44) + (set! (-> this rec 2 name) #f) + (set! (-> this rec 2 owner) (the-as handle #f)) + ) + ((and (= arg1 (-> this rec 2 parts)) (name= arg0 (-> this rec 2 name))) + (if (>= arg3 (-> this rec 2 priority)) + (return (the-as int #f)) + ) + (set! (-> this rec 2 name) #f) + (set! (-> this rec 2 owner) (the-as handle #f)) + ) + ) + (cond + ((< arg3 (-> this rec 0 priority)) + (mem-copy! (&-> (-> this rec 2) type) (&-> (-> this rec 1) type) 44) + (mem-copy! (&-> (-> this rec 1) type) (&-> (-> this rec) 0 type) 44) + (set! (-> this rec 0 name) arg0) + (set! (-> this rec 0 parts) arg1) + (set! (-> this rec 0 priority) arg3) + (set! (-> this rec 0 owner) (process->handle arg2)) + ) + ((< arg3 (-> this rec 1 priority)) + (mem-copy! (&-> (-> this rec 2) type) (&-> (-> this rec 1) type) 44) + (set! (-> this rec 1 name) arg0) + (set! (-> this rec 1 parts) arg1) + (set! (-> this rec 1 priority) arg3) + (set! (-> this rec 1 owner) (process->handle arg2)) + ) + ((< arg3 (-> this rec 2 priority)) + (set! (-> this rec 2 name) arg0) + (set! (-> this rec 2 parts) arg1) + (set! (-> this rec 2 priority) arg3) + (set! (-> this rec 2 owner) (process->handle arg2)) + ) + ) + 0 + ) + +(deftype spooler-block (basic) + ((anim spool-anim) + (idle art-joint-anim) + (exit art-joint-anim) + (break-func (function process-drawable object)) + (flags spooler-flags) + (part int32) + (part-audio-start float) + (old-status uint16) + (old-pos int32) + (good-time time-frame) + (old-time time-frame) + (good-count int32) + (sid sound-id) + (real-start-time time-frame) + (paused? symbol) + ) + ) + + +(defbehavior ja-play-spooled-anim process-drawable ((arg0 spool-anim) + (arg1 art-joint-anim) + (arg2 art-joint-anim) + (arg3 (function process-drawable symbol)) + (arg4 spooler-flags) + ) + (local-vars (v0-62 int) (sv-176 int)) + (let ((gp-0 (new 'stack 'spooler-block))) + (let ((s5-0 gp-0)) + (set! (-> s5-0 anim) arg0) + (set! (-> s5-0 idle) arg1) + (set! (-> s5-0 exit) arg2) + (set! (-> s5-0 break-func) arg3) + (set! (-> s5-0 flags) arg4) + (set! (-> s5-0 part-audio-start) -17.0) + (set! (-> s5-0 old-status) (the-as uint (-> self skel status))) + (set! (-> s5-0 old-pos) -2) + (set! (-> s5-0 sid) (new-sound-id)) + (set! (-> s5-0 paused?) #f) + ) + (let ((v1-7 + (lookup-gui-connection *gui-control* self (gui-channel art-load) (-> gp-0 anim name) (new 'static 'sound-id)) + ) + ) + (if v1-7 + (set! (-> gp-0 sid) (-> v1-7 id)) + ) + ) + (if (!= self *target*) + (send-event *target* 'movie) + ) + (backup-load-state-and-set-cmds *load-state* (-> gp-0 anim command-list)) + (logior! (-> self skel status) (joint-control-status sync-math spooling spooling-not-last-block)) + (talker-surpress!) + (update *setting-control*) + (when (or (and (-> *setting-control* user-current spooling) + (or (< 2 (-> gp-0 anim parts)) + (not (string= (-> *setting-control* user-current spool-anim name) (-> gp-0 anim name))) + ) + ) + (logtest? (-> *art-control* frame-mask) 28) + (!= *master-mode* 'game) + ) + (cond + ((-> gp-0 idle) + (when (!= (ja-group) (-> gp-0 idle)) + (ja-channel-push! 1 (seconds 0.05)) + (ja :group! (-> gp-0 idle) :num! min) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (while (or (and (-> *setting-control* user-current spooling) + (or (< 2 (-> gp-0 anim parts)) + (not (string= (-> *setting-control* user-current spool-anim name) (-> gp-0 anim name))) + ) + ) + (logtest? (-> *art-control* frame-mask) 28) + (!= *master-mode* 'game) + ) + (format #t "WARNING: ---------------------> loader stall on lock~%") + (if ((-> gp-0 break-func) self) + (goto cfg-139) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -9.0 + (-> gp-0 sid) + ) + (suspend) + (if (-> gp-0 idle) + (ja :num! (loop!)) + ) + ) + ) + (set-setting! 'spooling (process->ppointer self) 0.0 0) + (set-setting! 'spool-anim (-> gp-0 anim) 0.0 0) + (update *setting-control*) + (set-time! (-> gp-0 old-time)) + (while (< (-> gp-0 part) (-> gp-0 anim parts)) + (when (> (-> gp-0 part) 0) + (while (let ((v1-103 (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)))) + (not (or (= v1-103 'active) (= v1-103 'locked))) + ) + (if ((-> gp-0 break-func) self) + (goto cfg-139) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (+ (-> gp-0 part) -1) + -20.0 + (-> gp-0 sid) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -10.0 + (-> gp-0 sid) + ) + (when (and (not (-> gp-0 paused?)) (< (-> *setting-control* user-current movie-skip-frame) 0.0)) + (format + #t + "WARNING: ---------------------> loader pre stall on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + (set! (-> gp-0 paused?) #t) + (if (nonzero? (-> gp-0 part)) + (sound-pause (-> gp-0 sid)) + ) + ) + (if (logtest? (-> gp-0 flags) (spooler-flags blackout-on-stall)) + (set-blackout-frames (seconds 0.05)) + ) + (suspend) + ) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (update *gui-control* #f) + (update *art-control* #f) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (when (!= (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) 'active) + (cond + ((-> gp-0 idle) + (when (!= (ja-group) (-> gp-0 idle)) + (ja-channel-set! 1) + (ja :group! (-> gp-0 idle) :num! min) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (while (!= (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) 'active) + (if ((-> gp-0 break-func) self) + (goto cfg-139) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (when (not (-> gp-0 paused?)) + (format + #t + "WARNING: ---------------------> loader stall on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + (set! (-> gp-0 paused?) #t) + (if (nonzero? (-> gp-0 part)) + (sound-pause (-> gp-0 sid)) + ) + ) + (if (logtest? (-> gp-0 flags) (spooler-flags blackout-on-stall)) + (set-blackout-frames (seconds 0.05)) + ) + (suspend) + (if (-> gp-0 idle) + (ja :num! (loop!)) + ) + ) + ) + (when (-> gp-0 paused?) + (set! (-> gp-0 paused?) #f) + (sound-continue (-> gp-0 sid)) + (format + #t + "WARNING: ---------------------> loader release lock on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (let ((s5-8 (get-art-by-name (-> self draw art-group) (-> gp-0 anim anim-name) art-joint-anim))) + (cond + (s5-8 + (ja-channel-set! 1) + (ja-no-eval :group! s5-8 :num! (seek!) :frame-num 0.0) + (when (zero? (-> gp-0 part)) + (str-play-async (-> gp-0 anim name) (-> gp-0 sid) 1024 2) + (set! (-> *art-control* active-stream) (-> gp-0 anim name)) + ) + (let* ((f30-0 (* 0.05859375 (-> s5-8 speed))) + (f28-0 (+ (-> gp-0 part-audio-start) (/ (the float (+ (-> s5-8 frames num-frames) -1)) f30-0))) + ) + (set! sv-176 (current-str-pos (-> gp-0 sid))) + (set-time! (-> gp-0 good-time)) + (until (>= (the float v0-62) f28-0) + (if (= (-> self skel root-channel 0) (-> self skel channel)) + (logior! (-> self skel status) (joint-control-status valid-spooled-frame)) + ) + (if (or ((-> gp-0 break-func) self) + (and (<= sv-176 0) (time-elapsed? (-> gp-0 good-time) (seconds 4))) + (and (< 300 (-> gp-0 good-count)) (<= sv-176 0)) + ) + (goto cfg-139) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (if (< (+ (-> gp-0 part) 1) (-> gp-0 anim parts)) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (+ (-> gp-0 part) 1) + -10.0 + (-> gp-0 sid) + ) + (logclear! (-> self skel status) (joint-control-status spooling-not-last-block)) + ) + (execute-commands-up-to *load-state* (ja-aframe-num 0)) + (cond + ((and (< (-> gp-0 old-pos) sv-176) (< -1 sv-176)) + (+! (-> gp-0 good-count) (- (current-time) (-> self clock old-frame-counter))) + (set-time! (-> gp-0 good-time)) + ) + (else + 0 + ) + ) + (set! (-> gp-0 old-pos) sv-176) + (set-time! (-> gp-0 old-time)) + (if (and (logtest? (-> gp-0 flags) (spooler-flags blackout-on-stall)) (<= sv-176 0)) + (set-blackout-frames (seconds 0.05)) + ) + (suspend) + (let* ((f26-0 (* (- (the float (current-str-pos (-> gp-0 sid))) (-> gp-0 part-audio-start)) f30-0)) + (f0-16 (if (str-id-is-playing? (-> gp-0 sid)) + (fmax 0.0 (fmin f26-0 (the float (+ (-> (ja-group) frames num-frames) -1)))) + (fmax 0.0 (fmin (ja-frame-num 0) (the float (+ (-> (ja-group) frames num-frames) -1)))) + ) + ) + ) + (ja-no-eval :num! (seek!) :frame-num f0-16) + ) + (set! v0-62 (current-str-pos (-> gp-0 sid))) + (set! sv-176 v0-62) + ) + (set! (-> gp-0 part-audio-start) f28-0) + ) + (logclear! (-> self skel status) (joint-control-status valid-spooled-frame)) + ) + (else + (format + 0 + "ERROR: ~A in spool anim loop for ~A ~D, but not loaded.~" + self + (-> gp-0 anim name) + (-> gp-0 part) + ) + (goto cfg-139) + ) + ) + ) + (+! (-> gp-0 part) 1) + ) + (+! (-> gp-0 part) -1) + (label cfg-139) + (ja-abort-spooled-anim (-> gp-0 anim) (-> gp-0 exit) (-> gp-0 part)) + ) + 0 + ) + +(defbehavior ja-abort-spooled-anim process-drawable ((arg0 spool-anim) (arg1 art-joint-anim) (arg2 int)) + (let ((s3-0 0)) + (let ((v1-1 + (lookup-gui-connection *gui-control* self (gui-channel art-load) (-> arg0 name) (new 'static 'sound-id)) + ) + ) + (when v1-1 + (set! s3-0 (the-as int (-> v1-1 id))) + (set! (-> v1-1 action) (gui-action abort)) + ) + ) + (if (zero? s3-0) + (return (the-as int #f)) + ) + (str-play-stop (-> arg0 name) (the-as sound-id s3-0)) + ) + (restore-load-state-and-cleanup *load-state*) + (set! (-> *art-control* active-stream) #f) + (logclear! (-> self skel status) (joint-control-status spooling spooling-not-last-block)) + (if (not (logtest? (-> self skel status) (joint-control-status sync-math))) + (logclear! (-> self skel status) (joint-control-status sync-math)) + ) + (cond + ((and arg1 (>= arg2 0)) + (ja-channel-push! 1 (seconds 0.03)) + (set! (-> self skel root-channel 0 frame-group) arg1) + (while (!= (-> self skel root-channel 0) (-> self skel channel)) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> arg0 name) + arg2 + -20.0 + (new 'static 'sound-id) + ) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (remove-setting! 'spooling) + (remove-setting! 'spool-anim) + 0 + ) + + +(defmethod print ((this gui-connection)) + (let* ((t9-0 format) + (a0-1 #t) + (a1-0 "# this name)) + (a3-0 (-> this anim-part)) + (t0-0 (-> this id)) + (t1-0 (-> this priority)) + (v1-0 (-> this channel)) + (t2-1 (cond + ((= v1-0 (gui-channel hud-lower-left)) + "hud-lower-left" + ) + ((= v1-0 (gui-channel citizen)) + "citizen" + ) + ((= v1-0 (gui-channel pecker)) + "pecker" + ) + ((= v1-0 (gui-channel jak-effect-1)) + "jak-effect-1" + ) + ((= v1-0 (gui-channel ashelin)) + "ashelin" + ) + ((= v1-0 (gui-channel hud-lower-left-1)) + "hud-lower-left-1" + ) + ((= v1-0 (gui-channel message)) + "message" + ) + ((= v1-0 (gui-channel hud-middle-left)) + "hud-middle-left" + ) + ((= v1-0 (gui-channel gun)) + "gun" + ) + ((= v1-0 (gui-channel hud-upper-center-2)) + "hud-upper-center-2" + ) + ((= v1-0 (gui-channel hud-middle-right)) + "hud-middle-right" + ) + ((= v1-0 (gui-channel subtitle)) + "subtitle" + ) + ((= v1-0 (gui-channel notice)) + "notice" + ) + ((= v1-0 (gui-channel art-load-next)) + "art-load-next" + ) + ((= v1-0 (gui-channel voicebox)) + "voicebox" + ) + ((= v1-0 (gui-channel sig)) + "sig" + ) + ((= v1-0 (gui-channel hud-center-left)) + "hud-center-left" + ) + ((= v1-0 (gui-channel task)) + "task" + ) + ((= v1-0 (gui-channel hud-upper-right)) + "hud-upper-right" + ) + ((= v1-0 (gui-channel hud-center-right)) + "hud-center-right" + ) + ((= v1-0 (gui-channel alert)) + "alert" + ) + ((= v1-0 (gui-channel hud-upper-left)) + "hud-upper-left" + ) + ((= v1-0 (gui-channel query)) + "query" + ) + ((= v1-0 (gui-channel hud-lower-right)) + "hud-lower-right" + ) + ((= v1-0 (gui-channel screen)) + "screen" + ) + ((= v1-0 (gui-channel guard)) + "guard" + ) + ((= v1-0 (gui-channel supertitle)) + "supertitle" + ) + ((= v1-0 (gui-channel hal)) + "hal" + ) + ((= v1-0 (gui-channel hud-upper-center)) + "hud-upper-center" + ) + ((= v1-0 (gui-channel blackout)) + "blackout" + ) + ((= v1-0 (gui-channel bbush)) + "bbush" + ) + ((= v1-0 (gui-channel hud)) + "hud" + ) + ((= v1-0 (gui-channel voice)) + "voice" + ) + ((= v1-0 (gui-channel jak-mode)) + "jak-mode" + ) + ((= v1-0 (gui-channel max)) + "max" + ) + ((= v1-0 (gui-channel none)) + "none" + ) + ((= v1-0 (gui-channel freeze)) + "freeze" + ) + ((= v1-0 (gui-channel notice-low)) + "notice-low" + ) + ((= v1-0 (gui-channel art-load)) + "art-load" + ) + ((= v1-0 (gui-channel hud-auto-save-message)) + "hud-auto-save-message" + ) + ((= v1-0 (gui-channel jak)) + "jak" + ) + ((= v1-0 (gui-channel progress)) + "progress" + ) + ((= v1-0 (gui-channel resetter)) + "resetter" + ) + ((= v1-0 (gui-channel jak-effect-2)) + "jak-effect-2" + ) + ((= v1-0 (gui-channel daxter)) + "daxter" + ) + ((= v1-0 (gui-channel hud-lower-left-2)) + "hud-lower-left-2" + ) + ((= v1-0 (gui-channel background)) + "background" + ) + ((= v1-0 (gui-channel beast)) + "beast" + ) + ((= v1-0 (gui-channel hud-auto-save)) + "hud-auto-save" + ) + ((= v1-0 (gui-channel hud-lower-center)) + "hud-lower-center" + ) + ((= v1-0 (gui-channel rider)) + "rider" + ) + ((= v1-0 (gui-channel movie)) + "movie" + ) + (else + "*unknown*" + ) + ) + ) + (v1-1 (-> this action)) + ) + (t9-0 a0-1 a1-0 a2-0 a3-0 t0-0 t1-0 t2-1 (cond + ((= v1-1 (gui-action queue)) + "queue" + ) + ((= v1-1 (gui-action stop)) + "stop" + ) + ((= v1-1 (gui-action play)) + "play" + ) + ((= v1-1 (gui-action hide)) + "hide" + ) + ((= v1-1 (gui-action fade)) + "fade" + ) + ((= v1-1 (gui-action none)) + "none" + ) + ((= v1-1 (gui-action abort)) + "abort" + ) + ((= v1-1 (gui-action stopping)) + "stopping" + ) + ((= v1-1 (gui-action hidden)) + "hidden" + ) + ((= v1-1 (gui-action playing)) + "playing" + ) + (else + "*unknown*" + ) + ) + ) + ) + (let ((s5-0 format) + (s4-0 #t) + (s3-0 " ~6S @ #x~A>") + (v1-3 (get-status *gui-control* (-> this id))) + ) + (s5-0 + s4-0 + s3-0 + (cond + ((= v1-3 (gui-status ready)) + "ready" + ) + ((= v1-3 (gui-status active)) + "active" + ) + ((= v1-3 (gui-status stop)) + "stop" + ) + ((= v1-3 (gui-status unknown)) + "unknown" + ) + ((= v1-3 (gui-status hide)) + "hide" + ) + ((= v1-3 (gui-status pending)) + "pending" + ) + (else + "*unknown*" + ) + ) + this + ) + ) + this + ) + +(defmethod channel-id-set! ((this gui-control) (arg0 gui-connection) (arg1 sound-id)) + (set! (-> this ids (-> arg0 channel)) arg1) + 0 + ) + +;; WARN: Return type mismatch connectable vs gui-connection. +(defmethod lookup-gui-connection ((this gui-control) (arg0 process) (arg1 gui-channel) (arg2 string) (arg3 sound-id)) + (let ((s1-0 (-> this engine alive-list next0))) + (-> this engine) + (let ((s0-0 (-> (the-as gui-connection s1-0) next0))) + (while (!= s1-0 (-> this engine alive-list-end)) + (if (and (or (= arg1 (gui-channel none)) (= (-> (the-as gui-connection s1-0) channel) arg1)) + (or (not arg0) + (= (-> arg0 type) scene-player) + (= arg0 ((method-of-type gui-connection get-process) (the-as connection s1-0))) + ) + (or (not arg2) (string= arg2 (-> (the-as gui-connection s1-0) name))) + (or (zero? arg3) (= (-> (the-as gui-connection s1-0) id) arg3)) + ) + (return (the-as gui-connection s1-0)) + ) + (set! s1-0 s0-0) + (-> this engine) + (set! s0-0 (-> s0-0 next0)) + ) + ) + ) + (countdown (s1-1 32) + (let ((s0-1 (-> this connections s1-1))) + (if (and (nonzero? (-> s0-1 id)) + (or (= arg1 (gui-channel none)) (= (-> s0-1 channel) arg1)) + (and (or (not arg0) (= (-> arg0 type) scene-player) (= arg0 (handle->process (-> s0-1 handle)))) + (or (not arg2) (string= arg2 (-> s0-1 name))) + (or (zero? arg3) (= (-> s0-1 id) arg3)) + ) + ) + (return s0-1) + ) + ) + ) + (the-as gui-connection #f) + ) + +;; WARN: Return type mismatch int vs sound-id. +(defmethod lookup-gui-connection-id ((this gui-control) (arg0 string) (arg1 gui-channel) (arg2 gui-action)) + (let ((s2-0 (-> this engine alive-list next0))) + (-> this engine) + (let ((s1-0 (-> (the-as gui-connection s2-0) next0))) + (while (!= (the-as gui-connection s2-0) (-> this engine alive-list-end)) + (if (and (or (= arg1 (gui-channel none)) (= arg1 (-> (the-as gui-connection s2-0) channel))) + (or (= arg2 (gui-action none)) (= arg2 (-> (the-as gui-connection s2-0) action))) + (or (not arg0) (string= arg0 (-> (the-as gui-connection s2-0) name))) + ) + (return (the-as sound-id (-> (the-as gui-connection s2-0) id))) + ) + (set! s2-0 s1-0) + (-> this engine) + (set! s1-0 (-> s1-0 next0)) + ) + ) + ) + (countdown (s2-1 32) + (let ((s1-1 (-> this connections s2-1))) + (if (and (nonzero? (-> s1-1 id)) + (or (= arg1 (gui-channel none)) (= arg1 (-> s1-1 channel))) + (or (= arg2 (gui-action none)) (= arg2 (-> s1-1 action))) + (or (not arg0) (string= arg0 (-> s1-1 name))) + ) + (return (the-as sound-id (-> s1-1 id))) + ) + ) + ) + (the-as sound-id 0) + ) + +(defmethod sound-params-set! ((this gui-control) (arg0 sound-id) (arg1 symbol) (arg2 int) (arg3 int) (arg4 int) (arg5 float)) + (when (nonzero? arg0) + (let ((v1-2 (lookup-gui-connection *gui-control* (the-as process #f) (gui-channel none) (the-as string #f) arg0))) + (when v1-2 + (if arg1 + (logior! (-> v1-2 flags) (gui-connection-flags gcf1)) + ) + (when (>= arg2 0) + (logior! (-> v1-2 flags) (gui-connection-flags fo-min)) + (set! (-> v1-2 fo-min) arg2) + ) + (when (>= arg3 0) + (logior! (-> v1-2 flags) (gui-connection-flags fo-max)) + (set! (-> v1-2 fo-max) arg3) + ) + (when (>= arg4 0) + (logior! (-> v1-2 flags) (gui-connection-flags fo-curve)) + (set! (-> v1-2 fo-curve) arg4) + ) + (when (>= arg5 0.0) + (logior! (-> v1-2 flags) (gui-connection-flags volume)) + (set! (-> v1-2 volume) (the int (* 1024.0 arg5))) + ) + v1-2 + ) + ) + ) + ) + +;; WARN: Return type mismatch object vs symbol. +;; WARN: disable def twice: 34. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +(defmethod gui-control-method-18 ((this gui-control) (arg0 gui-channel)) + (let ((v1-0 arg0)) + (the-as + symbol + (cond + ((or (= v1-0 (gui-channel message)) (= v1-0 (gui-channel notice)) (= v1-0 (gui-channel notice-low))) + (not (or (logtest? (-> *art-control* frame-mask) 28) (!= *master-mode* 'game))) + ) + ((= v1-0 (gui-channel query)) + (and (not (or (logtest? (-> *art-control* frame-mask) 28) (!= *master-mode* 'game))) + (and *target* (not (logtest? (-> *target* focus-status) (focus-status dead hit)))) + ) + ) + (else + #t + ) + ) + ) + ) + ) + +(defmethod handle-command ((this gui-control) (arg0 gui-channel) (arg1 gui-channel) (arg2 symbol) (arg3 gui-connection)) + (let ((s5-0 (-> this ids arg1))) + (cond + ((nonzero? s5-0) + (case arg2 + (('wait) + (if (nonzero? (get-status this s5-0)) + (return #f) + ) + ) + (('stop 'priority-stop) + (when (nonzero? (-> this ids arg1)) + (let ((s2-0 (lookup-gui-connection this (the-as process #f) arg1 (the-as string #f) s5-0))) + (when (and s2-0 (or (= arg2 'priority) (= s2-0 arg3) (and arg3 (< (-> arg3 priority) (-> s2-0 priority))))) + (stop-str this s2-0) + (cond + ((= (shr (the-as int arg1) 4) 5) + (set! (-> this times arg1) + (the-as time-frame (max (-> this times arg1) (+ (-> *display* base-clock frame-counter) (seconds 0.1)))) + ) + (set! (-> s2-0 action) (gui-action hidden)) + ) + ((= arg1 (gui-channel query)) + (set! (-> s2-0 action) (gui-action play)) + ) + (else + (set! (-> s2-0 action) (gui-action hidden)) + ) + ) + ) + ) + ) + (if (nonzero? (get-status this s5-0)) + (return #f) + ) + ) + (('hide) + (let ((v1-34 (lookup-gui-connection this (the-as process #f) arg1 (the-as string #f) s5-0))) + (when (and v1-34 (!= (-> v1-34 action) 8)) + (set-action! + this + (gui-action hide) + s5-0 + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (set! (-> this times arg1) + (the-as time-frame (max (-> this times arg1) (+ (-> *display* base-clock frame-counter) (seconds 0.1)))) + ) + ) + ) + (if (nonzero? (get-status this s5-0)) + (return #f) + ) + ) + ) + ) + ((< (-> *display* base-clock frame-counter) (-> this times arg1)) + (if (= arg2 'wait) + (return #f) + ) + ) + ) + ) + #t + ) + +(defmethod handle-command-list ((this gui-control) (arg0 gui-channel) (arg1 gui-connection)) + (local-vars (sv-16 int) (sv-32 int) (sv-48 int)) + (let ((gp-0 #t)) + (cond + ((or (not (gui-control-method-18 this arg0)) (< (-> *display* base-clock frame-counter) (-> this times arg0))) + #f + ) + ((not (null? (-> this cmd arg0))) + (let* ((s2-0 (-> this cmd arg0)) + (v1-9 (car s2-0)) + ) + (while (not (null? s2-0)) + (let ((a2-1 (/ (the-as int (car v1-9)) 8)) + (s1-0 (cdr v1-9)) + ) + (case a2-1 + ((95) + (let ((s0-0 80)) + (set! sv-16 92) + (while (>= (the-as uint sv-16) (the-as uint s0-0)) + (if (not (handle-command this arg0 (the-as gui-channel s0-0) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-0 1) + ) + ) + ) + ((79) + (let ((s0-1 66)) + (set! sv-32 70) + (while (>= (the-as uint sv-32) (the-as uint s0-1)) + (if (not (handle-command this arg0 (the-as gui-channel s0-1) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-1 1) + ) + ) + ) + ((47) + (let ((s0-2 18)) + (set! sv-48 32) + (while (>= (the-as uint sv-48) (the-as uint s0-2)) + (if (not (handle-command this arg0 (the-as gui-channel s0-2) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-2 1) + ) + ) + ) + (else + (if (not (handle-command this arg0 (the-as gui-channel a2-1) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + ) + ) + ) + (set! s2-0 (cdr s2-0)) + (set! v1-9 (car s2-0)) + ) + ) + gp-0 + ) + ) + ) + ) + +;; WARN: Return type mismatch int vs gui-status. +(defmethod get-status ((this gui-control) (arg0 sound-id)) + (let ((gp-0 (the-as connectable #f))) + (if (zero? arg0) + (return (gui-status unknown)) + ) + (let ((v1-4 (-> this engine alive-list next0))) + (-> this engine) + (let ((a0-3 (-> v1-4 next0))) + (while (!= v1-4 (-> this engine alive-list-end)) + (when (= arg0 (-> (the-as gui-connection v1-4) id)) + (set! gp-0 v1-4) + (goto cfg-15) + ) + (set! v1-4 a0-3) + (-> this engine) + (set! a0-3 (-> a0-3 next0)) + ) + ) + ) + #t + (countdown (v1-10 32) + (let ((a0-7 (-> this connections v1-10))) + (when (= arg0 (-> a0-7 id)) + (set! gp-0 a0-7) + (goto cfg-15) + ) + ) + ) + (label cfg-15) + (the-as + gui-status + (cond + ((= (-> (the-as gui-connection gp-0) channel) (gui-channel movie)) + (cond + ((= (-> (the-as gui-connection gp-0) id) (-> this ids (-> (the-as gui-connection gp-0) channel))) + 3 + ) + ((handle-command-list this (-> (the-as gui-connection gp-0) channel) (the-as gui-connection gp-0)) + 2 + ) + (else + 1 + ) + ) + ) + ((let ((v1-22 (shr (the-as int (-> (the-as gui-connection gp-0) channel)) 4))) + (or (= v1-22 1) (= v1-22 2)) + ) + (case (-> (the-as gui-connection gp-0) action) + (((gui-action queue) (gui-action play) (gui-action playing) (gui-action fade) (gui-action stop)) + (cond + ((the-as gui-connection gp-0) + (dotimes (s4-0 4) + (when (and (string-charp= + (-> (the-as gui-connection gp-0) name) + (the-as (pointer uint8) (-> *sound-iop-info* stream-name s4-0)) + ) + (or (= (-> (the-as gui-connection gp-0) id) (-> *sound-iop-info* stream-id s4-0)) + (zero? (-> *sound-iop-info* stream-id s4-0)) + ) + (begin + (if (logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ss9)) + (return (gui-status stop)) + ) + (and (logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ss1 ss6)) + (if (and (>= (the-as uint (-> (the-as gui-connection gp-0) channel)) (the-as uint 16)) + (>= (the-as uint 17) (the-as uint (-> (the-as gui-connection gp-0) channel))) + ) + (= (file-status + *art-control* + (-> (the-as gui-connection gp-0) name) + (the-as int (-> (the-as gui-connection gp-0) anim-part)) + ) + 'active + ) + #t + ) + ) + ) + ) + (cond + ((logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ss4)) + (return (gui-status active)) + ) + ((or (= (-> (the-as gui-connection gp-0) id) (-> this ids (-> (the-as gui-connection gp-0) channel))) + (handle-command-list this (-> (the-as gui-connection gp-0) channel) (the-as gui-connection gp-0)) + ) + (return (gui-status ready)) + ) + (else + (return (gui-status pending)) + ) + ) + (the-as none 0) + ) + ) + 1 + ) + (else + 0 + ) + ) + ) + (else + 0 + ) + ) + ) + ((= (shr (the-as int (-> (the-as gui-connection gp-0) channel)) 4) 5) + (cond + ((= (-> (the-as gui-connection gp-0) id) (-> this ids (-> (the-as gui-connection gp-0) channel))) + (if (or (= (-> (the-as gui-connection gp-0) action) (gui-action hide)) + (= (-> (the-as gui-connection gp-0) action) (gui-action hidden)) + ) + 4 + 3 + ) + ) + ((handle-command-list this (-> (the-as gui-connection gp-0) channel) (the-as gui-connection gp-0)) + 2 + ) + (else + 1 + ) + ) + ) + (else + (case (shr (the-as int (-> (the-as gui-connection gp-0) channel)) 4) + ((4 5) + (cond + ((= (-> (the-as gui-connection gp-0) id) (-> this ids (-> (the-as gui-connection gp-0) channel))) + 3 + ) + ((handle-command-list this (-> (the-as gui-connection gp-0) channel) (the-as gui-connection gp-0)) + 2 + ) + (else + 1 + ) + ) + ) + (else + 0 + ) + ) + ) + ) + ) + ) + ) + +(defmethod set-action! ((this gui-control) + (arg0 gui-action) + (arg1 sound-id) + (arg2 gui-channel) + (arg3 gui-action) + (arg4 string) + (arg5 (function gui-connection symbol)) + (arg6 process) + ) + (local-vars (sv-16 gui-action) (sv-17 gui-action) (sv-20 string) (sv-24 (function gui-connection symbol))) + (set! sv-16 arg0) + (set! sv-17 arg3) + (set! sv-20 arg4) + (set! sv-24 arg5) + (let ((s1-0 (-> this engine alive-list next0))) + (-> this engine) + (let ((s0-0 (-> s1-0 next0))) + (while (!= s1-0 (-> this engine alive-list-end)) + (when (and (or (= arg1 1) (= arg1 (-> (the-as gui-connection s1-0) id))) + (or (= arg2 (gui-channel none)) (= arg2 (-> (the-as gui-connection s1-0) channel))) + (or (= sv-17 (gui-action none)) (= sv-17 (-> (the-as gui-connection s1-0) action))) + (or (not sv-20) (string= sv-20 (-> (the-as gui-connection s1-0) name))) + (or (not arg5) (arg5 (the-as gui-connection s1-0))) + (or (not arg6) (= arg6 (get-process (the-as gui-connection s1-0)))) + ) + (cond + ((and (= sv-16 (gui-action hide)) + (!= (-> this ids (-> (the-as gui-connection s1-0) channel)) (-> (the-as gui-connection s1-0) id)) + ) + (set! (-> (the-as gui-connection s1-0) action) (gui-action hidden)) + ) + ((and (= sv-16 (gui-action play)) (= (-> (the-as gui-connection s1-0) action) (gui-action playing))) + ) + (else + (set! (-> (the-as gui-connection s1-0) action) sv-16) + (if (and (= sv-16 'play) + (handle-command-list this (-> (the-as gui-connection s1-0) channel) (the-as gui-connection s1-0)) + ) + (channel-id-set! this (the-as gui-connection s1-0) (-> (the-as gui-connection s1-0) id)) + ) + ) + ) + ) + (set! s1-0 s0-0) + (-> this engine) + (set! s0-0 (-> s0-0 next0)) + ) + ) + ) + 0 + ) + +;; WARN: Return type mismatch int vs sound-id. +(defmethod add-process ((this gui-control) + (arg0 process) + (arg1 gui-channel) + (arg2 gui-action) + (arg3 string) + (arg4 float) + (arg5 time-frame) + ) + (local-vars + (sv-16 int) + (sv-20 gui-connection) + (sv-32 connectable) + (sv-48 connectable) + (sv-64 connectable) + (sv-80 int) + ) + (set! sv-32 (the-as connectable #f)) + (set! sv-48 (-> this engine alive-list next0)) + (-> this engine) + (set! sv-64 (-> sv-48 next0)) + (while (!= sv-48 (-> this engine alive-list-end)) + (when (and (= arg1 (-> (the-as gui-connection sv-48) channel)) + (string= arg3 (-> (the-as gui-connection sv-48) name)) + (= ((method-of-type gui-connection get-process) (the-as connection sv-48)) arg0) + ) + (set! sv-32 sv-48) + (goto cfg-12) + ) + (set! sv-48 sv-64) + (-> this engine) + (set! sv-64 (-> sv-64 next0)) + ) + (label cfg-12) + (when (not sv-32) + (set! sv-16 0) + (set! sv-80 32) + (while (nonzero? sv-80) + (set! sv-80 (+ sv-80 -1)) + (set! sv-20 (-> this connections sv-80)) + (if (and (nonzero? (-> sv-20 id)) + (= arg1 (-> sv-20 channel)) + (string= arg3 (-> sv-20 name)) + (>= (-> sv-20 priority) -1.0) + ) + (set! sv-16 (the-as int (-> sv-20 id))) + ) + ) + (if (zero? sv-16) + (set! sv-16 (the-as int (new-sound-id))) + ) + (set! sv-32 (add-connection (-> this engine) arg0 arg4 0 arg3 sv-16)) + (the-as connection sv-32) + ) + (the-as sound-id (cond + (sv-32 + (set! (-> (the-as gui-connection sv-32) priority) arg4) + (set! (-> (the-as gui-connection sv-32) channel) arg1) + (set! (-> (the-as gui-connection sv-32) action) arg2) + (set! (-> (the-as gui-connection sv-32) param2) (the-as int arg3)) + (set! (-> (the-as gui-connection sv-32) hold-time) arg5) + (set! (-> (the-as gui-connection sv-32) flags) (gui-connection-flags gcf0)) + (set! (-> (the-as gui-connection sv-32) fade) (the-as uint 0)) + (the-as int (-> (the-as gui-connection sv-32) id)) + ) + (else + (format 0 "ERROR: could not connection ~A to gui engine.~%" arg0) + 0 + ) + ) + ) + ) + +(defmethod remove-process ((this gui-control) (arg0 process) (arg1 gui-channel)) + (let ((con-i-0 (the-as gui-connection (-> this engine alive-list next0)))) + (-> this engine) + (let ((s2-0 (-> (the-as connectable con-i-0) next0))) + (while (!= con-i-0 (-> this engine alive-list-end)) + (if (and (= arg1 (-> con-i-0 channel)) (= arg0 (get-process con-i-0))) + (move-to-dead con-i-0) + ) + (set! con-i-0 (the-as gui-connection s2-0)) + (-> this engine) + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + 0 + ) + +;; WARN: Return type mismatch int vs sound-id. +(defmethod gui-control-method-12 ((this gui-control) + (arg0 process) + (arg1 gui-channel) + (arg2 gui-action) + (arg3 string) + (arg4 int) + (arg5 float) + (arg6 sound-id) + ) + (local-vars + (sv-16 gui-connection) + (sv-20 int) + (sv-24 gui-connection) + (sv-28 process) + (sv-32 int) + (sv-48 sound-id) + ) + (set! sv-48 arg6) + (set! sv-16 (the-as gui-connection #f)) + (set! sv-20 0) + (set! sv-32 32) + (while (nonzero? sv-32) + (set! sv-32 (+ sv-32 -1)) + (set! sv-24 (-> this connections sv-32)) + (when (and (nonzero? (-> sv-24 id)) + (= arg1 (-> sv-24 channel)) + (let ((v1-14 (handle->process (-> sv-24 handle)))) + (and (or (= v1-14 arg0) (= (-> arg0 type) scene-player) (and v1-14 (= (-> v1-14 type) scene-player))) + (and (string= arg3 (-> sv-24 name)) (= arg4 (-> sv-24 anim-part))) + ) + ) + ) + (when (< (-> sv-24 priority) arg5) + (set! (-> sv-24 time-stamp) (-> this update-time)) + (return (the-as sound-id (-> sv-24 id))) + ) + (set! sv-16 sv-24) + (goto cfg-44) + ) + ) + (countdown (v1-33 32) + (let ((a0-15 (-> this connections v1-33))) + (when (or (zero? (-> a0-15 id)) (not (handle->process (-> a0-15 handle)))) + (set! sv-16 a0-15) + (set! (-> sv-16 param3) 0) + (set! (-> sv-16 flags) (gui-connection-flags)) + (goto cfg-44) + ) + ) + ) + (label cfg-44) + (the-as + sound-id + (cond + (sv-16 + (when (zero? (-> (the-as gui-connection sv-16) id)) + (when (zero? sv-20) + (let ((v1-46 (lookup-gui-connection this arg0 arg1 arg3 (new 'static 'sound-id)))) + (if v1-46 + (set! sv-20 (the-as int (-> v1-46 id))) + ) + ) + ) + (if (zero? sv-20) + (set! sv-20 (the-as int sv-48)) + ) + (set! (-> sv-16 param3) (if (nonzero? sv-20) + sv-20 + (the-as int (new-sound-id)) + ) + ) + ) + (when (= arg5 -99.0) + (let ((s2-1 arg0)) + (set! sv-28 (if (type? s2-1 process-drawable) + s2-1 + ) + ) + ) + (set! arg5 (if sv-28 + (vector-vector-distance (target-pos 0) (-> (the-as process-drawable sv-28) root trans)) + -1.0 + ) + ) + ) + (set! (-> sv-16 time-stamp) (-> this update-time)) + (set! (-> sv-16 handle) (process->handle arg0)) + (set! (-> sv-16 priority) arg5) + (set! (-> sv-16 channel) arg1) + (set! (-> sv-16 action) arg2) + (set! (-> sv-16 anim-part) (the-as uint arg4)) + (set! (-> sv-16 param2) (the-as int arg3)) + (set! (-> sv-16 fade) (the-as uint 0)) + (the-as int (-> (the-as gui-connection sv-16) id)) + ) + (else + 0 + ) + ) + ) + ) + +(defmethod gui-control-method-22 ((this gui-control) (arg0 gui-connection) (arg1 vector)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (let ((s5-0 (-> this spool-connections))) + (case (-> arg0 action) + (((gui-action queue) (gui-action play) (gui-action playing) (gui-action fade)) + (let ((f30-0 (-> arg0 priority))) + (when (= f30-0 -99.0) + (let* ((s2-0 (get-process arg0)) + (v1-10 (if (type? s2-0 process-drawable) + s2-0 + ) + ) + ) + (set! f30-0 (cond + ((= (-> arg0 id) (-> this ids (-> arg0 channel))) + -1.0 + ) + (v1-10 + (vector-vector-distance arg1 (-> (the-as process-drawable v1-10) root trans)) + ) + (else + -1.0 + ) + ) + ) + ) + ) + (dotimes (s4-1 4) + (cond + ((>= (-> s5-0 s4-1 priority) f30-0) + (let ((s3-1 s4-1)) + (while (< s3-1 4) + (when (= (-> s5-0 s3-1 id) (-> arg0 id)) + (let ((s2-1 s3-1)) + (while (< s2-1 3) + (mem-copy! (the-as pointer (-> s5-0 s2-1)) (the-as pointer (-> s5-0 (+ s2-1 1))) 48) + (+! s2-1 1) + ) + ) + (set! (-> s5-0 3 param2) (the-as int "")) + (set! (-> s5-0 3 priority) 100000000.0) + ) + (+! s3-1 1) + ) + ) + (let ((s3-2 3)) + (while (!= s3-2 s4-1) + (mem-copy! (the-as pointer (-> s5-0 s3-2)) (the-as pointer (-> s5-0 (+ s3-2 -1))) 48) + (+! s3-2 -1) + ) + ) + (mem-copy! (the-as pointer (-> s5-0 s4-1)) (the-as pointer arg0) 48) + (set! (-> s5-0 s4-1 priority) f30-0) + (goto cfg-42) + ) + ((= (-> s5-0 s4-1 id) (-> arg0 id)) + (goto cfg-42) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (label cfg-42) + 0 + ) + +(defmethod stop-str ((this gui-control) (arg0 gui-connection)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (if (= (get-status this (-> arg0 id)) (gui-status active)) + (str-play-stop (-> arg0 name) (-> arg0 id)) + ) + ) + ) + (if (= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! this arg0 (new 'static 'sound-id)) + ) + 0 + ) + +(defmethod gui-control-method-21 ((this gui-control) (arg0 gui-connection)) + (with-pp + (when *sound-player-enable* + (let ((gp-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> gp-0 command) (sound-command set-param)) + (set! (-> gp-0 id) (-> arg0 id)) + (set! (-> gp-0 params mask) (the-as uint 0)) + (when (logtest? (-> arg0 flags) (gui-connection-flags gcf1)) + (let* ((s4-0 (get-process arg0)) + (v1-8 (if (type? s4-0 process-drawable) + s4-0 + ) + ) + ) + (when (and v1-8 (nonzero? (-> (the-as process-drawable v1-8) root))) + (let ((a1-3 (-> (the-as process-drawable v1-8) root trans))) + (let ((s4-1 pp)) + (when (= a1-3 #t) + (if (and s4-1 (type? s4-1 process-drawable) (nonzero? (-> (the-as process-drawable s4-1) root))) + (set! a1-3 (-> (the-as process-drawable s4-1) root trans)) + (set! a1-3 (the-as vector #f)) + ) + ) + ) + (sound-trans-convert (-> gp-0 params trans) a1-3) + ) + (logior! (-> gp-0 params mask) 32) + ) + ) + ) + (set! (-> gp-0 params fo-curve) (-> arg0 fo-curve)) + (set! (-> gp-0 params fo-min) (-> arg0 fo-min)) + (set! (-> gp-0 params fo-max) (-> arg0 fo-max)) + (set! (-> gp-0 params volume) (-> arg0 volume)) + (if (logtest? (-> arg0 flags) (gui-connection-flags fo-curve)) + (logior! (-> gp-0 params mask) 256) + ) + (if (logtest? (-> arg0 flags) (gui-connection-flags fo-min)) + (logior! (-> gp-0 params mask) 64) + ) + (if (logtest? (-> arg0 flags) (gui-connection-flags fo-max)) + (logior! (-> gp-0 params mask) 128) + ) + (if (logtest? (-> arg0 flags) (gui-connection-flags volume)) + (logior! (-> gp-0 params mask) 1) + ) + ) + ) + 0 + ) + ) + +(defmethod update-connection ((this gui-control) (arg0 gui-connection) (arg1 process) (arg2 symbol)) + (local-vars (v1-75 symbol)) + (when (and (>= (the-as uint (-> arg0 channel)) (the-as uint 16)) + (>= (the-as uint 17) (the-as uint (-> arg0 channel))) + ) + (case (-> arg0 action) + (((gui-action queue)) + (spool-push *art-control* (-> arg0 name) (the-as int (-> arg0 anim-part)) arg1 (-> arg0 priority)) + (if (and (logtest? (-> arg0 flags) (gui-connection-flags gcf0)) + (= (get-status this (-> arg0 id)) (gui-status active)) + ) + (set! (-> arg0 action) (gui-action playing)) + ) + ) + ) + ) + (let ((v1-16 (-> arg0 action))) + (b! (!= v1-16 (gui-action play)) cfg-47 :delay (empty-form)) + (if (handle-command-list this (-> arg0 channel) arg0) + (channel-id-set! this arg0 (-> arg0 id)) + ) + (let ((s3-0 (get-status this (-> arg0 id)))) + (if (and (logtest? (-> arg0 flags) (gui-connection-flags gcf1 fo-curve fo-min fo-max volume)) + (logtest? (-> arg0 flags) (gui-connection-flags gcf0)) + ) + (gui-control-method-21 this arg0) + ) + (cond + ((or (not (gui-control-method-18 this (-> arg0 channel))) (= s3-0 (gui-status stop))) + (if (= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! this arg0 (new 'static 'sound-id)) + ) + (if (and arg2 (or (< (shr (the-as int (-> arg0 channel)) 4) (the-as uint 4)) (= s3-0 (gui-status stop)))) + (move-to-dead arg0) + ) + ) + ((= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (cond + ((= s3-0 (gui-status ready)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (if (not (paused?)) + (str-play-async + (-> arg0 name) + (-> arg0 id) + (if (logtest? (-> arg0 flags) (gui-connection-flags volume)) + (-> arg0 volume) + 1024 + ) + (the-as int (-> this group (-> arg0 channel))) + ) + ) + ) + ) + ) + ((= s3-0 (gui-status active)) + (set! (-> arg0 action) (gui-action playing)) + ) + ) + ) + ) + ) + (b! #t cfg-124 :delay (nop!)) + (label cfg-47) + (b! (not (or (= v1-16 (gui-action playing)) (= v1-16 (gui-action fade)))) cfg-102 :delay (empty-form)) + (b! + (not (and (= (get-status this (-> arg0 id)) (gui-status active)) + (gui-control-method-18 this (-> arg0 channel)) + (or (= (-> arg0 action) (gui-action playing)) (< (-> arg0 fade) (the-as uint 30))) + ) + ) + cfg-91 + :delay (nop!) + ) + (channel-id-set! this arg0 (-> arg0 id)) + (set! (-> this times 0) 0) + (let ((v1-73 (shr (the-as int (-> arg0 channel)) 4))) + (set! v1-75 + (and (or (= v1-73 1) (= v1-73 2)) + (not (and (>= (the-as uint (-> arg0 channel)) (the-as uint 16)) + (>= (the-as uint 17) (the-as uint (-> arg0 channel))) + ) + ) + (begin + (dotimes (s3-1 4) + (when (and (string-charp= (-> arg0 name) (the-as (pointer uint8) (-> *sound-iop-info* stream-name s3-1))) + (= (-> arg0 id) (-> *sound-iop-info* stream-id s3-1)) + (logtest? (-> *sound-iop-info* stream-status s3-1) (stream-status ss6)) + ) + (set! v1-75 #t) + (goto cfg-81) + ) + ) + #f + ) + ) + ) + ) + (label cfg-81) + (b! v1-75 cfg-91 :delay (nop!)) + (if (and (logtest? (-> arg0 flags) (gui-connection-flags gcf1 fo-curve fo-min fo-max volume)) + (logtest? (-> arg0 flags) (gui-connection-flags gcf0)) + ) + (gui-control-method-21 this arg0) + ) + (when (= (-> arg0 action) (gui-action fade)) + (set! (-> arg0 fade) (the-as uint (seekl (the-as int (-> arg0 fade)) 30 1))) + (when *sound-player-enable* + (let ((s5-1 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> s5-1 command) (sound-command set-param)) + (set! (-> s5-1 id) (-> arg0 id)) + (set! (-> s5-1 params volume) (the int (* 1024.0 (lerp-scale 1.0 0.0 (the float (-> arg0 fade)) 0.0 30.0)))) + (set! (-> s5-1 params mask) (the-as uint 1)) + (-> s5-1 id) + ) + ) + ) + (b! #t cfg-101 :delay (nop!)) + (label cfg-91) + (when (= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! this arg0 (new 'static 'sound-id)) + (set! (-> this times (-> arg0 channel)) (+ (-> *display* base-clock frame-counter) (-> arg0 hold-time))) + ) + (if (and arg2 (or (< (shr (the-as int (-> arg0 channel)) 4) (the-as uint 4)) + (= (get-status this (-> arg0 id)) (gui-status stop)) + ) + ) + (move-to-dead arg0) + (set! (-> arg0 action) (gui-action play)) + ) + (label cfg-101) + (b! #t cfg-124 :delay (nop!)) + (label cfg-102) + (cond + ((= v1-16 (gui-action stop)) + (stop-str this arg0) + (if arg2 + (move-to-dead arg0) + ) + ) + ((= v1-16 (gui-action abort)) + (if (= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! this arg0 (new 'static 'sound-id)) + ) + (if arg2 + (move-to-dead arg0) + ) + ) + ((= v1-16 (gui-action hide)) + ) + ((= v1-16 (gui-action hidden)) + (cond + ((or (< (shr (the-as int (-> arg0 channel)) 4) (the-as uint 4)) + (= (get-status this (-> arg0 id)) (gui-status stop)) + ) + (stop-str this arg0) + (if arg2 + (move-to-dead arg0) + ) + ) + (else + (if (= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! this arg0 (new 'static 'sound-id)) + ) + ) + ) + ) + ) + ) + (label cfg-124) + 0 + (none) + ) + +(defmethod update ((this gui-control) (arg0 symbol)) + (set! (-> this ids 65) + (the-as sound-id (if (and (>= (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (= (-> *setting-control* user-current bg-a) 0.0) + (= (-> *setting-control* user-current bg-a-force) 0.0) + ) + 0 + 1 + ) + ) + ) + (let ((s4-0 (target-pos 0))) + (dotimes (v1-8 4) + (set! (-> this spool-connections v1-8 param2) (the-as int #f)) + (set! (-> this spool-connections v1-8 param3) 0) + (set! (-> this spool-connections v1-8 priority) 100000000.0) + ) + (let ((con-i-0 (the-as gui-connection (-> this engine alive-list next0)))) + (-> this engine) + (let ((s2-0 (-> (the-as connectable con-i-0) next0))) + (while (!= (the-as connectable con-i-0) (-> this engine alive-list-end)) + (gui-control-method-22 this con-i-0 s4-0) + (case (-> con-i-0 action) + (((gui-action playing)) + (channel-id-set! this con-i-0 (-> con-i-0 id)) + ) + ) + (set! con-i-0 (the-as gui-connection s2-0)) + (-> this engine) + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + (let ((s3-1 (-> this update-time))) + (countdown (s2-1 32) + (let ((s1-0 (-> this connections s2-1))) + (when (nonzero? (-> s1-0 id)) + (cond + ((= (-> s1-0 time-stamp) s3-1) + (gui-control-method-22 this s1-0 s4-0) + ) + (else + (if (= (-> this ids (-> s1-0 channel)) (-> s1-0 id)) + (channel-id-set! this s1-0 (new 'static 'sound-id)) + ) + (set! (-> s1-0 param3) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (let ((s4-1 (new 'stack-no-clear 'array 'sound-id 4)) + (s3-2 0) + ) + (let ((s2-2 (-> *setting-control* user-current movie-name))) + (dotimes (s1-1 4) + (set! (-> s4-1 s1-1) (-> this spool-connections s1-1 id)) + (when (and (-> this spool-connections s1-1 name) (case (-> this spool-connections s1-1 channel) + (((gui-channel art-load) (gui-channel art-load-next)) + #t + ) + ) + ) + (set! s3-2 (logior s3-2 (ash 1 s1-1))) + (if (and s2-2 (string= (-> this spool-connections s1-1 name) (the-as string s2-2))) + (set! s3-2 (logior s3-2 (ash 1 (+ s1-1 4)))) + ) + ) + ) + ) + (let* ((t9-6 str-play-queue) + (v1-69 (-> this spool-connections 0 name)) + (a0-32 (if v1-69 + v1-69 + ) + ) + (v1-70 (-> this spool-connections 1 name)) + (a1-7 (if v1-70 + v1-70 + ) + ) + (v1-71 (-> this spool-connections 2 name)) + (a2-4 (if v1-71 + v1-71 + ) + ) + (v1-72 (-> this spool-connections 3 name)) + ) + (t9-6 + a0-32 + a1-7 + a2-4 + (if v1-72 + v1-72 + ) + s4-1 + (the-as pointer s3-2) + ) + ) + ) + (-> this engine) + (let ((con-i-1 (the-as gui-connection (-> this engine alive-list-end prev0)))) + (-> this engine) + (let ((s4-2 (-> (the-as connectable con-i-1) prev0))) + (while (!= (the-as connectable con-i-1) (-> this engine alive-list)) + (update-connection this con-i-1 ((method-of-type connection get-process) (the-as connection con-i-1)) #t) + (set! con-i-1 (the-as gui-connection s4-2)) + (-> this engine) + (set! s4-2 (-> s4-2 prev0)) + ) + ) + ) + (countdown (s4-3 32) + (let ((v1-91 (-> this connections s4-3))) + (if (nonzero? (-> v1-91 id)) + (update-connection this v1-91 (handle->process (-> v1-91 handle)) #f) + ) + ) + ) + (when arg0 + (when *display-art-control* + (dotimes (s5-1 4) + (let ((a3-4 (-> this spool-connections s5-1))) + (if (-> a3-4 name) + (format *stdcon* "~D: ~`gui-connection`P~%" s5-1 a3-4) + ) + ) + ) + (dotimes (s5-2 4) + (format + *stdcon* + "~0KCh ~D: ~8D ~5X ~6D ~G~1K~%" + s5-2 + (-> *sound-iop-info* stream-id-signed s5-2) + (-> *sound-iop-info* stream-status s5-2) + (-> *sound-iop-info* stream-position s5-2) + (-> *sound-iop-info* stream-name s5-2) + ) + ) + ) + (when *display-gui-control* + (-> this engine) + (let ((a2-12 (-> this engine alive-list-end prev0))) + (-> this engine) + (let ((s5-3 (-> a2-12 prev0))) + (while (!= a2-12 (-> this engine alive-list)) + (format *stdcon* "c: ~`gui-connection`P~%" a2-12) + (set! a2-12 s5-3) + (-> this engine) + (set! s5-3 (-> s5-3 prev0)) + ) + ) + ) + (countdown (s5-4 32) + (let ((a2-13 (-> this connections s5-4))) + (if (nonzero? (-> a2-13 id)) + (format *stdcon* "l: ~`gui-connection`P~%" a2-13) + ) + ) + ) + ) + ) + (set! (-> this update-time) (-> *display* base-clock frame-counter)) + 0 + ) + +(defmethod new gui-control ((allocation symbol) (type-to-make type) (arg0 int)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> gp-0 engine) ((method-of-type engine new) allocation engine 'gui-control arg0 gui-connection)) + (dotimes (v1-3 32) + (set! (-> gp-0 connections v1-3 handle) (the-as handle #f)) + ) + (dotimes (v1-6 96) + (set! (-> gp-0 cmd v1-6) '()) + (set! (-> gp-0 group v1-6) (sound-group music)) + ) + (set! (-> gp-0 cmd 64) '((64 . wait) (72 . wait) (65 . wait) (66 . stop) (95 . stop))) + (set! (-> gp-0 cmd 72) '((64 . wait) (72 . wait) (65 . wait) (66 . stop) (95 . hide))) + (set! (-> gp-0 cmd 73) '((64 . wait) (73 . wait) (65 . wait) (66 . stop) (67 . stop) (95 . hide))) + (set! (-> gp-0 cmd 74) '((64 . wait) (72 . wait) (65 . wait) (73 . wait) (87 . hide) (89 . hide))) + (set! (-> gp-0 cmd 66) + '((64 . wait) + (65 . wait) + (68 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + (92 . hide) + ) + ) + (set! (-> gp-0 cmd 67) + '((64 . wait) + (65 . wait) + (68 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + (82 . hide) + (92 . hide) + ) + ) + (set! (-> gp-0 cmd 68) + '((65 . wait) + (68 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + (82 . hide) + (92 . hide) + ) + ) + (set! (-> gp-0 cmd 71) + '((65 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + (82 . hide) + (92 . hide) + ) + ) + (set! (-> gp-0 cmd 69) '((65 . wait) (71 . wait) (67 . wait) (66 . wait))) + (set! (-> gp-0 cmd 70) '((65 . wait) (90 . hide) (91 . hide) (81 . hide) (80 . hide) (94 . wait))) + (set! (-> gp-0 cmd 80) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (80 . wait) (70 . wait))) + (set! (-> gp-0 cmd 81) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (81 . wait) (70 . wait))) + (set! (-> gp-0 cmd 82) + '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (67 . wait) (71 . wait) (69 . wait) (82 . wait)) + ) + (set! (-> gp-0 cmd 83) + '((64 . wait) + (72 . wait) + (73 . wait) + (65 . wait) + (67 . wait) + (71 . wait) + (69 . wait) + (66 . wait) + (83 . wait) + (84 . hide) + (85 . hide) + ) + ) + (set! (-> gp-0 cmd 84) + '((64 . wait) + (72 . wait) + (73 . wait) + (65 . wait) + (67 . wait) + (71 . wait) + (69 . wait) + (66 . wait) + (83 . wait) + (84 . wait) + ) + ) + (set! (-> gp-0 cmd 85) + '((64 . wait) + (72 . wait) + (73 . wait) + (65 . wait) + (67 . wait) + (71 . wait) + (69 . wait) + (66 . wait) + (83 . wait) + (85 . wait) + ) + ) + (set! (-> gp-0 cmd 86) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (86 . wait) (93 . wait))) + (set! (-> gp-0 cmd 87) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (87 . wait) (74 . wait))) + (set! (-> gp-0 cmd 88) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (88 . wait) (93 . wait))) + (set! (-> gp-0 cmd 89) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (89 . wait) (74 . wait))) + (set! (-> gp-0 cmd 92) + '((64 . wait) + (72 . wait) + (73 . wait) + (65 . wait) + (92 . wait) + (69 . wait) + (68 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + ) + ) + (set! (-> gp-0 cmd 90) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (90 . wait) (70 . wait))) + (set! (-> gp-0 cmd 91) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (91 . wait) (70 . wait))) + (set! (-> gp-0 cmd 93) '((65 . wait) (86 . hide) (88 . hide))) + (set! (-> gp-0 cmd 94) '((65 . wait) (94 . wait) (70 . hide))) + (set! (-> gp-0 cmd 16) '((16 . wait))) + (set! (-> gp-0 cmd 17) '((17 . wait))) + (set! (-> gp-0 cmd 18) '((18 . wait))) + (set! (-> gp-0 cmd 27) '((27 . wait))) + (set! (-> gp-0 cmd 31) '((31 . wait))) + (set! (-> gp-0 cmd 24) '((64 . wait) (24 . wait))) + (set! (-> gp-0 cmd 26) '((64 . wait) (26 . wait))) + (set! (-> gp-0 cmd 36) '((64 . wait) (36 . wait))) + (set! (-> gp-0 cmd 32) '((64 . wait) (32 . wait))) + (set! (-> gp-0 cmd 30) '((64 . wait) (30 . wait))) + (set! (-> gp-0 cmd 33) '((64 . wait) (33 . wait))) + (set! (-> gp-0 cmd 34) '((64 . wait) (34 . wait))) + (set! (-> gp-0 cmd 20) '((64 . wait) (20 . wait) (19 . wait) (29 . wait) (25 . wait))) + (set! (-> gp-0 cmd 19) '((64 . wait) (20 . wait) (19 . wait) (29 . wait) (25 . wait))) + (set! (-> gp-0 cmd 25) '((64 . wait) (20 . wait) (19 . wait) (29 . wait) (25 . wait))) + (set! (-> gp-0 cmd 29) '((64 . wait) (20 . wait) (19 . wait) (29 . wait) (25 . wait))) + (set! (-> gp-0 cmd 21) + '((64 . wait) (21 . wait) (22 . wait) (23 . wait) (25 . wait) (19 . wait) (28 . wait) (35 . wait)) + ) + (set! (-> gp-0 cmd 22) + '((64 . wait) (21 . wait) (22 . wait) (23 . wait) (25 . wait) (19 . wait) (28 . wait) (35 . wait)) + ) + (set! (-> gp-0 cmd 23) + '((64 . wait) (21 . wait) (22 . wait) (23 . wait) (25 . wait) (19 . wait) (28 . wait) (35 . wait)) + ) + (set! (-> gp-0 cmd 28) + '((64 . wait) (21 . wait) (22 . wait) (23 . wait) (25 . wait) (19 . wait) (28 . wait) (35 . wait)) + ) + (set! (-> gp-0 cmd 35) + '((64 . wait) (21 . wait) (22 . wait) (23 . wait) (25 . wait) (19 . wait) (28 . wait) (35 . wait)) + ) + (set! (-> gp-0 group 18) (sound-group)) + (set! (-> gp-0 group 27) (sound-group)) + (set! (-> gp-0 group 31) (sound-group)) + (set! (-> gp-0 group 24) (sound-group music dialog)) + (set! (-> gp-0 group 26) (sound-group music dialog)) + (set! (-> gp-0 group 36) (sound-group music dialog)) + gp-0 + ) + ) + +(kmemopen global "gui-controls") + +(define *gui-control* (new 'global 'gui-control 64)) + +(if (zero? *art-control*) + (set! *art-control* (new 'global 'external-art-control)) + ) + +(kmemclose) diff --git a/goal_src/jak3/engine/process-drawable/process-drawable-h.gc b/goal_src/jak3/engine/process-drawable/process-drawable-h.gc index 3f7b9481ef..802e15dab6 100644 --- a/goal_src/jak3/engine/process-drawable/process-drawable-h.gc +++ b/goal_src/jak3/engine/process-drawable/process-drawable-h.gc @@ -10,6 +10,11 @@ (define-extern joint-control-reset! (function joint-control joint-control-channel none :behavior process-drawable)) (define-extern sleep-code (function symbol :behavior process)) (define-extern vector<-matrix! (function vector matrix vector)) +(define-extern ja-channel-push! (function int time-frame int :behavior process-drawable)) +(define-extern ja-channel-set! (function int int :behavior process-drawable)) +(define-extern ja-aframe-num (function int float :behavior process-drawable)) +(define-extern ja-frame-num (function int float :behavior process-drawable)) +(define-extern ja-aframe (function float int float :behavior process-drawable)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/sound/gsound-h.gc b/goal_src/jak3/engine/sound/gsound-h.gc index f90fcba562..0a4b4a3de0 100644 --- a/goal_src/jak3/engine/sound/gsound-h.gc +++ b/goal_src/jak3/engine/sound/gsound-h.gc @@ -63,6 +63,14 @@ (defenum sound-group :bitfield #t :type uint8 + (sfx) + (music) + (dialog) ;; same as jak 1 dialog + (sog3) + (ambient) + (dialog2) ;; more dialog + (sog6) + (sog7) ) (defenum sound-mask @@ -91,6 +99,7 @@ (ss1 1) ;; id-is-playing (ss4 4) ;; is-playing (ss6 6) ;; id-is-playing + (ss9 9) ) (defmacro static-sound-name (str) diff --git a/goal_src/jak3/engine/sound/gsound.gc b/goal_src/jak3/engine/sound/gsound.gc index d1d6edc7f6..b8ecddb865 100644 --- a/goal_src/jak3/engine/sound/gsound.gc +++ b/goal_src/jak3/engine/sound/gsound.gc @@ -47,36 +47,37 @@ ) (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) + ((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) + (stream-id-signed int32 4 :overlay-at (-> stream-id 0)) + (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) ) ) diff --git a/goal_src/jak3/engine/ui/gui-h.gc b/goal_src/jak3/engine/ui/gui-h.gc index 234957553b..ff610dd4ae 100644 --- a/goal_src/jak3/engine/ui/gui-h.gc +++ b/goal_src/jak3/engine/ui/gui-h.gc @@ -14,6 +14,7 @@ (fo-curve 2) (fo-min 3) (fo-max 4) + (volume 5) ) ;; ---gui-connection-flags @@ -133,4 +134,36 @@ ) -;; type gui-control is defined here, but it is unknown to the decompiler +(deftype gui-control (basic) + ((engine engine) + (update-time time-frame) + (connections gui-connection 32 :inline) + (spool-connections gui-connection 4 :inline) + (ids sound-id 96) + (times time-frame 96) + (cmd pair 96) + (group sound-group 96) + ) + (:methods + (new (symbol type int) _type_) + (add-process (_type_ process gui-channel gui-action string float time-frame) sound-id) + (remove-process (_type_ process gui-channel) int) + (stop-str (_type_ gui-connection) int) + (gui-control-method-12 (_type_ process gui-channel gui-action string int float sound-id) sound-id) + (update (_type_ symbol) int) + (lookup-gui-connection-id (_type_ string gui-channel gui-action) sound-id) + (lookup-gui-connection (_type_ process gui-channel string sound-id) gui-connection) + (set-action! (_type_ gui-action sound-id gui-channel gui-action string (function gui-connection symbol) process) int) + (get-status (_type_ sound-id) gui-status) + (gui-control-method-18 (_type_ gui-channel) symbol) + (handle-command-list (_type_ gui-channel gui-connection) symbol) + (sound-params-set! (_type_ sound-id symbol int int int float) gui-connection) + (gui-control-method-21 (_type_ gui-connection) int) + (gui-control-method-22 (_type_ gui-connection vector) int) + (update-connection (_type_ gui-connection process symbol) none) + (handle-command (_type_ gui-channel gui-channel symbol gui-connection) symbol) + (channel-id-set! (_type_ gui-connection sound-id) int) + ) + ) + +(define-extern *gui-control* gui-control) diff --git a/scripts/batch/decomp-jak3.bat b/scripts/batch/decomp-jak3.bat new file mode 100644 index 0000000000..970b24d7b3 --- /dev/null +++ b/scripts/batch/decomp-jak3.bat @@ -0,0 +1,4 @@ +@echo off +cd ..\.. +out\build\Release\bin\decompiler decompiler\config\jak3\jak3_config.jsonc iso_data\ decompiler_out\ --version ntsc_v1 +pause diff --git a/scripts/batch/decomp-jak3_pal.bat b/scripts/batch/decomp-jak3_pal.bat new file mode 100644 index 0000000000..dc9b03c6a4 --- /dev/null +++ b/scripts/batch/decomp-jak3_pal.bat @@ -0,0 +1,4 @@ +@echo off +cd ..\.. +out\build\Release\bin\decompiler decompiler\config\jak3\jak3_config.jsonc iso_data\ decompiler_out\ --version pal +pause diff --git a/scripts/batch/extract-jak3.bat b/scripts/batch/extract-jak3.bat new file mode 100644 index 0000000000..52c4138f80 --- /dev/null +++ b/scripts/batch/extract-jak3.bat @@ -0,0 +1,6 @@ +@echo off +cd ..\.. +task set-game-jak3 +task set-decomp-ntscv1 +task extract +pause diff --git a/scripts/batch/gc3.bat b/scripts/batch/gc3.bat new file mode 100644 index 0000000000..36a0dad554 --- /dev/null +++ b/scripts/batch/gc3.bat @@ -0,0 +1,4 @@ +@echo off +cd ..\.. +out\build\Release\bin\goalc --user-auto --game jak3 +pause diff --git a/scripts/batch/gk3.bat b/scripts/batch/gk3.bat new file mode 100644 index 0000000000..314162b3f3 --- /dev/null +++ b/scripts/batch/gk3.bat @@ -0,0 +1,4 @@ +@echo off +cd ..\.. +out\build\Release\bin\gk -v --no-display --game jak3 -- -fakeiso -debug +pause diff --git a/scripts/batch/test3-offline-and-update.bat b/scripts/batch/test3-offline-and-update.bat new file mode 100644 index 0000000000..e1f3b653e2 --- /dev/null +++ b/scripts/batch/test3-offline-and-update.bat @@ -0,0 +1,6 @@ +@echo off +cd ..\.. +out\build\Release\bin\offline-test -d --iso_data_path iso_data\jak3\ --game jak3 +python3 scripts\update_decomp_reference.py failures\ test\decompiler\reference\ --game jak3 +RMDIR /Q/S failures +pause \ No newline at end of file diff --git a/scripts/batch/test3-types.bat b/scripts/batch/test3-types.bat new file mode 100644 index 0000000000..300bf4b542 --- /dev/null +++ b/scripts/batch/test3-types.bat @@ -0,0 +1,4 @@ +@echo off +cd ..\.. +out\build\Release\bin\goalc-test --gtest_filter="Jak3TypeConsistency.TypeConsistency" +pause \ No newline at end of file diff --git a/test/decompiler/reference/jak3/decompiler-macros.gc b/test/decompiler/reference/jak3/decompiler-macros.gc index d55bd15557..b199b98c2c 100644 --- a/test/decompiler/reference/jak3/decompiler-macros.gc +++ b/test/decompiler/reference/jak3/decompiler-macros.gc @@ -997,4 +997,133 @@ (.ftoi.vf ,dst temp) ) ) + ) + +(defmacro ja-group (&key (chan 0)) + "get the frame group for self. default channel is 0, the base channel. returns #f if no frame group." + `(if (> (-> self skel active-channels) ,chan) + (-> self skel root-channel ,chan frame-group)) + ) + +(defmacro ja (&key (chan 0) + &key (group! #f) + &key (num! #f) + &key (param0 #f) + &key (param1 #f) + &key (num-func #f) + &key (frame-num #f) + &key (frame-interp #f) + &key (dist #f) + &key (eval? #t) + ) + "set various joint anim parameters for self and eval them. + you can use this for playing animations! + chan = the channel to modify. defaults to 0 (base channel). this is usually what you want. + group! = when not #f, set this as the new frame-group. defaults to #f + num! = set the frame playback function. this is what determines what frame an animation is at. funcs below. + #f = no func will be set, and there wont be a frame eval. + num-func = sets the num-func field for the channel. this lets you change the function with eval'ing. + param0 = 1st parameter for the playback function. ONLY USE THESE WITH num-func !! + param1 = 2nd parameter for the playback function. ONLY USE THESE WITH num-func !! + frame-num = set the frame-num field. + frame-interp = set the frame-interp field. + dist = set the dist field. + available num! functions: + - (+!) = advance anim. + - (-!) = reverse anim. + - (identity num) = play 'num' frame. + - (seek! target speed) = animate towards frame target at a speed. + speed is optional and defaults to 1.0 when not provided. + target is optional and defaults to the last frame of the animation. + if you want to set the speed, you therefore must also set the target. + target can be max (no quote), which is just the same as the default value. + - (loop! speed) = loop animation at a speed. default speed is 1.0 when not provided. + - (chan channel) = copy frame from another channel. + - min = the start of the animation. + - max = the end of the animation. + - zero = frame zero. + " + + (let* ((num-args (if (pair? num!) (cdr num!) '())) + (num! (if (pair? num!) (car num!) num!)) + (nf (cond + ((or (eq? num! 'identity) + (eq? num! 'min) + (eq? num! 'max) + (eq? num! 'zero)) + 'num-func-identity) + ((eq? num! 'none) 'num-func-none) + ((eq? num! '+!) 'num-func-+!) + ((eq? num! '-!) 'num-func--!) + ((eq? num! 'seek!) 'num-func-seek!) + ((eq? num! 'loop!) 'num-func-loop!) + ((eq? num! 'blend-in!) 'num-func-blend-in!) + ((eq? num! 'chan) 'num-func-chan) + )) + (p0 (if param0 param0 + (cond + ((eq? num! 'chan) `(the float ,(car num-args))) + ((eq? num! '+!) (if (null? num-args) 1.0 (car num-args))) + ((eq? num! '-!) (if (null? num-args) 1.0 (car num-args))) + ((eq? num! 'loop!) (if (null? num-args) 1.0 (if (eq? 'max (car num-args)) + (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + ) + (car num-args)))) + ((eq? num! 'seek!) (if (or (null? num-args) (eq? (car num-args) 'max)) + (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + ) + (car num-args))) + ))) + (p1 (if param1 param1 + (cond + ((eq? num! 'seek!) (if (or (null? num-args) (null? (cdr num-args))) 1.0 (cadr num-args))) + ))) + (frame-num (cond + ((eq? 'max frame-num) (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + )) + ((eq? 'zero frame-num) 0) + (#t frame-num))) + (frame-group (if (or p0 p1 frame-num (not nf)) group! #f)) + ) + `(let ((ja-ch (-> self skel root-channel ,chan))) + ,(if frame-interp `(set! (-> ja-ch frame-interp) ,frame-interp) `(none)) + ,(if dist `(set! (-> ja-ch dist) ,dist) `(none)) + ,(if frame-group `(set! (-> ja-ch frame-group) (the art-joint-anim ,frame-group)) `(none)) + ,(if p0 `(set! (-> ja-ch param 0) ,p0) `(none)) + ,(if p1 `(set! (-> ja-ch param 1) ,p1) `(none)) + ,(if num-func `(set! (-> ja-ch num-func) ,num-func) `(none)) + ,(if frame-num `(set! (-> ja-ch frame-num) ,frame-num) `(none)) + ,(if nf + `(,(if eval? 'joint-control-channel-group-eval! 'joint-control-channel-group!) + ja-ch (the art-joint-anim ,group!) ,nf) + `(none)) + ,(cond + ((eq? num! 'min) `(set! (-> ja-ch frame-num) 0.0)) + ((eq? num! 'max) (if group! + `(set! (-> ja-ch frame-num) (the float (1- (-> (the art-joint-anim ,group!) frames num-frames)))) + `(set! (-> ja-ch frame-num) (the float (1- (-> ja-ch frame-group frames num-frames)))) + )) + ((eq? num! 'identity) `(set! (-> ja-ch frame-num) ,(car num-args))) + (#t `(none)) + ) + )) + ) + +(defmacro ja-no-eval (&key (chan 0) + &key (group! #f) + &key (num! #f) + &key (param0 #f) + &key (param1 #f) + &key (num-func #f) + &key (frame-num #f) + &key (frame-interp #f) + &key (dist #f) + ) + `(ja :eval? #f :chan ,chan :group! ,group! :num! ,num! :param0 ,param0 :param1 ,param1 :num-func ,num-func :frame-num ,frame-num :frame-interp ,frame-interp :dist ,dist) ) \ No newline at end of file diff --git a/test/decompiler/reference/jak3/engine/anim/joint-mod_REF.gc b/test/decompiler/reference/jak3/engine/anim/joint-mod_REF.gc index a63957ddae..39a418c040 100644 --- a/test/decompiler/reference/jak3/engine/anim/joint-mod_REF.gc +++ b/test/decompiler/reference/jak3/engine/anim/joint-mod_REF.gc @@ -666,18 +666,18 @@ ) ;; definition for method 13 of type joint-mod -(defmethod twist-set! ((thix joint-mod) (x float) (y float) (z float)) +(defmethod twist-set! ((this joint-mod) (x float) (y float) (z float)) "Set twist x,y,z. A value of #f will skip the set." (if x - (set! (-> thix twist x) x) + (set! (-> this twist x) x) ) (if y - (set! (-> thix twist y) y) + (set! (-> this twist y) y) ) (if z - (set! (-> thix twist z) z) + (set! (-> this twist z) z) ) - (-> thix twist) + (-> this twist) ) ;; definition for method 14 of type joint-mod @@ -1610,7 +1610,3 @@ 0 (none) ) - - - - diff --git a/test/decompiler/reference/jak3/engine/data/art-h_REF.gc b/test/decompiler/reference/jak3/engine/data/art-h_REF.gc index 088558d24a..6ee8eeacdd 100644 --- a/test/decompiler/reference/jak3/engine/data/art-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/data/art-h_REF.gc @@ -327,8 +327,8 @@ actor, like the mesh, animations, shadow mesh, skeleton, etc." ) (:methods (relocate (_type_ kheap (pointer uint8)) none :replace) - (link-art-to-master (_type_) none) - (unknown-1 () none) + (link-art-to-master (_type_) art-group) + (unlink-art-to-master (_type_) int) ) ) 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 813451ffa6..6818a57802 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 @@ -142,10 +142,10 @@ (load-state-method-14 () none) (load-state-method-15 () none) (load-state-method-16 () none) - (load-state-method-17 () none) - (load-state-method-18 () none) - (load-state-method-19 () none) - (load-state-method-20 () none) + (execute-commands-up-to (_type_ float) none) + (backup-load-state-and-set-cmds (_type_ pair) int) + (restore-load-state-and-cleanup (_type_) int) + (restore-load-state (_type_) int) (load-state-method-21 () 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 ecbf1e2392..c2b578311a 100644 --- a/test/decompiler/reference/jak3/engine/game/settings-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/game/settings-h_REF.gc @@ -631,8 +631,8 @@ (setting-control-method-14 (_type_ object) connectable) (remove-setting-by-arg0 (_type_ object) none) (set-setting-by-param (_type_ symbol object object object) connection) - (setting-control-method-17 () none) - (setting-control-method-18 () none) + (apply-settings (_type_) user-setting-data) + (update (_type_) user-setting-data) (setting-control-method-19 () none) ) ) diff --git a/test/decompiler/reference/jak3/engine/level/level-h_REF.gc b/test/decompiler/reference/jak3/engine/level/level-h_REF.gc index 60c0c9ab3d..4031c26de7 100644 --- a/test/decompiler/reference/jak3/engine/level/level-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/level/level-h_REF.gc @@ -446,7 +446,7 @@ (level-method-18 () none) (level-method-19 () none) (level-method-20 () none) - (level-method-21 () none) + (get-art-group-by-name (_type_ string) art-group) (level-method-22 () none) (level-method-23 () none) (level-method-24 () none) 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 57b4d59671..d9218ebde3 100644 --- a/test/decompiler/reference/jak3/engine/load/load-dgo_REF.gc +++ b/test/decompiler/reference/jak3/engine/load/load-dgo_REF.gc @@ -162,7 +162,7 @@ ;; definition for function str-play-async ;; WARN: Return type mismatch int vs none. -(defun str-play-async ((name string) (id sound-id) (chunk-idx int) (group int)) +(defun str-play-async ((name string) (id sound-id) (volume int) (group int)) "Start playing a streaming audio." (set! *que-str-lock* #t) (let ((s2-0 (the-as play-chunk-msg (add-element *play-str-rpc*)))) @@ -174,7 +174,7 @@ (set! (-> s2-0 id 1) (the-as uint 0)) (set! (-> s2-0 id 2) (the-as uint 0)) (set! (-> s2-0 id 3) (the-as uint 0)) - (set! (-> s2-0 section) (the-as uint chunk-idx)) + (set! (-> s2-0 section) (the-as uint volume)) (set! (-> s2-0 maxlen) (the-as uint 0)) (set! (-> s2-0 group) (the-as uint group)) (set! (-> s2-0 result) (the-as uint 0)) diff --git a/test/decompiler/reference/jak3/engine/load/loader_REF.gc b/test/decompiler/reference/jak3/engine/load/loader_REF.gc new file mode 100644 index 0000000000..e1a6c66b37 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/load/loader_REF.gc @@ -0,0 +1,2842 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 8 of type subtitle-range +(defmethod mem-usage ((this subtitle-range) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 74 (-> usage length))) + (set! (-> usage data 73 name) "subtitle") + (+! (-> usage data 73 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 73 used) v1-6) + (+! (-> usage data 73 total) (logand -16 (+ v1-6 15))) + ) + this + ) + +;; definition for method 3 of type load-dir +;; INFO: Used lq/sq +(defmethod inspect ((this load-dir)) + (local-vars (sv-16 basic)) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~Tlevel: ~A~%" (-> this lev)) + (format #t "~Tallocated-length: ~D~%" (-> this string-array allocated-length)) + (format #t "~Tlength: ~D~%" (-> this string-array length)) + (dotimes (s5-0 (-> this string-array length)) + (let ((s4-0 format) + (s3-0 #t) + (s2-0 "~T [~D] ~S ~A (~D bytes)~%") + (s1-0 s5-0) + (s0-0 (-> this string-array s5-0)) + ) + (set! sv-16 (-> this data-array s5-0)) + (let ((t1-0 (mem-size (-> this data-array s5-0) #f 0))) + (s4-0 s3-0 s2-0 s1-0 s0-0 sv-16 t1-0) + ) + ) + ) + this + ) + +;; definition for method 8 of type load-dir +;; WARN: Return type mismatch symbol vs load-dir. +(defmethod mem-usage ((this load-dir) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 86 (-> usage length))) + (set! (-> usage data 85 name) "array") + (+! (-> usage data 85 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 85 used) v1-6) + (+! (-> usage data 85 total) (logand -16 (+ v1-6 15))) + ) + (set! (-> usage length) (max 86 (-> usage length))) + (set! (-> usage data 85 name) "array") + (set! (-> usage data 85 count) (-> usage data 85 count)) + (let ((v1-15 (asize-of (-> this string-array)))) + (+! (-> usage data 85 used) v1-15) + (+! (-> usage data 85 total) (logand -16 (+ v1-15 15))) + ) + (set! (-> usage length) (max 86 (-> usage length))) + (set! (-> usage data 85 name) "array") + (set! (-> usage data 85 count) (-> usage data 85 count)) + (let ((v1-24 (asize-of (-> this data-array)))) + (+! (-> usage data 85 used) v1-24) + (+! (-> usage data 85 total) (logand -16 (+ v1-24 15))) + ) + (dotimes (s3-0 (-> this data-array length)) + (mem-usage (-> this data-array s3-0) usage flags) + ) + (the-as load-dir #f) + ) + +;; definition for method 9 of type load-dir-art-group +(defmethod load-to-heap-by-name ((this load-dir-art-group) (arg0 string) (arg1 symbol) (arg2 kheap) (arg3 int)) + (let ((s5-0 (-> this string-array))) + (dotimes (s3-0 (-> s5-0 length)) + (when (string= arg0 (-> s5-0 s3-0)) + (when (= arg1 'reload) + (let ((v1-5 (art-group-load-check arg0 arg2 arg3))) + (if v1-5 + (set! (-> this art-group-array s3-0) v1-5) + ) + ) + ) + (return (-> this art-group-array s3-0)) + ) + ) + (when (= arg1 'load) + (let ((v0-2 (art-group-load-check arg0 arg2 arg3))) + (when v0-2 + (set! (-> s5-0 (-> s5-0 length)) arg0) + (set! (-> this art-group-array (-> s5-0 length)) v0-2) + (+! (-> s5-0 length) 1) + (+! (-> this art-group-array length) 1) + ) + v0-2 + ) + ) + ) + ) + +;; definition for method 10 of type load-dir-art-group +(defmethod set-loaded-art ((this load-dir-art-group) (arg0 art-group)) + (let ((s4-0 (-> this string-array))) + (dotimes (s3-0 (-> s4-0 length)) + (when (string= (-> arg0 name) (-> s4-0 s3-0)) + (set! (-> this art-group-array s3-0) arg0) + (set! arg0 (-> this art-group-array s3-0)) + (goto cfg-7) + ) + ) + (set! (-> s4-0 (-> s4-0 length)) (-> arg0 name)) + (set! (-> this art-group-array (-> s4-0 length)) arg0) + (+! (-> s4-0 length) 1) + ) + (+! (-> this art-group-array length) 1) + (label cfg-7) + arg0 + ) + +;; definition for function drawable-load +(defun drawable-load ((arg0 drawable) (arg1 kheap)) + (local-vars (sp-0 pointer)) + (cond + ((type? arg0 string) + (the-as none sp-0) + (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + (set! sp-0 (&+ *kernel-sp* -1024)) + ) + (let ((s5-1 (the-as drawable (loado (the-as string arg0) arg1)))) + (if (and s5-1 (type? s5-1 drawable)) + (login s5-1) + ) + ) + ) + ((type? arg0 drawable) + (login arg0) + ) + ) + ) + +;; definition for function art-load +(defun art-load ((arg0 string) (arg1 kheap)) + (local-vars (sp-0 pointer)) + (the-as none sp-0) + (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + (set! sp-0 (&+ *kernel-sp* -1024)) + ) + (let ((s5-0 (the-as art (loado arg0 arg1)))) + (if (type? s5-0 art) + (login s5-0) + (the-as art #f) + ) + ) + ) + +;; definition for function art-group-load-check +(defun art-group-load-check ((arg0 string) (arg1 kheap) (arg2 int)) + (local-vars (sp-0 pointer)) + (when *debug-segment* + (the-as none sp-0) + (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + (set! sp-0 (&+ *kernel-sp* -1024)) + ) + (let ((s3-1 (the-as art-group (loado (make-file-name (file-kind art-group) arg0 arg2 #f) arg1)))) + (cond + ((not s3-1) + (format 0 "ERROR: art-group ~A is not a valid file.~%" arg0) + (the-as art-group #f) + ) + ((not (type? s3-1 art-group)) + (format 0 "ERROR: art-group ~A is not a art-group.~%" arg0) + (the-as art-group #f) + ) + ((not (file-info-correct-version? (-> s3-1 info) (file-kind art-group) arg2)) + (the-as art-group #f) + ) + (else + (login s3-1) + ) + ) + ) + ) + ) + +;; definition for method 2 of type external-art-buffer +(defmethod print ((this external-art-buffer)) + (format + #t + "#<~A ~S ~D ~A @ #x~X>" + (-> this type) + (-> this pending-load-file) + (-> this pending-load-file-part) + (-> this status) + this + ) + this + ) + +;; definition for function external-art-buffer-init +(defun external-art-buffer-init ((arg0 external-art-buffer)) + (let ((v1-0 (-> arg0 heap))) + (set! (-> v1-0 base) (the-as pointer (+ #x84000 (* #x3dc00 (-> arg0 index))))) + (set! (-> v1-0 current) (-> v1-0 base)) + (set! (-> v1-0 top-base) (&+ (-> v1-0 base) #x3dc00)) + (set! (-> v1-0 top) (-> v1-0 top-base)) + ) + 0 + ) + +;; definition for method 9 of type external-art-buffer +(defmethod set-pending-file ((this external-art-buffer) (arg0 string) (arg1 int) (arg2 handle) (arg3 float)) + (set! (-> this pending-load-file) arg0) + (set! (-> this pending-load-file-part) arg1) + (set! (-> this pending-load-file-owner) arg2) + (set! (-> this pending-load-file-priority) arg3) + 0 + ) + +;; definition for method 15 of type external-art-buffer +(defmethod unlock! ((this external-art-buffer)) + (set! (-> this locked?) #f) + 0 + ) + +;; definition for method 11 of type external-art-buffer +(defmethod inactive? ((this external-art-buffer)) + (!= (-> this status) 'active) + ) + +;; definition for method 12 of type external-art-buffer +(defmethod file-status ((this external-art-buffer) (arg0 string) (arg1 int)) + (when (and (name= (-> this pending-load-file) arg0) (= (-> this pending-load-file-part) arg1)) + (if (and (name= (-> this load-file) arg0) (= (-> this load-file-part) arg1)) + (-> this status) + 'pending + ) + ) + ) + +;; definition for method 14 of type art-group +(defmethod link-art-to-master ((this art-group)) + (when this + (countdown (s5-0 (-> this length)) + (let* ((s3-0 (-> this data s5-0)) + (s4-0 (if (type? s3-0 art-element) + s3-0 + ) + ) + (s2-0 #f) + ) + (when s4-0 + (let ((s3-1 11)) + (while (begin (label cfg-24) (nonzero? s3-1)) + (+! s3-1 -1) + (let ((v1-8 (get-art-group-by-name (-> *level* level s3-1) (-> s4-0 master-art-group-name)))) + (when v1-8 + (countdown (a0-5 (-> v1-8 length)) + (if (= (-> v1-8 data a0-5) s4-0) + (goto cfg-24) + ) + ) + (cond + ((and (< (-> s4-0 master-art-group-index) (-> v1-8 length)) + (not (-> v1-8 data (-> s4-0 master-art-group-index))) + ) + (set! (-> v1-8 data (-> s4-0 master-art-group-index)) s4-0) + (set! s2-0 #t) + ) + (else + (countdown (a0-17 (-> v1-8 length)) + (when (not (-> v1-8 data a0-17)) + (set! (-> v1-8 data a0-17) s4-0) + (set! s2-0 #t) + (goto cfg-24) + ) + ) + ) + ) + ) + ) + ) + ) + (if (not s2-0) + (format 0 "ERROR: ~A could not find a master slot to link for ~A.~%" (-> this name) s4-0) + ) + ) + ) + ) + ) + this + ) + +;; definition for method 15 of type art-group +(defmethod unlink-art-to-master ((this art-group)) + (when this + (countdown (s5-0 (-> this length)) + (let* ((s3-0 (-> this data s5-0)) + (s4-0 (if (type? s3-0 art-element) + s3-0 + ) + ) + (s3-1 #f) + ) + (when s4-0 + (let ((s2-0 11)) + (while (begin (label cfg-13) (nonzero? s2-0)) + (+! s2-0 -1) + (let ((v1-8 (get-art-group-by-name (-> *level* level s2-0) (-> s4-0 master-art-group-name)))) + (when v1-8 + (countdown (a0-5 (-> v1-8 length)) + (when (= s4-0 (-> v1-8 data a0-5)) + (set! (-> v1-8 data a0-5) #f) + (set! s3-1 #t) + (goto cfg-13) + ) + ) + ) + ) + ) + ) + (if (not s3-1) + (format 0 "ERROR: ~A could not find a master slot to unlink for ~A.~%" (-> this name) s4-0) + ) + ) + ) + ) + ) + 0 + ) + +;; definition for method 13 of type external-art-buffer +(defmethod link-file ((this external-art-buffer) (arg0 art-group)) + (when arg0 + (link-art-to-master arg0) + (set! (-> this art-group) arg0) + ) + arg0 + ) + +;; definition for method 14 of type external-art-buffer +(defmethod unlink-file ((this external-art-buffer) (arg0 art-group)) + (when arg0 + (unlink-art-to-master arg0) + (set! (-> this art-group) #f) + ) + 0 + ) + +;; definition for method 10 of type external-art-buffer +;; WARN: Found some very strange gotos. Check result carefully, this is not well tested. +(defmethod update ((this external-art-buffer)) + (when (or (not (name= (-> this pending-load-file) (-> this load-file))) + (!= (-> this pending-load-file-part) (-> this load-file-part)) + ) + (when (not (handle->process (-> this pending-load-file-owner))) + (set! (-> this pending-load-file) #f) + (set! (-> this pending-load-file-part) -1) + (set! (-> this pending-load-file-owner) (the-as handle #f)) + (set! (-> this pending-load-file-priority) 100000000.0) + ) + (when (= (-> this status) 'initialize) + ((-> this init-heap) this) + (set! (-> this status) 'inactive) + ) + (cond + ((-> this load-file) + (if (= (-> this status) 'loading) + (str-load-cancel) + ) + (set! (-> this load-file) #f) + (set! (-> this load-file-part) -1) + (set! (-> this load-file-owner) (the-as handle #f)) + (set! (-> this load-file-priority) 100000000.0) + ) + (else + (set! (-> this load-file) (-> this pending-load-file)) + (set! (-> this load-file-part) (-> this pending-load-file-part)) + (set! (-> this load-file-owner) (-> this pending-load-file-owner)) + (set! (-> this load-file-priority) (-> this pending-load-file-priority)) + ) + ) + ) + (label cfg-18) + (cond + ((-> this load-file) + (case (-> this status) + (('active 'reserved) + ) + (('error) + (set! (-> this status) 'inactive) + (set! (-> this load-file) #f) + (set! (-> this load-file-part) -1) + (set! (-> this load-file-owner) (the-as handle #f)) + (set! (-> this load-file-priority) 100000000.0) + (set! (-> this pending-load-file) #f) + (set! (-> this pending-load-file-part) -1) + (set! (-> this pending-load-file-owner) (the-as handle #f)) + (set! (-> this pending-load-file-priority) 100000000.0) + (set! (-> this art-group) #f) + ) + (('inactive) + (let ((v1-31 (-> this heap))) + (set! (-> v1-31 current) (-> v1-31 base)) + ) + (cond + ((string= (-> this load-file) "reserved") + (cond + ((-> *art-control* reserve-buffer) + (format 0 "ERROR: trying double reserve ~A when ~A is reserved~%" this (-> *art-control* reserve-buffer)) + ) + (else + (set! (-> this status) 'reserved) + (set! (-> *art-control* reserve-buffer) this) + ) + ) + ) + ((and (!= (-> *level* loading-level) (-> *level* level-default)) + (or (< 81920.0 (-> this load-file-priority)) (logtest? (-> *level* loading-level info level-flags) 16)) + ) + ) + ((let ((v1-46 (logand -64 (&+ (-> this heap current) 63)))) + (str-load (-> this load-file) (-> this load-file-part) v1-46 (&- (-> this heap top) (the-as uint v1-46))) + ) + (set! (-> this status) 'loading) + 0 + ) + ) + ) + (('loading) + (case (str-load-status (&-> this len)) + (('error) + (set! (-> this status) 'error) + ) + (('busy) + ) + (else + (set! (-> this buf) (logand -64 (&+ (-> this heap current) 63))) + (set! (-> this status) 'loaded) + (goto cfg-18) + ) + ) + ) + (('loaded) + (let ((a0-39 (-> this buf))) + (cond + ((-> this login?) + (set! (-> this art-group) + (the-as art-group (link a0-39 (-> this load-file data) (-> this len) (-> this heap) (if *print-login* + 8 + 0 + ) + ) + ) + ) + (let ((s4-0 (-> this art-group)) + (s3-0 (-> this load-file)) + ) + (cond + ((not s4-0) + (format 0 "ERROR: art-group ~A part ~D is not a valid file.~%" s3-0 (-> this load-file-part)) + (set! (-> this status) 'error) + ) + ((not (type? s4-0 art-group)) + (format 0 "ERROR: art-group ~A part ~D is not a art-group.~%" s3-0 (-> this load-file-part)) + (set! (-> this status) 'error) + ) + ((not (file-info-correct-version? (-> s4-0 info) (file-kind art-group) 0)) + (set! (-> this status) 'error) + ) + (else + (login s4-0) + (set! (-> this status) 'locked) + ) + ) + ) + ) + (else + (set! (-> this status) 'locked) + (set! (-> this art-group) (the-as art-group a0-39)) + ) + ) + ) + ) + (('locked) + (when (and (not (-> this locked?)) (handle->process (-> this load-file-owner))) + (if (-> this login?) + (link-file this (-> this art-group)) + ) + (if (-> this other) + (set! (-> this other locked?) #t) + ) + (set! (-> this status) 'active) + (goto cfg-18) + ) + ) + ) + ) + (else + (case (-> this status) + (('initialize) + ) + (('reserved) + (cond + ((= (-> *art-control* reserve-buffer) this) + (set! (-> *art-control* reserve-buffer) #f) + (set! (-> this status) 'inactive) + ) + (else + (format 0 "ERROR: trying tro free ~A when ~A is reserved~%" this (-> *art-control* reserve-buffer)) + ) + ) + ) + (('active) + (if (-> this login?) + (unlink-file this (-> this art-group)) + ) + (let ((v1-89 (-> this heap))) + (set! (-> v1-89 current) (-> v1-89 base)) + ) + (set! (-> this art-group) #f) + (set! (-> this status) 'inactive) + (when (and (-> this other) (-> this other locked?)) + (unlock! (-> this other)) + (update (-> this other)) + ) + ) + (else + (let ((v1-99 (-> this heap))) + (set! (-> v1-99 current) (-> v1-99 base)) + ) + (set! (-> this art-group) #f) + (set! (-> this status) 'inactive) + ) + ) + ) + ) + 0 + ) + +;; definition for symbol *preload-spool-anims*, type symbol +(define *preload-spool-anims* #t) + +;; definition for method 12 of type external-art-control +(defmethod file-status ((this external-art-control) (arg0 string) (arg1 int)) + (dotimes (s3-0 2) + (let ((v1-3 (file-status (-> this buffer s3-0) arg0 arg1))) + (if v1-3 + (return v1-3) + ) + ) + ) + #f + ) + +;; definition for method 9 of type external-art-control +(defmethod update ((this external-art-control) (arg0 symbol)) + (if (nonzero? (-> this reserve-buffer-count)) + (spool-push this "reserved" 0 *dproc* (if (-> this reserve-buffer) + -110.0 + -0.5 + ) + ) + ) + (dotimes (v1-5 2) + (set! (-> this buffer v1-5 frame-lock) #f) + ) + (dotimes (v1-8 3) + (set! (-> this rec v1-8 anim-name) #f) + ) + (dotimes (s4-0 2) + (let ((s3-0 (-> this rec s4-0))) + (when (-> s3-0 name) + (dotimes (s2-0 2) + (when (and (file-status (-> this buffer s2-0) (-> s3-0 name) (-> s3-0 parts)) + (not (-> this buffer s2-0 frame-lock)) + ) + (set! (-> this buffer s2-0 frame-lock) #t) + (set! (-> s3-0 anim-name) (the-as string (-> this buffer s2-0))) + (set! (-> this buffer s2-0 pending-load-file-owner) (-> s3-0 owner)) + (set! (-> this buffer s2-0 load-file-owner) (-> s3-0 owner)) + (set! (-> this buffer s2-0 pending-load-file-priority) (-> s3-0 priority)) + (set! (-> this buffer s2-0 load-file-priority) (-> s3-0 priority)) + (goto cfg-24) + ) + ) + ) + ) + (label cfg-24) + ) + (dotimes (s4-1 2) + (let ((s3-1 (-> this rec s4-1))) + (when (and (-> s3-1 name) (not (-> s3-1 anim-name))) + (if (and (not *preload-spool-anims*) (>= (-> s3-1 priority) 0.0)) + (goto cfg-46) + ) + (dotimes (s2-1 2) + (when (not (-> this buffer s2-1 frame-lock)) + (set! (-> this buffer s2-1 frame-lock) #t) + (set-pending-file (-> this buffer s2-1) (-> s3-1 name) (-> s3-1 parts) (-> s3-1 owner) (-> s3-1 priority)) + (set! (-> s3-1 anim-name) (the-as string (-> this buffer s2-1))) + (goto cfg-46) + ) + ) + ) + ) + (label cfg-46) + ) + (when (not (-> this reserve-buffer)) + (let ((s4-2 (the-as external-art-buffer (-> this rec 0 anim-name)))) + (if (and s4-2 + (-> s4-2 locked?) + (not (string= (-> s4-2 pending-load-file) "reserved")) + (not (string= (-> s4-2 other pending-load-file) "reserved")) + ) + (set-pending-file (-> s4-2 other) (the-as string #f) -1 (the-as handle #f) 100000000.0) + ) + ) + ) + (dotimes (s4-3 2) + (update (-> this buffer s4-3)) + ) + (let ((s4-4 (-> this queue-stream))) + (set! (-> s4-4 length) 0) + (dotimes (s3-2 3) + (when (-> this rec s3-2 name) + (mem-copy! (&-> (-> s4-4 (-> s4-4 length)) type) (&-> (-> this rec s3-2) type) 44) + (+! (-> s4-4 length) 1) + ) + ) + ) + (when (and arg0 *display-art-control*) + (dotimes (s5-1 3) + (let ((t9-8 format) + (a0-27 *stdcon*) + (a1-8 "rec ~d ~S ~D ~f ~A~%") + (a2-5 s5-1) + (a3-3 (-> this rec s5-1 name)) + (t0-3 (-> this rec s5-1 parts)) + (t1-0 (-> this rec s5-1 priority)) + (v1-121 (handle->process (-> this rec s5-1 owner))) + ) + (t9-8 a0-27 a1-8 a2-5 a3-3 t0-3 t1-0 (if v1-121 + (-> v1-121 name) + ) + ) + ) + ) + (dotimes (s5-2 2) + (let ((t9-9 format) + (a0-28 *stdcon*) + (a1-9 "buf ~d ~C ~S ~D ~A ~A~%") + (a2-6 s5-2) + (a3-4 (if (-> this buffer s5-2 locked?) + 108 + 32 + ) + ) + (t0-4 (-> this buffer s5-2 pending-load-file)) + (t1-1 (-> this buffer s5-2 pending-load-file-part)) + (t2-5 (-> this buffer s5-2 status)) + (v1-142 (handle->process (-> this buffer s5-2 pending-load-file-owner))) + ) + (t9-9 a0-28 a1-9 a2-6 a3-4 t0-4 t1-1 t2-5 (if v1-142 + (-> v1-142 name) + ) + ) + ) + ) + (format *stdcon* " a: ~S~%" (-> this active-stream)) + ) + 0 + ) + +;; definition for method 15 of type external-art-control +(defmethod none-reserved? ((this external-art-control)) + (zero? (-> this reserve-buffer-count)) + ) + +;; definition for method 13 of type external-art-control +(defmethod reserve-alloc ((this external-art-control)) + (cond + ((or (nonzero? (-> this dma-reserve-buffer-count)) (= *master-mode* 'progress)) + (set! (-> this dma-reserve-buffer-count) 1) + (when (and (-> *bigmap* drawing-flag) (zero? (-> *blit-displays-work* count-down))) + (let ((v1-8 (-> this dma-reserve-heap))) + (set! (-> v1-8 base) (logand -64 (&+ (&+ (-> *display* frames 1 global-buf end) -252992) 63))) + (set! (-> v1-8 current) (-> v1-8 base)) + (set! (-> v1-8 top-base) (&+ (-> v1-8 base) #x3dc00)) + (set! (-> v1-8 top) (-> v1-8 top-base)) + ) + (set! (-> *display* frames 1 global-buf end) (-> this dma-reserve-heap base)) + (-> this dma-reserve-heap) + ) + ) + (else + (set! (-> this reserve-buffer-count) 1) + (if (and (-> this reserve-buffer) (not (check-busy *load-str-rpc*))) + (-> this reserve-buffer heap) + ) + ) + ) + ) + +;; definition for method 14 of type external-art-control +(defmethod reserve-free ((this external-art-control) (arg0 kheap)) + (cond + ((nonzero? (-> this dma-reserve-buffer-count)) + (set! (-> this dma-reserve-buffer-count) 0) + (let ((v1-3 (-> *display* frames 1 global-buf))) + (set! (-> v1-3 end) (the-as pointer (+ (+ (-> v1-3 allocated-length) 28) (the-as int v1-3)))) + ) + ) + ((and (zero? (-> this reserve-buffer-count)) (zero? (-> this dma-reserve-buffer-count))) + (format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (none reserved).~%" arg0) + ) + ((not (-> this reserve-buffer)) + (set! (-> this reserve-buffer-count) 0) + 0 + ) + ((= (-> this reserve-buffer heap) arg0) + (set-pending-file (-> this reserve-buffer) (the-as string #f) -1 (the-as handle #f) 100000000.0) + (update (-> this reserve-buffer)) + (set! (-> this reserve-buffer-count) 0) + 0 + ) + (else + (format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (buffer unknown).~%" arg0) + ) + ) + 0 + ) + +;; definition for method 10 of type external-art-control +(defmethod clear-rec ((this external-art-control)) + (dotimes (v1-0 3) + (set! (-> this rec v1-0 type) spool-anim) + (set! (-> this rec v1-0 name) #f) + (set! (-> this rec v1-0 priority) 100000000.0) + (set! (-> this rec v1-0 owner) (the-as handle #f)) + ) + (set! (-> this frame-mask) (the-as uint (-> *setting-control* user-current process-mask))) + 0 + ) + +;; definition for method 11 of type external-art-control +(defmethod spool-push ((this external-art-control) (arg0 string) (arg1 int) (arg2 process) (arg3 float)) + (when (and (= arg3 -99.0) arg2) + (let ((a0-2 (target-pos 0))) + (set! arg3 (vector-vector-distance a0-2 (-> (the-as process-drawable arg2) root trans))) + ) + ) + (cond + ((and (= arg1 (-> this rec 0 parts)) (name= arg0 (-> this rec 0 name))) + (if (>= arg3 (-> this rec 0 priority)) + (return (the-as int #f)) + ) + (mem-copy! (&-> (-> this rec) 0 type) (&-> (-> this rec 1) type) 44) + (mem-copy! (&-> (-> this rec 1) type) (&-> (-> this rec 2) type) 44) + (set! (-> this rec 2 name) #f) + (set! (-> this rec 2 owner) (the-as handle #f)) + ) + ((and (= arg1 (-> this rec 1 parts)) (name= arg0 (-> this rec 1 name))) + (if (>= arg3 (-> this rec 1 priority)) + (return (the-as int #f)) + ) + (mem-copy! (&-> (-> this rec 1) type) (&-> (-> this rec 2) type) 44) + (set! (-> this rec 2 name) #f) + (set! (-> this rec 2 owner) (the-as handle #f)) + ) + ((and (= arg1 (-> this rec 2 parts)) (name= arg0 (-> this rec 2 name))) + (if (>= arg3 (-> this rec 2 priority)) + (return (the-as int #f)) + ) + (set! (-> this rec 2 name) #f) + (set! (-> this rec 2 owner) (the-as handle #f)) + ) + ) + (cond + ((< arg3 (-> this rec 0 priority)) + (mem-copy! (&-> (-> this rec 2) type) (&-> (-> this rec 1) type) 44) + (mem-copy! (&-> (-> this rec 1) type) (&-> (-> this rec) 0 type) 44) + (set! (-> this rec 0 name) arg0) + (set! (-> this rec 0 parts) arg1) + (set! (-> this rec 0 priority) arg3) + (set! (-> this rec 0 owner) (process->handle arg2)) + ) + ((< arg3 (-> this rec 1 priority)) + (mem-copy! (&-> (-> this rec 2) type) (&-> (-> this rec 1) type) 44) + (set! (-> this rec 1 name) arg0) + (set! (-> this rec 1 parts) arg1) + (set! (-> this rec 1 priority) arg3) + (set! (-> this rec 1 owner) (process->handle arg2)) + ) + ((< arg3 (-> this rec 2 priority)) + (set! (-> this rec 2 name) arg0) + (set! (-> this rec 2 parts) arg1) + (set! (-> this rec 2 priority) arg3) + (set! (-> this rec 2 owner) (process->handle arg2)) + ) + ) + 0 + ) + +;; definition of type spooler-block +(deftype spooler-block (basic) + ((anim spool-anim) + (idle art-joint-anim) + (exit art-joint-anim) + (break-func (function process-drawable object)) + (flags spooler-flags) + (part int32) + (part-audio-start float) + (old-status uint16) + (old-pos int32) + (good-time time-frame) + (old-time time-frame) + (good-count int32) + (sid sound-id) + (real-start-time time-frame) + (paused? symbol) + ) + ) + +;; definition for method 3 of type spooler-block +(defmethod inspect ((this spooler-block)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tanim: ~A~%" (-> this anim)) + (format #t "~1Tidle: ~A~%" (-> this idle)) + (format #t "~1Texit: ~A~%" (-> this exit)) + (format #t "~1Tbreak-func: ~A~%" (-> this break-func)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (format #t "~1Tpart: ~D~%" (-> this part)) + (format #t "~1Tpart-audio-start: ~f~%" (-> this part-audio-start)) + (format #t "~1Told-status: ~D~%" (-> this old-status)) + (format #t "~1Told-pos: ~D~%" (-> this old-pos)) + (format #t "~1Tgood-time: ~D~%" (-> this good-time)) + (format #t "~1Told-time: ~D~%" (-> this old-time)) + (format #t "~1Tgood-count: ~D~%" (-> this good-count)) + (format #t "~1Tsid: ~D~%" (-> this sid)) + (format #t "~1Treal-start-time: ~D~%" (-> this real-start-time)) + (format #t "~1Tpaused?: ~A~%" (-> this paused?)) + (label cfg-4) + this + ) + +;; definition for function ja-play-spooled-anim +(defbehavior ja-play-spooled-anim process-drawable ((arg0 spool-anim) + (arg1 art-joint-anim) + (arg2 art-joint-anim) + (arg3 (function process-drawable symbol)) + (arg4 spooler-flags) + ) + (local-vars (v0-62 int) (sv-176 int)) + (let ((gp-0 (new 'stack 'spooler-block))) + (let ((s5-0 gp-0)) + (set! (-> s5-0 anim) arg0) + (set! (-> s5-0 idle) arg1) + (set! (-> s5-0 exit) arg2) + (set! (-> s5-0 break-func) arg3) + (set! (-> s5-0 flags) arg4) + (set! (-> s5-0 part-audio-start) -17.0) + (set! (-> s5-0 old-status) (the-as uint (-> self skel status))) + (set! (-> s5-0 old-pos) -2) + (set! (-> s5-0 sid) (new-sound-id)) + (set! (-> s5-0 paused?) #f) + ) + (let ((v1-7 + (lookup-gui-connection *gui-control* self (gui-channel art-load) (-> gp-0 anim name) (new 'static 'sound-id)) + ) + ) + (if v1-7 + (set! (-> gp-0 sid) (-> v1-7 id)) + ) + ) + (if (!= self *target*) + (send-event *target* 'movie) + ) + (backup-load-state-and-set-cmds *load-state* (-> gp-0 anim command-list)) + (logior! (-> self skel status) (joint-control-status sync-math spooling spooling-not-last-block)) + (talker-surpress!) + (update *setting-control*) + (when (or (and (-> *setting-control* user-current spooling) + (or (< 2 (-> gp-0 anim parts)) + (not (string= (-> *setting-control* user-current spool-anim name) (-> gp-0 anim name))) + ) + ) + (logtest? (-> *art-control* frame-mask) 28) + (!= *master-mode* 'game) + ) + (cond + ((-> gp-0 idle) + (when (!= (ja-group) (-> gp-0 idle)) + (ja-channel-push! 1 (seconds 0.05)) + (ja :group! (-> gp-0 idle) :num! min) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (while (or (and (-> *setting-control* user-current spooling) + (or (< 2 (-> gp-0 anim parts)) + (not (string= (-> *setting-control* user-current spool-anim name) (-> gp-0 anim name))) + ) + ) + (logtest? (-> *art-control* frame-mask) 28) + (!= *master-mode* 'game) + ) + (format #t "WARNING: ---------------------> loader stall on lock~%") + (if ((-> gp-0 break-func) self) + (goto cfg-139) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -9.0 + (-> gp-0 sid) + ) + (suspend) + (if (-> gp-0 idle) + (ja :num! (loop!)) + ) + ) + ) + (set-setting! 'spooling (process->ppointer self) 0.0 0) + (set-setting! 'spool-anim (-> gp-0 anim) 0.0 0) + (update *setting-control*) + (set-time! (-> gp-0 old-time)) + (while (< (-> gp-0 part) (-> gp-0 anim parts)) + (when (> (-> gp-0 part) 0) + (while (let ((v1-103 (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)))) + (not (or (= v1-103 'active) (= v1-103 'locked))) + ) + (if ((-> gp-0 break-func) self) + (goto cfg-139) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (+ (-> gp-0 part) -1) + -20.0 + (-> gp-0 sid) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -10.0 + (-> gp-0 sid) + ) + (when (and (not (-> gp-0 paused?)) (< (-> *setting-control* user-current movie-skip-frame) 0.0)) + (format + #t + "WARNING: ---------------------> loader pre stall on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + (set! (-> gp-0 paused?) #t) + (if (nonzero? (-> gp-0 part)) + (sound-pause (-> gp-0 sid)) + ) + ) + (if (logtest? (-> gp-0 flags) (spooler-flags blackout-on-stall)) + (set-blackout-frames (seconds 0.05)) + ) + (suspend) + ) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (update *gui-control* #f) + (update *art-control* #f) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (when (!= (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) 'active) + (cond + ((-> gp-0 idle) + (when (!= (ja-group) (-> gp-0 idle)) + (ja-channel-set! 1) + (ja :group! (-> gp-0 idle) :num! min) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (while (!= (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) 'active) + (if ((-> gp-0 break-func) self) + (goto cfg-139) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (when (not (-> gp-0 paused?)) + (format + #t + "WARNING: ---------------------> loader stall on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + (set! (-> gp-0 paused?) #t) + (if (nonzero? (-> gp-0 part)) + (sound-pause (-> gp-0 sid)) + ) + ) + (if (logtest? (-> gp-0 flags) (spooler-flags blackout-on-stall)) + (set-blackout-frames (seconds 0.05)) + ) + (suspend) + (if (-> gp-0 idle) + (ja :num! (loop!)) + ) + ) + ) + (when (-> gp-0 paused?) + (set! (-> gp-0 paused?) #f) + (sound-continue (-> gp-0 sid)) + (format + #t + "WARNING: ---------------------> loader release lock on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (let ((s5-8 (get-art-by-name (-> self draw art-group) (-> gp-0 anim anim-name) art-joint-anim))) + (cond + (s5-8 + (ja-channel-set! 1) + (ja-no-eval :group! s5-8 :num! (seek!) :frame-num 0.0) + (when (zero? (-> gp-0 part)) + (str-play-async (-> gp-0 anim name) (-> gp-0 sid) 1024 2) + (set! (-> *art-control* active-stream) (-> gp-0 anim name)) + ) + (let* ((f30-0 (* 0.05859375 (-> s5-8 speed))) + (f28-0 (+ (-> gp-0 part-audio-start) (/ (the float (+ (-> s5-8 frames num-frames) -1)) f30-0))) + ) + (set! sv-176 (current-str-pos (-> gp-0 sid))) + (set-time! (-> gp-0 good-time)) + (until (>= (the float v0-62) f28-0) + (if (= (-> self skel root-channel 0) (-> self skel channel)) + (logior! (-> self skel status) (joint-control-status valid-spooled-frame)) + ) + (if (or ((-> gp-0 break-func) self) + (and (<= sv-176 0) (time-elapsed? (-> gp-0 good-time) (seconds 4))) + (and (< 300 (-> gp-0 good-count)) (<= sv-176 0)) + ) + (goto cfg-139) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (if (< (+ (-> gp-0 part) 1) (-> gp-0 anim parts)) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (+ (-> gp-0 part) 1) + -10.0 + (-> gp-0 sid) + ) + (logclear! (-> self skel status) (joint-control-status spooling-not-last-block)) + ) + (execute-commands-up-to *load-state* (ja-aframe-num 0)) + (cond + ((and (< (-> gp-0 old-pos) sv-176) (< -1 sv-176)) + (+! (-> gp-0 good-count) (- (current-time) (-> self clock old-frame-counter))) + (set-time! (-> gp-0 good-time)) + ) + (else + 0 + ) + ) + (set! (-> gp-0 old-pos) sv-176) + (set-time! (-> gp-0 old-time)) + (if (and (logtest? (-> gp-0 flags) (spooler-flags blackout-on-stall)) (<= sv-176 0)) + (set-blackout-frames (seconds 0.05)) + ) + (suspend) + (let* ((f26-0 (* (- (the float (current-str-pos (-> gp-0 sid))) (-> gp-0 part-audio-start)) f30-0)) + (f0-16 (if (str-id-is-playing? (-> gp-0 sid)) + (fmax 0.0 (fmin f26-0 (the float (+ (-> (ja-group) frames num-frames) -1)))) + (fmax 0.0 (fmin (ja-frame-num 0) (the float (+ (-> (ja-group) frames num-frames) -1)))) + ) + ) + ) + (ja-no-eval :num! (seek!) :frame-num f0-16) + ) + (set! v0-62 (current-str-pos (-> gp-0 sid))) + (set! sv-176 v0-62) + ) + (set! (-> gp-0 part-audio-start) f28-0) + ) + (logclear! (-> self skel status) (joint-control-status valid-spooled-frame)) + ) + (else + (format + 0 + "ERROR: ~A in spool anim loop for ~A ~D, but not loaded.~" + self + (-> gp-0 anim name) + (-> gp-0 part) + ) + (goto cfg-139) + ) + ) + ) + (+! (-> gp-0 part) 1) + ) + (+! (-> gp-0 part) -1) + (label cfg-139) + (ja-abort-spooled-anim (-> gp-0 anim) (-> gp-0 exit) (-> gp-0 part)) + ) + 0 + ) + +;; definition for function ja-abort-spooled-anim +(defbehavior ja-abort-spooled-anim process-drawable ((arg0 spool-anim) (arg1 art-joint-anim) (arg2 int)) + (let ((s3-0 0)) + (let ((v1-1 + (lookup-gui-connection *gui-control* self (gui-channel art-load) (-> arg0 name) (new 'static 'sound-id)) + ) + ) + (when v1-1 + (set! s3-0 (the-as int (-> v1-1 id))) + (set! (-> v1-1 action) (gui-action abort)) + ) + ) + (if (zero? s3-0) + (return (the-as int #f)) + ) + (str-play-stop (-> arg0 name) (the-as sound-id s3-0)) + ) + (restore-load-state-and-cleanup *load-state*) + (set! (-> *art-control* active-stream) #f) + (logclear! (-> self skel status) (joint-control-status spooling spooling-not-last-block)) + (if (not (logtest? (-> self skel status) (joint-control-status sync-math))) + (logclear! (-> self skel status) (joint-control-status sync-math)) + ) + (cond + ((and arg1 (>= arg2 0)) + (ja-channel-push! 1 (seconds 0.03)) + (set! (-> self skel root-channel 0 frame-group) arg1) + (while (!= (-> self skel root-channel 0) (-> self skel channel)) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> arg0 name) + arg2 + -20.0 + (new 'static 'sound-id) + ) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (remove-setting! 'spooling) + (remove-setting! 'spool-anim) + 0 + ) + +;; definition for method 3 of type gui-control +(defmethod inspect ((this gui-control)) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~Tengine: ~A~%" (-> this engine)) + (let ((a2-2 (-> this engine alive-list next0))) + (-> this engine) + (let ((s5-0 (-> a2-2 next0))) + (while (!= a2-2 (-> this engine alive-list-end)) + (format #t "~T~T~`gui-connection`P~%" a2-2) + (set! a2-2 s5-0) + (-> this engine) + (set! s5-0 (-> s5-0 next0)) + ) + ) + ) + this + ) + +;; definition for method 2 of type gui-connection +(defmethod print ((this gui-connection)) + (let* ((t9-0 format) + (a0-1 #t) + (a1-0 "# this name)) + (a3-0 (-> this anim-part)) + (t0-0 (-> this id)) + (t1-0 (-> this priority)) + (v1-0 (-> this channel)) + (t2-1 (cond + ((= v1-0 (gui-channel hud-lower-left)) + "hud-lower-left" + ) + ((= v1-0 (gui-channel citizen)) + "citizen" + ) + ((= v1-0 (gui-channel pecker)) + "pecker" + ) + ((= v1-0 (gui-channel jak-effect-1)) + "jak-effect-1" + ) + ((= v1-0 (gui-channel ashelin)) + "ashelin" + ) + ((= v1-0 (gui-channel hud-lower-left-1)) + "hud-lower-left-1" + ) + ((= v1-0 (gui-channel message)) + "message" + ) + ((= v1-0 (gui-channel hud-middle-left)) + "hud-middle-left" + ) + ((= v1-0 (gui-channel gun)) + "gun" + ) + ((= v1-0 (gui-channel hud-upper-center-2)) + "hud-upper-center-2" + ) + ((= v1-0 (gui-channel hud-middle-right)) + "hud-middle-right" + ) + ((= v1-0 (gui-channel subtitle)) + "subtitle" + ) + ((= v1-0 (gui-channel notice)) + "notice" + ) + ((= v1-0 (gui-channel art-load-next)) + "art-load-next" + ) + ((= v1-0 (gui-channel voicebox)) + "voicebox" + ) + ((= v1-0 (gui-channel sig)) + "sig" + ) + ((= v1-0 (gui-channel hud-center-left)) + "hud-center-left" + ) + ((= v1-0 (gui-channel task)) + "task" + ) + ((= v1-0 (gui-channel hud-upper-right)) + "hud-upper-right" + ) + ((= v1-0 (gui-channel hud-center-right)) + "hud-center-right" + ) + ((= v1-0 (gui-channel alert)) + "alert" + ) + ((= v1-0 (gui-channel hud-upper-left)) + "hud-upper-left" + ) + ((= v1-0 (gui-channel query)) + "query" + ) + ((= v1-0 (gui-channel hud-lower-right)) + "hud-lower-right" + ) + ((= v1-0 (gui-channel screen)) + "screen" + ) + ((= v1-0 (gui-channel guard)) + "guard" + ) + ((= v1-0 (gui-channel supertitle)) + "supertitle" + ) + ((= v1-0 (gui-channel hal)) + "hal" + ) + ((= v1-0 (gui-channel hud-upper-center)) + "hud-upper-center" + ) + ((= v1-0 (gui-channel blackout)) + "blackout" + ) + ((= v1-0 (gui-channel bbush)) + "bbush" + ) + ((= v1-0 (gui-channel hud)) + "hud" + ) + ((= v1-0 (gui-channel voice)) + "voice" + ) + ((= v1-0 (gui-channel jak-mode)) + "jak-mode" + ) + ((= v1-0 (gui-channel max)) + "max" + ) + ((= v1-0 (gui-channel none)) + "none" + ) + ((= v1-0 (gui-channel freeze)) + "freeze" + ) + ((= v1-0 (gui-channel notice-low)) + "notice-low" + ) + ((= v1-0 (gui-channel art-load)) + "art-load" + ) + ((= v1-0 (gui-channel hud-auto-save-message)) + "hud-auto-save-message" + ) + ((= v1-0 (gui-channel jak)) + "jak" + ) + ((= v1-0 (gui-channel progress)) + "progress" + ) + ((= v1-0 (gui-channel resetter)) + "resetter" + ) + ((= v1-0 (gui-channel jak-effect-2)) + "jak-effect-2" + ) + ((= v1-0 (gui-channel daxter)) + "daxter" + ) + ((= v1-0 (gui-channel hud-lower-left-2)) + "hud-lower-left-2" + ) + ((= v1-0 (gui-channel background)) + "background" + ) + ((= v1-0 (gui-channel beast)) + "beast" + ) + ((= v1-0 (gui-channel hud-auto-save)) + "hud-auto-save" + ) + ((= v1-0 (gui-channel hud-lower-center)) + "hud-lower-center" + ) + ((= v1-0 (gui-channel rider)) + "rider" + ) + ((= v1-0 (gui-channel movie)) + "movie" + ) + (else + "*unknown*" + ) + ) + ) + (v1-1 (-> this action)) + ) + (t9-0 a0-1 a1-0 a2-0 a3-0 t0-0 t1-0 t2-1 (cond + ((= v1-1 (gui-action queue)) + "queue" + ) + ((= v1-1 (gui-action stop)) + "stop" + ) + ((= v1-1 (gui-action play)) + "play" + ) + ((= v1-1 (gui-action hide)) + "hide" + ) + ((= v1-1 (gui-action fade)) + "fade" + ) + ((= v1-1 (gui-action none)) + "none" + ) + ((= v1-1 (gui-action abort)) + "abort" + ) + ((= v1-1 (gui-action stopping)) + "stopping" + ) + ((= v1-1 (gui-action hidden)) + "hidden" + ) + ((= v1-1 (gui-action playing)) + "playing" + ) + (else + "*unknown*" + ) + ) + ) + ) + (let ((s5-0 format) + (s4-0 #t) + (s3-0 " ~6S @ #x~A>") + (v1-3 (get-status *gui-control* (-> this id))) + ) + (s5-0 + s4-0 + s3-0 + (cond + ((= v1-3 (gui-status ready)) + "ready" + ) + ((= v1-3 (gui-status active)) + "active" + ) + ((= v1-3 (gui-status stop)) + "stop" + ) + ((= v1-3 (gui-status unknown)) + "unknown" + ) + ((= v1-3 (gui-status hide)) + "hide" + ) + ((= v1-3 (gui-status pending)) + "pending" + ) + (else + "*unknown*" + ) + ) + this + ) + ) + this + ) + +;; definition for method 25 of type gui-control +(defmethod channel-id-set! ((this gui-control) (arg0 gui-connection) (arg1 sound-id)) + (set! (-> this ids (-> arg0 channel)) arg1) + 0 + ) + +;; definition for method 15 of type gui-control +;; WARN: Return type mismatch connectable vs gui-connection. +(defmethod lookup-gui-connection ((this gui-control) (arg0 process) (arg1 gui-channel) (arg2 string) (arg3 sound-id)) + (let ((s1-0 (-> this engine alive-list next0))) + (-> this engine) + (let ((s0-0 (-> (the-as gui-connection s1-0) next0))) + (while (!= s1-0 (-> this engine alive-list-end)) + (if (and (or (= arg1 (gui-channel none)) (= (-> (the-as gui-connection s1-0) channel) arg1)) + (or (not arg0) + (= (-> arg0 type) scene-player) + (= arg0 ((method-of-type gui-connection get-process) (the-as connection s1-0))) + ) + (or (not arg2) (string= arg2 (-> (the-as gui-connection s1-0) name))) + (or (zero? arg3) (= (-> (the-as gui-connection s1-0) id) arg3)) + ) + (return (the-as gui-connection s1-0)) + ) + (set! s1-0 s0-0) + (-> this engine) + (set! s0-0 (-> s0-0 next0)) + ) + ) + ) + (countdown (s1-1 32) + (let ((s0-1 (-> this connections s1-1))) + (if (and (nonzero? (-> s0-1 id)) + (or (= arg1 (gui-channel none)) (= (-> s0-1 channel) arg1)) + (and (or (not arg0) (= (-> arg0 type) scene-player) (= arg0 (handle->process (-> s0-1 handle)))) + (or (not arg2) (string= arg2 (-> s0-1 name))) + (or (zero? arg3) (= (-> s0-1 id) arg3)) + ) + ) + (return s0-1) + ) + ) + ) + (the-as gui-connection #f) + ) + +;; definition for method 14 of type gui-control +;; WARN: Return type mismatch int vs sound-id. +(defmethod lookup-gui-connection-id ((this gui-control) (arg0 string) (arg1 gui-channel) (arg2 gui-action)) + (let ((s2-0 (-> this engine alive-list next0))) + (-> this engine) + (let ((s1-0 (-> (the-as gui-connection s2-0) next0))) + (while (!= (the-as gui-connection s2-0) (-> this engine alive-list-end)) + (if (and (or (= arg1 (gui-channel none)) (= arg1 (-> (the-as gui-connection s2-0) channel))) + (or (= arg2 (gui-action none)) (= arg2 (-> (the-as gui-connection s2-0) action))) + (or (not arg0) (string= arg0 (-> (the-as gui-connection s2-0) name))) + ) + (return (the-as sound-id (-> (the-as gui-connection s2-0) id))) + ) + (set! s2-0 s1-0) + (-> this engine) + (set! s1-0 (-> s1-0 next0)) + ) + ) + ) + (countdown (s2-1 32) + (let ((s1-1 (-> this connections s2-1))) + (if (and (nonzero? (-> s1-1 id)) + (or (= arg1 (gui-channel none)) (= arg1 (-> s1-1 channel))) + (or (= arg2 (gui-action none)) (= arg2 (-> s1-1 action))) + (or (not arg0) (string= arg0 (-> s1-1 name))) + ) + (return (the-as sound-id (-> s1-1 id))) + ) + ) + ) + (the-as sound-id 0) + ) + +;; definition for method 20 of type gui-control +(defmethod sound-params-set! ((this gui-control) (arg0 sound-id) (arg1 symbol) (arg2 int) (arg3 int) (arg4 int) (arg5 float)) + (when (nonzero? arg0) + (let ((v1-2 (lookup-gui-connection *gui-control* (the-as process #f) (gui-channel none) (the-as string #f) arg0))) + (when v1-2 + (if arg1 + (logior! (-> v1-2 flags) (gui-connection-flags gcf1)) + ) + (when (>= arg2 0) + (logior! (-> v1-2 flags) (gui-connection-flags fo-min)) + (set! (-> v1-2 fo-min) arg2) + ) + (when (>= arg3 0) + (logior! (-> v1-2 flags) (gui-connection-flags fo-max)) + (set! (-> v1-2 fo-max) arg3) + ) + (when (>= arg4 0) + (logior! (-> v1-2 flags) (gui-connection-flags fo-curve)) + (set! (-> v1-2 fo-curve) arg4) + ) + (when (>= arg5 0.0) + (logior! (-> v1-2 flags) (gui-connection-flags volume)) + (set! (-> v1-2 volume) (the int (* 1024.0 arg5))) + ) + v1-2 + ) + ) + ) + ) + +;; definition for method 18 of type gui-control +;; WARN: Return type mismatch object vs symbol. +;; WARN: disable def twice: 34. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +(defmethod gui-control-method-18 ((this gui-control) (arg0 gui-channel)) + (let ((v1-0 arg0)) + (the-as + symbol + (cond + ((or (= v1-0 (gui-channel message)) (= v1-0 (gui-channel notice)) (= v1-0 (gui-channel notice-low))) + (not (or (logtest? (-> *art-control* frame-mask) 28) (!= *master-mode* 'game))) + ) + ((= v1-0 (gui-channel query)) + (and (not (or (logtest? (-> *art-control* frame-mask) 28) (!= *master-mode* 'game))) + (and *target* (not (logtest? (-> *target* focus-status) (focus-status dead hit)))) + ) + ) + (else + #t + ) + ) + ) + ) + ) + +;; definition for method 24 of type gui-control +(defmethod handle-command ((this gui-control) (arg0 gui-channel) (arg1 gui-channel) (arg2 symbol) (arg3 gui-connection)) + (let ((s5-0 (-> this ids arg1))) + (cond + ((nonzero? s5-0) + (case arg2 + (('wait) + (if (nonzero? (get-status this s5-0)) + (return #f) + ) + ) + (('stop 'priority-stop) + (when (nonzero? (-> this ids arg1)) + (let ((s2-0 (lookup-gui-connection this (the-as process #f) arg1 (the-as string #f) s5-0))) + (when (and s2-0 (or (= arg2 'priority) (= s2-0 arg3) (and arg3 (< (-> arg3 priority) (-> s2-0 priority))))) + (stop-str this s2-0) + (cond + ((= (shr (the-as int arg1) 4) 5) + (set! (-> this times arg1) + (the-as time-frame (max (-> this times arg1) (+ (-> *display* base-clock frame-counter) (seconds 0.1)))) + ) + (set! (-> s2-0 action) (gui-action hidden)) + ) + ((= arg1 (gui-channel query)) + (set! (-> s2-0 action) (gui-action play)) + ) + (else + (set! (-> s2-0 action) (gui-action hidden)) + ) + ) + ) + ) + ) + (if (nonzero? (get-status this s5-0)) + (return #f) + ) + ) + (('hide) + (let ((v1-34 (lookup-gui-connection this (the-as process #f) arg1 (the-as string #f) s5-0))) + (when (and v1-34 (!= (-> v1-34 action) 8)) + (set-action! + this + (gui-action hide) + s5-0 + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (set! (-> this times arg1) + (the-as time-frame (max (-> this times arg1) (+ (-> *display* base-clock frame-counter) (seconds 0.1)))) + ) + ) + ) + (if (nonzero? (get-status this s5-0)) + (return #f) + ) + ) + ) + ) + ((< (-> *display* base-clock frame-counter) (-> this times arg1)) + (if (= arg2 'wait) + (return #f) + ) + ) + ) + ) + #t + ) + +;; definition for method 19 of type gui-control +;; INFO: Used lq/sq +(defmethod handle-command-list ((this gui-control) (arg0 gui-channel) (arg1 gui-connection)) + (local-vars (sv-16 int) (sv-32 int) (sv-48 int)) + (let ((gp-0 #t)) + (cond + ((or (not (gui-control-method-18 this arg0)) (< (-> *display* base-clock frame-counter) (-> this times arg0))) + #f + ) + ((not (null? (-> this cmd arg0))) + (let* ((s2-0 (-> this cmd arg0)) + (v1-9 (car s2-0)) + ) + (while (not (null? s2-0)) + (let ((a2-1 (/ (the-as int (car v1-9)) 8)) + (s1-0 (cdr v1-9)) + ) + (case a2-1 + ((95) + (let ((s0-0 80)) + (set! sv-16 92) + (while (>= (the-as uint sv-16) (the-as uint s0-0)) + (if (not (handle-command this arg0 (the-as gui-channel s0-0) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-0 1) + ) + ) + ) + ((79) + (let ((s0-1 66)) + (set! sv-32 70) + (while (>= (the-as uint sv-32) (the-as uint s0-1)) + (if (not (handle-command this arg0 (the-as gui-channel s0-1) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-1 1) + ) + ) + ) + ((47) + (let ((s0-2 18)) + (set! sv-48 32) + (while (>= (the-as uint sv-48) (the-as uint s0-2)) + (if (not (handle-command this arg0 (the-as gui-channel s0-2) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-2 1) + ) + ) + ) + (else + (if (not (handle-command this arg0 (the-as gui-channel a2-1) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + ) + ) + ) + (set! s2-0 (cdr s2-0)) + (set! v1-9 (car s2-0)) + ) + ) + gp-0 + ) + ) + ) + ) + +;; definition for method 17 of type gui-control +;; WARN: Return type mismatch int vs gui-status. +(defmethod get-status ((this gui-control) (arg0 sound-id)) + (let ((gp-0 (the-as connectable #f))) + (if (zero? arg0) + (return (gui-status unknown)) + ) + (let ((v1-4 (-> this engine alive-list next0))) + (-> this engine) + (let ((a0-3 (-> v1-4 next0))) + (while (!= v1-4 (-> this engine alive-list-end)) + (when (= arg0 (-> (the-as gui-connection v1-4) id)) + (set! gp-0 v1-4) + (goto cfg-15) + ) + (set! v1-4 a0-3) + (-> this engine) + (set! a0-3 (-> a0-3 next0)) + ) + ) + ) + #t + (countdown (v1-10 32) + (let ((a0-7 (-> this connections v1-10))) + (when (= arg0 (-> a0-7 id)) + (set! gp-0 a0-7) + (goto cfg-15) + ) + ) + ) + (label cfg-15) + (the-as + gui-status + (cond + ((= (-> (the-as gui-connection gp-0) channel) (gui-channel movie)) + (cond + ((= (-> (the-as gui-connection gp-0) id) (-> this ids (-> (the-as gui-connection gp-0) channel))) + 3 + ) + ((handle-command-list this (-> (the-as gui-connection gp-0) channel) (the-as gui-connection gp-0)) + 2 + ) + (else + 1 + ) + ) + ) + ((let ((v1-22 (shr (the-as int (-> (the-as gui-connection gp-0) channel)) 4))) + (or (= v1-22 1) (= v1-22 2)) + ) + (case (-> (the-as gui-connection gp-0) action) + (((gui-action queue) (gui-action play) (gui-action playing) (gui-action fade) (gui-action stop)) + (cond + ((the-as gui-connection gp-0) + (dotimes (s4-0 4) + (when (and (string-charp= + (-> (the-as gui-connection gp-0) name) + (the-as (pointer uint8) (-> *sound-iop-info* stream-name s4-0)) + ) + (or (= (-> (the-as gui-connection gp-0) id) (-> *sound-iop-info* stream-id s4-0)) + (zero? (-> *sound-iop-info* stream-id s4-0)) + ) + (begin + (if (logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ss9)) + (return (gui-status stop)) + ) + (and (logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ss1 ss6)) + (if (and (>= (the-as uint (-> (the-as gui-connection gp-0) channel)) (the-as uint 16)) + (>= (the-as uint 17) (the-as uint (-> (the-as gui-connection gp-0) channel))) + ) + (= (file-status + *art-control* + (-> (the-as gui-connection gp-0) name) + (the-as int (-> (the-as gui-connection gp-0) anim-part)) + ) + 'active + ) + #t + ) + ) + ) + ) + (cond + ((logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ss4)) + (return (gui-status active)) + ) + ((or (= (-> (the-as gui-connection gp-0) id) (-> this ids (-> (the-as gui-connection gp-0) channel))) + (handle-command-list this (-> (the-as gui-connection gp-0) channel) (the-as gui-connection gp-0)) + ) + (return (gui-status ready)) + ) + (else + (return (gui-status pending)) + ) + ) + (the-as none 0) + ) + ) + 1 + ) + (else + 0 + ) + ) + ) + (else + 0 + ) + ) + ) + ((= (shr (the-as int (-> (the-as gui-connection gp-0) channel)) 4) 5) + (cond + ((= (-> (the-as gui-connection gp-0) id) (-> this ids (-> (the-as gui-connection gp-0) channel))) + (if (or (= (-> (the-as gui-connection gp-0) action) (gui-action hide)) + (= (-> (the-as gui-connection gp-0) action) (gui-action hidden)) + ) + 4 + 3 + ) + ) + ((handle-command-list this (-> (the-as gui-connection gp-0) channel) (the-as gui-connection gp-0)) + 2 + ) + (else + 1 + ) + ) + ) + (else + (case (shr (the-as int (-> (the-as gui-connection gp-0) channel)) 4) + ((4 5) + (cond + ((= (-> (the-as gui-connection gp-0) id) (-> this ids (-> (the-as gui-connection gp-0) channel))) + 3 + ) + ((handle-command-list this (-> (the-as gui-connection gp-0) channel) (the-as gui-connection gp-0)) + 2 + ) + (else + 1 + ) + ) + ) + (else + 0 + ) + ) + ) + ) + ) + ) + ) + +;; definition for method 16 of type gui-control +(defmethod set-action! ((this gui-control) + (arg0 gui-action) + (arg1 sound-id) + (arg2 gui-channel) + (arg3 gui-action) + (arg4 string) + (arg5 (function gui-connection symbol)) + (arg6 process) + ) + (local-vars (sv-16 gui-action) (sv-17 gui-action) (sv-20 string) (sv-24 (function gui-connection symbol))) + (set! sv-16 arg0) + (set! sv-17 arg3) + (set! sv-20 arg4) + (set! sv-24 arg5) + (let ((s1-0 (-> this engine alive-list next0))) + (-> this engine) + (let ((s0-0 (-> s1-0 next0))) + (while (!= s1-0 (-> this engine alive-list-end)) + (when (and (or (= arg1 1) (= arg1 (-> (the-as gui-connection s1-0) id))) + (or (= arg2 (gui-channel none)) (= arg2 (-> (the-as gui-connection s1-0) channel))) + (or (= sv-17 (gui-action none)) (= sv-17 (-> (the-as gui-connection s1-0) action))) + (or (not sv-20) (string= sv-20 (-> (the-as gui-connection s1-0) name))) + (or (not arg5) (arg5 (the-as gui-connection s1-0))) + (or (not arg6) (= arg6 (get-process (the-as gui-connection s1-0)))) + ) + (cond + ((and (= sv-16 (gui-action hide)) + (!= (-> this ids (-> (the-as gui-connection s1-0) channel)) (-> (the-as gui-connection s1-0) id)) + ) + (set! (-> (the-as gui-connection s1-0) action) (gui-action hidden)) + ) + ((and (= sv-16 (gui-action play)) (= (-> (the-as gui-connection s1-0) action) (gui-action playing))) + ) + (else + (set! (-> (the-as gui-connection s1-0) action) sv-16) + (if (and (= sv-16 'play) + (handle-command-list this (-> (the-as gui-connection s1-0) channel) (the-as gui-connection s1-0)) + ) + (channel-id-set! this (the-as gui-connection s1-0) (-> (the-as gui-connection s1-0) id)) + ) + ) + ) + ) + (set! s1-0 s0-0) + (-> this engine) + (set! s0-0 (-> s0-0 next0)) + ) + ) + ) + 0 + ) + +;; definition for method 9 of type gui-control +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs sound-id. +(defmethod add-process ((this gui-control) + (arg0 process) + (arg1 gui-channel) + (arg2 gui-action) + (arg3 string) + (arg4 float) + (arg5 time-frame) + ) + (local-vars + (sv-16 int) + (sv-20 gui-connection) + (sv-32 connectable) + (sv-48 connectable) + (sv-64 connectable) + (sv-80 int) + ) + (set! sv-32 (the-as connectable #f)) + (set! sv-48 (-> this engine alive-list next0)) + (-> this engine) + (set! sv-64 (-> sv-48 next0)) + (while (!= sv-48 (-> this engine alive-list-end)) + (when (and (= arg1 (-> (the-as gui-connection sv-48) channel)) + (string= arg3 (-> (the-as gui-connection sv-48) name)) + (= ((method-of-type gui-connection get-process) (the-as connection sv-48)) arg0) + ) + (set! sv-32 sv-48) + (goto cfg-12) + ) + (set! sv-48 sv-64) + (-> this engine) + (set! sv-64 (-> sv-64 next0)) + ) + (label cfg-12) + (when (not sv-32) + (set! sv-16 0) + (set! sv-80 32) + (while (nonzero? sv-80) + (set! sv-80 (+ sv-80 -1)) + (set! sv-20 (-> this connections sv-80)) + (if (and (nonzero? (-> sv-20 id)) + (= arg1 (-> sv-20 channel)) + (string= arg3 (-> sv-20 name)) + (>= (-> sv-20 priority) -1.0) + ) + (set! sv-16 (the-as int (-> sv-20 id))) + ) + ) + (if (zero? sv-16) + (set! sv-16 (the-as int (new-sound-id))) + ) + (set! sv-32 (add-connection (-> this engine) arg0 arg4 0 arg3 sv-16)) + (the-as connection sv-32) + ) + (the-as sound-id (cond + (sv-32 + (set! (-> (the-as gui-connection sv-32) priority) arg4) + (set! (-> (the-as gui-connection sv-32) channel) arg1) + (set! (-> (the-as gui-connection sv-32) action) arg2) + (set! (-> (the-as gui-connection sv-32) param2) (the-as int arg3)) + (set! (-> (the-as gui-connection sv-32) hold-time) arg5) + (set! (-> (the-as gui-connection sv-32) flags) (gui-connection-flags gcf0)) + (set! (-> (the-as gui-connection sv-32) fade) (the-as uint 0)) + (the-as int (-> (the-as gui-connection sv-32) id)) + ) + (else + (format 0 "ERROR: could not connection ~A to gui engine.~%" arg0) + 0 + ) + ) + ) + ) + +;; definition for method 10 of type gui-control +(defmethod remove-process ((this gui-control) (arg0 process) (arg1 gui-channel)) + (let ((con-i-0 (the-as gui-connection (-> this engine alive-list next0)))) + (-> this engine) + (let ((s2-0 (-> (the-as connectable con-i-0) next0))) + (while (!= con-i-0 (-> this engine alive-list-end)) + (if (and (= arg1 (-> con-i-0 channel)) (= arg0 (get-process con-i-0))) + (move-to-dead con-i-0) + ) + (set! con-i-0 (the-as gui-connection s2-0)) + (-> this engine) + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + 0 + ) + +;; definition for method 12 of type gui-control +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs sound-id. +(defmethod gui-control-method-12 ((this gui-control) + (arg0 process) + (arg1 gui-channel) + (arg2 gui-action) + (arg3 string) + (arg4 int) + (arg5 float) + (arg6 sound-id) + ) + (local-vars + (sv-16 gui-connection) + (sv-20 int) + (sv-24 gui-connection) + (sv-28 process) + (sv-32 int) + (sv-48 sound-id) + ) + (set! sv-48 arg6) + (set! sv-16 (the-as gui-connection #f)) + (set! sv-20 0) + (set! sv-32 32) + (while (nonzero? sv-32) + (set! sv-32 (+ sv-32 -1)) + (set! sv-24 (-> this connections sv-32)) + (when (and (nonzero? (-> sv-24 id)) + (= arg1 (-> sv-24 channel)) + (let ((v1-14 (handle->process (-> sv-24 handle)))) + (and (or (= v1-14 arg0) (= (-> arg0 type) scene-player) (and v1-14 (= (-> v1-14 type) scene-player))) + (and (string= arg3 (-> sv-24 name)) (= arg4 (-> sv-24 anim-part))) + ) + ) + ) + (when (< (-> sv-24 priority) arg5) + (set! (-> sv-24 time-stamp) (-> this update-time)) + (return (the-as sound-id (-> sv-24 id))) + ) + (set! sv-16 sv-24) + (goto cfg-44) + ) + ) + (countdown (v1-33 32) + (let ((a0-15 (-> this connections v1-33))) + (when (or (zero? (-> a0-15 id)) (not (handle->process (-> a0-15 handle)))) + (set! sv-16 a0-15) + (set! (-> sv-16 param3) 0) + (set! (-> sv-16 flags) (gui-connection-flags)) + (goto cfg-44) + ) + ) + ) + (label cfg-44) + (the-as + sound-id + (cond + (sv-16 + (when (zero? (-> (the-as gui-connection sv-16) id)) + (when (zero? sv-20) + (let ((v1-46 (lookup-gui-connection this arg0 arg1 arg3 (new 'static 'sound-id)))) + (if v1-46 + (set! sv-20 (the-as int (-> v1-46 id))) + ) + ) + ) + (if (zero? sv-20) + (set! sv-20 (the-as int sv-48)) + ) + (set! (-> sv-16 param3) (if (nonzero? sv-20) + sv-20 + (the-as int (new-sound-id)) + ) + ) + ) + (when (= arg5 -99.0) + (let ((s2-1 arg0)) + (set! sv-28 (if (type? s2-1 process-drawable) + s2-1 + ) + ) + ) + (set! arg5 (if sv-28 + (vector-vector-distance (target-pos 0) (-> (the-as process-drawable sv-28) root trans)) + -1.0 + ) + ) + ) + (set! (-> sv-16 time-stamp) (-> this update-time)) + (set! (-> sv-16 handle) (process->handle arg0)) + (set! (-> sv-16 priority) arg5) + (set! (-> sv-16 channel) arg1) + (set! (-> sv-16 action) arg2) + (set! (-> sv-16 anim-part) (the-as uint arg4)) + (set! (-> sv-16 param2) (the-as int arg3)) + (set! (-> sv-16 fade) (the-as uint 0)) + (the-as int (-> (the-as gui-connection sv-16) id)) + ) + (else + 0 + ) + ) + ) + ) + +;; definition for method 22 of type gui-control +(defmethod gui-control-method-22 ((this gui-control) (arg0 gui-connection) (arg1 vector)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (let ((s5-0 (-> this spool-connections))) + (case (-> arg0 action) + (((gui-action queue) (gui-action play) (gui-action playing) (gui-action fade)) + (let ((f30-0 (-> arg0 priority))) + (when (= f30-0 -99.0) + (let* ((s2-0 (get-process arg0)) + (v1-10 (if (type? s2-0 process-drawable) + s2-0 + ) + ) + ) + (set! f30-0 (cond + ((= (-> arg0 id) (-> this ids (-> arg0 channel))) + -1.0 + ) + (v1-10 + (vector-vector-distance arg1 (-> (the-as process-drawable v1-10) root trans)) + ) + (else + -1.0 + ) + ) + ) + ) + ) + (dotimes (s4-1 4) + (cond + ((>= (-> s5-0 s4-1 priority) f30-0) + (let ((s3-1 s4-1)) + (while (< s3-1 4) + (when (= (-> s5-0 s3-1 id) (-> arg0 id)) + (let ((s2-1 s3-1)) + (while (< s2-1 3) + (mem-copy! (the-as pointer (-> s5-0 s2-1)) (the-as pointer (-> s5-0 (+ s2-1 1))) 48) + (+! s2-1 1) + ) + ) + (set! (-> s5-0 3 param2) (the-as int "")) + (set! (-> s5-0 3 priority) 100000000.0) + ) + (+! s3-1 1) + ) + ) + (let ((s3-2 3)) + (while (!= s3-2 s4-1) + (mem-copy! (the-as pointer (-> s5-0 s3-2)) (the-as pointer (-> s5-0 (+ s3-2 -1))) 48) + (+! s3-2 -1) + ) + ) + (mem-copy! (the-as pointer (-> s5-0 s4-1)) (the-as pointer arg0) 48) + (set! (-> s5-0 s4-1 priority) f30-0) + (goto cfg-42) + ) + ((= (-> s5-0 s4-1 id) (-> arg0 id)) + (goto cfg-42) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (label cfg-42) + 0 + ) + +;; definition for method 11 of type gui-control +(defmethod stop-str ((this gui-control) (arg0 gui-connection)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (if (= (get-status this (-> arg0 id)) (gui-status active)) + (str-play-stop (-> arg0 name) (-> arg0 id)) + ) + ) + ) + (if (= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! this arg0 (new 'static 'sound-id)) + ) + 0 + ) + +;; definition for method 21 of type gui-control +(defmethod gui-control-method-21 ((this gui-control) (arg0 gui-connection)) + (with-pp + (when *sound-player-enable* + (let ((gp-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> gp-0 command) (sound-command set-param)) + (set! (-> gp-0 id) (-> arg0 id)) + (set! (-> gp-0 params mask) (the-as uint 0)) + (when (logtest? (-> arg0 flags) (gui-connection-flags gcf1)) + (let* ((s4-0 (get-process arg0)) + (v1-8 (if (type? s4-0 process-drawable) + s4-0 + ) + ) + ) + (when (and v1-8 (nonzero? (-> (the-as process-drawable v1-8) root))) + (let ((a1-3 (-> (the-as process-drawable v1-8) root trans))) + (let ((s4-1 pp)) + (when (= a1-3 #t) + (if (and s4-1 (type? s4-1 process-drawable) (nonzero? (-> (the-as process-drawable s4-1) root))) + (set! a1-3 (-> (the-as process-drawable s4-1) root trans)) + (set! a1-3 (the-as vector #f)) + ) + ) + ) + (sound-trans-convert (-> gp-0 params trans) a1-3) + ) + (logior! (-> gp-0 params mask) 32) + ) + ) + ) + (set! (-> gp-0 params fo-curve) (-> arg0 fo-curve)) + (set! (-> gp-0 params fo-min) (-> arg0 fo-min)) + (set! (-> gp-0 params fo-max) (-> arg0 fo-max)) + (set! (-> gp-0 params volume) (-> arg0 volume)) + (if (logtest? (-> arg0 flags) (gui-connection-flags fo-curve)) + (logior! (-> gp-0 params mask) 256) + ) + (if (logtest? (-> arg0 flags) (gui-connection-flags fo-min)) + (logior! (-> gp-0 params mask) 64) + ) + (if (logtest? (-> arg0 flags) (gui-connection-flags fo-max)) + (logior! (-> gp-0 params mask) 128) + ) + (if (logtest? (-> arg0 flags) (gui-connection-flags volume)) + (logior! (-> gp-0 params mask) 1) + ) + ) + ) + 0 + ) + ) + +;; definition for method 23 of type gui-control +;; WARN: Return type mismatch int vs none. +(defmethod update-connection ((this gui-control) (arg0 gui-connection) (arg1 process) (arg2 symbol)) + (local-vars (v1-75 symbol)) + (when (and (>= (the-as uint (-> arg0 channel)) (the-as uint 16)) + (>= (the-as uint 17) (the-as uint (-> arg0 channel))) + ) + (case (-> arg0 action) + (((gui-action queue)) + (spool-push *art-control* (-> arg0 name) (the-as int (-> arg0 anim-part)) arg1 (-> arg0 priority)) + (if (and (logtest? (-> arg0 flags) (gui-connection-flags gcf0)) + (= (get-status this (-> arg0 id)) (gui-status active)) + ) + (set! (-> arg0 action) (gui-action playing)) + ) + ) + ) + ) + (let ((v1-16 (-> arg0 action))) + (b! (!= v1-16 (gui-action play)) cfg-47 :delay (empty-form)) + (if (handle-command-list this (-> arg0 channel) arg0) + (channel-id-set! this arg0 (-> arg0 id)) + ) + (let ((s3-0 (get-status this (-> arg0 id)))) + (if (and (logtest? (-> arg0 flags) (gui-connection-flags gcf1 fo-curve fo-min fo-max volume)) + (logtest? (-> arg0 flags) (gui-connection-flags gcf0)) + ) + (gui-control-method-21 this arg0) + ) + (cond + ((or (not (gui-control-method-18 this (-> arg0 channel))) (= s3-0 (gui-status stop))) + (if (= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! this arg0 (new 'static 'sound-id)) + ) + (if (and arg2 (or (< (shr (the-as int (-> arg0 channel)) 4) (the-as uint 4)) (= s3-0 (gui-status stop)))) + (move-to-dead arg0) + ) + ) + ((= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (cond + ((= s3-0 (gui-status ready)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (if (not (paused?)) + (str-play-async + (-> arg0 name) + (-> arg0 id) + (if (logtest? (-> arg0 flags) (gui-connection-flags volume)) + (-> arg0 volume) + 1024 + ) + (the-as int (-> this group (-> arg0 channel))) + ) + ) + ) + ) + ) + ((= s3-0 (gui-status active)) + (set! (-> arg0 action) (gui-action playing)) + ) + ) + ) + ) + ) + (b! #t cfg-124 :delay (nop!)) + (label cfg-47) + (b! (not (or (= v1-16 (gui-action playing)) (= v1-16 (gui-action fade)))) cfg-102 :delay (empty-form)) + (b! + (not (and (= (get-status this (-> arg0 id)) (gui-status active)) + (gui-control-method-18 this (-> arg0 channel)) + (or (= (-> arg0 action) (gui-action playing)) (< (-> arg0 fade) (the-as uint 30))) + ) + ) + cfg-91 + :delay (nop!) + ) + (channel-id-set! this arg0 (-> arg0 id)) + (set! (-> this times 0) 0) + (let ((v1-73 (shr (the-as int (-> arg0 channel)) 4))) + (set! v1-75 + (and (or (= v1-73 1) (= v1-73 2)) + (not (and (>= (the-as uint (-> arg0 channel)) (the-as uint 16)) + (>= (the-as uint 17) (the-as uint (-> arg0 channel))) + ) + ) + (begin + (dotimes (s3-1 4) + (when (and (string-charp= (-> arg0 name) (the-as (pointer uint8) (-> *sound-iop-info* stream-name s3-1))) + (= (-> arg0 id) (-> *sound-iop-info* stream-id s3-1)) + (logtest? (-> *sound-iop-info* stream-status s3-1) (stream-status ss6)) + ) + (set! v1-75 #t) + (goto cfg-81) + ) + ) + #f + ) + ) + ) + ) + (label cfg-81) + (b! v1-75 cfg-91 :delay (nop!)) + (if (and (logtest? (-> arg0 flags) (gui-connection-flags gcf1 fo-curve fo-min fo-max volume)) + (logtest? (-> arg0 flags) (gui-connection-flags gcf0)) + ) + (gui-control-method-21 this arg0) + ) + (when (= (-> arg0 action) (gui-action fade)) + (set! (-> arg0 fade) (the-as uint (seekl (the-as int (-> arg0 fade)) 30 1))) + (when *sound-player-enable* + (let ((s5-1 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> s5-1 command) (sound-command set-param)) + (set! (-> s5-1 id) (-> arg0 id)) + (set! (-> s5-1 params volume) (the int (* 1024.0 (lerp-scale 1.0 0.0 (the float (-> arg0 fade)) 0.0 30.0)))) + (set! (-> s5-1 params mask) (the-as uint 1)) + (-> s5-1 id) + ) + ) + ) + (b! #t cfg-101 :delay (nop!)) + (label cfg-91) + (when (= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! this arg0 (new 'static 'sound-id)) + (set! (-> this times (-> arg0 channel)) (+ (-> *display* base-clock frame-counter) (-> arg0 hold-time))) + ) + (if (and arg2 (or (< (shr (the-as int (-> arg0 channel)) 4) (the-as uint 4)) + (= (get-status this (-> arg0 id)) (gui-status stop)) + ) + ) + (move-to-dead arg0) + (set! (-> arg0 action) (gui-action play)) + ) + (label cfg-101) + (b! #t cfg-124 :delay (nop!)) + (label cfg-102) + (cond + ((= v1-16 (gui-action stop)) + (stop-str this arg0) + (if arg2 + (move-to-dead arg0) + ) + ) + ((= v1-16 (gui-action abort)) + (if (= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! this arg0 (new 'static 'sound-id)) + ) + (if arg2 + (move-to-dead arg0) + ) + ) + ((= v1-16 (gui-action hide)) + ) + ((= v1-16 (gui-action hidden)) + (cond + ((or (< (shr (the-as int (-> arg0 channel)) 4) (the-as uint 4)) + (= (get-status this (-> arg0 id)) (gui-status stop)) + ) + (stop-str this arg0) + (if arg2 + (move-to-dead arg0) + ) + ) + (else + (if (= (-> this ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! this arg0 (new 'static 'sound-id)) + ) + ) + ) + ) + ) + ) + (label cfg-124) + 0 + (none) + ) + +;; definition for method 13 of type gui-control +(defmethod update ((this gui-control) (arg0 symbol)) + (set! (-> this ids 65) + (the-as sound-id (if (and (>= (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (= (-> *setting-control* user-current bg-a) 0.0) + (= (-> *setting-control* user-current bg-a-force) 0.0) + ) + 0 + 1 + ) + ) + ) + (let ((s4-0 (target-pos 0))) + (dotimes (v1-8 4) + (set! (-> this spool-connections v1-8 param2) (the-as int #f)) + (set! (-> this spool-connections v1-8 param3) 0) + (set! (-> this spool-connections v1-8 priority) 100000000.0) + ) + (let ((con-i-0 (the-as gui-connection (-> this engine alive-list next0)))) + (-> this engine) + (let ((s2-0 (-> (the-as connectable con-i-0) next0))) + (while (!= (the-as connectable con-i-0) (-> this engine alive-list-end)) + (gui-control-method-22 this con-i-0 s4-0) + (case (-> con-i-0 action) + (((gui-action playing)) + (channel-id-set! this con-i-0 (-> con-i-0 id)) + ) + ) + (set! con-i-0 (the-as gui-connection s2-0)) + (-> this engine) + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + (let ((s3-1 (-> this update-time))) + (countdown (s2-1 32) + (let ((s1-0 (-> this connections s2-1))) + (when (nonzero? (-> s1-0 id)) + (cond + ((= (-> s1-0 time-stamp) s3-1) + (gui-control-method-22 this s1-0 s4-0) + ) + (else + (if (= (-> this ids (-> s1-0 channel)) (-> s1-0 id)) + (channel-id-set! this s1-0 (new 'static 'sound-id)) + ) + (set! (-> s1-0 param3) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (let ((s4-1 (new 'stack-no-clear 'array 'sound-id 4)) + (s3-2 0) + ) + (let ((s2-2 (-> *setting-control* user-current movie-name))) + (dotimes (s1-1 4) + (set! (-> s4-1 s1-1) (-> this spool-connections s1-1 id)) + (when (and (-> this spool-connections s1-1 name) (case (-> this spool-connections s1-1 channel) + (((gui-channel art-load) (gui-channel art-load-next)) + #t + ) + ) + ) + (set! s3-2 (logior s3-2 (ash 1 s1-1))) + (if (and s2-2 (string= (-> this spool-connections s1-1 name) (the-as string s2-2))) + (set! s3-2 (logior s3-2 (ash 1 (+ s1-1 4)))) + ) + ) + ) + ) + (let* ((t9-6 str-play-queue) + (v1-69 (-> this spool-connections 0 name)) + (a0-32 (if v1-69 + v1-69 + ) + ) + (v1-70 (-> this spool-connections 1 name)) + (a1-7 (if v1-70 + v1-70 + ) + ) + (v1-71 (-> this spool-connections 2 name)) + (a2-4 (if v1-71 + v1-71 + ) + ) + (v1-72 (-> this spool-connections 3 name)) + ) + (t9-6 + a0-32 + a1-7 + a2-4 + (if v1-72 + v1-72 + ) + s4-1 + (the-as pointer s3-2) + ) + ) + ) + (-> this engine) + (let ((con-i-1 (the-as gui-connection (-> this engine alive-list-end prev0)))) + (-> this engine) + (let ((s4-2 (-> (the-as connectable con-i-1) prev0))) + (while (!= (the-as connectable con-i-1) (-> this engine alive-list)) + (update-connection this con-i-1 ((method-of-type connection get-process) (the-as connection con-i-1)) #t) + (set! con-i-1 (the-as gui-connection s4-2)) + (-> this engine) + (set! s4-2 (-> s4-2 prev0)) + ) + ) + ) + (countdown (s4-3 32) + (let ((v1-91 (-> this connections s4-3))) + (if (nonzero? (-> v1-91 id)) + (update-connection this v1-91 (handle->process (-> v1-91 handle)) #f) + ) + ) + ) + (when arg0 + (when *display-art-control* + (dotimes (s5-1 4) + (let ((a3-4 (-> this spool-connections s5-1))) + (if (-> a3-4 name) + (format *stdcon* "~D: ~`gui-connection`P~%" s5-1 a3-4) + ) + ) + ) + (dotimes (s5-2 4) + (format + *stdcon* + "~0KCh ~D: ~8D ~5X ~6D ~G~1K~%" + s5-2 + (-> *sound-iop-info* stream-id-signed s5-2) + (-> *sound-iop-info* stream-status s5-2) + (-> *sound-iop-info* stream-position s5-2) + (-> *sound-iop-info* stream-name s5-2) + ) + ) + ) + (when *display-gui-control* + (-> this engine) + (let ((a2-12 (-> this engine alive-list-end prev0))) + (-> this engine) + (let ((s5-3 (-> a2-12 prev0))) + (while (!= a2-12 (-> this engine alive-list)) + (format *stdcon* "c: ~`gui-connection`P~%" a2-12) + (set! a2-12 s5-3) + (-> this engine) + (set! s5-3 (-> s5-3 prev0)) + ) + ) + ) + (countdown (s5-4 32) + (let ((a2-13 (-> this connections s5-4))) + (if (nonzero? (-> a2-13 id)) + (format *stdcon* "l: ~`gui-connection`P~%" a2-13) + ) + ) + ) + ) + ) + (set! (-> this update-time) (-> *display* base-clock frame-counter)) + 0 + ) + +;; definition for method 0 of type gui-control +(defmethod new gui-control ((allocation symbol) (type-to-make type) (arg0 int)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> gp-0 engine) ((method-of-type engine new) allocation engine 'gui-control arg0 gui-connection)) + (dotimes (v1-3 32) + (set! (-> gp-0 connections v1-3 handle) (the-as handle #f)) + ) + (dotimes (v1-6 96) + (set! (-> gp-0 cmd v1-6) '()) + (set! (-> gp-0 group v1-6) (sound-group music)) + ) + (set! (-> gp-0 cmd 64) '((64 . wait) (72 . wait) (65 . wait) (66 . stop) (95 . stop))) + (set! (-> gp-0 cmd 72) '((64 . wait) (72 . wait) (65 . wait) (66 . stop) (95 . hide))) + (set! (-> gp-0 cmd 73) '((64 . wait) (73 . wait) (65 . wait) (66 . stop) (67 . stop) (95 . hide))) + (set! (-> gp-0 cmd 74) '((64 . wait) (72 . wait) (65 . wait) (73 . wait) (87 . hide) (89 . hide))) + (set! (-> gp-0 cmd 66) + '((64 . wait) + (65 . wait) + (68 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + (92 . hide) + ) + ) + (set! (-> gp-0 cmd 67) + '((64 . wait) + (65 . wait) + (68 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + (82 . hide) + (92 . hide) + ) + ) + (set! (-> gp-0 cmd 68) + '((65 . wait) + (68 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + (82 . hide) + (92 . hide) + ) + ) + (set! (-> gp-0 cmd 71) + '((65 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + (82 . hide) + (92 . hide) + ) + ) + (set! (-> gp-0 cmd 69) '((65 . wait) (71 . wait) (67 . wait) (66 . wait))) + (set! (-> gp-0 cmd 70) '((65 . wait) (90 . hide) (91 . hide) (81 . hide) (80 . hide) (94 . wait))) + (set! (-> gp-0 cmd 80) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (80 . wait) (70 . wait))) + (set! (-> gp-0 cmd 81) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (81 . wait) (70 . wait))) + (set! (-> gp-0 cmd 82) + '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (67 . wait) (71 . wait) (69 . wait) (82 . wait)) + ) + (set! (-> gp-0 cmd 83) + '((64 . wait) + (72 . wait) + (73 . wait) + (65 . wait) + (67 . wait) + (71 . wait) + (69 . wait) + (66 . wait) + (83 . wait) + (84 . hide) + (85 . hide) + ) + ) + (set! (-> gp-0 cmd 84) + '((64 . wait) + (72 . wait) + (73 . wait) + (65 . wait) + (67 . wait) + (71 . wait) + (69 . wait) + (66 . wait) + (83 . wait) + (84 . wait) + ) + ) + (set! (-> gp-0 cmd 85) + '((64 . wait) + (72 . wait) + (73 . wait) + (65 . wait) + (67 . wait) + (71 . wait) + (69 . wait) + (66 . wait) + (83 . wait) + (85 . wait) + ) + ) + (set! (-> gp-0 cmd 86) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (86 . wait) (93 . wait))) + (set! (-> gp-0 cmd 87) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (87 . wait) (74 . wait))) + (set! (-> gp-0 cmd 88) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (88 . wait) (93 . wait))) + (set! (-> gp-0 cmd 89) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (89 . wait) (74 . wait))) + (set! (-> gp-0 cmd 92) + '((64 . wait) + (72 . wait) + (73 . wait) + (65 . wait) + (92 . wait) + (69 . wait) + (68 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + ) + ) + (set! (-> gp-0 cmd 90) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (90 . wait) (70 . wait))) + (set! (-> gp-0 cmd 91) '((64 . wait) (72 . wait) (73 . wait) (65 . wait) (91 . wait) (70 . wait))) + (set! (-> gp-0 cmd 93) '((65 . wait) (86 . hide) (88 . hide))) + (set! (-> gp-0 cmd 94) '((65 . wait) (94 . wait) (70 . hide))) + (set! (-> gp-0 cmd 16) '((16 . wait))) + (set! (-> gp-0 cmd 17) '((17 . wait))) + (set! (-> gp-0 cmd 18) '((18 . wait))) + (set! (-> gp-0 cmd 27) '((27 . wait))) + (set! (-> gp-0 cmd 31) '((31 . wait))) + (set! (-> gp-0 cmd 24) '((64 . wait) (24 . wait))) + (set! (-> gp-0 cmd 26) '((64 . wait) (26 . wait))) + (set! (-> gp-0 cmd 36) '((64 . wait) (36 . wait))) + (set! (-> gp-0 cmd 32) '((64 . wait) (32 . wait))) + (set! (-> gp-0 cmd 30) '((64 . wait) (30 . wait))) + (set! (-> gp-0 cmd 33) '((64 . wait) (33 . wait))) + (set! (-> gp-0 cmd 34) '((64 . wait) (34 . wait))) + (set! (-> gp-0 cmd 20) '((64 . wait) (20 . wait) (19 . wait) (29 . wait) (25 . wait))) + (set! (-> gp-0 cmd 19) '((64 . wait) (20 . wait) (19 . wait) (29 . wait) (25 . wait))) + (set! (-> gp-0 cmd 25) '((64 . wait) (20 . wait) (19 . wait) (29 . wait) (25 . wait))) + (set! (-> gp-0 cmd 29) '((64 . wait) (20 . wait) (19 . wait) (29 . wait) (25 . wait))) + (set! (-> gp-0 cmd 21) + '((64 . wait) (21 . wait) (22 . wait) (23 . wait) (25 . wait) (19 . wait) (28 . wait) (35 . wait)) + ) + (set! (-> gp-0 cmd 22) + '((64 . wait) (21 . wait) (22 . wait) (23 . wait) (25 . wait) (19 . wait) (28 . wait) (35 . wait)) + ) + (set! (-> gp-0 cmd 23) + '((64 . wait) (21 . wait) (22 . wait) (23 . wait) (25 . wait) (19 . wait) (28 . wait) (35 . wait)) + ) + (set! (-> gp-0 cmd 28) + '((64 . wait) (21 . wait) (22 . wait) (23 . wait) (25 . wait) (19 . wait) (28 . wait) (35 . wait)) + ) + (set! (-> gp-0 cmd 35) + '((64 . wait) (21 . wait) (22 . wait) (23 . wait) (25 . wait) (19 . wait) (28 . wait) (35 . wait)) + ) + (set! (-> gp-0 group 18) (sound-group)) + (set! (-> gp-0 group 27) (sound-group)) + (set! (-> gp-0 group 31) (sound-group)) + (set! (-> gp-0 group 24) (sound-group music dialog)) + (set! (-> gp-0 group 26) (sound-group music dialog)) + (set! (-> gp-0 group 36) (sound-group music dialog)) + gp-0 + ) + ) + +;; failed to figure out what this is: +(kmemopen global "gui-controls") + +;; definition for symbol *gui-control*, type gui-control +(define *gui-control* (new 'global 'gui-control 64)) + +;; failed to figure out what this is: +(if (zero? *art-control*) + (set! *art-control* (new 'global 'external-art-control)) + ) + +;; failed to figure out what this is: +(kmemclose) diff --git a/test/decompiler/reference/jak3/engine/sound/gsound_REF.gc b/test/decompiler/reference/jak3/engine/sound/gsound_REF.gc index eba549144f..980bad625e 100644 --- a/test/decompiler/reference/jak3/engine/sound/gsound_REF.gc +++ b/test/decompiler/reference/jak3/engine/sound/gsound_REF.gc @@ -71,36 +71,37 @@ ;; 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) + ((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) + (stream-id-signed int32 4 :overlay-at (-> stream-id 0)) + (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) ) ) @@ -1479,7 +1480,3 @@ 0 (none) ) - - - -