mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
decomp: generic
(#611)
* decomp: Fix casting issue with uint64's from static data * decomp: `generic` * add forward declaration Co-authored-by: water111 <48171810+water111@users.noreply.github.com>
This commit is contained in:
parent
4f8403d8e6
commit
87961bdb3b
|
@ -642,8 +642,10 @@ Form* LoadVarOp::get_load_src(FormPool& pool, const Env& env) const {
|
|||
u64 value;
|
||||
memcpy(&value, &word0.data, 4);
|
||||
memcpy(((u8*)&value) + 4, &word1.data, 4);
|
||||
return pool.alloc_single_element_form<SimpleAtomElement>(
|
||||
nullptr, SimpleAtom::make_int_constant(value));
|
||||
return pool.alloc_single_element_form<CastElement>(
|
||||
nullptr, TypeSpec("uint"),
|
||||
pool.alloc_single_element_form<SimpleAtomElement>(
|
||||
nullptr, SimpleAtom::make_int_constant(value)));
|
||||
}
|
||||
|
||||
// is it a constant bitfield?
|
||||
|
@ -797,4 +799,4 @@ FormElement* StackSpillStoreOp::get_as_form(FormPool& pool, const Env& env) cons
|
|||
|
||||
return pool.alloc_element<StackSpillStoreElement>(m_value, m_size, m_offset, cast_type);
|
||||
}
|
||||
} // namespace decompiler
|
||||
} // namespace decompiler
|
||||
|
|
|
@ -547,7 +547,7 @@ std::vector<Form*> compact_nested_logiors(GenericElement* input, const Env&) {
|
|||
while (next) {
|
||||
assert(next->elts().size() == 2);
|
||||
result.push_back(next->elts().at(1));
|
||||
auto next_next = next->elts().at(0);
|
||||
auto next_next = strip_int_or_uint_cast(next->elts().at(0));
|
||||
next = next_next->try_as_element<GenericElement>();
|
||||
if (!next || !next->op().is_fixed(FixedOperatorKind::LOGIOR)) {
|
||||
result.push_back(next_next);
|
||||
|
@ -778,4 +778,4 @@ Form* cast_to_bitfield_enum(const EnumType* type_info, FormPool& pool, const Env
|
|||
return pool.alloc_single_element_form<GenericElement>(nullptr, oper, form_elts);
|
||||
}
|
||||
|
||||
} // namespace decompiler
|
||||
} // namespace decompiler
|
||||
|
|
|
@ -520,10 +520,6 @@
|
|||
["L10", "debug-sphere-table", true]
|
||||
],
|
||||
|
||||
"generic": [
|
||||
["L11", "(array generic-dma-foreground-sink)", true],
|
||||
["L12", "uint64", true]
|
||||
],
|
||||
"entity": [
|
||||
["L324", "float", true]
|
||||
],
|
||||
|
@ -583,6 +579,12 @@
|
|||
["L229", "uint64", true]
|
||||
],
|
||||
|
||||
"generic": [
|
||||
["L10", "generic-dma-foreground-sink", true],
|
||||
["L11", "(array generic-dma-foreground-sink)", true],
|
||||
["L12", "uint64", true]
|
||||
],
|
||||
|
||||
"entity-table": [
|
||||
["L8", "(array entity-info)", true]
|
||||
]
|
||||
|
|
|
@ -686,5 +686,8 @@
|
|||
],
|
||||
"drawable-frag-count": [
|
||||
[[14, 20], "s5", "drawable-group"]
|
||||
],
|
||||
"generic-init-buffers": [
|
||||
[[39, 44], "v1", "dma-packet"]
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2033,7 +2033,11 @@
|
|||
"v1-11":["v1-11", "dma-packet"]
|
||||
}
|
||||
},
|
||||
"add-debug-light": { "vars": { "s1-0":["s1-0", "rgba"]} }
|
||||
|
||||
|
||||
"add-debug-light": { "vars": { "s1-0":["s1-0", "rgba"]} },
|
||||
|
||||
"generic-init-buffers": {
|
||||
"vars": {
|
||||
"v1-8": ["packet", "dma-packet"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,3 +5,150 @@
|
|||
;; name in dgo: generic
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
; This is actually defined in generic-vu1.gc but this file builds first
|
||||
(define-extern generic-init-buf (function dma-buffer int uint none))
|
||||
|
||||
;; definition for symbol *generic-foreground-sinks*, type (array generic-dma-foreground-sink)
|
||||
(define
|
||||
*generic-foreground-sinks*
|
||||
(the-as (array generic-dma-foreground-sink)
|
||||
(new
|
||||
'static
|
||||
'boxed-array
|
||||
:type generic-dma-foreground-sink :length 0 :allocated-length 9
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 0)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level0 foreground-sink-group 0 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 1)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level0 foreground-sink-group 1 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 2)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level1 foreground-sink-group 0 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 3)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level1 foreground-sink-group 1 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 4)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level-default foreground-sink-group 0 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 5)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level-default foreground-sink-group 1 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 6)
|
||||
(new 'static 'generic-dma-foreground-sink :bucket 30)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 7)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level0 foreground-sink-group 2 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 8)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level1 foreground-sink-group 2 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function generic-dma-foreground-sink-init
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defun generic-dma-foreground-sink-init ((arg0 generic-dma-foreground-sink))
|
||||
(set! (-> arg0 state gifbuf-adr) (the-as uint 837))
|
||||
(set! (-> arg0 state inbuf-adr) (the-as uint 9))
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for function generic-init-buffers
|
||||
(defun generic-init-buffers ()
|
||||
(vu-lights-default! *default-lights*)
|
||||
(let ((gp-0 #x10001c0)
|
||||
(s5-0 (the-as uint #x1010001c0))
|
||||
)
|
||||
(dotimes (s4-0 9)
|
||||
(let ((s1-0 (-> *generic-foreground-sinks* s4-0)))
|
||||
(when s1-0
|
||||
(let* ((s3-0 (-> s1-0 bucket))
|
||||
(s0-0
|
||||
(-> *display* frames (-> *display* on-screen) frame global-buf)
|
||||
)
|
||||
(s2-0 (-> s0-0 base))
|
||||
)
|
||||
(if (>= s4-0 7)
|
||||
(generic-init-buf s0-0 1 s5-0)
|
||||
(generic-init-buf s0-0 1 (the-as uint gp-0))
|
||||
)
|
||||
(generic-dma-foreground-sink-init s1-0)
|
||||
(let ((a3-0 (-> s0-0 base)))
|
||||
(let ((packet (the-as dma-packet (-> s0-0 base))))
|
||||
(set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next)))
|
||||
(set! (-> packet vif0) (new 'static 'vif-tag))
|
||||
(set! (-> packet vif1) (new 'static 'vif-tag))
|
||||
(set! (-> s0-0 base) (&+ (the-as pointer packet) 16))
|
||||
)
|
||||
(dma-bucket-insert-tag
|
||||
(-> *display* frames (-> *display* on-screen) frame bucket-group)
|
||||
s3-0
|
||||
s2-0
|
||||
(the-as (pointer dma-tag) a3-0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
#f
|
||||
)
|
||||
|
||||
;; definition for function generic-sink
|
||||
(defun generic-sink ((arg0 int))
|
||||
(-> *generic-foreground-sinks* arg0)
|
||||
)
|
||||
|
|
|
@ -264,7 +264,7 @@
|
|||
(defun clear-vu0-mem ()
|
||||
(let ((v1-0 (the-as (pointer uint32) #x11004000)))
|
||||
(dotimes (a0-0 1024)
|
||||
(set! (-> v1-0 a0-0) #xabadbeef)
|
||||
(set! (-> v1-0 a0-0) (the-as uint #xabadbeef))
|
||||
)
|
||||
)
|
||||
(let ((v0-0 0))
|
||||
|
@ -277,7 +277,7 @@
|
|||
(defun clear-vu1-mem ()
|
||||
(let ((v1-0 (the-as (pointer uint32) #x1100c000)))
|
||||
(dotimes (a0-0 4096)
|
||||
(set! (-> v1-0 a0-0) #xabadbeef)
|
||||
(set! (-> v1-0 a0-0) (the-as uint #xabadbeef))
|
||||
)
|
||||
)
|
||||
(let ((v0-0 0))
|
||||
|
|
|
@ -100,7 +100,3 @@
|
|||
(defun get-aspect-ratio ()
|
||||
(-> *setting-control* current aspect-ratio)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
151
test/decompiler/reference/engine/gfx/generic/generic_REF.gc
Normal file
151
test/decompiler/reference/engine/gfx/generic/generic_REF.gc
Normal file
|
@ -0,0 +1,151 @@
|
|||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for symbol *generic-foreground-sinks*, type (array generic-dma-foreground-sink)
|
||||
(define
|
||||
*generic-foreground-sinks*
|
||||
(the-as (array generic-dma-foreground-sink)
|
||||
(new
|
||||
'static
|
||||
'boxed-array
|
||||
:type generic-dma-foreground-sink :length 0 :allocated-length 9
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 0)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level0 foreground-sink-group 0 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 1)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level0 foreground-sink-group 1 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 2)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level1 foreground-sink-group 0 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 3)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level1 foreground-sink-group 1 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 4)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level-default foreground-sink-group 0 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 5)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level-default foreground-sink-group 1 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 6)
|
||||
(new 'static 'generic-dma-foreground-sink :bucket 30)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 7)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level0 foreground-sink-group 2 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set!
|
||||
(-> *generic-foreground-sinks* 8)
|
||||
(the-as
|
||||
generic-dma-foreground-sink
|
||||
(-> *level* level1 foreground-sink-group 2 merc-sink)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function generic-dma-foreground-sink-init
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defun generic-dma-foreground-sink-init ((arg0 generic-dma-foreground-sink))
|
||||
(set! (-> arg0 state gifbuf-adr) (the-as uint 837))
|
||||
(set! (-> arg0 state inbuf-adr) (the-as uint 9))
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for function generic-init-buffers
|
||||
(defun generic-init-buffers ()
|
||||
(vu-lights-default! *default-lights*)
|
||||
(let ((gp-0 #x10001c0)
|
||||
(s5-0 (the-as uint #x1010001c0))
|
||||
)
|
||||
(dotimes (s4-0 9)
|
||||
(let ((s1-0 (-> *generic-foreground-sinks* s4-0)))
|
||||
(when s1-0
|
||||
(let* ((s3-0 (-> s1-0 bucket))
|
||||
(s0-0
|
||||
(-> *display* frames (-> *display* on-screen) frame global-buf)
|
||||
)
|
||||
(s2-0 (-> s0-0 base))
|
||||
)
|
||||
(if (>= s4-0 7)
|
||||
(generic-init-buf s0-0 1 s5-0)
|
||||
(generic-init-buf s0-0 1 (the-as uint gp-0))
|
||||
)
|
||||
(generic-dma-foreground-sink-init s1-0)
|
||||
(let ((a3-0 (-> s0-0 base)))
|
||||
(let ((packet (the-as dma-packet (-> s0-0 base))))
|
||||
(set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next)))
|
||||
(set! (-> packet vif0) (new 'static 'vif-tag))
|
||||
(set! (-> packet vif1) (new 'static 'vif-tag))
|
||||
(set! (-> s0-0 base) (&+ (the-as pointer packet) 16))
|
||||
)
|
||||
(dma-bucket-insert-tag
|
||||
(-> *display* frames (-> *display* on-screen) frame bucket-group)
|
||||
s3-0
|
||||
s2-0
|
||||
(the-as (pointer dma-tag) a3-0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
#f
|
||||
)
|
||||
|
||||
;; definition for function generic-sink
|
||||
(defun generic-sink ((arg0 int))
|
||||
(-> *generic-foreground-sinks* arg0)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
|
@ -410,7 +410,7 @@
|
|||
;; INFO: Return type mismatch int vs none.
|
||||
(defun destroy-mem ((arg0 (pointer uint32)) (arg1 (pointer uint32)))
|
||||
(while (< (the-as int arg0) (the-as int arg1))
|
||||
(set! (-> arg0 0) #xffffffff)
|
||||
(set! (-> arg0 0) (the-as uint #xffffffff))
|
||||
(set! arg0 (&-> arg0 1))
|
||||
)
|
||||
(let ((v0-0 0))
|
||||
|
|
|
@ -160,7 +160,10 @@
|
|||
;; definition for method 5 of type type
|
||||
;; INFO: Return type mismatch uint vs int.
|
||||
(defmethod asize-of type ((obj type))
|
||||
(the-as int (logand #xfffffff0 (+ (* (-> obj allocated-length) 4) 43)))
|
||||
(the-as
|
||||
int
|
||||
(logand (the-as uint #xfffffff0) (+ (* (-> obj allocated-length) 4) 43))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function basic-type?
|
||||
|
|
Loading…
Reference in a new issue