mirror of
https://github.com/open-goal/jak-project
synced 2026-08-04 09:09:52 -04:00
[Decomp] Minor fixes plus some math camera decomp (#287)
* make some progress on math camera * minor fixes plus start of decomp of math camera
This commit is contained in:
@@ -98,6 +98,10 @@ static OpcodeInfo& dfd_sfs(OpcodeInfo& info) {
|
||||
return info.dst_fpr(FT::FD).src_fpr(FT::FS);
|
||||
}
|
||||
|
||||
static OpcodeInfo& dfd_sft(OpcodeInfo& info) {
|
||||
return info.dst_fpr(FT::FD).src_fpr(FT::FT);
|
||||
}
|
||||
|
||||
static OpcodeInfo& drd(OpcodeInfo& info) {
|
||||
return info.dst_gpr(FT::RD);
|
||||
}
|
||||
@@ -338,7 +342,7 @@ void init_opcode_info() {
|
||||
dfd_sfs(def(IK::CVTSW, "cvt.s.w")); // Fixed-point Convert to Single Floating Point
|
||||
dfd_sfs(def(IK::CVTWS, "cvt.w.s")); // Floating Point Convert to Word Fixed-point
|
||||
dfd_sfs(def(IK::MOVS, "mov.s")); // Floating Point Move
|
||||
dfd_sfs(def(IK::SQRTS, "sqrt.s")); // Floating Point Square Root
|
||||
dfd_sft(def(IK::SQRTS, "sqrt.s")); // Floating Point Square Root
|
||||
|
||||
sfs_sft(def(IK::CLTS, "c.lt.s")); // Floating Point Compare
|
||||
sfs_sft(def(IK::CLES, "c.le.s")); // Floating Point Compare
|
||||
|
||||
@@ -348,7 +348,7 @@ FormElement* LoadVarOp::get_as_form(FormPool& pool, const Env& env) const {
|
||||
if (m_kind == Kind::UNSIGNED) {
|
||||
cast_type = "u" + cast_type;
|
||||
} else if (m_kind == Kind::FLOAT) {
|
||||
assert(false); // nyi
|
||||
cast_type = "float";
|
||||
}
|
||||
|
||||
auto dest = pool.alloc_single_element_form<SimpleExpressionElement>(
|
||||
|
||||
@@ -958,6 +958,7 @@
|
||||
(w int16 :offset 6)
|
||||
(long uint64 :offset 0)
|
||||
)
|
||||
:pack-me
|
||||
:method-count-assert 9
|
||||
:size-assert #x8
|
||||
:flag-assert #x900000008
|
||||
@@ -1210,7 +1211,7 @@
|
||||
|
||||
(deftype matrix (structure)
|
||||
((data float 16 :offset-assert 0)
|
||||
(vector vector 4 :offset 0)
|
||||
(vector vector 4 :inline :offset 0)
|
||||
(quad uint128 4 :offset 0)
|
||||
)
|
||||
:method-count-assert 10
|
||||
@@ -1223,7 +1224,7 @@
|
||||
|
||||
(deftype matrix3 (structure)
|
||||
((data float 12 :offset-assert 0)
|
||||
(vector vector 3 :offset 0)
|
||||
(vector vector 3 :inline :offset 0)
|
||||
(quad uint128 3 :offset 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
@@ -1233,7 +1234,7 @@
|
||||
|
||||
(deftype matrix4h (structure)
|
||||
((data int16 16 :offset-assert 0)
|
||||
(vector4h vector4h 4 :offset 0)
|
||||
(vector4h vector4h 4 :inline :offset 0)
|
||||
(long int64 4 :offset 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
@@ -1430,7 +1431,7 @@
|
||||
(define-extern matrix-rotate-z! function)
|
||||
;;(define-extern *identity-matrix* object) ;; unknown type
|
||||
(define-extern matrix-axis-angle! function)
|
||||
(define-extern matrix-rotate-zyx! function)
|
||||
(define-extern matrix-rotate-zyx! (function matrix vector matrix))
|
||||
(define-extern matrix-rotate-x! function)
|
||||
|
||||
(define-extern matrix-rotate-yxy! function)
|
||||
@@ -3772,7 +3773,7 @@
|
||||
(inv-hmge-scale vector :inline :offset-assert 720)
|
||||
(hvdf-off vector :inline :offset-assert 736)
|
||||
(guard vector :inline :offset-assert 752)
|
||||
(vis-gifs uint128 4 :offset-assert 768)
|
||||
(vis-gifs vis-gif-tag 4 :inline :offset-assert 768)
|
||||
(giftex uint128 :offset 768)
|
||||
(gifgr uint128 :offset 784)
|
||||
(giftex-trans uint128 :offset 800)
|
||||
@@ -3785,6 +3786,9 @@
|
||||
(shrub-mat matrix :inline :offset-assert 992)
|
||||
(fov-correction-factor float :offset-assert 1056)
|
||||
)
|
||||
(:methods
|
||||
(new (symbol type) _type_ 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x424
|
||||
:flag-assert #x900000424
|
||||
@@ -3799,14 +3803,31 @@
|
||||
:flag-assert #x900000008
|
||||
)
|
||||
|
||||
;;(define-extern cull-info object) ;; unknown type
|
||||
;;(define-extern math-camera object) ;; unknown type
|
||||
;;(define-extern vis-gif-tag object) ;; unknown type
|
||||
(define-extern *math-camera* math-camera) ;; unknown type
|
||||
(define-extern *math-camera-fog-correction* fog-corrector) ;; unknown type
|
||||
(define-extern init-for-transform function)
|
||||
(define-extern move-target-from-pad (function (pointer float) int none))
|
||||
(define-extern transform-point-vector! function)
|
||||
(define-extern fog-corrector-setup (function fog-corrector math-camera float))
|
||||
;;(define-extern fog-corrector object) ;; unknown type
|
||||
(define-extern math-cam-start-smoothing (function float float quaternion))
|
||||
(define-extern update-math-camera (function math-camera symbol symbol math-camera))
|
||||
(define-extern transform-point-qword! function)
|
||||
(define-extern transform-point-vector-scale! function)
|
||||
(define-extern sprite-distorter-generate-tables (function none))
|
||||
;;(define-extern ntsc object) ;; unknown type
|
||||
|
||||
;;;;;;;;;;;
|
||||
;; font-h
|
||||
;;;;;;;;;;;
|
||||
|
||||
(deftype char-verts (structure)
|
||||
((pos uint128 4 :offset-assert 0)
|
||||
(color uint128 4 :offset-assert 64)
|
||||
(tex-st uint128 4 :offset-assert 128)
|
||||
((pos vector 4 :inline :offset-assert 0)
|
||||
(color vector 4 :inline :offset-assert 64)
|
||||
(tex-st vector 4 :inline :offset-assert 128)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #xc0
|
||||
@@ -3837,17 +3858,18 @@
|
||||
:size-assert #x58
|
||||
:flag-assert #x1400000058
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
(dummy-16 () none 16)
|
||||
(dummy-17 () none 17)
|
||||
(dummy-18 () none 18)
|
||||
(dummy-19 () none 19)
|
||||
(new (symbol type int int int float int int) _type_ 0)
|
||||
(set-mat! (font-context matrix) font-context 9)
|
||||
(set-origin! (font-context int int) font-context 10)
|
||||
(set-depth! (font-context int) font-context 11)
|
||||
(set-w! (font-context int) font-context 12)
|
||||
(set-width! (font-context int) font-context 13)
|
||||
(set-height! (font-context int) font-context 14)
|
||||
(set-projection! (font-context float) font-context 15)
|
||||
(set-color! (font-context uint64) font-context 16)
|
||||
(set-flags! (font-context uint32) font-context 17)
|
||||
(set-start-line! (font-context uint32) font-context 18)
|
||||
(set-scale! (font-context float) font-context 19)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -3869,13 +3891,13 @@
|
||||
(size-st2 vector :inline :offset-assert 256)
|
||||
(size-st3 vector :inline :offset-assert 272)
|
||||
(save vector :inline :offset-assert 288)
|
||||
(save-color uint128 4 :offset-assert 304)
|
||||
(save-color vector 4 :inline :offset-assert 304)
|
||||
(current-verts char-verts :inline :offset-assert 368)
|
||||
(src-verts char-verts :inline :offset-assert 560)
|
||||
(dest-verts char-verts :inline :offset-assert 752)
|
||||
(justify uint128 64 :offset-assert 944)
|
||||
(justify vector 64 :inline :offset-assert 944)
|
||||
(color-shadow vector4w :inline :offset-assert 1968)
|
||||
(color-table uint128 64 :offset-assert 1984)
|
||||
(color-table vector 64 :inline :offset-assert 1984)
|
||||
(last-color uint64 :offset-assert 3008)
|
||||
(save-last-color uint64 :offset-assert 3016)
|
||||
(buf basic :offset-assert 3024)
|
||||
@@ -32397,7 +32419,7 @@
|
||||
|
||||
(define-extern quaternion-zero! function)
|
||||
(define-extern quaternion-set! function)
|
||||
(define-extern matrix->quaternion function)
|
||||
(define-extern matrix->quaternion (function quaternion matrix quaternion))
|
||||
(define-extern quaternion-exp! function)
|
||||
(define-extern quaternion-axis-angle! function)
|
||||
(define-extern quaternion-rotate-x! function)
|
||||
@@ -32556,26 +32578,11 @@
|
||||
;;(define-extern reserved object) ;; unknown type
|
||||
;;(define-extern default object) ;; unknown type
|
||||
;;(define-extern inactive object) ;; unknown type
|
||||
;;(define-extern cull-info object) ;; unknown type
|
||||
;;(define-extern math-camera object) ;; unknown type
|
||||
;;(define-extern vis-gif-tag object) ;; unknown type
|
||||
;;(define-extern *math-camera* object) ;; unknown type
|
||||
;;(define-extern *math-camera-fog-correction* object) ;; unknown type
|
||||
(define-extern init-for-transform function)
|
||||
(define-extern move-target-from-pad function)
|
||||
(define-extern transform-point-vector! function)
|
||||
(define-extern fog-corrector-setup function)
|
||||
;;(define-extern fog-corrector object) ;; unknown type
|
||||
(define-extern math-cam-start-smoothing function)
|
||||
(define-extern update-math-camera function)
|
||||
(define-extern transform-point-qword! function)
|
||||
(define-extern transform-point-vector-scale! function)
|
||||
(define-extern sprite-distorter-generate-tables function)
|
||||
;;(define-extern ntsc object) ;; unknown type
|
||||
|
||||
;;(define-extern aspect4x3 object) ;; unknown type
|
||||
;;(define-extern font-work object) ;; unknown type
|
||||
(define-extern font-set-tex0 function)
|
||||
;;(define-extern *font-default-matrix* object) ;; unknown type
|
||||
(define-extern font-set-tex0 (function font-work texture uint uint uint none))
|
||||
(define-extern *font-default-matrix* matrix) ;; unknown type
|
||||
;;(define-extern char-verts object) ;; unknown type
|
||||
;;(define-extern char-color object) ;; unknown type
|
||||
;;(define-extern font-context object) ;; unknown type
|
||||
@@ -32604,14 +32611,14 @@
|
||||
;;(define-extern *profile-ticks* object) ;; unknown type
|
||||
;;(define-extern *font-context* object) ;; unknown type
|
||||
(define-extern vif1-handler-debug function)
|
||||
(define-extern set-display-env function)
|
||||
(define-extern set-display-env (function display-env int int int int int int display-env))
|
||||
(define-extern set-display2 function)
|
||||
(define-extern allocate-dma-buffers function)
|
||||
(define-extern draw-string-xy function)
|
||||
;;(define-extern end-draw object) ;; unknown type
|
||||
(define-extern start function)
|
||||
;;(define-extern pal object) ;; unknown type
|
||||
(define-extern get-video-mode function)
|
||||
(define-extern get-video-mode (function symbol))
|
||||
;;(define-extern end-calc object) ;; unknown type
|
||||
;;(define-extern engine object) ;; unknown type
|
||||
;;(define-extern connectable object) ;; unknown type
|
||||
|
||||
@@ -81,5 +81,64 @@
|
||||
],
|
||||
|
||||
"level-h":[
|
||||
["L3", "_auto_", true]]
|
||||
["L3", "_auto_", true]],
|
||||
|
||||
"math-camera":[
|
||||
["L51", "float", true],
|
||||
["L52", "float", true],
|
||||
["L53", "float", true],
|
||||
["L55", "float", true],
|
||||
["L56", "float", true],
|
||||
["L38", "float", true],
|
||||
["L37", "float", true],
|
||||
["L54", "float", true],
|
||||
["L50", "float", true],
|
||||
["L49", "float", true],
|
||||
["L27", "float", true],
|
||||
["L35", "float", true],
|
||||
["L34", "float", true],
|
||||
["L28", "float", true],
|
||||
["L26", "float", true],
|
||||
["L34", "float", true],
|
||||
["L33", "float", true],
|
||||
["L30", "float", true],
|
||||
["L44", "float", true],
|
||||
["L45", "float", true],
|
||||
["L32", "float", true],
|
||||
["L31", "float", true],
|
||||
["L47", "float", true],
|
||||
["L48", "float", true],
|
||||
["L46", "float", true],
|
||||
["L36", "float", true],
|
||||
["L43", "float", true],
|
||||
["L42", "float", true],
|
||||
["L40", "float", true],
|
||||
["L41", "float", true],
|
||||
["L39", "float", true],
|
||||
["L59", "float", true]
|
||||
|
||||
],
|
||||
|
||||
"quaternion":[
|
||||
["L80", "float", true]
|
||||
],
|
||||
|
||||
"font-h":[
|
||||
["L18", "matrix", true],
|
||||
["L19", "float", true],
|
||||
["L17", "font-work", true]
|
||||
],
|
||||
|
||||
"display":[
|
||||
["L47", "float", true],
|
||||
["L42", "float", true],
|
||||
["L43", "float", true],
|
||||
["L44", "float", true],
|
||||
["L45", "float", true],
|
||||
["L48", "float", true],
|
||||
["L46", "float", true],
|
||||
["L50", "float", true],
|
||||
["L49", "float", true]
|
||||
]
|
||||
|
||||
}
|
||||
@@ -195,7 +195,12 @@
|
||||
|
||||
"glst-length-of-longest-name":[
|
||||
[17, ["s5", "glst-named-node"]]
|
||||
]
|
||||
],
|
||||
|
||||
"move-target-from-pad":[
|
||||
[2, ["sp", "int"]],
|
||||
[3, ["s4", "vector"]]
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -488,6 +488,74 @@
|
||||
|
||||
"__assert-zero-lim-range-int":{
|
||||
"args":["exp", "maximum", "msg-exp", "msg-max"]
|
||||
},
|
||||
|
||||
"update-math-camera":{
|
||||
"args":["math-cam", "ignored", "aspect"],
|
||||
"vars":{"f0-4":"temp1", "v1-1":"elim1",
|
||||
"f0-6":"temp2", "v1-2":"elim2",
|
||||
"f1-3":"x-rat", "f0-7":"y-rat",
|
||||
"v1-3":"cull-info",
|
||||
"f2-2":"unused-x-thing",
|
||||
"f2-5":"y-thing",
|
||||
"f3-11":"one-plus-2x-squared",
|
||||
"f3-14":"one-plus-2y-squared",
|
||||
"f2-9":"temp3",
|
||||
"a0-2":"elim3",
|
||||
"f2-11":"dx-rat",
|
||||
"f1-5":"dy-rat",
|
||||
"f0-10":"drat-sqr-len",
|
||||
"f2-8":"unused-thing-2",
|
||||
"f1-8":"d-temp",
|
||||
"f0-12":"temp4",
|
||||
"a0-6":"elim4",
|
||||
"f1-12":"dx-rat-2",
|
||||
"f0-14":"d-temp-2",
|
||||
"f2-13":"dx-rat-times-4",
|
||||
"f3-21":"d-temp-3",
|
||||
"f4-21":"inverse-x-len",
|
||||
"f5-11":"inverse-x-len-2",
|
||||
"f0-16":"temp5",
|
||||
"a0-7":"elim5",
|
||||
"f1-15":"dy-rat",
|
||||
"f0-18":"d-temp-4",
|
||||
"f2-15":"dy-rat-times-4",
|
||||
"f3-22":"d-temp-5",
|
||||
"f4-26":"inverse-y-len",
|
||||
"f5-16":"inverse-y-len-2",
|
||||
"f0-20":"temp6",
|
||||
"v1-4":"elim6",
|
||||
"v0-2":"cam-mat",
|
||||
"f2-16":"fog-constant-1",
|
||||
"f3-23":"fog-constant-2",
|
||||
"f0-12":"fog-contsant-3",
|
||||
"f0-24":"fog-factor-1",
|
||||
"f1-22":"fog-factor-2",
|
||||
"f4-35":"cam-fov-mult",
|
||||
"f5-19":"corrected-fog",
|
||||
"f5-23":"hvdf-x",
|
||||
"f6-29":"hvdf-y",
|
||||
"f2-18":"hvdf-z",
|
||||
"f4-40":"hvdf-w",
|
||||
"f2-19":"persp-xx",
|
||||
"f3-36":"persp-yy",
|
||||
"f1-32":"persp-x",
|
||||
"v1-11":"sprite-row-0",
|
||||
"v1-12":"sprite-row-1",
|
||||
"v1-13":"sprite-row-2",
|
||||
"v1-14":"sprite-row-3",
|
||||
"f1-37":"temp7",
|
||||
"v1-16":"elim7",
|
||||
"v1-24":"pfog",
|
||||
"a0-12":"vis-gif-0",
|
||||
"a0-13":"vis-gif-1",
|
||||
"a0-14":"vis-gif-1-again",
|
||||
"a0-15":"vis-gif-1-again-again"
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,3 +5,96 @@
|
||||
;; name in dgo: math-camera-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
|
||||
(deftype vis-gif-tag (structure)
|
||||
((fog0 uint32 :offset-assert 0)
|
||||
(strip uint32 :offset-assert 4)
|
||||
(regs uint32 :offset-assert 8)
|
||||
(fan uint32 :offset-assert 12)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x10
|
||||
:flag-assert #x900000010
|
||||
)
|
||||
|
||||
|
||||
(deftype cull-info (structure)
|
||||
((x-fact float :offset-assert 0)
|
||||
(y-fact float :offset-assert 4)
|
||||
(z-fact float :offset-assert 8)
|
||||
(cam-radius float :offset-assert 12)
|
||||
(cam-x float :offset-assert 16)
|
||||
(cam-y float :offset-assert 20)
|
||||
(xz-dir-ax float :offset-assert 24)
|
||||
(xz-dir-az float :offset-assert 28)
|
||||
(xz-dir-bx float :offset-assert 32)
|
||||
(xz-dir-bz float :offset-assert 36)
|
||||
(xz-cross-ab float :offset-assert 40)
|
||||
(yz-dir-ay float :offset-assert 44)
|
||||
(yz-dir-az float :offset-assert 48)
|
||||
(yz-dir-by float :offset-assert 52)
|
||||
(yz-dir-bz float :offset-assert 56)
|
||||
(yz-cross-ab float :offset-assert 60)
|
||||
)
|
||||
:pack-me
|
||||
:method-count-assert 9
|
||||
:size-assert #x40
|
||||
:flag-assert #x900000040
|
||||
)
|
||||
|
||||
(deftype math-camera (basic)
|
||||
((d float :offset-assert 4) ;; meters, camera near plane
|
||||
(f float :offset-assert 8) ;; meters, camera far plane
|
||||
(fov float :offset-assert 12) ;; deg, field of view angle
|
||||
(x-ratio float :offset-assert 16)
|
||||
(y-ratio float :offset-assert 20)
|
||||
(x-pix float :offset-assert 24)
|
||||
(x-clip float :offset-assert 28)
|
||||
(x-clip-ratio-in float :offset-assert 32)
|
||||
(x-clip-ratio-over float :offset-assert 36)
|
||||
(y-pix float :offset-assert 40)
|
||||
(y-clip float :offset-assert 44)
|
||||
(y-clip-ratio-in float :offset-assert 48)
|
||||
(y-clip-ratio-over float :offset-assert 52)
|
||||
(cull-info cull-info :inline :offset-assert 56)
|
||||
(fog-start float :offset-assert 120) ;; meters
|
||||
(fog-end float :offset-assert 124) ;; meters
|
||||
(fog-max float :offset-assert 128)
|
||||
(fog-min float :offset-assert 132)
|
||||
(reset int32 :offset-assert 136)
|
||||
(smooth-step float :offset-assert 140)
|
||||
(smooth-t float :offset-assert 144)
|
||||
(perspective matrix :inline :offset-assert 160)
|
||||
(isometric matrix :inline :offset-assert 224)
|
||||
(sprite-2d matrix :inline :offset-assert 288)
|
||||
(sprite-2d-hvdf vector :inline :offset-assert 352)
|
||||
(camera-rot matrix :inline :offset-assert 368)
|
||||
(inv-camera-rot matrix :inline :offset-assert 432)
|
||||
(inv-camera-rot-smooth matrix :inline :offset-assert 496)
|
||||
(inv-camera-rot-smooth-from quaternion :inline :offset-assert 560)
|
||||
(camera-temp matrix :inline :offset-assert 576)
|
||||
(prev-camera-temp matrix :inline :offset-assert 640)
|
||||
(hmge-scale vector :inline :offset-assert 704)
|
||||
(inv-hmge-scale vector :inline :offset-assert 720)
|
||||
(hvdf-off vector :inline :offset-assert 736)
|
||||
(guard vector :inline :offset-assert 752)
|
||||
(vis-gifs vis-gif-tag 4 :inline :offset-assert 768)
|
||||
(giftex uint128 :offset 768)
|
||||
(gifgr uint128 :offset 784)
|
||||
(giftex-trans uint128 :offset 800)
|
||||
(gifgr-trans uint128 :offset 816)
|
||||
(pfog0 float :offset-assert 832)
|
||||
(pfog1 float :offset-assert 836)
|
||||
(trans vector :inline :offset-assert 848)
|
||||
(plane uint128 4 :offset-assert 864)
|
||||
(guard-plane uint128 4 :offset-assert 928)
|
||||
(shrub-mat matrix :inline :offset-assert 992)
|
||||
(fov-correction-factor float :offset-assert 1056)
|
||||
)
|
||||
(:methods
|
||||
(new (symbol type) _type_ 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x424
|
||||
:flag-assert #x900000424
|
||||
)
|
||||
|
||||
@@ -5,3 +5,397 @@
|
||||
;; name in dgo: math-camera
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
(deftype fog-corrector (structure)
|
||||
((fog-end float :offset-assert 0)
|
||||
(fog-start float :offset-assert 4)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x8
|
||||
:flag-assert #x900000008
|
||||
)
|
||||
|
||||
|
||||
(defun fog-corrector-setup ((arg0 fog-corrector) (arg1 math-camera))
|
||||
"Set up a fog-corrector based on the math-camera"
|
||||
(set! (-> arg0 fog-end) (* (-> arg1 fog-end) (-> arg1 fov-correction-factor)))
|
||||
(set! (-> arg0 fog-start) (* (-> arg1 fog-start) (-> arg1 fov-correction-factor)))
|
||||
)
|
||||
|
||||
(define *math-camera-fog-correction* (new 'global 'fog-corrector))
|
||||
|
||||
(define-extern sprite-distorter-generate-tables (function none))
|
||||
|
||||
(defun update-math-camera ((math-cam math-camera) (video-mode symbol) (aspect symbol))
|
||||
(local-vars
|
||||
(cam-mat matrix)
|
||||
(cull-info cull-info)
|
||||
(sprite-row-0 matrix)
|
||||
(sprite-row-1 (pointer float))
|
||||
(sprite-row-2 (pointer float))
|
||||
(sprite-row-3 (pointer float))
|
||||
(v1-15 vector)
|
||||
(v1-17 int)
|
||||
(v1-19 int)
|
||||
(v1-20 int)
|
||||
(v1-22 int)
|
||||
(v1-23 int)
|
||||
(pfog float)
|
||||
(a0-10 vector)
|
||||
(a0-11 int)
|
||||
(vis-gif-0 vis-gif-tag)
|
||||
(vis-gif-1 vis-gif-tag)
|
||||
(vis-gif-1-again vis-gif-tag)
|
||||
(vis-gif-1-again-again vis-gif-tag)
|
||||
(a1-5 int)
|
||||
(a1-6 int)
|
||||
(y-rat float)
|
||||
(drat-sqr-len float)
|
||||
(fog-contsant-3 float)
|
||||
(d-temp-2 float)
|
||||
(d-temp-4 float)
|
||||
(fog-constant-3 float)
|
||||
(fog-at-d float)
|
||||
(x-rat float)
|
||||
(dy-rat float)
|
||||
(d-temp float)
|
||||
(dx-rat-2 float)
|
||||
;;(dy-rat float)
|
||||
(mid-range float)
|
||||
(persp-x float)
|
||||
(temp7 float)
|
||||
(unused-x-thing float)
|
||||
(y-thing float)
|
||||
(dx-rat float)
|
||||
(dx-rat-times-4 float)
|
||||
(dy-rat-times-4 float)
|
||||
(very-near float)
|
||||
(hvdf-z float)
|
||||
(persp-xx float)
|
||||
(d-temp-3 float)
|
||||
(d-temp-5 float)
|
||||
(very-far float)
|
||||
(persp-yy float)
|
||||
(inverse-x-len float)
|
||||
(inverse-y-len float)
|
||||
(cam-fov-mult float)
|
||||
(hvdf-w float)
|
||||
(inverse-x-len-2 float)
|
||||
(inverse-y-len-2 float)
|
||||
(range-factor float)
|
||||
(hvdf-x float)
|
||||
(hvdf-y float)
|
||||
)
|
||||
|
||||
;; Camera Math:
|
||||
;; The camera transformation projects a point in space to the camera's projection plane.
|
||||
;; The usual camera frustum is shown below:
|
||||
|
||||
;;
|
||||
;; * <- the camera origin.
|
||||
;; --- <- project the point onto this plane, the screen.
|
||||
;; / | \
|
||||
;; / | \
|
||||
;; / | * \ <- some point in the world
|
||||
|
||||
;; The "x ratio" is the slope of frustum:
|
||||
;; for a point on the frustum (px,pz), it satisfies x_ratio * pz = px.
|
||||
|
||||
;; Compute the x-ratio using half of the fov angle (the triangle is the midplane, frustum wall, and offset in x)
|
||||
(set! (-> math-cam x-ratio) (tan (* 0.500000 (-> math-cam fov))))
|
||||
|
||||
;; The plane has the same aspect ratio as the screen, so we can derive the y-ratio
|
||||
;; based on the game's aspect ratio setting.
|
||||
(if (= aspect 'aspect4x3)
|
||||
(set! (-> math-cam y-ratio) (* 0.75 (-> math-cam x-ratio)))
|
||||
(set! (-> math-cam y-ratio) (* 0.5625 (-> math-cam x-ratio)))
|
||||
)
|
||||
|
||||
;; Eventually, we will want to cull things that are oustide of the view frustum.
|
||||
;; To do this, we need to compute the equation of the planes for the sides of the frustum.
|
||||
;; I'm not yet sure what these "x-fact" things are, but likely related to their culling strategy.
|
||||
(set! x-rat (-> math-cam x-ratio))
|
||||
(set! y-rat (-> math-cam y-ratio))
|
||||
(set! cull-info (-> math-cam cull-info))
|
||||
|
||||
(set! unused-x-thing
|
||||
(/ (+ 1.000000 (* (* 4.000000 x-rat) x-rat)) (+ 1.000000 (* x-rat x-rat)))
|
||||
)
|
||||
|
||||
(set! y-thing
|
||||
(/ (+ 1.000000 (* (* 4.000000 y-rat) y-rat)) (+ 1.000000 (* y-rat y-rat)))
|
||||
)
|
||||
|
||||
(set!
|
||||
(-> cull-info x-fact)
|
||||
(/ (+ 1.000000 (* (* 4.000000 x-rat) x-rat))
|
||||
(* x-rat (sqrtf (+ 1.000000 (* (* 16.000000 x-rat) x-rat))))
|
||||
)
|
||||
)
|
||||
|
||||
(set!
|
||||
(-> cull-info y-fact)
|
||||
(/ (+ 1.000000 (* (* 4.000000 y-rat) y-rat))
|
||||
(* y-rat (sqrtf (+ 1.000000 (* (* 16.000000 y-rat) y-rat))))
|
||||
)
|
||||
)
|
||||
|
||||
(set! (-> cull-info z-fact)
|
||||
(sqrtf (+ (* (* (* (+ -4.000000 y-thing) (+ -4.000000 y-thing)) y-rat) y-rat)
|
||||
(* (+ -1.000000 y-thing) (+ -1.000000 y-thing))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; this is the distance from the origin of the projection plane to the frustum, in x
|
||||
(set! dx-rat (* x-rat (-> math-cam d)))
|
||||
;; this is the distance from the origin of the projection plane to the frustum, in y
|
||||
(set! dy-rat (* y-rat (-> math-cam d)))
|
||||
;; this is the distance from the origin of the projection plane to the corner of the frustum
|
||||
(set! drat-sqr-len (+ (* dx-rat dx-rat) (* dy-rat dy-rat)))
|
||||
|
||||
;; this is the distance from the origin (behind the projection plane)
|
||||
;; to the farthest point of the intersection of the view frustum and the projection plane
|
||||
(set! d-temp (-> math-cam d))
|
||||
(set! (-> cull-info cam-radius) (sqrtf (+ drat-sqr-len (* d-temp d-temp))))
|
||||
|
||||
;; origin of projection plane to frustum, x
|
||||
(set! dx-rat-2 (* (-> math-cam d) (-> math-cam x-ratio)))
|
||||
(set! d-temp-2 (-> math-cam d))
|
||||
|
||||
;; ?? not sure what this is used for
|
||||
(set! dx-rat-times-4 (* 4.000000 dx-rat-2))
|
||||
(set! d-temp-3 (-> math-cam d))
|
||||
|
||||
;; 1/length(cam origin to frust x on projection plane)
|
||||
(set! inverse-x-len
|
||||
(/ 1.000000 (sqrtf (+ (* dx-rat-2 dx-rat-2) (* d-temp-2 d-temp-2))))
|
||||
)
|
||||
(set! inverse-x-len-2
|
||||
(/ 1.000000
|
||||
(sqrtf (+ (* dx-rat-times-4 dx-rat-times-4) (* d-temp-3 d-temp-3)))
|
||||
)
|
||||
)
|
||||
(set! (-> cull-info xz-dir-ax) (* dx-rat-2 inverse-x-len)) ;; frustum normal x (scaled)
|
||||
(set! (-> cull-info xz-dir-az) (* d-temp-2 inverse-x-len)) ;; normal z (scaled)
|
||||
|
||||
;; not sure what this "b" means, but it just seems like it's a much wider frustum?
|
||||
(set! (-> cull-info xz-dir-bx) (* dx-rat-times-4 inverse-x-len-2))
|
||||
(set! (-> cull-info xz-dir-bz) (* d-temp-3 inverse-x-len-2))
|
||||
|
||||
;; not sure why you'd want this, but okay.
|
||||
(set! (-> cull-info xz-cross-ab) (- (* dx-rat-2 d-temp-3) (* d-temp-2 dx-rat-times-4)))
|
||||
|
||||
;; Repeat of the above math for y.
|
||||
(set! dy-rat (* (-> math-cam d) (-> math-cam y-ratio)))
|
||||
(set! d-temp-4 (-> math-cam d))
|
||||
(set! dy-rat-times-4 (* 4.000000 dy-rat))
|
||||
(set! d-temp-5 (-> math-cam d))
|
||||
(set! inverse-y-len
|
||||
(/ 1.000000 (sqrtf (+ (* dy-rat dy-rat) (* d-temp-4 d-temp-4))))
|
||||
)
|
||||
(set! inverse-y-len-2
|
||||
(/ 1.000000
|
||||
(sqrtf (+ (* dy-rat-times-4 dy-rat-times-4) (* d-temp-5 d-temp-5)))
|
||||
)
|
||||
)
|
||||
(set! (-> cull-info yz-dir-ay) (* dy-rat inverse-y-len))
|
||||
(set! (-> cull-info yz-dir-az) (* d-temp-4 inverse-y-len))
|
||||
(set! (-> cull-info yz-dir-by) (* dy-rat-times-4 inverse-y-len-2))
|
||||
(set! (-> cull-info yz-dir-bz) (* d-temp-5 inverse-y-len-2))
|
||||
(set! (-> cull-info yz-cross-ab) (- (* dy-rat d-temp-5) (* d-temp-4 dy-rat-times-4)))
|
||||
|
||||
|
||||
;; update the fog corrector.
|
||||
(fog-corrector-setup *math-camera-fog-correction* math-cam)
|
||||
;; not sure why we do this here.
|
||||
(set! cam-mat (matrix-identity! (-> math-cam camera-rot)))
|
||||
(set! very-near 100.000000)
|
||||
(set! very-far 16760631.000000) ;; this is ~4091.95 meters.
|
||||
(set! fog-constant-3 16777115.000000) ;; unused.
|
||||
|
||||
;; this is actually fog.
|
||||
(set! fog-at-d
|
||||
(/ (* (-> math-cam d) (- (-> math-cam fog-min) (-> math-cam fog-max))) ;; fog of the plane
|
||||
(- (-> *math-camera-fog-correction* fog-end) (-> *math-camera-fog-correction* fog-start)) ;; corrected fog.
|
||||
)
|
||||
)
|
||||
|
||||
(set! mid-range (* -0.500000 (- very-far very-near)))
|
||||
|
||||
;; not sure what this is doing exactly
|
||||
(set! range-factor
|
||||
(/ mid-range
|
||||
(* (-> math-cam d) (- (-> math-cam f) (-> math-cam d)))
|
||||
)
|
||||
)
|
||||
|
||||
(set! cam-fov-mult (-> math-cam fov-correction-factor))
|
||||
|
||||
|
||||
(set! (-> math-cam perspective data 0)
|
||||
(* cam-fov-mult
|
||||
(- (/ (-> math-cam x-pix) ;; scale for pixels I guess?
|
||||
(* (-> math-cam x-ratio) (-> math-cam d)) ;; width of frustum
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set! (-> math-cam perspective data 5)
|
||||
(* cam-fov-mult
|
||||
(- (/ (-> math-cam y-pix) (* (-> math-cam y-ratio) (-> math-cam d))))
|
||||
)
|
||||
)
|
||||
(set! (-> math-cam perspective data 10)
|
||||
(* cam-fov-mult
|
||||
(+ (-> math-cam f) (-> math-cam d))
|
||||
range-factor
|
||||
)
|
||||
)
|
||||
(set! (-> math-cam perspective data 11)
|
||||
(* (/ cam-fov-mult (-> math-cam d)) fog-at-d)
|
||||
)
|
||||
(set! (-> math-cam perspective data 14)
|
||||
(* -2.000000 range-factor (-> math-cam f) (-> math-cam d) cam-fov-mult)
|
||||
)
|
||||
(set! hvdf-x 2048.000000)
|
||||
(set! hvdf-y 2048.000000)
|
||||
(set! hvdf-w
|
||||
(/ (- (* (-> *math-camera-fog-correction* fog-end) (-> math-cam fog-max))
|
||||
(* (-> *math-camera-fog-correction* fog-start) (-> math-cam fog-min))
|
||||
)
|
||||
(- (-> *math-camera-fog-correction* fog-end)
|
||||
(-> *math-camera-fog-correction* fog-start)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set! hvdf-z (* 0.500000 (+ very-far very-near)))
|
||||
(set! (-> math-cam hmge-scale data 0) (/ 1.000000 (-> math-cam x-clip)))
|
||||
(set! (-> math-cam hmge-scale data 1) (/ 1.000000 (-> math-cam y-clip)))
|
||||
(set! (-> math-cam hmge-scale data 2) (/ 1.000000 mid-range))
|
||||
(set! (-> math-cam hmge-scale data 3) (/ 1.000000 fog-at-d))
|
||||
(set! (-> math-cam inv-hmge-scale data 0) (-> math-cam x-clip))
|
||||
(set! (-> math-cam inv-hmge-scale data 1) (-> math-cam y-clip))
|
||||
(set! (-> math-cam inv-hmge-scale data 2) mid-range)
|
||||
(set! (-> math-cam inv-hmge-scale data 3) fog-at-d)
|
||||
(set! (-> math-cam hvdf-off data 0) hvdf-x)
|
||||
(set! (-> math-cam hvdf-off data 1) hvdf-y)
|
||||
(set! (-> math-cam hvdf-off data 2) hvdf-z)
|
||||
(set! (-> math-cam hvdf-off data 3) hvdf-w)
|
||||
(set! (-> math-cam guard data 0) (/ (-> math-cam x-clip) (-> math-cam x-pix)))
|
||||
(set! (-> math-cam guard data 1) (/ (-> math-cam y-clip) (-> math-cam y-pix)))
|
||||
(set! (-> math-cam guard data 2) 1.000000)
|
||||
(set! (-> math-cam guard data 3) 1.000000)
|
||||
(set! (-> math-cam isometric data 14) (- 16777215.000000 hvdf-z))
|
||||
(set! (-> math-cam isometric data 15) fog-at-d)
|
||||
(set! persp-xx (-> math-cam perspective data 0))
|
||||
(set! persp-yy (-> math-cam perspective data 5))
|
||||
(set! persp-x (* (the-as float #xbffff2e5) (-> math-cam perspective data 0)))
|
||||
(set! sprite-row-0 (-> math-cam sprite-2d))
|
||||
(set! (-> sprite-row-0 data 0) persp-x)
|
||||
(set! (-> sprite-row-0 data 1) 0.000000)
|
||||
(set! (-> sprite-row-0 data 2) 0.000000)
|
||||
(set! (-> sprite-row-0 data 3) 0.000000)
|
||||
(set! sprite-row-1 (&-> math-cam sprite-2d data 4))
|
||||
(set! (-> sprite-row-1 0) 0.000000)
|
||||
(set! (-> sprite-row-1 1) (- (* (/ persp-yy persp-xx) persp-x)))
|
||||
(set! (-> sprite-row-1 2) 0.000000)
|
||||
(set! (-> sprite-row-1 3) 0.000000)
|
||||
(set! sprite-row-2 (&-> math-cam sprite-2d data 8))
|
||||
(set! (-> sprite-row-2 0) 0.000000)
|
||||
(set! (-> sprite-row-2 1) 0.000000)
|
||||
(set! (-> sprite-row-2 2) (- persp-x))
|
||||
(set! (-> sprite-row-2 3) 0.000000)
|
||||
(set! sprite-row-3 (&-> math-cam sprite-2d data 12))
|
||||
(set! (-> sprite-row-3 0) 0.000000)
|
||||
(set! (-> sprite-row-3 1) 0.000000)
|
||||
(set! (-> sprite-row-3 2) (* 500000000.000000 persp-x))
|
||||
(set! (-> sprite-row-3 3) (* (* 60.000000 persp-x) (-> math-cam pfog0)))
|
||||
(set! v1-15 (-> math-cam sprite-2d-hvdf))
|
||||
(set! a0-10 (-> math-cam hvdf-off))
|
||||
|
||||
;;(.lq a0-11 0 a0-10)
|
||||
;;(.sq a0-11 0 v1-15)
|
||||
(rlet ((a0-11 :class vf))
|
||||
(.lvf a0-11 a0-10)
|
||||
(.svf v1-15 a0-11)
|
||||
)
|
||||
|
||||
(set! (-> math-cam sprite-2d-hvdf data 0) 2048.000000)
|
||||
(set! (-> math-cam sprite-2d-hvdf data 1) 2048.000000)
|
||||
(set! (-> math-cam sprite-2d-hvdf data 2) (-> math-cam hvdf-off data 2))
|
||||
(set! (-> math-cam pfog0) fog-at-d)
|
||||
(set! (-> math-cam pfog1) hvdf-w)
|
||||
;; unused
|
||||
;;(set! v1-17 0)
|
||||
;;(set! v1-19 (shl #x301ec000 32))
|
||||
;;(.pcpyld v1-20 r0-0 v1-19)
|
||||
;;(set! v1-22 (shl #x303ec000 32))
|
||||
;;(.pcpyld v1-23 r0-0 v1-22)
|
||||
(set! pfog (-> math-cam pfog0))
|
||||
(set! vis-gif-0 (-> math-cam vis-gifs 0))
|
||||
(set! (-> vis-gif-0 fog0) (the-as uint pfog))
|
||||
(set! (-> vis-gif-0 strip) #x301e4000)
|
||||
(set! (-> vis-gif-0 regs) 1042)
|
||||
(set! (-> vis-gif-0 fan) #x301ec000)
|
||||
(set! vis-gif-1 (-> math-cam vis-gifs 1))
|
||||
(set! (-> vis-gif-1 fog0) (the-as uint pfog))
|
||||
(set! a1-5 (shl #x20164000 32))
|
||||
;;(.pcpyld a1-6 r0-0 a1-5) no effect
|
||||
(set! (-> vis-gif-1 strip) a1-5)
|
||||
|
||||
(set! (-> vis-gif-1 regs) 65)
|
||||
(set! (-> vis-gif-1 fan) #x301ec000)
|
||||
(set! vis-gif-1-again (-> math-cam vis-gifs 0))
|
||||
(set! (-> vis-gif-1-again fog0) (the-as uint pfog))
|
||||
(set! (-> vis-gif-1-again strip) #x303e4000)
|
||||
(set! (-> vis-gif-1-again regs) 1042)
|
||||
(set! (-> vis-gif-1-again fan) #x303ec000)
|
||||
(set! vis-gif-1-again-again (-> math-cam vis-gifs 0))
|
||||
(set! (-> vis-gif-1-again-again fog0) (the-as uint pfog))
|
||||
(set! (-> vis-gif-1-again-again strip) #x303e4000)
|
||||
(set! (-> vis-gif-1-again-again regs) 1042)
|
||||
(set! (-> vis-gif-1-again-again fan) #x303ec000)
|
||||
(if (nonzero? sprite-distorter-generate-tables)
|
||||
(sprite-distorter-generate-tables)
|
||||
)
|
||||
math-cam
|
||||
)
|
||||
|
||||
(defmethod new math-camera ((allocation symbol) (type-to-make type))
|
||||
"Allocate and initialize a math-camera.
|
||||
NOTE: the result is full of nans due to fov-correction-factor being unset and defaulting to 0.
|
||||
This matches what I remember from PS2 emulator stuff."
|
||||
(local-vars (v1-2 vector) (obj math-camera))
|
||||
(set! obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))
|
||||
(set! (-> obj d) 1024.000000) ;; near plane
|
||||
(set! (-> obj f) 40960000.000000) ;; far plane (4096 meters)
|
||||
(set! (-> obj fov) (the-as float #x46360b61)) ;; 64 degrees
|
||||
(set! (-> obj x-pix) 256.000000)
|
||||
;; not sure what this is, but it seems like there's a 4x wide clipping plane called "b"
|
||||
(set! (-> obj x-clip) 1024.000000)
|
||||
(set! (-> obj y-pix) 112.000000)
|
||||
;; again, 4x wide clippin gthing
|
||||
(set! (-> obj y-clip) 448.000000)
|
||||
;; start fog at 10 meters
|
||||
(set! (-> obj fog-start) 40960.000000)
|
||||
;; end fog at 200 meters
|
||||
(set! (-> obj fog-end) 819200.000000)
|
||||
;; are these the actual fog values used?
|
||||
(set! (-> obj fog-max) 255.000000)
|
||||
(set! (-> obj fog-min) 150.000000)
|
||||
(matrix-identity! (-> obj inv-camera-rot))
|
||||
(matrix-identity! (-> obj camera-rot))
|
||||
;;(set! v1-2 (-> obj trans))
|
||||
;;(.sqc2 vf0 0 v1-2)
|
||||
(vector-zero! (-> obj trans))
|
||||
(set! (-> obj isometric data 0) 1.000000) ;; xx
|
||||
(set! (-> obj isometric data 5) 0.500000) ;; yy
|
||||
(set! (-> obj isometric data 10) -1.000000) ;; zz
|
||||
(set! (-> obj reset) 1)
|
||||
(set! (-> obj smooth-step) 0.000000)
|
||||
(set! (-> obj smooth-t) 0.000000)
|
||||
;; setup initial math camera
|
||||
(update-math-camera obj 'ntsc 'aspect4x3)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -5,3 +5,13 @@
|
||||
;; name in dgo: decomp-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
(deftype decomp-work (structure)
|
||||
((buffer0 uint8 2048 :offset-assert 0)
|
||||
(buffer1 uint8 2048 :offset-assert 2048)
|
||||
(indices uint16 2048 :offset-assert 4096)
|
||||
(temp-indices uint16 2048 :offset-assert 8192)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x3000
|
||||
:flag-assert #x900003000
|
||||
)
|
||||
@@ -8,7 +8,7 @@
|
||||
;; matrix-h
|
||||
(deftype matrix (structure)
|
||||
((data float 16 :offset-assert 0)
|
||||
(vector vector 4 :offset 0)
|
||||
(vector vector 4 :inline :offset 0)
|
||||
(quad uint128 4 :offset 0)
|
||||
)
|
||||
:method-count-assert 10
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
(deftype matrix3 (structure)
|
||||
((data float 12 :offset-assert 0)
|
||||
(vector vector 3 :offset 0)
|
||||
(vector vector 3 :inline :offset 0)
|
||||
(quad uint128 3 :offset 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
@@ -32,7 +32,7 @@
|
||||
;; guess on signs here
|
||||
(deftype matrix4h (structure)
|
||||
((data int16 16 :offset-assert 0)
|
||||
(vector4h vector4h 4 :offset 0)
|
||||
(vector4h vector4h 4 :inline :offset 0)
|
||||
(long int64 4 :offset 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
|
||||
@@ -5,3 +5,20 @@
|
||||
;; name in dgo: matrix
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
(defun matrix-identity! ((m matrix))
|
||||
(rlet ((vf1 :class vf))
|
||||
;; zero
|
||||
(.xor.vf vf1 vf1 vf1)
|
||||
(.svf (-> m vector 0) vf1)
|
||||
(.svf (-> m vector 1) vf1)
|
||||
(.svf (-> m vector 2) vf1)
|
||||
(.svf (-> m vector 2) vf1)
|
||||
)
|
||||
(let ((one 1.0))
|
||||
(set! (-> m data 15) one)
|
||||
(set! (-> m data 10) one)
|
||||
(set! (-> m data 5) one)
|
||||
(set! (-> m data 0) one)
|
||||
)
|
||||
m
|
||||
)
|
||||
|
||||
@@ -19,4 +19,6 @@
|
||||
:flag-assert #x900000010
|
||||
)
|
||||
|
||||
(define *unity-quaternion* (new 'static 'quaternion :x 0.0 :y 0.0 :z 0.0 :w 1.0))
|
||||
(define *unity-quaternion* (new 'static 'quaternion :x 0.0 :y 0.0 :z 0.0 :w 1.0))
|
||||
|
||||
(define-extern matrix->quaternion (function quaternion matrix quaternion))
|
||||
|
||||
@@ -263,6 +263,7 @@
|
||||
(w int16 :offset 6)
|
||||
(long uint64 :offset 0)
|
||||
)
|
||||
:pack-me
|
||||
:method-count-assert 9
|
||||
:size-assert #x8
|
||||
:flag-assert #x900000008
|
||||
|
||||
@@ -298,15 +298,21 @@ Val* Compiler::compile_function_or_method_call(const goos::Object& form, Env* en
|
||||
if (!auto_inline) {
|
||||
// if auto-inlining failed, we must get the thing to call in a different way.
|
||||
if (uneval_head.is_symbol()) {
|
||||
if (is_local_symbol(uneval_head, env) ||
|
||||
m_symbol_types.find(symbol_string(uneval_head)) != m_symbol_types.end()) {
|
||||
// the local environment (mlets, lexicals, constants, globals) defines this symbol.
|
||||
// this will "win" over a method name lookup, so we should compile as normal
|
||||
head = compile_error_guard(args.unnamed.front(), env);
|
||||
} else {
|
||||
// we don't think compiling the head give us a function, so it's either a method or an error
|
||||
if (uneval_head.as_symbol()->name == "inspect" || uneval_head.as_symbol()->name == "print") {
|
||||
is_method_call = true;
|
||||
} else {
|
||||
if (is_local_symbol(uneval_head, env) ||
|
||||
m_symbol_types.find(symbol_string(uneval_head)) != m_symbol_types.end()) {
|
||||
// the local environment (mlets, lexicals, constants, globals) defines this symbol.
|
||||
// this will "win" over a method name lookup, so we should compile as normal
|
||||
head = compile_error_guard(args.unnamed.front(), env);
|
||||
} else {
|
||||
// we don't think compiling the head give us a function, so it's either a method or an
|
||||
// error
|
||||
is_method_call = true;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// the head is some expression. Could be something like (inline my-func) or (-> obj
|
||||
// func-ptr-field) in either case, compile it - and it can't be a method call.
|
||||
|
||||
@@ -123,16 +123,16 @@ void Compiler::generate_field_description(const goos::Object& form,
|
||||
// Dynamic Field
|
||||
str_template += fmt::format("~T{}[0] @ #x~X~%", f.name());
|
||||
format_args.push_back(get_field_of_structure(type, reg, f.name(), env)->to_gpr(env));
|
||||
} else if (f.is_dynamic()) {
|
||||
// Structure
|
||||
str_template += fmt::format("~T{}: #<{} @ #x~X>~%", f.name(), f.type().print());
|
||||
format_args.push_back(get_field_of_structure(type, reg, f.name(), env)->to_gpr(env));
|
||||
} else if (m_ts.typecheck(m_ts.make_typespec("basic"), f.type(), "", false, false) ||
|
||||
m_ts.typecheck(m_ts.make_typespec("binteger"), f.type(), "", false, false) ||
|
||||
m_ts.typecheck(m_ts.make_typespec("pair"), f.type(), "", false, false)) {
|
||||
// basic, binteger, pair
|
||||
str_template += fmt::format("~T{}: ~A~%", f.name());
|
||||
format_args.push_back(get_field_of_structure(type, reg, f.name(), env)->to_gpr(env));
|
||||
} else if (m_ts.typecheck(m_ts.make_typespec("structure"), f.type(), "", false, false)) {
|
||||
// Structure
|
||||
str_template += fmt::format("~T{}: #<{} @ #x~X>~%", f.name(), f.type().print());
|
||||
format_args.push_back(get_field_of_structure(type, reg, f.name(), env)->to_gpr(env));
|
||||
} else if (m_ts.typecheck(m_ts.make_typespec("integer"), f.type(), "", false, false)) {
|
||||
// Integer
|
||||
if (f.type().print() == "uint128") {
|
||||
|
||||
@@ -1 +1 @@
|
||||
(print (-> type parent parent)) 0
|
||||
((the (function object object) print) (-> type parent parent)) 0
|
||||
Reference in New Issue
Block a user