mirror of
https://github.com/open-goal/jak-project
synced 2026-08-06 18:03:30 -04:00
a3e004f475
Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
189 lines
4.5 KiB
Common Lisp
189 lines
4.5 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))
|
|
|
|
(defun glst-num-elements ((arg0 glst-list))
|
|
(-> arg0 numelem)
|
|
)
|
|
|
|
(defun glst-remove ((arg0 glst-list) (arg1 glst-node))
|
|
(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
|
|
)
|
|
|
|
(defun glst-remove-tail ((arg0 glst-list))
|
|
(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)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defun glst-remove-head ((arg0 glst-list))
|
|
(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)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defun glst-insert-before ((arg0 glst-list) (arg1 glst-node) (arg2 glst-node))
|
|
(let ((v1-0 arg1))
|
|
"return the previous node in the list"
|
|
(let ((v1-1 (-> v1-0 prev)))
|
|
(set! (-> arg2 prev) v1-1)
|
|
(set! (-> arg2 next) arg1)
|
|
(set! (-> v1-1 next) arg2)
|
|
)
|
|
)
|
|
(set! (-> arg1 prev) arg2)
|
|
(+! (-> arg0 numelem) 1)
|
|
arg2
|
|
)
|
|
|
|
(defun glst-insert-after ((arg0 glst-list) (arg1 glst-node) (arg2 glst-node))
|
|
(let ((v1-0 arg1))
|
|
"return the next node in the list"
|
|
(let ((v1-1 (-> v1-0 next)))
|
|
(set! (-> arg2 prev) arg1)
|
|
(set! (-> arg2 next) v1-1)
|
|
(set! (-> v1-1 prev) arg2)
|
|
)
|
|
)
|
|
(set! (-> arg1 next) arg2)
|
|
(+! (-> arg0 numelem) 1)
|
|
arg2
|
|
)
|
|
|
|
(defun glst-add-tail ((arg0 glst-list) (arg1 glst-node))
|
|
(glst-insert-before arg0 (the-as glst-node (&-> arg0 tail)) arg1)
|
|
arg1
|
|
)
|
|
|
|
(defun glst-add-head ((arg0 glst-list) (arg1 glst-node))
|
|
(glst-insert-after arg0 (the-as glst-node arg0) arg1)
|
|
arg1
|
|
)
|
|
|
|
(defun glst-init-list! ((arg0 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
|
|
)
|
|
|
|
(defun glst-find-node-by-name ((arg0 glst-list) (arg1 string))
|
|
(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)
|
|
)
|
|
|
|
(defun glst-get-node-by-index ((arg0 glst-list) (arg1 int))
|
|
(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)
|
|
)
|
|
|
|
(defun glst-length-of-longest-name ((arg0 glst-list))
|
|
(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
|
|
)
|
|
)
|
|
|
|
(defun glst-get-node-index ((arg0 glst-list) (arg1 glst-node))
|
|
(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
|
|
)
|