mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
Fix asize bug, decompile a few files (#293)
* fix bug in asize of basic * more decomp
This commit is contained in:
parent
c15c163333
commit
9d3b056b7a
|
@ -36,10 +36,10 @@ void ObjectFileDB::analyze_functions_ir2(const std::string& output_dir) {
|
|||
ir2_type_analysis_pass();
|
||||
lg::info("Register usage analysis...");
|
||||
ir2_register_usage_pass();
|
||||
lg::info("Initial structuring..");
|
||||
ir2_cfg_build_pass();
|
||||
lg::info("Variable analysis...");
|
||||
ir2_variable_pass();
|
||||
lg::info("Initial structuring..");
|
||||
ir2_cfg_build_pass();
|
||||
if (get_config().analyze_expressions) {
|
||||
lg::info("Storing temporary form result...");
|
||||
ir2_store_current_forms();
|
||||
|
|
|
@ -330,21 +330,23 @@ bool try_clean_up_sc_as_and(FormPool& pool, Function& func, ShortCircuitElement*
|
|||
// we also want to fix up the use/def info for the result.
|
||||
// it's somewhat arbitrary, but we use the convention that the short-circuit defs
|
||||
// are eliminated:
|
||||
auto& ud_info = func.ir2.env.get_use_def_info(as_set->dst());
|
||||
if (i == int(ir->entries.size()) - 2) {
|
||||
if (ud_info.def_count() == 1) {
|
||||
// the final case of the or doesn't explicitly set the destination register.
|
||||
// this can happen if the move is eliminated during coloring.
|
||||
// for now, let's leave this last def here, just so it looks like _something_ sets it.
|
||||
if (func.ir2.env.has_local_vars()) {
|
||||
auto& ud_info = func.ir2.env.get_use_def_info(as_set->dst());
|
||||
if (i == int(ir->entries.size()) - 2) {
|
||||
if (ud_info.def_count() == 1) {
|
||||
// the final case of the or doesn't explicitly set the destination register.
|
||||
// this can happen if the move is eliminated during coloring.
|
||||
// for now, let's leave this last def here, just so it looks like _something_ sets it.
|
||||
|
||||
} else {
|
||||
// lg::warn("Disabling def of {} in final or delay slot",
|
||||
// as_set->to_string(func.ir2.env));
|
||||
func.ir2.env.disable_def(as_set->dst());
|
||||
}
|
||||
} else {
|
||||
// lg::warn("Disabling def of {} in final or delay slot",
|
||||
// as_set->to_string(func.ir2.env));
|
||||
// lg::warn("Disabling def of {} in or delay slot", as_set->to_string(func.ir2.env));
|
||||
func.ir2.env.disable_def(as_set->dst());
|
||||
}
|
||||
} else {
|
||||
// lg::warn("Disabling def of {} in or delay slot", as_set->to_string(func.ir2.env));
|
||||
func.ir2.env.disable_def(as_set->dst());
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
@ -679,12 +681,13 @@ void clean_up_cond_no_else_final(Function& func, CondNoElseElement* cne) {
|
|||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < cne->entries.size(); i++) {
|
||||
if (func.ir2.env.has_reg_use()) {
|
||||
auto branch = dynamic_cast<BranchElement*>(cne->entries.at(i).original_condition_branch);
|
||||
auto reg = cne->entries.at(i).false_destination;
|
||||
// lg::warn("Disable def of {} at {}\n", reg->to_string(func.ir2.env), reg->idx());
|
||||
func.ir2.env.disable_def(*reg);
|
||||
if (func.ir2.env.has_local_vars()) {
|
||||
for (size_t i = 0; i < cne->entries.size(); i++) {
|
||||
if (func.ir2.env.has_reg_use()) {
|
||||
auto reg = cne->entries.at(i).false_destination;
|
||||
// lg::warn("Disable def of {} at {}\n", reg->to_string(func.ir2.env), reg->idx());
|
||||
func.ir2.env.disable_def(*reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -213,7 +213,65 @@
|
|||
|
||||
"surface-h":[
|
||||
["L72", "float", true],
|
||||
["L71", "float", true]
|
||||
["L71", "float", true],
|
||||
["L68", "_auto_", true],
|
||||
["L67", "_auto_", true],
|
||||
["L66", "_auto_", true],
|
||||
["L65", "_auto_", true],
|
||||
["L64", "_auto_", true],
|
||||
["L63", "_auto_", true],
|
||||
["L62", "_auto_", true],
|
||||
["L61", "_auto_", true],
|
||||
["L60", "_auto_", true],
|
||||
["L59", "_auto_", true],
|
||||
["L58", "_auto_", true],
|
||||
["L57", "_auto_", true],
|
||||
["L56", "_auto_", true],
|
||||
["L55", "_auto_", true],
|
||||
["L54", "_auto_", true],
|
||||
["L53", "_auto_", true],
|
||||
["L52", "_auto_", true],
|
||||
["L51", "_auto_", true],
|
||||
["L50", "_auto_", true],
|
||||
["L49", "_auto_", true],
|
||||
["L48", "_auto_", true],
|
||||
["L47", "_auto_", true],
|
||||
["L46", "_auto_", true],
|
||||
["L45", "_auto_", true],
|
||||
["L44", "_auto_", true],
|
||||
["L43", "_auto_", true],
|
||||
["L42", "_auto_", true],
|
||||
["L41", "_auto_", true],
|
||||
["L40", "_auto_", true],
|
||||
["L39", "_auto_", true],
|
||||
["L38", "_auto_", true],
|
||||
["L37", "_auto_", true],
|
||||
["L36", "_auto_", true],
|
||||
["L35", "_auto_", true],
|
||||
["L34", "_auto_", true],
|
||||
["L33", "_auto_", true],
|
||||
["L32", "_auto_", true]
|
||||
],
|
||||
|
||||
"pat-h":[
|
||||
["L1", "(inline-array pat-mode-info)", true, 4]
|
||||
],
|
||||
|
||||
"fact-h":[
|
||||
["L35", "_auto_", true]
|
||||
],
|
||||
|
||||
"smush-control-h":[
|
||||
["L20", "float", true],
|
||||
["L18", "float", true],
|
||||
["L19", "float", true],
|
||||
["L17", "float", true]
|
||||
],
|
||||
|
||||
"collide-shape-h":[
|
||||
["L27", "float", true],
|
||||
["L25", "_auto_", true],
|
||||
["L24", "_auto_", true]
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -221,7 +221,18 @@
|
|||
"(method 19 engine)":[
|
||||
[8, ["a0", "connection"]]],
|
||||
"(method 20 engine)":[
|
||||
[8, ["a0", "connection"]]]
|
||||
[8, ["a0", "connection"]]],
|
||||
|
||||
"(method 0 collide-shape-prim-sphere)":[
|
||||
[4, ["v0", "collide-shape-prim-sphere"]]
|
||||
],
|
||||
|
||||
"(method 0 collide-shape-prim-mesh)":[
|
||||
[6, ["v0", "collide-shape-prim-mesh"]]
|
||||
],
|
||||
"(method 0 collide-shape-prim-group)":[
|
||||
[11, ["v0", "collide-shape-prim-group"]]
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -571,7 +571,36 @@
|
|||
"(method 15 engine)":{
|
||||
"args":["obj", "proc", "func", "p1", "p2", "p3"],
|
||||
"vars":{"v1-0":"con"}
|
||||
},
|
||||
|
||||
"surface-interp!":{
|
||||
"args":["dst", "src0", "src1", "amount"]
|
||||
},
|
||||
|
||||
"surface-mult!":{
|
||||
"args":["dst", "src0", "src1"]
|
||||
|
||||
},
|
||||
|
||||
"(method 0 collide-shape-prim)":{
|
||||
"args":["allocation", "type-to-make", "cshape", "prim-id", "size-bytes"]
|
||||
},
|
||||
|
||||
"(method 0 collide-shape-prim-sphere)":{
|
||||
"args":["allocation", "type-to-make", "cshape", "prim-id"]
|
||||
},
|
||||
"(method 0 collide-shape-prim-mesh)":{
|
||||
"args":["allocation", "type-to-make", "cshape", "mesh-id", "prim-id"]
|
||||
},
|
||||
"(method 0 collide-shape-prim-group)":{
|
||||
"args":["allocation", "type-to-make", "cshape", "elt-count", "prim-id"]
|
||||
},
|
||||
"(method 0 collide-shape)":{
|
||||
"args":["allocation", "type-to-make", "proc", "collide-list-kind", "prim-id"],
|
||||
"vars":{"s5-0":"obj"}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -510,11 +510,18 @@ goos::Object decompile_structure(const TypeSpec& type,
|
|||
}
|
||||
|
||||
std::vector<goos::Object> result_def = {
|
||||
pretty_print::to_symbol("new"), pretty_print::to_symbol("'static"),
|
||||
pretty_print::to_symbol(fmt::format("'{}", actual_type.print()))};
|
||||
pretty_print::to_symbol(fmt::format("new 'static '{}", actual_type.print()))};
|
||||
// pretty_print::to_symbol("new"), pretty_print::to_symbol("'static"),
|
||||
// pretty_print::to_symbol(fmt::format("'{}", actual_type.print()))};
|
||||
for (auto& f : field_defs_out) {
|
||||
result_def.push_back(pretty_print::to_symbol(fmt::format(":{}", f.first)));
|
||||
result_def.push_back(f.second);
|
||||
auto str = f.second.print();
|
||||
if (str.length() < 40) {
|
||||
result_def.push_back(
|
||||
pretty_print::to_symbol(fmt::format(":{} {}", f.first, f.second.print())));
|
||||
} else {
|
||||
result_def.push_back(pretty_print::to_symbol(fmt::format(":{}", f.first)));
|
||||
result_def.push_back(f.second);
|
||||
}
|
||||
}
|
||||
return pretty_print::build_list(result_def);
|
||||
}
|
||||
|
|
|
@ -1377,7 +1377,7 @@ u64 print_vu_function(u32 obj) {
|
|||
* Dynamically sized basics should override this method.
|
||||
*/
|
||||
u64 asize_of_basic(u32 it) {
|
||||
return Ptr<Type>(it - 4)->allocated_size;
|
||||
return Ptr<Type>(*Ptr<u32>(it - BASIC_OFFSET))->allocated_size;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -5,3 +5,4 @@
|
|||
;; name in dgo: collide-func-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
;; empty!
|
|
@ -5,3 +5,112 @@
|
|||
;; name in dgo: collide-mesh-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
(deftype collide-tri-result (structure)
|
||||
((vertex vector 3 :inline :offset-assert 0)
|
||||
(intersect vector :inline :offset-assert 48)
|
||||
(normal vector :inline :offset-assert 64)
|
||||
(pat uint32 :offset-assert 80)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x54
|
||||
:flag-assert #x900000054
|
||||
)
|
||||
|
||||
(deftype collide-mesh-tri (structure)
|
||||
((vertex-index uint8 3 :offset-assert 0)
|
||||
(unused uint8 :offset-assert 3)
|
||||
(pat uint32 :offset-assert 4)
|
||||
)
|
||||
:pack-me
|
||||
:method-count-assert 9
|
||||
:size-assert #x8
|
||||
:flag-assert #x900000008
|
||||
)
|
||||
|
||||
(deftype collide-mesh (basic)
|
||||
((joint-id int32 :offset-assert 4)
|
||||
(num-tris uint32 :offset-assert 8)
|
||||
(num-verts uint32 :offset-assert 12)
|
||||
(vertex-data uint32 :offset-assert 16)
|
||||
;; todo - this could be wrong
|
||||
(tris collide-mesh-tri 1 :inline :offset 32)
|
||||
)
|
||||
:method-count-assert 16
|
||||
:size-assert #x28
|
||||
:flag-assert #x1000000028
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype collide-mesh-cache (basic)
|
||||
((used-size uint32 :offset-assert 4)
|
||||
(max-size uint32 :offset-assert 8)
|
||||
(id uint64 :offset-assert 16)
|
||||
(pad uint8 8) ;; added
|
||||
(data uint8 40960 :offset-assert 32)
|
||||
)
|
||||
:method-count-assert 12
|
||||
:size-assert #xa020
|
||||
:flag-assert #xc0000a020
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(is-id? (_type_ int) symbol 10)
|
||||
(next-id! (_type_) uint 11)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod next-id! collide-mesh-cache ((obj collide-mesh-cache))
|
||||
"Reset all used entries in the cache and increment the id.
|
||||
If the id is zero, set it to 1"
|
||||
;; ld v1, 12(a0)
|
||||
(let ((v1 (-> obj id)))
|
||||
;; sw r0, 0(a0)
|
||||
(set! (-> obj used-size) 0)
|
||||
;; daddiu v0, v1, 1
|
||||
(let ((v0 (+ v1 1)))
|
||||
;; beql v0, r0, L3
|
||||
;; addiu v0, r0, 1 (only taken if v0 = 0)
|
||||
(if (= v0 0)
|
||||
(set! v0 (the uint 1))
|
||||
)
|
||||
;; L3:
|
||||
;; sd v0, 12(a0)
|
||||
(set! (-> obj id) v0)
|
||||
v0
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod is-id? collide-mesh-cache ((obj collide-mesh-cache) (arg0 int))
|
||||
"Is this our id?"
|
||||
(= (-> obj id) arg0)
|
||||
)
|
||||
|
||||
(deftype collide-mesh-cache-tri (structure)
|
||||
((vertex vector 3 :inline :offset-assert 0)
|
||||
(normal vector :inline :offset-assert 48)
|
||||
(bbox4w bounding-box4w :inline :offset-assert 64)
|
||||
(pat uint32 :offset 60)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x60
|
||||
:flag-assert #x900000060
|
||||
)
|
||||
|
||||
;; only allocate if we don't have an existing one.
|
||||
(define-extern *collide-mesh-cache* collide-mesh-cache)
|
||||
(if (or (not *collide-mesh-cache*) (zero? *collide-mesh-cache*))
|
||||
(set! *collide-mesh-cache* (new 'global 'collide-mesh-cache))
|
||||
)
|
||||
|
||||
;; in all cases, re-init.
|
||||
(set! (-> *collide-mesh-cache* id) 1)
|
||||
(set! (-> *collide-mesh-cache* used-size) 0)
|
||||
(set! (-> *collide-mesh-cache* max-size) #xa000)
|
||||
|
|
|
@ -5,3 +5,639 @@
|
|||
;; name in dgo: collide-shape-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
;; Represents a collision between the "rider" (zoomer?) and a primitive shape.
|
||||
;; collisions are "sticky", meaning these structures stick around.
|
||||
(deftype collide-sticky-rider (structure)
|
||||
((rider-handle handle :offset-assert 0)
|
||||
(sticky-prim basic :offset-assert 8)
|
||||
(prim-ry float :offset-assert 12)
|
||||
(rider-local-pos vector :inline :offset-assert 16)
|
||||
)
|
||||
:method-count-assert 10
|
||||
:size-assert #x20
|
||||
:flag-assert #xa00000020
|
||||
(:methods
|
||||
(set-rider! (_type_ handle) symbol 9)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod set-rider! collide-sticky-rider ((obj collide-sticky-rider) (arg0 handle))
|
||||
"Set the rider and clear the primitive."
|
||||
(set! (-> obj rider-handle) arg0)
|
||||
(set! (-> obj sticky-prim) #f)
|
||||
#f
|
||||
)
|
||||
|
||||
;; A collection of collide-sticky-riders
|
||||
;; dynamic type. I think there's one collide-sticky-rider per rider?
|
||||
(deftype collide-sticky-rider-group (basic)
|
||||
((num-riders int32 :offset-assert 4)
|
||||
(allocated-riders int32 :offset-assert 8)
|
||||
(rider collide-sticky-rider 1 :inline :offset-assert 16)
|
||||
)
|
||||
:method-count-assert 11
|
||||
:size-assert #x30
|
||||
:flag-assert #xb00000030
|
||||
(:methods
|
||||
(new (symbol type int) _type_ 0)
|
||||
(dummy-9 () none 9)
|
||||
(reset! (_type_) int 10)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod reset! collide-sticky-rider-group ((obj collide-sticky-rider-group))
|
||||
"Reset all active riders"
|
||||
(set! (-> obj num-riders) 0)
|
||||
0
|
||||
)
|
||||
|
||||
(deftype pull-rider-info (structure)
|
||||
((rider collide-sticky-rider :offset-assert 0)
|
||||
(rider-cshape basic :offset-assert 4)
|
||||
(rider-delta-ry float :offset-assert 8)
|
||||
(rider-dest vector :inline :offset-assert 16)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x20
|
||||
:flag-assert #x900000020
|
||||
)
|
||||
|
||||
(deftype collide-shape-intersect (basic)
|
||||
((move-vec vector :inline :offset-assert 16)
|
||||
(best-u float :offset-assert 32)
|
||||
(best-tri collide-tri-result :inline :offset-assert 48)
|
||||
(best-from-prim basic :offset-assert 132)
|
||||
(best-to-prim basic :offset-assert 136)
|
||||
)
|
||||
:method-count-assert 10
|
||||
:size-assert #x8c
|
||||
:flag-assert #xa0000008c
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype collide-overlap-result (structure)
|
||||
((best-dist float :offset-assert 0)
|
||||
(best-from-prim basic :offset-assert 4)
|
||||
(best-to-prim basic :offset-assert 8)
|
||||
(best-from-tri collide-tri-result :inline :offset-assert 16)
|
||||
)
|
||||
:method-count-assert 10
|
||||
:size-assert #x64
|
||||
:flag-assert #xa00000064
|
||||
(:methods
|
||||
(reset! (_type_) none 9)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod reset! collide-overlap-result ((obj collide-overlap-result))
|
||||
"Reset the result."
|
||||
(set! (-> obj best-dist) 0.000000)
|
||||
(set! (-> obj best-from-prim) #f)
|
||||
(set! (-> obj best-to-prim) #f)
|
||||
(none)
|
||||
)
|
||||
|
||||
(deftype overlaps-others-params (structure)
|
||||
((options uint32 :offset-assert 0)
|
||||
(tlist basic :offset-assert 4)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x8
|
||||
:flag-assert #x900000008
|
||||
)
|
||||
|
||||
;; The engine system is used to link collision checks with processes.
|
||||
(define *collide-hit-by-player-list*
|
||||
(new 'global 'engine 'collide-hit-by-player-list 768)
|
||||
)
|
||||
|
||||
(define *collide-usually-hit-by-player-list*
|
||||
(new 'global 'engine 'collide-usually-hit-by-player-list 256)
|
||||
)
|
||||
|
||||
(define *collide-hit-by-others-list*
|
||||
(new 'global 'engine 'collide-hit-by-others-list 96)
|
||||
)
|
||||
|
||||
(define *collide-player-list* (new 'global 'engine 'collide-player-list 32))
|
||||
|
||||
;; some parts of collide-shape-prim are broken out here.
|
||||
(deftype collide-prim-core (structure)
|
||||
((world-sphere vector :inline :offset-assert 0)
|
||||
(collide-as uint64 :offset-assert 16)
|
||||
(action uint32 :offset-assert 24)
|
||||
(offense int8 :offset-assert 28)
|
||||
(prim-type int8 :offset-assert 29)
|
||||
(extra uint8 2 :offset-assert 30)
|
||||
(quad uint128 2 :offset 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x20
|
||||
:flag-assert #x900000020
|
||||
)
|
||||
|
||||
;; the base class for collision shapes.
|
||||
(deftype collide-shape-prim (basic)
|
||||
((cshape basic :offset-assert 4)
|
||||
(prim-id uint32 :offset-assert 8)
|
||||
(transform-index int8 :offset-assert 12)
|
||||
(prim-core collide-prim-core :inline :offset-assert 16)
|
||||
(local-sphere vector :inline :offset-assert 48)
|
||||
(collide-with uint64 :offset-assert 64)
|
||||
;; overlays of the prim-core
|
||||
(world-sphere vector :inline :offset 16)
|
||||
(collide-as uint64 :offset 32)
|
||||
(action uint32 :offset 40)
|
||||
(offense int8 :offset 44)
|
||||
(prim-type int8 :offset 45)
|
||||
;; overlay of the local-sphere w
|
||||
(radius float :offset 60) ;; meters
|
||||
)
|
||||
:method-count-assert 28
|
||||
:size-assert #x48
|
||||
:flag-assert #x1c00000048
|
||||
(:methods
|
||||
(new (symbol type basic uint int) _type_ 0)
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
(dummy-16 () none 16)
|
||||
(dummy-17 () none 17)
|
||||
(dummy-18 () none 18)
|
||||
(dummy-19 () none 19)
|
||||
(dummy-20 () none 20)
|
||||
(dummy-21 () none 21)
|
||||
(dummy-22 () none 22)
|
||||
(dummy-23 () none 23)
|
||||
(dummy-24 () none 24)
|
||||
(dummy-25 () none 25)
|
||||
(dummy-26 () none 26)
|
||||
(dummy-27 () none 27)
|
||||
)
|
||||
)
|
||||
|
||||
;; sphere collision
|
||||
;; the pat is stored directly here.
|
||||
(deftype collide-shape-prim-sphere (collide-shape-prim)
|
||||
((pat uint32 :offset-assert 72)
|
||||
)
|
||||
:method-count-assert 28
|
||||
:size-assert #x4c
|
||||
:flag-assert #x1c0000004c
|
||||
(:methods
|
||||
(new (symbol type basic uint) _type_ 0)
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
(dummy-16 () none 16)
|
||||
(dummy-17 () none 17)
|
||||
(dummy-18 () none 18)
|
||||
(dummy-19 () none 19)
|
||||
(dummy-20 () none 20)
|
||||
(dummy-21 () none 21)
|
||||
(dummy-22 () none 22)
|
||||
(dummy-23 () none 23)
|
||||
(dummy-24 () none 24)
|
||||
(dummy-25 () none 25)
|
||||
(dummy-26 () none 26)
|
||||
(dummy-27 () none 27)
|
||||
)
|
||||
)
|
||||
|
||||
;; mesh collision
|
||||
;; the pats are stored per tri in the mesh.
|
||||
(deftype collide-shape-prim-mesh (collide-shape-prim)
|
||||
((mesh basic :offset-assert 72)
|
||||
(mesh-id int32 :offset-assert 76)
|
||||
(mesh-cache-id uint64 :offset-assert 80)
|
||||
(mesh-cache-tris uint32 :offset-assert 88)
|
||||
)
|
||||
:method-count-assert 29
|
||||
:size-assert #x5c
|
||||
:flag-assert #x1d0000005c
|
||||
(:methods
|
||||
(new (symbol type basic uint uint) _type_ 0)
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
(dummy-16 () none 16)
|
||||
(dummy-17 () none 17)
|
||||
(dummy-18 () none 18)
|
||||
(dummy-19 () none 19)
|
||||
(dummy-20 () none 20)
|
||||
(dummy-21 () none 21)
|
||||
(dummy-22 () none 22)
|
||||
(dummy-23 () none 23)
|
||||
(dummy-24 () none 24)
|
||||
(dummy-25 () none 25)
|
||||
(dummy-26 () none 26)
|
||||
(dummy-27 () none 27)
|
||||
(dummy-28 () none 28)
|
||||
)
|
||||
)
|
||||
|
||||
;; A group of collide-shape-prim's
|
||||
(deftype collide-shape-prim-group (collide-shape-prim)
|
||||
((num-prims int32 :offset-assert 72)
|
||||
(allocated-prims int32 :offset-assert 76)
|
||||
(prim uint32 1 :offset-assert 80) ;; array of references.
|
||||
)
|
||||
:method-count-assert 30
|
||||
:size-assert #x54
|
||||
:flag-assert #x1e00000054
|
||||
(:methods
|
||||
(new (symbol type basic uint int) _type_ 0)
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
(dummy-16 () none 16)
|
||||
(dummy-17 () none 17)
|
||||
(dummy-18 () none 18)
|
||||
(dummy-19 () none 19)
|
||||
(dummy-20 () none 20)
|
||||
(dummy-21 () none 21)
|
||||
(dummy-22 () none 22)
|
||||
(dummy-23 () none 23)
|
||||
(dummy-24 () none 24)
|
||||
(dummy-25 () none 25)
|
||||
(dummy-26 () none 26)
|
||||
(dummy-27 () none 27)
|
||||
(dummy-28 () none 28)
|
||||
(dummy-29 () none 29)
|
||||
)
|
||||
)
|
||||
|
||||
;; an actual instance of a collision primitive.
|
||||
;; it's based on a transform (q means quaternion, v means with derivatives)
|
||||
(deftype collide-shape (trsqv)
|
||||
((process basic :offset-assert 140)
|
||||
(max-iteration-count uint8 :offset-assert 144)
|
||||
(nav-flags uint8 :offset-assert 145)
|
||||
(pad-byte uint8 2 :offset-assert 146)
|
||||
(pat-ignore-mask uint32 :offset-assert 148)
|
||||
(event-self basic :offset-assert 152)
|
||||
(event-other basic :offset-assert 156)
|
||||
(root-prim basic :offset-assert 160)
|
||||
(riders basic :offset-assert 164)
|
||||
(backup-collide-as uint64 :offset-assert 168)
|
||||
(backup-collide-with uint64 :offset-assert 176)
|
||||
)
|
||||
:method-count-assert 56
|
||||
:size-assert #xb8
|
||||
:flag-assert #x38000000b8
|
||||
(:methods
|
||||
(new (symbol type process int) _type_)
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
(dummy-16 () none 16)
|
||||
(dummy-17 () none 17)
|
||||
(dummy-18 () none 18)
|
||||
(dummy-19 () none 19)
|
||||
(dummy-20 () none 20)
|
||||
(dummy-21 () none 21)
|
||||
(dummy-22 () none 22)
|
||||
(dummy-23 () none 23)
|
||||
(dummy-24 () none 24)
|
||||
(dummy-25 () none 25)
|
||||
(dummy-26 () none 26)
|
||||
(dummy-27 () none 27)
|
||||
(dummy-28 () none 28)
|
||||
(dummy-29 () none 29)
|
||||
(dummy-30 () none 30)
|
||||
(dummy-31 () none 31)
|
||||
(dummy-32 () none 32)
|
||||
(dummy-33 () none 33)
|
||||
(dummy-34 () none 34)
|
||||
(dummy-35 () none 35)
|
||||
(dummy-36 () none 36)
|
||||
(dummy-37 () none 37)
|
||||
(dummy-38 () none 38)
|
||||
(dummy-39 () none 39)
|
||||
(dummy-40 () none 40)
|
||||
(dummy-41 () none 41)
|
||||
(dummy-42 () none 42)
|
||||
(dummy-43 () none 43)
|
||||
(dummy-44 () none 44)
|
||||
(dummy-45 () none 45)
|
||||
(dummy-46 () none 46)
|
||||
(dummy-47 () none 47)
|
||||
(dummy-48 () none 48)
|
||||
(dummy-49 () none 49)
|
||||
(dummy-50 () none 50)
|
||||
(dummy-51 () none 51)
|
||||
(dummy-52 () none 52)
|
||||
(dummy-53 () none 53)
|
||||
(dummy-54 () none 54)
|
||||
(dummy-55 () none 55)
|
||||
)
|
||||
)
|
||||
|
||||
;; More complicated collide-shape?
|
||||
(deftype collide-shape-moving (collide-shape)
|
||||
((rider-time uint64 :offset-assert 184)
|
||||
(rider-last-move vector :inline :offset-assert 192)
|
||||
(trans-old vector 3 :inline :offset-assert 208)
|
||||
(poly-pat uint32 :offset-assert 256)
|
||||
(cur-pat uint32 :offset-assert 260)
|
||||
(ground-pat uint32 :offset-assert 264)
|
||||
(status uint64 :offset-assert 272)
|
||||
(old-status uint64 :offset-assert 280)
|
||||
(prev-status uint64 :offset-assert 288)
|
||||
(reaction-flag uint32 :offset-assert 296)
|
||||
(reaction basic :offset-assert 300)
|
||||
(no-reaction basic :offset-assert 304)
|
||||
(local-normal vector :inline :offset-assert 320)
|
||||
(surface-normal vector :inline :offset-assert 336)
|
||||
(poly-normal vector :inline :offset-assert 352)
|
||||
(ground-poly-normal vector :inline :offset-assert 368)
|
||||
(ground-touch-point vector :inline :offset-assert 384)
|
||||
(shadow-pos vector :inline :offset-assert 400)
|
||||
(ground-impact-vel float :offset-assert 416) ;; meters
|
||||
(surface-angle float :offset-assert 420)
|
||||
(poly-angle float :offset-assert 424)
|
||||
(touch-angle float :offset-assert 428)
|
||||
(coverage float :offset-assert 432)
|
||||
(dynam basic :offset-assert 436)
|
||||
(surf basic :offset-assert 440)
|
||||
)
|
||||
:method-count-assert 65
|
||||
:size-assert #x1bc
|
||||
:flag-assert #x41000001bc
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
(dummy-16 () none 16)
|
||||
(dummy-17 () none 17)
|
||||
(dummy-18 () none 18)
|
||||
(dummy-19 () none 19)
|
||||
(dummy-20 () none 20)
|
||||
(dummy-21 () none 21)
|
||||
(dummy-22 () none 22)
|
||||
(dummy-23 () none 23)
|
||||
(dummy-24 () none 24)
|
||||
(dummy-25 () none 25)
|
||||
(dummy-26 () none 26)
|
||||
(dummy-27 () none 27)
|
||||
(dummy-28 () none 28)
|
||||
(dummy-29 () none 29)
|
||||
(dummy-30 () none 30)
|
||||
(dummy-31 () none 31)
|
||||
(dummy-32 () none 32)
|
||||
(dummy-33 () none 33)
|
||||
(dummy-34 () none 34)
|
||||
(dummy-35 () none 35)
|
||||
(dummy-36 () none 36)
|
||||
(dummy-37 () none 37)
|
||||
(dummy-38 () none 38)
|
||||
(dummy-39 () none 39)
|
||||
(dummy-40 () none 40)
|
||||
(dummy-41 () none 41)
|
||||
(dummy-42 () none 42)
|
||||
(dummy-43 () none 43)
|
||||
(dummy-44 () none 44)
|
||||
(dummy-45 () none 45)
|
||||
(dummy-46 () none 46)
|
||||
(dummy-47 () none 47)
|
||||
(dummy-48 () none 48)
|
||||
(dummy-49 () none 49)
|
||||
(dummy-50 () none 50)
|
||||
(dummy-51 () none 51)
|
||||
(dummy-52 () none 52)
|
||||
(dummy-53 () none 53)
|
||||
(dummy-54 () none 54)
|
||||
(dummy-55 () none 55)
|
||||
(dummy-56 () none 56)
|
||||
(dummy-57 () none 57)
|
||||
(dummy-58 () none 58)
|
||||
(dummy-59 () none 59)
|
||||
(dummy-60 () none 60)
|
||||
(dummy-61 () none 61)
|
||||
(dummy-62 () none 62)
|
||||
(dummy-63 () none 63)
|
||||
(dummy-64 () none 64)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod new collide-shape-prim ((allocation symbol) (type-to-make type) (cshape basic) (prim-id uint) (size-bytes int))
|
||||
"Allocate a new collide-shape-prim. It is expected that children of collide-shape-prim override this.
|
||||
NOTE: uses the size-bytes as the TOTAL size of the structure."
|
||||
(local-vars (v0-0 collide-shape-prim))
|
||||
(set! v0-0 (object-new allocation type-to-make size-bytes))
|
||||
;; not sure what this is.
|
||||
(set! (-> v0-0 cshape) cshape)
|
||||
;; sphere/mesh?
|
||||
(set! (-> v0-0 prim-id) prim-id)
|
||||
(set! (-> v0-0 prim-core action) 0)
|
||||
(set! (-> v0-0 prim-core collide-as) 0)
|
||||
(set! (-> v0-0 collide-with) 0)
|
||||
(set! (-> v0-0 transform-index) -2)
|
||||
(set! (-> v0-0 prim-core offense) 0)
|
||||
(set! (-> v0-0 prim-core prim-type) -2)
|
||||
v0-0
|
||||
)
|
||||
|
||||
(defmethod new collide-shape-prim-sphere ((allocation symbol) (type-to-make type) (cshape basic) (prim-id uint))
|
||||
"Allocate a new sphere primitive"
|
||||
(local-vars (v0-0 collide-shape-prim-sphere))
|
||||
(set! v0-0
|
||||
(the collide-shape-prim-sphere
|
||||
((method-of-type collide-shape-prim new)
|
||||
allocation
|
||||
type-to-make
|
||||
cshape
|
||||
prim-id
|
||||
76
|
||||
)
|
||||
)
|
||||
)
|
||||
(set! (-> v0-0 pat) 16) ;; todo - bitfield
|
||||
(set! (-> v0-0 prim-core prim-type) -1)
|
||||
v0-0
|
||||
)
|
||||
|
||||
(defmethod new collide-shape-prim-mesh ((allocation symbol) (type-to-make type) (cshape basic) (mesh-id uint) (prim-id uint))
|
||||
"Allocate a new mesh primitive"
|
||||
(local-vars (v0-0 collide-shape-prim-mesh))
|
||||
(set! v0-0 (the collide-shape-prim-mesh
|
||||
((method-of-type collide-shape-prim new)
|
||||
allocation
|
||||
type-to-make
|
||||
cshape
|
||||
prim-id
|
||||
92
|
||||
)
|
||||
)
|
||||
)
|
||||
(set! (-> (the-as collide-shape-prim-mesh v0-0) mesh) #f)
|
||||
(set! (-> v0-0 mesh-id) (the int mesh-id))
|
||||
(set! (-> v0-0 mesh-cache-id) 0)
|
||||
(set! (-> v0-0 prim-core prim-type) 1)
|
||||
v0-0
|
||||
)
|
||||
|
||||
(defmethod new collide-shape-prim-group ((allocation symbol) (type-to-make type) (cshape basic) (elt-count uint) (prim-id int))
|
||||
"Allocate a group of primitives."
|
||||
(local-vars (v0-0 collide-shape-prim-group))
|
||||
(set! v0-0 (the collide-shape-prim-group
|
||||
((method-of-type collide-shape-prim new)
|
||||
allocation
|
||||
type-to-make
|
||||
cshape
|
||||
(the-as uint prim-id)
|
||||
;; minus one for the one reference in the type.
|
||||
(the-as int (+ (-> type-to-make size) (shl (+ elt-count -1) 2)))
|
||||
)
|
||||
)
|
||||
)
|
||||
(set! (-> v0-0 allocated-prims) (the int elt-count))
|
||||
(set! (-> v0-0 num-prims) 0)
|
||||
(set! (-> v0-0 prim-core prim-type) 0)
|
||||
(while (nonzero? elt-count)
|
||||
(+! elt-count -1)
|
||||
(set! (-> v0-0 prim elt-count) (the uint #f))
|
||||
(nop!)
|
||||
)
|
||||
v0-0
|
||||
)
|
||||
|
||||
(defmethod length collide-shape-prim-group ((obj collide-shape-prim-group))
|
||||
"How many primitives are used?"
|
||||
(-> obj num-prims)
|
||||
)
|
||||
|
||||
(defmethod asize-of collide-shape-prim-group ((obj collide-shape-prim-group))
|
||||
"How big is this in memory?"
|
||||
(the-as int
|
||||
(+ (-> obj type size) (the-as uint (shl (+ (-> obj allocated-prims) -1) 2)))
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod new collide-shape ((allocation symbol) (type-to-make type) (proc process) (collide-list-kind int))
|
||||
(local-vars (v1-5 symbol) (obj collide-shape))
|
||||
(set! obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))
|
||||
(set! (-> obj process) proc)
|
||||
(set! (-> obj max-iteration-count) 1)
|
||||
(set! (-> obj nav-flags) 1)
|
||||
(set! (-> obj event-self) #f)
|
||||
(set! (-> obj event-other) #f)
|
||||
(set! (-> obj riders) #f)
|
||||
(set! (-> obj root-prim) #f)
|
||||
(set! v1-5 (-> proc type symbol))
|
||||
|
||||
;; add a special ignore mask for the camera vs other things.
|
||||
(if (= v1-5 'camera)
|
||||
(set! (-> obj pat-ignore-mask) 2)
|
||||
(set! (-> obj pat-ignore-mask) 1)
|
||||
)
|
||||
|
||||
;; reset transformation to the origin.
|
||||
(set! (-> obj trans w) 1.000000)
|
||||
(quaternion-identity! (the-as quaternion (-> obj rot)))
|
||||
(vector-identity! (-> obj scale))
|
||||
|
||||
;; add us to right list.
|
||||
(cond
|
||||
((zero? collide-list-kind)
|
||||
(add-connection *collide-hit-by-player-list* proc (the (function object object object object object) #f) obj #f #f)
|
||||
)
|
||||
((= collide-list-kind 1)
|
||||
(add-connection *collide-usually-hit-by-player-list* proc (the (function object object object object object) #f) obj #f #f)
|
||||
)
|
||||
((= collide-list-kind 2)
|
||||
(add-connection *collide-hit-by-others-list* proc (the (function object object object object object) #f) obj #f #f)
|
||||
)
|
||||
((= collide-list-kind 3)
|
||||
(add-connection *collide-player-list* proc (the (function object object object object object) #f) obj #f #f)
|
||||
)
|
||||
(else
|
||||
(format 0 "Unsupported collide-list-enum in collide-shape constructor!~%")
|
||||
)
|
||||
)
|
||||
obj
|
||||
)
|
||||
|
||||
(defmethod new collide-sticky-rider-group ((allocation symbol) (type-to-make type) (arg0 int))
|
||||
(local-vars (v0-0 collide-sticky-rider-group))
|
||||
(set! v0-0
|
||||
(object-new allocation type-to-make
|
||||
(the-as int (+ (-> type-to-make size) (the-as uint (shl (+ arg0 -1) 5))))
|
||||
)
|
||||
)
|
||||
(set! (-> v0-0 allocated-riders) arg0)
|
||||
(set! (-> v0-0 num-riders) 0)
|
||||
v0-0
|
||||
)
|
||||
|
||||
(defmethod length collide-sticky-rider-group ((obj collide-sticky-rider-group))
|
||||
(-> obj num-riders)
|
||||
)
|
||||
|
||||
(defmethod asize-of collide-sticky-rider-group ((obj collide-sticky-rider-group))
|
||||
(the-as int
|
||||
(+ (-> obj type size) (the-as uint (shl (+ (-> obj allocated-riders) -1) 5)))
|
||||
)
|
||||
)
|
||||
|
||||
(define *collide-shape-prim-backgnd*
|
||||
(new 'static 'collide-shape-prim-mesh
|
||||
:cshape #f
|
||||
:prim-core
|
||||
(new 'static 'collide-prim-core
|
||||
:world-sphere
|
||||
(new 'static 'vector :w 204800000.000000)
|
||||
:collide-as #x1
|
||||
:action #x1
|
||||
:offense 4
|
||||
:prim-type 2
|
||||
)
|
||||
:local-sphere
|
||||
(new 'static 'vector :w 204800000.000000)
|
||||
:mesh #f
|
||||
)
|
||||
)
|
||||
|
||||
(define *collide-shape-prim-water*
|
||||
(new 'static 'collide-shape-prim-mesh
|
||||
:cshape #f
|
||||
:prim-core
|
||||
(new 'static 'collide-prim-core
|
||||
:world-sphere
|
||||
(new 'static 'vector :w 204800000.000000)
|
||||
:collide-as #x20
|
||||
:action #x1
|
||||
:offense 4
|
||||
:prim-type 2
|
||||
)
|
||||
:local-sphere
|
||||
(new 'static 'vector :w 204800000.000000)
|
||||
:mesh #f
|
||||
)
|
||||
)
|
||||
|
|
|
@ -5,3 +5,129 @@
|
|||
;; name in dgo: fact-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
;; NOT FINISHED
|
||||
|
||||
(deftype fact-bank (basic)
|
||||
((eco-level-max float :offset-assert 4)
|
||||
(eco-single-inc float :offset-assert 8)
|
||||
(eco-full-inc float :offset-assert 12)
|
||||
(eco-single-timeout uint64 :offset-assert 16) ; usec
|
||||
(eco-full-timeout uint64 :offset-assert 24) ; usec
|
||||
(dummy uint64 :offset-assert 32) ; usec
|
||||
(health-max-default float :offset-assert 40)
|
||||
(health-single-inc float :offset-assert 44)
|
||||
(eco-pill-max-default float :offset-assert 48)
|
||||
(health-small-inc float :offset-assert 52)
|
||||
(buzzer-max-default float :offset-assert 56)
|
||||
(buzzer-single-inc float :offset-assert 60)
|
||||
(suck-bounce-dist float :offset-assert 64) ; meters
|
||||
(suck-suck-dist float :offset-assert 68) ; meters
|
||||
(default-pill-inc float :offset-assert 72)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x4c
|
||||
:flag-assert #x90000004c
|
||||
)
|
||||
|
||||
(define *FACT-bank*
|
||||
(new 'static 'fact-bank
|
||||
:eco-level-max 2.000000
|
||||
:eco-single-inc 1.000000
|
||||
:eco-full-inc 5.000000
|
||||
:eco-single-timeout #x5dc
|
||||
:eco-full-timeout #x1770
|
||||
:dummy #x1194
|
||||
:health-max-default 3.000000
|
||||
:health-single-inc 1.000000
|
||||
:eco-pill-max-default 50.000000
|
||||
:health-small-inc 1.000000
|
||||
:buzzer-max-default 7.000000
|
||||
:buzzer-single-inc 1.000000
|
||||
:suck-bounce-dist 73728.000000
|
||||
:suck-suck-dist 30720.000000
|
||||
)
|
||||
)
|
||||
|
||||
(defun pickup-type->string ((arg0 int))
|
||||
(local-vars (v1-0 int))
|
||||
(set! v1-0 arg0)
|
||||
(cond
|
||||
((= v1-0 9) "eco-pill-random")
|
||||
((= v1-0 8) "buzzer")
|
||||
((= v1-0 7) "eco-pill")
|
||||
((= v1-0 6) "fuel-cell")
|
||||
((= v1-0 5) "money")
|
||||
((= v1-0 4) "eco-green")
|
||||
((= v1-0 3) "eco-blue")
|
||||
((= v1-0 2) "eco-red")
|
||||
((= v1-0 1) "eco-yellow")
|
||||
((zero? v1-0) "none")
|
||||
(else "*unknown*")
|
||||
)
|
||||
)
|
||||
|
||||
(deftype fact-info (basic)
|
||||
((process basic :offset-assert 4)
|
||||
(pickup-type int32 :offset-assert 8)
|
||||
(pickup-amount float :offset-assert 12)
|
||||
(pickup-spawn-amount float :offset-assert 16)
|
||||
(options uint64 :offset-assert 24)
|
||||
(fade-time uint64 :offset-assert 32)
|
||||
)
|
||||
:method-count-assert 12
|
||||
:size-assert #x28
|
||||
:flag-assert #xc00000028
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype fact-info-target (fact-info)
|
||||
((eco-type int32 :offset-assert 40)
|
||||
(eco-level float :offset-assert 44)
|
||||
(eco-pickup-time uint64 :offset-assert 48)
|
||||
(eco-timeout uint64 :offset-assert 56) ;; usec
|
||||
(health float :offset-assert 64)
|
||||
(health-max float :offset-assert 68)
|
||||
(buzzer float :offset-assert 72)
|
||||
(buzzer-max float :offset-assert 76)
|
||||
(eco-pill float :offset-assert 80)
|
||||
(eco-pill-max float :offset-assert 84)
|
||||
(health-pickup-time uint64 :offset-assert 88)
|
||||
(eco-source uint64 :offset-assert 96)
|
||||
(eco-source-time uint64 :offset-assert 104)
|
||||
(money-pickup-time uint64 :offset-assert 112)
|
||||
(buzzer-pickup-time uint64 :offset-assert 120)
|
||||
(fuel-cell-pickup-time uint64 :offset-assert 128)
|
||||
(eco-pill-pickup-time uint64 :offset-assert 136)
|
||||
)
|
||||
:method-count-assert 12
|
||||
:size-assert #x90
|
||||
:flag-assert #xc00000090
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype fact-info-enemy (fact-info)
|
||||
((speed float :offset-assert 40)
|
||||
(idle-distance float :offset-assert 44) ; meters
|
||||
(notice-top float :offset-assert 48) ; meters
|
||||
(notice-bottom float :offset-assert 52) ; meters
|
||||
(cam-horz float :offset-assert 56) ; meters
|
||||
(cam-vert float :offset-assert 60) ; meters
|
||||
(cam-notice-dist float :offset-assert 64) ; meters
|
||||
)
|
||||
:method-count-assert 12
|
||||
:size-assert #x44
|
||||
:flag-assert #xc00000044
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -5,3 +5,12 @@
|
|||
;; name in dgo: quaternion
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
|
||||
(defun quaternion-identity! ((dst quaternion))
|
||||
(rlet ((r0 :class vf))
|
||||
(.xor.vf r0 r0 r0)
|
||||
(.svf dst r0)
|
||||
)
|
||||
(set! (-> dst w) 1.0)
|
||||
dst
|
||||
)
|
||||
|
|
|
@ -5,3 +5,10 @@
|
|||
;; name in dgo: vector
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
(defun vector-identity! ((arg0 vector))
|
||||
(set! (-> arg0 data 0) 1.0)
|
||||
(set! (-> arg0 data 1) 1.0)
|
||||
(set! (-> arg0 data 2) 1.0)
|
||||
(set! (-> arg0 data 3) 1.0)
|
||||
arg0
|
||||
)
|
||||
|
|
|
@ -5,3 +5,22 @@
|
|||
;; name in dgo: trajectory-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
(deftype trajectory (structure)
|
||||
((initial-position vector :inline :offset-assert 0)
|
||||
(initial-velocity vector :inline :offset-assert 16)
|
||||
(time float :offset-assert 32)
|
||||
(gravity float :offset-assert 36) ;; meters
|
||||
)
|
||||
:method-count-assert 16
|
||||
:size-assert #x28
|
||||
:flag-assert #x1000000028
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -5,3 +5,120 @@
|
|||
;; name in dgo: pat-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
(deftype pat-surface (uint32)
|
||||
()
|
||||
:method-count-assert 9
|
||||
:size-assert #x4
|
||||
:flag-assert #x900000004
|
||||
)
|
||||
|
||||
(defmethod inspect pat-surface ((obj pat-surface))
|
||||
(format #t "[~8x] ~A~%" obj 'pat-surface)
|
||||
(format #t "~Tskip: ~D~%" (shr (shl (the-as int obj) 61) 61))
|
||||
(format #t "~Tmode: ~D~%" (shr (shl (the-as int obj) 58) 61))
|
||||
(format #t "~Tmaterial: ~D~%" (shr (shl (the-as int obj) 52) 58))
|
||||
(format #t "~Tcamera: ~D~%" (shr (shl (the-as int obj) 50) 62))
|
||||
(format #t "~Tevent: ~D~%" (shr (shl (the-as int obj) 44) 58))
|
||||
(format #t "~Tnoentity: ~D~%" (shr (shl (the-as int obj) 63) 63))
|
||||
(format #t "~Tnocamera: ~D~%" (shr (shl (the-as int obj) 62) 63))
|
||||
(format #t "~Tnoedge: ~D~%" (shr (shl (the-as int obj) 61) 63))
|
||||
(format #t "~Tnolineofsight: ~D~%" (shr (shl (the-as int obj) 51) 63))
|
||||
obj
|
||||
)
|
||||
|
||||
(defun-debug pat-material->string ((arg0 pat-surface))
|
||||
(local-vars (v1-1 int))
|
||||
(set! v1-1 (shr (shl (the-as int arg0) 52) 58))
|
||||
(cond
|
||||
((= v1-1 22) "neutral")
|
||||
((= v1-1 21) "rotate")
|
||||
((= v1-1 20) "stopproj")
|
||||
((= v1-1 19) "swamp")
|
||||
((= v1-1 18) "tube")
|
||||
((= v1-1 17) "straw")
|
||||
((= v1-1 16) "metal")
|
||||
((= v1-1 15) "dirt")
|
||||
((= v1-1 14) "gravel")
|
||||
((= v1-1 13) "crwood")
|
||||
((= v1-1 12) "lava")
|
||||
((= v1-1 11) "hotcoals")
|
||||
((= v1-1 10) "deepsnow")
|
||||
((= v1-1 9) "snow")
|
||||
((= v1-1 8) "pcmetal")
|
||||
((= v1-1 7) "grass")
|
||||
((= v1-1 6) "wood")
|
||||
((= v1-1 5) "sand")
|
||||
((= v1-1 4) "tar")
|
||||
((= v1-1 3) "waterbottom")
|
||||
((= v1-1 2) "quicksand")
|
||||
((= v1-1 1) "ice")
|
||||
((zero? v1-1) "stone")
|
||||
(else "*unknown*")
|
||||
)
|
||||
)
|
||||
|
||||
(defun-debug pat-mode->string ((arg0 pat-surface))
|
||||
(local-vars (v1-1 int))
|
||||
(set! v1-1 (shr (shl (the-as int arg0) 58) 61))
|
||||
(cond
|
||||
((= v1-1 2) "obstacle")
|
||||
((= v1-1 1) "wall")
|
||||
((zero? v1-1) "ground")
|
||||
(else "*unknown*")
|
||||
)
|
||||
)
|
||||
|
||||
(defun pat-event->string ((arg0 pat-surface))
|
||||
(local-vars (v1-1 int))
|
||||
(set! v1-1 (shr (shl (the-as int arg0) 44) 58))
|
||||
(cond
|
||||
((= v1-1 6) "melt")
|
||||
((= v1-1 5) "burnup")
|
||||
((= v1-1 4) "deadlyup")
|
||||
((= v1-1 3) "burn")
|
||||
((= v1-1 2) "endlessfall")
|
||||
((= v1-1 1) "deadly")
|
||||
((zero? v1-1) "none")
|
||||
(else "*unknown*")
|
||||
)
|
||||
)
|
||||
|
||||
(deftype pat-mode-info (structure)
|
||||
((name basic :offset-assert 0)
|
||||
(wall-angle float :offset-assert 4)
|
||||
(color uint32 :offset-assert 8)
|
||||
(hilite-color uint32 :offset-assert 12)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x10
|
||||
:flag-assert #x900000010
|
||||
)
|
||||
|
||||
(define *pat-mode-info*
|
||||
(new 'static 'inline-array pat-mode-info 4
|
||||
(new 'static 'pat-mode-info
|
||||
:name "ground"
|
||||
:wall-angle (the-as float #x3e4ccccd)
|
||||
:color #x4000007f
|
||||
:hilite-color #x800000ff
|
||||
)
|
||||
(new 'static 'pat-mode-info
|
||||
:name "wall"
|
||||
:wall-angle 2.000000
|
||||
:color #x407f0000
|
||||
:hilite-color #x80ff0000
|
||||
)
|
||||
(new 'static 'pat-mode-info
|
||||
:name "obstacle"
|
||||
:wall-angle (the-as float #x3f51eb85)
|
||||
:color #x407f007f
|
||||
:hilite-color #x80ff00ff
|
||||
)
|
||||
(new 'static 'pat-mode-info
|
||||
:name "pole"
|
||||
:wall-angle 2.000000
|
||||
:color #x40007f7f
|
||||
:hilite-color #x8000ffff
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,3 +5,135 @@
|
|||
;; name in dgo: smush-control-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
;; A "smush-control" generates a damped sinusoidal floating point value.
|
||||
;; - on each full period, the amplitude and period are changed (multiplied)
|
||||
;; - there is a maximum duration.
|
||||
;; - the amplitude is additionally linearly scaled to go to zero over the duration.
|
||||
|
||||
(deftype smush-control (structure)
|
||||
((start-time uint64 :offset-assert 0)
|
||||
(period float :offset-assert 8)
|
||||
(duration float :offset-assert 12)
|
||||
(amp float :offset-assert 16)
|
||||
(damp-amp float :offset-assert 20)
|
||||
(damp-period float :offset-assert 24) ;; set a negative value here to flag as die on next update
|
||||
(ticks float :offset-assert 28)
|
||||
)
|
||||
:method-count-assert 15
|
||||
:size-assert #x20
|
||||
:flag-assert #xf00000020
|
||||
(:methods
|
||||
(set-zero! (_type_) _type_ 9)
|
||||
(update! (_type_) float 10)
|
||||
(get-no-update (_type_) float 11)
|
||||
(activate! (_type_ float int int float float float) _type_ 12)
|
||||
(nonzero-amplitude? (_type_) symbol 13)
|
||||
(die-on-next-update! (_type_) _type_ 14)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod nonzero-amplitude? smush-control ((obj smush-control))
|
||||
(!= (-> obj amp) 0.000000)
|
||||
)
|
||||
|
||||
(defmethod set-zero! smush-control ((obj smush-control))
|
||||
(set! (-> obj period) 0.000000)
|
||||
(set! (-> obj duration) 0.000000)
|
||||
(set! (-> obj amp) 0.000000)
|
||||
(set! (-> obj damp-amp) 0.000000)
|
||||
(set! (-> obj damp-period) 0.000000)
|
||||
(set! (-> obj ticks) 0.000000)
|
||||
obj
|
||||
)
|
||||
|
||||
(defmethod update! smush-control ((obj smush-control))
|
||||
"Run the smush control and return the result. Updates the internal state."
|
||||
(local-vars (period float) (time-since-period-start float) (time-since-start float))
|
||||
(cond
|
||||
((!= (-> obj amp) 0.000000)
|
||||
(set! time-since-start
|
||||
(the float (- (-> *display* base-frame-counter) (-> obj start-time)))
|
||||
)
|
||||
(set! period (-> obj period))
|
||||
;; use float to int rounding to figure out offset into the current period.
|
||||
(set! time-since-period-start (- time-since-start
|
||||
(* (the float (the int (/ time-since-start period))) period))
|
||||
)
|
||||
;; we completed a new period!
|
||||
(when (>= (- time-since-start (-> obj ticks)) (-> obj period))
|
||||
;; once per period updates of amp/period
|
||||
(set! (-> obj amp) (* (-> obj amp) (-> obj damp-amp)))
|
||||
(set! (-> obj period) (* (-> obj period) (-> obj damp-period)))
|
||||
;; store the ticks that we did this on
|
||||
(set! (-> obj ticks) time-since-start)
|
||||
;; you can set damp-period to a negative number to indicate
|
||||
;; that it should die on the next update. Do that here.
|
||||
(if (< (-> obj damp-period) 0.000000)
|
||||
(set-zero! obj)
|
||||
)
|
||||
)
|
||||
|
||||
;; absolute duraction check
|
||||
(if (>= time-since-start (-> obj duration))
|
||||
(set-zero! obj)
|
||||
)
|
||||
;; sine term multiplied by amplitude, and scaled by how much is left to go.
|
||||
(* (sin (/ (* 65536.000000 time-since-period-start) (-> obj period)))
|
||||
(* (-> obj amp)
|
||||
(/ (- (-> obj duration) time-since-start) (-> obj duration)))
|
||||
)
|
||||
)
|
||||
;; amplitude = 0, die.
|
||||
(else 0.000000)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod get-no-update smush-control ((obj smush-control))
|
||||
"Get the value, but don't update internal state"
|
||||
(local-vars (f0-2 float) (f0-4 float) (f30-0 float))
|
||||
(cond
|
||||
((!= (-> obj amp) 0.000000)
|
||||
(set! f30-0
|
||||
(the float (- (-> *display* base-frame-counter) (-> obj start-time)))
|
||||
)
|
||||
(set! f0-2 (-> obj period))
|
||||
(set! f0-4 (- f30-0 (* (the float (the int (/ f30-0 f0-2))) f0-2)))
|
||||
(* (sin (/ (* 65536.000000 f0-4) (-> obj period)))
|
||||
(* (-> obj amp) (/ (- (-> obj duration) f30-0) (-> obj duration)))
|
||||
)
|
||||
)
|
||||
(else 0.000000)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod die-on-next-update! smush-control ((obj smush-control))
|
||||
"On the next call to update!, zero everything.
|
||||
Calls to get-no-update will still work."
|
||||
(when (!= (-> obj amp) 0.000000)
|
||||
(set! (-> obj damp-period) -1.000000)
|
||||
)
|
||||
obj
|
||||
)
|
||||
|
||||
(defmethod activate! smush-control ((obj smush-control)
|
||||
(arg0 float)
|
||||
(arg1 int)
|
||||
(arg2 int)
|
||||
(arg3 float)
|
||||
(arg4 float)
|
||||
(arg5 float)
|
||||
)
|
||||
"Activate the smush! This only activates if the ongoing smush is mostly done."
|
||||
(when (>= (fabs (* 0.2 (-> obj amp)))
|
||||
(fabs (get-no-update obj))
|
||||
)
|
||||
(set! (-> obj amp) arg0)
|
||||
(set! (-> obj period) (the float arg1))
|
||||
(set! (-> obj duration) (the float arg2))
|
||||
(set! (-> obj damp-amp) arg3)
|
||||
(set! (-> obj damp-period) arg4)
|
||||
(set! (-> obj ticks) 0.000000)
|
||||
(set! (-> obj start-time) (-> *display* base-frame-counter))
|
||||
)
|
||||
obj
|
||||
)
|
||||
|
|
|
@ -5,3 +5,154 @@
|
|||
;; name in dgo: sync-info-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
(deftype sync-info (structure)
|
||||
((offset float :offset-assert 0)
|
||||
(period uint32 :offset-assert 4)
|
||||
)
|
||||
:method-count-assert 18
|
||||
:size-assert #x8
|
||||
:flag-assert #x1200000008
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
(dummy-16 () none 16)
|
||||
(dummy-17 () none 17)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype sync-info-eased (sync-info)
|
||||
((tlo float :offset-assert 8)
|
||||
(thi float :offset-assert 12)
|
||||
(ylo float :offset-assert 16)
|
||||
(m2 float :offset-assert 20)
|
||||
(yend float :offset-assert 24)
|
||||
)
|
||||
:method-count-assert 18
|
||||
:size-assert #x1c
|
||||
:flag-assert #x120000001c
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
(dummy-16 () none 16)
|
||||
(dummy-17 () none 17)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype sync-info-paused (sync-info)
|
||||
((pause-after-out float :offset-assert 8)
|
||||
(pause-after-in float :offset-assert 12)
|
||||
)
|
||||
:method-count-assert 18
|
||||
:size-assert #x10
|
||||
:flag-assert #x1200000010
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
(dummy-16 () none 16)
|
||||
(dummy-17 () none 17)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype delayed-rand-float (structure)
|
||||
((min-time int32 :offset-assert 0)
|
||||
(max-time int32 :offset-assert 4)
|
||||
(max-val float :offset-assert 8)
|
||||
(timer int32 :offset-assert 12)
|
||||
(start-time uint64 :offset-assert 16)
|
||||
(value float :offset-assert 24)
|
||||
)
|
||||
:method-count-assert 11
|
||||
:size-assert #x1c
|
||||
:flag-assert #xb0000001c
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype oscillating-float (structure)
|
||||
((value float :offset-assert 0)
|
||||
(target float :offset-assert 4)
|
||||
(vel float :offset-assert 8)
|
||||
(max-vel float :offset-assert 12)
|
||||
(damping float :offset-assert 16)
|
||||
(accel float :offset-assert 20)
|
||||
)
|
||||
:method-count-assert 11
|
||||
:size-assert #x18
|
||||
:flag-assert #xb00000018
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype bouncing-float (structure)
|
||||
((osc oscillating-float :inline :offset-assert 0)
|
||||
(max-value float :offset-assert 24)
|
||||
(min-value float :offset-assert 28)
|
||||
(elasticity float :offset-assert 32)
|
||||
(state int32 :offset-assert 36)
|
||||
)
|
||||
:method-count-assert 13
|
||||
:size-assert #x28
|
||||
:flag-assert #xd00000028
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype delayed-rand-vector (structure)
|
||||
((min-time int32 :offset-assert 0)
|
||||
(max-time int32 :offset-assert 4)
|
||||
(xz-max float :offset-assert 8)
|
||||
(y-max float :offset-assert 12)
|
||||
(timer int32 :offset-assert 16)
|
||||
(start-time uint64 :offset-assert 24)
|
||||
(value vector :inline :offset-assert 32)
|
||||
)
|
||||
:method-count-assert 13
|
||||
:size-assert #x30
|
||||
:flag-assert #xd00000030
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype oscillating-vector (structure)
|
||||
((value vector :inline :offset-assert 0)
|
||||
(target vector :inline :offset-assert 16)
|
||||
(vel vector :inline :offset-assert 32)
|
||||
(max-vel float :offset-assert 48)
|
||||
(damping float :offset-assert 52)
|
||||
(accel float :offset-assert 56)
|
||||
)
|
||||
:method-count-assert 11
|
||||
:size-assert #x3c
|
||||
:flag-assert #xb0000003c
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue