From b6f0ef52b36adcb3d32646163d883eff5c1eb112 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Fri, 14 Oct 2022 20:47:59 -0400 Subject: [PATCH] [decomp] fixes for loader and game-info (#1968) Fixes for the functions that weren't decompiled. `initialize` in `game-info.gc` was fixed manually. --- decompiler/config/jak2/all-types.gc | 2 +- decompiler/config/jak2/hacks.jsonc | 20 +- decompiler/config/jak2/type_casts.jsonc | 6 + goal_src/jak2/engine/ambient/ambient-h.gc | 2 + goal_src/jak2/engine/entity/entity-h.gc | 2 +- goal_src/jak2/engine/game/game-info-h.gc | 2 +- goal_src/jak2/engine/game/game-info.gc | 428 +++++++++++------- goal_src/jak2/engine/game/settings.gc | 1 + goal_src/jak2/engine/load/loader.gc | 247 +++++++++- goalc/compiler/compilation/Function.cpp | 3 +- .../jak2/engine/game/game-info-h_REF.gc | 2 +- .../jak2/engine/game/game-info_REF.gc | 2 +- .../reference/jak2/engine/load/loader_REF.gc | 217 ++++++++- 13 files changed, 758 insertions(+), 176 deletions(-) diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 8a7e742e7..03f789e20 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -12783,7 +12783,7 @@ (game-info-method-23 (_type_ game-save string) int 23) (game-info-method-24 (_type_ game-save) none 24) (you-suck-stage (_type_ symbol) int 25) - (you-suck-scale (_type_) float 26) + (you-suck-scale (_type_ object) float 26) (get-next-attack-id (_type_) uint 27) (game-info-method-28 (_type_ game-score float) int 28) (get-game-score-ref (_type_ int) (pointer float) 29) diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index 40b4b62c8..048389ab0 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -344,7 +344,25 @@ "(method 44 nav-graph)": [1, 3, 6, 13, 17], "(method 11 sparticle-launch-control)": [ 18, 24, 25, 28, 29, 32, 33, 34, 36, 41, 55, 58, 93, 95 - ] + ], + + "(method 22 gui-control)": [ +10, // goto L63 (B39) +16, // goto L58 (B27) +26, // goto L62 (B) +27, // goto L62 +28, // goto L61 +35, // goto L62 +36, // goto L62 +38, // goto L99 +42, // goto L89 +50, // goto L84 +108, // goto L86 +110, // goto L86 +116, // goto L99 +117, // goto L91 +120 +] // "(method 67 collide-shape-moving)": [1, 7, 9, 10, 11, 12] - TODO }, diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index c838e99da..5f153f31d 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -3482,6 +3482,12 @@ "(method 7 drop-plat)": [ [18, "v1", "external-art-buffer"] ], + "(method 22 gui-control)": [ + [[268, 315], "s4", "process-drawable"], + [[275,338], "s5", "sound-rpc-set-param"], + [[351,375], "s5", "sound-rpc-set-param"] + + ], // placeholder "placeholder-do-not-add-below": [] } diff --git a/goal_src/jak2/engine/ambient/ambient-h.gc b/goal_src/jak2/engine/ambient/ambient-h.gc index 068c15d74..5e515f0f4 100644 --- a/goal_src/jak2/engine/ambient/ambient-h.gc +++ b/goal_src/jak2/engine/ambient/ambient-h.gc @@ -5,6 +5,8 @@ ;; name in dgo: ambient-h ;; dgos: ENGINE, GAME +(define-extern kill-current-talker (function symbol pair symbol none)) ;; see (exit play-anim scene-player) + ;; DECOMP BEGINS (deftype talker-speech-class (structure) diff --git a/goal_src/jak2/engine/entity/entity-h.gc b/goal_src/jak2/engine/entity/entity-h.gc index 9ceec646c..4e3db8369 100644 --- a/goal_src/jak2/engine/entity/entity-h.gc +++ b/goal_src/jak2/engine/entity/entity-h.gc @@ -34,8 +34,8 @@ (declare-type nav-poly structure) -;; NOTE - for default-menu (define-extern *compact-actors* symbol) +(define-extern *spawn-actors* symbol) (define-extern debug-actor (function string none)) (define-extern reset-actors (function symbol none)) diff --git a/goal_src/jak2/engine/game/game-info-h.gc b/goal_src/jak2/engine/game/game-info-h.gc index 66d2e932b..956175575 100644 --- a/goal_src/jak2/engine/game/game-info-h.gc +++ b/goal_src/jak2/engine/game/game-info-h.gc @@ -354,7 +354,7 @@ (game-info-method-23 (_type_ game-save string) int 23) (game-info-method-24 (_type_ game-save) none 24) (you-suck-stage (_type_ symbol) int 25) - (you-suck-scale (_type_) float 26) + (you-suck-scale (_type_ object) float 26) (get-next-attack-id (_type_) uint 27) (game-info-method-28 (_type_ game-score float) int 28) (get-game-score-ref (_type_ int) (pointer float) 29) diff --git a/goal_src/jak2/engine/game/game-info.gc b/goal_src/jak2/engine/game/game-info.gc index 8c0a91f36..57bc2e45c 100644 --- a/goal_src/jak2/engine/game/game-info.gc +++ b/goal_src/jak2/engine/game/game-info.gc @@ -5,6 +5,8 @@ ;; name in dgo: game-info ;; dgos: ENGINE, GAME +;; initialize was manually fixed. + (define-extern demo? (function symbol)) (define-extern task-resolution-close! (function game-task symbol)) (define-extern *lightning-darkjak-pill* lightning-spec) @@ -292,159 +294,281 @@ ) ) -;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 512] -;; ERROR: Expression building failed: In (method 9 game-info): Expression pass could not find the set-to-run function. Found t9-31 instead. Make sure there are no casts on this function. (defmethod initialize! game-info ((obj game-info) (arg0 symbol) (arg1 game-save) (arg2 string)) + (local-vars (v0-3 int) (sv-96 game-task-node-info) (sv-112 symbol)) + (case arg0 + (('dead 'life) + (+! (-> obj total-deaths) 1) + (+! (-> obj continue-deaths) 1) + (+! (-> obj task-deaths) 1) + (when *target* + (let ((s4-1 (-> *target* current-level info))) + (set! (-> obj deaths-per-level (-> s4-1 task-level)) + (the-as uint (seekl (the-as int (-> obj deaths-per-level (-> s4-1 task-level))) 255 1)) + ) + ) + ) + (case (-> obj mode) + (('play) + (set! arg0 'life) + ) + (else + (set! obj obj) + (goto cfg-131) + ) + ) + ) + (('try) + (+! (-> obj total-trys) 1) + ) + ) + (case arg0 + (('dead 'life 'try) + (let ((s2-0 (level-get-target-inside *level*))) + (when s2-0 + (let ((s1-0 (-> *game-info* sub-task-list))) + (dotimes (s0-0 (-> s1-0 length)) + (when (nonzero? s0-0) + (set! sv-96 (-> s1-0 s0-0)) + (if (open? sv-96) + (set! v0-3 (when (and (= (-> s2-0 info taskname) (-> sv-96 level)) + (and (or (not (-> sv-96 info)) (handle->process (-> sv-96 info manager))) + (>= (- (-> *display* game-clock frame-counter) (-> obj death-time)) (seconds 2)) + ) + ) + (format #t "death count inc for ~S~%" (-> sv-96 name)) + (set! v0-3 (seekl (the-as int (-> sv-96 death-count)) #xffff 1)) + (set! (-> sv-96 death-count) (the-as uint v0-3)) + v0-3 + ) + ) + ) + ) + ) + ) + ) + ) + (set! (-> obj death-time) (-> *display* game-clock frame-counter)) + ) + ) + (kill-current-talker (the-as symbol '()) '() 'die) + (case arg0 + (('game) + (+! (-> obj task-counter) 1) + (reset! (-> *display* total-game-clock)) + (set! (-> obj features) (game-feature sidekick)) + (set! (-> obj debug-features) (game-feature)) + (set! (-> obj secrets) (game-secrets)) + (set! (-> obj purchase-secrets) (game-secrets)) + (set-continue! + obj + (cond + (arg2 + (empty) + arg2 + ) + ((demo?) + "demo-start" + ) + (*debug-segment* + "game-start" + ) + (else + "title-start" + ) + ) + #f + ) + (set! (-> obj auto-save-count) 0) + (set! (-> *setting-control* user-default auto-save) #f) + (set! (-> obj money) 0.0) + (set! (-> obj money-total) 0.0) + (set! (-> obj fuel) 0.0) + (set! (-> obj buzzer-total) 0.0) + (set! (-> obj eco-pill-dark) 0.0) + (set! (-> obj eco-pill-dark-total) 0.0) + (set! (-> obj gem) 0.0) + (set! (-> obj gem-total) 0.0) + (set! (-> obj skill) 0.0) + (set! (-> obj skill-total) 0.0) + (set! (-> obj karma) 0.0) + (set! (-> obj perm-list length) 0) + (dotimes (v1-69 (-> obj unknown-pad6 allocated-length)) + (set! (-> obj unknown-pad6 v1-69) (the-as uint 0)) + ) + (set! (-> obj death-movie-tick) (rand-vu-int-count 10)) + (set! (-> obj gun-type) 2) + (set! (-> obj gun-ammo 0) (-> *FACT-bank* ammo-yellow-start)) + (set! (-> obj gun-ammo 1) (-> *FACT-bank* ammo-red-start)) + (set! (-> obj gun-ammo 2) (-> *FACT-bank* ammo-blue-start)) + (set! (-> obj gun-ammo 3) (-> *FACT-bank* ammo-dark-start)) + (set! (-> obj shield) 100.0) + (set! (-> obj score) 0.0) + (set! (-> obj score-owner) (the-as handle #f)) + (set! (-> obj goal) 0.0) + (set! (-> obj miss) 0.0) + (set! (-> obj miss-max) 0.0) + (set! (-> obj timer) 0) + (set! (-> obj timer-flash) #f) + (set! (-> obj timer-owner) (the-as handle #f)) + (set! (-> obj counter) 0.0) + (set! (-> obj counter-flash) #f) + (set! (-> obj wanted-flash) #f) + (set! (-> obj distance) 0.0) + (set! (-> obj attack-id) (the-as uint 2)) + (set! (-> obj total-trys) 0) + (set! (-> obj total-deaths) 0) + (set! (-> obj continue-deaths) 0) + (set! (-> obj task-deaths) 0) + (set! (-> obj death-pos length) 0) + (set! (-> obj game-start-time) (-> *display* game-clock frame-counter)) + (set! (-> obj task-pickup-time) (-> *display* game-clock frame-counter)) + (set! (-> obj continue-time) (-> *display* game-clock frame-counter)) + (set! (-> obj death-time) (-> *display* game-clock frame-counter)) + (set! (-> obj hit-time) (-> *display* game-clock frame-counter)) + (dotimes (v1-95 110) + (set! (-> obj unknown-array1 0) 0) + (set! (-> obj task-close-times 0) 0) + (nop!) + ) + (dotimes (v1-98 32) + (set! (-> obj money-per-level v1-98) (the-as uint 0)) + (set! (-> obj deaths-per-level v1-98) (the-as uint 0)) + (set! (-> obj task-enter-times v1-98) 0) + (set! (-> obj task-in-times v1-98) 0) + (set! (-> obj level-opened v1-98) (the-as uint 0)) + (nop!) + ) + (let ((v1-102 (-> *game-info* sub-task-list))) + (dotimes (a0-41 (-> v1-102 length)) + (when (nonzero? a0-41) + (let ((a1-16 (-> v1-102 a0-41))) + (set! (-> a1-16 death-count) (the-as uint 0)) + (set! (-> a1-16 gem-count) (the-as uint 0)) + (set! (-> a1-16 skill-count) (the-as uint 0)) + (set! (-> a1-16 close-time) 0) + ) + 0 + ) + ) + ) + (dotimes (v1-105 (-> obj game-score length)) + (set! (-> obj game-score v1-105) 0.0) + ) + (dotimes (s3-1 19) + (case s3-1 + ((4 5 6 7 10 11 12 13 15 14 16 17 18) + (let ((v1-112 (get-game-score-ref obj s3-1)) + (a0-62 (-> *highscore-info-array* s3-1)) + ) + (set! (-> v1-112 0) (-> a0-62 gold-score)) + (set! (-> v1-112 1) (-> a0-62 silver-score)) + (set! (-> v1-112 2) (-> a0-62 bronze-score)) + ) + ) + ) + ) + (initialize *bigmap*) + ) + ) + (case arg0 + (('game 'try 'life) + (case (-> obj mode) + (('play) + (set! *display-profile* #f) + (set! *display-entity-errors* #f) + ) + ) + (set! (-> obj life-max) (-> *GAME-bank* life-max-default)) + (set! (-> obj life) (-> *GAME-bank* life-start-default)) + (set! (-> obj gun-ammo 0) + (fmax (-> obj gun-ammo 0) (* (you-suck-scale *game-info* #f) (-> *FACT-bank* ammo-yellow-start))) + ) + (set! (-> obj gun-ammo 1) + (fmax (-> obj gun-ammo 1) (* (you-suck-scale *game-info* #f) (-> *FACT-bank* ammo-red-start))) + ) + (set! (-> obj gun-ammo 2) + (fmax (-> obj gun-ammo 2) (* (you-suck-scale *game-info* #f) (-> *FACT-bank* ammo-blue-start))) + ) + (set! (-> obj gun-ammo 3) + (fmax (-> obj gun-ammo 3) (* (you-suck-scale *game-info* #f) (-> *FACT-bank* ammo-dark-start))) + ) + ) + ) + (let ((v1-135 (-> obj mode))) + (cond + ((= v1-135 'movie) + (task-node-reset arg0) + (update-task-masks arg0) + ) + ((= v1-135 'debug) + (reset-actors arg0) + (if arg1 + (game-info-method-24 obj arg1) + ) + ) + ((= v1-135 'play) + (when *target* + (set-setting *setting-control* *target* 'allow-pause #f 0 0) + (set-setting *setting-control* *target* 'allow-progress #f 0 0) + (set-setting *setting-control* *target* 'allow-continue #f 0 0) + (apply-settings *setting-control*) + ) + (send-event (handle->process (-> *game-info* auto-save-proc)) 'die) + (set! (-> *setting-control* user-default border-mode) #f) + (set! (-> *setting-control* user-default region-mode) #f) + (apply-settings *setting-control*) + (set! *spawn-actors* #f) + (set-blackout-frames (seconds 0.1)) + (send-event *target* 'reset) + (let* ((s3-2 (get-process *4k-dead-pool* process #x4000)) + (v1-157 (when s3-2 + (let ((t9-29 (method-of-type process activate))) + (t9-29 s3-2 *default-pool* (symbol->string (-> process symbol)) (the-as pointer #x70004000)) + ) + set-to-run + (let ((s1-2 (-> s3-2 main-thread)) + (s0-1 (lambda :behavior process + ((arg0 symbol) (arg1 symbol) (arg2 continue-point) (arg3 game-save)) + (set! (-> self mask) (process-mask)) + (stop arg0) + (reset-actors arg1) + (close! (-> *game-info* sub-task-list 1) 'event) + (set-continue! *game-info* arg2 #f) + (when arg3 + (game-info-method-24 *game-info* arg3) + (set! arg2 (get-current-continue-forced *game-info*)) + (reset-actors 'life) + (send-event (handle->process (-> *game-info* auto-save-proc)) 'done) + ) + (suspend) + (start arg0 arg2) + (none) + ) + ) + ) + (set! sv-112 (-> obj mode)) + (let ((t0-3 (get-current-continue-forced obj)) + (t1-3 arg1) + ) + (run-next-time-in-process s3-2 s0-1 sv-112 arg0 t0-3 t1-3) + ) + ) + (-> s3-2 ppointer) + ) + ) + ) + (when v1-157 + (set! (-> v1-157 0 mask) (process-mask)) + 0 + ) + ) + (set-master-mode 'game) + ) + ) + ) + (label cfg-131) obj - ;; (local-vars - ;; (v0-17 none) - ;; (v0-29 process-tree) - ;; (v0-30 continue-point) - ;; (v0-31 none) - ;; (v0-32 game-info) - ;; (v1-0 symbol) - ;; (v1-16 symbol) - ;; (v1-135 symbol) - ;; (v1-154 process) - ;; (v1-157 (pointer process)) - ;; (v1-158 type) - ;; (v1-159 int) - ;; (v1-160 (pointer string)) - ;; (v1-161 symbol) - ;; (v1-162 type) - ;; (v1-163 process) - ;; (a0-95 process) - ;; (a0-96 game-info) - ;; (a0-97 cpu-thread) - ;; (a0-99 int) - ;; (a0-100 symbol) - ;; (a1-47 process-tree) - ;; (a1-48 (function symbol symbol continue-point game-save none :behavior process)) - ;; (a2-11 type) - ;; (a2-12 symbol) - ;; (a2-13 string) - ;; (a2-14 symbol) - ;; (a3-4 int) - ;; (a3-5 symbol) - ;; (t0-3 continue-point) - ;; (t1-3 game-save) - ;; (s0-1 (function symbol symbol continue-point game-save none :behavior process)) - ;; (s1-2 cpu-thread) - ;; (s2-2 function) - ;; (s3-2 process) - ;; (s4-1 level-load-info) - ;; (t9-29 (function process process-tree basic pointer process-tree)) - ;; (t9-30 (function game-info continue-point)) - ;; (t9-31 function) - ;; (t9-32 (function symbol none)) - ;; (sv-96 game-task-node-info) - ;; (sv-112 symbol) - ;; ) - ;; (cond - ;; ((or (= v1-0 'dead) (= v1-0 'life)) - ;; (+! (-> obj total-deaths) 1) - ;; (+! (-> obj continue-deaths) 1) - ;; (+! (-> obj task-deaths) 1) - ;; (when *target* - ;; (set! s4-1 (-> *target* current-level info)) - ;; (set! (-> obj deaths-per-level (-> s4-1 task-level)) - ;; (the-as uint (seekl (the-as int (-> obj deaths-per-level (-> s4-1 task-level))) 255 1)) - ;; ) - ;; ) - ;; (set! v1-16 (-> obj mode)) - ;; (cond - ;; ((= v1-16 'play) - ;; (set! arg0 'life) - ;; ) - ;; (else - ;; (set! obj obj) - ;; (goto cfg-131) - ;; ) - ;; ) - ;; ) - ;; ((= v1-0 'try) - ;; (+! (-> obj total-trys) 1) - ;; ) - ;; ) - ;; (cond - ;; ((= v1-135 'movie) - ;; (task-node-reset arg0) - ;; (update-task-masks arg0) - ;; ) - ;; ((= v1-135 'debug) - ;; (reset-actors arg0) - ;; (if arg1 - ;; (game-info-method-24 obj arg1) - ;; ) - ;; ) - ;; ((= v1-135 'play) - ;; (when (begin - ;; (if v1-154 - ;; (-> v1-154 ppointer) - ;; ) - ;; (when s3-2 - ;; (set! v1-158 process) - ;; (set! t9-29 (method-of-type process activate)) - ;; (set! a0-95 s3-2) - ;; (set! a1-47 *default-pool*) - ;; (set! v1-159 #xff37) - ;; (set! a2-11 process) - ;; (set! a2-12 (-> process symbol)) - ;; (set! v1-160 (sym->str-ptr (-> process symbol))) - ;; (set! a2-13 (symbol->string (-> process symbol))) - ;; (set! a3-4 #x70004000) - ;; (call! a0-95 a1-47 a2-13 a3-4) - ;; (set! s2-2 set-to-run) - ;; (set! s1-2 (-> s3-2 main-thread)) - ;; (set! s0-1 (lambda :behavior process - ;; ((arg0 symbol) (arg1 symbol) (arg2 continue-point) (arg3 game-save)) - ;; (set! (-> self mask) (process-mask)) - ;; (stop arg0) - ;; (reset-actors arg1) - ;; (close! (-> *game-info* sub-task-list 1) 'event) - ;; (set-continue! *game-info* arg2 #f) - ;; (when arg3 - ;; (game-info-method-24 *game-info* arg3) - ;; (set! arg2 (get-current-continue-forced *game-info*)) - ;; (reset-actors 'life) - ;; (send-event (handle->process (-> *game-info* auto-save-proc)) 'done) - ;; ) - ;; (suspend) - ;; (start arg0 arg2) - ;; (none) - ;; ) - ;; ) - ;; (set! v1-161 (-> obj mode)) - ;; (set! sv-112 v1-161) - ;; (set! a0-96 obj) - ;; (set! v1-162 (-> a0-96 type)) - ;; (set! t9-30 (method-of-object a0-96 get-current-continue-forced)) - ;; (set! v0-30 (get-current-continue-forced obj)) - ;; (set! t0-3 v0-30) - ;; (set! t1-3 arg1) - ;; (set! t9-31 s2-2) - ;; (set! a0-97 s1-2) - ;; (set! a1-48 s0-1) - ;; (set! a2-14 sv-112) - ;; (set! a3-5 arg0) - ;; (call! a0-97 a1-48 a2-14 a3-5 t0-3 t1-3) - ;; (set! v1-157 (-> s3-2 ppointer)) - ;; ) - ;; v1-157 - ;; ) - ;; (set! v1-163 (-> v1-157 0)) - ;; (set! (-> v1-163 mask) (the-as process-mask 0)) - ;; (set! a0-99 0) - ;; ) - ;; (set! t9-32 set-master-mode) - ;; (set! a0-100 'game) - ;; (set! v0-17 (call! a0-100)) - ;; ) - ;; ) - ;; (set! v1-164 v0-17) - ;; (label cfg-131) - ;; (set! v0-32 obj) - ;; (ret-value v0-32) ) (defmethod give game-info ((obj game-info) (arg0 symbol) (arg1 float) (arg2 handle)) @@ -1517,7 +1641,7 @@ ) ) -(defmethod you-suck-scale game-info ((obj game-info)) +(defmethod you-suck-scale game-info ((obj game-info) (arg0 object)) (* 0.25 (the float (you-suck-stage obj #f))) ) diff --git a/goal_src/jak2/engine/game/settings.gc b/goal_src/jak2/engine/game/settings.gc index 7f3c7bffa..8a03c4457 100644 --- a/goal_src/jak2/engine/game/settings.gc +++ b/goal_src/jak2/engine/game/settings.gc @@ -899,6 +899,7 @@ (defmethod apply-settings setting-control ((obj setting-control)) ;; (speech-control-method-11 *speech-control*) + (format #t "skip *speech-control* method 11 in apply-settings~%") (let ((s5-0 (-> obj user-current))) (let ((s4-0 (-> obj user-target))) (mem-copy! (the-as pointer s4-0) (the-as pointer (-> obj user-default)) 528) diff --git a/goal_src/jak2/engine/load/loader.gc b/goal_src/jak2/engine/load/loader.gc index 619f2a171..c4f1c343b 100644 --- a/goal_src/jak2/engine/load/loader.gc +++ b/goal_src/jak2/engine/load/loader.gc @@ -95,13 +95,13 @@ ) (defun drawable-load ((arg0 drawable) (arg1 kheap)) - (local-vars (sp-0 pointer)) + ;; (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)) - ) + ; (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 (loado (the-as string arg0) arg1))) (if (and s5-1 (type? s5-1 drawable)) (login (the-as drawable s5-1)) @@ -115,11 +115,11 @@ ) (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)) - ) + ; (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 (loado arg0 arg1))) (if (type? s5-0 art) (login (the-as art s5-0)) @@ -129,12 +129,12 @@ ) (defun art-group-load-check ((arg0 string) (arg1 kheap) (arg2 int)) - (local-vars (sp-0 pointer)) + ; (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)) - ) + ; (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 (loado (make-file-name (file-kind art-group) arg0 arg2 #f) arg1))) (cond ((not s3-1) @@ -2086,7 +2086,222 @@ 0 ) -;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod gui-control-method-22 gui-control ((obj gui-control) (arg0 gui-connection) (arg1 process) (arg2 symbol)) + (local-vars (v1-66 symbol) (v1-143 symbol)) + (with-pp + (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) 1) (= (gui-control-method-17 obj (-> arg0 id)) (gui-action playing))) + (set! (-> arg0 action) (gui-action playing)) + ) + ) + ) + ) + (let ((v1-16 (-> arg0 action))) + (b! (!= v1-16 (gui-action play)) cfg-39 :delay (empty-form)) + (if (gui-control-method-19 obj (-> arg0 channel) arg0) + (channel-id-set! obj arg0 (-> arg0 id)) + ) + (b! + (not (or (not (gui-control-method-18 obj (-> arg0 channel))) + (= (gui-control-method-17 obj (-> arg0 id)) (gui-action stopping)) + ) + ) + cfg-27 + :delay (empty-form) + ) + (if (= (-> obj ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! obj arg0 (new 'static 'sound-id)) + ) + (if (and arg2 (or (< (shr (the-as int (-> arg0 channel)) 4) (the-as uint 4)) + (= (gui-control-method-17 obj (-> arg0 id)) (gui-action stopping)) + ) + ) + (move-to-dead arg0) + ) + (b! #t cfg-38 :delay (nop!)) + (label cfg-27) + (let ((v1-40 (-> arg0 id))) + (b! (!= (-> obj ids (-> arg0 channel)) v1-40) cfg-38 :delay (empty-form)) + ) + (let ((v1-43 (gui-control-method-17 obj (-> arg0 id)))) + (b! (!= v1-43 (gui-action play)) cfg-36 :delay (empty-form)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (if (not (paused?)) + (str-play-async (-> arg0 name) (-> arg0 id)) + ) + ) + ) + (b! #t cfg-38 :delay (nop!)) + (label cfg-36) + (b! (!= v1-43 (gui-action playing)) cfg-38 :delay (empty-form)) + ) + (set! (-> arg0 action) (gui-action playing)) + (label cfg-38) + (b! #t cfg-139 :delay (nop!)) + (label cfg-39) + (b! (not (or (= v1-16 (gui-action playing)) (= v1-16 (gui-action fade)))) cfg-117 :delay (empty-form)) + (b! + (not (and (= (gui-control-method-17 obj (-> arg0 id)) (gui-action playing)) + (gui-control-method-18 obj (-> arg0 channel)) + (or (= (-> arg0 action) (gui-action playing)) (< (-> arg0 fade) (the-as uint 30))) + ) + ) + cfg-106 + :delay (nop!) + ) + (channel-id-set! obj arg0 (-> arg0 id)) + (set! (-> obj times 0) 0) + (let ((v1-64 (shr (the-as int (-> arg0 channel)) 4))) + (set! v1-66 + (and (or (= v1-64 1) (= v1-64 2)) + (not (and (>= (the-as uint (-> arg0 channel)) (the-as uint 16)) + (>= (the-as uint 17) (the-as uint (-> arg0 channel))) + ) + ) + (begin + (dotimes (s3-0 4) + (when (and (string-charp= (-> arg0 name) (the-as (pointer uint8) (-> *sound-iop-info* stream-name s3-0))) + (= (-> arg0 id) (-> *sound-iop-info* stream-id s3-0)) + (logtest? (-> *sound-iop-info* stream-status s3-0) (stream-status ststatus-six)) + ) + (set! v1-66 #t) + (goto cfg-73) + ) + ) + #f + ) + ) + ) + ) + (label cfg-73) + (cond + ((not v1-66) + (when (and (logtest? (-> arg0 flags) 30) (logtest? (-> arg0 flags) 1)) + (let* ((s5-1 (get-process arg0)) + (s4-1 (if (type? s5-1 process-drawable) + s5-1 + ) + ) + ) + (when (and s4-1 (nonzero? (-> (the-as process-drawable s4-1) root))) + (when *sound-player-enable* + (let ((s5-2 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> s5-2 command) (sound-command set-param)) + (set! (-> s5-2 id) (-> arg0 id)) + (let ((a1-24 (-> (the-as process-drawable s4-1) root trans))) + (let ((s4-2 (the-as process-drawable pp))) + (when (= a1-24 #t) + (if (and s4-2 (type? s4-2 process-drawable) (nonzero? (-> s4-2 root))) + (set! a1-24 (-> s4-2 root trans)) + (set! a1-24 (the-as vector #f)) + ) + ) + ) + (sound-trans-convert (the-as vector3w (-> s5-2 params trans)) a1-24) + ) + (set! (-> s5-2 params fo-curve) (-> arg0 fo-curve)) + (set! (-> s5-2 params fo-min) (-> arg0 fo-min)) + (set! (-> s5-2 params fo-max) (-> arg0 fo-max)) + (set! (-> s5-2 params mask) (the-as uint 0)) + (if (logtest? (-> arg0 flags) 2) + (logior! (-> s5-2 params mask) 32) + ) + (if (logtest? (-> arg0 flags) 4) + (logior! (-> s5-2 params mask) 256) + ) + (if (logtest? (-> arg0 flags) 8) + (logior! (-> s5-2 params mask) 64) + ) + (if (logtest? (-> arg0 flags) 16) + (logior! (-> s5-2 params mask) 128) + ) + ) + ) + ) + ) + ) + (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-3 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> s5-3 command) (sound-command set-param)) + (set! (-> s5-3 id) (-> arg0 id)) + (set! (-> s5-3 params volume) (the int (* 1024.0 (lerp-scale 1.0 0.0 (the float (-> arg0 fade)) 0.0 30.0)))) + (set! (-> s5-3 params mask) (the-as uint 1)) + (-> s5-3 id) + ) + ) + ) + ) + (else + (label cfg-106) + (when (= (-> obj ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! obj arg0 (new 'static 'sound-id)) + (set! (-> obj times (-> arg0 channel)) (+ (-> *display* base-clock frame-counter) (-> arg0 hold-time))) + ) + (b! (not arg2) cfg-113 :likely-delay (set! v1-143 arg2)) + (let ((a0-75 (< (shr (the-as int (-> arg0 channel)) 4) (the-as uint 4)))) + (b! a0-75 cfg-113 :likely-delay (set! v1-143 a0-75)) + ) + (set! v1-143 (= (gui-control-method-17 obj (-> arg0 id)) (gui-action stopping))) + (label cfg-113) + (if v1-143 + (move-to-dead arg0) + (set! (-> arg0 action) (gui-action play)) + ) + ) + ) + (b! #t cfg-139 :delay (nop!)) + (label cfg-117) + (b! (!= v1-16 (gui-action stop)) cfg-121 :delay (empty-form)) + (gui-control-method-11 obj arg0) + (if arg2 + (move-to-dead arg0) + ) + (b! #t cfg-139 :delay (nop!)) + (label cfg-121) + (cond + ((= v1-16 (gui-action abort)) + (if (= (-> obj ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! obj 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)) + (= (gui-control-method-17 obj (-> arg0 id)) (gui-action stopping)) + ) + (gui-control-method-11 obj arg0) + (if arg2 + (move-to-dead arg0) + ) + ) + (else + (if (= (-> obj ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! obj arg0 (new 'static 'sound-id)) + ) + ) + ) + ) + ) + ) + (label cfg-139) + 0 + (none) + ) + ) + (defmethod update gui-control ((obj gui-control) (arg0 symbol)) (set! (-> obj ids 65) diff --git a/goalc/compiler/compilation/Function.cpp b/goalc/compiler/compilation/Function.cpp index dd26bb387..1c3f3e1db 100644 --- a/goalc/compiler/compilation/Function.cpp +++ b/goalc/compiler/compilation/Function.cpp @@ -454,7 +454,8 @@ Val* Compiler::compile_function_or_method_call(const goos::Object& form, Env* en // note, inlined functions will get a more specific type if possible // todo, is this right? auto type = eval_args.at(i)->type(); - auto copy = env->make_ireg(type, m_ts.lookup_type(type)->get_preferred_reg_class()); + auto copy = + env->make_ireg(type, m_ts.lookup_type_allow_partial_def(type)->get_preferred_reg_class()); env->emit_ir(form, copy, eval_args.at(i)); copy->mark_as_settable(); lexical_env->vars[head_as_lambda->lambda.params.at(i).name] = copy; diff --git a/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc b/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc index a6f458cad..c86525e92 100644 --- a/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc @@ -340,7 +340,7 @@ (game-info-method-23 (_type_ game-save string) int 23) (game-info-method-24 (_type_ game-save) none 24) (you-suck-stage (_type_ symbol) int 25) - (you-suck-scale (_type_) float 26) + (you-suck-scale (_type_ object) float 26) (get-next-attack-id (_type_) uint 27) (game-info-method-28 (_type_ game-score float) int 28) (get-game-score-ref (_type_ int) (pointer float) 29) diff --git a/test/decompiler/reference/jak2/engine/game/game-info_REF.gc b/test/decompiler/reference/jak2/engine/game/game-info_REF.gc index 2f8f3f639..bf6f5c026 100644 --- a/test/decompiler/reference/jak2/engine/game/game-info_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/game-info_REF.gc @@ -1545,7 +1545,7 @@ ) ;; definition for method 26 of type game-info -(defmethod you-suck-scale game-info ((obj game-info)) +(defmethod you-suck-scale game-info ((obj game-info) (arg0 object)) (* 0.25 (the float (you-suck-stage obj #f))) ) diff --git a/test/decompiler/reference/jak2/engine/load/loader_REF.gc b/test/decompiler/reference/jak2/engine/load/loader_REF.gc index e0f0d7b31..d118248c6 100644 --- a/test/decompiler/reference/jak2/engine/load/loader_REF.gc +++ b/test/decompiler/reference/jak2/engine/load/loader_REF.gc @@ -2191,7 +2191,222 @@ ) ;; definition for method 22 of type gui-control -;; ERROR: function was not converted to expressions. Cannot decompile. +;; WARN: Return type mismatch int vs none. +(defmethod gui-control-method-22 gui-control ((obj gui-control) (arg0 gui-connection) (arg1 process) (arg2 symbol)) + (local-vars (v1-66 symbol) (v1-143 symbol)) + (with-pp + (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) 1) (= (gui-control-method-17 obj (-> arg0 id)) (gui-action playing))) + (set! (-> arg0 action) (gui-action playing)) + ) + ) + ) + ) + (let ((v1-16 (-> arg0 action))) + (b! (!= v1-16 (gui-action play)) cfg-39 :delay (empty-form)) + (if (gui-control-method-19 obj (-> arg0 channel) arg0) + (channel-id-set! obj arg0 (-> arg0 id)) + ) + (b! + (not (or (not (gui-control-method-18 obj (-> arg0 channel))) + (= (gui-control-method-17 obj (-> arg0 id)) (gui-action stopping)) + ) + ) + cfg-27 + :delay (empty-form) + ) + (if (= (-> obj ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! obj arg0 (new 'static 'sound-id)) + ) + (if (and arg2 (or (< (shr (the-as int (-> arg0 channel)) 4) (the-as uint 4)) + (= (gui-control-method-17 obj (-> arg0 id)) (gui-action stopping)) + ) + ) + (move-to-dead arg0) + ) + (b! #t cfg-38 :delay (nop!)) + (label cfg-27) + (let ((v1-40 (-> arg0 id))) + (b! (!= (-> obj ids (-> arg0 channel)) v1-40) cfg-38 :delay (empty-form)) + ) + (let ((v1-43 (gui-control-method-17 obj (-> arg0 id)))) + (b! (!= v1-43 (gui-action play)) cfg-36 :delay (empty-form)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (if (not (paused?)) + (str-play-async (-> arg0 name) (-> arg0 id)) + ) + ) + ) + (b! #t cfg-38 :delay (nop!)) + (label cfg-36) + (b! (!= v1-43 (gui-action playing)) cfg-38 :delay (empty-form)) + ) + (set! (-> arg0 action) (gui-action playing)) + (label cfg-38) + (b! #t cfg-139 :delay (nop!)) + (label cfg-39) + (b! (not (or (= v1-16 (gui-action playing)) (= v1-16 (gui-action fade)))) cfg-117 :delay (empty-form)) + (b! + (not (and (= (gui-control-method-17 obj (-> arg0 id)) (gui-action playing)) + (gui-control-method-18 obj (-> arg0 channel)) + (or (= (-> arg0 action) (gui-action playing)) (< (-> arg0 fade) (the-as uint 30))) + ) + ) + cfg-106 + :delay (nop!) + ) + (channel-id-set! obj arg0 (-> arg0 id)) + (set! (-> obj times 0) 0) + (let ((v1-64 (shr (the-as int (-> arg0 channel)) 4))) + (set! v1-66 + (and (or (= v1-64 1) (= v1-64 2)) + (not (and (>= (the-as uint (-> arg0 channel)) (the-as uint 16)) + (>= (the-as uint 17) (the-as uint (-> arg0 channel))) + ) + ) + (begin + (dotimes (s3-0 4) + (when (and (string-charp= (-> arg0 name) (the-as (pointer uint8) (-> *sound-iop-info* stream-name s3-0))) + (= (-> arg0 id) (-> *sound-iop-info* stream-id s3-0)) + (logtest? (-> *sound-iop-info* stream-status s3-0) (stream-status ststatus-six)) + ) + (set! v1-66 #t) + (goto cfg-73) + ) + ) + #f + ) + ) + ) + ) + (label cfg-73) + (cond + ((not v1-66) + (when (and (logtest? (-> arg0 flags) 30) (logtest? (-> arg0 flags) 1)) + (let* ((s5-1 (get-process arg0)) + (s4-1 (if (type? s5-1 process-drawable) + s5-1 + ) + ) + ) + (when (and s4-1 (nonzero? (-> (the-as process-drawable s4-1) root))) + (when *sound-player-enable* + (let ((s5-2 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> s5-2 command) (sound-command set-param)) + (set! (-> s5-2 id) (-> arg0 id)) + (let ((a1-24 (-> (the-as process-drawable s4-1) root trans))) + (let ((s4-2 (the-as process-drawable pp))) + (when (= a1-24 #t) + (if (and s4-2 (type? s4-2 process-drawable) (nonzero? (-> s4-2 root))) + (set! a1-24 (-> s4-2 root trans)) + (set! a1-24 (the-as vector #f)) + ) + ) + ) + (sound-trans-convert (the-as vector3w (-> s5-2 params trans)) a1-24) + ) + (set! (-> s5-2 params fo-curve) (-> arg0 fo-curve)) + (set! (-> s5-2 params fo-min) (-> arg0 fo-min)) + (set! (-> s5-2 params fo-max) (-> arg0 fo-max)) + (set! (-> s5-2 params mask) (the-as uint 0)) + (if (logtest? (-> arg0 flags) 2) + (logior! (-> s5-2 params mask) 32) + ) + (if (logtest? (-> arg0 flags) 4) + (logior! (-> s5-2 params mask) 256) + ) + (if (logtest? (-> arg0 flags) 8) + (logior! (-> s5-2 params mask) 64) + ) + (if (logtest? (-> arg0 flags) 16) + (logior! (-> s5-2 params mask) 128) + ) + ) + ) + ) + ) + ) + (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-3 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> s5-3 command) (sound-command set-param)) + (set! (-> s5-3 id) (-> arg0 id)) + (set! (-> s5-3 params volume) (the int (* 1024.0 (lerp-scale 1.0 0.0 (the float (-> arg0 fade)) 0.0 30.0)))) + (set! (-> s5-3 params mask) (the-as uint 1)) + (-> s5-3 id) + ) + ) + ) + ) + (else + (label cfg-106) + (when (= (-> obj ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! obj arg0 (new 'static 'sound-id)) + (set! (-> obj times (-> arg0 channel)) (+ (-> *display* base-clock frame-counter) (-> arg0 hold-time))) + ) + (b! (not arg2) cfg-113 :likely-delay (set! v1-143 arg2)) + (let ((a0-75 (< (shr (the-as int (-> arg0 channel)) 4) (the-as uint 4)))) + (b! a0-75 cfg-113 :likely-delay (set! v1-143 a0-75)) + ) + (set! v1-143 (= (gui-control-method-17 obj (-> arg0 id)) (gui-action stopping))) + (label cfg-113) + (if v1-143 + (move-to-dead arg0) + (set! (-> arg0 action) (gui-action play)) + ) + ) + ) + (b! #t cfg-139 :delay (nop!)) + (label cfg-117) + (b! (!= v1-16 (gui-action stop)) cfg-121 :delay (empty-form)) + (gui-control-method-11 obj arg0) + (if arg2 + (move-to-dead arg0) + ) + (b! #t cfg-139 :delay (nop!)) + (label cfg-121) + (cond + ((= v1-16 (gui-action abort)) + (if (= (-> obj ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! obj 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)) + (= (gui-control-method-17 obj (-> arg0 id)) (gui-action stopping)) + ) + (gui-control-method-11 obj arg0) + (if arg2 + (move-to-dead arg0) + ) + ) + (else + (if (= (-> obj ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! obj arg0 (new 'static 'sound-id)) + ) + ) + ) + ) + ) + ) + (label cfg-139) + 0 + (none) + ) + ) ;; definition for method 13 of type gui-control (defmethod update gui-control ((obj gui-control) (arg0 symbol))