Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

janim-status enum for joint-control #1190

Merged
merged 1 commit into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion decompiler/config/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -9637,10 +9637,24 @@
)
)

(defenum janim-status
:type uint16
:bitfield #t
(inited 0)
(drawn 1)
(done 2)
(blerc 3)
(skelf04 4)
(spool 5)
(blerc-done 6)
(eye-done 7)
(eye 8)
)

(declare-type process-drawable basic)
(declare-type effect-control basic)
(deftype joint-control (basic)
((status uint16 :offset-assert 4)
((status janim-status :offset-assert 4)
(allocated-length int16 :offset-assert 6)
(root-channel (inline-array joint-control-channel) :offset 16)
(blend-index int32 :offset-assert 20)
Expand Down
4 changes: 1 addition & 3 deletions decompiler/config/jak1_ntsc_black_label/type_casts.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4584,8 +4584,6 @@
[214, "s5", "handle"]
],

"(event idle logo-slave)": [[14, "v1", "uint"]],

"(method 11 training-cam)": [[21, "s5", "entity-actor"]],

"(method 23 tra-pontoon)": [
Expand Down Expand Up @@ -5678,7 +5676,7 @@
[10, "v1", "float"],
[297, "v1", "float"],
[308, "a0", "vector"],
[562, "v1", "(state target)"]
[562, "v1", "(state object object object object target)"]
],

"target-standard-event-handler": [
Expand Down
16 changes: 15 additions & 1 deletion goal_src/engine/anim/joint-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,23 @@
)
)

(defenum janim-status
:type uint16
:bitfield #t
(inited 0)
(drawn 1)
(done 2)
(blerc 3)
(skelf04 4)
(spool 5)
(blerc-done 6)
(eye-done 7)
(eye 8)
)

;; A collection of joint-control-channels.
(deftype joint-control (basic)
((status uint16 :offset-assert 4)
((status janim-status :offset-assert 4)
(allocated-length int16 :offset-assert 6)
(root-channel (inline-array joint-control-channel) :offset 16)
(blend-index int32 :offset-assert 20)
Expand Down
22 changes: 2 additions & 20 deletions goal_src/engine/camera/pov-camera.gc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

;; DECOMP BEGINS


;; definition for method 25 of type pov-camera
(defmethod check-for-abort pov-camera ((obj pov-camera))
(when (or (and (>= (- (-> *display* base-frame-counter) (-> obj debounce-start-time)) (seconds 0.2))
(cpad-pressed? 0 triangle)
Expand All @@ -24,17 +22,14 @@
)
)

;; definition for method 26 of type pov-camera
(defmethod target-grabbed? pov-camera ((obj pov-camera))
(or (not *target*) (process-grab? *target*))
)

;; definition for method 28 of type pov-camera
(defmethod target-released? pov-camera ()
(or (not *target*) (process-release? *target*))
)

;; failed to figure out what this is:
(defstate pov-camera-startup (pov-camera)
:virtual #t
:code
Expand All @@ -44,7 +39,6 @@
)
)

;; failed to figure out what this is:
(defstate pov-camera-start-playing (pov-camera)
:virtual #t
:code
Expand Down Expand Up @@ -77,8 +71,6 @@
)
)

;; definition for function pov-camera-play-and-reposition
;; INFO: Return type mismatch int vs none.
(defbehavior pov-camera-play-and-reposition pov-camera ((arg0 art-joint-anim) (arg1 vector) (arg2 float))
(let ((s4-0 #f))
(let ((v1-2 (-> self skel root-channel 0)))
Expand Down Expand Up @@ -121,7 +113,6 @@
(none)
)

;; failed to figure out what this is:
(defstate pov-camera-playing (pov-camera)
:virtual #t
:event
Expand Down Expand Up @@ -218,7 +209,6 @@
)
)

;; failed to figure out what this is:
(defstate pov-camera-abort (pov-camera)
:virtual #t
:enter
Expand All @@ -236,7 +226,6 @@
)
)

;; failed to figure out what this is:
(defstate pov-camera-done-playing (pov-camera)
:virtual #t
:code
Expand All @@ -253,22 +242,15 @@
)
)

;; definition for method 27 of type pov-camera
;; INFO: Return type mismatch int vs none.
(defmethod pre-startup-callback pov-camera ((obj pov-camera))
0
(none)
)

;; definition for method 29 of type pov-camera
;; INFO: Return type mismatch symbol vs none.
(defmethod set-stack-size! pov-camera ((obj pov-camera))
(none)
)

;; definition for function pov-camera-init-by-other
;; INFO: Return type mismatch object vs none.
;; Used lq/sq
(defbehavior pov-camera-init-by-other pov-camera ((arg0 vector) (arg1 skeleton-group) (arg2 string) (arg3 pov-camera-flag) (arg4 process-drawable) (arg5 pair))
(set-stack-size! self)
(set! (-> *game-info* pov-camera-handle) (process->handle self))
Expand All @@ -295,11 +277,11 @@
)
(initialize-skeleton self arg1 '())
(logior! (-> self draw status) (draw-status skip-bones))
(logior! (-> self skel status) 1)
(logior! (-> self skel status) (janim-status inited))
(set! (-> self anim-name) arg2)
(cond
((= (-> arg2 type) string)
(logior! (-> self skel status) 32)
(logior! (-> self skel status) (janim-status spool))
(let ((s5-1 (lookup-art (-> self draw art-group) arg2 art-joint-anim)))
(if (not s5-1)
(go process-drawable-art-error arg2)
Expand Down
101 changes: 48 additions & 53 deletions goal_src/engine/draw/process-drawable.gc
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@
)
0
(let ((v1-14 (dummy-9 (-> gp-0 data 1) #f)))
(set! (-> v1-14 joint) (the-as joint (-> arg0 data 0)))
(set! (-> v1-14 joint) (-> arg0 data 0))
(set! (-> v1-14 bone) (-> s4-1 bones 1))
(set! (-> v1-14 parent) (the-as cspace (-> gp-0 data)))
(set! (-> v1-14 bone cache bone-matrix) (the-as uint 128))
)
(let ((v1-17 (dummy-9 (-> gp-0 data 2) #f)))
(set! (-> v1-17 joint) (the-as joint (-> arg0 data 1)))
(set! (-> v1-17 joint) (-> arg0 data 1))
(set! (-> v1-17 bone) (-> s4-1 bones 2))
(set! (-> v1-17 parent) (the-as cspace (-> gp-0 data)))
(let ((a1-9 v1-17))
Expand All @@ -190,7 +190,7 @@
)
(let ((s3-0 3))
(while (< s3-0 (-> gp-0 length))
(let* ((s1-0 (the-as joint (-> arg0 data (+ s3-0 -1))))
(let* ((s1-0 (-> arg0 data (+ s3-0 -1)))
(s2-0 (if (-> s1-0 parent)
(+ (-> s1-0 parent number) 1)
0
Expand All @@ -211,9 +211,9 @@
)
(add-connection
(-> (if (-> self entity)
(-> self entity extra level)
(-> *level* level-default)
)
(-> self entity extra level)
(-> *level* level-default)
)
foreground-draw-engine
(-> self draw sink-group merc-sink foreground-texture-page)
)
Expand Down Expand Up @@ -504,9 +504,9 @@
(set! (-> v1-26 color-mult quad) (-> (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) quad))
(set! (-> v1-26 color-emissive quad) (-> (new 'static 'vector) quad))
(set! (-> v1-26 level-index) (the-as uint (-> (if (-> obj entity)
(-> obj entity extra level)
(-> *level* level-default)
)
(-> obj entity extra level)
(-> *level* level-default)
)
index
)
)
Expand Down Expand Up @@ -585,15 +585,15 @@
)
(else
(set! (-> s3-0 skeleton bones 0 transform vector 3 quad) (-> (the-as vector (get-property-struct
(-> sv-16 extra)
'trans-offset
'interp
-1000000000.0
*null-vector*
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(-> sv-16 extra)
'trans-offset
'interp
-1000000000.0
*null-vector*
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
quad
)
)
Expand Down Expand Up @@ -716,10 +716,10 @@
(defbehavior ja-aframe process-drawable ((arg0 float) (arg1 int))
(let ((v1-3 (-> self skel root-channel arg1 frame-group)))
(/ (- arg0 (if (and v1-3 (nonzero? v1-3))
(-> v1-3 artist-base)
0.0
)
)
(-> v1-3 artist-base)
0.0
)
)
(if v1-3
(-> v1-3 artist-step)
1.0
Expand Down Expand Up @@ -760,21 +760,20 @@

(defbehavior ja-channel-push! process-drawable ((arg0 int) (arg1 int))
(cond
((or
(zero? (-> self skel active-channels))
(zero? arg1)
(when (>= (+ (-> self skel active-channels) arg0) (-> self skel allocated-length))
(format
0
"WARNING: ~A could not do (ja-channel-push ~D) because it has ~D/~D channels.~%"
self
arg0
(-> self skel active-channels)
(-> self skel allocated-length)
((or (zero? (-> self skel active-channels))
(zero? arg1)
(when (>= (+ (-> self skel active-channels) arg0) (-> self skel allocated-length))
(format
0
"WARNING: ~A could not do (ja-channel-push ~D) because it has ~D/~D channels.~%"
self
arg0
(-> self skel active-channels)
(-> self skel allocated-length)
)
#t
)
#t
)
)
(ja-channel-set! arg0)
)
(else
Expand Down Expand Up @@ -862,8 +861,8 @@

(defbehavior ja-group-size process-drawable ()
(if (< (the-as int (-> self skel root-channel))
(the-as int (-> self skel channel (-> self skel active-channels)))
)
(the-as int (-> self skel channel (-> self skel active-channels)))
)
(-> self skel root-channel 0 group-size)
0
)
Expand Down Expand Up @@ -913,7 +912,8 @@
0
)

;; ERROR: function was not converted to expressions. Cannot decompile.
;; WARN: Unsupported inline assembly instruction kind - [lw ra, return-from-thread(s7)]
;; WARN: Unsupported inline assembly instruction kind - [jr ra]
(defmethod evaluate-joint-control process-drawable ((obj process-drawable))
(local-vars (s7-0 none) (ra-0 int))
(let ((gp-0 (-> obj skel)))
Expand Down Expand Up @@ -962,10 +962,10 @@
(logior! (-> obj draw status) (draw-status no-anim))
)
)
(if (logtest? (-> obj skel status) 72)
(if (logtest? (-> obj skel status) (janim-status blerc blerc-done))
(merc-blend-shape obj)
)
(if (logtest? (-> obj skel status) 384)
(if (logtest? (-> obj skel status) (janim-status eye-done eye))
(merc-eye-anim obj)
)
(label cfg-27)
Expand All @@ -985,10 +985,7 @@
(logclear! (-> self draw status) (draw-status no-anim no-skeleton-update))
(when (nonzero? (-> self skel))
(evaluate-joint-control self)



(when (or (logtest? (-> self skel status) 1) gp-1)
(when (or (logtest? (-> self skel status) (janim-status inited)) gp-1)
(do-joint-math! self)
(if (and gp-1 (type-type? (-> self root type) collide-shape))
(update-transforms! (the-as collide-shape (-> self root)))
Expand Down Expand Up @@ -1081,11 +1078,10 @@
)

(defbehavior process-drawable-delay-player process-drawable ((arg0 time-frame))
(while (and
*target*
(logtest? (-> *target* control unknown-surface00 flags) 2048)
(zero? (logand (-> *target* control status) 1))
)
(while (and *target*
(logtest? (-> *target* control unknown-surface00 flags) 2048)
(zero? (logand (-> *target* control status) 1))
)
(suspend)
)
(set! (-> self state-time) (-> *display* base-frame-counter))
Expand Down Expand Up @@ -1196,10 +1192,9 @@
(set! s5-0 (cond
((valid? (-> s2-0 frame-group) art-joint-anim "joint-control frame-group" #t *valid-con*)
(when (not
(and
(>= (the int (-> s2-0 frame-num)) 0)
(< (the int (-> s2-0 frame-num)) (-> s2-0 frame-group data 0 length))
)
(and (>= (the int (-> s2-0 frame-num)) 0)
(< (the int (-> s2-0 frame-num)) (-> s2-0 frame-group data 0 length))
)
)
(format
*valid-con*
Expand Down
Loading