more small fixes (#1094)

* more small fixes

* better bones fix

* type fix
This commit is contained in:
water111 2022-01-19 19:39:36 -05:00 committed by GitHub
parent 5c2cd01df8
commit a66eef6034
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 562 additions and 78 deletions

View file

@ -5,7 +5,7 @@
// if you want to filter to only some object names. // if you want to filter to only some object names.
// it will make the decompiler much faster. // it will make the decompiler much faster.
"allowed_objects": [], "allowed_objects": [],
"banned_objects": ["collide-mesh"], "banned_objects": [],
//////////////////////////// ////////////////////////////
// CODE ANALYSIS OPTIONS // CODE ANALYSIS OPTIONS

View file

@ -139,7 +139,7 @@ void main() {
float sp_sin = sin(quat.z); float sp_sin = sin(quat.z);
float sp_cos = cos(quat.z); float sp_cos = cos(quat.z);
vec4 xy0_vf19 = xy_array[vert_id]; vec4 xy0_vf19 = xy_array[vert_id + flags_matrix.x];
vec4 vf12_rotated = (basis_x * sp_cos) - (basis_y * sp_sin); vec4 vf12_rotated = (basis_x * sp_cos) - (basis_y * sp_sin);
vec4 vf13_rotated_trans = (basis_x * sp_sin) + (basis_y * sp_cos); vec4 vf13_rotated_trans = (basis_x * sp_sin) + (basis_y * sp_cos);

View file

@ -1148,6 +1148,27 @@
(matrix*! (-> arg0 bone transform) arg1 (-> arg0 parent bone transform)) (matrix*! (-> arg0 bone transform) arg1 (-> arg0 parent bone transform))
) )
;; tricky ones:
;; cspace<-parented-transformq-joint!
;; -manually done, could also be mips2c if too slow
;; clear-frame-accumulator
;; - clear 128 bytes + 48*s2 bytes.
;; - probably should be C++.
;; normalize-frame-quaternions
;; - can mips2c
;; decompress-fixed-data-to-accumulator
;; - pretty big, should mips2c (jump table)
;; decompress-frame-data-to-accumulator
;; - pretty big, should mips2c (jump table)
;; decompress-frame-data-pair-to-accumulator
;; - pretty big, should mips2c (jump table)
;; make-joint-jump-tables
;; - gross
;; calc-animation-from-spr
;; - would be nice as goal.
;; all run by create-interpolated-joint-animation-frame
(defun cspace<-parented-transformq-joint! ((arg0 cspace) (arg1 transformq)) (defun cspace<-parented-transformq-joint! ((arg0 cspace) (arg1 transformq))
(nop!) (nop!)
;; the ops in these funcs were scrambled for pipeline optimization. screw that. ;; the ops in these funcs were scrambled for pipeline optimization. screw that.

View file

@ -60,4 +60,33 @@
(none) (none)
) )
(define-extern slave-los-state->string (function slave-los-state string)) (define-extern slave-los-state->string (function slave-los-state string))
(define-extern cam-debug-reset-coll-tri (function none)) ;; not confirmed (define-extern cam-debug-reset-coll-tri (function none)) ;; not confirmed
(when (or (not *camera-old-cpu*) (zero? *camera-old-cpu*))
(set! *camera-old-cpu* 0)
0
)
;; failed to figure out what this is:
(when (or (not *camera-old-vu*) (zero? *camera-old-vu*))
(set! *camera-old-vu* 0)
0
)
;; failed to figure out what this is:
(when (or (not *camera-old-tfrag-bytes*) (zero? *camera-old-tfrag-bytes*))
(set! *camera-old-tfrag-bytes* 0)
0
)
;; definition (perm) for symbol *camera-old-level*, type string
(define-perm *camera-old-level* string (new 'global 'string 128 (the-as string #f)))
;; definition (perm) for symbol *camera-old-stat-string-tfrag*, type string
(define-perm *camera-old-stat-string-tfrag* string (new 'global 'string 128 (the-as string #f)))
;; definition (perm) for symbol *camera-old-stat-string-tfrag-near*, type string
(define-perm *camera-old-stat-string-tfrag-near* string (new 'global 'string 128 (the-as string #f)))
;; definition (perm) for symbol *camera-old-stat-string-total*, type string
(define-perm *camera-old-stat-string-total* string (new 'global 'string 128 (the-as string #f)))

View file

@ -107,8 +107,8 @@
(defmethod-mips2c "(method 11 collide-mesh)" 11 collide-mesh) (defmethod-mips2c "(method 11 collide-mesh)" 11 collide-mesh)
(defmethod-mips2c "(method 14 collide-mesh)" 11 collide-mesh) (defmethod-mips2c "(method 14 collide-mesh)" 14 collide-mesh)
(defmethod-mips2c "(method 15 collide-mesh)" 11 collide-mesh) (defmethod-mips2c "(method 15 collide-mesh)" 15 collide-mesh)
(defmethod allocate! collide-mesh-cache ((obj collide-mesh-cache) (arg0 int)) (defmethod allocate! collide-mesh-cache ((obj collide-mesh-cache) (arg0 int))
(local-vars (a1-2 int) (a2-2 int)) (local-vars (a1-2 int) (a2-2 int))

View file

@ -2177,6 +2177,24 @@
(v1-0 (-> obj cshape)) (v1-0 (-> obj cshape))
(a0-1 (-> obj transform-index)) (a0-1 (-> obj transform-index))
) )
;; HACK set all bones to identity. Fixes some issues with press O to talk
;; but doesn't seem to fix mesh issues (may be another bug there)
(#when NO_BONES_HACK
(cond
((nonzero? a1-1)
(cond
((>= a0-1 0)
(dotimes (i (-> a1-1 length))
(matrix-identity! (-> a1-1 data i bone transform))
(set! (-> a1-1 data i bone transform vector 3 quad) (-> v1-0 trans quad))
)
)
)
)
)
(set! a0-1 -2)
)
(cond (cond
((nonzero? a1-1) ((nonzero? a1-1)
(cond (cond

View file

@ -1168,4 +1168,302 @@
(defmethod collide-y-probe drawable ((obj drawable) (arg0 int) (arg1 collide-list)) (defmethod collide-y-probe drawable ((obj drawable) (arg0 int) (arg1 collide-list))
0 0
(none) (none)
) )
(defmethod collect-ambients drawable ((obj drawable) (arg0 sphere) (arg1 int) (arg2 ambient-list))
0
(none)
)
;; definition (debug) for function marks-cam-restore
;; Used lq/sq
(defun-debug marks-cam-restore ()
(let ((a0-0 (new-stack-vector0))
(a1-0 (new-stack-matrix0))
)
(set! (-> a0-0 x) 1672489.2)
(set! (-> a0-0 y) 60862.703)
(set! (-> a0-0 z) -13051605.0)
(set! (-> a0-0 w) 1.0)
(set! (-> a1-0 vector 0 x) -0.1783)
(set! (-> a1-0 vector 0 y) 0.0)
(set! (-> a1-0 vector 0 z) 0.9839)
(set! (-> a1-0 vector 0 w) 0.0)
(set! (-> a1-0 vector 1 x) -0.0629)
(set! (-> a1-0 vector 1 y) 0.9979)
(set! (-> a1-0 vector 1 z) -0.0114)
(set! (-> a1-0 vector 1 w) 0.0)
(set! (-> a1-0 vector 2 x) -0.9819)
(set! (-> a1-0 vector 2 y) -0.064)
(set! (-> a1-0 vector 2 z) -0.178)
(set! (-> a1-0 vector 2 w) 0.0)
(set! (-> a1-0 vector 3 x) 0.0)
(set! (-> a1-0 vector 3 y) 0.0)
(set! (-> a1-0 vector 3 z) 0.0)
(set! (-> a1-0 vector 3 w) 1.0)
(debug-set-camera-pos-rot! a0-0 a1-0)
)
(send-event *camera* 'set-fov 17294.205)
(clear *camera-old-level*)
(format *camera-old-level* "village3")
(set! *camera-old-cpu* 1219)
(set! *camera-old-vu* 9602)
(set! *camera-old-tfrag-bytes* 0)
(clear *camera-old-stat-string-tfrag*)
(clear *camera-old-stat-string-tfrag-near*)
(clear *camera-old-stat-string-total*)
(let ((v0-7 #t))
(set! *display-camera-old-stats* v0-7)
v0-7
)
)
;; definition (debug) for function eddie-cam-restore
;; Used lq/sq
(defun-debug eddie-cam-restore ()
(let ((a0-0 (new-stack-vector0))
(a1-0 (new-stack-matrix0))
)
(set! (-> a0-0 x) -427963.66)
(set! (-> a0-0 y) 24967.182)
(set! (-> a0-0 z) 339465.53)
(set! (-> a0-0 w) 1.0)
(set! (-> a1-0 vector 0 x) -0.6026)
(set! (-> a1-0 vector 0 y) 0.0)
(set! (-> a1-0 vector 0 z) 0.7979)
(set! (-> a1-0 vector 0 w) 0.0)
(set! (-> a1-0 vector 1 x) -0.1522)
(set! (-> a1-0 vector 1 y) 0.9816)
(set! (-> a1-0 vector 1 z) -0.1149)
(set! (-> a1-0 vector 1 w) 0.0)
(set! (-> a1-0 vector 2 x) -0.7833)
(set! (-> a1-0 vector 2 y) -0.1908)
(set! (-> a1-0 vector 2 z) -0.5915)
(set! (-> a1-0 vector 2 w) 0.0)
(set! (-> a1-0 vector 3 x) 0.0)
(set! (-> a1-0 vector 3 y) 0.0)
(set! (-> a1-0 vector 3 z) 0.0)
(set! (-> a1-0 vector 3 w) 1.0)
(debug-set-camera-pos-rot! a0-0 a1-0)
)
)
;; definition (debug) for function gregs-jungle-cam-restore
;; Used lq/sq
(defun-debug gregs-jungle-cam-restore ()
(let ((a0-0 (new-stack-vector0))
(a1-0 (new-stack-matrix0))
)
(set! (-> a0-0 x) 1399233.0)
(set! (-> a0-0 y) 39027.11)
(set! (-> a0-0 z) -1485580.1)
(set! (-> a0-0 w) 1.0)
(set! (-> a1-0 vector 0 x) 0.9965)
(set! (-> a1-0 vector 0 y) 0.0)
(set! (-> a1-0 vector 0 z) 0.0829)
(set! (-> a1-0 vector 0 w) 0.0)
(set! (-> a1-0 vector 1 x) -0.0021)
(set! (-> a1-0 vector 1 y) 0.9996)
(set! (-> a1-0 vector 1 z) 0.0253)
(set! (-> a1-0 vector 1 w) 0.0)
(set! (-> a1-0 vector 2 x) -0.0829)
(set! (-> a1-0 vector 2 y) -0.0254)
(set! (-> a1-0 vector 2 z) 0.9962)
(set! (-> a1-0 vector 2 w) 0.0)
(set! (-> a1-0 vector 3 x) 0.0)
(set! (-> a1-0 vector 3 y) 0.0)
(set! (-> a1-0 vector 3 z) 0.0)
(set! (-> a1-0 vector 3 w) 1.0)
(debug-set-camera-pos-rot! a0-0 a1-0)
)
(send-event *camera* 'set-fov 11650.845)
(clear *camera-old-level*)
(format *camera-old-level* "jungle")
(set! *camera-old-cpu* 5801)
(set! *camera-old-vu* 9605)
(set! *camera-old-tfrag-bytes* #x1ffee0)
(clear *camera-old-stat-string-tfrag*)
(clear *camera-old-stat-string-tfrag-near*)
(clear *camera-old-stat-string-total*)
)
;; definition (debug) for function gregs-village1-cam-restore
;; Used lq/sq
(defun-debug gregs-village1-cam-restore ()
(let ((a0-0 (new-stack-vector0))
(a1-0 (new-stack-matrix0))
)
(set! (-> a0-0 x) -511224.06)
(set! (-> a0-0 y) 157579.95)
(set! (-> a0-0 z) 764585.25)
(set! (-> a0-0 w) 1.0)
(set! (-> a1-0 vector 0 x) -0.9009)
(set! (-> a1-0 vector 0 y) 0.0)
(set! (-> a1-0 vector 0 z) -0.4338)
(set! (-> a1-0 vector 0 w) 0.0)
(set! (-> a1-0 vector 1 x) 0.0984)
(set! (-> a1-0 vector 1 y) 0.9739)
(set! (-> a1-0 vector 1 z) -0.2043)
(set! (-> a1-0 vector 1 w) 0.0)
(set! (-> a1-0 vector 2 x) 0.4225)
(set! (-> a1-0 vector 2 y) -0.2268)
(set! (-> a1-0 vector 2 z) -0.8774)
(set! (-> a1-0 vector 2 w) 0.0)
(set! (-> a1-0 vector 3 x) 0.0)
(set! (-> a1-0 vector 3 y) 0.0)
(set! (-> a1-0 vector 3 z) 0.0)
(set! (-> a1-0 vector 3 w) 1.0)
(debug-set-camera-pos-rot! a0-0 a1-0)
)
(send-event *camera* 'set-fov 11650.845)
(clear *camera-old-level*)
(format *camera-old-level* "village1")
(set! *camera-old-cpu* 4899)
(set! *camera-old-vu* 9605)
(set! *camera-old-tfrag-bytes* #x24e680)
(clear *camera-old-stat-string-tfrag*)
(clear *camera-old-stat-string-tfrag-near*)
(clear *camera-old-stat-string-total*)
)
;; definition (debug) for function gregs-texture-cam-restore
;; Used lq/sq
(defun-debug gregs-texture-cam-restore ()
(let ((a0-0 (new-stack-vector0))
(a1-0 (new-stack-matrix0))
)
(set! (-> a0-0 x) 1103816.0)
(set! (-> a0-0 y) 96275.71)
(set! (-> a0-0 z) -632064.5)
(set! (-> a0-0 w) 1.0)
(set! (-> a1-0 vector 0 x) 0.4063)
(set! (-> a1-0 vector 0 y) 0.0)
(set! (-> a1-0 vector 0 z) -0.9137)
(set! (-> a1-0 vector 0 w) 1.0)
(set! (-> a1-0 vector 1 x) 0.2824)
(set! (-> a1-0 vector 1 y) 0.951)
(set! (-> a1-0 vector 1 z) 0.1256)
(set! (-> a1-0 vector 1 w) 1.0)
(set! (-> a1-0 vector 2 x) 0.8689)
(set! (-> a1-0 vector 2 y) -0.3091)
(set! (-> a1-0 vector 2 z) 0.3864)
(set! (-> a1-0 vector 2 w) 1.0)
(set! (-> a1-0 vector 3 x) 0.0)
(set! (-> a1-0 vector 3 y) 0.0)
(set! (-> a1-0 vector 3 z) 0.0)
(set! (-> a1-0 vector 3 w) 1.0)
(debug-set-camera-pos-rot! a0-0 a1-0)
)
(send-event *camera* 'set-fov 11650.845)
(clear *camera-old-level*)
(format *camera-old-level* "village1")
(set! *camera-old-cpu* 4772)
(set! *camera-old-vu* 9603)
(set! *camera-old-tfrag-bytes* #x22e680)
(clear *camera-old-stat-string-tfrag*)
(clear *camera-old-stat-string-tfrag-near*)
(clear *camera-old-stat-string-total*)
)
;; definition (debug) for function gregs-texture2-cam-restore
;; Used lq/sq
(defun-debug gregs-texture2-cam-restore ()
(let ((a0-0 (new-stack-vector0))
(a1-0 (new-stack-matrix0))
)
(set! (-> a0-0 x) 1954572.9)
(set! (-> a0-0 y) 135123.98)
(set! (-> a0-0 z) -1028725.44)
(set! (-> a0-0 w) 1.0)
(set! (-> a1-0 vector 0 x) 0.2535)
(set! (-> a1-0 vector 0 y) 0.0)
(set! (-> a1-0 vector 0 z) 0.9673)
(set! (-> a1-0 vector 0 w) 1.0)
(set! (-> a1-0 vector 1 x) -0.1051)
(set! (-> a1-0 vector 1 y) 0.994)
(set! (-> a1-0 vector 1 z) 0.0275)
(set! (-> a1-0 vector 1 w) 1.0)
(set! (-> a1-0 vector 2 x) -0.9615)
(set! (-> a1-0 vector 2 y) -0.1087)
(set! (-> a1-0 vector 2 z) 0.252)
(set! (-> a1-0 vector 2 w) 1.0)
(set! (-> a1-0 vector 3 x) 0.0)
(set! (-> a1-0 vector 3 y) 0.0)
(set! (-> a1-0 vector 3 z) 0.0)
(set! (-> a1-0 vector 3 w) 1.0)
(debug-set-camera-pos-rot! a0-0 a1-0)
)
(send-event *camera* 'set-fov 11650.845)
(clear *camera-old-level*)
(format *camera-old-level* "village1")
(set! *camera-old-cpu* 4936)
(set! *camera-old-vu* #x4b0c)
(set! *camera-old-tfrag-bytes* #x22e680)
(clear *camera-old-stat-string-tfrag*)
(clear *camera-old-stat-string-tfrag-near*)
(clear *camera-old-stat-string-total*)
)
;; definition (debug) for function cave-cam-restore
;; Used lq/sq
(defun-debug cave-cam-restore ()
(let ((a0-0 (new-stack-vector0))
(a1-0 (new-stack-matrix0))
)
(set! (-> a0-0 x) -1449013.1)
(set! (-> a0-0 y) 15114.015)
(set! (-> a0-0 z) -1621305.5)
(set! (-> a0-0 w) 1.0)
(set! (-> a1-0 vector 0 x) -0.8223)
(set! (-> a1-0 vector 0 y) 0.0)
(set! (-> a1-0 vector 0 z) -0.5689)
(set! (-> a1-0 vector 0 w) 0.0)
(set! (-> a1-0 vector 1 x) 0.0076)
(set! (-> a1-0 vector 1 y) 0.9999)
(set! (-> a1-0 vector 1 z) -0.0111)
(set! (-> a1-0 vector 1 w) 0.0)
(set! (-> a1-0 vector 2 x) 0.5689)
(set! (-> a1-0 vector 2 y) -0.0135)
(set! (-> a1-0 vector 2 z) -0.8222)
(set! (-> a1-0 vector 2 w) 0.0)
(set! (-> a1-0 vector 3 x) 0.0)
(set! (-> a1-0 vector 3 y) 0.0)
(set! (-> a1-0 vector 3 z) 0.0)
(set! (-> a1-0 vector 3 w) 1.0)
(debug-set-camera-pos-rot! a0-0 a1-0)
)
)
;; definition (debug) for function paals-cam-restore
;; Used lq/sq
(defun-debug paals-cam-restore ()
(let ((a0-0 (new-stack-vector0))
(a1-0 (new-stack-matrix0))
)
(set! (-> a0-0 x) -791260.7)
(set! (-> a0-0 y) 50858.62)
(set! (-> a0-0 z) -163715.47)
(set! (-> a0-0 w) 1.0)
(set! (-> a1-0 vector 0 x) -0.7816)
(set! (-> a1-0 vector 0 y) 0.0)
(set! (-> a1-0 vector 0 z) -0.6236)
(set! (-> a1-0 vector 0 w) 0.0)
(set! (-> a1-0 vector 1 x) 0.0672)
(set! (-> a1-0 vector 1 y) 0.9941)
(set! (-> a1-0 vector 1 z) -0.0843)
(set! (-> a1-0 vector 1 w) 0.0)
(set! (-> a1-0 vector 2 x) 0.62)
(set! (-> a1-0 vector 2 y) -0.1079)
(set! (-> a1-0 vector 2 z) -0.7771)
(set! (-> a1-0 vector 2 w) 0.0)
(set! (-> a1-0 vector 3 x) 0.0)
(set! (-> a1-0 vector 3 y) 0.0)
(set! (-> a1-0 vector 3 z) 0.0)
(set! (-> a1-0 vector 3 w) 1.0)
(debug-set-camera-pos-rot! a0-0 a1-0)
)
)

View file

@ -1259,19 +1259,24 @@
(define-extern launcher type) (define-extern launcher type)
(define-extern warp-gate-switch type) (define-extern warp-gate-switch type)
(define-extern lurkercrab type) (define-extern lurkercrab type)
(define-extern ecoventrock type)
(define-extern harvester type)
(define-extern yakow type)
(defmacro heap-size-hack (info entity-type) (defmacro heap-size-hack (info entity-type)
`(cond #x8000
((type-type? ,entity-type collectable) ; `(cond
#x1000 ; ((type-type? ,entity-type collectable)
) ; #x1000
(else ; )
(if ,info ; (else
(-> ,info heap-size) ; (if ,info
#x4000 ; (-> ,info heap-size)
) ; #x4000
) ; )
) ; )
; )
) )
(defmethod birth! entity-actor ((obj entity-actor)) (defmethod birth! entity-actor ((obj entity-actor))
@ -1287,11 +1292,13 @@
(type-type? (-> obj etype) racer) (type-type? (-> obj etype) racer)
(type-type? (-> obj etype) launcher) (type-type? (-> obj etype) launcher)
(type-type? (-> obj etype) warp-gate-switch) (type-type? (-> obj etype) warp-gate-switch)
(type-type? (-> obj etype) lurkercrab) ;; crash on death (type-type? (-> obj etype) lurkercrab)
;(type-type? (-> obj etype) crate) (type-type? (-> obj etype) crate)
(type-type? (-> obj etype) ecoventrock)
(type-type? (-> obj etype) harvester)
(type-type? (-> obj etype) yakow)
) )
;;(birth-log "rejecting ~A birth because yes (was ~A)~%" obj (-> obj etype)) ;; (birth-log "rejecting ~A birth because yes (was ~A)~%" obj (-> obj etype))
(logior! (-> obj extra perm status) (entity-perm-status bit-0)) (logior! (-> obj extra perm status) (entity-perm-status bit-0))
(return obj) (return obj)
) )

View file

@ -2072,7 +2072,7 @@
) )
(defmethod initialize fuel-cell ((obj fuel-cell)) (defmethod initialize fuel-cell ((obj fuel-cell))
(stack-size-set! (-> obj main-thread) 512) (stack-size-set! (-> obj main-thread) 1280) ;; was 512
(let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player))))
(set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s5-0 reaction) default-collision-reaction) (set! (-> s5-0 reaction) default-collision-reaction)
@ -2432,6 +2432,7 @@
) )
(defmethod initialize buzzer ((obj buzzer)) (defmethod initialize buzzer ((obj buzzer))
(stack-size-set! (-> obj main-thread) 512) ;; added
(let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player))))
(set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s5-0 reaction) default-collision-reaction) (set! (-> s5-0 reaction) default-collision-reaction)

View file

@ -231,25 +231,30 @@
) )
(defmethod TODO-RENAME-14 effect-control ((obj effect-control) (arg0 float) (arg1 float) (arg2 float)) (defmethod TODO-RENAME-14 effect-control ((obj effect-control) (arg0 float) (arg1 float) (arg2 float))
(let ((s2-0 (-> obj name))) ;; note: this check was added. I believe in the original game name could be false, and then the
(while (= (-> s2-0 0 name) 'effect-name) ;; effect-name check below would fail. This did not cause a crash on original hardware because
(let ((f0-0 (-> s2-0 0 key-frame))) ;; misaligned 16-byte loads silently align. This causes a crash in opengoal, so we skip it manually.
(when (or (and (< f0-0 arg1) (< arg0 f0-0)) (= f0-0 arg2)) (when (-> obj name)
(let* ((a0-1 obj) (let ((s2-0 (-> obj name)))
(t9-0 (method-of-object a0-1 dummy-10)) (while (= (-> s2-0 0 name) 'effect-name)
(v1-7 (-> obj res)) (let ((f0-0 (-> s2-0 0 key-frame)))
(a1-1 (-> s2-0 0)) (when (or (and (< f0-0 arg1) (< arg0 f0-0)) (= f0-0 arg2))
) (let* ((a0-1 obj)
(t9-0 (t9-0 (method-of-object a0-1 dummy-10))
a0-1 (v1-7 (-> obj res))
(the-as symbol (-> (the-as (pointer uint32) (&+ (-> v1-7 data-base) (-> a1-1 data-offset))))) (a1-1 (-> s2-0 0))
f0-0 )
-1 (t9-0
a0-1
(the-as symbol (-> (the-as (pointer uint32) (&+ (-> v1-7 data-base) (-> a1-1 data-offset)))))
f0-0
-1
)
) )
) )
) )
(set! s2-0 (&-> s2-0 1))
) )
(set! s2-0 (&-> s2-0 1))
) )
) )
0 0

View file

@ -536,7 +536,7 @@
) )
(defbehavior manipy-init manipy ((arg0 vector) (arg1 entity) (arg2 skeleton-group) (arg3 vector)) (defbehavior manipy-init manipy ((arg0 vector) (arg1 entity) (arg2 skeleton-group) (arg3 vector))
(stack-size-set! (-> self main-thread) 128) (stack-size-set! (-> self main-thread) 256) ;; from 128
(logior! (-> self mask) (process-mask heap-shrunk)) (logior! (-> self mask) (process-mask heap-shrunk))
(set! (-> self entity) arg1) (set! (-> self entity) arg1)
(cond (cond
@ -1218,7 +1218,7 @@
) )
(defbehavior camera-tracker-init camera-tracker ((arg0 object)) (defbehavior camera-tracker-init camera-tracker ((arg0 object))
(stack-size-set! (-> self main-thread) 512) (stack-size-set! (-> self main-thread) 768) ;; was 512
(logclear! (-> self mask) (process-mask actor-pause movie enemy platform projectile)) (logclear! (-> self mask) (process-mask actor-pause movie enemy platform projectile))
(set! (-> self mask-to-clear) (the-as uint #x4a0800)) (set! (-> self mask-to-clear) (the-as uint #x4a0800))
(set! (-> self grab-target) (the-as handle #f)) (set! (-> self grab-target) (the-as handle #f))

View file

@ -7,6 +7,7 @@
;; Global engine settings: ;; Global engine settings:
(defglobalconstant TARGET_STARTUP_HACKS #t) (defglobalconstant TARGET_STARTUP_HACKS #t)
(defglobalconstant NO_BONES_HACK #t)
(define *stats-poly* #f) (define *stats-poly* #f)
(define *stats-memory* #f) (define *stats-memory* #f)
(define *stats-memory-short* #f) (define *stats-memory-short* #f)

View file

@ -530,27 +530,78 @@
(stack-size-set! (-> self main-thread) 512) (stack-size-set! (-> self main-thread) 512)
(let ((disp *display*)) (let ((disp *display*))
;; todo spad terrain context ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Pre loop initialization
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; the size is 0, so this doesn't actually do anything.
;; (dma-send-to-spr (the-as uint #x70000000) (the-as uint *terrain-context*) (the-as uint 0) #t)
(set! *teleport* #t) (set! *teleport* #t)
(update-per-frame-settings! *setting-control*) (update-per-frame-settings! *setting-control*)
;;(init-time-of-day-context *time-of-day-context*) TODO (init-time-of-day-context *time-of-day-context*)
(display-sync disp) (display-sync disp)
(swap-display disp) (swap-display disp)
;; touching list (free-all-prim-nodes *touching-list*)
;; bler init ;; bler init
;; collide dma ;; collide dma
(suspend) (suspend)
(while *run* (while *run*
;; blerc ;; start immediately after all process updates finish.
;; texscroll
;; ripple ;; drawing effects to be used in foreground drawing.
; (blerc-execute)
; (blerc-init)
; (texscroll-execute)
; (ripple-execute)
;;;;;;;;;;;;;;;;;;;;
;; AMBIENT
;;;;;;;;;;;;;;;;;;;;
;; set defaults for weather/music/flava.
(set! *weather-off* #f) (set! *weather-off* #f)
;; music (let ((v1-13 (-> *game-info* current-continue level)))
(dotimes (a0-8 (-> *level* length))
(let ((a1-6 (-> *level* level a0-8)))
(when (= (-> a1-6 status) 'active)
(if (and (= (-> a1-6 name) v1-13) (-> *level* play?))
(set! (-> *setting-control* default music) (-> a1-6 info music-bank))
)
)
)
)
)
(set! (-> *setting-control* default sound-flava) (the-as uint 49)) (set! (-> *setting-control* default sound-flava) (the-as uint 49))
(set! (-> *setting-control* default sound-flava-priority) 0.0) (set! (-> *setting-control* default sound-flava-priority) 0.0)
;; do ambients
;; find any ambients, and execute them.
(add-ee-profile-frame 'draw :r #x40 :b #x40) (when (and *execute-ambients* (not (paused?)))
(if *target*
(set! (-> *target* draw secondary-interp) 0.0)
)
(let ((s5-1 (sphere<-vector+r! (new 'stack 'sphere) (ear-trans) 0.0)))
(let ((v1-28 (scratchpad-object terrain-context)))
(set! (-> v1-28 work ambient ambient-list num-items) 0)
)
(dotimes (s4-1 (-> *level* length))
(let ((v1-32 (-> *level* level s4-1)))
(when (= (-> v1-32 status) 'active)
(collect-ambients (-> v1-32 bsp) s5-1 0 (-> (scratchpad-object terrain-context) work ambient ambient-list))
)
)
)
(countdown (s4-2 (-> (scratchpad-object terrain-context) work ambient ambient-list num-items))
(dummy-18 (-> (scratchpad-object terrain-context) work ambient ambient-list items s4-2) s5-1)
)
)
)
(add-ee-profile-frame 'draw :r #x40 :b #x40) ;; actor update
;; do math, before drawing
(execute-math-engine) (execute-math-engine)
;; DEBUG PROF ;; DEBUG PROF
(add-ee-profile-frame 'draw :r #x80) (add-ee-profile-frame 'draw :r #x80)
@ -567,8 +618,9 @@
(*menu-hook*) (*menu-hook*)
(add-ee-profile-frame 'draw :g #x40) (add-ee-profile-frame 'draw :g #x40)
;; (make-current-level-available-to-progress) TODO target ;; finally, update hints/text
;; update-task-hints (make-current-level-available-to-progress)
(update-task-hints)
(load-level-text-files -1) (load-level-text-files -1)
(add-ee-profile-frame 'unknown-cpu-time) (add-ee-profile-frame 'unknown-cpu-time)
@ -587,26 +639,18 @@
;; depth cue ;; depth cue
;; screen filter ;; screen filter
;; run letterbox if needed ;; add letterbox effect
(when (or (movie?) (when (or (movie?) (< (-> *display* base-frame-counter) (-> *game-info* letterbox-time)))
(< (the-as int (current-time)) (if (< (-> *game-info* letterbox-time) (-> *display* base-frame-counter))
(the-as int (-> *game-info* letterbox-time)) (set! (-> *game-info* letterbox-time) (-> *display* base-frame-counter))
)
)
(if (< (the-as int (-> *game-info* letterbox-time))
(the-as int (current-time))
)
(set! (-> *game-info* letterbox-time) (current-time))
) )
(if (= (-> *setting-control* current aspect-ratio) 'aspect4x3) (if (= (-> *setting-control* current aspect-ratio) 'aspect4x3)
(letterbox) (letterbox)
) )
) )
;; do blackout if needed. ;; add blackout effect
(if (< (the-as int (current-time)) (if (< (-> *display* base-frame-counter) (-> *game-info* blackout-time))
(the-as int (-> *game-info* blackout-time))
)
(set! (-> *setting-control* default bg-a-force) 1.0) (set! (-> *setting-control* default bg-a-force) 1.0)
(set! (-> *setting-control* default bg-a-force) 0.0) (set! (-> *setting-control* default bg-a-force) 0.0)
) )
@ -765,8 +809,14 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(swap-display disp) (swap-display disp)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(set! (-> *time-of-day-context* title-updated) #f)
(set! *teleport* #f)
(when (nonzero? *teleport-count*)
(set! *teleport* #t)
(set! *teleport-count* (+ *teleport-count* -1))
)
;; teleport stuff
;; perf stats ;; perf stats
(process-particles) (process-particles)
@ -777,7 +827,7 @@
;; str play ;; str play
(level-update *level*) ;; also updates settings. (level-update *level*) ;; also updates settings.
(mc-run) (mc-run)
;; auto save check (auto-save-check)
(#when PC_PORT (#when PC_PORT
(update *pc-settings*) (update *pc-settings*)

View file

@ -1159,7 +1159,7 @@
(s0-0 arg4) (s0-0 arg4)
(s5-0 arg5) (s5-0 arg5)
) )
(stack-size-set! (-> obj main-thread) 512) (stack-size-set! (-> obj main-thread) 768) ;; increased from 512
(initialize-collision obj s3-0 s0-0) (initialize-collision obj s3-0 s0-0)
(process-drawable-from-entity! obj (the-as entity-actor arg0)) (process-drawable-from-entity! obj (the-as entity-actor arg0))
(let* ((a0-4 obj) (let* ((a0-4 obj)

View file

@ -57,4 +57,7 @@
) )
(+ *eyes-base-block* (* v1-0 32) a0-4) (+ *eyes-base-block* (* v1-0 32) a0-4)
) )
) )
(defun merc-eye-anim ((arg0 process-drawable))
(none))

View file

@ -118,6 +118,8 @@
;; todo blerc-execute ;; todo blerc-execute
;; todo merc-blend-shape ;; todo merc-blend-shape
(define-extern merc-blend-shape (function process-drawable object)) (defun merc-blend-shape ((a process-drawable))
(the object #f)
)
;; todo setup-blerc-chains ;; todo setup-blerc-chains

View file

@ -9,4 +9,14 @@
(define-extern *shadow-data* shadow-data) (define-extern *shadow-data* shadow-data)
;; todo ;; todo
(define *shadow-data* (new 'static 'shadow-data)) (define *shadow-data* (new 'static 'shadow-data))
(defmethod dummy-14 shadow-control ((obj shadow-control))
(let ((v1-1 (-> *time-of-day-context* current-shadow)))
(set! (-> obj settings shadow-dir x) (-> v1-1 x))
(set! (-> obj settings shadow-dir y) (-> v1-1 y))
(set! (-> obj settings shadow-dir z) (-> v1-1 z))
)
0
(none)
)

View file

@ -445,6 +445,18 @@
"beach-vis" "beach-vis"
) )
(copy-strs
"BECANNON" ;; beachcam-cannon
"LRFALLIN" ;; lrocklrg-falling
"PESEXT" ;; pelican-spit-ext
)
(copy-strs
"FAINTROD" ;; farmer-introduction
"SCINTROD" ;; sculptor-introduction
"BILINTRO" ;; bird-lady-introduction
"MAINTROD" ;; mayor-introduction
)
;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;
;; Jungle ;; Jungle
@ -576,6 +588,18 @@
"village1-vis" "village1-vis"
) )
(copy-strs
"ASIBESWI" ;; assistant-introduction-blue-eco-switch
"SAISD1" ;; sage-intro-sequence-d1
"SAISD2" ;; sage-intro-sequence-d2
"EXINTROD" ;; explorer-introduction
"FIBRTMIS" ;; fishermans-boat-ride-to-misty
"ASR1BESW" ;; assistant-reminder-1-blue-eco-switch
"ORI1" ;; oracle-intro-1
"ORRE1" ;; oracle-right-eye-1
"ORR1" ;; oracle-reminder-1
"FAR1" ;; farmer-reminder-1
)
;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;
;; Jungle temple ;; Jungle temple

View file

@ -14,6 +14,8 @@
;; -hardware- ;; -hardware-
(defglobalconstant KERNEL_DEBUG #t)
;; the end of the 16 kB fast "scratchpad" memory of the PS2. ;; the end of the 16 kB fast "scratchpad" memory of the PS2.
;; this memory is mapped to 0x70000000 in the PS2. ;; this memory is mapped to 0x70000000 in the PS2.
(defconstant *scratch-memory-top* (the pointer #x70004000)) (defconstant *scratch-memory-top* (the pointer #x70004000))
@ -38,13 +40,13 @@
;; another stack size used as a maximum for temporary threads ;; another stack size used as a maximum for temporary threads
;; OpenGOAL NOTE: increased to 16kB ;; OpenGOAL NOTE: increased to 16kB
(defconstant PROCESS_STACK_SIZE #x4000) (defconstant PROCESS_STACK_SIZE #x6000)
;; default size of stack to backup for a process ;; default size of stack to backup for a process
(defconstant PROCESS_STACK_SAVE_SIZE 256) (defconstant PROCESS_STACK_SAVE_SIZE 256)
;; the size of the shared heap used by dynamically sized processes ;; the size of the shared heap used by dynamically sized processes
(defconstant PROCESS_HEAP_SIZE (* 984 1024)) (defconstant PROCESS_HEAP_SIZE (* 3 984 1024)) ;; increased by factor of 3 for PC
;; -system- ;; -system-
@ -557,7 +559,7 @@
;; suspend the current process. ;; suspend the current process.
`(rlet ((pp :reg r13 :reset-here #t)) `(rlet ((pp :reg r13 :reset-here #t))
(#when DEBUG_PRINT_SUSPEND_FAIL (#when (or DEBUG_PRINT_SUSPEND_FAIL KERNEL_DEBUG)
(rlet ((sp :reg rsp :reset-here #t :type int) (rlet ((sp :reg rsp :reset-here #t :type int)
(off :reg r15 :type uint)) (off :reg r15 :type uint))
(let* ((sp-goal (- sp off)) (let* ((sp-goal (- sp off))

View file

@ -1670,6 +1670,12 @@
(let ((trans (new 'process 'cpu-thread obj 'trans PROCESS_STACK_SAVE_SIZE (-> obj main-thread stack-top)))) (let ((trans (new 'process 'cpu-thread obj 'trans PROCESS_STACK_SAVE_SIZE (-> obj main-thread stack-top))))
;; call the function in the thread. ;; call the function in the thread.
(reset-and-call trans (-> obj trans-hook)) (reset-and-call trans (-> obj trans-hook))
(#when KERNEL_DEBUG
(when (!= (-> trans type) cpu-thread)
(format 0 "corrupted stack after trans for ~A~%" obj)
)
)
;; remove the cpu-thread ;; remove the cpu-thread
(delete trans) (delete trans)
;; check for deadness ;; check for deadness

View file

@ -707,7 +707,7 @@
) )
(defbehavior logo-init-by-other logo ((arg0 entity) (arg1 vector) (arg2 symbol)) (defbehavior logo-init-by-other logo ((arg0 entity) (arg1 vector) (arg2 symbol))
(stack-size-set! (-> self main-thread) 512) (stack-size-set! (-> self main-thread) 1024) ;; increased from 512
(logclear! (-> self mask) (process-mask progress)) (logclear! (-> self mask) (process-mask progress))
(set! (-> self entity) arg0) (set! (-> self entity) arg0)
(set! (-> self root) (new 'process 'trsqv)) (set! (-> self root) (new 'process 'trsqv))

View file

@ -651,8 +651,14 @@
) )
) )
) )
;; note: they appear to be calling this on the wrong object.
;; this doesn't actually cause any problems but corrupts the type of `float` in the symbol
;; table because they they write to some field of arg0, which is actually #t and not a
;; basebutton. The corruption is completely harmless but is annoying because it looks like
;; a more severe memory corruption problem. So we fix it.
(the-as int ((the-as (function basebutton symbol none) (find-parent-method warp-gate-switch 31)) (the-as int ((the-as (function basebutton symbol none) (find-parent-method warp-gate-switch 31))
(the-as basebutton arg0) ;;(the-as basebutton arg0)
obj
arg0 arg0
) )
) )

View file

@ -305,7 +305,7 @@ std::vector<BacktraceFrame> Debugger::get_backtrace(u64 rip, u64 rsp) {
} }
// attempt to backtrace anyway! if this fails then rip // attempt to backtrace anyway! if this fails then rip
u64 next_rip = 0; u64 next_rip = 0;
if (!read_memory_if_safe<u64>(&next_rip, rsp - m_debug_context.base)) { if (!read_memory_if_safe<u64>(&next_rip, rsp - m_debug_context.base - 8)) {
fmt::print("Invalid return address encountered!\n"); fmt::print("Invalid return address encountered!\n");
break; break;
} }
@ -555,7 +555,8 @@ void Debugger::read_symbol_table() {
sym_type = sym->type; sym_type = sym->type;
} else { } else {
if (sym_type != sym->type) { if (sym_type != sym->type) {
fmt::print("Got bad symbol type. Expected 0x{:x} got 0x{:x}\n", sym_type, sym->type); fmt::print("Got bad symbol type. Expected 0x{:x} got 0x{:x}: addr 0x{:x}\n", sym_type,
sym->type, offset + st_base + (uint64_t)m_debug_context.base);
return; return;
} }
} }