Files
water111 ee015e3b22 [jak3] A bunch of small fixes to get game.cgo to load (#3435)
The `test-play` macro is back, though it doesn't call `play` yet. We can
at least load all of `game.cgo`, which involves loading a lot of the
code we've decompiled, loading/linking objects files compiled by
OpenGOAL (like dir-tpages), and loading/linking Jak's art-groups (for
jak 3 they are stored v5 format that I added to the linker).

There were no major issues - just a few forgotten mips2c entries and
minor bugs/functions that needed stubs. Most of the work was updating
the linker. Hopefully I'll never have to touch that code again - I think
it supports everything we need for jak 3!
2024-03-24 16:30:28 -04:00

148 lines
4.6 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type matrix
(deftype matrix (structure)
"A 4x4 matrix, stored in row-major order.
some, but not all, functions assume that a matrix is an affine transform.
others assume that the rotation has no scale or shear (and that its inverse is its transpose)."
((data float 16)
(vector vector 4 :inline :overlay-at (-> data 0))
(quad uint128 4 :overlay-at (-> data 0))
(rvec vector :inline :overlay-at (-> data 0))
(uvec vector :inline :overlay-at (-> data 4))
(fvec vector :inline :overlay-at (-> data 8))
(trans vector :inline :overlay-at (-> data 12))
)
(:methods
(transform-vectors! (_type_ (inline-array vector) (inline-array vector) int) none)
)
)
;; definition for method 3 of type matrix
(defmethod inspect ((this matrix))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'matrix)
(format #t "~1Tdata[16] @ #x~X~%" (-> this rvec))
(format #t "~1Tvector[4] @ #x~X~%" (-> this rvec))
(format #t "~1Tquad[4] @ #x~X~%" (-> this rvec))
(format #t "~1Trvec: #<vector @ #x~X>~%" (-> this rvec))
(format #t "~1Tuvec: #<vector @ #x~X>~%" (-> this uvec))
(format #t "~1Tfvec: #<vector @ #x~X>~%" (-> this fvec))
(format #t "~1Ttrans: #<vector @ #x~X>~%" (-> this trans))
(label cfg-4)
this
)
;; definition of type matrix3
(deftype matrix3 (structure)
"A 3x3 matrix, stored in row-major order.
NOTE: the rows each have an extra 4-bytes of padding,
so this is really a 3x4 matrix.
This type is rarely used."
((data float 12)
(vector vector 3 :inline :overlay-at (-> data 0))
(quad uint128 3 :overlay-at (-> data 0))
)
)
;; definition for method 3 of type matrix3
(defmethod inspect ((this matrix3))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'matrix3)
(format #t "~1Tdata[12] @ #x~X~%" (-> this vector))
(format #t "~1Tvector[3] @ #x~X~%" (-> this vector))
(format #t "~1Tquad[3] @ #x~X~%" (-> this vector))
(label cfg-4)
this
)
;; definition of type matrix4h
(deftype matrix4h (structure)
"A matrix stored using 16-bit integers.
Note that these usually have different scaling for the 4th row which
contains the translation in an affine transform.
So you generally should not unpack these to floats without knowing where they came from
and how they were originally packed (for example, in tie/shrub)."
((data int16 16)
(vector4h vector4h 4 :overlay-at (-> data 0))
(long int64 4 :overlay-at (-> data 0))
)
)
;; definition for method 3 of type matrix4h
(defmethod inspect ((this matrix4h))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'matrix4h)
(format #t "~1Tdata[16] @ #x~X~%" (-> this vector4h))
(format #t "~1Tvector4h[4] @ #x~X~%" (-> this vector4h))
(format #t "~1Tlong[4] @ #x~X~%" (-> this vector4h))
(label cfg-4)
this
)
;; definition for function matrix-copy!
;; INFO: Used lq/sq
(defun matrix-copy! ((arg0 matrix) (arg1 matrix))
"Copy arg1 to arg0"
(let ((v1-0 (-> arg1 rvec quad))
(a2-0 (-> arg1 uvec quad))
(a3-0 (-> arg1 fvec quad))
(a1-1 (-> arg1 trans quad))
)
(set! (-> arg0 rvec quad) v1-0)
(set! (-> arg0 uvec quad) a2-0)
(set! (-> arg0 fvec quad) a3-0)
(set! (-> arg0 trans quad) a1-1)
)
arg0
)
;; definition for function matrix<-vector-yz-exact!
;; INFO: Used lq/sq
(defun matrix<-vector-yz-exact! ((arg0 matrix) (arg1 vector) (arg2 vector))
(set! (-> arg0 fvec quad) (-> arg1 quad))
(set! (-> arg0 uvec quad) (-> arg2 quad))
(vector-cross! (-> arg0 rvec) (-> arg0 uvec) arg1)
arg0
)
;; definition for function matrix<-vector-yz!
;; INFO: Used lq/sq
(defun matrix<-vector-yz! ((arg0 matrix) (arg1 vector) (arg2 vector))
(set! (-> arg0 fvec quad) (-> arg1 quad))
(vector-cross! (-> arg0 rvec) arg2 arg1)
(vector-normalize! (-> arg0 rvec) 1.0)
(vector-cross! (-> arg0 uvec) arg1 (-> arg0 rvec))
(set! (-> arg0 rvec w) 1.0)
(set! (-> arg0 uvec w) 1.0)
(set! (-> arg0 fvec w) 1.0)
arg0
)
;; definition for function matrix<-vector-z!
;; INFO: Used lq/sq
(defun matrix<-vector-z! ((arg0 matrix) (arg1 vector))
(let* ((s3-0 (new 'stack-no-clear 'vector))
(v1-0 (vector-get-closest-perpendicular! s3-0 arg1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1)))
(s4-1 arg0)
)
(set! (-> s4-1 fvec quad) (-> arg1 quad))
(set! (-> s4-1 uvec quad) (-> v1-0 quad))
(vector-cross! (-> s4-1 rvec) (-> s4-1 uvec) arg1)
)
arg0
)
;; failed to figure out what this is:
0