Skip to content

Commit

Permalink
[decompiler] do not use time-elapsed? on unsigned comps (#3031)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManDude authored Sep 26, 2023
1 parent fc43870 commit a662150
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 539 deletions.
6 changes: 3 additions & 3 deletions decompiler/IR2/FormExpressionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5284,14 +5284,14 @@ FormElement* ConditionElement::make_time_elapsed(const Env& env,
std::vector<Form*> args;
args.push_back(time_elapsed);
args.push_back(time);
if (m_kind == IR2_Condition::Kind::LESS_THAN_SIGNED ||
m_kind == IR2_Condition::Kind::LESS_THAN_UNSIGNED) {
// TODO - how to handle unsigned case?
if (m_kind == IR2_Condition::Kind::LESS_THAN_SIGNED) {
return pool.alloc_element<GenericElement>(
GenericOperator::make_compare(IR2_Condition::Kind::FALSE),
pool.form<GenericElement>(
GenericOperator::make_function(pool.form<ConstantTokenElement>("time-elapsed?")),
make_casts_if_needed(args, types, TypeSpec("time-frame"), pool, env)));
} else {
} else if (m_kind == IR2_Condition::Kind::GEQ_SIGNED) {
return pool.alloc_element<GenericElement>(
GenericOperator::make_function(pool.form<ConstantTokenElement>("time-elapsed?")),
make_casts_if_needed(args, types, TypeSpec("time-frame"), pool, env));
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak1/engine/entity/ambient.gc
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@
)
)
)
(when (not (time-elapsed? (the-as int s4-0) (seconds 1)))
(when (< (the-as uint (- (current-time) (the-as int s4-0))) (the-as uint 300))
(let ((f30-0 (the float (rand-vu-int-count (the-as int (-> s5-0 ambient-data user-float 2))))))
(set! sv-16 (symbol->string (res-lump-struct s5-0 'effect-name symbol :time f30-0)))
(let ((s4-2 (new 'stack 'sound-spec)))
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak1/engine/target/logic-target.gc
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
(if (logtest? (-> self control unknown-surface01 flags) (surface-flags no-turn-around))
(set! (-> v1-6 0) (the-as uint (current-time)))
)
(and (time-elapsed? (the-as int (-> v1-6 0)) (seconds 1))
(and (>= (the-as uint (- (current-time) (the-as int (-> v1-6 0)))) (the-as uint 300))
(< f0-1 0.0)
(< 32768.0 f1-1)
(< 0.7 (-> self control unknown-float20))
Expand Down
8 changes: 4 additions & 4 deletions goal_src/jak1/engine/target/target.gc
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@
#t
)
(or (zero? (-> self control unknown-uint20))
(time-elapsed? (the-as int (-> self control unknown-uint20)) (seconds 0.04))
(>= (the-as uint (- (current-time) (the-as int (-> self control unknown-uint20)))) (the-as uint 12))
)
(!= (-> self control unknown-uint31) 1)
)
Expand Down Expand Up @@ -2189,13 +2189,13 @@
)
)
)
(time-elapsed? (the-as int (-> self control unknown-uint20)) (seconds 0.04))
(>= (the-as uint (- (current-time) (the-as int (-> self control unknown-uint20)))) (the-as uint 12))
)
)
(go target-falling #f)
)
((and (nonzero? (-> self control unknown-uint30))
(time-elapsed? (the-as int (-> self control unknown-uint30)) (seconds 0.04))
(>= (the-as uint (- (current-time) (the-as int (-> self control unknown-uint30)))) (the-as uint 12))
)
(set-forward-vel (the-as float 0.0))
)
Expand Down Expand Up @@ -2916,7 +2916,7 @@
(set! gp-0 (the-as int (current-time)))
)
(when (and (or (smack-surface? #f) (>= (-> self control unknown-float63) 0.7))
(time-elapsed? (the-as int (-> self control unknown-uint20)) (seconds 0.01))
(>= (the-as uint (- (current-time) (the-as int (-> self control unknown-uint20)))) (the-as uint 3))
(time-elapsed? (-> self state-time) 1)
)
(if (>= 6.0 (ja-aframe-num 0))
Expand Down
4 changes: 2 additions & 2 deletions goal_src/jak1/engine/target/target2.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@
)
(ja-no-eval :group! eichar-yellow-running-blast-ja :num! (seek!) :frame-num (ja-aframe (the-as float 9.0) 0))
(until (ja-done? 0)
(if (or (not (time-elapsed? (the-as int (-> self control unknown-uint30)) (seconds 0.1)))
(if (or (< (the-as uint (- (current-time) (the-as int (-> self control unknown-uint30)))) (the-as uint 30))
(= (-> self control unknown-uint31) 1)
)
(send-event (handle->process gp-0) 'die)
Expand Down Expand Up @@ -2072,7 +2072,7 @@
)
(cond
((= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0)
(if (time-elapsed? (the-as int (-> self control unknown-uint20)) (seconds 0.05))
(if (>= (the-as uint (- (current-time) (the-as int (-> self control unknown-uint20)))) (the-as uint 15))
(go target-swim-stance)
)
)
Expand Down
6 changes: 3 additions & 3 deletions goal_src/jak1/levels/flut_common/target-flut.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@
#t
)
(or (zero? (-> self control unknown-uint20))
(time-elapsed? (the-as int (-> self control unknown-uint20)) (seconds 0.04))
(>= (the-as uint (- (current-time) (the-as int (-> self control unknown-uint20)))) (the-as uint 12))
)
(!= (-> self control unknown-uint31) 1)
)
Expand Down Expand Up @@ -1306,13 +1306,13 @@
)
)
)
(time-elapsed? (the-as int (-> self control unknown-uint20)) (seconds 0.04))
(>= (the-as uint (- (current-time) (the-as int (-> self control unknown-uint20)))) (the-as uint 12))
)
)
(go target-flut-falling #f)
)
((and (nonzero? (-> self control unknown-uint30))
(time-elapsed? (the-as int (-> self control unknown-uint30)) (seconds 0.04))
(>= (the-as uint (- (current-time) (the-as int (-> self control unknown-uint30)))) (the-as uint 12))
)
(set-forward-vel (the-as float 0.0))
(set! f30-0 0.0)
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak2/engine/target/logic-target.gc
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@
(if (logtest? (-> self control current-surface flags) (surface-flag no-turn-around))
(set-time! (-> v1-7 0))
)
(and (time-elapsed? (-> v1-7 0) (seconds 1))
(and (>= (the-as uint (- (current-time) (-> v1-7 0))) (the-as uint 300))
(< f0-1 0.0)
(< 32768.0 f1-1)
(< 0.7 (-> self control pad-magnitude))
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak2/engine/target/target-swim.gc
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@
)
(cond
((= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0)
(if (time-elapsed? (the-as int (-> self control unknown-word04)) (seconds 0.05))
(if (>= (the-as uint (- (current-time) (the-as int (-> self control unknown-word04)))) (the-as uint 15))
(go target-swim-stance)
)
)
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak2/engine/target/target.gc
Original file line number Diff line number Diff line change
Expand Up @@ -3608,7 +3608,7 @@
(set! (-> self gun combo-window-state) (-> self state name))
)
(when (and (or (smack-surface? #f) (>= (-> self control surface-slope-z) 0.7))
(time-elapsed? (the-as int (-> self control unknown-word04)) (seconds 0.01))
(>= (the-as uint (- (current-time) (the-as int (-> self control unknown-word04)))) (the-as uint 3))
(time-elapsed? (-> self state-time) 1)
)
(when (>= 6.0 (ja-aframe-num 0))
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak2/levels/common/race/race-manager.gc
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@
)
)
(((race-state-enum countdown-scene-start))
(when (time-elapsed? (the-as int (-> this countdown-start-time)) (seconds 1))
(when (>= (the-as uint (- (current-time) (the-as int (-> this countdown-start-time)))) (the-as uint 300))
(set! (-> this state) (race-state-enum countdown-scene))
(set! (-> this scene-player)
(ppointer->handle (process-spawn scene-player :init scene-player-init (-> this info countdown-scene) #t #f))
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

169 changes: 0 additions & 169 deletions test/decompiler/reference/jak1/engine/nav/path-h_REF.gc

This file was deleted.

Loading

0 comments on commit a662150

Please sign in to comment.