mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
af52341050
* make `anim-tester` decompile * add the anon behaviors * fix tests
113 lines
2.4 KiB
Common Lisp
113 lines
2.4 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: glist-h.gc
|
|
;; name in dgo: glist-h
|
|
;; dgos: GAME, ENGINE
|
|
|
|
|
|
;; Very very weird linked list system.
|
|
;; TODO add examples because this is extremely confusing.
|
|
|
|
(when *debug-segment*
|
|
|
|
(deftype glst-node (structure)
|
|
((next glst-node :offset-assert 0)
|
|
(prev glst-node :offset-assert 4)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x8
|
|
:flag-assert #x900000008
|
|
)
|
|
|
|
(deftype glst-named-node (glst-node)
|
|
((privname string :offset-assert 8)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #xc
|
|
:flag-assert #x90000000c
|
|
)
|
|
|
|
(deftype glst-list (structure)
|
|
((head glst-node :offset-assert 0)
|
|
(tail glst-node :offset-assert 4)
|
|
(tailpred glst-node :offset-assert 8)
|
|
(numelem int32 :offset-assert 12)
|
|
)
|
|
:allow-misaligned
|
|
:method-count-assert 9
|
|
:size-assert #x10
|
|
:flag-assert #x900000010
|
|
)
|
|
|
|
|
|
;; FUN FACT! The "defun" macro only checks if the first item in the function body is a
|
|
;; string (the docstring), but because these functions were marked as inline (or debug)
|
|
;; BEFORE the docstring, they end up being considered part of the body and the compiled output!
|
|
;; This amusing mistake is reproduced here.
|
|
|
|
(defun-debug glst-next ((node glst-node))
|
|
(declare (inline))
|
|
"return the next node in the list"
|
|
|
|
(-> node next)
|
|
)
|
|
|
|
(defun-debug glst-prev ((node glst-node))
|
|
(declare (inline))
|
|
"return the previous node in the list"
|
|
|
|
(-> node prev)
|
|
)
|
|
|
|
(defun-debug glst-head ((list glst-list))
|
|
(declare (inline))
|
|
"return the start of the list"
|
|
|
|
(-> list head)
|
|
)
|
|
|
|
(defun-debug glst-tail ((list glst-list))
|
|
(declare (inline))
|
|
"return the tail of the list"
|
|
|
|
(-> list tailpred)
|
|
)
|
|
|
|
(defun-debug glst-end-of-list? ((node glst-node))
|
|
(declare (inline))
|
|
"is this node the end of the list. #t = end"
|
|
|
|
(not (-> node next))
|
|
)
|
|
|
|
(defun-debug glst-start-of-list? ((node glst-node))
|
|
(declare (inline))
|
|
"is this node the start of the list. #t = start"
|
|
|
|
(not (-> node prev))
|
|
)
|
|
|
|
(defun-debug glst-empty? ((list glst-list))
|
|
(declare (inline))
|
|
"is the list empty, #t = empty"
|
|
|
|
(= (-> list tailpred) (&-> list head))
|
|
)
|
|
|
|
(defun-debug glst-node-name ((node glst-named-node))
|
|
"Return the name of the node"
|
|
|
|
(-> node privname)
|
|
)
|
|
|
|
(defun-debug glst-set-name! ((node glst-named-node) (name string))
|
|
"Set the name of the node"
|
|
(declare (inline))
|
|
|
|
(set! (-> node privname) name)
|
|
)
|
|
|
|
)
|
|
|