decompile some drawable stuff and fix a few small bugs (#859)

This commit is contained in:
water111 2021-09-28 19:24:09 -04:00 committed by GitHub
parent 56076caa9b
commit 188373a3f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 1641 additions and 166 deletions

View file

@ -281,8 +281,7 @@ Token Reader::get_next_token(TextStream& stream) {
// Second - not a special token, so we read until we get a character that ends the token.
while (stream.text_remains()) {
char next = stream.peek();
if (next == ' ' || next == '\n' || next == '\t' || next == ')' || next == ';' || next == '#' ||
next == '(') {
if (next == ' ' || next == '\n' || next == '\t' || next == ')' || next == ';' || next == '(') {
return t;
} else {
// not the end, so add to token.

View file

@ -266,9 +266,17 @@ void LoadSourceElement::get_modified_regs(RegSet& regs) const {
// SimpleAtomElement
/////////////////////////////
SimpleAtomElement::SimpleAtomElement(const SimpleAtom& atom) : m_atom(atom) {}
SimpleAtomElement::SimpleAtomElement(const SimpleAtom& atom, bool omit_var_cast)
: m_atom(atom), m_omit_var_cast(omit_var_cast) {
if (m_omit_var_cast) {
assert(atom.is_var());
}
}
goos::Object SimpleAtomElement::to_form_internal(const Env& env) const {
if (m_omit_var_cast) {
return m_atom.var().to_form(env, RegisterAccess::Print::AS_VARIABLE_NO_CAST);
}
return m_atom.to_form(env.file->labels, env);
}

View file

@ -293,7 +293,7 @@ class LoadSourceElement : public FormElement {
*/
class SimpleAtomElement : public FormElement {
public:
explicit SimpleAtomElement(const SimpleAtom& var);
explicit SimpleAtomElement(const SimpleAtom& var, bool omit_var_cast = false);
goos::Object to_form_internal(const Env& env) const override;
void apply(const std::function<void(FormElement*)>& f) override;
void apply_form(const std::function<void(Form*)>& f) override;
@ -308,6 +308,7 @@ class SimpleAtomElement : public FormElement {
private:
SimpleAtom m_atom;
bool m_omit_var_cast;
};
/*!

View file

@ -159,6 +159,14 @@ Form* try_cast_simplify(Form* in,
}
}
auto as_atom = form_as_atom(in);
if (as_atom && as_atom->is_var()) {
if (env.get_variable_type(as_atom->var(), true) == new_type) {
// we are a variable with the right type.
return pool.alloc_single_element_form<SimpleAtomElement>(nullptr, *as_atom, true);
}
}
if (tc_pass) {
return in;
} else {
@ -2717,10 +2725,6 @@ void FunctionCallElement::update_from_stack(const Env& env,
auto& var = all_pop_vars.at(arg_id + 1);
if (has_good_types) {
auto actual_arg_type = env.get_types_before_op(var.idx()).get(var.reg()).typespec();
auto val_atom = form_as_atom(val);
if (val_atom && val_atom->is_var()) {
actual_arg_type = env.get_variable_type(val_atom->var(), true);
}
if (arg_id == 0) {
first_arg_type = actual_arg_type;

View file

@ -6080,6 +6080,7 @@
;; - Types
(declare-type ambient-list structure)
(declare-type collide-list structure)
(deftype drawable (basic)
((id int16 :offset-assert 4)
; (unknown basic :offset-assert 8) ;; - from default-menu::build-instance-list
@ -6091,13 +6092,13 @@
(:methods
(login (_type_) _type_ 9) ;; probably login or init.
(draw (_type_ drawable display-frame) none 10) ;; display-frame is from the method inspect tool
(dummy-11 (_type_ int object) none 11) ; int - length, collision related
(dummy-12 (_type_ int object) none 12) ; int - length, collision related
(dummy-13 (_type_ int object) none 13) ; int - length, collision related
(collide-with-box (_type_ int collide-list) none 11)
(collide-y-probe (_type_ int collide-list) none 12)
(collide-ray (_type_ int collide-list) none 13)
(dummy-14 (_type_) none 14)
(dummy-15 (_type_ object object) none 15) ;; something debugging
(dummy-16 (_type_ object object) object 16)
(dummy-17 (_type_ sphere int ambient-list) none 17)
(collect-ambients (_type_ sphere int ambient-list) none 17)
)
)
@ -6158,7 +6159,7 @@
(deftype draw-node (drawable)
((child-count uint8 :offset 6)
(flags uint8 :offset 7)
(child uint32 :offset 8)
(child drawable :offset 8)
(distance float :offset 12)
)
:method-count-assert 18
@ -12222,7 +12223,9 @@
)
(deftype drawable-tree-instance-shrub (drawable-tree)
((info prototype-array-shrub-info :offset 8))
((info prototype-array-shrub-info :offset 8)
(colors-added uint32 :offset 12) ;; added
)
:method-count-assert #x12
:size-assert #x24
:flag-assert #x1200000024
@ -16025,7 +16028,7 @@
(define-extern generic-tie-convert function)
(define-extern generic-tie-display-stats function)
(define-extern generic-tie-debug function)
(define-extern generic-tie-execute function)
(define-extern generic-tie-execute (function generic-dma-foreground-sink dma-buffer basic none))
;; - Unknowns
@ -16227,17 +16230,17 @@
;; - Functions
(define-extern background-upload-vu0 function)
(define-extern time-of-day-interp-colors function)
(define-extern draw-drawable-tree-instance-shrub function)
(define-extern upload-vis-bits function)
(define-extern time-of-day-interp-colors-scratch function)
(define-extern draw-drawable-tree-tfrag function)
(define-extern draw-drawable-tree-trans-tfrag function)
(define-extern draw-drawable-tree-dirt-tfrag function)
(define-extern draw-drawable-tree-ice-tfrag function)
(define-extern tie-near-make-perspective-matrix function)
(define-extern draw-drawable-tree-instance-tie function)
(define-extern background-upload-vu0 (function none))
(define-extern time-of-day-interp-colors (function (pointer rgba) uint mood-context none))
(define-extern draw-drawable-tree-instance-shrub (function drawable-tree-instance-shrub level none))
(define-extern upload-vis-bits (function level level bsp-header none))
(define-extern time-of-day-interp-colors-scratch (function (pointer rgba) time-of-day-palette mood-context none))
(define-extern draw-drawable-tree-tfrag (function drawable-tree-tfrag none))
(define-extern draw-drawable-tree-trans-tfrag (function drawable-tree-trans-tfrag none))
(define-extern draw-drawable-tree-dirt-tfrag (function drawable-tree-dirt-tfrag none))
(define-extern draw-drawable-tree-ice-tfrag (function drawable-tree-ice-tfrag none))
(define-extern tie-near-make-perspective-matrix (function matrix none))
(define-extern draw-drawable-tree-instance-tie (function drawable-tree-instance-tie level none))
(define-extern init-background (function none))
(define-extern finish-background (function none))
@ -16260,8 +16263,8 @@
;; - Functions
(define-extern collide-cache-using-line-sphere-test function)
(define-extern collide-cache-using-y-probe-test function)
(define-extern collide-cache-using-line-sphere-test (function vector symbol))
(define-extern collide-cache-using-y-probe-test (function vector symbol))
(define-extern collide-cache-using-box-test (function vector symbol))
(define-extern draw-node-cull function)

View file

@ -188,7 +188,6 @@
"shadow-calc-dual-verts",
// background
"upload-vis-bits",
"background-upload-vu0",
// draw-node
@ -501,7 +500,8 @@
"(code format-card auto-save)":[3, 4, 5, 6, 7, 8],
"particle-adgif":[0, 1, 2, 3, 4, 5, 7],
"sp-launch-particles-var":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66],
"(method 11 sparticle-launch-control)": [ 27, 28, 35, 46, 48, 49, 77]
"(method 11 sparticle-launch-control)": [ 27, 28, 35, 46, 48, 49, 77],
"upload-vis-bits":[0,1,2,3,4,5, 6]
},
// Sometimes the game might use format strings that are fetched dynamically,

View file

@ -111,6 +111,14 @@
["L27", "vu-function"]
],
"merc-vu1": [
["L1", "vu-function"]
],
"background": [
["L51", "vu-function"]
],
"debug": [
["L179", "vector2h"],
["L176", "(inline-array vector)", 8],

View file

@ -1544,6 +1544,15 @@
[8, "a0", "terrain-bsp"]
],
"upload-vis-bits": [
[[4,16], "a1", "(pointer uint128)"],
[[12, 14], "a0", "(pointer uint128)"],
[[20,22], "a2", "(pointer uint128)"],
[[28, 30], "a0", "(pointer uint128)"],
[[32, 34], "a2", "(pointer uint128)"]
],
"bsp-camera-asm": [
[[4, 14], "a1", "bsp-node"],
[[0, 9], "v1", "bsp-node"],
@ -3206,6 +3215,43 @@
[[73, 82], "v1", "sprite-vec-data-2d"]
],
"finish-background":[
[249, "a0", "terrain-context"],
[297, "a0", "terrain-context"],
[307, "a0", "terrain-context"],
[355, "a0", "terrain-context"],
[365, "a0", "terrain-context"],
[451, "a0", "terrain-context"],
[461, "a0", "terrain-context"],
[32, "a0", "terrain-context"],
[180, "a0", "terrain-context"],
[188, "a0", "terrain-context"],
[199, "a0", "terrain-context"],
[238, "a0", "terrain-context"],
[288, "a0", "terrain-context"],
[346, "a0", "terrain-context"],
[404, "a0", "terrain-context"],
[442, "a0", "terrain-context"],
[531, "a0", "terrain-context"],
[534, "a0", "terrain-context"],
[[598, 603], "v1", "dma-packet"]
],
"(method 11 drawable-inline-array-node)":[
[[1, 6], "v1", "drawable"]
],
"(method 12 drawable-inline-array-node)":[
[[1, 6], "v1", "drawable"]
],
"(method 13 drawable-inline-array-node)":[
[[1, 6], "v1", "drawable"]
],
"(method 17 drawable-inline-array-node)":[
[[1, 6], "v1", "drawable"]
],
"placeholder-do-not-add-below": []
}

View file

@ -3510,5 +3510,14 @@
}
},
"upload-vis-bits": {
"vars": {
"v1-2":"qwc",
"a0-1":["lev-vis-bits", "(pointer uint128)"],
"a1-1":["all-vis", "(pointer uint128)"],
"a2-2":["spad-vis", "(pointer uint128)"]
}
},
"aaaaaaaaaaaaaaaaaaaaaaa": {}
}

View file

@ -425,7 +425,7 @@ goos::Object decompile_sparticle_group_item(const TypeSpec& type,
const TypeSystem& ts,
const LinkedObjectFile* file) {
auto normal = decompile_structure(type, label, labels, words, ts, file, false);
fmt::print("Doing: {}\n", normal.print());
// fmt::print("Doing: {}\n", normal.print());
auto uncast_type_info = ts.lookup_type(type);
auto type_info = dynamic_cast<StructureType*>(uncast_type_info);
if (!type_info) {
@ -504,7 +504,7 @@ goos::Object decompile_sparticle_group_item(const TypeSpec& type,
}
result += ')';
fmt::print("Result: {}\n", result);
// fmt::print("Result: {}\n", result);
return pretty_print::to_symbol(result);
}
@ -515,7 +515,7 @@ goos::Object decompile_sparticle_field_init(const TypeSpec& type,
const TypeSystem& ts,
const LinkedObjectFile* file) {
auto normal = decompile_structure(type, label, labels, words, ts, file, false);
fmt::print("Doing: {}\n", normal.print());
// fmt::print("Doing: {}\n", normal.print());
auto uncast_type_info = ts.lookup_type(type);
auto type_info = dynamic_cast<StructureType*>(uncast_type_info);
if (!type_info) {
@ -593,7 +593,7 @@ goos::Object decompile_sparticle_field_init(const TypeSpec& type,
}
}
fmt::print("Result: {}\n\n", result.print());
// fmt::print("Result: {}\n\n", result.print());
return result;
}
} // namespace decompiler

View file

@ -204,4 +204,5 @@
- Fix a bug where the size of static boxed arrays was only `length` and not `allocated-length`
- It is now possible to call a method on a forward declared type. The forward declared type must be a basic.
- Using `->` on a plain `pointer` or `inline-array` now generates an error instead of crashing the compiler
- It is now possible to use a macro to provide a static inline array element definition
- It is now possible to use a macro to provide a static inline array element definition
- It is now possible to have symbol names that have a `#` in the middle of them

View file

@ -1437,7 +1437,7 @@
;; definition for method 17 of type drawable-ambient
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-17
collect-ambients
drawable-ambient
((obj drawable-ambient) (arg0 sphere) (arg1 int) (arg2 ambient-list))
(dotimes (s2-0 arg1)
@ -1454,14 +1454,19 @@
;; definition for method 17 of type drawable-inline-array-ambient
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-17
collect-ambients
drawable-inline-array-ambient
((obj drawable-inline-array-ambient)
(arg0 sphere)
(arg1 int)
(arg2 ambient-list)
)
(dummy-17 (the-as drawable-ambient (-> obj data)) arg0 (-> obj length) arg2)
(collect-ambients
(the-as drawable-ambient (-> obj data))
arg0
(-> obj length)
arg2
)
0
(none)
)
@ -1469,10 +1474,10 @@
;; definition for method 17 of type drawable-tree-ambient
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-17
collect-ambients
drawable-tree-ambient
((obj drawable-tree-ambient) (arg0 sphere) (arg1 int) (arg2 ambient-list))
(dummy-17 (-> obj data 0) arg0 (-> obj length) arg2)
(collect-ambients (-> obj data 0) arg0 (-> obj length) arg2)
0
(none)
)

View file

@ -165,3 +165,7 @@
(define-perm *collide-work* collide-work (new 'global 'collide-work))
(define-perm *collide-cache* collide-cache (new 'global 'collide-cache))
(define-perm *collide-list* collide-list (new 'global 'collide-list))
(define-extern collide-cache-using-box-test (function vector symbol))
(define-extern collide-cache-using-y-probe-test (function vector symbol))
(define-extern collide-cache-using-line-sphere-test (function vector symbol))

View file

@ -28,39 +28,21 @@
arg1
)
;; definition for method 11 of type drawable-tree-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-11
drawable-tree-collide-fragment
((obj drawable-tree-collide-fragment) (arg0 int) (arg1 object))
(dummy-11 (-> obj data 0) (-> obj length) arg1)
(let ((v0-1 0))
)
(defmethod collide-with-box drawable-tree-collide-fragment ((obj drawable-tree-collide-fragment) (arg0 int) (arg1 collide-list))
"Collide everything in the tree with a box. Length arg doesn't matter here."
(collide-with-box (-> obj data 0) (-> obj length) arg1)
0
(none)
)
;; definition for method 12 of type drawable-tree-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-12
drawable-tree-collide-fragment
((obj drawable-tree-collide-fragment) (arg0 int) (arg1 object))
(dummy-12 (-> obj data 0) (-> obj length) arg1)
(let ((v0-1 0))
)
(defmethod collide-y-probe drawable-tree-collide-fragment ((obj drawable-tree-collide-fragment) (arg0 int) (arg1 collide-list))
(collide-y-probe (-> obj data 0) (-> obj length) arg1)
0
(none)
)
;; definition for method 13 of type drawable-tree-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-13
drawable-tree-collide-fragment
((obj drawable-tree-collide-fragment) (arg0 int) (arg1 object))
(dummy-13 (-> obj data 0) (-> obj length) arg1)
(let ((v0-1 0))
)
(defmethod collide-ray drawable-tree-collide-fragment ((obj drawable-tree-collide-fragment) (arg0 int) (arg1 collide-list))
(collide-ray (-> obj data 0) (-> obj length) arg1)
(none)
)
@ -143,31 +125,24 @@
;; definition for method 11 of type drawable-inline-array-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-11
drawable-inline-array-collide-fragment
((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 object))
(dummy-11 (the-as collide-fragment (-> obj data)) (-> obj length) arg1)
(defmethod collide-with-box drawable-inline-array-collide-fragment ((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 collide-list))
(collide-with-box (the-as collide-fragment (-> obj data)) (-> obj length) arg1)
0
(none)
)
;; definition for method 12 of type drawable-inline-array-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-12
drawable-inline-array-collide-fragment
((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 object))
(dummy-12 (the-as collide-fragment (-> obj data)) (-> obj length) arg1)
(defmethod collide-y-probe drawable-inline-array-collide-fragment ((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 collide-list))
(collide-y-probe (the-as collide-fragment (-> obj data)) (-> obj length) arg1)
0
(none)
)
;; definition for method 13 of type drawable-inline-array-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-13
drawable-inline-array-collide-fragment
((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 object))
(dummy-13 (the-as collide-fragment (-> obj data)) (-> obj length) arg1)
;; INFO: Return type mismatch int vs collide-list.
(defmethod collide-ray drawable-inline-array-collide-fragment ((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 collide-list))
(collide-ray (the-as collide-fragment (-> obj data)) (-> obj length) arg1)
(none)
)

View file

@ -5,10 +5,16 @@
;; name in dgo: draw-node-h
;; dgos: GAME, ENGINE
;; A "draw-node" is a way to group together a bunch of drawables (possibly other draw-nodes)
;; they do not support calling draw, but do support collision.
;; The typical use is to put a bunch of these in an inline array, then call collide on the first,
;; and pass in the length of the inline array. This will collide with all nodes in the list.
;; They are also used as groups for the culling system.
(deftype draw-node (drawable)
((child-count uint8 :offset 6)
((child-count uint8 :offset 6) ;; if our child requires a count
(flags uint8 :offset 7)
(child uint32 :offset 8)
(child drawable :offset 8) ;; can be draw-node or any other drawable
(distance float :offset 12)
)
:method-count-assert 18
@ -17,6 +23,10 @@
;; field distance is a float printed as hex?
)
;; It's annoying to work with draw-node's directly, so drawable-inline-array-node is a nice wrapper
;; that knows the array's length.
(deftype drawable-inline-array-node (drawable-inline-array)
((data draw-node 1 :inline)
(pad uint32)

View file

@ -5,3 +5,128 @@
;; name in dgo: draw-node
;; dgos: GAME, ENGINE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Draw Node Collisions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The collision stuff is a bit weird.
;; The method takes an integer argument. For some types, you must provide a length and calling the method
;; will automatically run on all the brothers of the node. For other types, you don't have to provide a length.
;; The output of the collision are stored in the collide-list that's passed through all the methods.
;; For an unknown reason, the input to the collision query (the box we're colliding with) is not.
;; It's stored in *collide-work*
(defmethod collide-with-box draw-node ((obj draw-node) (arg0 int) (arg1 collide-list))
"Find collisions with the box in the current collision query, add results to collide-list."
;; loop over ourself and our brothers
(dotimes (s3-0 arg0)
(if (collide-cache-using-box-test (-> obj bsphere)) ;; do we collide with the bounding sphere?
;; if so, do the collision check with the geometry.
(collide-with-box (-> obj child) (the-as int (-> obj child-count)) arg1)
)
(&+! obj 32)
)
0
(none)
)
(defmethod collide-y-probe draw-node ((obj draw-node) (arg0 int) (arg1 collide-list))
(dotimes (s3-0 arg0)
(if (collide-cache-using-y-probe-test (-> obj bsphere))
(collide-y-probe (-> obj child) (the-as int (-> obj child-count)) arg1)
)
(&+! obj 32)
)
0
(none)
)
(defmethod collide-ray draw-node ((obj draw-node) (arg0 int) (arg1 collide-list))
(dotimes (s3-0 arg0)
(if (collide-cache-using-line-sphere-test (-> obj bsphere))
(collide-ray (-> obj child) (the-as int (-> obj child-count)) arg1)
)
(&+! obj 32)
)
(none)
)
(defmethod collect-ambients draw-node ((obj draw-node) (arg0 sphere) (arg1 int) (arg2 ambient-list))
(dotimes (s2-0 arg1)
(if (spheres-overlap? arg0 (the-as sphere (-> obj bsphere)))
(collect-ambients (-> obj child) arg0 (the-as int (-> obj child-count)) arg2)
)
(&+! obj 32)
)
0
(none)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Drawable Inline Array Node
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This class is a convenient wrapper around an inline-array of draw-nodes.
;; It lets you treat this array like a normal drawable (at least for collisions).
(defmethod inspect drawable-inline-array-node ((obj drawable-inline-array-node))
"Custom inspect for drawable-inline-array-node to print our nodes."
(format #t "[~8x] ~A~%" obj (-> obj type))
(format #t "~Tlength: ~D~%" (-> obj length))
(format #t "~Tdata[~D]: @ #x~X~%" (-> obj length) (-> obj data))
(dotimes (s5-0 (-> obj length))
(format #t "~T [~D] ~A~%" s5-0 (-> obj data s5-0))
)
obj
)
(defmethod mem-usage drawable-inline-array-node ((obj drawable-inline-array-node) (arg0 memory-usage-block) (arg1 int))
"Compute the memory usage of a drawable-inline-array-node. Only counts the nodes, doesn't count the node children."
(set! (-> arg0 length) (max 62 (-> arg0 length)))
(set! (-> arg0 data 61 name) "draw-node")
(+! (-> arg0 data 61 count) (-> obj length))
(let ((v1-6 (asize-of obj)))
(+! (-> arg0 data 61 used) v1-6)
(+! (-> arg0 data 61 total) (logand -16 (+ v1-6 15)))
)
obj
)
(defmethod asize-of drawable-inline-array-node ((obj drawable-inline-array-node))
(the-as int (+ (-> drawable-inline-array-node size) (* (+ (-> obj length) -1) 32)))
)
(defmethod collide-with-box drawable-inline-array-node ((obj drawable-inline-array-node) (arg0 int) (arg1 collide-list))
;; call on the first in the array, then it will loop through all the brothers.
(collide-with-box (-> obj data 0) (-> obj length) arg1)
0
(none)
)
(defmethod collide-y-probe drawable-inline-array-node ((obj drawable-inline-array-node) (arg0 int) (arg1 collide-list))
(collide-y-probe (-> obj data 0) (-> obj length) arg1)
0
(none)
)
(defmethod collide-ray drawable-inline-array-node ((obj drawable-inline-array-node) (arg0 int) (arg1 collide-list))
(collide-ray (-> obj data 0) (-> obj length) arg1)
(none)
)
(defmethod collect-ambients drawable-inline-array-node ((obj drawable-inline-array-node) (arg0 sphere) (arg1 int) (arg2 ambient-list))
(collect-ambients (-> obj data 0) arg0 (-> obj length) arg2)
0
(none)
)
;;;;;;;;;;;;;;;;;;;;;;;;
;; DRAW NODE CULL
;;;;;;;;;;;;;;;;;;;;;;;;
;; TODO: waiting on tfrag/tie stuff to worry about this.

View file

@ -6,29 +6,38 @@
;; dgos: GAME, ENGINE
(declare-type ambient-list structure)
(declare-type collide-list structure)
;; These are the base classes for the draw nodes in the engine.
;; These is the base class for the scene graph node.
;; Note that it doesn't always make sense to call all of these methods on all types,
;; and that certain methods should only be called at certain times, and may require coordination
;; with having certain VU0 or scratchpad data present.
;; In many cases, "draw" simply adds data to a buffer that must later be converted to dma in finish-background
;; or similar.
(deftype drawable (basic)
((id int16 :offset-assert 4)
(bsphere vector :inline :offset-assert 16)
((id int16 :offset-assert 4) ;; ID number (not always used)
(bsphere vector :inline :offset-assert 16) ;; bounding sphere
)
:method-count-assert 18
:size-assert #x20
:flag-assert #x1200000020
(:methods
(login (_type_) _type_ 9) ;; probably login or init.
(draw (_type_ drawable display-frame) none 10) ;; display-frame is from the method inspect tool
(dummy-11 (_type_ int object) none 11) ; int - length
(dummy-12 (_type_ int object) none 12) ; int - length
(dummy-13 (_type_ int object) none 13) ; int - length
(dummy-14 (_type_) none 14) ;; related to culling?
(login (_type_) _type_ 9)
(draw (_type_ drawable display-frame) none 10)
(collide-with-box (_type_ int collide-list) none 11)
(collide-y-probe (_type_ int collide-list) none 12)
(collide-ray (_type_ int collide-list) none 13)
(dummy-14 (_type_) none 14)
(dummy-15 (_type_ object object) none 15)
(dummy-16 (_type_ object object) object 16)
(dummy-17 (_type_ sphere int ambient-list) none 17)
(collect-ambients (_type_ sphere int ambient-list) none 17)
)
)
;; A drawable that simply draws a sphere and an error message at the origin of the bounding sphere.
(deftype drawable-error (drawable)
((name basic :offset-assert 32)
)

View file

@ -60,7 +60,17 @@
)
(set! (-> (the-as vol-control gp-0) process) arg0)
(let* ((s5-1 (the-as res-lump (-> (the-as vol-control gp-0) process entity)))
(s4-0 (-> (lookup-tag-idx (the-as entity s5-1) 'vol 'exact 0.0) lo))
(s4-0
(->
((method-of-type res-lump lookup-tag-idx)
(the-as entity s5-1)
'vol
'exact
0.0
)
lo
)
)
)
(when (>= (the-as int s4-0) 0)
(let ((s3-0 (the-as uint s4-0))
@ -97,7 +107,15 @@
)
(let* ((s5-2 (the-as res-lump (-> (the-as vol-control gp-0) process entity)))
(s4-1
(-> (lookup-tag-idx (the-as entity s5-2) 'cutoutvol 'exact 0.0) lo)
(->
((method-of-type res-lump lookup-tag-idx)
(the-as entity s5-2)
'cutoutvol
'exact
0.0
)
lo
)
)
)
(when (>= (the-as int s4-1) 0)

View file

@ -5,3 +5,509 @@
;; name in dgo: background
;; dgos: GAME, ENGINE
;; The "background" is a collection of renderers.
;; The recursive draw call through the drawable trees will add drawables to various lists.
;; After this, (finish-background) is called to finalize DMA lists.
(define *background-work* (new 'global 'background-work))
(defun background-upload-vu0 ()
"Set up VU0 for background."
;; We set up VU0 with some code and data.
;; It looks like the intended use is to be able to do something like
;; vcallms <x>, and then some point stored in a vf register will be transformed.
;; But I honestly
;; would upload to vu0 program memory
;; (upload-vu-program background-vu0-block (&-> *background-work* wait-to-vu0))
;; set up math-camera registers:
(let ((at-0 *math-camera*))
(with-vf (vf16 vf17 vf18 vf19 vf20 vf21 vf22 vf23 vf24 vf25 vf26 vf27 vf28 vf29 vf30 vf31)
:rw 'write
(.lvf vf16 (&-> at-0 plane 0 quad))
(.lvf vf17 (&-> at-0 plane 1 quad))
(.lvf vf18 (&-> at-0 plane 2 quad))
(.lvf vf19 (&-> at-0 plane 3 quad))
(.lvf vf20 (&-> at-0 shrub-mat vector 0 quad))
(.lvf vf21 (&-> at-0 shrub-mat vector 1 quad))
(.lvf vf22 (&-> at-0 shrub-mat vector 2 quad))
(.lvf vf23 (&-> at-0 shrub-mat vector 3 quad))
(.lvf vf24 (&-> at-0 camera-rot vector 0 quad))
(.lvf vf25 (&-> at-0 camera-rot vector 1 quad))
(.lvf vf26 (&-> at-0 camera-rot vector 2 quad))
(.lvf vf27 (&-> at-0 camera-rot vector 3 quad))
(.lvf vf28 (&-> at-0 camera-temp vector 0 quad))
(.lvf vf29 (&-> at-0 camera-temp vector 1 quad))
(.lvf vf30 (&-> at-0 camera-temp vector 2 quad))
(.lvf vf31 (&-> at-0 camera-temp vector 3 quad))
)
)
;; here there would be a loop that waits for VIF0 DMA to be complete.
;; now a vcallms 0. TODO: this will store all of the above data. But camera-rot premultiplies all values by z's.
;; It's used in shrubbery (at least).
;; I suspect it will be easier to modify specific renderers than to try to implement this in a general way.
;; (but this is likely still a good spot to set things up.)
)
(defun init-background ()
"Initialize the global *background-work*"
(dotimes (v1-0 8)
(set! (-> *background-work* tfrag-trees v1-0) #f)
(set! (-> *background-work* trans-tfrag-trees v1-0) #f)
(set! (-> *background-work* dirt-tfrag-trees v1-0) #f)
(set! (-> *background-work* ice-tfrag-trees v1-0) #f)
(set! (-> *background-work* lowres-tfrag-trees v1-0) #f)
(set! (-> *background-work* lowres-trans-tfrag-trees v1-0) #f)
)
(set! (-> *background-work* tfrag-tree-count) 0)
(set! (-> *background-work* trans-tfrag-tree-count) 0)
(set! (-> *background-work* dirt-tfrag-tree-count) 0)
(set! (-> *background-work* ice-tfrag-tree-count) 0)
(set! (-> *background-work* lowres-tfrag-tree-count) 0)
(set! (-> *background-work* lowres-trans-tfrag-tree-count) 0)
(set! (-> *background-work* shrub-tree-count) 0)
(set! (-> *background-work* tie-tree-count) 0)
(set! (-> *background-work* wait-to-vu0) (the-as uint 0))
0
(none)
)
(defun upload-vis-bits ((arg0 level) (arg1 level) (arg2 bsp-header))
"Upload visibility data to the scratchpad."
(let ((qwc (/ (+ (-> arg2 visible-list-length) 15) 16)))
(let ((lev-vis-bits (the-as (pointer uint128) (-> arg0 vis-bits)))
(all-vis (the-as (pointer uint128) (-> arg2 all-visible-list)))
;;(spad-vis (the-as (pointer uint128) (+ #x38b0 #x70000000)))
(spad-vis (scratchpad-ptr uint128 :offset VISIBLE_LIST_SCRATCHPAD))
)
(b! (not *artist-flip-visible*) cfg-5 :delay (nop!))
(nop!)
(nop!)
(label cfg-2)
;; flip visible is selected. unfortunately this code is wrong and uses a 64-bit xor.
(let ((a3-2 (-> lev-vis-bits 0)))
(set! lev-vis-bits (&-> lev-vis-bits 1))
(let ((t0-0 (-> all-vis 0)))
(set! all-vis (&-> all-vis 1))
(nop!)
(nop!)
;; xor with all visible to flip the bits of the things that exist.
(let ((a3-3 (logxor a3-2 (the-as uint t0-0))))
(+! qwc -1)
(set! (-> spad-vis 0) a3-3)
)
)
)
(set! spad-vis (&-> spad-vis 1))
(b! (> qwc 0) cfg-2 :delay (nop!))
0
(b! #t cfg-8 :delay (nop!))
;; flip visible isn't selected, just copy to scratchpad.
(nop!)
(label cfg-5)
(nop!)
(nop!)
(label cfg-6)
(let ((a1-2 (-> lev-vis-bits 0)))
(set! lev-vis-bits (&-> lev-vis-bits 1))
(nop!)
(+! qwc -1)
(set! (-> spad-vis 0) a1-2)
)
(set! spad-vis (&-> spad-vis 1))
)
(b! (> qwc 0) cfg-6 :delay (nop!))
)
0
(label cfg-8)
(none)
)
(defun finish-background ()
"Complete the background drawing.
This function should run after the background engine has executed.
"
;; set up common VU0 stuff for background.
(background-upload-vu0)
;;;;;;;;;;;;;;;;
;; shrubbery
;;;;;;;;;;;;;;;;
(set! (-> *instance-shrub-work* paused) (paused?))
(when (nonzero? (-> *background-work* shrub-tree-count))
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x40 :b #x40 :a #x80)
)
)
;; iterate over all drawable trees
(dotimes (gp-0 (-> *background-work* shrub-tree-count))
;; update the level index in the scratchpad
(set! (-> (scratchpad-object terrain-context) bsp lev-index) (-> *background-work* shrub-levels gp-0 index))
(flush-cache 0)
(let ((s5-0 (-> *background-work* shrub-trees gp-0))
(s4-0 (-> *background-work* shrub-levels gp-0))
)
;; setup colors for shrub
(if (nonzero? (-> s5-0 colors-added))
(time-of-day-interp-colors
(-> *instance-shrub-work* colors)
(-> s5-0 colors-added)
(-> s4-0 mood)
)
)
;; and draw!
(draw-drawable-tree-instance-shrub s5-0 s4-0)
)
)
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x40 :g #x60 :b #x80 :a #x80)
)
)
)
(let ((gp-1 (the-as level #f)))
(when (or (nonzero? (-> *background-work* tfrag-tree-count))
(nonzero? (-> *background-work* trans-tfrag-tree-count))
(nonzero? (-> *background-work* dirt-tfrag-tree-count))
(nonzero? (-> *background-work* ice-tfrag-tree-count))
(nonzero? (-> *background-work* lowres-tfrag-tree-count))
(nonzero? (-> *background-work* lowres-trans-tfrag-tree-count))
)
;; setup the vf's for transformation again (not sure why we don't use the VU0 program...)
(let ((v1-48 *math-camera*))
(with-vf (vf16 vf17 vf18 vf19 vf20 vf21 vf22 vf23 vf24 vf25 vf26 vf27 vf28 vf29 vf30 vf31)
:rw 'write
(.lvf vf16 (&-> v1-48 plane 0 quad))
(.lvf vf17 (&-> v1-48 plane 1 quad))
(.lvf vf18 (&-> v1-48 plane 2 quad))
(.lvf vf19 (&-> v1-48 plane 3 quad))
(.lvf vf20 (&-> v1-48 shrub-mat vector 0 quad))
(.lvf vf21 (&-> v1-48 shrub-mat vector 1 quad))
(.lvf vf22 (&-> v1-48 shrub-mat vector 2 quad))
(.lvf vf23 (&-> v1-48 shrub-mat vector 3 quad))
(.lvf vf24 (&-> v1-48 camera-rot vector 0 quad))
(.lvf vf25 (&-> v1-48 camera-rot vector 1 quad))
(.lvf vf26 (&-> v1-48 camera-rot vector 2 quad))
(.lvf vf27 (&-> v1-48 camera-rot vector 3 quad))
(.lvf vf28 (&-> v1-48 camera-temp vector 0 quad))
(.lvf vf29 (&-> v1-48 camera-temp vector 1 quad))
(.lvf vf30 (&-> v1-48 camera-temp vector 2 quad))
(.lvf vf31 (&-> v1-48 camera-temp vector 3 quad))
(.lvf vf31 (&-> v1-48 camera-temp vector 3 quad))
)
)
;; TFRAG
(let* ((v1-52 (max (-> *background-work* tfrag-tree-count) (-> *background-work* trans-tfrag-tree-count)))
(s4-1 (the-as time-of-day-palette #f))
(s5-2 (max (max v1-52
(-> *background-work* lowres-tfrag-tree-count))
(-> *background-work* lowres-trans-tfrag-tree-count)
)
)
)
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x40 :b #x40 :a #x80)
)
)
;; loop over all tfrag trees
(dotimes (s3-0 s5-2)
;;;;;;;;;;;;;; Normal TFRAG
(let ((s2-0 (-> *background-work* tfrag-trees s3-0)))
(when s2-0
(let ((s1-0 (-> *background-work* tfrag-levels s3-0)))
(let ((a2-4 (-> s1-0 bsp))
(s0-0 (-> s2-0 time-of-day-pal))
)
;; load visibility data
(upload-vis-bits s1-0 gp-1 a2-4)
;; update colors, but only if needed
(when (not (or (zero? s0-0) (= s4-1 s0-0)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as (pointer rgba)
(+ 6160 (the-as int (the-as terrain-context #x70000000)))
)
s0-0
(-> s1-0 mood)
)
;; remember the previous colors
(set! s4-1 s0-0)
)
)
;; set the level.
(set! (-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-0 index)
)
)
(set! (-> *tfrag-work* min-dist z) 4095996000.0)
;; draw!
(draw-drawable-tree-tfrag s2-0)
;; remember closest.
(set! (-> *level* level (-> (the-as terrain-context #x70000000) bsp lev-index) closest-object 0)
(-> *tfrag-work* min-dist z)
)
)
)
;;;;;;;;;;;;;; Trans TFRAG
(let ((s2-1 (-> *background-work* trans-tfrag-trees s3-0)))
(when s2-1
(let ((s1-1 (-> *background-work* trans-tfrag-levels s3-0)))
(let ((a2-6 (-> s1-1 bsp))
(s0-1 (-> s2-1 time-of-day-pal))
)
(upload-vis-bits s1-1 gp-1 a2-6)
(when (not (or (zero? s0-1) (= s4-1 s0-1)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as (pointer rgba) (+ 6160 #x70000000))
s0-1
(-> s1-1 mood)
)
(set! s4-1 s0-1)
)
)
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-1 index)
)
)
(set! (-> *tfrag-work* min-dist z) 4095996000.0)
(draw-drawable-tree-trans-tfrag s2-1)
(set! (-> *level* level (-> (the-as terrain-context #x70000000) bsp lev-index) closest-object 3)
(-> *tfrag-work* min-dist z)
)
)
)
;;;;;;;;;;;;;; DIRT TFRAG
(let ((s2-2 (-> *background-work* dirt-tfrag-trees s3-0)))
(when s2-2
(let ((s1-2 (-> *background-work* dirt-tfrag-levels s3-0)))
(let ((a2-8 (-> s1-2 bsp))
(s0-2 (-> s2-2 time-of-day-pal))
)
(upload-vis-bits s1-2 gp-1 a2-8)
(when (not (or (zero? s0-2) (= s4-1 s0-2)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as (pointer rgba) (+ 6160 #x70000000))
s0-2
(-> s1-2 mood)
)
(set! s4-1 s0-2)
)
)
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-2 index)
)
)
(set! (-> *tfrag-work* min-dist z) 4095996000.0)
(draw-drawable-tree-dirt-tfrag s2-2)
(set! (-> *level* level (-> (the-as terrain-context #x70000000) bsp lev-index) closest-object 3)
(fmin
(-> *level* level (-> (the-as terrain-context #x70000000) bsp lev-index) closest-object 3)
(-> *tfrag-work* min-dist z)
)
)
)
)
;;;;;;;;;;;;;; ICE TFRAG
(let ((s2-3 (-> *background-work* ice-tfrag-trees s3-0)))
(when s2-3
(let ((s1-3 (-> *background-work* ice-tfrag-levels s3-0)))
(let ((a2-10 (-> s1-3 bsp))
(s0-3 (-> s2-3 time-of-day-pal))
)
(upload-vis-bits s1-3 gp-1 a2-10)
(when (not (or (zero? s0-3) (= s4-1 s0-3)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as (pointer rgba) (+ 6160 #x70000000))
s0-3
(-> s1-3 mood)
)
(set! s4-1 s0-3)
)
)
(set! (-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-3 index)
)
)
(set! (-> *tfrag-work* min-dist z) 4095996000.0)
(draw-drawable-tree-ice-tfrag s2-3)
(set! (-> *level* level (-> (the-as terrain-context #x70000000) bsp lev-index) closest-object 3)
(fmin
(-> *level* level (-> (the-as terrain-context #x70000000) bsp lev-index) closest-object 3)
(-> *tfrag-work* min-dist z)
)
)
)
)
;;;;;;;;;;;;;; LOWRES TFRAG
(let ((s2-4 (-> *background-work* lowres-tfrag-trees s3-0)))
(when s2-4
(let ((s1-4 (-> *background-work* lowres-tfrag-levels s3-0)))
(let ((a2-12 (-> s1-4 bsp))
(s0-4 (-> s2-4 time-of-day-pal))
)
(upload-vis-bits s1-4 gp-1 a2-12)
(when (not (or (zero? s0-4) (= s4-1 s0-4)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as (pointer rgba) (+ 6160 #x70000000))
s0-4
(-> s1-4 mood)
)
(set! s4-1 s0-4)
)
)
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-4 index)
)
)
(draw-drawable-tree-tfrag s2-4)
)
)
;;;;;;;;;;;;;; LOWRES TRANS TFRAG
(let ((s2-5 (-> *background-work* lowres-trans-tfrag-trees s3-0)))
(when s2-5
(let ((s1-5 (-> *background-work* lowres-trans-tfrag-levels s3-0)))
(let ((a2-14 (-> s1-5 bsp))
(s0-5 (-> s2-5 time-of-day-pal))
)
(upload-vis-bits s1-5 gp-1 a2-14)
(when (not (or (zero? s0-5) (= s4-1 s0-5)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as (pointer rgba) (+ 6160 #x70000000))
s0-5
(-> s1-5 mood)
)
(set! s4-1 s0-5)
)
)
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-5 index)
)
)
(set! (-> *tfrag-work* min-dist z) 4095996000.0)
(draw-drawable-tree-trans-tfrag s2-5)
(set! (-> *level* level (-> (the-as terrain-context #x70000000) bsp lev-index) closest-object 3)
(fmin
(-> *level* level (-> (the-as terrain-context #x70000000) bsp lev-index) closest-object 3)
(-> *tfrag-work* min-dist z)
)
)
)
)
)
)
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x40 :g #x80 :b #x60 :a #x80)
)
)
)
;;;;;;;;;; TIE (TFRAG Instance Engine)
;; common setup
(set! (-> *instance-tie-work* paused) (paused?))
(when (nonzero? (-> *background-work* tie-tree-count))
(tie-near-make-perspective-matrix
(-> *instance-tie-work* tie-near-perspective-matrix)
)
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x40 :b #x40 :a #x80)
)
)
;;;;;;;;;; Normal TIE
(dotimes (s5-3 (-> *background-work* tie-tree-count))
(let ((s4-2 (-> *background-work* tie-levels s5-3)))
(let ((a2-18 (-> s4-2 bsp)))
(when (!= s4-2 gp-1)
(set! (-> *instance-tie-work* min-dist x) 4095996000.0)
(upload-vis-bits s4-2 gp-1 a2-18)
(set! gp-1 s4-2)
)
)
(set! (-> (the-as terrain-context #x70000000) bsp lev-index) (-> s4-2 index))
(set! (-> (the-as terrain-context #x70000000) bsp mood) (-> s4-2 mood))
(draw-drawable-tree-instance-tie (-> *background-work* tie-trees s5-3) s4-2)
)
;; todo, type here probably wrong.
(set! (-> *background-work* tie-generic s5-3)
(the-as basic (-> *instance-tie-work* first-generic-prototype))
)
)
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x80 :g #x20 :b #x60 :a #x80)
)
)
;; TIE Generic
(dotimes (gp-2 (-> *background-work* tie-tree-count))
(when (nonzero? (-> *background-work* tie-generic gp-2))
(let* ((s5-4 (-> *background-work* tie-levels gp-2 foreground-sink-group 0 generic-sink))
(s3-1 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s4-3 (-> s3-1 base))
)
(generic-tie-execute s5-4 s3-1 (-> *background-work* tie-generic gp-2))
(let ((a3-0 (-> s3-1 base)))
(let ((v1-219 (the-as object (-> s3-1 base))))
(set! (-> (the-as dma-packet v1-219) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
(set! (-> (the-as dma-packet v1-219) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet v1-219) vif1) (new 'static 'vif-tag))
(set! (-> s3-1 base) (&+ (the-as pointer v1-219) 16))
)
(dma-bucket-insert-tag
(-> *display* frames (-> *display* on-screen) frame bucket-group)
(-> s5-4 bucket)
s4-3
(the-as (pointer dma-tag) a3-0)
)
)
)
)
)
)
)
0
(none)
)

View file

@ -6,5 +6,4 @@
;; dgos: GAME, ENGINE
;; all this contains is the merc-vu1-block
(define merc-vu1-block (the vu-function 0))
(define merc-vu1-block (new 'static 'vu-function))

View file

@ -69,7 +69,9 @@
)
(deftype drawable-tree-instance-shrub (drawable-tree)
((info prototype-array-shrub-info :offset 8))
((info prototype-array-shrub-info :offset 8)
(colors-added uint32 :offset 12) ;; added
)
:method-count-assert #x12
:size-assert #x24
:flag-assert #x1200000024
@ -269,3 +271,6 @@
:flag-assert #x9000038a0
)
(define-extern *instance-shrub-work* instance-shrub-work)
(define-extern draw-drawable-tree-instance-shrub (function drawable-tree-instance-shrub level none))

View file

@ -252,4 +252,9 @@
:flag-assert #x9000037fc
)
(define-extern *tfrag-work* tfrag-work)
(define-extern *tfrag-work* tfrag-work)
(define-extern draw-drawable-tree-tfrag (function drawable-tree-tfrag none))
(define-extern draw-drawable-tree-trans-tfrag (function drawable-tree-trans-tfrag none))
(define-extern draw-drawable-tree-dirt-tfrag (function drawable-tree-dirt-tfrag none))
(define-extern draw-drawable-tree-ice-tfrag (function drawable-tree-ice-tfrag none))

View file

@ -230,3 +230,5 @@
:size-assert #x1d50
:flag-assert #x900001d50
)
(define-extern generic-tie-execute (function generic-dma-foreground-sink dma-buffer basic none))

View file

@ -178,3 +178,6 @@
;; probably a more specific type.
(define *instance-tie-work-copy* (the-as instance-tie-work #f))
(define-extern *instance-tie-work* instance-tie-work)
(define-extern tie-near-make-perspective-matrix (function matrix none))
(define-extern draw-drawable-tree-instance-tie (function drawable-tree-instance-tie level none))

View file

@ -114,3 +114,5 @@
;; TODO for mood
(define-extern *time-of-day-proc* (pointer time-of-day-proc))
(define-extern time-of-day-interp-colors (function (pointer rgba) uint mood-context none))
(define-extern time-of-day-interp-colors-scratch (function (pointer rgba) time-of-day-palette mood-context none))

View file

@ -482,40 +482,41 @@
;; Collision
;;;;;;;;;;;;;;;
(defmethod dummy-11 bsp-header ((obj bsp-header) (arg0 int) (arg1 object))
(defmethod collide-with-box bsp-header ((obj bsp-header) (arg0 int) (arg1 collide-list))
"Top level collision with a box function. I think the arg0 length doesn't really matter here."
(+! (-> *collide-stats* calls) 1)
(let ((s4-0 (-> obj drawable-trees)))
(dotimes (s3-0 (-> s4-0 length))
(dummy-11 (-> s4-0 data s3-0) arg0 arg1)
(dotimes (s3-0 (-> s4-0 length))
(collide-with-box (-> s4-0 data s3-0) arg0 arg1)
)
)
)
(none)
)
(defmethod dummy-12 bsp-header ((obj bsp-header) (arg0 int) (arg1 object))
(defmethod collide-y-probe bsp-header ((obj bsp-header) (arg0 int) (arg1 collide-list))
(+! (-> *collide-stats* calls) 1)
(let ((s4-0 (-> obj drawable-trees)))
(dotimes (s3-0 (-> s4-0 length))
(dummy-12 (-> s4-0 data s3-0) arg0 arg1)
(dotimes (s3-0 (-> s4-0 length))
(collide-y-probe (-> s4-0 data s3-0) arg0 arg1)
)
)
)
(none)
)
(defmethod dummy-13 bsp-header ((obj bsp-header) (arg0 int) (arg1 object))
(defmethod collide-ray bsp-header ((obj bsp-header) (arg0 int) (arg1 collide-list))
(+! (-> *collide-stats* calls) 1)
(let ((s4-0 (-> obj drawable-trees)))
(dotimes (s3-0 (-> s4-0 length))
(dummy-13 (-> s4-0 data s3-0) arg0 arg1)
(dotimes (s3-0 (-> s4-0 length))
(collide-ray (-> s4-0 data s3-0) arg0 arg1)
)
)
)
(none)
)
(defmethod dummy-17 bsp-header ((obj bsp-header) (arg0 sphere) (arg1 int) (arg2 ambient-list))
(defmethod collect-ambients bsp-header ((obj bsp-header) (arg0 sphere) (arg1 int) (arg2 ambient-list))
(let ((s3-0 (-> obj drawable-trees)))
(dotimes (s2-0 (-> s3-0 length))
(dummy-17 (-> s3-0 data s2-0) arg0 arg1 arg2)
(collect-ambients (-> s3-0 data s2-0) arg0 arg1 arg2)
)
)
(none)

View file

@ -587,3 +587,8 @@
"Access an object on the scratchpad."
`(the-as ,type (&+ *fake-scratchpad-data* ,offset))
)
(defmacro scratchpad-ptr (type &key (offset 0))
"Create a pointer to an object on the scratchpad."
`(the-as (pointer ,type) (&+ *fake-scratchpad-data* ,offset))
)

View file

@ -130,13 +130,13 @@
(.ppach v1-2 a1-1 v1-1)
(.mov r0-2 f31-0)
(.ppach a1-2 a3-1 a2-1)
(set! (-> arg0 itimes 0 quad) (the-as uint128 v1-2))
(set! (-> arg0 itimes 0 quad) v1-2)
(.ppach v1-3 t1-1 t0-1)
(set! (-> arg0 itimes 1 quad) (the-as uint128 a1-2))
(set! (-> arg0 itimes 1 quad) a1-2)
(.ppach a1-3 t3-1 t2-1)
(set! (-> arg0 itimes 2 quad) (the-as uint128 v1-3))
(set! (-> arg0 itimes 2 quad) v1-3)
(nop!)
(set! (-> arg0 itimes 3 quad) (the-as uint128 a1-3))
(set! (-> arg0 itimes 3 quad) a1-3)
0
(none)
)

View file

@ -30,7 +30,7 @@
(a0-7 "align joint-anim")
)
(set! (-> pp next-state) process-drawable-art-error)
(t9-0 a0-7 (the-as none a1-0) a2-0)
(t9-0 a0-7 (the-as object a1-0) a2-0)
)
(.lw ra-0 return-from-thread s7-0)
(.jr ra-0)

View file

@ -1247,7 +1247,7 @@
(set! (-> a1-3 param 0) (the-as uint self))
(let ((t9-4 send-event-function))
(set! a0-4 *camera*)
(t9-4 (the-as process a0-4) a1-3)
(t9-4 (the-as camera-master a0-4) a1-3)
)
)
)

View file

@ -35,10 +35,10 @@
;; definition for method 11 of type drawable-tree-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-11
collide-with-box
drawable-tree-collide-fragment
((obj drawable-tree-collide-fragment) (arg0 int) (arg1 object))
(dummy-11 (-> obj data 0) (-> obj length) arg1)
((obj drawable-tree-collide-fragment) (arg0 int) (arg1 collide-list))
(collide-with-box (-> obj data 0) (-> obj length) arg1)
0
(none)
)
@ -46,10 +46,10 @@
;; definition for method 12 of type drawable-tree-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-12
collide-y-probe
drawable-tree-collide-fragment
((obj drawable-tree-collide-fragment) (arg0 int) (arg1 object))
(dummy-12 (-> obj data 0) (-> obj length) arg1)
((obj drawable-tree-collide-fragment) (arg0 int) (arg1 collide-list))
(collide-y-probe (-> obj data 0) (-> obj length) arg1)
0
(none)
)
@ -57,10 +57,10 @@
;; definition for method 13 of type drawable-tree-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-13
collide-ray
drawable-tree-collide-fragment
((obj drawable-tree-collide-fragment) (arg0 int) (arg1 object))
(dummy-13 (-> obj data 0) (-> obj length) arg1)
((obj drawable-tree-collide-fragment) (arg0 int) (arg1 collide-list))
(collide-ray (-> obj data 0) (-> obj length) arg1)
0
(none)
)
@ -143,10 +143,14 @@
;; definition for method 11 of type drawable-inline-array-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-11
collide-with-box
drawable-inline-array-collide-fragment
((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 object))
(dummy-11 (the-as collide-fragment (-> obj data)) (-> obj length) arg1)
((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 collide-list))
(collide-with-box
(the-as collide-fragment (-> obj data))
(-> obj length)
arg1
)
0
(none)
)
@ -154,10 +158,10 @@
;; definition for method 12 of type drawable-inline-array-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-12
collide-y-probe
drawable-inline-array-collide-fragment
((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 object))
(dummy-12 (the-as collide-fragment (-> obj data)) (-> obj length) arg1)
((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 collide-list))
(collide-y-probe (the-as collide-fragment (-> obj data)) (-> obj length) arg1)
0
(none)
)
@ -165,10 +169,10 @@
;; definition for method 13 of type drawable-inline-array-collide-fragment
;; INFO: Return type mismatch int vs none.
(defmethod
dummy-13
collide-ray
drawable-inline-array-collide-fragment
((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 object))
(dummy-13 (the-as collide-fragment (-> obj data)) (-> obj length) arg1)
((obj drawable-inline-array-collide-fragment) (arg0 int) (arg1 collide-list))
(collide-ray (the-as collide-fragment (-> obj data)) (-> obj length) arg1)
0
(none)
)

View file

@ -3,10 +3,10 @@
;; definition of type draw-node
(deftype draw-node (drawable)
((child-count uint8 :offset 6)
(flags uint8 :offset 7)
(child uint32 :offset 8)
(distance float :offset 12)
((child-count uint8 :offset 6)
(flags uint8 :offset 7)
(child drawable :offset 8)
(distance float :offset 12)
)
:method-count-assert 18
:size-assert #x20

View file

@ -0,0 +1,157 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for method 11 of type draw-node
;; INFO: Return type mismatch int vs none.
(defmethod
collide-with-box
draw-node
((obj draw-node) (arg0 int) (arg1 collide-list))
(dotimes (s3-0 arg0)
(if (collide-cache-using-box-test (-> obj bsphere))
(collide-with-box (-> obj child) (the-as int (-> obj child-count)) arg1)
)
(&+! obj 32)
)
0
(none)
)
;; definition for method 12 of type draw-node
;; INFO: Return type mismatch int vs none.
(defmethod
collide-y-probe
draw-node
((obj draw-node) (arg0 int) (arg1 collide-list))
(dotimes (s3-0 arg0)
(if (collide-cache-using-y-probe-test (-> obj bsphere))
(collide-y-probe (-> obj child) (the-as int (-> obj child-count)) arg1)
)
(&+! obj 32)
)
0
(none)
)
;; definition for method 13 of type draw-node
;; INFO: Return type mismatch int vs none.
(defmethod collide-ray draw-node ((obj draw-node) (arg0 int) (arg1 collide-list))
(dotimes (s3-0 arg0)
(if (collide-cache-using-line-sphere-test (-> obj bsphere))
(collide-ray (-> obj child) (the-as int (-> obj child-count)) arg1)
)
(&+! obj 32)
)
0
(none)
)
;; definition for method 17 of type draw-node
;; INFO: Return type mismatch int vs none.
(defmethod
collect-ambients
draw-node
((obj draw-node) (arg0 sphere) (arg1 int) (arg2 ambient-list))
(dotimes (s2-0 arg1)
(if (spheres-overlap? arg0 (the-as sphere (-> obj bsphere)))
(collect-ambients
(-> obj child)
arg0
(the-as int (-> obj child-count))
arg2
)
)
(&+! obj 32)
)
0
(none)
)
;; definition for method 3 of type drawable-inline-array-node
(defmethod inspect drawable-inline-array-node ((obj drawable-inline-array-node))
(format #t "[~8x] ~A~%" obj (-> obj type))
(format #t "~Tlength: ~D~%" (-> obj length))
(format #t "~Tdata[~D]: @ #x~X~%" (-> obj length) (-> obj data))
(dotimes (s5-0 (-> obj length))
(format #t "~T [~D] ~A~%" s5-0 (-> obj data s5-0))
)
obj
)
;; definition for method 8 of type drawable-inline-array-node
(defmethod
mem-usage
drawable-inline-array-node
((obj drawable-inline-array-node) (arg0 memory-usage-block) (arg1 int))
(set! (-> arg0 length) (max 62 (-> arg0 length)))
(set! (-> arg0 data 61 name) "draw-node")
(+! (-> arg0 data 61 count) (-> obj length))
(let ((v1-6 (asize-of obj)))
(+! (-> arg0 data 61 used) v1-6)
(+! (-> arg0 data 61 total) (logand -16 (+ v1-6 15)))
)
obj
)
;; definition for method 5 of type drawable-inline-array-node
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of drawable-inline-array-node ((obj drawable-inline-array-node))
(the-as
int
(+ (-> drawable-inline-array-node size) (* (+ (-> obj length) -1) 32))
)
)
;; definition for method 11 of type drawable-inline-array-node
;; INFO: Return type mismatch int vs none.
(defmethod
collide-with-box
drawable-inline-array-node
((obj drawable-inline-array-node) (arg0 int) (arg1 collide-list))
(collide-with-box (the-as drawable (-> obj data)) (-> obj length) arg1)
0
(none)
)
;; definition for method 12 of type drawable-inline-array-node
;; INFO: Return type mismatch int vs none.
(defmethod
collide-y-probe
drawable-inline-array-node
((obj drawable-inline-array-node) (arg0 int) (arg1 collide-list))
(collide-y-probe (the-as drawable (-> obj data)) (-> obj length) arg1)
0
(none)
)
;; definition for method 13 of type drawable-inline-array-node
;; INFO: Return type mismatch int vs none.
(defmethod
collide-ray
drawable-inline-array-node
((obj drawable-inline-array-node) (arg0 int) (arg1 collide-list))
(collide-ray (the-as drawable (-> obj data)) (-> obj length) arg1)
0
(none)
)
;; definition for method 17 of type drawable-inline-array-node
;; INFO: Return type mismatch int vs none.
(defmethod
collect-ambients
drawable-inline-array-node
((obj drawable-inline-array-node)
(arg0 sphere)
(arg1 int)
(arg2 ambient-list)
)
(collect-ambients (the-as drawable (-> obj data)) arg0 (-> obj length) arg2)
0
(none)
)
;; definition for function draw-node-cull
;; ERROR: function was not converted to expressions. Cannot decompile.
;; failed to figure out what this is:
0

View file

@ -12,13 +12,13 @@
(:methods
(login (_type_) _type_ 9)
(draw (_type_ drawable display-frame) none 10)
(dummy-11 (_type_ int object) none 11)
(dummy-12 (_type_ int object) none 12)
(dummy-13 (_type_ int object) none 13)
(collide-with-box (_type_ int collide-list) none 11)
(collide-y-probe (_type_ int collide-list) none 12)
(collide-ray (_type_ int collide-list) none 13)
(dummy-14 (_type_) none 14)
(dummy-15 (_type_ object object) none 15)
(dummy-16 (_type_ object object) object 16)
(dummy-17 (_type_ sphere int ambient-list) none 17)
(collect-ambients (_type_ sphere int ambient-list) none 17)
)
)

View file

@ -281,13 +281,10 @@
(while s4-0
(if
(and
((method-of-type connection belongs-to-engine?)
(the-as connection s4-0)
s5-0
)
(belongs-to-engine? (the-as connection s4-0) s5-0)
(or (= arg1 #t) (= arg1 (-> (the-as connection s4-0) param0)))
)
((method-of-type connection move-to-dead) (the-as connection s4-0))
(move-to-dead (the-as connection s4-0))
)
(set! s4-0 (-> s4-0 next1))
)

View file

@ -93,7 +93,17 @@
)
(set! (-> (the-as vol-control gp-0) process) arg0)
(let* ((s5-1 (the-as res-lump (-> (the-as vol-control gp-0) process entity)))
(s4-0 (-> (lookup-tag-idx (the-as entity s5-1) 'vol 'exact 0.0) lo))
(s4-0
(->
((method-of-type res-lump lookup-tag-idx)
(the-as entity s5-1)
'vol
'exact
0.0
)
lo
)
)
)
(when (>= (the-as int s4-0) 0)
(let ((s3-0 (the-as uint s4-0))
@ -130,7 +140,15 @@
)
(let* ((s5-2 (the-as res-lump (-> (the-as vol-control gp-0) process entity)))
(s4-1
(-> (lookup-tag-idx (the-as entity s5-2) 'cutoutvol 'exact 0.0) lo)
(->
((method-of-type res-lump lookup-tag-idx)
(the-as entity s5-2)
'cutoutvol
'exact
0.0
)
lo
)
)
)
(when (>= (the-as int s4-1) 0)

View file

@ -0,0 +1,525 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for symbol *background-work*, type background-work
(define *background-work* (new 'global 'background-work))
;; definition for symbol background-vu0-block, type vu-function
(define background-vu0-block (new 'static 'vu-function :length 59 :qlength 30))
;; definition for function background-upload-vu0
;; ERROR: function was not converted to expressions. Cannot decompile.
;; definition for function init-background
;; INFO: Return type mismatch int vs none.
(defun init-background ()
(dotimes (v1-0 8)
(set! (-> *background-work* tfrag-trees v1-0) #f)
(set! (-> *background-work* trans-tfrag-trees v1-0) #f)
(set! (-> *background-work* dirt-tfrag-trees v1-0) #f)
(set! (-> *background-work* ice-tfrag-trees v1-0) #f)
(set! (-> *background-work* lowres-tfrag-trees v1-0) #f)
(set! (-> *background-work* lowres-trans-tfrag-trees v1-0) #f)
)
(set! (-> *background-work* tfrag-tree-count) 0)
(set! (-> *background-work* trans-tfrag-tree-count) 0)
(set! (-> *background-work* dirt-tfrag-tree-count) 0)
(set! (-> *background-work* ice-tfrag-tree-count) 0)
(set! (-> *background-work* lowres-tfrag-tree-count) 0)
(set! (-> *background-work* lowres-trans-tfrag-tree-count) 0)
(set! (-> *background-work* shrub-tree-count) 0)
(set! (-> *background-work* tie-tree-count) 0)
(set! (-> *background-work* wait-to-vu0) (the-as uint 0))
0
(none)
)
;; definition for function upload-vis-bits
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defun upload-vis-bits ((arg0 level) (arg1 level) (arg2 bsp-header))
(let ((qwc (/ (+ (-> arg2 visible-list-length) 15) 16)))
(let ((lev-vis-bits (the-as (pointer uint128) (-> arg0 vis-bits)))
(all-vis (the-as (pointer uint128) (-> arg2 all-visible-list)))
(spad-vis (the-as (pointer uint128) (+ #x38b0 #x70000000)))
)
(b! (not *artist-flip-visible*) cfg-5 :delay (nop!))
(nop!)
(nop!)
(label cfg-2)
(let ((a3-2 (-> lev-vis-bits 0)))
(set! lev-vis-bits (&-> lev-vis-bits 1))
(let ((t0-0 (-> all-vis 0)))
(set! all-vis (&-> all-vis 1))
(nop!)
(nop!)
(let ((a3-3 (logxor a3-2 (the-as uint t0-0))))
(+! qwc -1)
(set! (-> spad-vis 0) a3-3)
)
)
)
(set! spad-vis (&-> spad-vis 1))
(b! (> qwc 0) cfg-2 :delay (nop!))
0
(b! #t cfg-8 :delay (nop!))
(nop!)
(label cfg-5)
(nop!)
(nop!)
(label cfg-6)
(let ((a1-2 (-> lev-vis-bits 0)))
(set! lev-vis-bits (&-> lev-vis-bits 1))
(nop!)
(+! qwc -1)
(set! (-> spad-vis 0) a1-2)
)
(set! spad-vis (&-> spad-vis 1))
)
(b! (> qwc 0) cfg-6 :delay (nop!))
)
0
(label cfg-8)
(none)
)
;; definition for function finish-background
;; INFO: Return type mismatch int vs none.
(defun finish-background ()
(rlet ((vf16 :class vf)
(vf17 :class vf)
(vf18 :class vf)
(vf19 :class vf)
(vf20 :class vf)
(vf21 :class vf)
(vf22 :class vf)
(vf23 :class vf)
(vf24 :class vf)
(vf25 :class vf)
(vf26 :class vf)
(vf27 :class vf)
(vf28 :class vf)
(vf29 :class vf)
(vf30 :class vf)
(vf31 :class vf)
)
(background-upload-vu0)
(set! (-> *instance-shrub-work* paused) (paused?))
(when (nonzero? (-> *background-work* shrub-tree-count))
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x40 :b #x40 :a #x80)
)
)
(dotimes (gp-0 (-> *background-work* shrub-tree-count))
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> *background-work* shrub-levels gp-0 index)
)
(flush-cache 0)
(let ((s5-0 (-> *background-work* shrub-trees gp-0))
(s4-0 (-> *background-work* shrub-levels gp-0))
)
(if (nonzero? (-> s5-0 colors-added))
(time-of-day-interp-colors
(-> *instance-shrub-work* colors)
(-> s5-0 colors-added)
(-> s4-0 mood)
)
)
(draw-drawable-tree-instance-shrub s5-0 s4-0)
)
)
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x40 :g #x60 :b #x80 :a #x80)
)
)
)
(let ((gp-1 (the-as level #f)))
(when
(or
(nonzero? (-> *background-work* tfrag-tree-count))
(nonzero? (-> *background-work* trans-tfrag-tree-count))
(nonzero? (-> *background-work* dirt-tfrag-tree-count))
(nonzero? (-> *background-work* ice-tfrag-tree-count))
(nonzero? (-> *background-work* lowres-tfrag-tree-count))
(nonzero? (-> *background-work* lowres-trans-tfrag-tree-count))
)
(let ((v1-48 *math-camera*))
(.lvf vf16 (&-> v1-48 plane 0 quad))
(.lvf vf17 (&-> v1-48 plane 1 quad))
(.lvf vf18 (&-> v1-48 plane 2 quad))
(.lvf vf19 (&-> v1-48 plane 3 quad))
(.lvf vf20 (&-> v1-48 shrub-mat vector 0 quad))
(.lvf vf21 (&-> v1-48 shrub-mat vector 1 quad))
(.lvf vf22 (&-> v1-48 shrub-mat vector 2 quad))
(.lvf vf23 (&-> v1-48 shrub-mat vector 3 quad))
(.lvf vf24 (&-> v1-48 camera-rot vector 0 quad))
(.lvf vf25 (&-> v1-48 camera-rot vector 1 quad))
(.lvf vf26 (&-> v1-48 camera-rot vector 2 quad))
(.lvf vf27 (&-> v1-48 camera-rot vector 3 quad))
(.lvf vf28 (&-> v1-48 camera-temp vector 0 quad))
(.lvf vf29 (&-> v1-48 camera-temp vector 1 quad))
(.lvf vf30 (&-> v1-48 camera-temp vector 2 quad))
(.lvf vf31 (&-> v1-48 camera-temp vector 3 quad))
(.lvf vf31 (&-> v1-48 camera-temp vector 3 quad))
)
(let*
((v1-52
(max
(-> *background-work* tfrag-tree-count)
(-> *background-work* trans-tfrag-tree-count)
)
)
(s4-1 (the-as time-of-day-palette #f))
(s5-2
(max
(max v1-52 (-> *background-work* lowres-tfrag-tree-count))
(-> *background-work* lowres-trans-tfrag-tree-count)
)
)
)
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x40 :b #x40 :a #x80)
)
)
(dotimes (s3-0 s5-2)
(let ((s2-0 (-> *background-work* tfrag-trees s3-0)))
(when s2-0
(let ((s1-0 (-> *background-work* tfrag-levels s3-0)))
(let ((a2-4 (-> s1-0 bsp))
(s0-0 (-> s2-0 time-of-day-pal))
)
(upload-vis-bits s1-0 gp-1 a2-4)
(when (not (or (zero? s0-0) (= s4-1 s0-0)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as
(pointer rgba)
(+ 6160 (the-as int (the-as terrain-context #x70000000)))
)
s0-0
(-> s1-0 mood)
)
(set! s4-1 s0-0)
)
)
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-0 index)
)
)
(set! (-> *tfrag-work* min-dist z) 4095996000.0)
(draw-drawable-tree-tfrag s2-0)
(set!
(->
*level*
level
(-> (the-as terrain-context #x70000000) bsp lev-index)
closest-object
0
)
(-> *tfrag-work* min-dist z)
)
)
)
(let ((s2-1 (-> *background-work* trans-tfrag-trees s3-0)))
(when s2-1
(let ((s1-1 (-> *background-work* trans-tfrag-levels s3-0)))
(let ((a2-6 (-> s1-1 bsp))
(s0-1 (-> s2-1 time-of-day-pal))
)
(upload-vis-bits s1-1 gp-1 a2-6)
(when (not (or (zero? s0-1) (= s4-1 s0-1)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as (pointer rgba) (+ 6160 #x70000000))
s0-1
(-> s1-1 mood)
)
(set! s4-1 s0-1)
)
)
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-1 index)
)
)
(set! (-> *tfrag-work* min-dist z) 4095996000.0)
(draw-drawable-tree-trans-tfrag s2-1)
(set!
(->
*level*
level
(-> (the-as terrain-context #x70000000) bsp lev-index)
closest-object
3
)
(-> *tfrag-work* min-dist z)
)
)
)
(let ((s2-2 (-> *background-work* dirt-tfrag-trees s3-0)))
(when s2-2
(let ((s1-2 (-> *background-work* dirt-tfrag-levels s3-0)))
(let ((a2-8 (-> s1-2 bsp))
(s0-2 (-> s2-2 time-of-day-pal))
)
(upload-vis-bits s1-2 gp-1 a2-8)
(when (not (or (zero? s0-2) (= s4-1 s0-2)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as (pointer rgba) (+ 6160 #x70000000))
s0-2
(-> s1-2 mood)
)
(set! s4-1 s0-2)
)
)
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-2 index)
)
)
(set! (-> *tfrag-work* min-dist z) 4095996000.0)
(draw-drawable-tree-dirt-tfrag s2-2)
(set!
(->
*level*
level
(-> (the-as terrain-context #x70000000) bsp lev-index)
closest-object
3
)
(fmin
(->
*level*
level
(-> (the-as terrain-context #x70000000) bsp lev-index)
closest-object
3
)
(-> *tfrag-work* min-dist z)
)
)
)
)
(let ((s2-3 (-> *background-work* ice-tfrag-trees s3-0)))
(when s2-3
(let ((s1-3 (-> *background-work* ice-tfrag-levels s3-0)))
(let ((a2-10 (-> s1-3 bsp))
(s0-3 (-> s2-3 time-of-day-pal))
)
(upload-vis-bits s1-3 gp-1 a2-10)
(when (not (or (zero? s0-3) (= s4-1 s0-3)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as (pointer rgba) (+ 6160 #x70000000))
s0-3
(-> s1-3 mood)
)
(set! s4-1 s0-3)
)
)
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-3 index)
)
)
(set! (-> *tfrag-work* min-dist z) 4095996000.0)
(draw-drawable-tree-ice-tfrag s2-3)
(set!
(->
*level*
level
(-> (the-as terrain-context #x70000000) bsp lev-index)
closest-object
3
)
(fmin
(->
*level*
level
(-> (the-as terrain-context #x70000000) bsp lev-index)
closest-object
3
)
(-> *tfrag-work* min-dist z)
)
)
)
)
(let ((s2-4 (-> *background-work* lowres-tfrag-trees s3-0)))
(when s2-4
(let ((s1-4 (-> *background-work* lowres-tfrag-levels s3-0)))
(let ((a2-12 (-> s1-4 bsp))
(s0-4 (-> s2-4 time-of-day-pal))
)
(upload-vis-bits s1-4 gp-1 a2-12)
(when (not (or (zero? s0-4) (= s4-1 s0-4)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as (pointer rgba) (+ 6160 #x70000000))
s0-4
(-> s1-4 mood)
)
(set! s4-1 s0-4)
)
)
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-4 index)
)
)
(draw-drawable-tree-tfrag s2-4)
)
)
(let ((s2-5 (-> *background-work* lowres-trans-tfrag-trees s3-0)))
(when s2-5
(let ((s1-5 (-> *background-work* lowres-trans-tfrag-levels s3-0)))
(let ((a2-14 (-> s1-5 bsp))
(s0-5 (-> s2-5 time-of-day-pal))
)
(upload-vis-bits s1-5 gp-1 a2-14)
(when (not (or (zero? s0-5) (= s4-1 s0-5)))
(flush-cache 0)
(time-of-day-interp-colors-scratch
(the-as (pointer rgba) (+ 6160 #x70000000))
s0-5
(-> s1-5 mood)
)
(set! s4-1 s0-5)
)
)
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s1-5 index)
)
)
(set! (-> *tfrag-work* min-dist z) 4095996000.0)
(draw-drawable-tree-trans-tfrag s2-5)
(set!
(->
*level*
level
(-> (the-as terrain-context #x70000000) bsp lev-index)
closest-object
3
)
(fmin
(->
*level*
level
(-> (the-as terrain-context #x70000000) bsp lev-index)
closest-object
3
)
(-> *tfrag-work* min-dist z)
)
)
)
)
)
)
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x40 :g #x80 :b #x60 :a #x80)
)
)
)
(set! (-> *instance-tie-work* paused) (paused?))
(when (nonzero? (-> *background-work* tie-tree-count))
(tie-near-make-perspective-matrix
(-> *instance-tie-work* tie-near-perspective-matrix)
)
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x40 :b #x40 :a #x80)
)
)
(dotimes (s5-3 (-> *background-work* tie-tree-count))
(let ((s4-2 (-> *background-work* tie-levels s5-3)))
(let ((a2-18 (-> s4-2 bsp)))
(when (!= s4-2 gp-1)
(set! (-> *instance-tie-work* min-dist x) 4095996000.0)
(upload-vis-bits s4-2 gp-1 a2-18)
(set! gp-1 s4-2)
)
)
(set!
(-> (the-as terrain-context #x70000000) bsp lev-index)
(-> s4-2 index)
)
(set! (-> (the-as terrain-context #x70000000) bsp mood) (-> s4-2 mood))
(draw-drawable-tree-instance-tie
(-> *background-work* tie-trees s5-3)
s4-2
)
)
(set!
(-> *background-work* tie-generic s5-3)
(the-as basic (-> *instance-tie-work* first-generic-prototype))
)
)
(if *debug-segment*
(add-frame
(-> *display* frames (-> *display* on-screen) frame profile-bar 0)
'draw
(new 'static 'rgba :r #x80 :g #x20 :b #x60 :a #x80)
)
)
(dotimes (gp-2 (-> *background-work* tie-tree-count))
(when (nonzero? (-> *background-work* tie-generic gp-2))
(let*
((s5-4
(->
*background-work*
tie-levels
gp-2
foreground-sink-group
0
generic-sink
)
)
(s3-1 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s4-3 (-> s3-1 base))
)
(generic-tie-execute s5-4 s3-1 (-> *background-work* tie-generic gp-2))
(let ((a3-0 (-> s3-1 base)))
(let ((v1-219 (the-as object (-> s3-1 base))))
(set!
(-> (the-as dma-packet v1-219) dma)
(new 'static 'dma-tag :id (dma-tag-id next))
)
(set! (-> (the-as dma-packet v1-219) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet v1-219) vif1) (new 'static 'vif-tag))
(set! (-> s3-1 base) (&+ (the-as pointer v1-219) 16))
)
(dma-bucket-insert-tag
(-> *display* frames (-> *display* on-screen) frame bucket-group)
(-> s5-4 bucket)
s4-3
(the-as (pointer dma-tag) a3-0)
)
)
)
)
)
)
)
0
(none)
)
)

View file

@ -0,0 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for symbol merc-vu1-block, type vu-function
(define merc-vu1-block (new 'static 'vu-function :length #x7e5 :qlength #x3f3))

View file

@ -130,7 +130,8 @@
;; definition of type drawable-tree-instance-shrub
(deftype drawable-tree-instance-shrub (drawable-tree)
((info prototype-array-shrub-info :offset 8)
((info prototype-array-shrub-info :offset 8)
(colors-added uint32 :offset 12)
)
:method-count-assert 18
:size-assert #x24

View file

@ -446,11 +446,14 @@
;; definition for method 11 of type bsp-header
;; INFO: Return type mismatch symbol vs none.
(defmethod dummy-11 bsp-header ((obj bsp-header) (arg0 int) (arg1 object))
(defmethod
collide-with-box
bsp-header
((obj bsp-header) (arg0 int) (arg1 collide-list))
(+! (-> *collide-stats* calls) 1)
(let ((s4-0 (-> obj drawable-trees)))
(dotimes (s3-0 (-> s4-0 length))
(dummy-11 (-> s4-0 data s3-0) arg0 arg1)
(collide-with-box (-> s4-0 data s3-0) arg0 arg1)
)
)
(none)
@ -458,11 +461,14 @@
;; definition for method 12 of type bsp-header
;; INFO: Return type mismatch symbol vs none.
(defmethod dummy-12 bsp-header ((obj bsp-header) (arg0 int) (arg1 object))
(defmethod
collide-y-probe
bsp-header
((obj bsp-header) (arg0 int) (arg1 collide-list))
(+! (-> *collide-stats* calls) 1)
(let ((s4-0 (-> obj drawable-trees)))
(dotimes (s3-0 (-> s4-0 length))
(dummy-12 (-> s4-0 data s3-0) arg0 arg1)
(collide-y-probe (-> s4-0 data s3-0) arg0 arg1)
)
)
(none)
@ -470,11 +476,14 @@
;; definition for method 13 of type bsp-header
;; INFO: Return type mismatch symbol vs none.
(defmethod dummy-13 bsp-header ((obj bsp-header) (arg0 int) (arg1 object))
(defmethod
collide-ray
bsp-header
((obj bsp-header) (arg0 int) (arg1 collide-list))
(+! (-> *collide-stats* calls) 1)
(let ((s4-0 (-> obj drawable-trees)))
(dotimes (s3-0 (-> s4-0 length))
(dummy-13 (-> s4-0 data s3-0) arg0 arg1)
(collide-ray (-> s4-0 data s3-0) arg0 arg1)
)
)
(none)
@ -483,12 +492,12 @@
;; definition for method 17 of type bsp-header
;; INFO: Return type mismatch symbol vs none.
(defmethod
dummy-17
collect-ambients
bsp-header
((obj bsp-header) (arg0 sphere) (arg1 int) (arg2 ambient-list))
(let ((s3-0 (-> obj drawable-trees)))
(dotimes (s2-0 (-> s3-0 length))
(dummy-17 (-> s3-0 data s2-0) arg0 arg1 arg2)
(collect-ambients (-> s3-0 data s2-0) arg0 arg1 arg2)
)
)
(none)

View file

@ -1001,7 +1001,7 @@
(.ftoi.vf vf1 vf1)
(.mov v1-0 vf1)
(.pw.sll v1-1 v1-0 16)
(set! (-> arg0 quad) (the-as uint128 v1-1))
(set! (-> arg0 quad) v1-1)
arg0
)
)

View file

@ -76,8 +76,10 @@ const std::unordered_set<std::string> g_functions_expected_to_reject = {
"update-mood-lightning", // asm
// ambient
"ambient-inspect" // asm, weird
};
"ambient-inspect", // asm, weird
// background
"background-upload-vu0", "draw-node-cull"};
const std::unordered_set<std::string> g_functions_to_skip_compiling = {
/// GCOMMON