jak-project/goal_src/jak2/engine/util/glist.gc
Tyler Wilding d264779173
d/jak2: finish glist | glist-h | camera | cam-interface | cam-states-dbg | cam-combiner | cam-debug | cam-start (#1829)
* d/jak2: finish `glist` and `glist-h` partially done `time-of-day`

* d/jak2: finish `camera` and `cam-interface`

* d/jak2: partially finish `cam-master` `cam-states`, and `cam-update` finish `cam-states-dbg` `cam-combiner` `cam-debug` and `cam-start`

* tests: update ref tests

* scripts: add scripts to automatically update gsrc files

* d/jak2: update gsrc
2022-08-31 19:22:47 -04:00

220 lines
6.1 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: glist.gc
;; name in dgo: glist
;; dgos: ENGINE, GAME
;; DECOMP BEGINS
;; this file is debug only
(declare-file (debug))
(when *debug-segment*
;; definition for function glst-num-elements
(defun glst-num-elements ((arg0 glst-list))
"Returns `numelem` from the provided [[glst-list]]"
(-> arg0 numelem)
)
;; definition for function glst-remove
(defun glst-remove ((arg0 glst-list) (arg1 glst-node))
"Removes the provided [[glst-node]] from the list and returns it back"
(let ((v1-0 arg1))
"return the previous node in the list"
(let ((v1-1 (-> v1-0 prev))
(a2-1 arg1)
)
"return the next node in the list"
(let ((a2-2 (-> a2-1 next)))
(set! (-> v1-1 next) a2-2)
(set! (-> a2-2 prev) v1-1)
)
)
)
(+! (-> arg0 numelem) -1)
arg1
)
;; definition for function glst-remove-tail
(defun glst-remove-tail ((arg0 glst-list))
"Removes the tail of the [[glst-list]], returns #f if the list is empty, otherwise returns the [[glst-node]] that was removed"
(let ((v1-0 arg0))
"return the tail of the list"
(let* ((a1-1 (-> v1-0 tailpred))
(v1-1 a1-1)
)
"is this node the start of the list. #t = start"
(if (not (not (-> v1-1 prev)))
(glst-remove arg0 a1-1)
(the-as glst-node #f)
)
)
)
)
;; definition for function glst-remove-head
(defun glst-remove-head ((arg0 glst-list))
"Removes the head of the [[glst-list]], returns #f if the list is empty, otherwise returns the [[glst-node]] that was removed"
(let ((v1-0 arg0))
"return the start of the list"
(let* ((a1-1 (-> v1-0 head))
(v1-1 a1-1)
)
"is this node the end of the list. #t = end"
(if (not (not (-> v1-1 next)))
(glst-remove arg0 a1-1)
(the-as glst-node #f)
)
)
)
)
;; definition for function glst-insert-before
(defun glst-insert-before ((list glst-list) (curr glst-node) (new glst-node))
"Inserts `new` before `curr`, returns the newly inserted [[glst-node]]"
(let ((v1-0 curr))
"return the previous node in the list"
(let ((v1-1 (-> v1-0 prev)))
(set! (-> new prev) v1-1)
(set! (-> new next) curr)
(set! (-> v1-1 next) new)
)
)
(set! (-> curr prev) new)
(+! (-> list numelem) 1)
new
)
;; definition for function glst-insert-after
(defun glst-insert-after ((list glst-list) (curr glst-node) (new glst-node))
"Inserts `new` after `curr`, returns the newly inserted [[glst-node]]"
(let ((v1-0 curr))
"return the next node in the list"
(let ((v1-1 (-> v1-0 next)))
(set! (-> new prev) curr)
(set! (-> new next) v1-1)
(set! (-> v1-1 prev) new)
)
)
(set! (-> curr next) new)
(+! (-> list numelem) 1)
new
)
;; definition for function glst-add-tail
(defun glst-add-tail ((arg0 glst-list) (arg1 glst-node))
"Adds the provided [[glst-node]] to the end of the [[glst-list]]"
(glst-insert-before arg0 (the-as glst-node (&-> arg0 tail)) arg1)
arg1
)
;; definition for function glst-add-head
(defun glst-add-head ((arg0 glst-list) (arg1 glst-node))
"Adds the provided [[glst-node]] to the beginning of the [[glst-list]]"
(glst-insert-after arg0 (the-as glst-node arg0) arg1)
arg1
)
;; definition for function glst-init-list!
(defun glst-init-list! ((arg0 glst-list))
"Clears the provided [[glst-list]]"
(set! (-> arg0 head) (the-as glst-node (&-> arg0 tail)))
(set! (-> arg0 tail) #f)
(set! (-> arg0 tailpred) (the-as glst-node (&-> arg0 head)))
(set! (-> arg0 numelem) 0)
arg0
)
;; definition for function glst-find-node-by-name
(defun glst-find-node-by-name ((arg0 glst-list) (arg1 string))
"Returns the [[glst-named-node]] by examining it's `privname`, returns #f if nothing is found"
(let ((v1-0 arg0))
"return the start of the list"
(let ((s5-0 (-> v1-0 head)))
(while (let ((v1-6 s5-0))
"is this node the end of the list. #t = end"
(not (not (-> v1-6 next)))
)
(if (name= (-> (the-as glst-named-node s5-0) privname) arg1)
(return s5-0)
)
"return the next node in the list"
(set! s5-0 (-> s5-0 next))
)
)
)
(the-as glst-node #f)
)
;; definition for function glst-get-node-by-index
(defun glst-get-node-by-index ((arg0 glst-list) (arg1 int))
"Returns the [[glst-node]] by index, returns #f if nothing is found"
(when (and (< arg1 (glst-num-elements arg0)) (>= arg1 0))
"return the start of the list"
(let ((v1-3 (-> arg0 head)))
(dotimes (a0-3 arg1)
(nop!)
(nop!)
(nop!)
(nop!)
"return the next node in the list"
(set! v1-3 (-> v1-3 next))
)
(return v1-3)
)
)
(the-as glst-node #f)
)
;; definition for function glst-length-of-longest-name
(defun glst-length-of-longest-name ((arg0 glst-list))
"Returns the length of the longest `privname`"
(let ((gp-0 0))
(let ((v1-0 arg0))
"return the start of the list"
(let ((s5-0 (-> v1-0 head)))
(while (let ((v1-6 s5-0))
"is this node the end of the list. #t = end"
(not (not (-> v1-6 next)))
)
(let ((v1-3 (length (-> (the-as glst-named-node s5-0) privname))))
(if (< gp-0 v1-3)
(set! gp-0 v1-3)
)
)
"return the next node in the list"
(set! s5-0 (-> s5-0 next))
)
)
)
gp-0
)
)
;; definition for function glst-get-node-index
(defun glst-get-node-index ((arg0 glst-list) (arg1 glst-node))
"Given a [[glst-node]] return it's position in the [[glst-list]]"
(let ((v1-0 0))
"return the start of the list"
(let ((a0-1 (-> arg0 head)))
(while (let ((a2-3 a0-1))
"is this node the end of the list. #t = end"
(not (not (-> a2-3 next)))
)
(if (= a0-1 arg1)
(return v1-0)
)
(+! v1-0 1)
"return the next node in the list"
(set! a0-1 (-> a0-1 next))
)
)
)
-1
)
)