[decomp] fix and decomp part tester (#935)

* temp

* update tests
This commit is contained in:
water111 2021-10-23 20:15:31 -04:00 committed by GitHub
parent 20e5f671b1
commit d6e82eedb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 353 additions and 45 deletions

View File

@ -2798,11 +2798,11 @@ std::shared_ptr<ControlFlowGraph> build_cfg(
}
if (!changed) {
changed = changed || cfg->find_goto_not_end();
changed = changed || cfg->find_cond_w_empty_else();
}
if (!changed) {
changed = changed || cfg->find_cond_w_empty_else();
changed = changed || cfg->find_goto_not_end();
}
if (!changed) {

View File

@ -21756,8 +21756,8 @@
;; - Types
(deftype part-tester (process)
((root basic :offset-assert 112)
(part basic :offset-assert 116)
((root trsqv :offset-assert 112)
(part sparticle-launch-control :offset-assert 116)
(old-group basic :offset-assert 120))
:method-count-assert 14
:size-assert #x7c
@ -21767,8 +21767,8 @@
;; - Functions
(define-extern part-tester-init-by-other function)
(define-extern start-part function)
(define-extern part-tester-init-by-other (function vector none :behavior process-drawable))
(define-extern start-part (function none))
;; - Unknowns

View File

@ -1145,6 +1145,12 @@
["L527", "quaternion"]
],
"part-tester": [
["L27", "rgba", true],
["L32", "uint64", true]
],
// please do not add things after this entry! git is dumb.
"object-file-that-doesnt-actually-exist-and-i-just-put-this-here-to-prevent-merge-conflicts-with-this-file": []
}

View File

@ -3257,6 +3257,10 @@
[93, "v1", "process-drawable"]
],
"(code part-tester-idle)": [
[[16,22], "s5", "process-drawable"]
],
"(method 20 hud-money)": [
[35, "a0", "process-drawable"],
[38, "v1", "process-drawable"],

View File

@ -1014,7 +1014,7 @@ void SpriteRenderer::do_2d_group0_block_cpu(u32 count,
// lq.xyzw vf18, 1007(vi00) | madday.xyzw ACC, vf26, vf23 (pipeline)
Vector4f basis_y_vf18 = m_frame_data.basis_y;
assert(flag_vi07 == 0);
// assert(flag_vi07 == 0);
Vector4f* xy_array = m_frame_data.xy_array + flag_vi07;
// lq.xyzw vf19, 980(vi07) | ftoi0.xyzw vf11, vf11
Vector4f xy0_vf19 = xy_array[0];

View File

@ -5,3 +5,157 @@
;; name in dgo: part-tester
;; dgos: GAME, ENGINE
(declare-type part-tester basic)
(define-extern *part-tester* part-tester)
(when *debug-segment*
;; failed to figure out what this is:
(set!
(-> *part-group-id-table* 105)
(new 'static 'sparticle-launch-group
:length 2
:duration #xbb8
:linger-duration #x5dc
:name "group-part-tester"
:launcher
(new 'static 'inline-array sparticle-group-item 2 (sp-item 56) (sp-item 57))
:bounds (new 'static 'sphere :w 4096.0)
)
)
(deftype part-tester (process)
((root trsqv :offset-assert 112)
(part sparticle-launch-control :offset-assert 116)
(old-group basic :offset-assert 120)
)
:heap-base #x100
:method-count-assert 14
:size-assert #x7c
:flag-assert #xe0100007c
)
(define *part-tester-name* (the-as string #f))
(defmethod deactivate part-tester ((obj part-tester))
(if (nonzero? (-> obj part))
(kill-and-free-particles (-> obj part))
)
((method-of-type process deactivate) obj)
(none)
)
(defstate part-tester-idle (part-tester)
:code
(behavior ()
(while #t
(let ((gp-0 (entity-by-name *part-tester-name*)))
(when gp-0
(let ((s5-0 (-> gp-0 extra process)))
(if
(and
s5-0
(type-type? (-> s5-0 type) process-drawable)
(nonzero? (-> (the-as process-drawable s5-0) root))
)
(set!
(-> self root trans quad)
(-> (the-as process-drawable s5-0) root trans quad)
)
(set! (-> self root trans quad) (-> gp-0 extra trans quad))
)
)
)
)
(add-debug-x
#t
(bucket-id debug-draw1)
(-> self root trans)
(the-as rgba (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80))
)
;; change this line to change the particle group to test
;; notes:
;; - 3d particles won't work
;; - particles that use aux list won't work
;; - some particles may have callbacks that won't work yet
;; - you need to load the level with the particle defs first
;; - there is an issue with blending. check the "always" box as a temporary workaround
;; - the visibilty check also doesn't work. comment it out in defmethod spawn.
(let ((gp-1 (-> *part-group-id-table* 105)))
(let ((s5-1 (-> self root trans)))
(when (!= gp-1 (-> self old-group))
(when (nonzero? (-> self part))
(kill-and-free-particles (-> self part))
(set! (-> self heap-cur) (&-> (-> self part) type))
)
(set! (-> self part) (create-launch-control gp-1 self))
)
(when (nonzero? (-> self part))
(spawn (-> self part) (cond
((logtest?
(-> gp-1 flags)
(sp-group-flag screen-space)
)
*zero-vector*
)
(else
(empty)
s5-1
)
)
)
)
)
(set! (-> self old-group) gp-1)
)
(suspend)
)
(none)
)
)
(defbehavior part-tester-init-by-other process-drawable ((arg0 vector))
(set! (-> self root) (new 'process 'trsqv))
(set! (-> self root trans quad) (-> arg0 quad))
(set! *part-tester* (the-as part-tester (process->ppointer self)))
(go part-tester-idle)
(none)
)
(define-perm *debug-part-dead-pool* dead-pool
(new 'debug 'dead-pool 1 #x10000 '*debug-part-dead-pool*)
)
(defun start-part ()
(kill-by-type part-tester *active-pool*)
(let ((gp-0 (get-process *debug-part-dead-pool* part-tester #x4000)))
(when gp-0
(let ((t9-2 (method-of-type part-tester activate)))
(t9-2
(the-as part-tester gp-0)
*default-pool*
'part-tester
(the-as pointer #x70004000)
)
)
(run-now-in-process gp-0 part-tester-init-by-other (if *anim-tester*
(->
*anim-tester*
0
root
trans
)
(target-pos 0)
)
)
(-> gp-0 ppointer)
)
)
(none)
)
)

View File

@ -944,7 +944,7 @@
(defmethod spawn sparticle-launch-control ((obj sparticle-launch-control) (arg0 vector))
(set! (-> obj center quad) (-> arg0 quad))
;; check if we are visible
;; check if we are visible (remove this check to force particles to be drawn.)
(if (not (or (is-visible? obj arg0)
(logtest? (-> obj group flags) (sp-group-flag always-draw screen-space))
)

View File

@ -0,0 +1,166 @@
;;-*-Lisp-*-
(in-package goal)
;; this file is debug only
(when *debug-segment*
;; failed to figure out what this is:
(set!
(-> *part-group-id-table* 105)
(new 'static 'sparticle-launch-group
:length 2
:duration #xbb8
:linger-duration #x5dc
:name "group-part-tester"
:launcher
(new 'static 'inline-array sparticle-group-item 2 (sp-item 56) (sp-item 57))
:bounds (new 'static 'sphere :w 4096.0)
)
)
;; definition of type part-tester
(deftype part-tester (process)
((root trsqv :offset-assert 112)
(part sparticle-launch-control :offset-assert 116)
(old-group basic :offset-assert 120)
)
:heap-base #x100
:method-count-assert 14
:size-assert #x7c
:flag-assert #xe0100007c
)
;; definition for method 3 of type part-tester
(defmethod inspect part-tester ((obj part-tester))
(let ((t9-0 (method-of-type process inspect)))
(t9-0 obj)
)
(format #t "~T~Troot: ~A~%" (-> obj root))
(format #t "~T~Tpart: ~A~%" (-> obj part))
(format #t "~T~Told-group: ~A~%" (-> obj old-group))
obj
)
;; definition for symbol *part-tester-name*, type string
(define *part-tester-name* (the-as string #f))
;; definition for method 10 of type part-tester
(defmethod deactivate part-tester ((obj part-tester))
(if (nonzero? (-> obj part))
(kill-and-free-particles (-> obj part))
)
((method-of-type process deactivate) obj)
(none)
)
;; failed to figure out what this is:
(defstate part-tester-idle (part-tester)
:code
(behavior ()
(while #t
(let ((gp-0 (entity-by-name *part-tester-name*)))
(when gp-0
(let ((s5-0 (-> gp-0 extra process)))
(if
(and
s5-0
(type-type? (-> s5-0 type) process-drawable)
(nonzero? (-> (the-as process-drawable s5-0) root))
)
(set!
(-> self root trans quad)
(-> (the-as process-drawable s5-0) root trans quad)
)
(set! (-> self root trans quad) (-> gp-0 extra trans quad))
)
)
)
)
(add-debug-x
#t
(bucket-id debug-draw1)
(-> self root trans)
(the-as rgba (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80))
)
(let ((gp-1 (-> *part-group-id-table* 105)))
(let ((s5-1 (-> self root trans)))
(when (!= gp-1 (-> self old-group))
(when (nonzero? (-> self part))
(kill-and-free-particles (-> self part))
(set! (-> self heap-cur) (&-> (-> self part) type))
)
(set! (-> self part) (create-launch-control gp-1 self))
)
(if (nonzero? (-> self part))
(spawn (-> self part) (cond
((logtest?
(-> gp-1 flags)
(sp-group-flag screen-space)
)
*zero-vector*
)
(else
(empty)
s5-1
)
)
)
)
)
(set! (-> self old-group) gp-1)
)
(suspend)
)
(none)
)
)
;; definition for function part-tester-init-by-other
;; INFO: Return type mismatch object vs none.
;; Used lq/sq
(defbehavior part-tester-init-by-other process-drawable ((arg0 vector))
(set! (-> self root) (new 'process 'trsqv))
(set! (-> self root trans quad) (-> arg0 quad))
(set! *part-tester* (the-as part-tester (process->ppointer self)))
(go part-tester-idle)
(none)
)
;; definition (perm) for symbol *debug-part-dead-pool*, type dead-pool
(define-perm *debug-part-dead-pool* dead-pool
(new 'debug 'dead-pool 1 #x10000 '*debug-part-dead-pool*)
)
;; definition for function start-part
;; INFO: Return type mismatch (pointer process) vs none.
(defun start-part ()
(kill-by-type part-tester *active-pool*)
(let ((gp-0 (get-process *debug-part-dead-pool* part-tester #x4000)))
(when gp-0
(let ((t9-2 (method-of-type part-tester activate)))
(t9-2
(the-as part-tester gp-0)
*default-pool*
'part-tester
(the-as pointer #x70004000)
)
)
(run-now-in-process gp-0 part-tester-init-by-other (if *anim-tester*
(->
*anim-tester*
0
root
trans
)
(target-pos 0)
)
)
(-> gp-0 ppointer)
)
)
(none)
)
)

View File

@ -1016,39 +1016,21 @@
)
(else
(let* ((a0-1 (-> obj bsp boxes))
(v1-5 (the-as object (-> a0-1 data)))
(s5-1 (-> a0-1 data))
)
(countdown (a0-2 (-> a0-1 length))
(if
(and
(>=
(-> arg0 x)
(-> (the-as (inline-array box8s) v1-5) 0 min x)
)
(>=
(-> arg0 y)
(-> (the-as (inline-array box8s) v1-5) 0 min y)
)
(>=
(-> arg0 z)
(-> (the-as (inline-array box8s) v1-5) 0 min z)
)
(<
(-> arg0 x)
(-> (the-as (inline-array box8s) v1-5) 0 max x)
)
(<
(-> arg0 y)
(-> (the-as (inline-array box8s) v1-5) 0 max y)
)
(<
(-> arg0 z)
(-> (the-as (inline-array box8s) v1-5) 0 max z)
)
(>= (-> arg0 x) (-> s5-1 0 min x))
(>= (-> arg0 y) (-> s5-1 0 min y))
(>= (-> arg0 z) (-> s5-1 0 min z))
(< (-> arg0 x) (-> s5-1 0 max x))
(< (-> arg0 y) (-> s5-1 0 max y))
(< (-> arg0 z) (-> s5-1 0 max z))
)
(return (the-as symbol #t))
)
(set! v1-5 (-> (the-as (inline-array box8s) v1-5) 1))
(set! s5-1 (the-as (inline-array box8s) (-> s5-1 1)))
)
)
#f
@ -2159,7 +2141,3 @@
)
)
)

View File

@ -250,13 +250,13 @@
;; definition of type vector4w
(deftype vector4w (structure)
((data int32 4 :offset 0)
(x int32 :offset 0)
(y int32 :offset 4)
(z int32 :offset 8)
(w int32 :offset 12)
(dword uint64 2 :offset 0)
(quad uint128 :offset 0)
((data int32 4 :offset-assert 0)
(x int32 :offset 0)
(y int32 :offset 4)
(z int32 :offset 8)
(w int32 :offset 12)
(dword uint64 2 :offset 0)
(quad uint128 :offset 0)
)
:method-count-assert 9
:size-assert #x10