add ref test for sprite and support nested bitfields in static data (#723)

This commit is contained in:
water111 2021-07-26 20:02:16 -04:00 committed by GitHub
parent 92a5d84a5b
commit bd9f550d82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1538 additions and 261 deletions

View file

@ -454,6 +454,13 @@ goos::Object SetFormFormElement::to_form_internal(const Env& env) const {
goos::Object SetFormFormElement::to_form_for_define(const Env& env) const { goos::Object SetFormFormElement::to_form_for_define(const Env& env) const {
if (m_cast_for_define) { if (m_cast_for_define) {
// for vu-function, we just put a 0. These aren't supported
if (*m_cast_for_define == TypeSpec("vu-function")) {
return pretty_print::build_list(
fmt::format("define"), m_dst->to_form(env),
pretty_print::build_list(fmt::format("the-as {}", m_cast_for_define->print()),
pretty_print::to_symbol("0")));
}
return pretty_print::build_list( return pretty_print::build_list(
fmt::format("define"), m_dst->to_form(env), fmt::format("define"), m_dst->to_form(env),
pretty_print::build_list(fmt::format("the-as {}", m_cast_for_define->print()), pretty_print::build_list(fmt::format("the-as {}", m_cast_for_define->print()),

View file

@ -647,7 +647,14 @@ BitFieldDef BitFieldDef::from_constant(const BitFieldConstantDef& constant, Form
BitFieldDef bfd; BitFieldDef bfd;
bfd.field_name = constant.field_name; bfd.field_name = constant.field_name;
bfd.is_signed = constant.is_signed; bfd.is_signed = constant.is_signed;
if (constant.enum_constant) { if (constant.nested_field) {
std::vector<BitFieldDef> defs;
for (auto& x : constant.nested_field->fields) {
defs.push_back(BitFieldDef::from_constant(x, pool));
}
bfd.value = pool.alloc_single_element_form<BitfieldStaticDefElement>(
nullptr, constant.nested_field->field_type, defs);
} else if (constant.enum_constant) {
bfd.value = bfd.value =
pool.alloc_single_element_form<ConstantTokenElement>(nullptr, *constant.enum_constant); pool.alloc_single_element_form<ConstantTokenElement>(nullptr, *constant.enum_constant);
} else { } else {

View file

@ -530,6 +530,7 @@
(water-tex1 60) (water-tex1 60)
;; merc1 61 ;; merc1 61
;; generic1 62 ;; generic1 62
(depth-cue 64)
(bucket-65 65) (bucket-65 65)
(sprite 66) (sprite 66)
;; debug spheres? 67 ;; debug spheres? 67
@ -5075,7 +5076,7 @@
(define-extern math-cam-start-smoothing (function float float quaternion)) (define-extern math-cam-start-smoothing (function float float quaternion))
(define-extern move-target-from-pad (function transform int transform)) (define-extern move-target-from-pad (function transform int transform))
(define-extern transform-point-vector! (function vector vector symbol)) (define-extern transform-point-vector! (function vector vector symbol))
(define-extern transform-point-qword! (function vector vector symbol)) (define-extern transform-point-qword! (function vector4w vector symbol))
(define-extern transform-point-vector-scale! (function vector vector float)) (define-extern transform-point-vector-scale! (function vector vector float))
(define-extern init-for-transform (function matrix none)) (define-extern init-for-transform (function matrix none))
@ -15698,7 +15699,7 @@
;; - Functions ;; - Functions
(define-extern depth-cue-draw-front function) (define-extern depth-cue-draw-front (function dma-buffer int float float uint int none))
(define-extern depth-cue-set-stencil function) (define-extern depth-cue-set-stencil function)
(define-extern depth-cue-draw-depth function) (define-extern depth-cue-draw-depth function)
(define-extern depth-cue-calc-z function) (define-extern depth-cue-calc-z function)
@ -15706,7 +15707,7 @@
;; - Unknowns ;; - Unknowns
;;(define-extern *depth-cue-work* object) ;; unknown type (define-extern *depth-cue-work* depth-cue-work)
;; ---------------------- ;; ----------------------

View file

@ -97,10 +97,6 @@
// vector // vector
"vector=", // asm branching "vector=", // asm branching
// texture
// "adgif-shader<-texture-with-update!", // F: asm branching
// "(method 9 texture-page-dir)",
// collide-mesh-h // collide-mesh-h
"(method 11 collide-mesh-cache)", "(method 11 collide-mesh-cache)",
@ -117,6 +113,9 @@
"clear-frame-accumulator", // F: asm branching "clear-frame-accumulator", // F: asm branching
"cspace<-parented-transformq-joint!", "cspace<-parented-transformq-joint!",
// sprite
"add-to-sprite-aux-list", // fine, but don't know types yet.
// merc-blend-shape // merc-blend-shape
"setup-blerc-chains-for-one-fragment", // F: asm branching "setup-blerc-chains-for-one-fragment", // F: asm branching
"blerc-execute", // F: asm branching "blerc-execute", // F: asm branching
@ -526,8 +525,6 @@
"(method 12 perf-stat)": [0], "(method 12 perf-stat)": [0],
"(method 11 perf-stat)": [0], "(method 11 perf-stat)": [0],
"(method 20 actor-link-info)": [2],
"(method 21 actor-link-info)": [2],
"raw-ray-sphere-intersect": [0, 1, 2, 3, 4, 5], "raw-ray-sphere-intersect": [0, 1, 2, 3, 4, 5],
"ray-cylinder-intersect": [0, 1, 2, 3, 4, 5], "ray-cylinder-intersect": [0, 1, 2, 3, 4, 5],
"ray-triangle-intersect": [0, 1, 2, 3, 4], "ray-triangle-intersect": [0, 1, 2, 3, 4],

View file

@ -1282,7 +1282,8 @@
["L509", "(inline-array list-field)", true, 12], ["L509", "(inline-array list-field)", true, 12],
["L123", "_lambda_", true], ["L123", "_lambda_", true],
["L119", "_lambda_", true], ["L119", "_lambda_", true],
["L86", "_lambda_", true] ["L86", "_lambda_", true],
["L652", "float", true]
], ],
// please do not add things after this entry! git is dumb. // please do not add things after this entry! git is dumb.

View file

@ -1266,20 +1266,20 @@
[23, "v1", "float"], [23, "v1", "float"],
[36, "v1", "uint"] [36, "v1", "uint"]
], ],
"(method 0 anim-test-obj)": [ "(method 0 anim-test-obj)": [
[9, "s4", "anim-test-obj"], [9, "s4", "anim-test-obj"],
[10, "s4", "anim-test-obj"], [10, "s4", "anim-test-obj"],
[13, "s4", "anim-test-obj"], [13, "s4", "anim-test-obj"],
[15, "s4", "anim-test-obj"] [15, "s4", "anim-test-obj"]
], ],
"(method 0 anim-test-sequence)": [ "(method 0 anim-test-sequence)": [
[8, "s5", "anim-test-sequence"], [8, "s5", "anim-test-sequence"],
[11, "s5", "anim-test-sequence"], [11, "s5", "anim-test-sequence"],
[13, "s5", "anim-test-sequence"] [13, "s5", "anim-test-sequence"]
], ],
"(method 0 anim-test-seq-item)": [ "(method 0 anim-test-seq-item)": [
[8, "v1", "anim-test-seq-item"], [8, "v1", "anim-test-seq-item"],
[10, "v0", "anim-test-seq-item"], [10, "v0", "anim-test-seq-item"],
@ -1287,7 +1287,7 @@
[14, "v0", "anim-test-seq-item"], [14, "v0", "anim-test-seq-item"],
[17, "v0", "anim-test-seq-item"] [17, "v0", "anim-test-seq-item"]
], ],
"(method 3 anim-tester)": [ "(method 3 anim-tester)": [
[12, "s5", "anim-test-obj"], [12, "s5", "anim-test-obj"],
[15, "s5", "anim-test-obj"], [15, "s5", "anim-test-obj"],
@ -1311,7 +1311,7 @@
[126, "s3", "anim-test-seq-item"], [126, "s3", "anim-test-seq-item"],
[128, "s3", "anim-test-seq-item"] [128, "s3", "anim-test-seq-item"]
], ],
"anim-test-obj-item-valid?": [ "anim-test-obj-item-valid?": [
[5, "s5", "anim-test-sequence"], [5, "s5", "anim-test-sequence"],
[12, "s5", "anim-test-sequence"], [12, "s5", "anim-test-sequence"],
@ -1322,7 +1322,7 @@
[26, "v1", "anim-test-seq-item"], [26, "v1", "anim-test-seq-item"],
[28, "v1", "anim-test-seq-item"] [28, "v1", "anim-test-seq-item"]
], ],
"anim-test-obj-remove-invalid": [ "anim-test-obj-remove-invalid": [
[84, "v1", "anim-test-sequence"], [84, "v1", "anim-test-sequence"],
[88, "v1", "anim-test-sequence"], [88, "v1", "anim-test-sequence"],
@ -1350,7 +1350,7 @@
[36, "s3", "anim-test-seq-item"], [36, "s3", "anim-test-seq-item"],
[61, "a0", "anim-test-seq-item"] [61, "a0", "anim-test-seq-item"]
], ],
"anim-tester-reset": [ "anim-tester-reset": [
[14, "v1", "anim-test-obj"], [14, "v1", "anim-test-obj"],
[30, "v1", "anim-test-obj"], [30, "v1", "anim-test-obj"],
@ -1359,12 +1359,12 @@
[43, "v1", "anim-test-obj"], [43, "v1", "anim-test-obj"],
[[50, 53], "v1", "anim-test-obj"] [[50, 53], "v1", "anim-test-obj"]
], ],
"anim-tester-save-all-objects": [ "anim-tester-save-all-objects": [
[[4, 19], "gp", "anim-test-obj"], [[4, 19], "gp", "anim-test-obj"],
[17, "v1", "anim-test-obj"] [17, "v1", "anim-test-obj"]
], ],
"anim-tester-save-object-seqs": [ "anim-tester-save-object-seqs": [
[63, "s5", "anim-test-sequence"], [63, "s5", "anim-test-sequence"],
[69, "s5", "anim-test-sequence"], [69, "s5", "anim-test-sequence"],
@ -1386,7 +1386,7 @@
[121, "v1", "anim-test-seq-item"], [121, "v1", "anim-test-seq-item"],
[122, "s4", "anim-test-seq-item"] [122, "s4", "anim-test-seq-item"]
], ],
"anim-test-obj-list-handler": [ "anim-test-obj-list-handler": [
[25, "s5", "anim-test-obj"], [25, "s5", "anim-test-obj"],
[31, "s5", "anim-test-obj"], [31, "s5", "anim-test-obj"],
@ -1394,7 +1394,7 @@
[166, "s5", "anim-test-obj"], [166, "s5", "anim-test-obj"],
[112, "v1", "anim-tester"] [112, "v1", "anim-tester"]
], ],
"anim-test-anim-list-handler": [ "anim-test-anim-list-handler": [
[2, "s5", "anim-test-obj"], [2, "s5", "anim-test-obj"],
[25, "s5", "anim-test-obj"], [25, "s5", "anim-test-obj"],
@ -1413,7 +1413,7 @@
[171, "v1", "anim-test-obj"], [171, "v1", "anim-test-obj"],
[173, "v1", "anim-test-obj"] [173, "v1", "anim-test-obj"]
], ],
"anim-test-sequence-list-handler": [ "anim-test-sequence-list-handler": [
[2, "s5", "anim-test-sequence"], [2, "s5", "anim-test-sequence"],
[25, "s5", "anim-test-sequence"], [25, "s5", "anim-test-sequence"],
@ -1429,7 +1429,7 @@
[146, "v1", "anim-test-sequence"], [146, "v1", "anim-test-sequence"],
[151, "v1", "anim-test-sequence"] [151, "v1", "anim-test-sequence"]
], ],
"anim-test-edit-sequence-list-handler": [ "anim-test-edit-sequence-list-handler": [
[[122, 965], "s4", "anim-test-sequence"], [[122, 965], "s4", "anim-test-sequence"],
[129, "v1", "glst-named-node"], [129, "v1", "glst-named-node"],
@ -1442,21 +1442,21 @@
[491, "s3", "anim-test-seq-item"], [491, "s3", "anim-test-seq-item"],
[502, "s3", "anim-test-seq-item"] [502, "s3", "anim-test-seq-item"]
], ],
"anim-tester-interface": [ "anim-tester-interface": [
[[34, 48], "gp", "anim-test-obj"], [[34, 48], "gp", "anim-test-obj"],
[[95, 109], "gp", "anim-test-obj"], [[95, 109], "gp", "anim-test-obj"],
[[156, 160], "v1", "anim-test-obj"], [[156, 160], "v1", "anim-test-obj"],
[[162, 165], "v1", "anim-test-sequence"] [[162, 165], "v1", "anim-test-sequence"]
], ],
"anim-tester-get-playing-item": [ "anim-tester-get-playing-item": [
[7, "v0", "anim-test-seq-item"], [7, "v0", "anim-test-seq-item"],
[[5, 22], "s5", "anim-test-seq-item"], [[5, 22], "s5", "anim-test-seq-item"],
[21, "v0", "anim-test-seq-item"], [21, "v0", "anim-test-seq-item"],
[25, "v0", "anim-test-seq-item"] [25, "v0", "anim-test-seq-item"]
], ],
"anim-tester-add-newobj": [ "anim-tester-add-newobj": [
[[2, 185], "s2", "anim-test-obj"], [[2, 185], "s2", "anim-test-obj"],
[[70, 193], "s5", "anim-test-obj"], [[70, 193], "s5", "anim-test-obj"],
@ -1466,20 +1466,16 @@
[164, "a0", "art-joint-anim"], [164, "a0", "art-joint-anim"],
[170, "a0", "art-joint-anim"] [170, "a0", "art-joint-anim"]
], ],
"anim-tester-start": [ "anim-tester-start": [[20, "t9", "(function process function none)"]],
[20, "t9", "(function process function none)"]
],
"anim-tester-set-name": [ "anim-tester-set-name": [
[[34, 51], "s3", "anim-test-obj"], [[34, 51], "s3", "anim-test-obj"],
[[40, 63], "s5", "anim-test-sequence"] [[40, 63], "s5", "anim-test-sequence"]
], ],
"anim-tester-add-sequence": [ "anim-tester-add-sequence": [[[33, 102], "s5", "anim-test-obj"]],
[[33, 102], "s5", "anim-test-obj"]
],
"(anon-function 11 anim-tester)": [ "(anon-function 11 anim-tester)": [
[[23, 113], "s4", "anim-test-obj"], [[23, 113], "s4", "anim-test-obj"],
[[83, 338], "gp", "anim-test-sequence"], [[83, 338], "gp", "anim-test-sequence"],
@ -1579,5 +1575,17 @@
[[62, 67], "a1", "dma-packet"] [[62, 67], "a1", "dma-packet"]
], ],
"sprite-draw-distorters": [
[[70, 90], "a0", "vector"],
[72, "v1", "vector"],
[93, "v1", "vector"],
[96, "v1", "vector"],
[115, "v1", "(pointer int32)"],
[119, "a0", "(pointer int32)"],
[124, "v1", "vector"],
[154, "v1", "vector"],
[[172, 189], "a1", "dma-packet"]
],
"placeholder-do-not-add-below": [] "placeholder-do-not-add-below": []
} }

View file

@ -2162,6 +2162,7 @@
}, },
"add-debug-point": { "add-debug-point": {
"args": ["enable-draw", "bucket", "pt"],
"vars": { "vars": {
"a0-6": ["a0-6", "(pointer uint64)"], "a0-6": ["a0-6", "(pointer uint64)"],
"a0-7": ["a0-7", "dma-packet"], "a0-7": ["a0-7", "dma-packet"],

View file

@ -1183,6 +1183,14 @@ std::optional<std::vector<BitFieldConstantDef>> try_decompile_bitfield_from_int(
auto name = decompile_int_enum_from_int(field.type(), ts, bitfield_value); auto name = decompile_int_enum_from_int(field.type(), ts, bitfield_value);
def.enum_constant = fmt::format("({} {})", field.type().print(), name); def.enum_constant = fmt::format("({} {})", field.type().print(), name);
} }
auto nested_bitfield_type = dynamic_cast<BitFieldType*>(ts.lookup_type(field.type()));
if (nested_bitfield_type) {
BitFieldConstantDef::NestedField nested;
nested.field_type = field.type();
nested.fields = *try_decompile_bitfield_from_int(field.type(), ts, bitfield_value, true);
def.nested_field = nested;
}
result.push_back(def); result.push_back(def);
} }

View file

@ -73,6 +73,13 @@ struct BitFieldConstantDef {
u64 value = -1; u64 value = -1;
std::optional<std::string> enum_constant; std::optional<std::string> enum_constant;
std::string field_name; std::string field_name;
struct NestedField {
TypeSpec field_type;
std::vector<BitFieldConstantDef> fields;
};
std::optional<NestedField> nested_field;
}; };
template <typename T> template <typename T>

View file

@ -439,7 +439,7 @@
) )
) )
(defun transform-point-qword! ((arg0 vector) (arg1 vector)) (defun transform-point-qword! ((arg0 vector4w) (arg1 vector))
"Apply camera transformation to point, returning fixed point 28.4 position" "Apply camera transformation to point, returning fixed point 28.4 position"
(rlet ((acc :class vf) (rlet ((acc :class vf)
(Q :class vf) (Q :class vf)

View file

@ -5,7 +5,6 @@
;; name in dgo: debug-sphere ;; name in dgo: debug-sphere
;; dgos: GAME, ENGINE ;; dgos: GAME, ENGINE
;; definition of type debug-sphere-table
(deftype debug-sphere-table (basic) (deftype debug-sphere-table (basic)
((point vector 300 :inline :offset-assert 16) ((point vector 300 :inline :offset-assert 16)
) )
@ -14,9 +13,6 @@
:flag-assert #x9000012d0 :flag-assert #x9000012d0
) )
;; definition for function make-debug-sphere-table
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defun make-debug-sphere-table ((arg0 debug-sphere-table)) (defun make-debug-sphere-table ((arg0 debug-sphere-table))
(local-vars (sv-80 int)) (local-vars (sv-80 int))
(let ((s5-0 (new-stack-vector0)) (let ((s5-0 (new-stack-vector0))
@ -31,41 +27,17 @@
(s1-0 (new-stack-vector0)) (s1-0 (new-stack-vector0))
(s0-0 (new-stack-vector0)) (s0-0 (new-stack-vector0))
) )
(set! (set! (-> s2-0 y) (+ (-> s5-0 y) (* (cos (* 3276.8 (the float s3-0))) f30-0)))
(-> s2-0 y)
(+ (-> s5-0 y) (* (cos (* 3276.8 (the float s3-0))) f30-0))
)
(set! (-> s1-0 y) (-> s2-0 y)) (set! (-> s1-0 y) (-> s2-0 y))
(set! (set! (-> s0-0 y) (+ (-> s5-0 y) (* (cos (* 3276.8 (the float (+ s3-0 1)))) f30-0)))
(-> s0-0 y)
(+ (-> s5-0 y) (* (cos (* 3276.8 (the float (+ s3-0 1)))) f30-0))
)
(set! sv-80 0) (set! sv-80 0)
(while (< sv-80 10) (while (< sv-80 10)
(set! (set! (-> s2-0 x) (+ (-> s5-0 x) (* (cos (* 6553.6 (the float sv-80))) f28-0)))
(-> s2-0 x) (set! (-> s2-0 z) (+ (-> s5-0 z) (* (sin (* 6553.6 (the float sv-80))) f28-0)))
(+ (-> s5-0 x) (* (cos (* 6553.6 (the float sv-80))) f28-0)) (set! (-> s1-0 x) (+ (-> s5-0 x) (* (cos (* 6553.6 (the float (+ sv-80 1)))) f28-0)))
) (set! (-> s1-0 z) (+ (-> s5-0 z) (* (sin (* 6553.6 (the float (+ sv-80 1)))) f28-0)))
(set! (set! (-> s0-0 x) (+ (-> s5-0 x) (* (cos (* 6553.6 (the float sv-80))) f26-0)))
(-> s2-0 z) (set! (-> s0-0 z) (+ (-> s5-0 z) (* (sin (* 6553.6 (the float sv-80))) f26-0)))
(+ (-> s5-0 z) (* (sin (* 6553.6 (the float sv-80))) f28-0))
)
(set!
(-> s1-0 x)
(+ (-> s5-0 x) (* (cos (* 6553.6 (the float (+ sv-80 1)))) f28-0))
)
(set!
(-> s1-0 z)
(+ (-> s5-0 z) (* (sin (* 6553.6 (the float (+ sv-80 1)))) f28-0))
)
(set!
(-> s0-0 x)
(+ (-> s5-0 x) (* (cos (* 6553.6 (the float sv-80))) f26-0))
)
(set!
(-> s0-0 z)
(+ (-> s5-0 z) (* (sin (* 6553.6 (the float sv-80))) f26-0))
)
(set! (-> arg0 point s4-0 quad) (-> s2-0 quad)) (set! (-> arg0 point s4-0 quad) (-> s2-0 quad))
(set! (-> arg0 point (+ s4-0 1) quad) (-> s1-0 quad)) (set! (-> arg0 point (+ s4-0 1) quad) (-> s1-0 quad))
(set! (-> arg0 point (+ s4-0 2) quad) (-> s0-0 quad)) (set! (-> arg0 point (+ s4-0 2) quad) (-> s0-0 quad))
@ -75,56 +47,45 @@
) )
) )
) )
(let ((v0-10 0))
)
(none) (none)
) )
;; definition for symbol *debug-sphere-table*, type debug-sphere-table
(define *debug-sphere-table* (new 'static 'debug-sphere-table)) (define *debug-sphere-table* (new 'static 'debug-sphere-table))
;; failed to figure out what this is:
(make-debug-sphere-table *debug-sphere-table*) (make-debug-sphere-table *debug-sphere-table*)
;; definition for function add-debug-sphere-from-table (defun add-debug-sphere-from-table ((arg0 bucket-id) (arg1 vector) (arg2 float) (arg3 rgba))
;; INFO: Return type mismatch int vs none. "Draw a wireframe sphere"
;; Used lq/sq
(defun
add-debug-sphere-from-table
((arg0 bucket-id) (arg1 vector) (arg2 float) (arg3 rgba))
(rlet ((vf1 :class vf) (rlet ((vf1 :class vf)
(vf2 :class vf) (vf2 :class vf)
(vf3 :class vf) (vf3 :class vf)
(vf4 :class vf) (vf4 :class vf)
(vf5 :class vf) (vf5 :class vf)
) )
(let ((s4-0 (new-stack-vector0)) (let ((s4-0 (new-stack-vector0))
(s3-0 (new-stack-vector0)) (s3-0 (new-stack-vector0))
(s2-0 (new-stack-vector0)) (s2-0 (new-stack-vector0))
(points (-> *debug-sphere-table* point)) (points (-> *debug-sphere-table* point))
) )
(.lvf vf1 (&-> arg1 quad)) (.lvf vf1 (&-> arg1 quad))
(.mov vf2 arg2) (.mov vf2 arg2)
(dotimes (s0-0 100) (dotimes (s0-0 100)
(.lvf vf3 (&-> points 0 quad)) (.lvf vf3 (&-> points 0 quad))
(.lvf vf4 (&-> points 1 quad)) (.lvf vf4 (&-> points 1 quad))
(.lvf vf5 (&-> points 2 quad)) (.lvf vf5 (&-> points 2 quad))
(set! points (the-as (inline-array vector) (-> points 3))) (set! points (the-as (inline-array vector) (-> points 3)))
(.mul.x.vf vf3 vf3 vf2) (.mul.x.vf vf3 vf3 vf2)
(.mul.x.vf vf4 vf4 vf2) (.mul.x.vf vf4 vf4 vf2)
(.mul.x.vf vf5 vf5 vf2) (.mul.x.vf vf5 vf5 vf2)
(.add.vf vf3 vf3 vf1) (.add.vf vf3 vf3 vf1)
(.add.vf vf4 vf4 vf1) (.add.vf vf4 vf4 vf1)
(.add.vf vf5 vf5 vf1) (.add.vf vf5 vf5 vf1)
(.svf (&-> s4-0 quad) vf3) (.svf (&-> s4-0 quad) vf3)
(.svf (&-> s3-0 quad) vf4) (.svf (&-> s3-0 quad) vf4)
(.svf (&-> s2-0 quad) vf5) (.svf (&-> s2-0 quad) vf5)
(add-debug-line #t arg0 s4-0 s3-0 arg3 #f (the rgba -1)) (add-debug-line #t arg0 s4-0 s3-0 arg3 #f (the rgba -1))
(add-debug-line #t arg0 s4-0 s2-0 arg3 #f (the rgba -1)) (add-debug-line #t arg0 s4-0 s2-0 arg3 #f (the rgba -1))
) )
)
(none)
) )
(let ((v0-2 0))
)
(none)
)
) )

View file

@ -6,15 +6,17 @@
;; dgos: GAME, ENGINE ;; dgos: GAME, ENGINE
(defun transform-float-point ((arg0 vector) (arg1 vector)) (defun transform-float-point ((in vector) (out vector))
"Transform point in and store the result in out.
This uses the cached vf register transformation matrix
Note that the input/output order of the arguments is swapped from usual"
(with-vf0 (with-vf0
(with-vf (vf4 vf1 vf2 vf3 vf9 vf8 vf6) (with-vf (vf4 vf1 vf2 vf3 vf9 vf8 vf6)
(rlet ((acc :class vf) (rlet ((acc :class vf)
(Q :class vf) (Q :class vf)
(vf5 :class vf) (vf5 :class vf)
) )
(.lvf vf5 (&-> arg0 quad)) (.lvf vf5 (&-> in quad))
(.mul.w.vf acc vf4 vf5) (.mul.w.vf acc vf4 vf5)
(.add.mul.x.vf acc vf1 vf5 acc) (.add.mul.x.vf acc vf1 vf5 acc)
(.add.mul.y.vf acc vf2 vf5 acc) (.add.mul.y.vf acc vf2 vf5 acc)
@ -26,146 +28,154 @@
(.max.x.vf vf5 vf5 vf0 :mask #b1000) (.max.x.vf vf5 vf5 vf0 :mask #b1000)
(.min.x.vf vf5 vf5 vf6 :mask #b1000) (.min.x.vf vf5 vf5 vf6 :mask #b1000)
(vftoi4.xyzw vf5 vf5) (vftoi4.xyzw vf5 vf5)
(.svf (&-> arg1 quad) vf5) (.svf (&-> out quad) vf5)
arg1 out
) )
) )
) )
) )
(defun-debug add-debug-point ((arg0 symbol) (arg1 bucket-id) (arg2 vector)) ;;;;;;;;;;;;;;;;;;
(if (not arg0) ;; Debug Draw
(return #f) ;;;;;;;;;;;;;;;;;;
)
;; All of these functions are super slow and probably very old.
;; They do a DMA packet per thing drawn.
(defun-debug add-debug-point ((enable-draw symbol) (bucket bucket-id) (pt vector))
"Draw a point."
(if (not enable-draw)
(return #f)
)
(let ((s5-0 (new 'stack 'vector4w-2))) (let ((s5-0 (new 'stack 'vector4w-2)))
(set! (-> arg2 w) 1.0) ;; transform the input point and convert to fixed point
(when (transform-point-qword! (the-as vector (-> s5-0 quad)) arg2) (set! (-> pt w) 1.0)
(let* ((v1-7 (-> *display* frames (-> *display* on-screen) frame debug-buf)) (when (transform-point-qword! (the-as vector4w (-> s5-0 quad)) pt)
(a2-1 (-> v1-7 base)) (let* ((v1-7 (-> *display* frames (-> *display* on-screen) frame debug-buf))
(a2-1 (-> v1-7 base))
)
(let ((a0-6 (the-as (pointer uint64) (-> v1-7 base))))
(let* ((a1-3 v1-7)
(a3-0 (the-as dma-packet (-> a1-3 base)))
)
;; for now, don't set the length
(set! (-> a3-0 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> a3-0 vif0) (new 'static 'vif-tag))
(set! (-> a3-0 vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1))
(set! (-> a1-3 base) (&+ (the-as pointer a3-0) 16))
)
;; add a giftag to draw a primitive
(let* ((a1-4 v1-7)
(a3-2 (the-as gs-gif-tag (-> a1-4 base)))
)
(set! (-> a3-2 tag)
(new 'static 'gif-tag64
:nloop #x1
:eop #x1
:pre #x1
:prim #x4c
:nreg #x8
)
)
(set! (-> a3-2 regs)
(new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id xyzf2)
:regs2 (gif-reg-id rgbaq)
:regs3 (gif-reg-id xyzf2)
:regs4 (gif-reg-id rgbaq)
:regs5 (gif-reg-id xyzf2)
:regs6 (gif-reg-id rgbaq)
:regs7 (gif-reg-id xyzf2)
)
)
(set! (-> a1-4 base) (&+ (the-as pointer a3-2) 16))
)
;; add the data.
(set! (-> s5-0 vector 1 x) 255)
(set! (-> s5-0 vector 1 y) 128)
(set! (-> s5-0 vector 1 z) 128)
(set! (-> s5-0 vector 1 w) 128)
(+! (-> s5-0 vector 0 y) 160)
(let* ((a1-11 v1-7)
(a3-4 (the-as vector4w-2 (-> a1-11 base)))
)
(set! (-> a3-4 quad 0) (-> (&-> s5-0 quad 1) 0))
(set! (-> a3-4 quad 1) (-> s5-0 quad 0))
(set! (-> a1-11 base) (&+ (the-as pointer a3-4) 32))
)
(+! (-> s5-0 vector 0 x) -256)
(+! (-> s5-0 vector 0 y) -160)
(set! (-> s5-0 vector 1 x) 128)
(set! (-> s5-0 vector 1 y) 255)
(let* ((a1-18 v1-7)
(a3-6 (the-as vector4w-2 (-> a1-18 base)))
)
(set! (-> a3-6 quad 0) (-> (&-> s5-0 quad 1) 0))
(set! (-> a3-6 quad 1) (-> s5-0 quad 0))
(set! (-> a1-18 base) (&+ (the-as pointer a3-6) 32))
)
(+! (-> s5-0 vector 0 x) 512)
(set! (-> s5-0 vector 1 y) 128)
(set! (-> s5-0 vector 1 z) 255)
(let* ((a1-23 v1-7)
(a3-8 (the-as vector4w-2 (-> a1-23 base)))
)
(set! (-> a3-8 quad 0) (-> (&-> s5-0 quad 1) 0))
(set! (-> a3-8 quad 1) (-> s5-0 quad 0))
(set! (-> a1-23 base) (&+ (the-as pointer a3-8) 32))
)
(+! (-> s5-0 vector 0 x) -256)
(+! (-> s5-0 vector 0 y) -160)
(set! (-> s5-0 vector 1 x) 255)
(set! (-> s5-0 vector 1 y) 128)
(let* ((a3-10 v1-7)
(a1-30 (the-as vector4w-2 (-> a3-10 base)))
)
(set! (-> a1-30 quad 0) (-> (&-> s5-0 quad 1) 0))
(set! (-> a1-30 quad 1) (-> s5-0 quad 0))
(set! (-> a3-10 base) (&+ (the-as pointer a1-30) 32))
)
;; update the lengths
(let ((a3-14 (/ (the-as int (+ (&- (the-as pointer -16) (the-as uint a0-6)) (the-as int (-> v1-7 base)))) 16)))
(cond
((nonzero? a3-14)
(logior! (-> a0-6 0) (shr (shl a3-14 48) 48))
(logior! (-> a0-6 1) (shl (shr (shl a3-14 48) 48) 32))
)
(else
(set! (-> v1-7 base) a0-6)
)
)
)
)
;; add to bucket
(let ((a3-20 (-> v1-7 base)))
(let ((a0-7 (the-as dma-packet (-> v1-7 base))))
(set! (-> a0-7 dma) (new 'static 'dma-tag :id (dma-tag-id next)))
(set! (-> a0-7 vif0) (new 'static 'vif-tag))
(set! (-> a0-7 vif1) (new 'static 'vif-tag))
(set! (-> v1-7 base) (&+ (the-as pointer a0-7) 16))
)
(dma-bucket-insert-tag
(-> *display* frames (-> *display* on-screen) frame bucket-group)
bucket
a2-1
(the-as (pointer dma-tag) a3-20)
) )
(let ((a0-6 (the-as (pointer uint64) (-> v1-7 base))))
(let* ((a1-3 v1-7)
(a3-0 (the-as dma-packet (-> a1-3 base)))
)
(set! (-> a3-0 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> a3-0 vif0) (new 'static 'vif-tag))
(set!
(-> a3-0 vif1)
(new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1)
)
(set! (-> a1-3 base) (&+ (the-as pointer a3-0) 16))
)
(let* ((a1-4 v1-7)
(a3-2 (the-as gs-gif-tag (-> a1-4 base)))
)
(set!
(-> a3-2 tag)
(new 'static 'gif-tag64
:nloop #x1
:eop #x1
:pre #x1
:prim #x4c
:nreg #x8
)
)
(set!
(-> a3-2 regs)
(new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id xyzf2)
:regs2 (gif-reg-id rgbaq)
:regs3 (gif-reg-id xyzf2)
:regs4 (gif-reg-id rgbaq)
:regs5 (gif-reg-id xyzf2)
:regs6 (gif-reg-id rgbaq)
:regs7 (gif-reg-id xyzf2)
)
)
(set! (-> a1-4 base) (&+ (the-as pointer a3-2) 16))
)
(set! (-> s5-0 vector 1 x) 255)
(set! (-> s5-0 vector 1 y) 128)
(set! (-> s5-0 vector 1 z) 128)
(set! (-> s5-0 vector 1 w) 128)
(set! (-> s5-0 vector 0 y) (+ (-> s5-0 vector 0 y) 160))
(let* ((a1-11 v1-7)
(a3-4 (the-as vector4w-2 (-> a1-11 base)))
)
(set! (-> a3-4 quad 0) (-> (&-> s5-0 quad 1) 0))
(set! (-> a3-4 quad 1) (-> s5-0 quad 0))
(set! (-> a1-11 base) (&+ (the-as pointer a3-4) 32))
)
(set! (-> s5-0 vector 0 x) (+ (-> s5-0 vector 0 x) -256))
(set! (-> s5-0 vector 0 y) (+ (-> s5-0 vector 0 y) -160))
(set! (-> s5-0 vector 1 x) 128)
(set! (-> s5-0 vector 1 y) 255)
(let* ((a1-18 v1-7)
(a3-6 (the-as vector4w-2 (-> a1-18 base)))
)
(set! (-> a3-6 quad 0) (-> (&-> s5-0 quad 1) 0))
(set! (-> a3-6 quad 1) (-> s5-0 quad 0))
(set! (-> a1-18 base) (&+ (the-as pointer a3-6) 32))
)
(set! (-> s5-0 vector 0 x) (+ (-> s5-0 vector 0 x) 512))
(set! (-> s5-0 vector 1 y) 128)
(set! (-> s5-0 vector 1 z) 255)
(let* ((a1-23 v1-7)
(a3-8 (the-as vector4w-2 (-> a1-23 base)))
)
(set! (-> a3-8 quad 0) (-> (&-> s5-0 quad 1) 0))
(set! (-> a3-8 quad 1) (-> s5-0 quad 0))
(set! (-> a1-23 base) (&+ (the-as pointer a3-8) 32))
)
(set! (-> s5-0 vector 0 x) (+ (-> s5-0 vector 0 x) -256))
(set! (-> s5-0 vector 0 y) (+ (-> s5-0 vector 0 y) -160))
(set! (-> s5-0 vector 1 x) 255)
(set! (-> s5-0 vector 1 y) 128)
(let* ((a3-10 v1-7)
(a1-30 (the-as vector4w-2 (-> a3-10 base)))
)
(set! (-> a1-30 quad 0) (-> (&-> s5-0 quad 1) 0))
(set! (-> a1-30 quad 1) (-> s5-0 quad 0))
(set! (-> a3-10 base) (&+ (the-as pointer a1-30) 32))
)
(let ((a3-14 (/ (the-as int (+ (&- (the-as pointer -16) (the-as uint a0-6)) (the-as int (-> v1-7 base)))) 16)))
(cond
((nonzero? a3-14)
(set!
(-> a0-6 0)
(logior (-> a0-6 0) (the-as uint (shr (shl a3-14 48) 48)))
) )
(set!
(-> a0-6 1)
(logior (-> a0-6 1) (the-as uint (shl (shr (shl a3-14 48) 48) 32)))
)
)
(else
(set! (-> v1-7 base) a0-6)
)
) )
)
) )
(let ((a3-20 (-> v1-7 base)))
(let ((a0-7 (the-as dma-packet (-> v1-7 base))))
(set! (-> a0-7 dma) (new 'static 'dma-tag :id (dma-tag-id next)))
(set! (-> a0-7 vif0) (new 'static 'vif-tag))
(set! (-> a0-7 vif1) (new 'static 'vif-tag))
(set! (-> v1-7 base) (&+ (the-as pointer a0-7) 16))
)
(dma-bucket-insert-tag
(-> *display* frames (-> *display* on-screen) frame bucket-group)
arg1
a2-1
(the-as (pointer dma-tag) a3-20)
)
)
)
) )
)
#f #f
) )
(defun-debug internal-draw-debug-line ((arg0 bucket-id) (arg1 vector) (arg2 vector) (arg3 rgba) (arg4 symbol) (arg5 rgba)) (defun-debug internal-draw-debug-line ((arg0 bucket-id) (arg1 vector) (arg2 vector) (arg3 rgba) (arg4 symbol) (arg5 rgba))
(local-vars (sv-80 vector)) (local-vars (sv-80 vector))
(set! sv-80 arg2) (set! sv-80 arg2)
@ -214,8 +224,8 @@
int int
(when (when
(and (and
(transform-point-qword! (the-as vector (-> s4-0 quad)) arg1) (transform-point-qword! (the-as vector4w (-> s4-0 quad)) arg1)
(transform-point-qword! (the-as vector (&-> s4-0 quad 1)) sv-80) (transform-point-qword! (the-as vector4w (&-> s4-0 quad 1)) sv-80)
) )
(let* (let*
((v1-28 (-> *display* frames (-> *display* on-screen) frame debug-buf)) ((v1-28 (-> *display* frames (-> *display* on-screen) frame debug-buf))
@ -389,7 +399,7 @@
(defun-debug internal-draw-debug-text-3d ((arg0 bucket-id) (arg1 string) (arg2 vector) (arg3 rgba) (arg4 vector2h)) (defun-debug internal-draw-debug-text-3d ((arg0 bucket-id) (arg1 string) (arg2 vector) (arg3 rgba) (arg4 vector2h))
(let ((s2-0 (new 'stack-no-clear 'vector4w))) (let ((s2-0 (new 'stack-no-clear 'vector4w)))
(set! (-> s2-0 quad) (the-as uint128 0)) (set! (-> s2-0 quad) (the-as uint128 0))
(when (transform-point-qword! (the-as vector s2-0) arg2) (when (transform-point-qword! (the-as vector4w s2-0) arg2)
(let* ((s3-0 (-> *display* frames (-> *display* on-screen) frame debug-buf)) (let* ((s3-0 (-> *display* frames (-> *display* on-screen) frame debug-buf))
(s5-0 (-> s3-0 base)) (s5-0 (-> s3-0 base))
) )
@ -514,9 +524,9 @@
(set! (-> arg4 w) 1.0) (set! (-> arg4 w) 1.0)
(when (when
(and (and
(transform-point-qword! (the-as vector (-> s5-0 quad)) arg2) (transform-point-qword! (the-as vector4w (-> s5-0 quad)) arg2)
(transform-point-qword! (the-as vector (&-> s5-0 quad 1)) arg3) (transform-point-qword! (the-as vector4w (&-> s5-0 quad 1)) arg3)
(transform-point-qword! (the-as vector (&-> s5-0 quad 2)) arg4) (transform-point-qword! (the-as vector4w (&-> s5-0 quad 2)) arg4)
) )
(let* ((v1-9 (-> *display* frames (-> *display* on-screen) frame debug-buf)) (let* ((v1-9 (-> *display* frames (-> *display* on-screen) frame debug-buf))
(a2-1 (-> v1-9 base)) (a2-1 (-> v1-9 base))

View file

@ -245,6 +245,7 @@
(water-tex1 60) (water-tex1 60)
;; merc1 61 ;; merc1 61
;; generic1 62 ;; generic1 62
(depth-cue 64)
(bucket-65 65) (bucket-65 65)
(sprite 66) (sprite 66)
;; debug spheres? 67 ;; debug spheres? 67

View file

@ -5,3 +5,4 @@
;; name in dgo: merc-vu1 ;; name in dgo: merc-vu1
;; dgos: GAME, ENGINE ;; dgos: GAME, ENGINE
;; all this contains is the merc-vu1-block

View file

@ -180,10 +180,16 @@
) )
;; I believe this is used for the group 0's in 2d ;; I believe this is used for the group 0's in 2d
;; TODO prim.
(set! (-> data sprite-2d-giftag tag) (set! (-> data sprite-2d-giftag tag)
(new 'static 'gif-tag64 :nloop #x1 :eop #x1 :pre #x1 :prim #x75 :nreg #x9) (new 'static 'gif-tag64
) :nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1 :fge #x1 :abe #x1)
:nreg #x9
)
)
(set! (-> data sprite-2d-giftag regs) (set! (-> data sprite-2d-giftag regs)
(new 'static 'gif-tag-regs (new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq) :regs0 (gif-reg-id rgbaq)
@ -201,8 +207,13 @@
;; group 1's in 2d ;; group 1's in 2d
(set! (-> data sprite-2d-giftag-2 tag) (set! (-> data sprite-2d-giftag-2 tag)
(new 'static 'gif-tag64 :nloop #x1 :eop #x1 :pre #x1 :prim #x55 :nreg #x9) (new 'static 'gif-tag64
) :nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1 :abe #x1)
:nreg #x9)
)
(set! (-> data sprite-2d-giftag-2 regs) (set! (-> data sprite-2d-giftag-2 regs)
(new 'static 'gif-tag-regs (new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq) :regs0 (gif-reg-id rgbaq)
@ -219,8 +230,15 @@
;; 3d's don't have different groups? ;; 3d's don't have different groups?
(set! (-> data sprite-3d-giftag tag) (set! (-> data sprite-3d-giftag tag)
(new 'static 'gif-tag64 :nloop #x1 :eop #x1 :pre #x1 :prim #x75 :nreg #xc) (new 'static 'gif-tag64
) :nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1 :fge #x1 :abe #x1)
:nreg #xc
)
)
;; note that we have rgbaq's per vertex in 3d ;; note that we have rgbaq's per vertex in 3d
(set! (-> data sprite-3d-giftag regs) (set! (-> data sprite-3d-giftag regs)
(new 'static 'gif-tag-regs (new 'static 'gif-tag-regs
@ -241,10 +259,16 @@
;; ?? ;; ??
(set! (-> data clipped-giftag tag) (set! (-> data clipped-giftag tag)
(new 'static 'gif-tag64 :nloop #x1 :eop #x1 :pre #x1 :prim #x75 :nreg #x3) (new 'static 'gif-tag64
) :nloop #x1
(set! :eop #x1
(-> data clipped-giftag regs) :pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1 :fge #x1 :abe #x1)
:nreg #x3
)
)
(set! (-> data clipped-giftag regs)
(new 'static 'gif-tag-regs (new 'static 'gif-tag-regs
:regs0 (gif-reg-id st) :regs0 (gif-reg-id st)
:regs1 (gif-reg-id rgbaq) :regs1 (gif-reg-id rgbaq)
@ -254,8 +278,15 @@
;; not sure what this is either ;; not sure what this is either
(set! (-> data warp-giftag tag) (set! (-> data warp-giftag tag)
(new 'static 'gif-tag64 :nloop #x1 :eop #x1 :pre #x1 :prim #x53 :nreg #xc) (new 'static 'gif-tag64
) :nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri) :tme #x1 :abe #x1)
:nreg #xc
)
)
(set! (-> data warp-giftag regs) (set! (-> data warp-giftag regs)
(new 'static 'gif-tag-regs (new 'static 'gif-tag-regs
:regs0 (gif-reg-id st) :regs0 (gif-reg-id st)

View file

@ -476,7 +476,7 @@
;; WARN: Inline assembly instruction marked with TODO - [TODO.VCLIP] ;; WARN: Inline assembly instruction marked with TODO - [TODO.VCLIP]
;; WARN: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] ;; WARN: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping]
;; WARN: Inline assembly instruction marked with TODO - [TODO.VFTOI4] ;; WARN: Inline assembly instruction marked with TODO - [TODO.VFTOI4]
(defun transform-point-qword! ((arg0 vector) (arg1 vector)) (defun transform-point-qword! ((arg0 vector4w) (arg1 vector))
(local-vars (v1-7 int)) (local-vars (v1-7 int))
(rlet ((acc :class vf) (rlet ((acc :class vf)
(Q :class vf) (Q :class vf)

File diff suppressed because it is too large Load diff

View file

@ -62,6 +62,8 @@ const std::unordered_set<std::string> g_functions_expected_to_reject = {
// display // display
"vblank-handler", // asm "vblank-handler", // asm
"vif1-handler", "vif1-handler-debug", "vif1-handler", "vif1-handler-debug",
// sprite. Don't know types yet.
"add-to-sprite-aux-list",
// ripple - asm // ripple - asm
"ripple-execute-init", "ripple-create-wave-table", "ripple-apply-wave-table", "ripple-execute-init", "ripple-create-wave-table", "ripple-apply-wave-table",
"ripple-matrix-scale", "ripple-matrix-scale",
@ -153,6 +155,9 @@ const std::unordered_set<std::string> g_functions_to_skip_compiling = {
// float to int // float to int
"(method 10 bsp-header)", "(method 10 bsp-header)",
// multiply defined.
"(method 3 sprite-aux-list)",
// loader - decompiler bug with detecting handle macros // loader - decompiler bug with detecting handle macros
"(method 10 external-art-buffer)"}; "(method 10 external-art-buffer)"};