[decompiler] Several small fixes (#775)

* fix assorted bugs

* stricter return types

* only look for functions in code files
This commit is contained in:
water111
2021-08-19 20:35:12 -04:00
committed by GitHub
parent 69d0840080
commit 11e11d2c04
48 changed files with 461 additions and 304 deletions
@@ -557,7 +557,7 @@
(when
(and
(< 8192.0 f28-1)
(nonzero? (logand (-> *camera* master-options) 2))
(logtest? (-> *camera* master-options) 2)
)
(vector-!
(the-as vector (-> s1-0 vector))
+2 -2
View File
@@ -166,13 +166,13 @@
(let ((v1-32 #f))
(set! a0-16 #f)
(when s4-0
(set! v1-32 (nonzero? (logand (shl #x8000 16) (-> s4-0 flags))))
(set! v1-32 (logtest? (shl #x8000 16) (-> s4-0 flags)))
(if (< (-> s4-0 length) (-> s4-0 from-bsp current-leaf-idx))
(set! v1-32 #f)
)
)
(when s3-0
(set! a0-16 (nonzero? (logand (shl #x8000 16) (-> s3-0 flags))))
(set! a0-16 (logtest? (shl #x8000 16) (-> s3-0 flags)))
(if (< (-> s3-0 length) (-> s3-0 from-bsp current-leaf-idx))
(set! a0-16 #f)
)
+1 -1
View File
@@ -1686,7 +1686,7 @@
(logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons right))
(logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons left))
(logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons down))
(nonzero? (logand (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons up)))
(logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons up))
)
(let ((v1-39 (cond
((logtest?
@@ -46,19 +46,19 @@
;; definition for method 12 of type task-cstage
(defmethod closed? task-cstage ((obj task-cstage))
(nonzero? (logand (-> obj flags) (task-flags closed)))
(logtest? (-> obj flags) (task-flags closed))
)
;; definition for method 13 of type task-cstage
(defmethod closed-by-default? task-cstage ((obj task-cstage))
(nonzero? (logand (-> obj flags) (task-flags closed-by-default)))
(logtest? (-> obj flags) (task-flags closed-by-default))
)
;; definition for method 11 of type task-cstage
(defmethod task-available? task-cstage ((obj task-cstage) (arg0 task-control))
(let ((a0-1 obj))
(cond
((nonzero? (logand (-> a0-1 flags) (task-flags closed)))
((logtest? (-> a0-1 flags) (task-flags closed))
#f
)
((>=
@@ -227,11 +227,9 @@
(dotimes (s4-0 (-> obj stage length))
(if (or (= arg0 'game) (let ((a0-4 (-> obj stage s4-0)))
(not
(nonzero?
(logand
(-> a0-4 flags)
(task-flags closed-by-default)
)
(logtest?
(-> a0-4 flags)
(task-flags closed-by-default)
)
)
)
@@ -239,7 +237,7 @@
(open-task! (-> obj stage s4-0))
)
(let ((a0-10 (-> obj stage s4-0)))
(if (nonzero? (logand (-> a0-10 flags) (task-flags closed)))
(if (logtest? (-> a0-10 flags) (task-flags closed))
(close-task! (-> obj stage s4-0))
)
)
@@ -263,7 +261,7 @@
(= arg1 (-> obj stage v1-3 status))
)
(let ((a0-3 (-> obj stage v1-3)))
(return (nonzero? (logand (-> a0-3 flags) (task-flags closed))))
(return (logtest? (-> a0-3 flags) (task-flags closed)))
)
)
)
+1 -1
View File
@@ -173,5 +173,5 @@
;; definition for method 11 of type vol-control
(defmethod TODO-RENAME-11 vol-control ((obj vol-control))
(and *display-vol-marks* (nonzero? (logand (-> obj flags) 1)))
(and *display-vol-marks* (logtest? (-> obj flags) 1))
)
@@ -22,11 +22,9 @@
(v1-4 (logand a0-4 3))
(a0-6 (+ (* a3-0 4) a2-3))
)
(nonzero?
(logand
(-> *ocean-work* trans-camera-masks 0 mask (+ a1-2 (* a0-6 8)))
(ash 1 v1-4)
)
(logtest?
(-> *ocean-work* trans-camera-masks 0 mask (+ a1-2 (* a0-6 8)))
(ash 1 v1-4)
)
)
)
@@ -62,7 +60,7 @@
)
)
(if a0-11
(nonzero? (logand (-> a0-11 1) (ash 1 v1-4)))
(logtest? (-> a0-11 1) (ash 1 v1-4))
#f
)
)
+2 -8
View File
@@ -1213,10 +1213,7 @@
)
(dotimes (upload-chunk-idx chunk-count)
(set! current-dest-chunk (+ tex-dest-base-chunk upload-chunk-idx))
(set!
need-tex
(nonzero? (logand allow-cache-mask (ash 1 upload-chunk-idx)))
)
(set! need-tex (logtest? allow-cache-mask (ash 1 upload-chunk-idx)))
(cond
((zero? chunks-to-upload-count)
(when (and (!= (-> pool ids current-dest-chunk) page-id) need-tex)
@@ -1856,10 +1853,7 @@
(dotimes (v1-0 32)
(let ((a2-0 (-> obj common-page v1-0)))
(when
(and
(nonzero? a2-0)
(nonzero? (logand (-> obj common-page-mask) (ash 1 v1-0)))
)
(and (nonzero? a2-0) (logtest? (-> obj common-page-mask) (ash 1 v1-0)))
(upload-vram-pages
obj
(-> obj segment-common)
+1 -1
View File
@@ -96,7 +96,7 @@
;; definition for method 14 of type water-control
(defmethod display-water-marks? water-control ((obj water-control))
(and *display-water-marks* (nonzero? (logand (-> obj flags) 1)))
(and *display-water-marks* (logtest? (-> obj flags) 1))
)
;; definition for method 0 of type water-control
+1 -1
View File
@@ -62,7 +62,7 @@
;; definition for method 9 of type bit-array
(defmethod get-bit bit-array ((obj bit-array) (arg0 int))
(let ((v1-2 (-> obj bytes (/ arg0 8))))
(nonzero? (logand v1-2 (ash 1 (logand arg0 7))))
(logtest? v1-2 (ash 1 (logand arg0 7)))
)
)
+1 -1
View File
@@ -591,7 +591,7 @@
(defmethod should-display? nav-control ((obj nav-control))
(and
*display-nav-marks*
(nonzero? (logand (-> obj flags) (nav-control-flags display-marks bit0)))
(logtest? (-> obj flags) (nav-control-flags display-marks))
)
)
+1 -1
View File
@@ -135,7 +135,7 @@
(defmethod should-display? path-control ((obj path-control))
(and
*display-path-marks*
(nonzero? (logand (-> obj flags) (path-control-flag display)))
(logtest? (-> obj flags) (path-control-flag display))
)
)
+2 -2
View File
@@ -34,7 +34,7 @@
((let ((a0-5 obj))
(and
*display-path-marks*
(nonzero? (logand (-> a0-5 flags) (path-control-flag display)))
(logtest? (-> a0-5 flags) (path-control-flag display))
)
)
(dotimes (s5-1 (-> obj curve num-cverts))
@@ -404,7 +404,7 @@
((let ((a0-5 obj))
(and
*display-path-marks*
(nonzero? (logand (-> a0-5 flags) (path-control-flag display)))
(logtest? (-> a0-5 flags) (path-control-flag display))
)
)
(if
-1
View File
@@ -1135,7 +1135,6 @@
(set! (-> *flava-table* count) 0)
;; definition for function flava-lookup
;; INFO: Return type mismatch int vs integer.
(defun flava-lookup ((arg0 symbol) (arg1 int))
(dotimes (v1-0 (-> *flava-table* count))
(if (= (-> *flava-table* row v1-0 music) arg0)