[decomp] game-info (#779)

* support more process stuff

* more of game info

* add ref file

* progress on save
This commit is contained in:
water111
2021-08-22 20:12:47 -04:00
committed by GitHub
parent 30d1e1d6c9
commit 403bb5f4de
117 changed files with 6234 additions and 2243 deletions
+23 -25
View File
@@ -401,17 +401,32 @@
(defmacro handle->process (handle)
;; the actual implementation is more clever than this.
;; Checks PID.
`(if (-> ,handle process)
(let ((proc (-> (-> ,handle process))))
(if (= (-> ,handle pid) (-> proc pid))
proc
)
`(let ((the-handle ,handle))
(if (-> the-handle process)
(let ((proc (-> (-> the-handle process))))
(if (= (-> the-handle pid) (-> proc pid))
proc
)
)
)
)
)
)
(defmacro ppointer->process (ppointer)
;; convert a (pointer process) to a process.
;; this uses the self field, which seems to always just get set to the object.
;; perhaps when deleting a process you could have it set self to #f?
;; I don't see this happen anywhere though, so it's not clear.
`(let ((the-pp ,ppointer))
(the process (if the-pp (-> the-pp 0 self)))
)
)
(defmacro process->ppointer (proc)
`(if ,proc (the (pointer process) (-> ,proc ppointer)))
;"safely get a (pointer process) from a process, returning #f if invalid."
`(let ((the-proc ,proc))
(if the-proc (-> the-proc ppointer))
)
)
(defmacro ppointer->handle (pproc)
@@ -440,7 +455,7 @@
(deftype state (protect-frame)
((code function :offset-assert 16)
(trans (function none) :offset-assert 20)
(post (function none) :offset-assert 24)
(post (function none) :offset-assert 24)
(enter function :offset-assert 28)
(event (function process int symbol event-message-block object) :offset-assert 32)
)
@@ -471,23 +486,6 @@
:flag-assert #x900000048
)
(defmacro as-process (ppointer)
;; convert a (pointer process) to a process.
;; this uses the self field, which seems to always just get set to the object.
;; perhaps when deleting a process you could have it set self to #f?
;; I don't see this happen anywhere though, so it's not clear.
`(if ,ppointer
(-> (-> ,ppointer) self)
)
)
(defmacro as-ppointer (proc)
;"safely get a (pointer process) from a process, returning #f if invalid."
`(if ,proc
(-> ,proc ppointer)
)
)
(defmacro process-stack-used (proc)
;; get how much stack the top thread of a process has used.
`(- (the int (-> ,proc top-thread stack-top))
+12 -12
View File
@@ -308,9 +308,9 @@
(format #t "[~8x] ~A~%" obj (-> obj type))
(format #t "~Tname: ~S~%" (-> obj name))
(format #t "~Tmask: #x~X~%" (-> obj mask))
(format #t "~Tparent: ~A~%" (as-process (-> obj parent)))
(format #t "~Tbrother: ~A~%" (as-process (-> obj brother)))
(format #t "~Tchild: ~A~%" (as-process (-> obj child)))
(format #t "~Tparent: ~A~%" (ppointer->process (-> obj parent)))
(format #t "~Tbrother: ~A~%" (ppointer->process (-> obj brother)))
(format #t "~Tchild: ~A~%" (ppointer->process (-> obj child)))
obj
)
@@ -394,9 +394,9 @@
(format #t "~Ttrans-hook: ~A~%" (-> obj trans-hook))
(format #t "~Tpost-hook: ~A~%" (-> obj post-hook))
(format #t "~Tevent-hook: ~A~%" (-> obj event-hook))
(format #t "~Tparent: ~A~%" (as-process (-> obj parent)))
(format #t "~Tbrother: ~A~%" (as-process (-> obj brother)))
(format #t "~Tchild: ~A~%" (as-process (-> obj child)))
(format #t "~Tparent: ~A~%" (ppointer->process (-> obj parent)))
(format #t "~Tbrother: ~A~%" (ppointer->process (-> obj brother)))
(format #t "~Tchild: ~A~%" (ppointer->process (-> obj child)))
(format #t "~Tconnection-list: ~`connectable`P~%" (-> obj connection-list))
(format #t "~Tstack-frame-top: ~A~%" (-> obj stack-frame-top))
(format #t "~Theap-base: #x~X~%" (-> obj heap-base))
@@ -845,8 +845,8 @@
;; create each process
(let ((old-bro (-> obj child))
(next ((method-of-type process new) allocation process 'dead stack-size)))
(set! (-> obj child) (as-ppointer next))
(set! (-> next parent) (as-ppointer obj))
(set! (-> obj child) (process->ppointer next))
(set! (-> next parent) (process->ppointer obj))
(set! (-> next pool) obj)
(set! (-> next brother) old-bro)
)
@@ -865,7 +865,7 @@
(set! proc (the (pointer process-tree) (get-process *debug-dead-pool* type-to-make stack-size)))
(when proc
(format 0 "WARNING: ~A ~A had to be allocated from the debug pool, because ~A was empty.~%"
type-to-make (as-process proc) (-> obj name))
type-to-make (ppointer->process proc) (-> obj name))
)
;; there's a bug here. proc is a process here, but will be used as a process pointer.
;; let's just kill the program here.
@@ -881,7 +881,7 @@
)
(else
(format 0 "WARNING: ~A ~A could not be allocated, because ~A was empty.~%"
type-to-make (as-process proc) (-> obj name))
type-to-make (ppointer->process proc) (-> obj name))
(the process #f)
)
)
@@ -2007,12 +2007,12 @@
;; need to remove obj from its current parent
(when parent
(let ((proc (-> (-> parent) child)))
(if (eq? (as-process proc) obj)
(if (eq? (ppointer->process proc) obj)
;; case where we're the first child is easy!
(set! (-> (-> parent) child) (-> obj brother))
;; otherwise, look through brothers to find us.
(begin
(while (not (eq? (as-process (-> (-> proc) brother)) obj))
(while (not (eq? (ppointer->process (-> (-> proc) brother)) obj))
(set! proc (-> (-> proc) brother))
)
;; ok, got us, splice out of list.