From b79f28fe07618dfd234407a06462a33a01693fca Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Sun, 7 May 2023 12:12:21 -0400 Subject: [PATCH] [jak2] combined shadow work PR (#2632) This PR is a combination of https://github.com/open-goal/jak-project/pull/2507 and some additional changes to port Shadow VU1 to OpenGL. As far as I can tell, it's working. --------- Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com> --- common/dma/dma_chain_read.h | 11 + decompiler/config/jak2/all-types.gc | 88 +- decompiler/config/jak2/ntsc_v1/hacks.jsonc | 19 +- .../config/jak2/ntsc_v1/type_casts.jsonc | 138 +- .../config/jak2/ntsc_v1/var_names.jsonc | 8 + docs/progress-notes/jak2/shadow-vu1.txt | 851 +++++ game/CMakeLists.txt | 2 + .../opengl_renderer/BucketRenderer.cpp | 25 + .../graphics/opengl_renderer/BucketRenderer.h | 13 + .../opengl_renderer/OpenGLRenderer.cpp | 6 +- game/graphics/opengl_renderer/Shader.cpp | 1 + game/graphics/opengl_renderer/Shader.h | 1 + .../graphics/opengl_renderer/ShadowRenderer.h | 2 +- game/graphics/opengl_renderer/Shadow_PS2.cpp | 2 +- .../opengl_renderer/foreground/Shadow2.cpp | 578 ++++ .../opengl_renderer/foreground/Shadow2.h | 97 + .../opengl_renderer/ocean/OceanMidAndFar.cpp | 9 - .../opengl_renderer/shaders/shadow2.frag | 8 + .../opengl_renderer/shaders/shadow2.vert | 37 + game/kernel/jak2/kmachine.cpp | 8 +- game/mips2c/jak2_functions/shadow.cpp | 2803 +++++++++++++++++ game/mips2c/jak2_functions/squid.cpp | 1 + game/mips2c/mips2c_table.cpp | 28 +- goal_src/jak2/engine/draw/drawable.gc | 8 +- goal_src/jak2/engine/game/main.gc | 3 + .../jak2/engine/gfx/foreground/foreground.gc | 177 +- .../engine/gfx/foreground/shadow-cpu-h.gc | 18 +- .../jak2/engine/gfx/foreground/shadow-cpu.gc | 812 ++++- .../jak2/engine/gfx/foreground/shadow-vu1.gc | 225 ++ goal_src/jak2/kernel-defs.gc | 2 + .../jak2/engine/draw/drawable_REF.gc | 10 +- .../engine/gfx/foreground/shadow-cpu_REF.gc | 923 ++++++ .../engine/gfx/foreground/shadow-vu1_REF.gc | 283 ++ test/decompiler/test_VuDisasm.cpp | 14 + .../vu_reference/jak2/shadow-vu0-result.txt | 88 + .../vu_reference/jak2/shadow-vu0.txt | 176 ++ .../vu_reference/jak2/shadow-vu1-result.txt | 799 +++++ .../vu_reference/jak2/shadow-vu1.txt | 1492 +++++++++ test/offline/config/jak2/config.jsonc | 4 +- 39 files changed, 9659 insertions(+), 111 deletions(-) create mode 100644 docs/progress-notes/jak2/shadow-vu1.txt create mode 100644 game/graphics/opengl_renderer/foreground/Shadow2.cpp create mode 100644 game/graphics/opengl_renderer/foreground/Shadow2.h create mode 100644 game/graphics/opengl_renderer/shaders/shadow2.frag create mode 100644 game/graphics/opengl_renderer/shaders/shadow2.vert create mode 100644 game/mips2c/jak2_functions/shadow.cpp create mode 100644 test/decompiler/reference/jak2/engine/gfx/foreground/shadow-cpu_REF.gc create mode 100644 test/decompiler/reference/jak2/engine/gfx/foreground/shadow-vu1_REF.gc create mode 100644 test/decompiler/vu_reference/jak2/shadow-vu0-result.txt create mode 100644 test/decompiler/vu_reference/jak2/shadow-vu0.txt create mode 100644 test/decompiler/vu_reference/jak2/shadow-vu1-result.txt create mode 100644 test/decompiler/vu_reference/jak2/shadow-vu1.txt diff --git a/common/dma/dma_chain_read.h b/common/dma/dma_chain_read.h index 5e6f5f582f..d908478af1 100644 --- a/common/dma/dma_chain_read.h +++ b/common/dma/dma_chain_read.h @@ -106,6 +106,17 @@ class DmaFollower { return result; } + DmaTransfer advance_and_print_dma(DmaFollower& dma) { + auto data = dma.read_and_advance(); + printf( + "dma transfer:\n%ssize: %d\nvif0: %s, data: %d\nvif1: %s, data: %d, imm: " + "%d\n\n", + dma.current_tag().print().c_str(), data.size_bytes, data.vifcode0().print().c_str(), + data.vif0(), data.vifcode1().print().c_str(), data.vifcode1().num, + data.vifcode1().immediate); + return data; + } + DmaTag current_tag() const { return DmaTag(read_val(m_tag_offset)); } u32 current_tag_vif0() const { return read_val(m_tag_offset + 8); } u32 current_tag_vif1() const { return read_val(m_tag_offset + 12); } diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index a8723be351..5ef40f4981 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -12567,12 +12567,14 @@ :flag-assert #x9000025b0 ) +(declare-type shadow-vu1-constants structure) + (deftype shadow-bucket (structure) - ((first uint32 :offset-assert 0) - (next uint32 :offset-assert 4) + ((first pointer :offset-assert 0) + (next pointer :offset-assert 4) (bucket-id int32 :offset-assert 8) (shadow-color rgba :offset-assert 12) - (constants basic :offset-assert 16) + (constants shadow-vu1-constants :offset-assert 16) ) :allow-misaligned :method-count-assert 9 @@ -12702,9 +12704,9 @@ ) (define-extern *shadow-globals* shadow-globals) -(define-extern *shadow* object) ;; symbol -(define-extern *shadow-object* object) -(define-extern *shadow-debug* object) +(define-extern *shadow* symbol) ;; symbol +(define-extern *shadow-object* symbol) +(define-extern *shadow-debug* symbol) (define-extern *shadow-dma-buf* dma-buffer) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -24582,7 +24584,6 @@ ;; shadow-cpu ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype shadow-stats (structure) ((num-single-tris uint32 :offset-assert 0) (num-double-tris uint32 :offset-assert 4) @@ -24595,9 +24596,7 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype shadow-dcache (structure) ((vtx-table uint32 :offset-assert 0) (single-edge-table uint32 :offset-assert 4) @@ -24625,40 +24624,38 @@ :size-assert #xb0 :flag-assert #x9000000b0 ) -|# -;; (define-extern *shadow-data* object) ;; shadow-data -;; (define-extern shadow-invert-z-buf function) -;; (define-extern shadow-make-invert-buf function) -;; (define-extern *shadow-dma-invert-call* object) -;; (define-extern shadow-dma-init function) ;; (function dma-buffer none) -;; (define-extern shadow-dma-end function) ;; (function dma-buffer none) -;; (define-extern shadow-vu0-block object) ;; vu-function -;; (define-extern shadow-xform-verts function) ;; function -;; (define-extern shadow-calc-dual-verts function) ;; function -;; (define-extern shadow-scissor-edges function) ;; function -;; (define-extern shadow-scissor-top function) ;; function -;; (define-extern shadow-init-vars function) ;; function -;; (define-extern shadow-find-facing-single-tris function) ;; function -;; (define-extern shadow-find-single-edges function) ;; function -;; (define-extern shadow-find-facing-double-tris function) ;; function -;; (define-extern shadow-find-double-edges function) ;; function -;; (define-extern shadow-add-verts function) ;; function -;; (define-extern shadow-add-facing-single-tris function) ;; function -;; (define-extern shadow-add-single-edges function) ;; function -;; (define-extern shadow-add-single-tris function) -;; (define-extern shadow-add-double-tris function) ;; function -;; (define-extern shadow-add-double-edges function) ;; function -;; (define-extern debug-draw-settings function) -;; (define-extern shadow-execute function) ;; (function shadow-dma-packet pointer pointer) -;; (define-extern shadow-vu0-upload function) ;; (function none) +(define-extern *shadow-data* shadow-data) +(define-extern shadow-invert-z-buf (function dma-buffer none)) +(define-extern shadow-make-invert-buf (function none)) +(define-extern *shadow-dma-invert-call* pointer) +(define-extern shadow-dma-init (function dma-buffer none)) +(define-extern shadow-dma-end (function dma-buffer gs-rgbaq symbol int none)) +(define-extern shadow-vu0-block vu-function) +(define-extern shadow-xform-verts function) +(define-extern shadow-calc-dual-verts function) +(define-extern shadow-scissor-edges function) +(define-extern shadow-scissor-top function) +(define-extern shadow-init-vars function) +(define-extern shadow-find-facing-single-tris function) +(define-extern shadow-find-single-edges function) +(define-extern shadow-find-facing-double-tris function) +(define-extern shadow-find-double-edges function) +(define-extern shadow-add-verts function) +(define-extern shadow-add-facing-single-tris function) +(define-extern shadow-add-single-edges function) +(define-extern shadow-add-single-tris function) +(define-extern shadow-add-double-tris function) +(define-extern shadow-add-double-edges function) +(define-extern debug-draw-settings (function matrix none)) +(define-extern shadow-execute (function shadow-dma-packet pointer pointer)) +(define-extern shadow-vu0-upload (function none)) (define-extern shadow-execute-all (function dma-buffer none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; shadow-vu1 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype shadow-vu1-constants (structure) ((hmgescale vector :inline :offset-assert 0) (invhscale vector :inline :offset-assert 16) @@ -24666,7 +24663,7 @@ (texscale vector :inline :offset-assert 48) (hvdfoff vector :inline :offset-assert 64) (fog vector :inline :offset-assert 80) - (clrs vector 2 :offset-assert 96) ;; guessed by decompiler + (clrs vector 2 :inline :offset-assert 96) ;; guessed by decompiler (adgif gs-gif-tag :inline :offset-assert 128) (texflush gs-adcmd :inline :offset-assert 144) ;; ad-cmd :inline (flush gs-adcmd :inline :offset-assert 160) ;; ad-cmd :inline @@ -24677,9 +24674,7 @@ :size-assert #xd0 :flag-assert #x9000000d0 ) -|# -#| (deftype shadow-vu1-data (structure) ((adgif gs-gif-tag :inline :offset-assert 0) (ad gs-adcmd :inline :offset-assert 16) @@ -24688,20 +24683,19 @@ (quadgif gs-gif-tag :inline :offset-assert 64) (texoffset vector :inline :offset-assert 80) (texscale vector :inline :offset-assert 96) - (clrs UNKNOWN 2 :offset-assert 112) + (clrs qword 2 :inline :offset-assert 112) ) :method-count-assert 9 :size-assert #x90 :flag-assert #x900000090 ) -|# -;; (define-extern *shadow-vu1-data* object) -;; (define-extern shadow-vu1-block object) ;; vu-function -;; (define-extern shadow-vu1-add-constants function) ;; (function dma-buffer none) -;; (define-extern shadow-vu1-patch-consts function) -;; (define-extern shadow-vu1-add-matrix function) ;; (function dma-buffer math-camera none) -;; (define-extern shadow-vu1-init-buffer function) ;; (function dma-buffer none) +(define-extern *shadow-vu1-data* shadow-vu1-data) +(define-extern shadow-vu1-block vu-function) +(define-extern shadow-vu1-add-constants (function dma-buffer int none)) +(define-extern shadow-vu1-patch-consts (function symbol int none)) +(define-extern shadow-vu1-add-matrix (function dma-buffer math-camera none)) +(define-extern shadow-vu1-init-buffer (function dma-buffer int none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; warp ;; diff --git a/decompiler/config/jak2/ntsc_v1/hacks.jsonc b/decompiler/config/jak2/ntsc_v1/hacks.jsonc index c6e82ec4b7..2a6c8febbb 100644 --- a/decompiler/config/jak2/ntsc_v1/hacks.jsonc +++ b/decompiler/config/jak2/ntsc_v1/hacks.jsonc @@ -741,7 +741,24 @@ "generic-warp-dest", "generic-warp-envmap-dest", "generic-no-light-proc", - "foreground-draw-hud" + "foreground-draw-hud", + // shadow + "shadow-execute", + "shadow-add-double-edges", + "shadow-add-double-tris", + "shadow-add-single-tris", + "shadow-add-single-edges", + "shadow-add-facing-single-tris", + "shadow-add-verts", + "shadow-find-double-edges", + "shadow-find-facing-double-tris", + "shadow-find-single-edges", + "shadow-find-facing-single-tris", + "shadow-init-vars", + "shadow-scissor-top", + "shadow-scissor-edges", + "shadow-calc-dual-verts", + "shadow-xform-verts" ], "mips2c_jump_table_functions": {}, diff --git a/decompiler/config/jak2/ntsc_v1/type_casts.jsonc b/decompiler/config/jak2/ntsc_v1/type_casts.jsonc index 6fc5cbd37f..bc6a61f543 100644 --- a/decompiler/config/jak2/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak2/ntsc_v1/type_casts.jsonc @@ -4560,7 +4560,15 @@ "foreground-add-mtx-calc": [[1, "v1", "foreground-work"]], "foreground-shadow": [ [2, "v1", "foreground-work"], - [[13, 19], "t1", "vector"] + [[13, 19], "t1", "vector"], + [[44, 110], "a3", "shadow-dma-packet"], + [54, "t3", "(pointer shadow-dma-packet)"], + [[67, 72], "t5", "(inline-array vector)"], + [[77, 83], "v1", "vector"], + [[127, 193], "t2", "shadow-dma-packet"], + [137, "t5", "(pointer shadow-dma-packet)"], + [[150, 155], "t7", "(inline-array vector)"], + [[160, 166], "t7", "vector"] ], "dma-add-process-drawable": [ [433, "a0", "foreground-work"], @@ -10237,5 +10245,131 @@ [4, "v1", "generic-work"] ], "generic-warp-source": [[2, "at", "generic-work"]], - "birth-func-whack-score": [[[0, 29], "v1", "(array int32)"]] + "birth-func-whack-score": [[[0, 29], "v1", "(array int32)"]], + "shadow-vu1-init-buffer": [[[18, 27], "a0", "dma-packet"]], + "shadow-vu1-add-constants": [ + [[7, 16], "a2", "dma-packet"], + [[20, 66], "v1", "shadow-vu1-constants"], + [[72, 77], "a1", "dma-packet"], + [[82, 94], "a1", "shadow-vu1-data"] + ], + "shadow-vu1-add-matrix": [ + [[11, 19], "a3", "dma-packet"], + [[26, 30], "v1", "matrix"] + ], + "shadow-vu0-upload": [[[16, 18], "a0", "dma-packet"]], + "shadow-make-invert-buf": [[[13, 16], "v1", "dma-packet"]], + "shadow-invert-z-buf": [ + [[4, 8], "a2", "dma-packet"], + [[13, 16], "a2", "gs-gif-tag"], + [27, "t1", "(pointer gs-reg)"], + [28, "t1", "(pointer gs-reg64)"], + [30, "t1", "(pointer gs-reg)"], + [32, "t1", "(pointer gs-frame)"], + [34, "t1", "(pointer gs-reg)"], + [38, "t1", "(pointer gs-reg)"], + [42, "t1", "(pointer gs-reg)"], + [36, "t1", "(pointer gs-zbuf)"], + [40, "t1", "(pointer gs-test)"], + [44, "t1", "(pointer gs-alpha)"], + [45, "t1", "(pointer gs-reg)"], + [47, "t1", "(pointer gs-reg64)"], + [49, "t1", "(pointer gs-reg)"], + [51, "t1", "(pointer gs-rgbaq)"], + [[61, 64], "t2", "gs-gif-tag"], + [89, "t4", "(pointer gs-xyzf)"], + [79, "t4", "(pointer gs-xyzf)"], + [[106, 117], "v1", "(pointer uint64)"] + ], + "shadow-dma-init": [ + [[18, 21], "t4", "dma-packet"], + [[27, 31], "t6", "dma-packet"], + [[36, 39], "t6", "gs-gif-tag"], + [43, "t4", "(pointer gs-reg64)"], + [47, "t4", "(pointer gs-test)"], + [45, "t4", "(pointer gs-reg64)"], + [49, "t4", "(pointer gs-reg64)"], + [51, "t4", "(pointer gs-alpha)"], + [53, "t4", "(pointer gs-reg64)"], + [58, "t4", "(pointer gs-frame)"], + [60, "t4", "(pointer gs-reg64)"], + [64, "t4", "(pointer gs-reg64)"], + [73, "t4", "(pointer gs-reg64)"], + [81, "t4", "(pointer gs-reg)"], + [84, "t4", "(pointer gs-reg)"], + [62, "t4", "(pointer gs-zbuf)"], + [71, "t4", "(pointer gs-xy-offset)"], + [79, "t4", "(pointer gs-tex0)"], + [82, "t4", "(pointer gs-tex1)"], + [85, "t4", "(pointer gs-miptbp)"], + [87, "t4", "(pointer gs-reg)"], + [96, "t4", "(pointer gs-clamp)"], + [[103, 106], "t3", "gs-gif-tag"], + [[122, 125], "t3", "gs-gif-tag"], + [111, "t3", "(pointer gs-prim)"], + [113, "t3", "(pointer gs-rgbaq)"], + [143, "t5", "(pointer gs-xyzf)"], + [156, "t5", "(pointer gs-xyzf)"], + [[167, 170], "a3", "gs-gif-tag"], + [177, "a3", "(pointer gs-test)"], + [179, "a3", "(pointer gs-reg64)"], + [183, "a3", "(pointer gs-reg64)"], + [193, "a3", "(pointer gs-reg64)"], + [190, "a3", "(pointer gs-reg64)"], + [202, "a3", "(pointer gs-reg64)"], + [181, "a3", "(pointer gs-zbuf)"], + [188, "a3", "(pointer gs-frame)"], + [191, "a3", "(pointer uint64)"], + [206, "a3", "(pointer gs-reg64)"], + [213, "a3", "(pointer gs-reg64)"], + [214, "a3", "(pointer uint64)"], + [216, "a3", "(pointer gs-reg64)"], + [211, "a3", "(pointer gs-frame)"], + [204, "a3", "(pointer gs-zbuf)"], + [200, "a3", "(pointer gs-test)"], + [229, "v1", "(pointer uint64)"], + [225, "v1", "(pointer uint64)"], + [230, "v1", "(pointer uint64)"], + [235, "v1", "(pointer uint64)"] + ], + "shadow-dma-end": [ + [33, "a1", "dma-packet"], + [32, "a1", "dma-packet"], + [35, "a1", "dma-packet"], + [24, "v1", "(pointer uint64)"], + [40, "v1", "dma-packet"], + [41, "v1", "(pointer uint64)"], + [[62, 65], "a0", "gs-gif-tag"], + [[51, 56], "a0", "dma-packet"], + [69, "a0", "(pointer uint64)"], + [71, "a0", "(pointer gs-reg64)"], + [75, "a0", "(pointer gs-reg64)"], + [82, "a0", "(pointer gs-reg64)"], + [83, "a0", "(pointer uint64)"], + [85, "a0", "(pointer gs-reg64)"], + [86, "a0", "(pointer uint64)"], + [88, "a0", "(pointer gs-reg64)"], + [73, "a0", "(pointer gs-test)"], + [80, "a0", "(pointer gs-frame)"], + [[95, 100], "a1", "dma-packet"], + [150, "t0", "(pointer uint64)"], + [163, "t0", "(pointer uint64)"], + [186, "t0", "(pointer uint64)"], + [199, "t0", "(pointer uint64)"], + [[105, 108], "a1", "gs-gif-tag"], + [109, "a1", "(pointer gs-prim)"], + [110, "a1", "(pointer gs-rgbaq)"], + [[115, 118], "a1", "(inline-array gs-gif-tag)"], + [217, "v1", "(pointer uint64)"], + [213, "v1", "(pointer uint64)"], + [218, "v1", "(pointer uint64)"], + [223, "v1", "(pointer uint64)"] + ], + "shadow-execute-all": [ + [[53, 60], "v1", "shadow-dcache"], + [111, "v1", "shadow-dcache"], + [116, "a0", "uint32"], + [[188, 246], "gp", "shadow-dcache"], + [93, "v1", "shadow-dcache"] + ] } diff --git a/decompiler/config/jak2/ntsc_v1/var_names.jsonc b/decompiler/config/jak2/ntsc_v1/var_names.jsonc index 8000d39be0..22b83ac1c7 100644 --- a/decompiler/config/jak2/ntsc_v1/var_names.jsonc +++ b/decompiler/config/jak2/ntsc_v1/var_names.jsonc @@ -4222,5 +4222,13 @@ }, "(method 55 nav-enemy)": { "args": ["self"] + }, + "foreground-shadow": { + "args": ["draw-ctrl", "arg1"], + "vars": { + "v1-3": "shadow-settings", + "a3-0": "shadow-geo", + "t0-0": "dist" + } } } diff --git a/docs/progress-notes/jak2/shadow-vu1.txt b/docs/progress-notes/jak2/shadow-vu1.txt new file mode 100644 index 0000000000..e086d11208 --- /dev/null +++ b/docs/progress-notes/jak2/shadow-vu1.txt @@ -0,0 +1,851 @@ + b L1 | nop + nop | nop + b L2 | nop + nop | nop + b L13 | nop + nop | nop + b L21 | nop + nop | nop + nop | nop :e + nop | nop + +;; ---------- memory layout +;; 0 - 4 camera +;; 4 - 119 upload4 + +;; 174 - 289 upload174 + +;; 344 - ?? upload344 + +;; 600 - ?? upload 600 + +;; 856 - 868 output0 +;; 868 - 880 output1 + +;; 880 hmgescale +;; 881 invhscale +;; 882 texoffset +;; 883 texscale +;; 884 hvdfoff +;; 885 fog +;; 886 clrs[0] +;; 887 clrs[1] + +;; 940 mystery[0] +;; 941 mystery[1] +;; 942 mystery[2] +;; 943 mystery[3] + +;; ---------- vi's +;; vi01 - temp +;; vi02 - output addr + +;; ----------- vf's +;; vf01 - output buffer addresses (rotated) +;; vf02 - hmgescale (constant) +;; vf03 - texoffset (constant) +;; vf04 - texscale (constant) +;; vf05 - hvdfoffset (constant) +;; vf06 - cpersx +;; vf07 - cpersy +;; vf08 - cpersz +;; vf09 - cpersw +;; vf12 - fog (constant) +;; vf13 - invhscale (constant) + +;; MSCAL 10 +L1: + iaddiu vi01, vi00, 0x358 | nop + iaddiu vi02, vi00, 0x364 | nop + mfir.x vf01, vi01 | nop + mfir.y vf01, vi02 | nop + mfir.z vf01, vi01 | nop + mfir.w vf01, vi02 | nop ;; vf01 = [856, 868, 856, 868] + lq.xyzw vf02, 880(vi00) | nop + lq.xyzw vf03, 882(vi00) | nop + lq.xyzw vf04, 883(vi00) | nop + lq.xyzw vf05, 884(vi00) | nop + lq.xyzw vf12, 885(vi00) | nop :e + lq.xyzw vf13, 881(vi00) | nop +;; END + +;; mscal 2 init block. +L2: + iaddiu vi03, vi00, 0x158 | nop ;; vi03 = 344 (addr list) + ilwr.x vi08, vi03 | nop ;; vi08 = num tris + mtir vi02, vf01.x | nop ;; vi02 = output addr + iaddi vi03, vi03, 0x1 | addw.z vf25, vf00, vf00 ;; inc input ptr, set vf25.z = 1. + lq.xyzw vf25, 888(vi00) | addw.z vf26, vf00, vf00 ;; vf25 = adgif, vf26.z = 1. + lq.xyzw vf29, 889(vi00) | addw.z vf27, vf00, vf00 ;; vf29 = texflush, vf27.z = 1. + lq.xyzw vf30, 891(vi00) | addw.z vf28, vf00, vf00 ;; vf30 = trigif, vf28.z = 1. + lq.xyzw vf06, 0(vi00) | nop ;; vf06 -> vf09 = camera + lq.xyzw vf07, 1(vi00) | nop + lq.xyzw vf08, 2(vi00) | nop + lq.xyzw vf09, 3(vi00) | nop + mtir vi01, vf01.y | nop ;; vi01 is the second output buffer + sq.xyzw vf25, 0(vi02) | nop ;; init output buffers + sq.xyzw vf29, 1(vi02) | nop + sq.xyzw vf30, 2(vi02) | nop + sq.xyzw vf25, 0(vi01) | nop + sq.xyzw vf29, 1(vi01) | nop + sq.xyzw vf30, 2(vi01) | nop + +;; mscal happy loop, from in344. +L3: + lqi.xyzw vf16, vi03 | nop ;; load tri addrs + nop | nop + nop | nop + nop | nop + mtir vi04, vf16.x | nop ;; vi04 = v0 addr + mtir vi05, vf16.y | nop ;; vi05 = v1 addr + mtir vi06, vf16.z | nop ;; vi06 = v2 add4r + nop | nop + lq.xyzw vf17, 4(vi04) | nop ;; load vertices from upload4 data: vf17 = v0 pos + lq.xyzw vf18, 4(vi05) | nop ;; vf18 = v1 pos + lq.xyzw vf19, 4(vi06) | nop ;; vf19 = v2 pos + nop | mulaw.xyzw ACC, vf09, vf00 ;; transform v0 + move.xyzw vf15, vf17 | maddax.xyzw ACC, vf06, vf17 ;; vf15 = pre-transformed v0 + nop | madday.xyzw ACC, vf07, vf17 + nop | maddz.xyzw vf17, vf08, vf17 ;; vf17 = transformed(v0) + nop | mulaw.xyzw ACC, vf09, vf00 ;; start v1 trans + nop | sub.xyzw vf29, vf18, vf15 ;; vf29 = (v1 - v0) (pre-trans) + nop | sub.xyzw vf30, vf19, vf15 ;; vf30 = (v2 - v0) (pre-trans) + div Q, vf12.x, vf17.w | maddax.xyzw ACC, vf06, vf18 ;; Q = fog.x / transformed(v0).w, v1 trans + nop | mul.xyzw vf21, vf17, vf02 ;; vf21 = hmge_scale * transformed(v0) + nop | madday.xyzw ACC, vf07, vf18 ;; v1 trans + nop | maddz.xyzw vf18, vf08, vf18 ;; v1 trans, vf18 = transformed(v1) + nop | mulaw.xyzw ACC, vf09, vf00 ;; v2 trans + nop | maddax.xyzw ACC, vf06, vf19 ;; v2 trans + nop | madday.xyzw ACC, vf07, vf19 ;; v2 trans + div Q, vf12.x, vf18.w | mul.xyz vf17, vf17, Q ;; do perspective divide (transform(v0).xyz * fog.x / tf(v0).w) + nop | maddz.xyzw vf19, vf08, vf19 ;; vf19 = transformed(v2) + nop | mul.xyzw vf22, vf18, vf02 ;; vf22 = hmge_scale * transformed(v1) + nop | opmula.xyz ACC, vf29, vf30 ;; cross (v1 - v0) x (v2 - v0) + nop | add.xy vf25, vf17, vf03 ;; vf25 = v0's texture + nop | mulw.z vf17, vf17, vf12 ;; multiply by weird fog value. + nop | opmsub.xyz vf29, vf30, vf29 ;; vf29 = finish cross + div Q, vf12.x, vf19.w | mul.xyz vf18, vf18, Q ;; v1's perspective + nop | mul.xyzw vf23, vf19, vf02 ;; v2's hmge + nop | mul.xyz vf29, vf29, vf15 ;; dot with pre-trans v0 (kind sketch?) + nop | add.xy vf26, vf18, vf03 ;; v1's texture + nop | add.xyzw vf17, vf17, vf05 ;; v0's hvdf offset + nop | mulw.z vf18, vf18, vf12 ;; v1's fog 1/-1 + nop | mul.xy vf25, vf25, vf04 ;; v0's texture scale + nop | mul.xyz vf19, vf19, Q ;; v2's perspective + nop | ftoi4.xyzw vf17, vf17 ;; v0 to GS format + fcset 0x0 | addy.x vf29, vf29, vf29 ;; dot product sum, clear add flags + nop | add.xyzw vf18, vf18, vf05 ;; v1's hvdf + nop | clipw.xyz vf21, vf21 ;; v0's clip + nop | mulw.z vf19, vf19, vf12 ;; v2's fog mult + sq.xyzw vf25, 4(vi02) | mul.xy vf26, vf26, vf04 ;; texscale + sq.xyzw vf17, 5(vi02) | addz.x vf29, vf29, vf29 ;; dot PRODUCT! + nop | ftoi4.xyzw vf18, vf18 ;; v1's ftoi + nop | add.xy vf27, vf19, vf03 ;; v2's texoffset + sq.xyzw vf26, 6(vi02) | add.xyzw vf19, vf19, vf05 ;; v2's hvdf + fsand vi01, 0x2 | clipw.xyz vf22, vf22 ;; check dp, clip v1 + sq.xyzw vf18, 7(vi02) | clipw.xyz vf23, vf23 ;; clip v1 + ibeq vi00, vi01, L4 | mul.xy vf27, vf27, vf04 ;; texscale + nop | nop + b L5 | nop + lq.xyzw vf31, 887(vi00) | nop ;; vf31 is one of the colors. +L4: + lq.xyzw vf31, 886(vi00) | nop +L5: + fcand vi01, 0x3ffff | ftoi4.xyzw vf19, vf19 ;; last ftoi + ibne vi00, vi01, L11 | nop ;; ssee if we need to do clipping. + iaddi vi08, vi08, -0x1 | nop ;; dec tri count + sq.xyzw vf27, 8(vi02) | nop + sq.xyzw vf31, 3(vi02) | nop + sq.xyzw vf19, 9(vi02) | nop + xgkick vi02 | nop ;; KICK + mtir vi02, vf01.y | nop ;; next output buffer + mr32.xyzw vf01, vf01 | nop +L6: + ibgtz vi08, L3 | nop ;; check tri count + nop | nop +;; next happy loop + iaddiu vi03, vi00, 0x158 | nop + ilwr.x vi08, vi03 | nop + ilwr.y vi01, vi03 | nop + iaddi vi03, vi03, 0x1 | nop +L7: + lqi.xyzw vf16, vi03 | nop + nop | nop + nop | nop + mtir vi04, vf16.x | nop + mtir vi05, vf16.y | nop + mtir vi06, vf16.z | nop + nop | nop + lq.xyzw vf17, 174(vi04) | nop + lq.xyzw vf18, 174(vi06) | nop + lq.xyzw vf19, 174(vi05) | nop + nop | mulaw.xyzw ACC, vf09, vf00 + move.xyzw vf15, vf17 | maddax.xyzw ACC, vf06, vf17 + nop | madday.xyzw ACC, vf07, vf17 + nop | maddz.xyzw vf17, vf08, vf17 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | sub.xyzw vf29, vf18, vf15 + nop | sub.xyzw vf30, vf19, vf15 + div Q, vf12.x, vf17.w | maddax.xyzw ACC, vf06, vf18 + nop | mul.xyzw vf21, vf17, vf02 + nop | madday.xyzw ACC, vf07, vf18 + nop | maddz.xyzw vf18, vf08, vf18 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf19 + nop | madday.xyzw ACC, vf07, vf19 + div Q, vf12.x, vf18.w | mul.xyz vf17, vf17, Q + nop | maddz.xyzw vf19, vf08, vf19 + nop | mul.xyzw vf22, vf18, vf02 + nop | opmula.xyz ACC, vf29, vf30 + nop | add.xy vf25, vf17, vf03 + nop | mulw.z vf17, vf17, vf12 + nop | opmsub.xyz vf29, vf30, vf29 + div Q, vf12.x, vf19.w | mul.xyz vf18, vf18, Q + nop | mul.xyzw vf23, vf19, vf02 + nop | mul.xyz vf29, vf29, vf15 + nop | add.xy vf26, vf18, vf03 + nop | add.xyzw vf17, vf17, vf05 + nop | mulw.z vf18, vf18, vf12 + nop | mul.xy vf25, vf25, vf04 + nop | mul.xyz vf19, vf19, Q + nop | ftoi4.xyzw vf17, vf17 + fcset 0x0 | addy.x vf29, vf29, vf29 + nop | add.xyzw vf18, vf18, vf05 + nop | clipw.xyz vf21, vf21 + sq.xyzw vf25, 4(vi02) | mulw.z vf19, vf19, vf12 + sq.xyzw vf17, 5(vi02) | mul.xy vf26, vf26, vf04 + iaddi vi08, vi08, -0x1 | addz.x vf29, vf29, vf29 + nop | ftoi4.xyzw vf18, vf18 + nop | add.xy vf27, vf19, vf03 + sq.xyzw vf26, 6(vi02) | add.xyzw vf19, vf19, vf05 + fsand vi01, 0x2 | clipw.xyz vf22, vf22 + sq.xyzw vf18, 7(vi02) | clipw.xyz vf23, vf23 + ibeq vi00, vi01, L8 | mul.xy vf27, vf27, vf04 + nop | nop + b L9 | nop + lq.xyzw vf31, 887(vi00) | nop +L8: + lq.xyzw vf31, 886(vi00) | nop +L9: + fcand vi01, 0x3ffff | ftoi4.xyzw vf19, vf19 + ibne vi00, vi01, L12 | nop + sq.xyzw vf27, 8(vi02) | nop + sq.xyzw vf31, 3(vi02) | nop + sq.xyzw vf19, 9(vi02) | nop + xgkick vi02 | nop + mtir vi02, vf01.y | nop + mr32.xyzw vf01, vf01 | nop +L10: + ibgtz vi08, L7 | nop + nop | nop + nop | nop :e + nop | nop +L11: + sq.xyzw vf21, 1000(vi00) | nop + sq.xyzw vf22, 1003(vi00) | nop + sq.xyzw vf23, 1006(vi00) | nop + sq.xyzw vf31, 942(vi00) | nop + mfir.x vf29, vi02 | nop + mfir.y vf29, vi03 | nop + mfir.z vf29, vi07 | nop + bal vi15, L36 | nop + mfir.w vf29, vi08 | nop + mtir vi08, vf29.w | nop + mtir vi03, vf29.y | nop + mtir vi07, vf29.z | nop + b L6 | nop + mtir vi02, vf29.x | nop +L12: + sq.xyzw vf21, 1000(vi00) | nop + sq.xyzw vf22, 1003(vi00) | nop + sq.xyzw vf23, 1006(vi00) | nop + sq.xyzw vf31, 942(vi00) | nop + mfir.x vf29, vi02 | nop + mfir.y vf29, vi03 | nop + mfir.z vf29, vi07 | nop + bal vi15, L36 | nop + mfir.w vf29, vi08 | nop + mtir vi08, vf29.w | nop + mtir vi03, vf29.y | nop + mtir vi07, vf29.z | nop + b L10 | nop + mtir vi02, vf29.x | nop +L13: + iaddiu vi03, vi00, 0x258 | nop ;; vi03 = 600 + ilwr.x vi08, vi03 | nop ;; num quads + mtir vi02, vf01.x | nop ;; output buffer + iaddi vi03, vi03, 0x1 | addw.z vf25, vf00, vf00 ;; set 1's in texture + lq.xyzw vf25, 888(vi00) | addw.z vf26, vf00, vf00 + lq.xyzw vf29, 889(vi00) | addw.z vf27, vf00, vf00 + lq.xyzw vf30, 892(vi00) | nop ;;oops they forget vf28?? + lq.xyzw vf06, 0(vi00) | nop + lq.xyzw vf07, 1(vi00) | nop + lq.xyzw vf08, 2(vi00) | nop + lq.xyzw vf09, 3(vi00) | nop + mtir vi01, vf01.y | nop + sq.xyzw vf25, 0(vi02) | nop + sq.xyzw vf29, 1(vi02) | nop + sq.xyzw vf30, 2(vi02) | nop + sq.xyzw vf25, 0(vi01) | nop + sq.xyzw vf29, 1(vi01) | nop + sq.xyzw vf30, 2(vi01) | nop +L14: + lqi.xyzw vf16, vi03 | nop + nop | nop + nop | nop + nop | nop + mtir vi06, vf16.z | nop + mtir vi04, vf16.x | nop + mtir vi05, vf16.y | nop + nop | nop + ibeq vi00, vi06, L15 | nop + nop | nop + lq.xyzw vf17, 4(vi04) | nop + lq.xyzw vf18, 4(vi05) | nop + lq.xyzw vf19, 174(vi05) | nop + b L16 | nop + lq.xyzw vf20, 174(vi04) | nop +L15: + lq.xyzw vf17, 4(vi05) | nop + lq.xyzw vf18, 4(vi04) | nop + lq.xyzw vf19, 174(vi04) | nop + lq.xyzw vf20, 174(vi05) | nop +L16: + move.xyzw vf15, vf17 | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf17 + nop | madday.xyzw ACC, vf07, vf17 + nop | maddz.xyzw vf17, vf08, vf17 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | sub.xyzw vf29, vf18, vf15 + nop | sub.xyzw vf30, vf19, vf15 + div Q, vf12.x, vf17.w | maddax.xyzw ACC, vf06, vf18 + nop | mul.xyzw vf21, vf17, vf02 + nop | madday.xyzw ACC, vf07, vf18 + nop | maddz.xyzw vf18, vf08, vf18 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf19 + nop | madday.xyzw ACC, vf07, vf19 + div Q, vf12.x, vf18.w | mul.xyz vf17, vf17, Q + nop | maddz.xyzw vf19, vf08, vf19 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf20 + nop | madday.xyzw ACC, vf07, vf20 + nop | maddz.xyzw vf20, vf08, vf20 + nop | mul.xyzw vf22, vf18, vf02 + div Q, vf12.x, vf19.w | mul.xyz vf18, vf18, Q + nop | add.xy vf25, vf17, vf03 + nop | mulw.z vf17, vf17, vf12 + nop | opmula.xyz ACC, vf29, vf30 + nop | opmsub.xyz vf29, vf30, vf29 + nop | mul.xyzw vf23, vf19, vf02 + nop | mul.xyz vf29, vf29, vf15 + div Q, vf12.x, vf20.w | mul.xyz vf19, vf19, Q + nop | add.xyzw vf17, vf17, vf05 + nop | mul.xyzw vf24, vf20, vf02 + nop | mul.xy vf25, vf25, vf04 + nop | nop + nop | ftoi4.xyzw vf17, vf17 + nop | add.xy vf26, vf18, vf03 + nop | mul.xyz vf20, vf20, Q + nop | mulw.z vf18, vf18, vf12 + nop | addy.x vf29, vf29, vf29 + sq.xyzw vf25, 4(vi02) | nop + sq.xyzw vf17, 5(vi02) | nop + nop | add.xyzw vf18, vf18, vf05 + nop | clipw.xyz vf21, vf21 + nop | mul.xy vf26, vf26, vf04 + nop | addz.x vf29, vf29, vf29 + nop | ftoi4.xyzw vf18, vf18 + nop | add.xy vf27, vf19, vf03 + sq.xyzw vf26, 6(vi02) | mulw.z vf19, vf19, vf12 + fsand vi01, 0x2 | clipw.xyz vf22, vf22 + sq.xyzw vf18, 7(vi02) | clipw.xyz vf23, vf23 + nop | clipw.xyz vf24, vf24 + nop | add.xy vf28, vf20, vf03 + nop | mulw.z vf20, vf20, vf12 + nop | mul.xy vf27, vf27, vf04 + nop | add.xyzw vf19, vf19, vf05 + nop | nop + ibeq vi00, vi01, L17 | mul.xy vf28, vf28, vf04 + nop | add.xyzw vf20, vf20, vf05 + b L18 | nop + lq.xyzw vf31, 887(vi00) | nop +L17: + lq.xyzw vf31, 886(vi00) | nop +L18: + fcand vi01, 0xffffff | ftoi4.xyzw vf19, vf19 + ibne vi00, vi01, L20 | nop + iaddi vi08, vi08, -0x1 | nop + sq.xyzw vf27, 8(vi02) | ftoi4.xyzw vf20, vf20 + sq.xyzw vf31, 3(vi02) | nop + sq.xyzw vf19, 9(vi02) | nop + sq.xyzw vf28, 10(vi02) | nop + sq.xyzw vf20, 11(vi02) | nop + xgkick vi02 | nop + mtir vi02, vf01.y | nop + mr32.xyzw vf01, vf01 | nop +L19: + ibgtz vi08, L14 | nop + nop | nop + nop | nop :e + nop | nop +L20: + sq.xyzw vf21, 1000(vi00) | nop + sq.xyzw vf22, 1003(vi00) | nop + sq.xyzw vf23, 1006(vi00) | nop + sq.xyzw vf24, 1009(vi00) | nop + sq.xyzw vf31, 942(vi00) | nop + mfir.x vf29, vi02 | nop + mfir.y vf29, vi03 | nop + mfir.z vf29, vi07 | nop + bal vi15, L37 | nop + mfir.w vf29, vi08 | nop + mtir vi08, vf29.w | nop + mtir vi03, vf29.y | nop + mtir vi07, vf29.z | nop + b L19 | nop + mtir vi02, vf29.x | nop +L21: + iaddiu vi03, vi00, 0x158 | nop + ilwr.x vi08, vi03 | nop + mtir vi02, vf01.x | nop + iaddi vi03, vi03, 0x1 | addw.z vf25, vf00, vf00 + lq.xyzw vf25, 888(vi00) | addw.z vf26, vf00, vf00 + lq.xyzw vf29, 889(vi00) | addw.z vf27, vf00, vf00 + lq.xyzw vf30, 891(vi00) | addw.z vf28, vf00, vf00 + lq.xyzw vf06, 0(vi00) | nop + lq.xyzw vf07, 1(vi00) | nop + lq.xyzw vf08, 2(vi00) | nop + lq.xyzw vf09, 3(vi00) | nop + mtir vi01, vf01.y | nop + sq.xyzw vf25, 0(vi02) | nop + sq.xyzw vf29, 1(vi02) | nop + sq.xyzw vf30, 2(vi02) | nop + sq.xyzw vf25, 0(vi01) | nop + sq.xyzw vf29, 1(vi01) | nop + sq.xyzw vf30, 2(vi01) | nop +L22: + lqi.xyzw vf16, vi03 | nop + nop | nop + nop | nop + nop | nop + mtir vi01, vf16.w | nop + mtir vi04, vf16.x | nop + mtir vi05, vf16.y | nop + mtir vi06, vf16.z | nop + ibeq vi00, vi01, L23 | nop + lq.xyzw vf17, 4(vi04) | nop + lq.xyzw vf18, 4(vi05) | nop + b L24 | nop + lq.xyzw vf19, 4(vi06) | nop +L23: + lq.xyzw vf19, 4(vi05) | nop + lq.xyzw vf18, 4(vi06) | nop +L24: + nop | mulaw.xyzw ACC, vf09, vf00 + move.xyzw vf15, vf17 | maddax.xyzw ACC, vf06, vf17 + nop | madday.xyzw ACC, vf07, vf17 + nop | sub.xyzw vf29, vf18, vf17 + nop | sub.xyzw vf30, vf19, vf17 + nop | maddz.xyzw vf17, vf08, vf17 + nop | mulaw.xyzw ACC, vf09, vf00 + div Q, vf12.x, vf17.w | maddax.xyzw ACC, vf06, vf18 + nop | madday.xyzw ACC, vf07, vf18 + nop | mul.xyzw vf21, vf17, vf02 + nop | maddz.xyzw vf18, vf08, vf18 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf19 + nop | madday.xyzw ACC, vf07, vf19 + div Q, vf12.x, vf18.w | mul.xyz vf17, vf17, Q + nop | maddz.xyzw vf19, vf08, vf19 + nop | mul.xyzw vf22, vf18, vf02 + nop | opmula.xyz ACC, vf29, vf30 + nop | opmsub.xyz vf29, vf30, vf29 + nop | add.xy vf25, vf17, vf03 + nop | mulw.z vf17, vf17, vf12 + div Q, vf12.x, vf19.w | mul.xyz vf18, vf18, Q + nop | mul.xyzw vf23, vf19, vf02 + nop | mul.xyz vf29, vf29, vf15 + nop | add.xyzw vf17, vf17, vf05 + nop | mul.xy vf25, vf25, vf04 + nop | nop + nop | ftoi4.xyzw vf17, vf17 + nop | add.xy vf26, vf18, vf03 + nop | mulw.z vf18, vf18, vf12 + fcset 0x0 | addy.x vf29, vf29, vf29 + nop | mul.xyz vf19, vf19, Q + sq.xyzw vf25, 4(vi02) | nop + sq.xyzw vf17, 5(vi02) | add.xyzw vf18, vf18, vf05 + nop | clipw.xyz vf21, vf21 + nop | mul.xy vf26, vf26, vf04 + nop | addz.x vf29, vf29, vf29 + nop | ftoi4.xyzw vf18, vf18 + nop | add.xy vf27, vf19, vf03 + sq.xyzw vf26, 6(vi02) | mulw.z vf19, vf19, vf12 + fsand vi01, 0x2 | clipw.xyz vf22, vf22 + sq.xyzw vf18, 7(vi02) | clipw.xyz vf23, vf23 + ibeq vi00, vi01, L25 | mul.xy vf27, vf27, vf04 + nop | add.xyzw vf19, vf19, vf05 + b L26 | nop + lq.xyzw vf31, 887(vi00) | nop +L25: + lq.xyzw vf31, 886(vi00) | nop +L26: + fcand vi01, 0x3ffff | ftoi4.xyzw vf19, vf19 + ibne vi00, vi01, L34 | nop + iaddi vi08, vi08, -0x1 | nop + sq.xyzw vf27, 8(vi02) | nop + sq.xyzw vf31, 3(vi02) | nop + sq.xyzw vf19, 9(vi02) | nop + xgkick vi02 | nop + mtir vi02, vf01.y | nop + mr32.xyzw vf01, vf01 | nop +L27: + ibgtz vi08, L22 | nop + nop | nop + iaddiu vi03, vi00, 0x158 | nop + ilwr.x vi08, vi03 | nop + ilwr.y vi01, vi03 | nop + iaddi vi03, vi03, 0x1 | nop +L28: + lqi.xyzw vf16, vi03 | nop + nop | nop + nop | nop + mtir vi01, vf16.w | nop + mtir vi04, vf16.x | nop + mtir vi05, vf16.y | nop + mtir vi06, vf16.z | nop + ibne vi00, vi01, L29 | nop + lq.xyzw vf17, 174(vi04) | nop + lq.xyzw vf18, 174(vi05) | nop + b L30 | nop + lq.xyzw vf19, 174(vi06) | nop +L29: + lq.xyzw vf19, 174(vi05) | nop + lq.xyzw vf18, 174(vi06) | nop +L30: + nop | mulaw.xyzw ACC, vf09, vf00 + move.xyzw vf15, vf17 | maddax.xyzw ACC, vf06, vf17 + nop | madday.xyzw ACC, vf07, vf17 + nop | maddz.xyzw vf17, vf08, vf17 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | sub.xyzw vf29, vf18, vf15 + nop | sub.xyzw vf30, vf19, vf15 + div Q, vf12.x, vf17.w | maddax.xyzw ACC, vf06, vf18 + nop | mul.xyzw vf21, vf17, vf02 + nop | madday.xyzw ACC, vf07, vf18 + nop | maddz.xyzw vf18, vf08, vf18 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf19 + nop | madday.xyzw ACC, vf07, vf19 + div Q, vf12.x, vf18.w | mul.xyz vf17, vf17, Q + nop | maddz.xyzw vf19, vf08, vf19 + nop | mul.xyzw vf22, vf18, vf02 + nop | opmula.xyz ACC, vf29, vf30 + nop | opmsub.xyz vf29, vf30, vf29 + nop | add.xy vf25, vf17, vf03 + nop | mulw.z vf17, vf17, vf12 + div Q, vf12.x, vf19.w | mul.xyz vf18, vf18, Q + nop | mul.xyzw vf23, vf19, vf02 + nop | mul.xyz vf29, vf29, vf15 + nop | add.xyzw vf17, vf17, vf05 + nop | mul.xy vf25, vf25, vf04 + nop | nop + nop | add.xy vf26, vf18, vf03 + nop | ftoi4.xyzw vf17, vf17 + nop | mulw.z vf18, vf18, vf12 + fcset 0x0 | addy.x vf29, vf29, vf29 + nop | mul.xyz vf19, vf19, Q + sq.xyzw vf25, 4(vi02) | nop + sq.xyzw vf17, 5(vi02) | add.xyzw vf18, vf18, vf05 + nop | clipw.xyz vf21, vf21 + nop | mul.xy vf26, vf26, vf04 + nop | addz.x vf29, vf29, vf29 + nop | ftoi4.xyzw vf18, vf18 + nop | add.xy vf27, vf19, vf03 + sq.xyzw vf26, 6(vi02) | mulw.z vf19, vf19, vf12 + fsand vi01, 0x2 | clipw.xyz vf22, vf22 + sq.xyzw vf18, 7(vi02) | clipw.xyz vf23, vf23 + ibeq vi00, vi01, L31 | mul.xy vf27, vf27, vf04 + nop | add.xyzw vf19, vf19, vf05 + b L32 | nop + lq.xyzw vf31, 887(vi00) | nop +L31: + lq.xyzw vf31, 886(vi00) | nop +L32: + fcand vi01, 0x3ffff | ftoi4.xyzw vf19, vf19 + ibne vi00, vi01, L35 | nop + iaddi vi08, vi08, -0x1 | nop + sq.xyzw vf27, 8(vi02) | nop + sq.xyzw vf31, 3(vi02) | nop + sq.xyzw vf19, 9(vi02) | nop + xgkick vi02 | nop + mtir vi02, vf01.y | nop + mr32.xyzw vf01, vf01 | nop +L33: + ibgtz vi08, L28 | nop + nop | nop + nop | nop :e + nop | nop +L34: + sq.xyzw vf21, 1000(vi00) | nop + sq.xyzw vf22, 1003(vi00) | nop + sq.xyzw vf23, 1006(vi00) | nop + sq.xyzw vf31, 942(vi00) | nop + mfir.x vf29, vi02 | nop + mfir.y vf29, vi03 | nop + mfir.z vf29, vi07 | nop + bal vi15, L36 | nop + mfir.w vf29, vi08 | nop + mtir vi08, vf29.w | nop + mtir vi03, vf29.y | nop + mtir vi07, vf29.z | nop + b L27 | nop + mtir vi02, vf29.x | nop +L35: + sq.xyzw vf21, 1000(vi00) | nop + sq.xyzw vf22, 1003(vi00) | nop + sq.xyzw vf23, 1006(vi00) | nop + sq.xyzw vf31, 942(vi00) | nop + mfir.x vf29, vi02 | nop + mfir.y vf29, vi03 | nop + mfir.z vf29, vi07 | nop + bal vi15, L36 | nop + mfir.w vf29, vi08 | nop + mtir vi08, vf29.w | nop + mtir vi03, vf29.y | nop + mtir vi07, vf29.z | nop + b L33 | nop + mtir vi02, vf29.x | nop +L36: + sq.xyzw vf00, 893(vi00) | nop + sq.xyzw vf00, 900(vi00) | nop + sq.xyzw vf00, 907(vi00) | nop + sq.xyzw vf00, 914(vi00) | nop + sq.xyzw vf00, 921(vi00) | nop + sq.xyzw vf00, 928(vi00) | nop + iaddiu vi01, vi00, 0x2d3 | nop + isw.z vi01, 893(vi00) | nop + iaddiu vi01, vi00, 0x2d5 | nop + isw.z vi01, 900(vi00) | nop + iaddiu vi01, vi00, 0x2d7 | nop + isw.z vi01, 907(vi00) | nop + iaddiu vi01, vi00, 0x2d9 | nop + isw.z vi01, 914(vi00) | nop + iaddiu vi01, vi00, 0x2db | nop + isw.z vi01, 921(vi00) | nop + iaddiu vi01, vi00, 0x2dd | nop + isw.z vi01, 928(vi00) | nop + iaddiu vi03, vi00, 0x3b0 | nop + iaddiu vi04, vi00, 0x3af | nop + mfir.x vf31, vi15 | nop + iaddi vi05, vi00, 0x0 | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3e8 | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3eb | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3ee | nop + b L47 | nop + nop | nop +L37: + sq.xyzw vf00, 893(vi00) | nop + sq.xyzw vf00, 900(vi00) | nop + sq.xyzw vf00, 907(vi00) | nop + sq.xyzw vf00, 914(vi00) | nop + sq.xyzw vf00, 921(vi00) | nop + sq.xyzw vf00, 928(vi00) | nop + iaddiu vi01, vi00, 0x2d3 | nop + isw.z vi01, 893(vi00) | nop + iaddiu vi01, vi00, 0x2d5 | nop + isw.z vi01, 900(vi00) | nop + iaddiu vi01, vi00, 0x2d7 | nop + isw.z vi01, 907(vi00) | nop + iaddiu vi01, vi00, 0x2d9 | nop + isw.z vi01, 914(vi00) | nop + iaddiu vi01, vi00, 0x2db | nop + isw.z vi01, 921(vi00) | nop + iaddiu vi01, vi00, 0x2dd | nop + isw.z vi01, 928(vi00) | nop + iaddiu vi03, vi00, 0x3b0 | nop + iaddiu vi04, vi00, 0x3af | nop + mfir.x vf31, vi15 | nop + iaddi vi05, vi00, 0x0 | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3e8 | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3eb | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3ee | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3f1 | nop + b L47 | nop + nop | nop +L38: + iaddiu vi09, vi00, 0x37d | nop +L39: + iaddi vi10, vi00, 0x0 | nop +L40: + isubiu vi01, vi09, 0x3a7 | nop + ilwr.y vi08, vi09 | nop + ibgez vi01, L44 | nop + ilwr.z vi06, vi09 | nop + lq.xyzw vf15, 0(vi07) | nop + lq.xyzw vf14, 0(vi08) | nop + ibne vi00, vi08, L41 | nop + iswr.y vi07, vi09 | nop + jalr vi11, vi06 | nop + iswr.x vi07, vi09 | nop + nop | nop + nop | nop + nop | nop + fsand vi02, 0x2 | nop + ibne vi00, vi02, L45 | nop + nop | nop + b L40 | nop + iaddi vi09, vi09, 0x7 | nop +L41: + jalr vi11, vi06 | nop + nop | nop + nop | nop + nop | nop + fsand vi01, 0x2 | nop + fsand vi02, 0x2 | nop + ibne vi00, vi01, L43 | nop + nop | nop + ibne vi00, vi02, L42 | nop + nop | nop + b L40 | nop + iaddi vi09, vi09, 0x7 | nop +L42: + bal vi11, L52 | nop + iaddi vi07, vi09, 0x1 | nop + sq.xyzw vf16, 1(vi09) | nop + b L40 | nop + iaddi vi09, vi09, 0x7 | nop +L43: + ibne vi00, vi02, L45 | nop + nop | nop + bal vi11, L53 | nop + nop | nop + sq.xyzw vf16, 4(vi09) | nop + iaddi vi09, vi09, 0x7 | nop + isw.x vi09, 935(vi10) | nop + isw.y vi07, 935(vi10) | nop + iaddi vi10, vi10, 0x1 | nop + b L40 | nop + iaddi vi07, vi09, -0x3 | nop +L44: + lq.xyzw vf14, 0(vi07) | nop + iaddi vi05, vi05, 0x1 | nop + div Q, vf00.w, vf14.w | nop + nop | mul.xyzw vf14, vf14, vf13 + iaddi vi03, vi03, 0x2 | nop + waitq | subw.w vf14, vf00, vf00 + nop | mul.xyz vf14, vf14, Q + nop | add.xy vf26, vf14, vf03 + nop | mulw.z vf14, vf14, vf12 + nop | add.xyzw vf14, vf14, vf05 + nop | mul.xy vf26, vf26, vf04 + sq.xyzw vf26, -2(vi03) | ftoi4.xyzw vf14, vf14 + sq.xyzw vf14, -1(vi03) | nop +L45: + iblez vi10, L46 | nop + nop | nop + ilw.x vi09, 934(vi10) | nop + ilw.y vi07, 934(vi10) | nop + b L40 | nop + iaddi vi10, vi10, -0x1 | nop +L46: + jr vi15 | nop + nop | nop +L47: + iaddiu vi09, vi00, 0x37d | nop +L48: + ilwr.x vi08, vi09 | nop + ilwr.y vi07, vi09 | nop + ilwr.z vi06, vi09 | nop + nop | nop + ibeq vi00, vi08, L50 | nop + lq.xyzw vf14, 0(vi07) | nop + ibeq vi07, vi08, L50 | nop + lq.xyzw vf15, 0(vi08) | nop + jalr vi11, vi06 | nop + nop | nop + nop | nop + nop | nop + fsand vi01, 0x2 | nop + fsand vi02, 0x2 | nop + ibeq vi02, vi01, L50 | nop + nop | nop + ibeq vi00, vi01, L49 | nop + nop | nop + bal vi11, L53 | nop + nop | nop + sq.xyzw vf16, 4(vi09) | nop + iaddi vi07, vi09, 0x4 | nop + ior vi12, vi09, vi00 | nop + bal vi15, L39 | nop + iaddi vi09, vi09, 0x7 | nop + b L50 | nop + ior vi09, vi12, vi00 | nop +L49: + bal vi11, L52 | nop + nop | nop + sq.xyzw vf16, 1(vi09) | nop + iaddi vi07, vi09, 0x1 | nop + ior vi12, vi09, vi00 | nop + bal vi15, L39 | nop + iaddi vi09, vi09, 0x7 | nop + ior vi09, vi12, vi00 | nop +L50: + isubiu vi01, vi09, 0x3a0 | nop + iswr.x vi00, vi09 | nop + iswr.y vi00, vi09 | nop + ibltz vi01, L48 | nop + iaddi vi09, vi09, 0x7 | nop + ibeq vi00, vi05, L51 | nop + mtir vi15, vf31.x | nop + iaddiu vi05, vi05, 0x4000 | nop + iaddiu vi05, vi05, 0x4000 | nop + iswr.x vi05, vi04 | nop + iaddiu vi01, vi00, 0x3ac | nop + xgkick vi01 | nop + lq.xyzw vf30, 888(vi00) | nop + lq.xyzw vf31, 890(vi00) | nop + iaddiu vi01, vi00, 0x3fe | nop + isubiu vi02, vi00, 0x7fff | nop + sq.xyzw vf30, 0(vi01) | nop + iswr.x vi02, vi01 | nop + sq.xyzw vf31, 1(vi01) | nop + nop | nop + xgkick vi01 | nop +L51: + nop | nop + jr vi15 | nop + nop | nop + jr vi11 | addx.w vf30, vf14, vf14 + nop | addx.w vf31, vf15, vf15 + jr vi11 | subx.w vf30, vf14, vf14 + nop | subx.w vf31, vf15, vf15 + jr vi11 | addy.w vf30, vf14, vf14 + nop | addy.w vf31, vf15, vf15 + jr vi11 | suby.w vf30, vf14, vf14 + nop | suby.w vf31, vf15, vf15 + jr vi11 | addz.w vf30, vf14, vf14 + nop | addz.w vf31, vf15, vf15 + jr vi11 | subz.w vf30, vf14, vf14 + nop | subz.w vf31, vf15, vf15 +L52: + nop | subw.w vf31, vf30, vf31 + div Q, vf30.w, vf31.w | sub.xyzw vf16, vf15, vf14 + waitq | mul.xyzw vf16, vf16, Q + jr vi11 | add.xyzw vf16, vf14, vf16 + nop | nop +L53: + nop | subw.w vf30, vf30, vf31 + div Q, vf31.w, vf30.w | sub.xyzw vf16, vf14, vf15 + waitq | mul.xyzw vf16, vf16, Q + jr vi11 | sub.xyzw vf16, vf15, vf16 + nop | nop + lq. vf00, 0(vi00) | addx. vf00, vf00, vf00 diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 680f794267..9d67c03216 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -108,6 +108,7 @@ set(RUNTIME_SOURCE mips2c/jak2_functions/merc_blend_shape.cpp mips2c/jak2_functions/ripple.cpp mips2c/jak2_functions/squid.cpp + mips2c/jak2_functions/shadow.cpp overlord/common/dma.cpp overlord/common/iso.cpp overlord/common/iso_api.cpp @@ -158,6 +159,7 @@ set(RUNTIME_SOURCE graphics/opengl_renderer/foreground/Generic2_DMA.cpp graphics/opengl_renderer/foreground/Generic2_Build.cpp graphics/opengl_renderer/foreground/Generic2_OpenGL.cpp + graphics/opengl_renderer/foreground/Shadow2.cpp graphics/opengl_renderer/sprite/GlowRenderer.cpp graphics/opengl_renderer/sprite/Sprite3.cpp graphics/opengl_renderer/sprite/Sprite3_Distort.cpp diff --git a/game/graphics/opengl_renderer/BucketRenderer.cpp b/game/graphics/opengl_renderer/BucketRenderer.cpp index 464e462d28..22123f48f7 100644 --- a/game/graphics/opengl_renderer/BucketRenderer.cpp +++ b/game/graphics/opengl_renderer/BucketRenderer.cpp @@ -66,6 +66,31 @@ void SkipRenderer::render(DmaFollower& dma, } } +PrintRenderer::PrintRenderer(const std::string& name, int my_id) : BucketRenderer(name, my_id) {} + +void PrintRenderer::render(DmaFollower& dma, + SharedRenderState* render_state, + ScopedProfilerNode& /*prof*/) { + // jump to bucket + dma.read_and_advance(); + + auto transfers = 0; + // print the entire chain + fmt::print("START {} DMA!!!!!!!\n", m_name); + while (dma.current_tag_offset() != render_state->next_bucket) { + auto dmatag = dma.current_tag(); + auto data = dma.read_and_advance(); + printf( + "dma transfer %d:\n%ssize: %d\nvif0: %s, data: %d\nvif1: %s, data: %d, imm: " + "%d\n\n", + transfers, dmatag.print().c_str(), data.size_bytes, data.vifcode0().print().c_str(), + data.vif0(), data.vifcode1().print().c_str(), data.vifcode1().num, + data.vifcode1().immediate); + transfers++; + } + printf("transfers: %d\n\n", transfers); +} + void SharedRenderState::reset() { has_pc_data = false; for (auto& x : occlusion_vis) { diff --git a/game/graphics/opengl_renderer/BucketRenderer.h b/game/graphics/opengl_renderer/BucketRenderer.h index 9dcfd35757..773d764318 100644 --- a/game/graphics/opengl_renderer/BucketRenderer.h +++ b/game/graphics/opengl_renderer/BucketRenderer.h @@ -94,6 +94,8 @@ struct SharedRenderState { int num_vis_to_copy = 0; GameVersion version; u64 frame_idx = 0; + + bool stencil_dirty = false; }; /*! @@ -155,3 +157,14 @@ class SkipRenderer : public BucketRenderer { bool empty() const override { return true; } void draw_debug_window() override {} }; + +/*! + * Renderer that ignores and prints all DMA transfers. + */ +class PrintRenderer : public BucketRenderer { + public: + PrintRenderer(const std::string& name, int my_id); + void render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) override; + bool empty() const override { return true; } + void draw_debug_window() override {} +}; \ No newline at end of file diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index 92276b8340..37c492911e 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -20,6 +20,7 @@ #include "game/graphics/opengl_renderer/background/Tie3.h" #include "game/graphics/opengl_renderer/foreground/Generic2.h" #include "game/graphics/opengl_renderer/foreground/Merc2.h" +#include "game/graphics/opengl_renderer/foreground/Shadow2.h" #include "game/graphics/opengl_renderer/ocean/OceanMidAndFar.h" #include "game/graphics/opengl_renderer/ocean/OceanNear.h" #include "game/graphics/opengl_renderer/sprite/Sprite3.h" @@ -215,6 +216,7 @@ void OpenGLRenderer::init_bucket_renderers_jak2() { init_bucket_renderer("merc-lcom-shrub", BucketCategory::MERC, BucketId::MERC_LCOM_SHRUB); init_bucket_renderer("gmerc-lcom-tfrag", BucketCategory::GENERIC, BucketId::GMERC_LCOM_TFRAG); + init_bucket_renderer("shadow", BucketCategory::OTHER, BucketId::SHADOW); // 220 init_bucket_renderer("tex-lcom-pris", BucketCategory::TEX, BucketId::TEX_LCOM_PRIS); @@ -229,6 +231,7 @@ void OpenGLRenderer::init_bucket_renderers_jak2() { init_bucket_renderer("tex-all-sprite", BucketCategory::TEX, BucketId::TEX_ALL_SPRITE); init_bucket_renderer("particles", BucketCategory::SPRITE, BucketId::PARTICLES); + init_bucket_renderer("shadow2", BucketCategory::OTHER, BucketId::SHADOW2); init_bucket_renderer("effects", BucketCategory::OTHER, BucketId::EFFECTS); init_bucket_renderer("tex-all-warp", BucketCategory::TEX, BucketId::TEX_ALL_WARP); @@ -846,6 +849,7 @@ void OpenGLRenderer::setup_frame(const RenderOptions& settings) { // letterboxing glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glDisable(GL_BLEND); + m_render_state.stencil_dirty = false; // setup the draw region to letterbox later m_render_state.draw_region_w = settings.draw_region_width; @@ -1088,7 +1092,7 @@ void OpenGLRenderer::do_pcrtc_effects(float alp, ); glBindFramebuffer(GL_FRAMEBUFFER, 0); } - if (alp < 1 && m_version != GameVersion::Jak2) { // TODO: enable blackout on jak 2. + if (alp < 1) { glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); diff --git a/game/graphics/opengl_renderer/Shader.cpp b/game/graphics/opengl_renderer/Shader.cpp index 9307ac1c4d..d104a24ceb 100644 --- a/game/graphics/opengl_renderer/Shader.cpp +++ b/game/graphics/opengl_renderer/Shader.cpp @@ -107,6 +107,7 @@ ShaderLibrary::ShaderLibrary(GameVersion version) { at(ShaderId::GLOW_DRAW) = {"glow_draw", version}; at(ShaderId::ETIE_BASE) = {"etie_base", version}; at(ShaderId::ETIE) = {"etie", version}; + at(ShaderId::SHADOW2) = {"shadow2", version}; for (auto& shader : m_shaders) { ASSERT_MSG(shader.okay(), "error compiling shader"); diff --git a/game/graphics/opengl_renderer/Shader.h b/game/graphics/opengl_renderer/Shader.h index b741017388..cf6e736cd6 100644 --- a/game/graphics/opengl_renderer/Shader.h +++ b/game/graphics/opengl_renderer/Shader.h @@ -56,6 +56,7 @@ enum class ShaderId { GLOW_DRAW = 29, ETIE_BASE = 30, ETIE = 31, + SHADOW2 = 32, MAX_SHADERS }; diff --git a/game/graphics/opengl_renderer/ShadowRenderer.h b/game/graphics/opengl_renderer/ShadowRenderer.h index 5bbe1879b5..18eec8acf0 100644 --- a/game/graphics/opengl_renderer/ShadowRenderer.h +++ b/game/graphics/opengl_renderer/ShadowRenderer.h @@ -13,7 +13,7 @@ class ShadowRenderer : public BucketRenderer { private: void run_mscal_vu2c(u16 imm); void xgkick(u16 imm); - void run_mscal10_vu2c(); + void run_mscal10_vu2c(); // identical in jak 2 void handle_jalr_to_end_block(u16 val, u32& first_flag, u32& second_flag); void handle_bal52(); void draw(SharedRenderState* render_state, ScopedProfilerNode& prof); diff --git a/game/graphics/opengl_renderer/Shadow_PS2.cpp b/game/graphics/opengl_renderer/Shadow_PS2.cpp index 69fb615e94..1d6dbf3492 100644 --- a/game/graphics/opengl_renderer/Shadow_PS2.cpp +++ b/game/graphics/opengl_renderer/Shadow_PS2.cpp @@ -1892,4 +1892,4 @@ void ShadowRenderer::run_mscal_vu2c(u16 imm) { default: ASSERT_MSG(false, fmt::format("unknown vu.vi15 @ 722: {}", vu.vi15)); } -} +} \ No newline at end of file diff --git a/game/graphics/opengl_renderer/foreground/Shadow2.cpp b/game/graphics/opengl_renderer/foreground/Shadow2.cpp new file mode 100644 index 0000000000..aa82b6e63c --- /dev/null +++ b/game/graphics/opengl_renderer/foreground/Shadow2.cpp @@ -0,0 +1,578 @@ +#include "Shadow2.h" + +#include "third-party/imgui/imgui.h" + +Shadow2::Shadow2(const std::string& name, int my_id) : BucketRenderer(name, my_id) { + m_vertex_buffer.resize(kMaxVerts); + m_front_index_buffer.resize(kMaxInds); + m_back_index_buffer.resize(kMaxInds); + // a + + glGenBuffers(1, &m_ogl.vertex_buffer); + glGenBuffers(2, m_ogl.index_buffer); + glGenVertexArrays(1, &m_ogl.vao); + glBindVertexArray(m_ogl.vao); + for (int i = 0; i < 2; i++) { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ogl.index_buffer[i]); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, kMaxInds * sizeof(u32), nullptr, GL_STREAM_DRAW); + } + glBindBuffer(GL_ARRAY_BUFFER, m_ogl.vertex_buffer); + glBufferData(GL_ARRAY_BUFFER, kMaxVerts * sizeof(ShadowVertex), nullptr, GL_STREAM_DRAW); + + // xyz + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, // location 0 in the shader + 3, // 3 floats per vert + GL_FLOAT, // floats + GL_TRUE, // normalized, ignored, + sizeof(ShadowVertex), // + (void*)offsetof(ShadowVertex, pos) // offset in array + ); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(0); +} + +Shadow2::~Shadow2() { + glDeleteBuffers(1, &m_ogl.vertex_buffer); + glDeleteBuffers(2, m_ogl.index_buffer); + glDeleteVertexArrays(1, &m_ogl.vao); +} + +void Shadow2::init_shaders(ShaderLibrary& shaders) { + const auto id = shaders[ShaderId::SHADOW2].id(); + m_ogl.uniforms.perspective[0] = glGetUniformLocation(id, "perspective_x"); + m_ogl.uniforms.perspective[1] = glGetUniformLocation(id, "perspective_y"); + m_ogl.uniforms.perspective[2] = glGetUniformLocation(id, "perspective_z"); + m_ogl.uniforms.perspective[3] = glGetUniformLocation(id, "perspective_w"); + + m_ogl.uniforms.color = glGetUniformLocation(id, "color_uniform"); + m_ogl.uniforms.fog = glGetUniformLocation(id, "fog"); + m_ogl.uniforms.hvdf_offset = glGetUniformLocation(id, "hvdf_offset"); + m_ogl.uniforms.clear_mode = glGetUniformLocation(id, "clear_mode"); +} + +void Shadow2::draw_debug_window() { + ImGui::Checkbox("volume", &m_debug_draw_volume); +} + +void Shadow2::reset_buffers() { + m_front_index_buffer_used = 0; + m_back_index_buffer_used = 0; + m_vertex_buffer_used = 0; +} + +void Shadow2::render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) { + reset_buffers(); + // jump to bucket + dma.read_and_advance(); + + if (dma.current_tag_offset() == render_state->next_bucket) { + // nothing + return; + } + + auto maybe_constants = dma.read_and_advance(); + if (maybe_constants.size_bytes == 0 && maybe_constants.vif0() == 0 && + maybe_constants.vif1() == 0) { + // nothing + return; + } + + // shadow-vu1-constants + ASSERT(maybe_constants.size_bytes >= sizeof(ShadowVu1Constants)); + FrameConstants frame_constants; + memcpy(&frame_constants.constants, maybe_constants.data, sizeof(ShadowVu1Constants)); + + // ?? no idea what this is. + auto mystery_data_dma = dma.read_and_advance(); + ASSERT(mystery_data_dma.size_bytes == 4 * 16); + memcpy(frame_constants.mystery.data, mystery_data_dma.data, 4 * 16); + + // the perspective matrix + auto perspective_matrix_dma = dma.read_and_advance(); + ASSERT(perspective_matrix_dma.size_bytes == sizeof(CameraMatrix)); + memcpy(&frame_constants.camera, perspective_matrix_dma.data, sizeof(CameraMatrix)); + + // mscal 0xa + { + auto init_mscal = dma.read_and_advance(); + auto vif0 = init_mscal.vifcode0(); + + ASSERT(vif0.kind == VifCode::Kind::MSCALF); + ASSERT(vif0.immediate == 10); + } + + // nothing + { + auto nothing = dma.read_and_advance(); + ASSERT(nothing.size_bytes == 0); + ASSERT(nothing.vif0() == 0); + ASSERT(nothing.vif1() == 0); + } + + // maybe the invert z thing + DmaFollower f = dma; + auto maybe_invert_z = f.read_and_advance(); + bool invert_z = false; + if (maybe_invert_z.vif0() == 0 && maybe_invert_z.vifcode1().kind == VifCode::Kind::DIRECT && + maybe_invert_z.vifcode1().immediate == 35) { + invert_z = true; + dma.read_and_advance(); + } + + // loop over uploads + InputData current_input; + bool have_color = false; + while (true) { + if (dma.current_tag_offset() == render_state->next_bucket) { + break; + } + auto transfer = dma.read_and_advance(); + auto vif0 = transfer.vifcode0(); + auto vif1 = transfer.vifcode1(); + + if (vif1.kind == VifCode::Kind::UNPACK_V4_32) { + ASSERT(vif0.kind == VifCode::Kind::FLUSH || vif0.kind == VifCode::Kind::NOP); + ASSERT(vif1.num * 16 == transfer.size_bytes); // no extra data + int addr = vif1.immediate; + switch (addr) { + case kTopVertexDataAddr: + current_input.top_vertex_data = transfer.data; + break; + case kBottomVertexDataAddr: + current_input.bottom_vertex_data = transfer.data; + break; + default: + ASSERT_NOT_REACHED_MSG(fmt::format("Unknown address for transfer: {}\n", addr)); + } + } else if (vif1.kind == VifCode::Kind::UNPACK_V4_8) { + ASSERT(vif0.kind == VifCode::Kind::FLUSH || vif0.kind == VifCode::Kind::NOP); + auto up = VifCodeUnpack(vif1); + ASSERT(!up.use_tops_flag); + ASSERT(up.is_unsigned); + u16 addr = up.addr_qw; + + u32 offset = 4 * vif1.num; + ASSERT(offset + 16 == transfer.size_bytes); + + u32 after[4]; + memcpy(&after, transfer.data + offset, 16); + ASSERT(after[0] == 0); + ASSERT(after[1] == 0); + ASSERT(after[2] == 0); + VifCode mscal(after[3]); + ASSERT(mscal.kind == VifCode::Kind::MSCALF); + + switch (addr) { + case kCapIndexDataAddr: + current_input.cap_index_data_size = 4 * vif1.num; + current_input.cap_index_data = transfer.data; + break; + case kWallIndexDataAddr: + current_input.wall_index_data_size = 4 * vif1.num; + current_input.wall_index_data = transfer.data; + break; + default: + ASSERT_NOT_REACHED_MSG(fmt::format("Unknown address for transfer: {}\n", addr)); + } + + switch (mscal.immediate) { + case 2: + buffer_from_mscal2(current_input); + break; + case 4: + buffer_from_mscal4(current_input); + break; + case 6: + buffer_from_mscal6(current_input); + break; + default: + printf("mscal %d\n", mscal.immediate); + ASSERT_NOT_REACHED(); + } + } else if (vif0.kind == VifCode::Kind::FLUSHA && vif1.kind == VifCode::Kind::DIRECT) { + if (transfer.size_bytes == 560) { + have_color = true; + memcpy(m_color, transfer.data + 8 * 3, 4); + } + // ignore + } else if (vif0.kind == VifCode::Kind::NOP && vif1.kind == VifCode::Kind::NOP) { + // ignore + } + + else { + fmt::print("unhandled transfer in shadow2\n{} bytes\n{}\n{}\n", transfer.size_bytes, + vif0.print(), vif1.print()); + } + } + + ASSERT(have_color); + draw_buffers(render_state, prof, frame_constants); + auto transfers = 0; + while (dma.current_tag_offset() != render_state->next_bucket) { + auto data = dma.read_and_advance(); + if (data.size_bytes == 560) { + memcpy(m_color, data.data + 8 * 3, 4); + } + transfers++; + } + ASSERT(transfers < 7); +} + +void Shadow2::buffer_from_mscal2(const InputData& in) { + // draw top caps. + add_cap_tris(in.cap_index_data, in.top_vertex_data, false); + + // draw bottom caps. + add_cap_tris(in.cap_index_data, in.bottom_vertex_data, true); +} + +void Shadow2::buffer_from_mscal4(const InputData& in) { + add_wall_quads(in.wall_index_data, in.top_vertex_data, in.bottom_vertex_data); +} + +void Shadow2::buffer_from_mscal6(const InputData& in) { + // draw top caps. + add_flippable_tris(in.cap_index_data, in.top_vertex_data, false); + add_flippable_tris(in.cap_index_data, in.bottom_vertex_data, true); +} + +Shadow2::ShadowVertex* Shadow2::alloc_verts(int n) { + auto* result = &m_vertex_buffer[m_vertex_buffer_used]; + m_vertex_buffer_used += n; + ASSERT(m_vertex_buffer_used <= m_vertex_buffer.size()); + return result; +} + +u32* Shadow2::alloc_inds(int n, bool front) { + if (!front) { + auto* result = &m_front_index_buffer[m_front_index_buffer_used]; + m_front_index_buffer_used += n; + ASSERT(m_front_index_buffer_used <= m_front_index_buffer.size()); + return result; + } else { + auto* result = &m_back_index_buffer[m_back_index_buffer_used]; + m_back_index_buffer_used += n; + ASSERT(m_back_index_buffer_used <= m_back_index_buffer.size()); + return result; + } +} + +const u8* Shadow2::add_cap_tris(const u8* byte_data, const u8* vertex_data, bool flip) { + const int num_single_tris = *byte_data++; + for (int i = 0; i < 3; i++) { + int v = *byte_data++; + ASSERT(v == 0); + } + for (int i = 0; i < num_single_tris; i++) { + int vertex_addrs[3]; + vertex_addrs[0] = *byte_data++; // vi04 + vertex_addrs[1] = *byte_data++; // vi05 + vertex_addrs[2] = *byte_data++; // vi06 + const int bonus = *byte_data++; // unused, but not zero? + ASSERT(bonus == 1); // idk + + // due to unpackv4-8 alignment, they inserted up to 3 dummy tris at the end. let's just skip. + if (!vertex_addrs[0] && !vertex_addrs[1] && !vertex_addrs[2]) { + ASSERT(i + 4 >= num_single_tris); + continue; + } + + // load vertices (to vf17, vf18, vf19) + const int opengl_vertex_idx = m_vertex_buffer_used; + auto* vertex_rt_camera = alloc_verts(3); + if (flip) { + memcpy(vertex_rt_camera[0].pos.data(), vertex_data + 16 * vertex_addrs[0], 12); + memcpy(vertex_rt_camera[1].pos.data(), vertex_data + 16 * vertex_addrs[2], 12); + memcpy(vertex_rt_camera[2].pos.data(), vertex_data + 16 * vertex_addrs[1], 12); + } else { + for (int j = 0; j < 3; j++) { + memcpy(vertex_rt_camera[j].pos.data(), vertex_data + 16 * vertex_addrs[j], 12); + } + } + + const math::Vector3f v1_v0_rt_camera = vertex_rt_camera[1].pos - vertex_rt_camera[0].pos; + const math::Vector3f v2_v0_rt_camera = vertex_rt_camera[2].pos - vertex_rt_camera[0].pos; + const math::Vector3f tri_normal = v1_v0_rt_camera.cross(v2_v0_rt_camera); + const float normal_dot_eye = tri_normal.dot(vertex_rt_camera[0].pos); + auto* idx_buffer = alloc_inds(4, normal_dot_eye > 0); + for (int j = 0; j < 3; j++) { + idx_buffer[j] = opengl_vertex_idx + j; + } + idx_buffer[3] = UINT32_MAX; + } + return byte_data; +} + +const u8* Shadow2::add_flippable_tris(const u8* byte_data, const u8* vertex_data, bool flip) { + const int num_single_tris = *byte_data++; + for (int i = 0; i < 3; i++) { + int v = *byte_data++; + ASSERT(v == 0); + } + for (int i = 0; i < num_single_tris; i++) { + int vertex_addrs[3]; + vertex_addrs[0] = *byte_data++; // vi04 + vertex_addrs[1] = *byte_data++; // vi05 + vertex_addrs[2] = *byte_data++; // vi06 + const int flip_flag = *byte_data++; + + // due to unpackv4-8 alignment, they inserted up to 3 dummy tris at the end. let's just skip. + if (!vertex_addrs[0] && !vertex_addrs[1] && !vertex_addrs[2]) { + ASSERT(i + 4 >= num_single_tris); + continue; + } + + // load vertices (to vf17, vf18, vf19) + const int opengl_vertex_idx = m_vertex_buffer_used; + auto* vertex_rt_camera = alloc_verts(3); + if ((flip ^ flip_flag) == 0) { + memcpy(vertex_rt_camera[0].pos.data(), vertex_data + 16 * vertex_addrs[0], 12); + memcpy(vertex_rt_camera[1].pos.data(), vertex_data + 16 * vertex_addrs[2], 12); + memcpy(vertex_rt_camera[2].pos.data(), vertex_data + 16 * vertex_addrs[1], 12); + + } else { + for (int j = 0; j < 3; j++) { + memcpy(vertex_rt_camera[j].pos.data(), vertex_data + 16 * vertex_addrs[j], 12); + } + } + + const math::Vector3f v1_v0_rt_camera = vertex_rt_camera[1].pos - vertex_rt_camera[0].pos; + const math::Vector3f v2_v0_rt_camera = vertex_rt_camera[2].pos - vertex_rt_camera[0].pos; + const math::Vector3f tri_normal = v1_v0_rt_camera.cross(v2_v0_rt_camera); + const float normal_dot_eye = tri_normal.dot(vertex_rt_camera[0].pos); + auto* idx_buffer = alloc_inds(4, normal_dot_eye > 0); + for (int j = 0; j < 3; j++) { + idx_buffer[j] = opengl_vertex_idx + j; + } + idx_buffer[3] = UINT32_MAX; + } + return byte_data; +} + +const u8* Shadow2::add_wall_quads(const u8* byte_data, + const u8* vertex_data_0, + const u8* vertex_data_1) { + const int num_quads = *byte_data++; + for (int i = 0; i < 3; i++) { + int v = *byte_data++; + ASSERT(v == 0); + } + + for (int i = 0; i < num_quads; i++) { + int vertex_addrs[2]; + vertex_addrs[0] = *byte_data++; // vi04 + vertex_addrs[1] = *byte_data++; // vi05 + int side_control = *byte_data++; + + const int bonus = *byte_data++; // unused, but not zero? + (void)bonus; + + // due to unpackv4-8 alignment, they inserted up to 3 dummy tris at the end. let's just skip. + if (!vertex_addrs[0] && !vertex_addrs[1]) { + ASSERT(i + 4 >= num_quads); + continue; + } + + const int opengl_vertex_idx = m_vertex_buffer_used; + auto* vertex_rt_camera = alloc_verts(4); + + if (side_control == 0) { + memcpy(vertex_rt_camera[0].pos.data(), vertex_data_0 + 16 * vertex_addrs[1], 12); + memcpy(vertex_rt_camera[1].pos.data(), vertex_data_0 + 16 * vertex_addrs[0], 12); + memcpy(vertex_rt_camera[2].pos.data(), vertex_data_1 + 16 * vertex_addrs[0], 12); + memcpy(vertex_rt_camera[3].pos.data(), vertex_data_1 + 16 * vertex_addrs[1], 12); + } else { + memcpy(vertex_rt_camera[0].pos.data(), vertex_data_0 + 16 * vertex_addrs[0], 12); + memcpy(vertex_rt_camera[1].pos.data(), vertex_data_0 + 16 * vertex_addrs[1], 12); + memcpy(vertex_rt_camera[2].pos.data(), vertex_data_1 + 16 * vertex_addrs[1], 12); + memcpy(vertex_rt_camera[3].pos.data(), vertex_data_1 + 16 * vertex_addrs[0], 12); + } + + const math::Vector3f v1_v0_rt_camera = vertex_rt_camera[1].pos - vertex_rt_camera[0].pos; + const math::Vector3f v2_v0_rt_camera = vertex_rt_camera[2].pos - vertex_rt_camera[0].pos; + const math::Vector3f tri_normal = v1_v0_rt_camera.cross(v2_v0_rt_camera); + const float normal_dot_eye = tri_normal.dot(vertex_rt_camera[0].pos); + auto* idx_buffer = alloc_inds(5, normal_dot_eye > 0); + idx_buffer[0] = opengl_vertex_idx + 1; + idx_buffer[1] = opengl_vertex_idx + 0; + idx_buffer[2] = opengl_vertex_idx + 2; + idx_buffer[3] = opengl_vertex_idx + 3; + idx_buffer[4] = UINT32_MAX; + } + return byte_data; +} + +namespace { +void set_uniform(GLint id, const math::Vector4f& value) { + glUniform4f(id, value[0], value[1], value[2], value[3]); +} +} // namespace + +void Shadow2::draw_buffers(SharedRenderState* render_state, + ScopedProfilerNode& prof, + const FrameConstants& constants) { + if (!m_front_index_buffer_used && !m_back_index_buffer_used) { + return; + } + + if (render_state->stencil_dirty) { + glClearStencil(0); + glClear(GL_STENCIL_BUFFER_BIT); + } + render_state->stencil_dirty = true; + + render_state->shaders.at(ShaderId::SHADOW2).activate(); + + // uniforms: + set_uniform(m_ogl.uniforms.hvdf_offset, constants.constants.hvdfoff); + glUniform1f(m_ogl.uniforms.fog, constants.constants.fog[0]); + for (int i = 0; i < 4; i++) { + set_uniform(m_ogl.uniforms.perspective[i], constants.camera.v[i]); + } + glUniform1i(m_ogl.uniforms.clear_mode, 0); + + // enable stencil! + glEnable(GL_STENCIL_TEST); + glStencilMask(0xFF); + + u32 clear_vertices = m_vertex_buffer_used; + m_vertex_buffer[m_vertex_buffer_used++] = ShadowVertex{math::Vector3f(0.3, 0.3, 0), 0}; + m_vertex_buffer[m_vertex_buffer_used++] = ShadowVertex{math::Vector3f(0.3, 0.7, 0), 0}; + m_vertex_buffer[m_vertex_buffer_used++] = ShadowVertex{math::Vector3f(0.7, 0.3, 0), 0}; + m_vertex_buffer[m_vertex_buffer_used++] = ShadowVertex{math::Vector3f(0.7, 0.7, 0), 0}; + m_front_index_buffer[m_front_index_buffer_used++] = clear_vertices; + m_front_index_buffer[m_front_index_buffer_used++] = clear_vertices + 1; + m_front_index_buffer[m_front_index_buffer_used++] = clear_vertices + 2; + m_front_index_buffer[m_front_index_buffer_used++] = clear_vertices + 3; + m_front_index_buffer[m_front_index_buffer_used++] = UINT32_MAX; + m_front_index_buffer[m_front_index_buffer_used++] = UINT32_MAX; + + glBindVertexArray(m_ogl.vao); + glEnable(GL_PRIMITIVE_RESTART); + glPrimitiveRestartIndex(UINT32_MAX); + glBindBuffer(GL_ARRAY_BUFFER, m_ogl.vertex_buffer); + glBufferData(GL_ARRAY_BUFFER, m_vertex_buffer_used * sizeof(ShadowVertex), m_vertex_buffer.data(), + GL_STREAM_DRAW); + + glEnable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + glDepthFunc(GL_GEQUAL); + + glDepthMask(GL_FALSE); // no depth writes. + if (m_debug_draw_volume) { + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); + } else { + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // no color writes. + } + + // First pass. + // here, we don't write depth or color. + // but we increment stencil on depth fail. + + { + glUniform4f(m_ogl.uniforms.color, 0., 0.4, 0., 0.5); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ogl.index_buffer[0]); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_front_index_buffer_used * sizeof(u32), + m_front_index_buffer.data(), GL_STREAM_DRAW); + glStencilFunc(GL_ALWAYS, 0, 0); // always pass stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); // increment on depth pass. + glEnable(GL_PRIMITIVE_RESTART); + glPrimitiveRestartIndex(UINT32_MAX); + glDrawElements(GL_TRIANGLE_STRIP, (m_front_index_buffer_used - 6), GL_UNSIGNED_INT, nullptr); + + if (m_debug_draw_volume) { + glDisable(GL_BLEND); + glUniform4f(m_ogl.uniforms.color, 0., 0.0, 0., 0.5); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + glDrawElements(GL_TRIANGLE_STRIP, (m_front_index_buffer_used - 6), GL_UNSIGNED_INT, nullptr); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glEnable(GL_BLEND); + prof.add_draw_call(); + prof.add_tri(m_front_index_buffer_used / 3); + } + prof.add_draw_call(); + prof.add_tri(m_front_index_buffer_used / 3); + } + + { + glUniform4f(m_ogl.uniforms.color, 0.4, 0.0, 0., 0.5); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ogl.index_buffer[1]); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_back_index_buffer_used * sizeof(u32), + m_back_index_buffer.data(), GL_STREAM_DRAW); + + // Second pass. + // same settings, but decrement. + glStencilFunc(GL_ALWAYS, 0, 0); + glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); // decrement on depth pass. + glDrawElements(GL_TRIANGLE_STRIP, m_back_index_buffer_used, GL_UNSIGNED_INT, nullptr); + if (m_debug_draw_volume) { + glDisable(GL_BLEND); + glUniform4f(m_ogl.uniforms.color, 0., 0.0, 0., 0.5); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + glDrawElements(GL_TRIANGLE_STRIP, (m_back_index_buffer_used - 0), GL_UNSIGNED_INT, nullptr); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glEnable(GL_BLEND); + prof.add_draw_call(); + prof.add_tri(m_back_index_buffer_used / 3); + } + + prof.add_draw_call(); + prof.add_tri(m_back_index_buffer_used / 3); + } + + // finally, draw shadow. + glUniform1i(m_ogl.uniforms.clear_mode, 1); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ogl.index_buffer[0]); + glStencilFunc(GL_NOTEQUAL, 0, 0xFF); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + glDepthFunc(GL_ALWAYS); + + glEnable(GL_BLEND); + glBlendFuncSeparate(GL_ONE, GL_ONE, GL_ONE, GL_ZERO); + + bool have_darken = false; + bool have_lighten = false; + bool lighten_channel[3] = {false, false, false}; + bool darken_channel[3] = {false, false, false}; + for (int i = 0; i < 3; i++) { + if (m_color[i] > 128) { + have_lighten = true; + lighten_channel[i] = true; + } else if (m_color[i] < 128) { + have_darken = true; + darken_channel[i] = true; + } + } + + if (have_darken) { + glColorMask(darken_channel[0], darken_channel[1], darken_channel[2], false); + glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); + glUniform4f(m_ogl.uniforms.color, (128 - m_color[0]) / 256.f, (128 - m_color[1]) / 256.f, + (128 - m_color[2]) / 256.f, 0); + glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); + glDrawElements(GL_TRIANGLE_STRIP, 6, GL_UNSIGNED_INT, + (void*)(sizeof(u32) * (m_front_index_buffer_used - 6))); + } + + if (have_lighten) { + glColorMask(lighten_channel[0], lighten_channel[1], lighten_channel[2], false); + glUniform4f(m_ogl.uniforms.color, (m_color[0] - 128) / 256.f, (m_color[1] - 128) / 256.f, + (m_color[2] - 128) / 256.f, 0); + glBlendEquation(GL_FUNC_ADD); + glDrawElements(GL_TRIANGLE_STRIP, 6, GL_UNSIGNED_INT, + (void*)(sizeof(u32) * (m_front_index_buffer_used - 6))); + } + + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + + prof.add_draw_call(); + prof.add_tri(2); + glBlendEquation(GL_FUNC_ADD); + glDepthMask(GL_TRUE); + + glDisable(GL_STENCIL_TEST); +} \ No newline at end of file diff --git a/game/graphics/opengl_renderer/foreground/Shadow2.h b/game/graphics/opengl_renderer/foreground/Shadow2.h new file mode 100644 index 0000000000..eddaa5c77e --- /dev/null +++ b/game/graphics/opengl_renderer/foreground/Shadow2.h @@ -0,0 +1,97 @@ +#pragma once + +#include "common/math/Vector.h" + +#include "game/graphics/opengl_renderer/BucketRenderer.h" + +class Shadow2 : public BucketRenderer { + public: + static constexpr int kMaxVerts = 8192 * 3; + static constexpr int kMaxInds = 8192 * 3; + Shadow2(const std::string& name, int my_id); + ~Shadow2(); + void render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) override; + void draw_debug_window() override; + void init_shaders(ShaderLibrary& shaders) override; + + private: + struct ShadowVu1Constants { + math::Vector4f hmgescale; + math::Vector4f invhscale; + math::Vector4f texoffset; + math::Vector4f texscale; + math::Vector4f hvdfoff; + math::Vector4f fog; + math::Vector4f clrs[2]; + }; + static_assert(sizeof(ShadowVu1Constants) == 128); + + struct MysteryData { + u8 data[4 * 16]; + }; + + struct CameraMatrix { + math::Vector4f v[4]; + }; + + struct FrameConstants { + ShadowVu1Constants constants; // 880, 0x370 + MysteryData mystery; // 940, 0x3ac + CameraMatrix camera; // 0 + }; + + static constexpr int kTopVertexDataAddr = 4; + static constexpr int kBottomVertexDataAddr = 174; + static constexpr int kCapIndexDataAddr = 344; + static constexpr int kWallIndexDataAddr = 600; + + struct InputData { + const u8* top_vertex_data = nullptr; // always 115 + const u8* bottom_vertex_data = nullptr; // always 115 + const u8* cap_index_data = nullptr; + size_t cap_index_data_size = 0; + const u8* wall_index_data = nullptr; + size_t wall_index_data_size = 0; + }; + + struct ShadowVertex { + math::Vector3f pos; + u32 pad = 0; + }; + static_assert(sizeof(ShadowVertex) == 16); + + struct { + GLuint vertex_buffer; + GLuint index_buffer[2]; + GLuint vao; + struct { + GLuint hvdf_offset; + GLuint perspective[4]; + GLuint fog; + GLuint color; + GLuint clear_mode; + } uniforms; + } m_ogl; + + std::vector m_vertex_buffer; + std::vector m_front_index_buffer; + std::vector m_back_index_buffer; + size_t m_vertex_buffer_used = 0; + size_t m_front_index_buffer_used = 0; + size_t m_back_index_buffer_used = 0; + bool m_debug_draw_volume = false; + + void reset_buffers(); + void buffer_from_mscal2(const InputData& input); + void buffer_from_mscal4(const InputData& input); + void buffer_from_mscal6(const InputData& input); + const u8* add_cap_tris(const u8* byte_data, const u8* vertex_data, bool flip); + const u8* add_wall_quads(const u8* byte_data, const u8* vertex_data_0, const u8* vertex_data_1); + const u8* add_flippable_tris(const u8* byte_data, const u8* vertex_data, bool flip); + ShadowVertex* alloc_verts(int n); + u32* alloc_inds(int n, bool front); + void draw_buffers(SharedRenderState* render_state, + ScopedProfilerNode& prof, + const FrameConstants& constants); + u8 m_color[4] = {0, 0, 0, 0}; +}; diff --git a/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp b/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp index 73a469d02c..8bc266e2ec 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp @@ -78,15 +78,6 @@ void OceanMidAndFar::render_jak1(DmaFollower& dma, m_direct.set_mipmap(false); } -void advance_and_print_dma(DmaFollower& dma) { - auto data = dma.read_and_advance(); - printf( - "dma transfer:\n%ssize: %d\nvif0: %s, data: %d\nvif1: %s, data: %d, imm: " - "%d\n\n", - dma.current_tag().print().c_str(), data.size_bytes, data.vifcode0().print().c_str(), - data.vif0(), data.vifcode1().print().c_str(), data.vifcode1().num, data.vifcode1().immediate); -} - void OceanMidAndFar::render_jak2(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) { diff --git a/game/graphics/opengl_renderer/shaders/shadow2.frag b/game/graphics/opengl_renderer/shaders/shadow2.frag new file mode 100644 index 0000000000..b941689807 --- /dev/null +++ b/game/graphics/opengl_renderer/shaders/shadow2.frag @@ -0,0 +1,8 @@ +#version 430 core + +out vec4 color; +uniform vec4 color_uniform; + +void main() { + color = 0.5 * color_uniform; +} diff --git a/game/graphics/opengl_renderer/shaders/shadow2.vert b/game/graphics/opengl_renderer/shaders/shadow2.vert new file mode 100644 index 0000000000..5d14393f28 --- /dev/null +++ b/game/graphics/opengl_renderer/shaders/shadow2.vert @@ -0,0 +1,37 @@ +#version 430 core + +layout (location = 0) in vec3 position_in; + +uniform int clear_mode; +uniform float fog; +uniform vec4 perspective_x; +uniform vec4 perspective_y; +uniform vec4 perspective_z; +uniform vec4 perspective_w; +uniform vec4 hvdf_offset; + + +void main() { + if (clear_mode == 1) { + // this is just copied from shadow 1, needs revisiting. + gl_Position = vec4((position_in.x - 0.5) * 16., -(position_in.y - 0.5) * 32, position_in.z * 2 - 1., 1.0); + gl_Position.y *= SCISSOR_ADJUST; + } else { + vec4 transformed = -perspective_w; + transformed -= perspective_x * position_in.x; + transformed -= perspective_y * position_in.y; + transformed -= perspective_z * position_in.z; + transformed.xyz *= fog / transformed.w; + + + transformed.xyz += hvdf_offset.xyz; + transformed.xy -= (2048.); + transformed.z /= (8388608); + transformed.z -= 1; + transformed.x /= (256); + transformed.y /= -(128); + transformed.xyz *= transformed.w; + transformed.y *= SCISSOR_ADJUST * HEIGHT_SCALE; + gl_Position = transformed; + } +} \ No newline at end of file diff --git a/game/kernel/jak2/kmachine.cpp b/game/kernel/jak2/kmachine.cpp index 34e701562b..192e09e735 100644 --- a/game/kernel/jak2/kmachine.cpp +++ b/game/kernel/jak2/kmachine.cpp @@ -708,8 +708,12 @@ void InitMachine_PCPort() { * PC port functions END */ -void PutDisplayEnv(u32 /*ptr*/) { - ASSERT(false); +void PutDisplayEnv(u32 alp) { + // we can mostly ignore this, except for one value that sets the 'blackout' amount. + auto* renderer = Gfx::GetCurrentRenderer(); + if (renderer) { + renderer->set_pmode_alp(alp / 255.f); + } } u32 sceGsSyncV(u32 mode) { diff --git a/game/mips2c/jak2_functions/shadow.cpp b/game/mips2c/jak2_functions/shadow.cpp new file mode 100644 index 0000000000..c8cb09f688 --- /dev/null +++ b/game/mips2c/jak2_functions/shadow.cpp @@ -0,0 +1,2803 @@ +//--------------------------MIPS2C--------------------- +#include "game/kernel/jak2/kscheme.h" +#include "game/mips2c/mips2c_private.h" +namespace Mips2C::jak2 { +// clang-format off +namespace { +void exec_0(ExecutionContext* c) { + // nop | sub.xyzw vf05, vf03, vf02 0 + c->vfs[vf05].vf.sub(Mask::xyzw, c->vf_src(vf03).vf, c->vf_src(vf02).vf); + // nop | sub.xyzw vf06, vf04, vf02 1 + c->vfs[vf06].vf.sub(Mask::xyzw, c->vf_src(vf04).vf, c->vf_src(vf02).vf); + // nop | sub.xyzw vf10, vf08, vf07 2 + c->vfs[vf10].vf.sub(Mask::xyzw, c->vf_src(vf08).vf, c->vf_src(vf07).vf); + // nop | sub.xyzw vf11, vf09, vf07 3 + c->vfs[vf11].vf.sub(Mask::xyzw, c->vf_src(vf09).vf, c->vf_src(vf07).vf); + // nop | sub.xyzw vf15, vf13, vf12 4 + c->vfs[vf15].vf.sub(Mask::xyzw, c->vf_src(vf13).vf, c->vf_src(vf12).vf); + // nop | sub.xyzw vf16, vf14, vf12 5 + c->vfs[vf16].vf.sub(Mask::xyzw, c->vf_src(vf14).vf, c->vf_src(vf12).vf); + // nop | sub.xyzw vf20, vf18, vf17 6 + c->vfs[vf20].vf.sub(Mask::xyzw, c->vf_src(vf18).vf, c->vf_src(vf17).vf); + // nop | sub.xyzw vf21, vf19, vf17 7 + c->vfs[vf21].vf.sub(Mask::xyzw, c->vf_src(vf19).vf, c->vf_src(vf17).vf); + // nop | opmula.xyz ACC, vf05, vf06 8 + c->vopmula(vf05, vf06); // ASSERT(false); + // nop | opmsub.xyz vf05, vf06, vf05 9 + c->vopmsub(vf05, vf06, vf05); //ASSERT(false); + // nop | opmula.xyz ACC, vf10, vf11 10 + c->vopmula(vf10, vf11); // ASSERT(false); + // nop | opmsub.xyz vf10, vf11, vf10 11 + c->vopmsub(vf10, vf11, vf10); // ASSERT(false); + // nop | opmula.xyz ACC, vf15, vf16 12 + c->vopmula(vf15, vf16); // ASSERT(false); + // nop | opmsub.xyz vf15, vf16, vf15 13 + c->vopmsub(vf15, vf16, vf15); // ASSERT(false); + // nop | opmula.xyz ACC, vf20, vf21 14 + c->vopmula(vf20, vf21); // ASSERT(false); + // nop | opmsub.xyz vf20, vf21, vf20 15 + c->vopmsub(vf20, vf21, vf20); // ASSERT(false); + // nop | mul.xyz vf05, vf05, vf01 16 + c->vfs[vf05].vf.mul(Mask::xyz, c->vf_src(vf05).vf, c->vf_src(vf01).vf); + // nop | mul.xyz vf10, vf10, vf01 17 + c->vfs[vf10].vf.mul(Mask::xyz, c->vf_src(vf10).vf, c->vf_src(vf01).vf); + // nop | mul.xyz vf15, vf15, vf01 18 + c->vfs[vf15].vf.mul(Mask::xyz, c->vf_src(vf15).vf, c->vf_src(vf01).vf); + // nop | mul.xyz vf20, vf20, vf01 19 + c->vfs[vf20].vf.mul(Mask::xyz, c->vf_src(vf20).vf, c->vf_src(vf01).vf); + // nop | addx.y vf05, vf05, vf05 20 + c->vfs[vf05].vf.add(Mask::y, c->vf_src(vf05).vf, c->vf_src(vf05).vf.x()); + // nop | addx.y vf10, vf10, vf10 21 + c->vfs[vf10].vf.add(Mask::y, c->vf_src(vf10).vf, c->vf_src(vf10).vf.x()); + // nop | addx.y vf15, vf15, vf15 22 + c->vfs[vf15].vf.add(Mask::y, c->vf_src(vf15).vf, c->vf_src(vf15).vf.x()); + // nop | addx.y vf20, vf20, vf20 23 + c->vfs[vf20].vf.add(Mask::y, c->vf_src(vf20).vf, c->vf_src(vf20).vf.x()); + // nop | addz.y vf22, vf05, vf05 24 + c->vfs[vf22].vf.add(Mask::y, c->vf_src(vf05).vf, c->vf_src(vf05).vf.z()); + // nop | addz.y vf23, vf10, vf10 25 + c->vfs[vf23].vf.add(Mask::y, c->vf_src(vf10).vf, c->vf_src(vf10).vf.z()); + // nop | addz.y vf24, vf15, vf15 :e 26 + c->vfs[vf24].vf.add(Mask::y, c->vf_src(vf15).vf, c->vf_src(vf15).vf.z()); + // nop | addz.y vf25, vf20, vf20 27 + c->vfs[vf25].vf.add(Mask::y, c->vf_src(vf20).vf, c->vf_src(vf20).vf.z()); +} + +void exec_28(ExecutionContext* c) { +// nop | mul.xyzw vf27, vf20, Q 28 + c->vfs[vf27].vf.mul(Mask::xyzw, c->vf_src(vf20).vf, c->Q); + // div Q, vf13.x, vf17.x | sub.xyzw vf19, vf01, vf03 29 + c->vfs[vf19].vf.sub(Mask::xyzw, c->vf_src(vf01).vf, c->vf_src(vf03).vf); c->Q = c->vfs[vf13].vf.x() / c->vfs[vf17].vf.x(); + // move.xyzw vf23, vf07 | sub.xyzw vf20, vf01, vf04 30 + c->vfs[vf20].vf.sub(Mask::xyzw, c->vf_src(vf01).vf, c->vf_src(vf04).vf); c->vfs[vf23].vf.move(Mask::xyzw, c->vf_src(vf07).vf); + // nop | sub.xyzw vf21, vf01, vf05 31 + c->vfs[vf21].vf.sub(Mask::xyzw, c->vf_src(vf01).vf, c->vf_src(vf05).vf); + // move.xyzw vf25, vf09 | sub.xyzw vf22, vf01, vf06 32 + c->vfs[vf22].vf.sub(Mask::xyzw, c->vf_src(vf01).vf, c->vf_src(vf06).vf); c->vfs[vf25].vf.move(Mask::xyzw, c->vf_src(vf09).vf); + // move.xyzw vf26, vf10 | sub.xyzw vf24, vf08, vf27 33 + c->vfs[vf24].vf.sub(Mask::xyzw, c->vf_src(vf08).vf, c->vf_src(vf27).vf); c->vfs[vf26].vf.move(Mask::xyzw, c->vf_src(vf10).vf); + // nop | mul.xyzw vf11, vf03, vf02 34 + c->vfs[vf11].vf.mul(Mask::xyzw, c->vf_src(vf03).vf, c->vf_src(vf02).vf); + // nop | mul.xyz vf15, vf19, vf02 35 + c->vfs[vf15].vf.mul(Mask::xyz, c->vf_src(vf19).vf, c->vf_src(vf02).vf); + // div Q, vf14.x, vf18.x | mul.xyzw vf12, vf04, vf02 36 + float oldQ = c->Q; + c->vfs[vf12].vf.mul(Mask::xyzw, c->vf_src(vf04).vf, c->vf_src(vf02).vf); c->Q = c->vfs[vf14].vf.x() / c->vfs[vf18].vf.x(); + // move.xyzw vf07, vf03 | mul.xyzw vf28, vf28, Q 37 + c->vfs[vf28].vf.mul(Mask::xyzw, c->vf_src(vf28).vf, oldQ); c->vfs[vf07].vf.move(Mask::xyzw, c->vf_src(vf03).vf); + // move.xyzw vf08, vf04 | mul.xyz vf16, vf20, vf02 38 + c->vfs[vf16].vf.mul(Mask::xyz, c->vf_src(vf20).vf, c->vf_src(vf02).vf); c->vfs[vf08].vf.move(Mask::xyzw, c->vf_src(vf04).vf); + // move.xyzw vf09, vf05 | addy.x vf11, vf11, vf11 39 + c->vfs[vf11].vf.add(Mask::x, c->vf_src(vf11).vf, c->vf_src(vf11).vf.y()); c->vfs[vf09].vf.move(Mask::xyzw, c->vf_src(vf05).vf); + // move.xyzw vf10, vf06 | addy.x vf15, vf15, vf15 40 + c->vfs[vf15].vf.add(Mask::x, c->vf_src(vf15).vf, c->vf_src(vf15).vf.y()); c->vfs[vf10].vf.move(Mask::xyzw, c->vf_src(vf06).vf); + // nop | sub.xyzw vf25, vf25, vf28 41 + c->vfs[vf25].vf.sub(Mask::xyzw, c->vf_src(vf25).vf, c->vf_src(vf28).vf); + // nop | addy.x vf12, vf12, vf12 42 + c->vfs[vf12].vf.add(Mask::x, c->vf_src(vf12).vf, c->vf_src(vf12).vf.y()); + // nop | mul.xyzw vf29, vf29, Q 43 + c->vfs[vf29].vf.mul(Mask::xyzw, c->vf_src(vf29).vf, c->Q); + // nop | addy.x vf16, vf16, vf16 44 + c->vfs[vf16].vf.add(Mask::x, c->vf_src(vf16).vf, c->vf_src(vf16).vf.y()); + // nop | addz.x vf11, vf11, vf11 45 + c->vfs[vf11].vf.add(Mask::x, c->vf_src(vf11).vf, c->vf_src(vf11).vf.z()); + // nop | addz.x vf15, vf15, vf15 46 + c->vfs[vf15].vf.add(Mask::x, c->vf_src(vf15).vf, c->vf_src(vf15).vf.z()); + // nop | sub.xyzw vf26, vf26, vf29 47 + c->vfs[vf26].vf.sub(Mask::xyzw, c->vf_src(vf26).vf, c->vf_src(vf29).vf); + // nop | addz.x vf12, vf12, vf12 48 + c->vfs[vf12].vf.add(Mask::x, c->vf_src(vf12).vf, c->vf_src(vf12).vf.z()); + // nop | addz.x vf16, vf16, vf16 49 + c->vfs[vf16].vf.add(Mask::x, c->vf_src(vf16).vf, c->vf_src(vf16).vf.z()); + // nop | addw.x vf11, vf11, vf11 50 + c->vfs[vf11].vf.add(Mask::x, c->vf_src(vf11).vf, c->vf_src(vf11).vf.w()); + // nop | mul.xyzw vf13, vf09, vf02 51 + + c->vfs[vf13].vf.mul(Mask::xyzw, c->vf_src(vf09).vf, c->vf_src(vf02).vf); + c->vfs[vf13].vf.saturate_infs(); + + // nop | addw.x vf12, vf12, vf12 52 + c->vfs[vf12].vf.add(Mask::x, c->vf_src(vf12).vf, c->vf_src(vf12).vf.w()); + // nop | mul.xyz vf17, vf21, vf02 53 + c->vfs[vf17].vf.mul(Mask::xyz, c->vf_src(vf21).vf, c->vf_src(vf02).vf); + // nop | mul.xyzw vf14, vf10, vf02 54 + c->vfs[vf14].vf.mul(Mask::xyzw, c->vf_src(vf10).vf, c->vf_src(vf02).vf); + c->vfs[vf14].vf.saturate_infs(); + + // div Q, vf11.x, vf15.x | mul.xyz vf18, vf22, vf02 55 + c->vfs[vf18].vf.mul(Mask::xyz, c->vf_src(vf22).vf, c->vf_src(vf02).vf); c->Q = c->vfs[vf11].vf.x() / c->vfs[vf15].vf.x(); + // nop | addy.x vf13, vf13, vf13 56 + c->vfs[vf13].vf.add(Mask::x, c->vf_src(vf13).vf, c->vf_src(vf13).vf.y()); + + // nop | addy.x vf17, vf17, vf17 57 + c->vfs[vf17].vf.add(Mask::x, c->vf_src(vf17).vf, c->vf_src(vf17).vf.y()); + // nop | addy.x vf14, vf14, vf14 58 + c->vfs[vf14].vf.add(Mask::x, c->vf_src(vf14).vf, c->vf_src(vf14).vf.y()); + + // nop | addy.x vf18, vf18, vf18 59 + c->vfs[vf18].vf.add(Mask::x, c->vf_src(vf18).vf, c->vf_src(vf18).vf.y()); + // nop | addz.x vf13, vf13, vf13 60 + c->vfs[vf13].vf.add(Mask::x, c->vf_src(vf13).vf, c->vf_src(vf13).vf.z()); + + // nop | addz.x vf17, vf17, vf17 61 + c->vfs[vf17].vf.add(Mask::x, c->vf_src(vf17).vf, c->vf_src(vf17).vf.z()); + // div Q, vf12.x, vf16.x | addz.x vf14, vf14, vf14 62 + oldQ = c->Q; + c->vfs[vf14].vf.add(Mask::x, c->vf_src(vf14).vf, c->vf_src(vf14).vf.z()); c->Q = c->vfs[vf12].vf.x() / c->vfs[vf16].vf.x(); + + // nop | mul.xyzw vf19, vf19, Q 63 + c->vfs[vf19].vf.mul(Mask::xyzw, c->vf_src(vf19).vf, oldQ); + // move.xyzw vf28, vf21 | addz.x vf18, vf18, vf18 64 + c->vfs[vf18].vf.add(Mask::x, c->vf_src(vf18).vf, c->vf_src(vf18).vf.z()); c->vfs[vf28].vf.move(Mask::xyzw, c->vf_src(vf21).vf); + // move.xyzw vf29, vf22 | addw.x vf13, vf13, vf13 65 + c->vfs[vf13].vf.add(Mask::x, c->vf_src(vf13).vf, c->vf_src(vf13).vf.w()); c->vfs[vf29].vf.move(Mask::xyzw, c->vf_src(vf22).vf); + c->vfs[vf13].vf.saturate_infs(); + + // nop | addw.x vf14, vf14, vf14 :e 66 + c->vfs[vf14].vf.add(Mask::x, c->vf_src(vf14).vf, c->vf_src(vf14).vf.w()); + c->vfs[vf14].vf.saturate_infs(); + + // nop | sub.xyzw vf07, vf07, vf19 67 + c->vfs[vf07].vf.sub(Mask::xyzw, c->vf_src(vf07).vf, c->vf_src(vf19).vf); +} + +void exec_68(ExecutionContext* c) { + // nop | mul.xyzw vf27, vf20, Q 68 + c->vfs[vf27].vf.mul(Mask::xyzw, c->vf_src(vf20).vf, c->Q); + // div Q, vf13.x, vf17.x | nop 69 + c->Q = c->vfs[vf13].vf.x() / c->vfs[vf17].vf.x(); + // move.xyzw vf23, vf07 | nop 70 + c->vfs[vf23].vf.move(Mask::xyzw, c->vf_src(vf07).vf); + // nop | nop 71 + + // move.xyzw vf25, vf09 | nop 72 + c->vfs[vf25].vf.move(Mask::xyzw, c->vf_src(vf09).vf); + // move.xyzw vf26, vf10 | sub.xyzw vf24, vf08, vf27 73 + c->vfs[vf24].vf.sub(Mask::xyzw, c->vf_src(vf08).vf, c->vf_src(vf27).vf); c->vfs[vf26].vf.move(Mask::xyzw, c->vf_src(vf10).vf); + // nop | nop 74 + + // nop | nop 75 + + // div Q, vf14.x, vf18.x | nop 76 + float oldQ = c->Q; + c->Q = c->vfs[vf14].vf.x() / c->vfs[vf18].vf.x(); + // nop | mul.xyzw vf28, vf28, Q 77 + c->vfs[vf28].vf.mul(Mask::xyzw, c->vf_src(vf28).vf, oldQ); + // nop | nop 78 + + // nop | nop 79 + + // nop | nop 80 + + // nop | sub.xyzw vf25, vf25, vf28 81 + c->vfs[vf25].vf.sub(Mask::xyzw, c->vf_src(vf25).vf, c->vf_src(vf28).vf); // was bad + // nop | nop 82 + + // nop | mul.xyzw vf29, vf29, Q 83 + c->vfs[vf29].vf.mul(Mask::xyzw, c->vf_src(vf29).vf, c->Q); + // nop | nop 84 + + // nop | nop 85 + + // nop | nop :e 86 + + // nop | sub.xyzw vf26, vf26, vf29 87 + c->vfs[vf26].vf.sub(Mask::xyzw, c->vf_src(vf26).vf, c->vf_src(vf29).vf); + +} +} // namespace +} // namespace Mips2C::jak2 + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_xform_verts { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + // nop // sll r0, r0, 0 + c->lw(v1, 68, a1); // lw v1, 68(a1) + // nop // sll r0, r0, 0 + c->lw(a2, 20, a0); // lw a2, 20(a0) + c->dsll(v1, v1, 4); // dsll v1, v1, 4 + c->lw(t0, 24, a0); // lw t0, 24(a0) + c->daddu(a2, a2, a0); // daddu a2, a2, a0 + c->lh(a3, 8, a0); // lh a3, 8(a0) + c->daddu(t0, t0, a0); // daddu t0, t0, a0 + // nop // sll r0, r0, 0 + c->daddu(v1, a0, v1); // daddu v1, a0, v1 + c->sw(a2, 0, a1); // sw a2, 0(a1) + c->daddiu(v1, v1, 144); // daddiu v1, v1, 144 + // nop // sll r0, r0, 0 + c->mov64(a1, t0); // or a1, t0, r0 + c->lh(t0, 10, a0); // lh t0, 10(a0) + c->mov64(a2, a2); // or a2, a2, r0 + // nop // sll r0, r0, 0 + c->dsubu(a3, a3, t0); // dsubu a3, a3, t0 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a3) == 0; // beq a3, r0, L119 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + +block_1: + c->daddiu(a3, a3, -1); // daddiu a3, a3, -1 + c->lbu(t0, 0, a1); // lbu t0, 0(a1) + // nop // sll r0, r0, 0 + c->lbu(t1, 1, a1); // lbu t1, 1(a1) + // nop // sll r0, r0, 0 + c->daddiu(a1, a1, 2); // daddiu a1, a1, 2 + c->dsll(t0, t0, 7); // dsll t0, t0, 7 + // nop // sll r0, r0, 0 + c->daddu(t0, t0, v1); // daddu t0, t0, v1 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lqc2(vf1, 0, t0); // lqc2 vf1, 0(t0) + // nop // sll r0, r0, 0 + c->lqc2(vf2, 16, t0); // lqc2 vf2, 16(t0) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 32, t0); // lqc2 vf3, 32(t0) + // nop // sll r0, r0, 0 + c->lqc2(vf4, 48, t0); // lqc2 vf4, 48(t0) + // nop // sll r0, r0, 0 + c->lqc2(vf9, 0, a2); // lqc2 vf9, 0(a2) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf9); // vmaddax.xyzw acc, vf1, vf9 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf9); // vmadday.xyzw acc, vf2, vf9 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyz, BC::z, vf9, vf3, vf9); // vmaddz.xyz vf9, vf3, vf9 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sqc2(vf9, 0, a2); // sqc2 vf9, 0(a2) + c->daddiu(a2, a2, 16); // daddiu a2, a2, 16 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a3) != 0; // bne a3, r0, L118 + // nop // sll r0, r0, 0 + if (bc) {goto block_1;} // branch non-likely + + +block_2: + // nop // sll r0, r0, 0 + c->lh(a0, 10, a0); // lh a0, 10(a0) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L121 + // nop // sll r0, r0, 0 + if (bc) {goto block_5;} // branch non-likely + + +block_3: + c->daddiu(a0, a0, -1); // daddiu a0, a0, -1 + c->lbu(t0, 0, a1); // lbu t0, 0(a1) + // nop // sll r0, r0, 0 + c->lbu(a3, 1, a1); // lbu a3, 1(a1) + c->dsll(t0, t0, 7); // dsll t0, t0, 7 + c->daddiu(a1, a1, 2); // daddiu a1, a1, 2 + c->dsll(a3, a3, 7); // dsll a3, a3, 7 + c->daddu(t0, t0, v1); // daddu t0, t0, v1 + c->daddu(a3, a3, v1); // daddu a3, a3, v1 + c->lqc2(vf1, 0, t0); // lqc2 vf1, 0(t0) + // nop // sll r0, r0, 0 + c->lqc2(vf2, 16, t0); // lqc2 vf2, 16(t0) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 32, t0); // lqc2 vf3, 32(t0) + // nop // sll r0, r0, 0 + c->lqc2(vf4, 48, t0); // lqc2 vf4, 48(t0) + // nop // sll r0, r0, 0 + c->lqc2(vf9, 0, a2); // lqc2 vf9, 0(a2) + // nop // sll r0, r0, 0 + c->lqc2(vf5, 0, a3); // lqc2 vf5, 0(a3) + // nop // sll r0, r0, 0 + c->lqc2(vf6, 16, a3); // lqc2 vf6, 16(a3) + // nop // sll r0, r0, 0 + c->lqc2(vf7, 32, a3); // lqc2 vf7, 32(a3) + // nop // sll r0, r0, 0 + c->lqc2(vf8, 48, a3); // lqc2 vf8, 48(a3) + c->vsub_bc(DEST::w, BC::w, vf10, vf0, vf9); // vsubw.w vf10, vf0, vf9 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf9); // vmaddax.xyzw acc, vf1, vf9 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf9); // vmadday.xyzw acc, vf2, vf9 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyz, BC::z, vf10, vf3, vf9); // vmaddz.xyz vf10, vf3, vf9 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf8, vf0); // vmulaw.xyzw acc, vf8, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf5, vf9); // vmaddax.xyzw acc, vf5, vf9 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf6, vf9); // vmadday.xyzw acc, vf6, vf9 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyz, BC::z, vf9, vf7, vf9); // vmaddz.xyz vf9, vf7, vf9 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyz, BC::w, vf10, vf9); // vmulaw.xyz acc, vf10, vf9 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyz, BC::w, vf9, vf9, vf10); // vmaddw.xyz vf9, vf9, vf10 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::w, BC::x, vf9, vf0, vf0); // vaddx.w vf9, vf0, vf0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sqc2(vf9, 0, a2); // sqc2 vf9, 0(a2) + c->daddiu(a2, a2, 16); // daddiu a2, a2, 16 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a0) != 0; // bne a0, r0, L120 + // nop // sll r0, r0, 0 + if (bc) {goto block_3;} // branch non-likely + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + +block_5: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + gLinkedFunctionTable.reg("shadow-xform-verts", execute, 128); +} + +} // namespace shadow_xform_verts +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_calc_dual_verts { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + // nop // sll r0, r0, 0 + c->lw(v1, 16, a1); // lw v1, 16(a1) + // nop // sll r0, r0, 0 + c->lw(a2, 0, a1); // lw a2, 0(a1) + c->daddiu(v1, v1, 15); // daddiu v1, v1, 15 + c->lqc2(vf1, 80, a1); // lqc2 vf1, 80(a1) + c->dsra(v1, v1, 4); // dsra v1, v1, 4 + c->lqc2(vf2, 96, a1); // lqc2 vf2, 96(a1) + c->dsll(a3, v1, 4); // dsll a3, v1, 4 + c->lh(a0, 8, a0); // lh a0, 8(a0) + c->mov64(v1, a3); // or v1, a3, r0 + c->sw(a3, 44, a1); // sw a3, 44(a1) + c->mov64(a2, a2); // or a2, a2, r0 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a0) == 0; // beq a0, r0, L116 + // nop // sll r0, r0, 0 + if (bc) {goto block_9;} // branch non-likely + + // nop // sll r0, r0, 0 + c->lq(a3, 0, a2); // lq a3, 0(a2) + // nop // sll r0, r0, 0 + c->lq(t0, 16, a2); // lq t0, 16(a2) + // nop // sll r0, r0, 0 + c->lq(t1, 32, a2); // lq t1, 32(a2) + // nop // sll r0, r0, 0 + c->lq(t2, 48, a2); // lq t2, 48(a2) + c->daddiu(a2, a2, 64); // daddiu a2, a2, 64 + c->mov128_vf_gpr(vf3, a3); // qmtc2.i vf3, a3 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf4, t0); // qmtc2.ni vf4, t0 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf5, t1); // qmtc2.ni vf5, t1 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf6, t2); // qmtc2.ni vf6, t2 + exec_28(c); // vcallms 28 + // nop // sll r0, r0, 0 + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->lq(a3, 0, a2); // lq a3, 0(a2) + bc = ((s64)c->sgpr64(a0)) <= 0; // blez a0, L114 + c->lq(t0, 16, a2); // lq t0, 16(a2) + if (bc) {goto block_4;} // branch non-likely + + // nop // sll r0, r0, 0 + c->lq(t1, 32, a2); // lq t1, 32(a2) + // nop // sll r0, r0, 0 + c->lq(t2, 48, a2); // lq t2, 48(a2) + c->daddiu(a2, a2, 64); // daddiu a2, a2, 64 + c->mov128_vf_gpr(vf3, a3); // qmtc2.i vf3, a3 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf4, t0); // qmtc2.ni vf4, t0 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf5, t1); // qmtc2.ni vf5, t1 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf6, t2); // qmtc2.ni vf6, t2 + +block_3: + exec_28(c); // vcallms 28 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a3, vf23); // qmfc2.i a3, vf23 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sq(a3, 0, v1); // sq a3, 0(v1) + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a3, vf24); // qmfc2.ni a3, vf24 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sq(a3, 16, v1); // sq a3, 16(v1) + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a3, vf25); // qmfc2.ni a3, vf25 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sq(a3, 32, v1); // sq a3, 32(v1) + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a3, vf26); // qmfc2.ni a3, vf26 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sq(a3, 48, v1); // sq a3, 48(v1) + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lq(a3, 0, a2); // lq a3, 0(a2) + // nop // sll r0, r0, 0 + c->lq(t0, 16, a2); // lq t0, 16(a2) + // nop // sll r0, r0, 0 + c->lq(t1, 32, a2); // lq t1, 32(a2) + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->lq(t2, 48, a2); // lq t2, 48(a2) + c->daddiu(a2, a2, 64); // daddiu a2, a2, 64 + c->daddiu(v1, v1, 64); // daddiu v1, v1, 64 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf3, a3); // qmtc2.ni vf3, a3 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf4, t0); // qmtc2.ni vf4, t0 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf5, t1); // qmtc2.ni vf5, t1 + bc = ((s64)c->sgpr64(a0)) > 0; // bgtz a0, L113 + c->mov128_vf_gpr(vf6, t2); // qmtc2.ni vf6, t2 + if (bc) {goto block_3;} // branch non-likely + + +block_4: + exec_68(c); // vcallms 68 + // nop // sll r0, r0, 0 + // nop // vnop + // nop // sll r0, r0, 0 + c->daddiu(a2, a0, 3); // daddiu a2, a0, 3 + c->mov128_gpr_vf(a3, vf23); // qmfc2.i a3, vf23 + c->daddiu(t0, a0, 2); // daddiu t0, a0, 2 + c->mov128_gpr_vf(t1, vf24); // qmfc2.i t1, vf24 + c->daddiu(t2, a0, 1); // daddiu t2, a0, 1 + c->mov128_gpr_vf(t3, vf25); // qmfc2.i t3, vf25 + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + c->mov128_gpr_vf(t4, vf26); // qmfc2.i t4, vf26 + bc = c->sgpr64(a2) == 0; // beq a2, r0, L115 + c->sq(a3, 0, v1); // sq a3, 0(v1) + if (bc) {goto block_8;} // branch non-likely + + bc = c->sgpr64(t0) == 0; // beq t0, r0, L115 + c->sq(t1, 16, v1); // sq t1, 16(v1) + if (bc) {goto block_8;} // branch non-likely + + bc = c->sgpr64(t2) == 0; // beq t2, r0, L115 + c->sq(t3, 32, v1); // sq t3, 32(v1) + if (bc) {goto block_8;} // branch non-likely + + // nop // sll r0, r0, 0 + c->sq(t4, 48, v1); // sq t4, 48(v1) + +block_8: + c->dsll(a0, a0, 4); // dsll a0, a0, 4 + // nop // sll r0, r0, 0 + c->daddu(v1, v1, a0); // daddu v1, v1, a0 + // nop // sll r0, r0, 0 + +block_9: + c->sw(v1, 16, a1); // sw v1, 16(a1) + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + gLinkedFunctionTable.reg("shadow-calc-dual-verts", execute, 128); +} + +} // namespace shadow_calc_dual_verts +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_scissor_edges { +struct Cache { + void* fake_scratchpad_data; // *fake-scratchpad-data* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + get_fake_spad_addr2(v1, cache.fake_scratchpad_data, 0, c);// lui v1, 28672 + c->lw(a3, 44, a1); // lw a3, 44(a1) + // nop // sll r0, r0, 0 + c->lw(a2, 0, a1); // lw a2, 0(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 128, a1); // lqc2 vf3, 128(a1) + // nop // sll r0, r0, 0 + c->lh(a0, 8, a0); // lh a0, 8(a0) + c->mov64(a1, a3); // or a1, a3, r0 + c->lw(a3, 44, v1); // lw a3, 44(v1) + c->mov64(a2, a2); // or a2, a2, r0 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a0) == 0; // beq a0, r0, L111 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + +block_1: + c->lqc2(vf1, 0, a2); // lqc2 vf1, 0(a2) + c->lqc2(vf2, 0, a1); // lqc2 vf2, 0(a1) + c->vadd_bc(DEST::z, BC::w, vf7, vf1, vf3); // vaddw.z vf7, vf1, vf3 + c->vadd_bc(DEST::z, BC::w, vf8, vf2, vf3); // vaddw.z vf8, vf2, vf3 + c->vsub_bc(DEST::z, BC::z, vf6, vf1, vf2); // vsubz.z vf6, vf1, vf2 + c->vadd_bc(DEST::z, BC::w, vf5, vf1, vf3); // vaddw.z vf5, vf1, vf3 + c->vadd_bc(DEST::y, BC::z, vf7, vf0, vf7); // vaddz.y vf7, vf0, vf7 + c->vadd_bc(DEST::y, BC::z, vf8, vf0, vf8); // vaddz.y vf8, vf0, vf8 + c->vsub(DEST::xyz, vf4, vf2, vf1); // vsub.xyz vf4, vf2, vf1 + c->mov128_gpr_vf(t0, vf7); // qmfc2.i t0, vf7 + c->mov128_gpr_vf(t1, vf8); // qmfc2.i t1, vf8 + bc = ((s64)c->sgpr64(t0)) < 0; // bltz t0, L109 + // nop // sll r0, r0, 0 + if (bc) {goto block_4;} // branch non-likely + + bc = ((s64)c->sgpr64(t1)) > 0; // bgtz t1, L110 + // nop // sll r0, r0, 0 + if (bc) {goto block_5;} // branch non-likely + + //beq r0, r0, L110 // beq r0, r0, L110 + c->daddiu(a3, a3, 1); // daddiu a3, a3, 1 + goto block_5; // branch always + + +block_4: + bc = ((s64)c->sgpr64(t1)) < 0; // bltz t1, L110 + c->daddiu(a3, a3, 1); // daddiu a3, a3, 1 + if (bc) {goto block_5;} // branch non-likely + + +block_5: + c->daddiu(a2, a2, 16); // daddiu a2, a2, 16 + c->daddiu(a1, a1, 16); // daddiu a1, a1, 16 + c->daddiu(a0, a0, -1); // daddiu a0, a0, -1 + bc = c->sgpr64(a0) != 0; // bne a0, r0, L108 + // nop // sll r0, r0, 0 + if (bc) {goto block_1;} // branch non-likely + + c->sw(a3, 44, v1); // sw a3, 44(v1) + +block_7: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + gLinkedFunctionTable.reg("shadow-scissor-edges", execute, 128); +} + +} // namespace shadow_scissor_edges +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_scissor_top { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + // nop // sll r0, r0, 0 + c->lw(a2, 44, a1); // lw a2, 44(a1) + // nop // sll r0, r0, 0 + c->lw(v1, 0, a1); // lw v1, 0(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 112, a1); // lqc2 vf3, 112(a1) + // nop // sll r0, r0, 0 + c->lh(a0, 8, a0); // lh a0, 8(a0) + c->mov64(a1, a2); // or a1, a2, r0 + // nop // sll r0, r0, 0 + c->mov64(v1, v1); // or v1, v1, r0 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a0) == 0; // beq a0, r0, L106 + // nop // sll r0, r0, 0 + if (bc) {goto block_4;} // branch non-likely + + +block_1: + c->lqc2(vf1, 0, v1); // lqc2 vf1, 0(v1) + c->lqc2(vf2, 0, a1); // lqc2 vf2, 0(a1) + c->vsub(DEST::xyzw, vf4, vf2, vf1); // vsub.xyzw vf4, vf2, vf1 + c->vmul(DEST::xyzw, vf5, vf1, vf3); // vmul.xyzw vf5, vf1, vf3 + c->vmul(DEST::xyz, vf6, vf4, vf3); // vmul.xyz vf6, vf4, vf3 + c->vadd_bc(DEST::y, BC::x, vf5, vf5, vf5); // vaddx.y vf5, vf5, vf5 + c->vadd_bc(DEST::x, BC::y, vf6, vf6, vf6); // vaddy.x vf6, vf6, vf6 + c->vadd_bc(DEST::y, BC::z, vf5, vf5, vf5); // vaddz.y vf5, vf5, vf5 + c->vadd_bc(DEST::x, BC::z, vf6, vf6, vf6); // vaddz.x vf6, vf6, vf6 + c->vadd_bc(DEST::y, BC::w, vf5, vf5, vf5); // vaddw.y vf5, vf5, vf5 + c->mov128_gpr_vf(a2, vf5); // qmfc2.i a2, vf5 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(a2)) < 0; // bltz a2, L105 + // nop // sll r0, r0, 0 + if (bc) {goto block_3;} // branch non-likely + + c->vdiv(vf5, BC::y, vf6, BC::x); // vdiv Q, vf5.y, vf6.x + c->vwaitq(); // vwaitq + c->vmulq(DEST::xyzw, vf4, vf4); // vmulq.xyzw vf4, vf4, Q + c->vsub(DEST::xyzw, vf1, vf1, vf4); // vsub.xyzw vf1, vf1, vf4 + c->sqc2(vf1, 0, v1); // sqc2 vf1, 0(v1) + +block_3: + c->daddiu(v1, v1, 16); // daddiu v1, v1, 16 + c->daddiu(a1, a1, 16); // daddiu a1, a1, 16 + c->daddiu(a0, a0, -1); // daddiu a0, a0, -1 + bc = c->sgpr64(a0) != 0; // bne a0, r0, L104 + // nop // sll r0, r0, 0 + if (bc) {goto block_1;} // branch non-likely + + +block_4: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + gLinkedFunctionTable.reg("shadow-scissor-top", execute, 128); +} + +} // namespace shadow_scissor_top +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_init_vars { +struct Cache { + void* math_camera; // *math-camera* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->load_symbol2(v1, cache.math_camera); // lw v1, *math-camera*(s7) + c->mov64(v1, v1); // or v1, v1, r0 + c->lqc2(vf7, 364, v1); // lqc2 vf7, 364(v1) + c->lqc2(vf8, 380, v1); // lqc2 vf8, 380(v1) + c->lqc2(vf9, 396, v1); // lqc2 vf9, 396(v1) + c->lqc2(vf10, 412, v1); // lqc2 vf10, 412(v1) + c->lqc2(vf1, 144, a1); // lqc2 vf1, 144(a1) + c->lqc2(vf11, 96, a1); // lqc2 vf11, 96(a1) + c->lqc2(vf12, 112, a1); // lqc2 vf12, 112(a1) + c->lqc2(vf2, 80, a1); // lqc2 vf2, 80(a1) + c->vmula_bc(DEST::xyzw, BC::x, vf7, vf1); // vmulax.xyzw acc, vf7, vf1 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf1); // vmadday.xyzw acc, vf8, vf1 + c->vmadd_bc(DEST::xyzw, BC::z, vf1, vf9, vf1); // vmaddz.xyzw vf1, vf9, vf1 + c->vmula_bc(DEST::xyzw, BC::x, vf7, vf11); // vmulax.xyzw acc, vf7, vf11 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf11); // vmadday.xyzw acc, vf8, vf11 + c->vmadd_bc(DEST::xyz, BC::z, vf11, vf9, vf11); // vmaddz.xyz vf11, vf9, vf11 + c->vmula_bc(DEST::xyzw, BC::x, vf7, vf12); // vmulax.xyzw acc, vf7, vf12 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf12); // vmadday.xyzw acc, vf8, vf12 + c->vmadd_bc(DEST::xyz, BC::z, vf12, vf9, vf12); // vmaddz.xyz vf12, vf9, vf12 + c->vmul(DEST::xyzw, vf13, vf10, vf11); // vmul.xyzw vf13, vf10, vf11 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf7, vf2); // vmaddax.xyzw acc, vf7, vf2 + c->vmul(DEST::xyzw, vf14, vf10, vf12); // vmul.xyzw vf14, vf10, vf12 + c->vsub_bc(DEST::w, BC::x, vf13, vf13, vf13); // vsubx.w vf13, vf13, vf13 + c->vsub_bc(DEST::w, BC::x, vf14, vf14, vf14); // vsubx.w vf14, vf14, vf14 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf2); // vmadday.xyzw acc, vf8, vf2 + c->vmadd_bc(DEST::xyzw, BC::z, vf2, vf9, vf2); // vmaddz.xyzw vf2, vf9, vf2 + c->vsub_bc(DEST::w, BC::y, vf13, vf13, vf13); // vsuby.w vf13, vf13, vf13 + c->vsub_bc(DEST::w, BC::y, vf14, vf14, vf14); // vsuby.w vf14, vf14, vf14 + c->vsub_bc(DEST::w, BC::z, vf11, vf13, vf13); // vsubz.w vf11, vf13, vf13 + c->vsub_bc(DEST::w, BC::z, vf12, vf14, vf14); // vsubz.w vf12, vf14, vf14 + c->sqc2(vf2, 80, a1); // sqc2 vf2, 80(a1) + c->sqc2(vf1, 144, a1); // sqc2 vf1, 144(a1) + c->sqc2(vf11, 96, a1); // sqc2 vf11, 96(a1) + c->sqc2(vf12, 112, a1); // sqc2 vf12, 112(a1) + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.math_camera = intern_from_c("*math-camera*").c(); + gLinkedFunctionTable.reg("shadow-init-vars", execute, 128); +} + +} // namespace shadow_init_vars +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_find_facing_single_tris { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->daddiu(sp, sp, -64); // daddiu sp, sp, -64 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s4, 16, sp); // sq s4, 16(sp) + c->sq(s5, 32, sp); // sq s5, 32(sp) + c->sq(gp, 48, sp); // sq gp, 48(sp) + c->lw(v1, 16, a1); // lw v1, 16(a1) + c->lh(t0, 12, a0); // lh t0, 12(a0) + c->mov64(a2, v1); // or a2, v1, r0 + c->lw(a3, 28, a0); // lw a3, 28(a0) + c->daddu(a0, a3, a0); // daddu a0, a3, a0 + c->mov64(a3, a0); // or a3, a0, r0 + c->lqc2(vf2, 80, a1); // lqc2 vf2, 80(a1) + c->lqc2(vf1, 144, a1); // lqc2 vf1, 144(a1) + c->lqc2(vf11, 96, a1); // lqc2 vf11, 96(a1) + c->lw(a0, 0, a1); // lw a0, 0(a1) + c->pextlw(a0, a0, a0); // pextlw a0, a0, a0 + c->pextlw(a0, a0, a0); // pextlw a0, a0, a0 + c->daddiu(t0, t0, -4); // daddiu t0, t0, -4 + c->addiu(t1, r0, 1); // addiu t1, r0, 1 + bc = ((s64)c->sgpr64(t0)) < 0; // bltz t0, L98 + c->daddiu(t0, t0, 4); // daddiu t0, t0, 4 + if (bc) {goto block_11;} // branch non-likely + + // nop // sll r0, r0, 0 + c->lq(t3, 0, a3); // lq t3, 0(a3) + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->pextub(t2, r0, t3); // pextub t2, r0, t3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlb(t3, r0, t3); // pextlb t3, r0, t3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->psllh(t2, t2, 4); // psllh t2, t2, 4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->psllh(t4, t3, 4); // psllh t4, t3, 4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextuh(t3, r0, t4); // pextuh t3, r0, t4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlh(t4, r0, t4); // pextlh t4, r0, t4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextuh(t7, r0, t2); // pextuh t7, r0, t2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlh(t5, r0, t2); // pextlh t5, r0, t2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->paddw(t6, t4, a0); // paddw t6, t4, a0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcpyud(t4, t6, r0); // pcpyud t4, t6, r0 + c->lq(t2, 0, t6); // lq t2, 0(t6) + c->paddw(t8, t3, a0); // paddw t8, t3, a0 + c->lq(t3, 0, t4); // lq t3, 0(t4) + c->pcpyud(t9, t8, r0); // pcpyud t9, t8, r0 + c->lq(t4, 0, t8); // lq t4, 0(t8) + c->dsra32(t6, t6, 0); // dsra32 t6, t6, 0 + c->dsra32(t8, t8, 0); // dsra32 t8, t8, 0 + c->paddw(s5, t5, a0); // paddw s5, t5, a0 + c->lq(t5, 0, t9); // lq t5, 0(t9) + c->pcpyud(t9, s5, r0); // pcpyud t9, s5, r0 + c->lq(t6, 0, t6); // lq t6, 0(t6) + c->paddw(gp, t7, a0); // paddw gp, t7, a0 + c->lq(t7, 0, t8); // lq t7, 0(t8) + c->pcpyud(ra, gp, r0); // pcpyud ra, gp, r0 + c->lq(t8, 0, s5); // lq t8, 0(s5) + c->dsra32(s5, s5, 0); // dsra32 s5, s5, 0 + c->dsra32(s4, gp, 0); // dsra32 s4, gp, 0 + // nop // sll r0, r0, 0 + c->lq(s5, 0, s5); // lq s5, 0(s5) + // nop // sll r0, r0, 0 + c->lq(t9, 0, t9); // lq t9, 0(t9) + // nop // sll r0, r0, 0 + c->lq(gp, 0, gp); // lq gp, 0(gp) + // nop // sll r0, r0, 0 + c->lq(s4, 0, s4); // lq s4, 0(s4) + // nop // sll r0, r0, 0 + c->lq(ra, 0, ra); // lq ra, 0(ra) + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf2, t2); // qmtc2.ni vf2, t2 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf3, t6); // qmtc2.ni vf3, t6 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf4, t3); // qmtc2.ni vf4, t3 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf7, t4); // qmtc2.ni vf7, t4 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf8, t7); // qmtc2.ni vf8, t7 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf9, t5); // qmtc2.ni vf9, t5 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf12, t8); // qmtc2.ni vf12, t8 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf13, s5); // qmtc2.ni vf13, s5 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf14, t9); // qmtc2.ni vf14, t9 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf17, gp); // qmtc2.ni vf17, gp + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf18, s4); // qmtc2.ni vf18, s4 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf19, ra); // qmtc2.ni vf19, ra + +block_2: + // nop // sll r0, r0, 0 + c->lq(t3, 16, a3); // lq t3, 16(a3) + c->daddiu(t0, t0, -4); // daddiu t0, t0, -4 + exec_0(c); // vcallms 0 + c->pextub(t2, r0, t3); // pextub t2, r0, t3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlb(t3, r0, t3); // pextlb t3, r0, t3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->psllh(t2, t2, 4); // psllh t2, t2, 4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->psllh(t4, t3, 4); // psllh t4, t3, 4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextuh(t3, r0, t4); // pextuh t3, r0, t4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlh(t4, r0, t4); // pextlh t4, r0, t4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextuh(t7, r0, t2); // pextuh t7, r0, t2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlh(t5, r0, t2); // pextlh t5, r0, t2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->paddw(t6, t4, a0); // paddw t6, t4, a0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcpyud(t4, t6, r0); // pcpyud t4, t6, r0 + c->lq(t2, 0, t6); // lq t2, 0(t6) + c->paddw(t8, t3, a0); // paddw t8, t3, a0 + c->lq(t3, 0, t4); // lq t3, 0(t4) + c->pcpyud(t9, t8, r0); // pcpyud t9, t8, r0 + c->lq(t4, 0, t8); // lq t4, 0(t8) + c->dsra32(t6, t6, 0); // dsra32 t6, t6, 0 + c->dsra32(t8, t8, 0); // dsra32 t8, t8, 0 + c->paddw(s5, t5, a0); // paddw s5, t5, a0 + c->lq(t5, 0, t9); // lq t5, 0(t9) + c->pcpyud(t9, s5, r0); // pcpyud t9, s5, r0 + c->lq(t6, 0, t6); // lq t6, 0(t6) + c->paddw(gp, t7, a0); // paddw gp, t7, a0 + c->lq(t7, 0, t8); // lq t7, 0(t8) + c->pcpyud(ra, gp, r0); // pcpyud ra, gp, r0 + c->lq(t8, 0, s5); // lq t8, 0(s5) + c->dsra32(s5, s5, 0); // dsra32 s5, s5, 0 + c->dsra32(s4, gp, 0); // dsra32 s4, gp, 0 + // nop // sll r0, r0, 0 + c->lq(s5, 0, s5); // lq s5, 0(s5) + // nop // sll r0, r0, 0 + c->lq(t9, 0, t9); // lq t9, 0(t9) + // nop // sll r0, r0, 0 + c->lq(gp, 0, gp); // lq gp, 0(gp) + // nop // sll r0, r0, 0 + c->lq(s4, 0, s4); // lq s4, 0(s4) + // nop // sll r0, r0, 0 + c->lq(ra, 0, ra); // lq ra, 0(ra) + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf2, t2); // qmtc2.ni vf2, t2 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf3, t6); // qmtc2.ni vf3, t6 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf4, t3); // qmtc2.ni vf4, t3 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf7, t4); // qmtc2.ni vf7, t4 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf8, t7); // qmtc2.ni vf8, t7 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf9, t5); // qmtc2.ni vf9, t5 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf12, t8); // qmtc2.ni vf12, t8 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf13, s5); // qmtc2.ni vf13, s5 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf14, t9); // qmtc2.ni vf14, t9 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf17, gp); // qmtc2.ni vf17, gp + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf18, s4); // qmtc2.ni vf18, s4 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf19, ra); // qmtc2.ni vf19, ra + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t3, vf22); // qmfc2.ni t3, vf22 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t4, vf23); // qmfc2.ni t4, vf23 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t2, vf24); // qmfc2.ni t2, vf24 + bc = ((s64)c->sgpr64(t3)) >= 0; // bgez t3, L94 + c->mov128_gpr_vf(t3, vf25); // qmfc2.ni t3, vf25 + if (bc) {goto block_4;} // branch non-likely + + c->sb(t1, 3, a3); // sb t1, 3(a3) + // nop // sll r0, r0, 0 + c->sw(a3, 0, a2); // sw a3, 0(a2) + c->daddiu(a2, a2, 4); // daddiu a2, a2, 4 + +block_4: + bc = ((s64)c->sgpr64(t4)) >= 0; // bgez t4, L95 + c->daddiu(a3, a3, 4); // daddiu a3, a3, 4 + if (bc) {goto block_6;} // branch non-likely + + c->sb(t1, 3, a3); // sb t1, 3(a3) + // nop // sll r0, r0, 0 + c->sw(a3, 0, a2); // sw a3, 0(a2) + c->daddiu(a2, a2, 4); // daddiu a2, a2, 4 + +block_6: + bc = ((s64)c->sgpr64(t2)) >= 0; // bgez t2, L96 + c->daddiu(a3, a3, 4); // daddiu a3, a3, 4 + if (bc) {goto block_8;} // branch non-likely + + c->sb(t1, 3, a3); // sb t1, 3(a3) + // nop // sll r0, r0, 0 + c->sw(a3, 0, a2); // sw a3, 0(a2) + c->daddiu(a2, a2, 4); // daddiu a2, a2, 4 + +block_8: + bc = ((s64)c->sgpr64(t3)) >= 0; // bgez t3, L97 + c->daddiu(a3, a3, 4); // daddiu a3, a3, 4 + if (bc) {goto block_10;} // branch non-likely + + c->sb(t1, 3, a3); // sb t1, 3(a3) + // nop // sll r0, r0, 0 + c->sw(a3, 0, a2); // sw a3, 0(a2) + c->daddiu(a2, a2, 4); // daddiu a2, a2, 4 + +block_10: + bc = ((s64)c->sgpr64(t0)) > 0; // bgtz t0, L93 + c->daddiu(a3, a3, 4); // daddiu a3, a3, 4 + if (bc) {goto block_2;} // branch non-likely + + +block_11: + bc = ((s64)c->sgpr64(t0)) <= 0; // blez t0, L101 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + +block_12: + c->lbu(t2, 0, a3); // lbu t2, 0(a3) + c->lbu(t3, 1, a3); // lbu t3, 1(a3) + c->lbu(t1, 2, a3); // lbu t1, 2(a3) + c->dsll(t2, t2, 4); // dsll t2, t2, 4 + c->dsll(t3, t3, 4); // dsll t3, t3, 4 + c->dsll(t1, t1, 4); // dsll t1, t1, 4 + c->daddu(t2, t2, a0); // daddu t2, t2, a0 + c->daddu(t3, t3, a0); // daddu t3, t3, a0 + c->daddu(t1, t1, a0); // daddu t1, t1, a0 + c->lqc2(vf2, 0, t2); // lqc2 vf2, 0(t2) + c->lqc2(vf3, 0, t3); // lqc2 vf3, 0(t3) + c->lqc2(vf4, 0, t1); // lqc2 vf4, 0(t1) + c->vsub(DEST::xyzw, vf5, vf3, vf2); // vsub.xyzw vf5, vf3, vf2 + c->vsub(DEST::xyzw, vf6, vf4, vf2); // vsub.xyzw vf6, vf4, vf2 + c->vopmula(vf5, vf6); // vopmula.xyz acc, vf5, vf6 + c->vopmsub(vf5, vf6, vf5); // vopmsub.xyz vf5, vf6, vf5 + c->vmul(DEST::xyz, vf5, vf5, vf1); // vmul.xyz vf5, vf5, vf1 + c->vadd_bc(DEST::y, BC::x, vf5, vf5, vf5); // vaddx.y vf5, vf5, vf5 + c->vadd_bc(DEST::y, BC::z, vf5, vf5, vf5); // vaddz.y vf5, vf5, vf5 + c->mov128_gpr_vf(t1, vf5); // qmfc2.i t1, vf5 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(t1)) >= 0; // bgez t1, L100 + c->addiu(t1, r0, 1); // addiu t1, r0, 1 + if (bc) {goto block_14;} // branch non-likely + + c->sw(a3, 0, a2); // sw a3, 0(a2) + c->daddiu(a2, a2, 4); // daddiu a2, a2, 4 + c->sb(t1, 3, a3); // sb t1, 3(a3) + +block_14: + c->daddiu(t0, t0, -1); // daddiu t0, t0, -1 + bc = c->sgpr64(t0) != 0; // bne t0, r0, L99 + c->daddiu(a3, a3, 4); // daddiu a3, a3, 4 + if (bc) {goto block_12;} // branch non-likely + + +block_15: + c->dsubu(a0, a2, v1); // dsubu a0, a2, v1 + c->dsra(a0, a0, 2); // dsra a0, a0, 2 + c->sw(a0, 20, a1); // sw a0, 20(a1) + c->sw(v1, 32, a1); // sw v1, 32(a1) + c->sw(a2, 16, a1); // sw a2, 16(a1) + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 48, sp); // lq gp, 48(sp) + c->lq(s5, 32, sp); // lq s5, 32(sp) + c->lq(s4, 16, sp); // lq s4, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 64); // daddiu sp, sp, 64 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + gLinkedFunctionTable.reg("shadow-find-facing-single-tris", execute, 128); +} + +} // namespace shadow_find_facing_single_tris +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_find_single_edges { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->lw(a2, 16, a1); // lw a2, 16(a1) + c->lh(a3, 14, a0); // lh a3, 14(a0) + c->mov64(v1, a2); // or v1, a2, r0 + c->lw(t0, 32, a0); // lw t0, 32(a0) + bc = c->sgpr64(a3) == 0; // beq a3, r0, L91 + c->lw(t1, 28, a0); // lw t1, 28(a0) + if (bc) {goto block_8;} // branch non-likely + + c->daddu(t0, t0, a0); // daddu t0, t0, a0 + c->sw(a2, 36, a1); // sw a2, 36(a1) + c->daddu(a0, t1, a0); // daddu a0, t1, a0 + c->sw(t0, 4, a1); // sw t0, 4(a1) + c->mov64(t1, t0); // or t1, t0, r0 + c->addiu(t2, r0, 255); // addiu t2, r0, 255 + // nop // sll r0, r0, 0 + +block_2: + c->daddiu(a3, a3, -1); // daddiu a3, a3, -1 + c->lbu(t4, 3, t1); // lbu t4, 3(t1) + // nop // sll r0, r0, 0 + c->lbu(t5, 2, t1); // lbu t5, 2(t1) + bc = c->sgpr64(t4) == c->sgpr64(t2); // beq t4, t2, L88 + c->gprs[t3].du64[0] = 0; // or t3, r0, r0 + if (bc) {goto block_5;} // branch non-likely + + c->dsll(t3, t5, 2); // dsll t3, t5, 2 + c->dsll(t4, t4, 2); // dsll t4, t4, 2 + c->daddu(t3, t3, a0); // daddu t3, t3, a0 + c->daddu(t5, t4, a0); // daddu t5, t4, a0 + // nop // sll r0, r0, 0 + c->lbu(t4, 3, t3); // lbu t4, 3(t3) + // nop // sll r0, r0, 0 + c->lbu(t5, 3, t5); // lbu t5, 3(t5) + c->sltiu(t3, t4, 1); // sltiu t3, t4, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t4) == c->sgpr64(t5); // beq t4, t5, L90 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + //beq r0, r0, L89 // beq r0, r0, L89 + // nop // sll r0, r0, 0 + goto block_6; // branch always + + +block_5: + c->dsll(t4, t5, 2); // dsll t4, t5, 2 + // nop // sll r0, r0, 0 + c->daddu(t4, t4, a0); // daddu t4, t4, a0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lbu(t4, 3, t4); // lbu t4, 3(t4) + bc = c->sgpr64(t4) == 0; // beq t4, r0, L90 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + +block_6: + c->dsubu(t4, t1, t0); // dsubu t4, t1, t0 + c->sh(t3, 2, v1); // sh t3, 2(v1) + c->sh(t4, 0, v1); // sh t4, 0(v1) + c->daddiu(v1, v1, 4); // daddiu v1, v1, 4 + +block_7: + bc = c->sgpr64(a3) != 0; // bne a3, r0, L87 + c->daddiu(t1, t1, 4); // daddiu t1, t1, 4 + if (bc) {goto block_2;} // branch non-likely + + +block_8: + c->dsubu(a0, v1, a2); // dsubu a0, v1, a2 + c->dsra(a0, a0, 2); // dsra a0, a0, 2 + c->sw(a0, 24, a1); // sw a0, 24(a1) + c->sw(v1, 16, a1); // sw v1, 16(a1) + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + gLinkedFunctionTable.reg("shadow-find-single-edges", execute, 128); +} + +} // namespace shadow_find_single_edges +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_find_facing_double_tris { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->daddiu(sp, sp, -16); // daddiu sp, sp, -16 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->lh(a2, 16, a0); // lh a2, 16(a0) + c->lw(v1, 36, a0); // lw v1, 36(a0) + c->daddu(a0, v1, a0); // daddu a0, v1, a0 + c->mov64(v1, a0); // or v1, a0, r0 + c->sw(a0, 12, a1); // sw a0, 12(a1) + c->lqc2(vf1, 144, a1); // lqc2 vf1, 144(a1) + c->lqc2(vf2, 80, a1); // lqc2 vf2, 80(a1) + c->lqc2(vf11, 96, a1); // lqc2 vf11, 96(a1) + c->lw(a0, 0, a1); // lw a0, 0(a1) + c->pextlw(a0, a0, a0); // pextlw a0, a0, a0 + c->pextlw(a0, a0, a0); // pextlw a0, a0, a0 + c->daddiu(a1, a2, -4); // daddiu a1, a2, -4 + c->addiu(a2, r0, 1); // addiu a2, r0, 1 + bc = ((s64)c->sgpr64(a1)) < 0; // bltz a1, L82 + c->daddiu(a1, a1, 4); // daddiu a1, a1, 4 + if (bc) {goto block_11;} // branch non-likely + + // nop // sll r0, r0, 0 + c->lq(t0, 0, v1); // lq t0, 0(v1) + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->pextub(a3, r0, t0); // pextub a3, r0, t0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlb(t0, r0, t0); // pextlb t0, r0, t0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->psllh(a3, a3, 4); // psllh a3, a3, 4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->psllh(t1, t0, 4); // psllh t1, t0, 4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextuh(t0, r0, t1); // pextuh t0, r0, t1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlh(t1, r0, t1); // pextlh t1, r0, t1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextuh(t4, r0, a3); // pextuh t4, r0, a3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlh(t2, r0, a3); // pextlh t2, r0, a3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->paddw(t3, t1, a0); // paddw t3, t1, a0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcpyud(t1, t3, r0); // pcpyud t1, t3, r0 + c->lq(a3, 0, t3); // lq a3, 0(t3) + c->paddw(t5, t0, a0); // paddw t5, t0, a0 + c->lq(t0, 0, t1); // lq t0, 0(t1) + c->pcpyud(t6, t5, r0); // pcpyud t6, t5, r0 + c->lq(t1, 0, t5); // lq t1, 0(t5) + c->dsra32(t3, t3, 0); // dsra32 t3, t3, 0 + c->dsra32(t5, t5, 0); // dsra32 t5, t5, 0 + c->paddw(t9, t2, a0); // paddw t9, t2, a0 + c->lq(t2, 0, t6); // lq t2, 0(t6) + c->pcpyud(t6, t9, r0); // pcpyud t6, t9, r0 + c->lq(t3, 0, t3); // lq t3, 0(t3) + c->paddw(t8, t4, a0); // paddw t8, t4, a0 + c->lq(t4, 0, t5); // lq t4, 0(t5) + c->pcpyud(t7, t8, r0); // pcpyud t7, t8, r0 + c->lq(t5, 0, t9); // lq t5, 0(t9) + c->dsra32(t9, t9, 0); // dsra32 t9, t9, 0 + c->dsra32(ra, t8, 0); // dsra32 ra, t8, 0 + // nop // sll r0, r0, 0 + c->lq(t9, 0, t9); // lq t9, 0(t9) + // nop // sll r0, r0, 0 + c->lq(t6, 0, t6); // lq t6, 0(t6) + // nop // sll r0, r0, 0 + c->lq(t8, 0, t8); // lq t8, 0(t8) + // nop // sll r0, r0, 0 + c->lq(ra, 0, ra); // lq ra, 0(ra) + // nop // sll r0, r0, 0 + c->lq(t7, 0, t7); // lq t7, 0(t7) + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf2, a3); // qmtc2.ni vf2, a3 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf3, t3); // qmtc2.ni vf3, t3 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf4, t0); // qmtc2.ni vf4, t0 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf7, t1); // qmtc2.ni vf7, t1 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf8, t4); // qmtc2.ni vf8, t4 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf9, t2); // qmtc2.ni vf9, t2 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf12, t5); // qmtc2.ni vf12, t5 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf13, t9); // qmtc2.ni vf13, t9 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf14, t6); // qmtc2.ni vf14, t6 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf17, t8); // qmtc2.ni vf17, t8 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf18, ra); // qmtc2.ni vf18, ra + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf19, t7); // qmtc2.ni vf19, t7 + +block_2: + // nop // sll r0, r0, 0 + c->lq(t0, 16, v1); // lq t0, 16(v1) + c->daddiu(a1, a1, -4); // daddiu a1, a1, -4 + exec_0(c); // vcallms 0 + c->pextub(a3, r0, t0); // pextub a3, r0, t0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlb(t0, r0, t0); // pextlb t0, r0, t0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->psllh(a3, a3, 4); // psllh a3, a3, 4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->psllh(t1, t0, 4); // psllh t1, t0, 4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextuh(t0, r0, t1); // pextuh t0, r0, t1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlh(t1, r0, t1); // pextlh t1, r0, t1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextuh(t4, r0, a3); // pextuh t4, r0, a3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlh(t2, r0, a3); // pextlh t2, r0, a3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->paddw(t3, t1, a0); // paddw t3, t1, a0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcpyud(t1, t3, r0); // pcpyud t1, t3, r0 + c->lq(a3, 0, t3); // lq a3, 0(t3) + c->paddw(t5, t0, a0); // paddw t5, t0, a0 + c->lq(t0, 0, t1); // lq t0, 0(t1) + c->pcpyud(t6, t5, r0); // pcpyud t6, t5, r0 + c->lq(t1, 0, t5); // lq t1, 0(t5) + c->dsra32(t3, t3, 0); // dsra32 t3, t3, 0 + c->dsra32(t5, t5, 0); // dsra32 t5, t5, 0 + c->paddw(t9, t2, a0); // paddw t9, t2, a0 + c->lq(t2, 0, t6); // lq t2, 0(t6) + c->pcpyud(t6, t9, r0); // pcpyud t6, t9, r0 + c->lq(t3, 0, t3); // lq t3, 0(t3) + c->paddw(t8, t4, a0); // paddw t8, t4, a0 + c->lq(t4, 0, t5); // lq t4, 0(t5) + c->pcpyud(t7, t8, r0); // pcpyud t7, t8, r0 + c->lq(t5, 0, t9); // lq t5, 0(t9) + c->dsra32(t9, t9, 0); // dsra32 t9, t9, 0 + c->dsra32(ra, t8, 0); // dsra32 ra, t8, 0 + // nop // sll r0, r0, 0 + c->lq(t9, 0, t9); // lq t9, 0(t9) + // nop // sll r0, r0, 0 + c->lq(t6, 0, t6); // lq t6, 0(t6) + // nop // sll r0, r0, 0 + c->lq(t8, 0, t8); // lq t8, 0(t8) + // nop // sll r0, r0, 0 + c->lq(ra, 0, ra); // lq ra, 0(ra) + // nop // sll r0, r0, 0 + c->lq(t7, 0, t7); // lq t7, 0(t7) + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf2, a3); // qmtc2.ni vf2, a3 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf3, t3); // qmtc2.ni vf3, t3 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf4, t0); // qmtc2.ni vf4, t0 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf7, t1); // qmtc2.ni vf7, t1 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf8, t4); // qmtc2.ni vf8, t4 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf9, t2); // qmtc2.ni vf9, t2 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf12, t5); // qmtc2.ni vf12, t5 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf13, t9); // qmtc2.ni vf13, t9 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf14, t6); // qmtc2.ni vf14, t6 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf17, t8); // qmtc2.ni vf17, t8 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf18, ra); // qmtc2.ni vf18, ra + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf19, t7); // qmtc2.ni vf19, t7 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t0, vf22); // qmfc2.ni t0, vf22 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t1, vf23); // qmfc2.ni t1, vf23 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a3, vf24); // qmfc2.ni a3, vf24 + bc = ((s64)c->sgpr64(t0)) >= 0; // bgez t0, L78 + c->mov128_gpr_vf(t0, vf25); // qmfc2.ni t0, vf25 + if (bc) {goto block_4;} // branch non-likely + + c->sb(a2, 3, v1); // sb a2, 3(v1) + // nop // sll r0, r0, 0 + +block_4: + bc = ((s64)c->sgpr64(t1)) >= 0; // bgez t1, L79 + c->daddiu(v1, v1, 4); // daddiu v1, v1, 4 + if (bc) {goto block_6;} // branch non-likely + + c->sb(a2, 3, v1); // sb a2, 3(v1) + // nop // sll r0, r0, 0 + +block_6: + bc = ((s64)c->sgpr64(a3)) >= 0; // bgez a3, L80 + c->daddiu(v1, v1, 4); // daddiu v1, v1, 4 + if (bc) {goto block_8;} // branch non-likely + + c->sb(a2, 3, v1); // sb a2, 3(v1) + // nop // sll r0, r0, 0 + +block_8: + bc = ((s64)c->sgpr64(t0)) >= 0; // bgez t0, L81 + c->daddiu(v1, v1, 4); // daddiu v1, v1, 4 + if (bc) {goto block_10;} // branch non-likely + + c->sb(a2, 3, v1); // sb a2, 3(v1) + // nop // sll r0, r0, 0 + +block_10: + bc = ((s64)c->sgpr64(a1)) > 0; // bgtz a1, L77 + c->daddiu(v1, v1, 4); // daddiu v1, v1, 4 + if (bc) {goto block_2;} // branch non-likely + + +block_11: + bc = ((s64)c->sgpr64(a1)) <= 0; // blez a1, L85 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + +block_12: + c->lbu(a3, 0, v1); // lbu a3, 0(v1) + c->lbu(t0, 1, v1); // lbu t0, 1(v1) + c->lbu(a2, 2, v1); // lbu a2, 2(v1) + c->dsll(a3, a3, 4); // dsll a3, a3, 4 + c->dsll(t0, t0, 4); // dsll t0, t0, 4 + c->dsll(a2, a2, 4); // dsll a2, a2, 4 + c->daddu(a3, a3, a0); // daddu a3, a3, a0 + c->daddu(t0, t0, a0); // daddu t0, t0, a0 + c->daddu(a2, a2, a0); // daddu a2, a2, a0 + c->lqc2(vf2, 0, a3); // lqc2 vf2, 0(a3) + c->lqc2(vf3, 0, t0); // lqc2 vf3, 0(t0) + c->lqc2(vf4, 0, a2); // lqc2 vf4, 0(a2) + c->vsub(DEST::xyzw, vf5, vf3, vf2); // vsub.xyzw vf5, vf3, vf2 + c->vsub(DEST::xyzw, vf6, vf4, vf2); // vsub.xyzw vf6, vf4, vf2 + c->vopmula(vf5, vf6); // vopmula.xyz acc, vf5, vf6 + c->vopmsub(vf5, vf6, vf5); // vopmsub.xyz vf5, vf6, vf5 + c->vmul(DEST::xyz, vf5, vf5, vf1); // vmul.xyz vf5, vf5, vf1 + c->vadd_bc(DEST::y, BC::x, vf5, vf5, vf5); // vaddx.y vf5, vf5, vf5 + c->vadd_bc(DEST::y, BC::z, vf5, vf5, vf5); // vaddz.y vf5, vf5, vf5 + c->mov128_gpr_vf(a2, vf5); // qmfc2.i a2, vf5 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(a2)) >= 0; // bgez a2, L84 + c->addiu(a2, r0, 1); // addiu a2, r0, 1 + if (bc) {goto block_14;} // branch non-likely + + c->sb(a2, 3, v1); // sb a2, 3(v1) + +block_14: + c->daddiu(a1, a1, -1); // daddiu a1, a1, -1 + bc = c->sgpr64(a1) != 0; // bne a1, r0, L83 + c->daddiu(v1, v1, 4); // daddiu v1, v1, 4 + if (bc) {goto block_12;} // branch non-likely + + +block_15: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 16); // daddiu sp, sp, 16 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + gLinkedFunctionTable.reg("shadow-find-facing-double-tris", execute, 128); +} + +} // namespace shadow_find_facing_double_tris +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_find_double_edges { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->lw(a2, 16, a1); // lw a2, 16(a1) + c->lh(a3, 18, a0); // lh a3, 18(a0) + c->mov64(v1, a2); // or v1, a2, r0 + c->lw(t1, 40, a0); // lw t1, 40(a0) + bc = c->sgpr64(a3) == 0; // beq a3, r0, L75 + c->lw(t0, 12, a1); // lw t0, 12(a1) + if (bc) {goto block_7;} // branch non-likely + + c->daddu(a0, t1, a0); // daddu a0, t1, a0 + c->sw(a2, 40, a1); // sw a2, 40(a1) + c->sw(a0, 8, a1); // sw a0, 8(a1) + c->mov64(t1, a0); // or t1, a0, r0 + c->addiu(t2, r0, 255); // addiu t2, r0, 255 + +block_2: + c->daddiu(a3, a3, -1); // daddiu a3, a3, -1 + c->lbu(t3, 3, t1); // lbu t3, 3(t1) + // nop // sll r0, r0, 0 + c->lbu(t4, 2, t1); // lbu t4, 2(t1) + bc = c->sgpr64(t3) == c->sgpr64(t2); // beq t3, t2, L73 + c->gprs[t5].du64[0] = 0; // or t5, r0, r0 + if (bc) {goto block_5;} // branch non-likely + + c->dsll(t4, t4, 2); // dsll t4, t4, 2 + c->dsll(t3, t3, 2); // dsll t3, t3, 2 + c->daddu(t4, t4, t0); // daddu t4, t4, t0 + c->daddu(t3, t3, t0); // daddu t3, t3, t0 + // nop // sll r0, r0, 0 + c->lbu(t4, 3, t4); // lbu t4, 3(t4) + // nop // sll r0, r0, 0 + c->lbu(t3, 3, t3); // lbu t3, 3(t3) + bc = c->sgpr64(t4) == c->sgpr64(t3); // beq t4, t3, L74 + // nop // sll r0, r0, 0 + if (bc) {goto block_6;} // branch non-likely + + c->sltiu(t4, t4, 1); // sltiu t4, t4, 1 + // nop // sll r0, r0, 0 + c->sltu(t3, r0, t3); // sltu t3, r0, t3 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sh(t4, 2, v1); // sh t4, 2(v1) + c->dsubu(t4, t1, a0); // dsubu t4, t1, a0 + c->sh(t3, 6, v1); // sh t3, 6(v1) + // nop // sll r0, r0, 0 + c->sh(t4, 0, v1); // sh t4, 0(v1) + // nop // sll r0, r0, 0 + c->sh(t4, 4, v1); // sh t4, 4(v1) + //beq r0, r0, L74 // beq r0, r0, L74 + c->daddiu(v1, v1, 8); // daddiu v1, v1, 8 + goto block_6; // branch always + + +block_5: + c->dsll(t3, t4, 2); // dsll t3, t4, 2 + // nop // sll r0, r0, 0 + c->daddu(t3, t3, t0); // daddu t3, t3, t0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lbu(t3, 3, t3); // lbu t3, 3(t3) + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sltiu(t3, t3, 1); // sltiu t3, t3, 1 + c->dsubu(t4, t1, a0); // dsubu t4, t1, a0 + c->sh(t3, 2, v1); // sh t3, 2(v1) + c->sh(t4, 0, v1); // sh t4, 0(v1) + c->daddiu(v1, v1, 4); // daddiu v1, v1, 4 + +block_6: + bc = c->sgpr64(a3) != 0; // bne a3, r0, L72 + c->daddiu(t1, t1, 4); // daddiu t1, t1, 4 + if (bc) {goto block_2;} // branch non-likely + + +block_7: + c->dsubu(a0, v1, a2); // dsubu a0, v1, a2 + c->dsra(a0, a0, 2); // dsra a0, a0, 2 + c->sw(a0, 28, a1); // sw a0, 28(a1) + c->sw(v1, 16, a1); // sw v1, 16(a1) + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + gLinkedFunctionTable.reg("shadow-find-double-edges", execute, 128); +} + +} // namespace shadow_find_double_edges +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_add_verts { +struct Cache { + void* shadow_data; // *shadow-data* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->load_symbol2(v1, cache.shadow_data); // lw v1, *shadow-data*(s7) + c->mov64(v1, v1); // or v1, v1, r0 + c->lh(a0, 8, a0); // lh a0, 8(a0) + c->addiu(t1, r0, 4); // addiu t1, r0, 4 + c->lq(t0, 0, v1); // lq t0, 0(v1) + // nop // sll r0, r0, 0 + c->sq(t0, 0, a2); // sq t0, 0(a2) + c->sh(a0, 0, a2); // sh a0, 0(a2) + c->sb(a0, 14, a2); // sb a0, 14(a2) + c->sh(t1, 12, a2); // sh t1, 12(a2) + c->daddiu(a2, a2, 16); // daddiu a2, a2, 16 + c->lw(t3, 0, a1); // lw t3, 0(a1) + c->sll(v1, a0, 4); // sll v1, a0, 4 + c->mov64(t2, a2); // or t2, a2, r0 + c->mov64(t1, a0); // or t1, a0, r0 + c->daddiu(t4, t1, -4); // daddiu t4, t1, -4 + c->mov64(t2, t2); // or t2, t2, r0 + bc = ((s64)c->sgpr64(t4)) < 0; // bltz t4, L65 + c->mov64(t3, t3); // or t3, t3, r0 + if (bc) {goto block_2;} // branch non-likely + + +block_1: + // nop // sll r0, r0, 0 + c->lq(t7, 0, t3); // lq t7, 0(t3) + // nop // sll r0, r0, 0 + c->lq(t4, 16, t3); // lq t4, 16(t3) + c->daddiu(t1, t1, -4); // daddiu t1, t1, -4 + c->lq(t5, 32, t3); // lq t5, 32(t3) + c->daddiu(t2, t2, 64); // daddiu t2, t2, 64 + c->lq(t6, 48, t3); // lq t6, 48(t3) + c->daddiu(t3, t3, 64); // daddiu t3, t3, 64 + c->sq(t7, -64, t2); // sq t7, -64(t2) + c->daddiu(t7, t1, -4); // daddiu t7, t1, -4 + c->sq(t4, -48, t2); // sq t4, -48(t2) + // nop // sll r0, r0, 0 + c->sq(t5, -32, t2); // sq t5, -32(t2) + bc = ((s64)c->sgpr64(t7)) >= 0; // bgez t7, L64 + c->sq(t6, -16, t2); // sq t6, -16(t2) + if (bc) {goto block_1;} // branch non-likely + + +block_2: + bc = c->sgpr64(t1) == 0; // beq t1, r0, L66 + c->lq(t4, 0, t3); // lq t4, 0(t3) + if (bc) {goto block_7;} // branch non-likely + + c->daddiu(t3, t3, 16); // daddiu t3, t3, 16 + c->daddiu(t2, t2, 16); // daddiu t2, t2, 16 + c->daddiu(t1, t1, -1); // daddiu t1, t1, -1 + c->sq(t4, -16, t2); // sq t4, -16(t2) + bc = c->sgpr64(t1) == 0; // beq t1, r0, L66 + c->lq(t4, 0, t3); // lq t4, 0(t3) + if (bc) {goto block_7;} // branch non-likely + + c->daddiu(t3, t3, 16); // daddiu t3, t3, 16 + c->daddiu(t2, t2, 16); // daddiu t2, t2, 16 + c->daddiu(t1, t1, -1); // daddiu t1, t1, -1 + c->sq(t4, -16, t2); // sq t4, -16(t2) + bc = c->sgpr64(t1) == 0; // beq t1, r0, L66 + c->lq(t4, 0, t3); // lq t4, 0(t3) + if (bc) {goto block_7;} // branch non-likely + + c->daddiu(t3, t3, 16); // daddiu t3, t3, 16 + c->daddiu(t2, t2, 16); // daddiu t2, t2, 16 + c->daddiu(t1, t1, -1); // daddiu t1, t1, -1 + c->sq(t4, -16, t2); // sq t4, -16(t2) + bc = c->sgpr64(t1) == 0; // beq t1, r0, L66 + c->lq(t4, 0, t3); // lq t4, 0(t3) + if (bc) {goto block_7;} // branch non-likely + + c->daddiu(t3, t3, 16); // daddiu t3, t3, 16 + c->daddiu(t2, t2, 16); // daddiu t2, t2, 16 + c->daddiu(t1, t1, -1); // daddiu t1, t1, -1 + c->sq(t4, -16, t2); // sq t4, -16(t2) + +block_7: + c->gprs[t1].du64[0] = 0; // or t1, r0, r0 + c->daddu(v0, a2, v1); // daddu v0, a2, v1 + bc = c->sgpr64(a3) != 0; // bne a3, r0, L70 + c->addiu(a2, r0, 174); // addiu a2, r0, 174 + if (bc) {goto block_16;} // branch non-likely + + c->sq(t0, 0, v0); // sq t0, 0(v0) + c->sh(a0, 0, v0); // sh a0, 0(v0) + c->sb(a0, 14, v0); // sb a0, 14(v0) + c->sw(r0, 8, v0); // sw r0, 8(v0) + c->sh(a2, 12, v0); // sh a2, 12(v0) + c->lw(a3, 44, a1); // lw a3, 44(a1) + c->daddiu(a1, v0, 16); // daddiu a1, v0, 16 + c->mov64(a2, a1); // or a2, a1, r0 + c->daddiu(t0, a0, -4); // daddiu t0, a0, -4 + c->mov64(a2, a2); // or a2, a2, r0 + bc = ((s64)c->sgpr64(t0)) < 0; // bltz t0, L68 + c->mov64(a3, a3); // or a3, a3, r0 + if (bc) {goto block_10;} // branch non-likely + + +block_9: + // nop // sll r0, r0, 0 + c->lq(t3, 0, a3); // lq t3, 0(a3) + // nop // sll r0, r0, 0 + c->lq(t0, 16, a3); // lq t0, 16(a3) + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->lq(t1, 32, a3); // lq t1, 32(a3) + c->daddiu(a2, a2, 64); // daddiu a2, a2, 64 + c->lq(t2, 48, a3); // lq t2, 48(a3) + c->daddiu(a3, a3, 64); // daddiu a3, a3, 64 + c->sq(t3, -64, a2); // sq t3, -64(a2) + c->daddiu(t3, a0, -4); // daddiu t3, a0, -4 + c->sq(t0, -48, a2); // sq t0, -48(a2) + // nop // sll r0, r0, 0 + c->sq(t1, -32, a2); // sq t1, -32(a2) + bc = ((s64)c->sgpr64(t3)) >= 0; // bgez t3, L67 + c->sq(t2, -16, a2); // sq t2, -16(a2) + if (bc) {goto block_9;} // branch non-likely + + +block_10: + bc = c->sgpr64(a0) == 0; // beq a0, r0, L69 + c->lq(t0, 0, a3); // lq t0, 0(a3) + if (bc) {goto block_15;} // branch non-likely + + c->daddiu(a3, a3, 16); // daddiu a3, a3, 16 + c->daddiu(a2, a2, 16); // daddiu a2, a2, 16 + c->daddiu(a0, a0, -1); // daddiu a0, a0, -1 + c->sq(t0, -16, a2); // sq t0, -16(a2) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L69 + c->lq(t0, 0, a3); // lq t0, 0(a3) + if (bc) {goto block_15;} // branch non-likely + + c->daddiu(a3, a3, 16); // daddiu a3, a3, 16 + c->daddiu(a2, a2, 16); // daddiu a2, a2, 16 + c->daddiu(a0, a0, -1); // daddiu a0, a0, -1 + c->sq(t0, -16, a2); // sq t0, -16(a2) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L69 + c->lq(t0, 0, a3); // lq t0, 0(a3) + if (bc) {goto block_15;} // branch non-likely + + c->daddiu(a3, a3, 16); // daddiu a3, a3, 16 + c->daddiu(a2, a2, 16); // daddiu a2, a2, 16 + c->daddiu(a0, a0, -1); // daddiu a0, a0, -1 + c->sq(t0, -16, a2); // sq t0, -16(a2) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L69 + c->lq(t0, 0, a3); // lq t0, 0(a3) + if (bc) {goto block_15;} // branch non-likely + + c->daddiu(a3, a3, 16); // daddiu a3, a3, 16 + c->daddiu(a2, a2, 16); // daddiu a2, a2, 16 + c->daddiu(a0, a0, -1); // daddiu a0, a0, -1 + c->sq(t0, -16, a2); // sq t0, -16(a2) + +block_15: + c->gprs[a0].du64[0] = 0; // or a0, r0, r0 + c->daddu(v0, a1, v1); // daddu v0, a1, v1 + +block_16: + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.shadow_data = intern_from_c("*shadow-data*").c(); + gLinkedFunctionTable.reg("shadow-add-verts", execute, 128); +} + +} // namespace shadow_add_verts +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_add_facing_single_tris { +struct Cache { + void* shadow_data; // *shadow-data* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->load_symbol2(v1, cache.shadow_data); // lw v1, *shadow-data*(s7) + c->mov64(a3, v1); // or a3, v1, r0 + c->lw(v1, 20, a1); // lw v1, 20(a1) + c->lw(a0, 32, a1); // lw a0, 32(a1) + bc = c->sgpr64(v1) == 0; // beq v1, r0, L62 + c->daddiu(a1, v1, 1); // daddiu a1, v1, 1 + if (bc) {goto block_4;} // branch non-likely + + c->daddiu(a1, a1, 3); // daddiu a1, a1, 3 + c->dsra(t0, a1, 2); // dsra t0, a1, 2 + c->dsll(a1, t0, 2); // dsll a1, t0, 2 + c->daddiu(t0, t0, 1); // daddiu t0, t0, 1 + c->ld(t1, 16, a3); // ld t1, 16(a3) + c->daddu(t0, t1, t0); // daddu t0, t1, t0 + c->lw(a3, 28, a3); // lw a3, 28(a3) + c->sd(t0, 0, a2); // sd t0, 0(a2) + c->addiu(t0, r0, 16728); // addiu t0, r0, 16728 + c->sw(r0, 8, a2); // sw r0, 8(a2) + c->sw(a3, 12, a2); // sw a3, 12(a2) + c->sb(a1, 14, a2); // sb a1, 14(a2) + c->dsll(a1, a1, 2); // dsll a1, a1, 2 + c->sh(t0, 12, a2); // sh t0, 12(a2) + c->daddiu(a2, a2, 16); // daddiu a2, a2, 16 + c->daddu(a1, a2, a1); // daddu a1, a2, a1 + c->sq(r0, -16, a1); // sq r0, -16(a1) + c->sw(v1, 0, a2); // sw v1, 0(a2) + c->daddiu(a2, a2, 4); // daddiu a2, a2, 4 + +block_2: + c->lw(a3, 0, a0); // lw a3, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + c->lw(a3, 0, a3); // lw a3, 0(a3) + c->daddiu(v1, v1, -1); // daddiu v1, v1, -1 + c->sw(a3, 0, a2); // sw a3, 0(a2) + c->daddiu(a2, a2, 4); // daddiu a2, a2, 4 + bc = ((s64)c->sgpr64(v1)) > 0; // bgtz v1, L61 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + c->mov64(v1, a1); // or v1, a1, r0 + c->lui(a0, 5376); // lui a0, 5376 + c->ori(a0, a0, 2); // ori a0, a0, 2 + c->sq(r0, 0, v1); // sq r0, 0(v1) + c->sw(a0, 12, v1); // sw a0, 12(v1) + c->daddiu(a2, v1, 16); // daddiu a2, v1, 16 + +block_4: + c->mov64(v0, a2); // or v0, a2, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.shadow_data = intern_from_c("*shadow-data*").c(); + gLinkedFunctionTable.reg("shadow-add-facing-single-tris", execute, 128); +} + +} // namespace shadow_add_facing_single_tris +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_add_single_edges { +struct Cache { + void* shadow_data; // *shadow-data* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->load_symbol2(v1, cache.shadow_data); // lw v1, *shadow-data*(s7) + c->mov64(a3, v1); // or a3, v1, r0 + c->lw(v1, 24, a1); // lw v1, 24(a1) + c->lw(a0, 36, a1); // lw a0, 36(a1) + c->lw(a1, 4, a1); // lw a1, 4(a1) + bc = c->sgpr64(v1) == 0; // beq v1, r0, L59 + c->daddiu(t0, v1, 1); // daddiu t0, v1, 1 + if (bc) {goto block_4;} // branch non-likely + + c->daddiu(t0, t0, 3); // daddiu t0, t0, 3 + c->dsra(t1, t0, 2); // dsra t1, t0, 2 + c->dsll(t0, t1, 2); // dsll t0, t1, 2 + c->daddiu(t1, t1, 1); // daddiu t1, t1, 1 + c->ld(t2, 16, a3); // ld t2, 16(a3) + c->daddu(t1, t2, t1); // daddu t1, t2, t1 + c->lw(a3, 28, a3); // lw a3, 28(a3) + c->sd(t1, 0, a2); // sd t1, 0(a2) + c->addiu(t1, r0, 16984); // addiu t1, r0, 16984 + c->sw(r0, 8, a2); // sw r0, 8(a2) + c->sw(a3, 12, a2); // sw a3, 12(a2) + c->sb(t0, 14, a2); // sb t0, 14(a2) + c->dsll(a3, t0, 2); // dsll a3, t0, 2 + c->sh(t1, 12, a2); // sh t1, 12(a2) + c->daddiu(t0, a2, 16); // daddiu t0, a2, 16 + c->daddu(a2, t0, a3); // daddu a2, t0, a3 + c->sq(r0, -16, a2); // sq r0, -16(a2) + c->sw(v1, 0, t0); // sw v1, 0(t0) + c->daddiu(a3, t0, 4); // daddiu a3, t0, 4 + +block_2: + c->lh(t1, 0, a0); // lh t1, 0(a0) + c->lh(t0, 2, a0); // lh t0, 2(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + c->daddu(t1, t1, a1); // daddu t1, t1, a1 + c->lhu(t1, 0, t1); // lhu t1, 0(t1) + c->sh(t0, 2, a3); // sh t0, 2(a3) + c->sh(t1, 0, a3); // sh t1, 0(a3) + c->daddiu(v1, v1, -1); // daddiu v1, v1, -1 + c->daddiu(a3, a3, 4); // daddiu a3, a3, 4 + bc = ((s64)c->sgpr64(v1)) > 0; // bgtz v1, L58 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + c->mov64(v1, a2); // or v1, a2, r0 + c->lui(a0, 5376); // lui a0, 5376 + c->ori(a0, a0, 4); // ori a0, a0, 4 + c->sq(r0, 0, v1); // sq r0, 0(v1) + c->sw(a0, 12, v1); // sw a0, 12(v1) + c->daddiu(a2, v1, 16); // daddiu a2, v1, 16 + +block_4: + c->mov64(v0, a2); // or v0, a2, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.shadow_data = intern_from_c("*shadow-data*").c(); + gLinkedFunctionTable.reg("shadow-add-single-edges", execute, 128); +} + +} // namespace shadow_add_single_edges +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_add_single_tris { +struct Cache { + void* shadow_data; // *shadow-data* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->load_symbol2(v1, cache.shadow_data); // lw v1, *shadow-data*(s7) + c->mov64(a3, v1); // or a3, v1, r0 + c->lh(a1, 12, a0); // lh a1, 12(a0) + c->lw(v1, 28, a0); // lw v1, 28(a0) + bc = c->sgpr64(a1) == 0; // beq a1, r0, L56 + c->daddu(v1, v1, a0); // daddu v1, v1, a0 + if (bc) {goto block_4;} // branch non-likely + + c->daddiu(a0, a1, 1); // daddiu a0, a1, 1 + c->daddiu(a0, a0, 3); // daddiu a0, a0, 3 + c->dsra(t0, a0, 2); // dsra t0, a0, 2 + c->dsll(a0, t0, 2); // dsll a0, t0, 2 + c->daddiu(t0, t0, 1); // daddiu t0, t0, 1 + c->ld(t1, 16, a3); // ld t1, 16(a3) + c->daddu(t0, t1, t0); // daddu t0, t1, t0 + c->lw(a3, 28, a3); // lw a3, 28(a3) + c->sd(t0, 0, a2); // sd t0, 0(a2) + c->addiu(t0, r0, 16728); // addiu t0, r0, 16728 + c->sw(r0, 8, a2); // sw r0, 8(a2) + c->sw(a3, 12, a2); // sw a3, 12(a2) + c->sb(a0, 14, a2); // sb a0, 14(a2) + c->dsll(a0, a0, 2); // dsll a0, a0, 2 + c->sh(t0, 12, a2); // sh t0, 12(a2) + c->daddiu(a2, a2, 16); // daddiu a2, a2, 16 + c->daddu(a0, a2, a0); // daddu a0, a2, a0 + c->sq(r0, -16, a0); // sq r0, -16(a0) + c->ori(a1, a1, 256); // ori a1, a1, 256 + c->sw(a1, 0, a2); // sw a1, 0(a2) + c->daddiu(a2, a2, 4); // daddiu a2, a2, 4 + +block_2: + c->lw(a3, 0, v1); // lw a3, 0(v1) + c->daddiu(v1, v1, 4); // daddiu v1, v1, 4 + c->daddiu(a1, a1, -1); // daddiu a1, a1, -1 + c->sw(a3, 0, a2); // sw a3, 0(a2) + bc = ((s64)c->sgpr64(a1)) > 0; // bgtz a1, L55 + c->daddiu(a2, a2, 4); // daddiu a2, a2, 4 + if (bc) {goto block_2;} // branch non-likely + + c->mov64(v1, a0); // or v1, a0, r0 + c->lui(a0, 5376); // lui a0, 5376 + c->ori(a0, a0, 6); // ori a0, a0, 6 + c->sq(r0, 0, v1); // sq r0, 0(v1) + c->sw(a0, 12, v1); // sw a0, 12(v1) + c->daddiu(a2, v1, 16); // daddiu a2, v1, 16 + +block_4: + c->mov64(v0, a2); // or v0, a2, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.shadow_data = intern_from_c("*shadow-data*").c(); + gLinkedFunctionTable.reg("shadow-add-single-tris", execute, 128); +} + +} // namespace shadow_add_single_tris +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_add_double_tris { +struct Cache { + void* shadow_data; // *shadow-data* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->load_symbol2(v1, cache.shadow_data); // lw v1, *shadow-data*(s7) + c->mov64(a3, v1); // or a3, v1, r0 + c->lh(v1, 16, a0); // lh v1, 16(a0) + c->lw(a0, 12, a1); // lw a0, 12(a1) + bc = c->sgpr64(v1) == 0; // beq v1, r0, L53 + c->daddiu(a1, v1, 1); // daddiu a1, v1, 1 + if (bc) {goto block_4;} // branch non-likely + + c->daddiu(a1, a1, 3); // daddiu a1, a1, 3 + c->dsra(t0, a1, 2); // dsra t0, a1, 2 + c->dsll(a1, t0, 2); // dsll a1, t0, 2 + c->daddiu(t0, t0, 1); // daddiu t0, t0, 1 + c->ld(t1, 16, a3); // ld t1, 16(a3) + c->daddu(t0, t1, t0); // daddu t0, t1, t0 + c->lw(a3, 28, a3); // lw a3, 28(a3) + c->sd(t0, 0, a2); // sd t0, 0(a2) + c->addiu(t0, r0, 16728); // addiu t0, r0, 16728 + c->sw(r0, 8, a2); // sw r0, 8(a2) + c->sw(a3, 12, a2); // sw a3, 12(a2) + c->sb(a1, 14, a2); // sb a1, 14(a2) + c->dsll(a1, a1, 2); // dsll a1, a1, 2 + c->sh(t0, 12, a2); // sh t0, 12(a2) + c->daddiu(a2, a2, 16); // daddiu a2, a2, 16 + c->daddu(a1, a2, a1); // daddu a1, a2, a1 + c->sq(r0, -16, a1); // sq r0, -16(a1) + c->sw(v1, 0, a2); // sw v1, 0(a2) + c->daddiu(a2, a2, 4); // daddiu a2, a2, 4 + +block_2: + c->lw(a3, 0, a0); // lw a3, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + c->daddiu(v1, v1, -1); // daddiu v1, v1, -1 + c->sw(a3, 0, a2); // sw a3, 0(a2) + c->daddiu(a2, a2, 4); // daddiu a2, a2, 4 + bc = ((s64)c->sgpr64(v1)) > 0; // bgtz v1, L52 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + c->mov64(v1, a1); // or v1, a1, r0 + c->lui(a0, 5376); // lui a0, 5376 + c->ori(a0, a0, 6); // ori a0, a0, 6 + c->sq(r0, 0, v1); // sq r0, 0(v1) + c->sw(a0, 12, v1); // sw a0, 12(v1) + c->daddiu(a2, v1, 16); // daddiu a2, v1, 16 + +block_4: + c->mov64(v0, a2); // or v0, a2, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.shadow_data = intern_from_c("*shadow-data*").c(); + gLinkedFunctionTable.reg("shadow-add-double-tris", execute, 128); +} + +} // namespace shadow_add_double_tris +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_add_double_edges { +struct Cache { + void* shadow_data; // *shadow-data* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->load_symbol2(v1, cache.shadow_data); // lw v1, *shadow-data*(s7) + c->mov64(a3, v1); // or a3, v1, r0 + c->lw(v1, 28, a1); // lw v1, 28(a1) + c->lw(a0, 40, a1); // lw a0, 40(a1) + c->lw(a1, 8, a1); // lw a1, 8(a1) + bc = c->sgpr64(v1) == 0; // beq v1, r0, L50 + c->daddiu(t0, v1, 1); // daddiu t0, v1, 1 + if (bc) {goto block_4;} // branch non-likely + + c->daddiu(t0, t0, 3); // daddiu t0, t0, 3 + c->dsra(t1, t0, 2); // dsra t1, t0, 2 + c->dsll(t0, t1, 2); // dsll t0, t1, 2 + c->daddiu(t1, t1, 1); // daddiu t1, t1, 1 + c->ld(t2, 16, a3); // ld t2, 16(a3) + c->daddu(t1, t2, t1); // daddu t1, t2, t1 + c->lw(a3, 28, a3); // lw a3, 28(a3) + c->sd(t1, 0, a2); // sd t1, 0(a2) + c->addiu(t1, r0, 16984); // addiu t1, r0, 16984 + c->sw(r0, 8, a2); // sw r0, 8(a2) + c->sw(a3, 12, a2); // sw a3, 12(a2) + c->sb(t0, 14, a2); // sb t0, 14(a2) + c->dsll(a3, t0, 2); // dsll a3, t0, 2 + c->sh(t1, 12, a2); // sh t1, 12(a2) + c->daddiu(t0, a2, 16); // daddiu t0, a2, 16 + c->daddu(a2, t0, a3); // daddu a2, t0, a3 + c->sq(r0, -16, a2); // sq r0, -16(a2) + c->sw(v1, 0, t0); // sw v1, 0(t0) + c->daddiu(a3, t0, 4); // daddiu a3, t0, 4 + +block_2: + c->lh(t1, 0, a0); // lh t1, 0(a0) + c->lh(t0, 2, a0); // lh t0, 2(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + c->daddu(t1, t1, a1); // daddu t1, t1, a1 + c->lhu(t1, 0, t1); // lhu t1, 0(t1) + c->sh(t0, 2, a3); // sh t0, 2(a3) + c->sh(t1, 0, a3); // sh t1, 0(a3) + c->daddiu(v1, v1, -1); // daddiu v1, v1, -1 + c->daddiu(a3, a3, 4); // daddiu a3, a3, 4 + bc = ((s64)c->sgpr64(v1)) > 0; // bgtz v1, L49 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + c->mov64(v1, a2); // or v1, a2, r0 + c->lui(a0, 5376); // lui a0, 5376 + c->ori(a0, a0, 4); // ori a0, a0, 4 + c->sq(r0, 0, v1); // sq r0, 0(v1) + c->sw(a0, 12, v1); // sw a0, 12(v1) + c->daddiu(a2, v1, 16); // daddiu a2, v1, 16 + +block_4: + c->mov64(v0, a2); // or v0, a2, r0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.shadow_data = intern_from_c("*shadow-data*").c(); + gLinkedFunctionTable.reg("shadow-add-double-edges", execute, 128); +} + +} // namespace shadow_add_double_edges +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace shadow_execute { +struct Cache { + void* fake_scratchpad_data; // *fake-scratchpad-data* + void* gsf_buffer; // *gsf-buffer* + void* math_camera; // *math-camera* + void* shadow_debug; // *shadow-debug* + void* camera_pos; // camera-pos + void* debug_draw_settings; // debug-draw-settings + void* flush_cache; // flush-cache + void* shadow_add_double_edges; // shadow-add-double-edges + void* shadow_add_double_tris; // shadow-add-double-tris + void* shadow_add_facing_single_tris; // shadow-add-facing-single-tris + void* shadow_add_single_edges; // shadow-add-single-edges + void* shadow_add_single_tris; // shadow-add-single-tris + void* shadow_add_verts; // shadow-add-verts + void* shadow_calc_dual_verts; // shadow-calc-dual-verts + void* shadow_find_double_edges; // shadow-find-double-edges + void* shadow_find_facing_double_tris; // shadow-find-facing-double-tris + void* shadow_find_facing_single_tris; // shadow-find-facing-single-tris + void* shadow_find_single_edges; // shadow-find-single-edges + void* shadow_init_vars; // shadow-init-vars + void* shadow_scissor_edges; // shadow-scissor-edges + void* shadow_scissor_top; // shadow-scissor-top + void* shadow_xform_verts; // shadow-xform-verts +} cache; + +u64 execute(void* ctxt) { + u32 sadr, tadr; + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -112); // daddiu sp, sp, -112 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s1, 16, sp); // sq s1, 16(sp) + c->sq(s2, 32, sp); // sq s2, 32(sp) + c->sq(s3, 48, sp); // sq s3, 48(sp) + c->sq(s4, 64, sp); // sq s4, 64(sp) + c->sq(s5, 80, sp); // sq s5, 80(sp) + c->sq(gp, 96, sp); // sq gp, 96(sp) + c->mov64(gp, a1); // or gp, a1, r0 + c->mov64(s4, a0); // or s4, a0, r0 + c->addiu(v1, r0, 0); // addiu v1, r0, 0 + get_fake_spad_addr2(v1, cache.fake_scratchpad_data, 0, c);// lui v1, 28672 + c->daddiu(s5, v1, 40); // daddiu s5, v1, 40 + c->load_symbol2(t9, cache.flush_cache); // lw t9, flush-cache(s7) + c->addiu(a0, r0, 0); // addiu a0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + //beq r0, r0, L42 // beq r0, r0, L42 + // nop // sll r0, r0, 0 + goto block_37; // branch always + + +block_1: + c->lui(v1, 4096); // lui v1, 4096 + c->ori(v1, v1, 54272); // ori v1, v1, 54272 + c->addiu(a0, r0, 48); // addiu a0, r0, 48 + c->mov64(a1, v1); // or a1, v1, r0 + +/* +block_2: + c->lw(a2, 0, a1); // lw a2, 0(a1) + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->andi(a2, a2, 256); // andi a2, a2, 256 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) == 0; // beq a2, r0, L26 + // nop // sll r0, r0, 0 + if (bc) {goto block_4;} // branch non-likely + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + goto block_2; // branch always + + +block_4: + c->gprs[a1].du64[0] = 0; // or a1, r0, r0 + c->mov64(a1, v1); // or a1, v1, r0 + c->mov64(a2, s5); // or a2, s5, r0 + c->lw(a3, 0, a1); // lw a3, 0(a1) + c->andi(a3, a3, 256); // andi a3, a3, 256 + bc = c->sgpr64(a3) == 0; // beq a3, r0, L28 + DANGER jump to delay slot, this MUST be fixed manually! + c->lw(a3, 0, a2); // lw a3, 0(a2) + if (bc) {goto block_-1;} // branch non-likely + + +block_5: + c->lw(a3, 0, a2); // lw a3, 0(a2) + // nop // sll r0, r0, 0 + c->lw(t0, 0, a1); // lw t0, 0(a1) + // nop // sll r0, r0, 0 + c->andi(t0, t0, 256); // andi t0, t0, 256 + c->daddiu(a3, a3, 1); // daddiu a3, a3, 1 + bc = c->sgpr64(t0) != 0; // bne t0, r0, L27 + c->sw(a3, 0, a2); // sw a3, 0(a2) + if (bc) {goto block_5;} // branch non-likely +*/ + + c->gprs[a1].du64[0] = 0; // or a1, r0, r0 + sadr = c->sgpr64(a0); // c->sw(a0, 128, v1); // sw a0, 128(v1) + tadr = c->sgpr64(s4); // c->sw(s4, 48, v1); // sw s4, 48(v1) + // c->sw(r0, 32, v1); // sw r0, 32(v1) + // Unknown instr: sync.l + c->addiu(a0, r0, 324); // addiu a0, r0, 324 + // c->sw(a0, 0, v1); // sw a0, 0(v1) + spad_to_dma_blerc_chain(cache.fake_scratchpad_data, sadr, tadr); + // Unknown instr: sync.l + c->mov64(a0, s5); // or a0, s5, r0 +/* + c->lw(a1, 0, v1); // lw a1, 0(v1) + c->andi(a1, a1, 256); // andi a1, a1, 256 + bc = c->sgpr64(a1) == 0; // beq a1, r0, L30 + DANGER jump to delay slot, this MUST be fixed manually! + c->lw(a1, 0, a0); // lw a1, 0(a0) + if (bc) {goto block_-1;} // branch non-likely + + +block_8: + c->lw(a1, 0, a0); // lw a1, 0(a0) + // nop // sll r0, r0, 0 + c->lw(a2, 0, v1); // lw a2, 0(v1) + // nop // sll r0, r0, 0 + c->andi(a2, a2, 256); // andi a2, a2, 256 + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L29 + c->sw(a1, 0, a0); // sw a1, 0(a0) + if (bc) {goto block_8;} // branch non-likely +*/ + + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + get_fake_spad_addr2(s4, cache.fake_scratchpad_data, 0, c);// lui s4, 28672 + c->addiu(v1, r0, 160); // addiu v1, r0, 160 + c->daddu(s2, v1, s4); // daddu s2, v1, s4 + c->lw(v1, 56, s4); // lw v1, 56(s4) + c->daddiu(s1, s4, 64); // daddiu s1, s4, 64 + c->load_symbol2(s3, cache.gsf_buffer); // lw s3, *gsf-buffer*(s7) + c->sw(v1, 68, s3); // sw v1, 68(s3) + c->lw(v1, 12, s1); // lw v1, 12(s1) + c->andi(v1, v1, 32); // andi v1, v1, 32 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L41 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_36;} // branch non-likely + + c->load_symbol2(v1, cache.shadow_debug); // lw v1, *shadow-debug*(s7) + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L31 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_13;} // branch non-likely + + c->load_symbol2(t9, cache.debug_draw_settings); // lw t9, debug-draw-settings(s7) + c->mov64(a0, s1); // or a0, s1, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(v1, v0); // or v1, v0, r0 + +block_13: + c->daddiu(v1, s3, 80); // daddiu v1, s3, 80 + c->daddu(a0, r0, s1); // daddu a0, r0, s1 + c->daddiu(a1, s1, 16); // daddiu a1, s1, 16 + c->lwc1(f0, 28, s1); // lwc1 f0, 28(s1) + c->lqc2(vf2, 0, a1); // lqc2 vf2, 0(a1) + c->lqc2(vf1, 0, a0); // lqc2 vf1, 0(a0) + c->mfc1(a0, f0); // mfc1 a0, f0 + c->mov128_vf_gpr(vf3, a0); // qmtc2.i vf3, a0 + c->vadd_bc(DEST::w, BC::x, vf4, vf0, vf0); // vaddx.w vf4, vf0, vf0 + c->vmula_bc(DEST::xyzw, BC::x, vf2, vf3); // vmulax.xyzw acc, vf2, vf3 + c->vmadd_bc(DEST::xyz, BC::w, vf4, vf1, vf0); // vmaddw.xyz vf4, vf1, vf0 + c->sqc2(vf4, 0, v1); // sqc2 vf4, 0(v1) + c->lw(v1, 12, s1); // lw v1, 12(s1) + c->andi(v1, v1, 4); // andi v1, v1, 4 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L32 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + c->lq(v1, 32, s1); // lq v1, 32(s1) + c->sq(v1, 96, s3); // sq v1, 96(s3) + c->lq(v1, 48, s1); // lq v1, 48(s1) + c->sq(v1, 112, s3); // sq v1, 112(s3) + //beq r0, r0, L33 // beq r0, r0, L33 + // nop // sll r0, r0, 0 + goto block_16; // branch always + + +block_15: + c->daddiu(v1, s3, 96); // daddiu v1, s3, 96 + c->lwc1(f0, 32, s1); // lwc1 f0, 32(s1) + c->swc1(f0, 0, v1); // swc1 f0, 0(v1) + c->lwc1(f0, 36, s1); // lwc1 f0, 36(s1) + c->swc1(f0, 4, v1); // swc1 f0, 4(v1) + c->lwc1(f0, 40, s1); // lwc1 f0, 40(s1) + c->swc1(f0, 8, v1); // swc1 f0, 8(v1) + c->lwc1(f0, 44, s1); // lwc1 f0, 44(s1) + c->lwc1(f1, 4, s1); // lwc1 f1, 4(s1) + c->subs(f0, f0, f1); // sub.s f0, f0, f1 + c->swc1(f0, 12, v1); // swc1 f0, 12(v1) + c->daddiu(v1, s3, 112); // daddiu v1, s3, 112 + c->lwc1(f0, 48, s1); // lwc1 f0, 48(s1) + c->swc1(f0, 0, v1); // swc1 f0, 0(v1) + c->lwc1(f0, 52, s1); // lwc1 f0, 52(s1) + c->swc1(f0, 4, v1); // swc1 f0, 4(v1) + c->lwc1(f0, 56, s1); // lwc1 f0, 56(s1) + c->swc1(f0, 8, v1); // swc1 f0, 8(v1) + c->lwc1(f0, 60, s1); // lwc1 f0, 60(s1) + c->lwc1(f1, 4, s1); // lwc1 f1, 4(s1) + c->subs(f0, f0, f1); // sub.s f0, f0, f1 + c->swc1(f0, 12, v1); // swc1 f0, 12(v1) + +block_16: + c->lw(v1, 12, s1); // lw v1, 12(s1) + c->andi(v1, v1, 1); // andi v1, v1, 1 + if (((s64)c->sgpr64(v1)) == ((s64)0)) { // beql v1, r0, L34 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + goto block_20; + } + +// block_18: + c->load_symbol2(t9, cache.camera_pos); // lw t9, camera-pos(s7) + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(a0, v0); // or a0, v0, r0 + c->daddiu(v1, s3, 96); // daddiu v1, s3, 96 + c->lwc1(f0, 0, a0); // lwc1 f0, 0(a0) + c->lwc1(f1, 4, a0); // lwc1 f1, 4(a0) + c->lwc1(f2, 8, a0); // lwc1 f2, 8(a0) + c->lwc1(f3, 0, v1); // lwc1 f3, 0(v1) + c->lwc1(f4, 4, v1); // lwc1 f4, 4(v1) + c->lwc1(f5, 8, v1); // lwc1 f5, 8(v1) + + // Unknown instr: mula.s f0, f3 + // Unknown instr: madda.s f1, f4 + // Unknown instr: madd.s f0, f2, f5 + c->fprs[f0] = (c->fprs[f2] * c->fprs[f5]) + (c->fprs[f1] * c->fprs[f4]) + (c->fprs[f0] * c->fprs[f3]); + + c->mfc1(v1, f0); // mfc1 v1, f0 + c->mtc1(f0, v1); // mtc1 f0, v1 + c->lwc1(f1, 108, s3); // lwc1 f1, 108(s3) + c->negs(f1, f1); // neg.s f1, f1 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L34 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + if (bc) {goto block_20;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + +block_20: + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L41 + c->mov64(a0, s7); // or a0, s7, r0 + if (bc) {goto block_36;} // branch non-likely + + c->daddiu(a0, s3, 80); // daddiu a0, s3, 80 + c->daddiu(v1, s3, 96); // daddiu v1, s3, 96 + c->lwc1(f0, 0, a0); // lwc1 f0, 0(a0) + c->lwc1(f1, 4, a0); // lwc1 f1, 4(a0) + c->lwc1(f2, 8, a0); // lwc1 f2, 8(a0) + c->lwc1(f3, 0, v1); // lwc1 f3, 0(v1) + c->lwc1(f4, 4, v1); // lwc1 f4, 4(v1) + c->lwc1(f5, 8, v1); // lwc1 f5, 8(v1) + // Unknown instr: mula.s f0, f3 + // Unknown instr: madda.s f1, f4 + // Unknown instr: madd.s f0, f2, f5 + c->fprs[f0] = (c->fprs[f2] * c->fprs[f5]) + (c->fprs[f1] * c->fprs[f4]) + (c->fprs[f0] * c->fprs[f3]); + c->mfc1(v1, f0); // mfc1 v1, f0 + c->mtc1(f0, v1); // mtc1 f0, v1 + c->daddiu(a0, s3, 80); // daddiu a0, s3, 80 + c->daddiu(v1, s3, 112); // daddiu v1, s3, 112 + c->lwc1(f1, 0, a0); // lwc1 f1, 0(a0) + c->lwc1(f2, 4, a0); // lwc1 f2, 4(a0) + c->lwc1(f3, 8, a0); // lwc1 f3, 8(a0) + c->lwc1(f4, 0, v1); // lwc1 f4, 0(v1) + c->lwc1(f5, 4, v1); // lwc1 f5, 4(v1) + c->lwc1(f6, 8, v1); // lwc1 f6, 8(v1) + // Unknown instr: mula.s f1, f4 + // Unknown instr: madda.s f2, f5 + // Unknown instr: madd.s f1, f3, f6 + c->fprs[f1] = (c->fprs[f3] * c->fprs[f6]) + (c->fprs[f2] * c->fprs[f5]) + (c->fprs[f1] * c->fprs[f4]); + c->mfc1(v1, f1); // mfc1 v1, f1 + c->mtc1(f1, v1); // mtc1 f1, v1 + c->lwc1(f2, 108, s3); // lwc1 f2, 108(s3) + cop1_bc = c->fprs[f2] < c->fprs[f0]; // c.lt.s f2, f0 + bc = cop1_bc; // bc1t L35 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + if (bc) {goto block_23;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + +block_23: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(v1))) {// beql s7, v1, L36 + c->mov64(v1, v1); // or v1, v1, r0 + goto block_27; + } + +// block_25: + c->lwc1(f2, 124, s3); // lwc1 f2, 124(s3) + cop1_bc = c->fprs[f1] < c->fprs[f2]; // c.lt.s f1, f2 + bc = cop1_bc; // bc1t L36 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + if (bc) {goto block_27;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + +block_27: + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L38 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_31;} // branch non-likely + + c->mtc1(f2, r0); // mtc1 f2, r0 + c->lwc1(f3, 28, s1); // lwc1 f3, 28(s1) + cop1_bc = c->fprs[f2] < c->fprs[f3]; // c.lt.s f2, f3 + bc = !cop1_bc; // bc1f L37 + // nop // sll r0, r0, 0 + if (bc) {goto block_30;} // branch non-likely + + c->negs(f0, f0); // neg.s f0, f0 + c->swc1(f0, 108, s3); // swc1 f0, 108(s3) + c->mfc1(v1, f0); // mfc1 v1, f0 + //beq r0, r0, L38 // beq r0, r0, L38 + // nop // sll r0, r0, 0 + goto block_31; // branch always + + +block_30: + c->negs(f0, f1); // neg.s f0, f1 + c->swc1(f0, 124, s3); // swc1 f0, 124(s3) + c->mfc1(v1, f0); // mfc1 v1, f0 + +block_31: + c->lq(v1, 16, s1); // lq v1, 16(s1) + c->sq(v1, 144, s3); // sq v1, 144(s3) + c->daddiu(v1, s3, 128); // daddiu v1, s3, 128 + c->mtc1(f0, r0); // mtc1 f0, r0 + c->swc1(f0, 0, v1); // swc1 f0, 0(v1) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->swc1(f0, 4, v1); // swc1 f0, 4(v1) + c->lui(a0, 16256); // lui a0, 16256 + c->mtc1(f0, a0); // mtc1 f0, a0 + c->swc1(f0, 8, v1); // swc1 f0, 8(v1) + c->lui(a0, -16384); // lui a0, -16384 + c->mtc1(f0, a0); // mtc1 f0, a0 + c->load_symbol2(a0, cache.math_camera); // lw a0, *math-camera*(s7) + c->lwc1(f1, 0, a0); // lwc1 f1, 0(a0) + c->muls(f0, f0, f1); // mul.s f0, f0, f1 + c->swc1(f0, 12, v1); // swc1 f0, 12(v1) + c->daddiu(v1, s3, 176); // daddiu v1, s3, 176 + c->sw(v1, 16, s3); // sw v1, 16(s3) + c->daddiu(v1, s3, 48); // daddiu v1, s3, 48 + c->lhu(a0, 18, v1); // lhu a0, 18(v1) + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + c->sh(a0, 18, v1); // sh a0, 18(v1) + c->lw(v1, 12, s1); // lw v1, 12(s1) + c->andi(v1, v1, 64); // andi v1, v1, 64 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L39 + // nop // sll r0, r0, 0 + if (bc) {goto block_33;} // branch non-likely + + c->load_symbol2(t9, cache.shadow_xform_verts); // lw t9, shadow-xform-verts(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->load_symbol2(t9, cache.shadow_init_vars); // lw t9, shadow-init-vars(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->load_symbol2(t9, cache.shadow_add_verts); // lw t9, shadow-add-verts(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + c->addiu(a3, r0, 1); // addiu a3, r0, 1 + c->mov64(a2, gp); // or a2, gp, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(a2, v0); // or a2, v0, r0 + c->load_symbol2(t9, cache.shadow_add_single_tris);// lw t9, shadow-add-single-tris(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(gp, v0); // or gp, v0, r0 + c->mov64(a0, gp); // or a0, gp, r0 + //beq r0, r0, L41 // beq r0, r0, L41 + // nop // sll r0, r0, 0 + goto block_36; // branch always + + +block_33: + c->load_symbol2(t9, cache.shadow_xform_verts); // lw t9, shadow-xform-verts(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->load_symbol2(t9, cache.shadow_init_vars); // lw t9, shadow-init-vars(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->load_symbol2(t9, cache.shadow_calc_dual_verts);// lw t9, shadow-calc-dual-verts(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->lw(v1, 12, s1); // lw v1, 12(s1) + c->andi(v1, v1, 8); // andi v1, v1, 8 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L40 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_35;} // branch non-likely + + c->load_symbol2(t9, cache.shadow_scissor_top); // lw t9, shadow-scissor-top(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(v1, v0); // or v1, v0, r0 + +block_35: + c->load_symbol2(t9, cache.shadow_scissor_edges); // lw t9, shadow-scissor-edges(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->load_symbol2(t9, cache.shadow_find_facing_single_tris);// lw t9, shadow-find-facing-single-tris(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->load_symbol2(t9, cache.shadow_find_single_edges);// lw t9, shadow-find-single-edges(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->load_symbol2(t9, cache.shadow_find_facing_double_tris);// lw t9, shadow-find-facing-double-tris(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->load_symbol2(t9, cache.shadow_find_double_edges);// lw t9, shadow-find-double-edges(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->load_symbol2(t9, cache.shadow_add_verts); // lw t9, shadow-add-verts(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + c->mov64(a2, gp); // or a2, gp, r0 + c->addiu(a3, r0, 0); // addiu a3, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(a2, v0); // or a2, v0, r0 + c->load_symbol2(t9, cache.shadow_add_facing_single_tris);// lw t9, shadow-add-facing-single-tris(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(a2, v0); // or a2, v0, r0 + c->load_symbol2(t9, cache.shadow_add_single_edges);// lw t9, shadow-add-single-edges(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(a2, v0); // or a2, v0, r0 + c->load_symbol2(t9, cache.shadow_add_double_tris);// lw t9, shadow-add-double-tris(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(a2, v0); // or a2, v0, r0 + c->load_symbol2(t9, cache.shadow_add_double_edges);// lw t9, shadow-add-double-edges(s7) + c->mov64(a0, s2); // or a0, s2, r0 + c->mov64(a1, s3); // or a1, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(gp, v0); // or gp, v0, r0 + c->daddiu(v1, s3, 48); // daddiu v1, s3, 48 + c->lwu(a0, 0, v1); // lwu a0, 0(v1) + c->lwu(a1, 20, s3); // lwu a1, 20(s3) + c->daddu(a0, a0, a1); // daddu a0, a0, a1 + c->sw(a0, 0, v1); // sw a0, 0(v1) + c->lwu(a0, 4, v1); // lwu a0, 4(v1) + c->lhu(a1, 16, s2); // lhu a1, 16(s2) + c->daddu(a0, a0, a1); // daddu a0, a0, a1 + c->sw(a0, 4, v1); // sw a0, 4(v1) + c->lwu(a0, 8, v1); // lwu a0, 8(v1) + c->lwu(a1, 24, s3); // lwu a1, 24(s3) + c->daddu(a0, a0, a1); // daddu a0, a0, a1 + c->sw(a0, 8, v1); // sw a0, 8(v1) + c->lwu(a0, 12, v1); // lwu a0, 12(v1) + c->lwu(a1, 28, s3); // lwu a1, 28(s3) + c->daddu(a0, a0, a1); // daddu a0, a0, a1 + c->sw(a0, 12, v1); // sw a0, 12(v1) + +block_36: + c->lw(s4, 60, s4); // lw s4, 60(s4) + +block_37: + bc = c->sgpr64(s4) != 0; // bne s4, r0, L24 + // nop // sll r0, r0, 0 + if (bc) {goto block_1;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + c->mov64(v0, gp); // or v0, gp, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 96, sp); // lq gp, 96(sp) + c->lq(s5, 80, sp); // lq s5, 80(sp) + c->lq(s4, 64, sp); // lq s4, 64(sp) + c->lq(s3, 48, sp); // lq s3, 48(sp) + c->lq(s2, 32, sp); // lq s2, 32(sp) + c->lq(s1, 16, sp); // lq s1, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 112); // daddiu sp, sp, 112 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + cache.gsf_buffer = intern_from_c("*gsf-buffer*").c(); + cache.math_camera = intern_from_c("*math-camera*").c(); + cache.shadow_debug = intern_from_c("*shadow-debug*").c(); + cache.camera_pos = intern_from_c("camera-pos").c(); + cache.debug_draw_settings = intern_from_c("debug-draw-settings").c(); + cache.flush_cache = intern_from_c("flush-cache").c(); + cache.shadow_add_double_edges = intern_from_c("shadow-add-double-edges").c(); + cache.shadow_add_double_tris = intern_from_c("shadow-add-double-tris").c(); + cache.shadow_add_facing_single_tris = intern_from_c("shadow-add-facing-single-tris").c(); + cache.shadow_add_single_edges = intern_from_c("shadow-add-single-edges").c(); + cache.shadow_add_single_tris = intern_from_c("shadow-add-single-tris").c(); + cache.shadow_add_verts = intern_from_c("shadow-add-verts").c(); + cache.shadow_calc_dual_verts = intern_from_c("shadow-calc-dual-verts").c(); + cache.shadow_find_double_edges = intern_from_c("shadow-find-double-edges").c(); + cache.shadow_find_facing_double_tris = intern_from_c("shadow-find-facing-double-tris").c(); + cache.shadow_find_facing_single_tris = intern_from_c("shadow-find-facing-single-tris").c(); + cache.shadow_find_single_edges = intern_from_c("shadow-find-single-edges").c(); + cache.shadow_init_vars = intern_from_c("shadow-init-vars").c(); + cache.shadow_scissor_edges = intern_from_c("shadow-scissor-edges").c(); + cache.shadow_scissor_top = intern_from_c("shadow-scissor-top").c(); + cache.shadow_xform_verts = intern_from_c("shadow-xform-verts").c(); + gLinkedFunctionTable.reg("shadow-execute", execute, 256); +} + +} // namespace shadow_execute +} // namespace Mips2C \ No newline at end of file diff --git a/game/mips2c/jak2_functions/squid.cpp b/game/mips2c/jak2_functions/squid.cpp index bfd0f27fb1..f94c70b803 100644 --- a/game/mips2c/jak2_functions/squid.cpp +++ b/game/mips2c/jak2_functions/squid.cpp @@ -222,6 +222,7 @@ namespace Mips2C::jak2 { // Unknown instr: mula.s f0, f3 // Unknown instr: madda.s f1, f4 // Unknown instr: madd.s f0, f2, f5 + c->fprs[f0] = (c->fprs[f2] * c->fprs[f5]) + (c->fprs[f1] * c->fprs[f4]) + (c->fprs[f0] * c->fprs[f3]); c->mfc1(v1, f0); // mfc1 v1, f0 c->mtc1(f0, v1); // mtc1 f0, v1 c->mtc1(f1, r0); // mtc1 f1, r0 diff --git a/game/mips2c/mips2c_table.cpp b/game/mips2c/mips2c_table.cpp index 9f7ecd930e..a55db5afd7 100644 --- a/game/mips2c/mips2c_table.cpp +++ b/game/mips2c/mips2c_table.cpp @@ -237,7 +237,22 @@ namespace generic_warp_dest { extern void link(); } namespace generic_warp_envmap_dest { extern void link(); } namespace generic_no_light_proc { extern void link(); } namespace foreground_draw_hud { extern void link(); } - +namespace shadow_execute { extern void link(); } +namespace shadow_add_double_edges { extern void link(); } +namespace shadow_add_double_tris { extern void link(); } +namespace shadow_add_single_tris { extern void link(); } +namespace shadow_add_single_edges { extern void link(); } +namespace shadow_add_facing_single_tris { extern void link(); } +namespace shadow_add_verts { extern void link(); } +namespace shadow_find_double_edges { extern void link(); } +namespace shadow_find_facing_double_tris { extern void link(); } +namespace shadow_find_single_edges { extern void link(); } +namespace shadow_find_facing_single_tris { extern void link(); } +namespace shadow_init_vars { extern void link(); } +namespace shadow_scissor_top { extern void link(); } +namespace shadow_scissor_edges { extern void link(); } +namespace shadow_calc_dual_verts { extern void link(); } +namespace shadow_xform_verts { extern void link(); } } // clang-format on @@ -397,7 +412,16 @@ PerGameVersion>> gMips2C jak2::generic_prepare_dma_double::link, jak2::generic_prepare_dma_single::link, jak2::generic_warp_source_proc::link, jak2::generic_warp_dest_proc::link, jak2::generic_warp_dest::link, jak2::generic_warp_envmap_dest::link, - jak2::generic_no_light_proc::link}}}}; + jak2::generic_no_light_proc::link}}, + {"shadow-cpu", + {jak2::shadow_execute::link, jak2::shadow_add_double_edges::link, + jak2::shadow_add_double_tris::link, jak2::shadow_add_single_tris::link, + jak2::shadow_add_single_edges::link, jak2::shadow_add_facing_single_tris::link, + jak2::shadow_add_verts::link, jak2::shadow_find_double_edges::link, + jak2::shadow_find_facing_double_tris::link, jak2::shadow_find_single_edges::link, + jak2::shadow_find_facing_single_tris::link, jak2::shadow_init_vars::link, + jak2::shadow_scissor_top::link, jak2::shadow_scissor_edges::link, + jak2::shadow_calc_dual_verts::link, jak2::shadow_xform_verts::link}}}}; void LinkedFunctionTable::reg(const std::string& name, u64 (*exec)(void*), u32 stack_size) { const auto& it = m_executes.insert({name, {exec, Ptr()}}); diff --git a/goal_src/jak2/engine/draw/drawable.gc b/goal_src/jak2/engine/draw/drawable.gc index ee402d27c6..bc63f0aed5 100644 --- a/goal_src/jak2/engine/draw/drawable.gc +++ b/goal_src/jak2/engine/draw/drawable.gc @@ -1372,14 +1372,14 @@ (let ((v1-0 *shadow-globals*)) (dotimes (a0-0 2) (let ((a1-2 (-> v1-0 bucket a0-0))) - (set! (-> a1-2 first) (the-as uint 0)) - (set! (-> a1-2 next) (the-as uint 0)) + (set! (-> a1-2 first) (the-as pointer 0)) + (set! (-> a1-2 next) (the-as pointer 0)) (set! (-> a1-2 shadow-color) (if (zero? a0-0) (new 'static 'rgba :r #xf0 :g #xf0 :b #xf0 :a #x80) (the-as rgba (-> *setting-control* user-current spotlight-color)) ) ) - (set! (-> a1-2 constants) (the-as basic 0)) + (set! (-> a1-2 constants) (the-as shadow-vu1-constants 0)) ) ) ) @@ -1395,7 +1395,7 @@ (bones-mtx-calc-execute) ;; generic-merc/shadow have VU0/CPU parts that need bones, run them here. (generic-merc-execute-all gp-0) - ;;(shadow-execute-all gp-0) + (shadow-execute-all gp-0) ) (lightning-draw-all) (none) diff --git a/goal_src/jak2/engine/game/main.gc b/goal_src/jak2/engine/game/main.gc index df0279344e..4fd886049e 100644 --- a/goal_src/jak2/engine/game/main.gc +++ b/goal_src/jak2/engine/game/main.gc @@ -1569,6 +1569,9 @@ ) ) + ;; send alp to C++ for blackout + (put-display-env (-> *display* pmode alp)) + ;; blackout drawing (when (-> *setting-control* user-current render) (if (< (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) diff --git a/goal_src/jak2/engine/gfx/foreground/foreground.gc b/goal_src/jak2/engine/gfx/foreground/foreground.gc index 8b1732bb71..78864e98ba 100644 --- a/goal_src/jak2/engine/gfx/foreground/foreground.gc +++ b/goal_src/jak2/engine/gfx/foreground/foreground.gc @@ -564,7 +564,182 @@ ;; todo foreground-shadow ;;(define-extern foreground-shadow (function draw-control (inline-array pris-mtx) pointer pointer)) -(defun foreground-shadow ((arg0 draw-control) (arg1 (inline-array pris-mtx)) (arg2 pointer)) +(defun foreground-shadow ((draw-ctrl draw-control) (arg1 (inline-array pris-mtx)) (arg2 pointer)) + (local-vars (shadow-settings shadow-settings)) + (let ((shadow-geo (-> draw-ctrl shadow)) + (dist (-> (scratchpad-object foreground-work) distance w)) + ) + (set! shadow-settings + (cond + ((-> draw-ctrl shadow-ctrl) + (set! shadow-settings (-> draw-ctrl shadow-ctrl settings)) + (let ((t1-2 (the-as vector (+ (the-as uint (the-as vector (-> draw-ctrl skeleton bones 0 transform trans))) + (* (the-as uint 80) (-> draw-ctrl shadow-joint-index)) + ) + ) + ) + ) + (set! (-> shadow-settings center x) (-> t1-2 x)) + (set! (-> shadow-settings center y) (-> t1-2 y)) + (set! (-> shadow-settings center z) (-> t1-2 z)) + ) + shadow-settings + ) + (else + *default-shadow-settings* + ) + ) + ) + (let ((t1-5 (-> shadow-settings flags))) + (-> draw-ctrl cur-lod) + (when (not (logtest? t1-5 (shadow-flags disable-fade))) + (if (< (-> shadow-settings fade-dist) dist) + (set! t1-5 (logior t1-5 (shadow-flags disable-draw))) + ) + ) + (when (not (logtest? t1-5 (shadow-flags disable-draw))) + (cond + ((zero? (-> shadow-geo version)) + (let ((t1-6 (* (-> shadow-geo num-joints) 8)) + (t2-5 (&-> shadow-geo total-qwc)) + (t4-0 (-> shadow-geo total-qwc)) + ) + 0 + (let ((a3-2 (the-as object arg2))) + (set! (-> (the-as shadow-dma-packet a3-2) tag dma) (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id cnt))) + (set! (-> (the-as shadow-dma-packet a3-2) tag vif0) (the-as vif-tag t4-0)) + (set! (-> (the-as shadow-dma-packet a3-2) tag vif1) (new 'static 'vif-tag)) + (let ((t0-11 (-> *shadow-globals* bucket (-> shadow-settings shadow-type)))) + (let ((t3-2 (-> t0-11 next))) + (if (nonzero? t3-2) + (set! (-> (the-as (pointer shadow-dma-packet) t3-2) 0) (the-as shadow-dma-packet a3-2)) + ) + ) + (if (zero? (-> t0-11 first)) + (set! (-> t0-11 first) (the-as pointer a3-2)) + ) + (let ((t3-7 (&-> (the-as shadow-dma-packet a3-2) tag vif1))) + (let ((t5-1 (the-as object (-> (the-as shadow-dma-packet a3-2) settings))) + (t6-0 (-> shadow-settings center quad)) + (t7-0 (-> shadow-settings shadow-dir quad)) + (t8-0 (-> shadow-settings bot-plane quad)) + (t9-0 (-> shadow-settings top-plane quad)) + (v1-4 (-> shadow-settings flag-vector quad)) + ) + (set! (-> (the-as (inline-array vector) t5-1) 0 quad) t6-0) + (set! (-> (the-as (inline-array vector) t5-1) 1 quad) t7-0) + (set! (-> (the-as (inline-array vector) t5-1) 2 quad) t8-0) + (set! (-> (the-as (inline-array vector) t5-1) 3 quad) t9-0) + (set! (-> (the-as (inline-array vector) t5-1) 4 quad) v1-4) + ) + (let ((v1-7 + (the-as + vector + (+ (the-as uint (the-as vector (-> draw-ctrl skeleton bones 0 transform trans))) + (* (the-as uint 80) (-> draw-ctrl shadow-joint-index)) + ) + ) + ) + ) + (set! (-> (the-as shadow-dma-packet a3-2) settings center x) (-> v1-7 x)) + (set! (-> (the-as shadow-dma-packet a3-2) settings center y) (-> v1-7 y)) + (set! (-> (the-as shadow-dma-packet a3-2) settings center z) (-> v1-7 z)) + ) + (set! (-> (the-as shadow-dma-packet a3-2) geo-ref dma) + (new 'static 'dma-tag :id (dma-tag-id ref) :addr (the-as int t2-5) :qwc t4-0) + ) + (set! (-> (the-as shadow-dma-packet a3-2) geo-ref vif0) (new 'static 'vif-tag)) + (set! (-> (the-as shadow-dma-packet a3-2) geo-ref vif1) (new 'static 'vif-tag)) + (set! (-> (the-as shadow-dma-packet a3-2) mtx-ref dma) + (new 'static 'dma-tag :id (dma-tag-id ref) :addr (the-as int (-> arg1 2)) :qwc t1-6) + ) + (set! (-> (the-as shadow-dma-packet a3-2) mtx-ref vif0) (new 'static 'vif-tag)) + (set! (-> (the-as shadow-dma-packet a3-2) mtx-ref vif1) (new 'static 'vif-tag)) + (set! (-> (the-as shadow-dma-packet a3-2) end-tag dma) (new 'static 'dma-tag :id (dma-tag-id end))) + (set! (-> (the-as shadow-dma-packet a3-2) end-tag vif0) (new 'static 'vif-tag)) + (set! (-> (the-as shadow-dma-packet a3-2) end-tag vif1) (new 'static 'vif-tag)) + (set! arg2 (&+ arg2 144)) + (set! (-> t0-11 next) t3-7) + ) + ) + ) + ) + ) + (else + (let ((t0-13 (* (-> shadow-geo num-joints) 8))) + (dotimes (t1-7 (the-as int (-> shadow-geo num-fragments))) + (let ((t4-1 (-> shadow-geo frags t1-7 header)) + (t6-1 (-> shadow-geo frags t1-7 qwc)) + ) + 0 + (let ((t2-11 (the-as object arg2))) + (set! (-> (the-as shadow-dma-packet t2-11) tag dma) (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id cnt))) + (set! (-> (the-as shadow-dma-packet t2-11) tag vif0) (the-as vif-tag t6-1)) + (set! (-> (the-as shadow-dma-packet t2-11) tag vif1) (new 'static 'vif-tag)) + (let ((t3-12 (-> *shadow-globals* bucket (-> shadow-settings shadow-type)))) + (let ((t5-4 (-> t3-12 next))) + (if (nonzero? t5-4) + (set! (-> (the-as (pointer shadow-dma-packet) t5-4) 0) (the-as shadow-dma-packet t2-11)) + ) + ) + (if (zero? (-> t3-12 first)) + (set! (-> t3-12 first) (the-as pointer t2-11)) + ) + (let ((t5-9 (&-> (the-as shadow-dma-packet t2-11) tag vif1))) + (let ((t7-2 (the-as object (-> (the-as shadow-dma-packet t2-11) settings))) + (t8-1 (-> shadow-settings center quad)) + (t9-1 (-> shadow-settings shadow-dir quad)) + (plane (-> shadow-settings bot-plane quad)) ; (.lq ra-0 32 shadow-settings) + ) + (let ((gp-0 (-> shadow-settings top-plane quad)) + (s5-0 (-> shadow-settings flag-vector quad)) + ) + (set! (-> (the-as (inline-array vector) t7-2) 0 quad) t8-1) + (set! (-> (the-as (inline-array vector) t7-2) 1 quad) t9-1) + (set! (-> (the-as (inline-array vector) t7-2) 2 quad) plane) ; (the-as uint128 ra-0) + (set! (-> (the-as (inline-array vector) t7-2) 3 quad) gp-0) + (set! (-> (the-as (inline-array vector) t7-2) 4 quad) s5-0) + ) + ) + (let ((t7-5 + (the-as + vector + (+ (the-as uint (the-as vector (-> draw-ctrl skeleton bones 0 transform trans))) + (* (the-as uint 80) (-> draw-ctrl shadow-joint-index)) + ) + ) + ) + ) + (set! (-> (the-as shadow-dma-packet t2-11) settings center x) (-> t7-5 x)) + (set! (-> (the-as shadow-dma-packet t2-11) settings center y) (-> t7-5 y)) + (set! (-> (the-as shadow-dma-packet t2-11) settings center z) (-> t7-5 z)) + ) + (set! (-> (the-as shadow-dma-packet t2-11) geo-ref dma) + (new 'static 'dma-tag :id (dma-tag-id ref) :addr (the-as int t4-1) :qwc t6-1) + ) + (set! (-> (the-as shadow-dma-packet t2-11) geo-ref vif0) (new 'static 'vif-tag)) + (set! (-> (the-as shadow-dma-packet t2-11) geo-ref vif1) (new 'static 'vif-tag)) + (set! (-> (the-as shadow-dma-packet t2-11) mtx-ref dma) + (new 'static 'dma-tag :id (dma-tag-id ref) :addr (the-as int (-> arg1 2)) :qwc t0-13) + ) + (set! (-> (the-as shadow-dma-packet t2-11) mtx-ref vif0) (new 'static 'vif-tag)) + (set! (-> (the-as shadow-dma-packet t2-11) mtx-ref vif1) (new 'static 'vif-tag)) + (set! (-> (the-as shadow-dma-packet t2-11) end-tag dma) (new 'static 'dma-tag :id (dma-tag-id end))) + (set! (-> (the-as shadow-dma-packet t2-11) end-tag vif0) (new 'static 'vif-tag)) + (set! (-> (the-as shadow-dma-packet t2-11) end-tag vif1) (new 'static 'vif-tag)) + (&+! arg2 144) + (set! (-> t3-12 next) t5-9) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) arg2 ) diff --git a/goal_src/jak2/engine/gfx/foreground/shadow-cpu-h.gc b/goal_src/jak2/engine/gfx/foreground/shadow-cpu-h.gc index 42961bd2e7..6ee06083a7 100644 --- a/goal_src/jak2/engine/gfx/foreground/shadow-cpu-h.gc +++ b/goal_src/jak2/engine/gfx/foreground/shadow-cpu-h.gc @@ -19,6 +19,8 @@ (shdf07) ) +(declare-type shadow-vu1-constants structure) + ;; DECOMP BEGINS (deftype shadow-settings (structure) @@ -105,11 +107,11 @@ (deftype shadow-bucket (structure) - ((first uint32 :offset-assert 0) - (next uint32 :offset-assert 4) - (bucket-id int32 :offset-assert 8) - (shadow-color rgba :offset-assert 12) - (constants basic :offset-assert 16) + ((first pointer :offset-assert 0) + (next pointer :offset-assert 4) + (bucket-id int32 :offset-assert 8) + (shadow-color rgba :offset-assert 12) + (constants shadow-vu1-constants :offset-assert 16) ) :allow-misaligned :method-count-assert 9 @@ -253,10 +255,10 @@ ) ) -(define *shadow* (the-as object #f)) +(define *shadow* #f) -(define *shadow-object* (the-as object #f)) +(define *shadow-object* #f) -(define *shadow-debug* (the-as object #f)) +(define *shadow-debug* #f) (define *shadow-dma-buf* (new 'global 'dma-buffer 512)) diff --git a/goal_src/jak2/engine/gfx/foreground/shadow-cpu.gc b/goal_src/jak2/engine/gfx/foreground/shadow-cpu.gc index a10991f610..a89b1424b0 100644 --- a/goal_src/jak2/engine/gfx/foreground/shadow-cpu.gc +++ b/goal_src/jak2/engine/gfx/foreground/shadow-cpu.gc @@ -5,7 +5,790 @@ ;; name in dgo: shadow-cpu ;; dgos: ENGINE, GAME -;; temp +(define-extern shadow-vu1-patch-consts (function symbol int none)) +(define-extern shadow-vu1-init-buffer (function dma-buffer int none)) + +;; DECOMP BEGINS + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of shadow-geo ((obj shadow-geo)) + (the-as int (* (-> obj total-qwc) 16)) + ) + +(defmethod mem-usage shadow-geo ((obj shadow-geo) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 111 (-> arg0 length))) + (set! (-> arg0 data 110 name) "shadow-geo") + (+! (-> arg0 data 110 count) 1) + (let ((v1-6 (* (-> obj total-qwc) 16))) + (+! (-> arg0 data 110 used) v1-6) + (+! (-> arg0 data 110 total) (logand -16 (+ v1-6 15))) + ) + obj + ) + +(define *shadow-data* (new 'static 'shadow-data + :dma-unpack-template (new 'static 'dma-packet + :dma (new 'static 'dma-tag :id (dma-tag-id cnt)) + :vif0 (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1) + :vif1 (new 'static 'vif-tag :cmd (vif-cmd unpack-v4-32)) + ) + :dma-cnt (new 'static 'dma-tag :id (dma-tag-id cnt)) + :vif-unpack-v4-8 (new 'static 'vif-tag :cmd (vif-cmd unpack-v4-8)) + ) + ) + +(defun shadow-invert-z-buf ((arg0 dma-buffer)) + (let ((v1-0 (-> arg0 base))) + (let* ((a1-0 arg0) + (a2-0 (the-as object (-> a1-0 base))) + ) + (set! (-> (the-as dma-packet a2-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a2-0) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a2-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a1-0 base) (&+ (the-as pointer a2-0) 16)) + ) + (let* ((a1-1 arg0) + (a2-2 (the-as object (-> a1-1 base))) + ) + (set! (-> (the-as gs-gif-tag a2-2) tag) (new 'static 'gif-tag64 :nloop #x7 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag a2-2) regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))) + (set! (-> a1-1 base) (&+ (the-as pointer a2-2) 16)) + ) + (let ((t1-0 (-> arg0 base)) + (t0-0 512) + ) + 416 + (let ((a1-3 1792) + (a2-4 1840) + ) + 2304 + (let ((a3-5 2256) + (t0-1 (/ t0-0 32)) + ) + (set! (-> (the-as (pointer gs-reg) t1-0) 8) (gs-reg texflush)) + (set! (-> (the-as (pointer gs-reg64) t1-0) 0) (gs-reg64 prim)) + (set! (-> (the-as (pointer gs-reg) t1-0) 24) (gs-reg frame-1)) + (set! (-> (the-as (pointer gs-frame) t1-0) 2) (new 'static 'gs-frame :fbp #x130 :fbw #x8 :fbmsk #xff000000)) + (set! (-> (the-as (pointer gs-reg) t1-0) 40) (gs-reg zbuf-1)) + (set! (-> (the-as (pointer gs-zbuf) t1-0) 4) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1)) + (set! (-> (the-as (pointer gs-reg) t1-0) 56) (gs-reg test-1)) + (set! (-> (the-as (pointer gs-test) t1-0) 6) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg) t1-0) 72) (gs-reg alpha-1)) + (set! (-> (the-as (pointer gs-alpha) t1-0) 8) (new 'static 'gs-alpha :b #x1 :c #x2 :d #x2 :fix #x80)) + (set! (-> (the-as (pointer gs-reg) t1-0) 88) (gs-reg prim)) + (set! (-> (the-as (pointer gs-reg64) t1-0) 10) (gs-reg64 colclamp)) + (set! (-> (the-as (pointer gs-reg) t1-0) 104) (gs-reg rgbaq)) + (set! (-> (the-as (pointer gs-rgbaq) t1-0) 12) (new 'static 'gs-rgbaq :r #xff :g #xff :b #xff :q 1.0)) + (&+! (-> arg0 base) 112) + (let* ((t1-3 arg0) + (t2-12 (the-as object (-> t1-3 base))) + ) + (set! (-> (the-as gs-gif-tag t2-12) tag) + (new 'static 'gif-tag64 :eop #x1 :flg (gif-flag reg-list) :nreg #x2 :nloop t0-1) + ) + (set! (-> (the-as gs-gif-tag t2-12) regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id xyz2) :regs1 (gif-reg-id xyz2)) + ) + (set! (-> t1-3 base) (&+ (the-as pointer t2-12) 16)) + ) + (let ((t1-4 0)) + (dotimes (t2-14 t0-1) + (let* ((t3-3 arg0) + (t4-2 (-> t3-3 base)) + ) + (set! (-> (the-as (pointer gs-xyzf) t4-2) 0) (new 'static 'gs-xyzf :y (* a2-4 16) :x (* (+ t1-4 a1-3) 16))) + (set! (-> (the-as (pointer gs-xyzf) t4-2) 1) (new 'static 'gs-xyzf :y (* a3-5 16) :x (* (+ t1-4 32 a1-3) 16))) + (set! (-> t3-3 base) (&+ t4-2 16)) + ) + (+! t1-4 32) + ) + ) + ) + ) + ) + (nop!) + (nop!) + 0 + (let ((a1-9 (/ (the-as int (+ (- -16 (the-as int v1-0)) (the-as int (-> arg0 base)))) 16))) + (cond + ((nonzero? a1-9) + (logior! (-> (the-as (pointer uint64) v1-0) 0) (shr (shl a1-9 48) 48)) + (logior! (-> (the-as (pointer uint64) v1-0) 1) (shl (shr (shl a1-9 48) 48) 32)) + ) + (else + (set! (-> arg0 base) v1-0) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch pointer vs none. +(defun shadow-make-invert-buf () + (let ((gp-0 *shadow-dma-buf*)) + (let ((v1-0 gp-0)) + (set! (-> v1-0 base) (-> v1-0 data)) + (set! (-> v1-0 end) (&-> v1-0 data-buffer (-> v1-0 allocated-length))) + ) + (shadow-invert-z-buf gp-0) + (let ((v1-1 (the-as object (-> gp-0 base)))) + (set! (-> (the-as dma-packet v1-1) dma) (new 'static 'dma-tag :id (dma-tag-id ret))) + (set! (-> (the-as dma-packet v1-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet v1-1) vif1) (new 'static 'vif-tag)) + (set! (-> gp-0 base) (&+ (the-as pointer v1-1) 16)) + ) + ) + (none) + ) + +(shadow-make-invert-buf) + +(define *shadow-dma-invert-call* (the-as pointer #f)) + +;; WARN: Return type mismatch dma-buffer vs none. +(defun shadow-dma-init ((arg0 dma-buffer)) + (-> *display* on-screen) + (let ((a1-0 408)) + (* a1-0 32) + (let ((t3-0 512) + (t2-0 416) + (a2-0 1792) + (a3-0 1840) + ) + 2304 + (let ((t0-0 2256) + (t1-0 (/ t3-0 32)) + (t5-0 (* a3-0 16)) + ) + (set! *shadow-dma-invert-call* (-> arg0 base)) + (let* ((v1-6 arg0) + (t4-0 (the-as object (-> v1-6 base))) + ) + (set! (-> (the-as dma-packet t4-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet t4-0) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet t4-0) vif1) (new 'static 'vif-tag)) + (set! (-> v1-6 base) (&+ (the-as pointer t4-0) 16)) + ) + (let ((v1-7 (-> arg0 base))) + (let* ((t4-2 arg0) + (t6-1 (the-as object (-> t4-2 base))) + ) + (set! (-> (the-as dma-packet t6-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet t6-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet t6-1) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1)) + (set! (-> t4-2 base) (&+ (the-as pointer t6-1) 16)) + ) + (let* ((t4-3 arg0) + (t6-3 (the-as object (-> t4-3 base))) + ) + (set! (-> (the-as gs-gif-tag t6-3) tag) (new 'static 'gif-tag64 :nloop #xa :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag t6-3) regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))) + (set! (-> t4-3 base) (&+ (the-as pointer t6-3) 16)) + ) + (let ((t4-4 (-> arg0 base))) + (set! (-> (the-as (pointer gs-reg64) t4-4) 1) (gs-reg64 texflush)) + (set! (-> (the-as (pointer gs-reg64) t4-4) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-test) t4-4) 2) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) t4-4) 5) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer gs-alpha) t4-4) 4) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) t4-4) 7) (gs-reg64 frame-1)) + (set! (-> (the-as (pointer gs-frame) t4-4) 6) (new 'static 'gs-frame :fbw #x8 :fbmsk #xffffff :fbp a1-0)) + (set! (-> (the-as (pointer gs-reg64) t4-4) 9) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-zbuf) t4-4) 8) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1)) + (set! (-> (the-as (pointer gs-reg64) t4-4) 11) (gs-reg64 xyoffset-1)) + (set! (-> (the-as (pointer gs-xy-offset) t4-4) 10) (new 'static 'gs-xy-offset :ofx (* a2-0 16) :ofy t5-0)) + (set! (-> (the-as (pointer gs-reg64) t4-4) 13) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer gs-tex0) t4-4) 12) + (new 'static 'gs-tex0 :tbw #x8 :tw #x9 :th #x9 :tcc #x1 :tbp0 (* a1-0 32)) + ) + (set! (-> (the-as (pointer gs-reg) t4-4) 120) (gs-reg tex1-1)) + (set! (-> (the-as (pointer gs-tex1) t4-4) 14) (new 'static 'gs-tex1)) + (set! (-> (the-as (pointer gs-reg) t4-4) 136) (gs-reg miptbp1-1)) + (set! (-> (the-as (pointer gs-miptbp) t4-4) 16) (new 'static 'gs-miptbp)) + (set! (-> (the-as (pointer gs-reg) t4-4) 152) (gs-reg clamp-1)) + (set! (-> (the-as (pointer gs-clamp) t4-4) 18) (new 'static 'gs-clamp + :wms (gs-tex-wrap-mode region-clamp) + :wmt (gs-tex-wrap-mode region-clamp) + :maxv (+ t2-0 -1) + :maxu (+ t3-0 -1) + ) + ) + ) + (&+! (-> arg0 base) 160) + (let* ((t2-7 arg0) + (t3-5 (the-as object (-> t2-7 base))) + ) + (set! (-> (the-as gs-gif-tag t3-5) tag) + (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :flg (gif-flag reg-list) :nreg #x2) + ) + (set! (-> (the-as gs-gif-tag t3-5) regs) (new 'static 'gif-tag-regs :regs1 (gif-reg-id rgbaq))) + (set! (-> t2-7 base) (&+ (the-as pointer t3-5) 16)) + ) + (let* ((t2-8 arg0) + (t3-7 (-> t2-8 base)) + ) + (set! (-> (the-as (pointer gs-prim) t3-7) 0) (new 'static 'gs-prim :prim (gs-prim-type sprite))) + (set! (-> (the-as (pointer gs-rgbaq) t3-7) 1) (new 'static 'gs-rgbaq :a #x60)) + (set! (-> t2-8 base) (&+ t3-7 16)) + ) + (let* ((t2-9 arg0) + (t3-9 (the-as object (-> t2-9 base))) + ) + (set! (-> (the-as gs-gif-tag t3-9) tag) + (new 'static 'gif-tag64 :eop #x1 :flg (gif-flag reg-list) :nreg #x2 :nloop t1-0) + ) + (set! (-> (the-as gs-gif-tag t3-9) regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id xyz2) :regs1 (gif-reg-id xyz2)) + ) + (set! (-> t2-9 base) (&+ (the-as pointer t3-9) 16)) + ) + (let ((t2-10 0)) + (dotimes (t3-11 t1-0) + (let* ((t4-12 arg0) + (t5-12 (-> t4-12 base)) + ) + (set! (-> (the-as (pointer gs-xyzf) t5-12) 0) + (new 'static 'gs-xyzf :z #x1ffff :y (* a3-0 16) :x (* (+ a2-0 t2-10) 16)) + ) + (set! (-> (the-as (pointer gs-xyzf) t5-12) 1) + (new 'static 'gs-xyzf :z #x1ffff :y (* t0-0 16) :x (* (+ t2-10 32 a2-0) 16)) + ) + (set! (-> t4-12 base) (&+ t5-12 16)) + ) + (+! t2-10 32) + ) + ) + (let* ((a2-3 arg0) + (a3-1 (the-as object (-> a2-3 base))) + ) + (set! (-> (the-as gs-gif-tag a3-1) tag) (new 'static 'gif-tag64 :nloop #x4 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag a3-1) regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))) + (set! (-> a2-3 base) (&+ (the-as pointer a3-1) 16)) + ) + (cond + (*shadow-debug* + (let* ((a2-5 arg0) + (a3-3 (-> a2-5 base)) + ) + (set! (-> (the-as (pointer gs-test) a3-3) 0) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest greater-equal)) + ) + (set! (-> (the-as (pointer gs-reg64) a3-3) 1) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-zbuf) a3-3) 2) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (set! (-> (the-as (pointer gs-reg64) a3-3) 3) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-frame) a3-3) 4) (new 'static 'gs-frame :fbw #x8 :fbp a1-0)) + (set! (-> (the-as (pointer gs-reg64) a3-3) 5) (gs-reg64 frame-1)) + (set! (-> (the-as (pointer uint64) a3-3) 6) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a3-3) 7) (gs-reg64 texflush)) + (set! (-> a2-5 base) (&+ a3-3 64)) + ) + ) + (else + (let* ((a2-6 arg0) + (a3-4 (-> a2-6 base)) + ) + (set! (-> (the-as (pointer gs-test) a3-4) 0) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest greater-equal)) + ) + (set! (-> (the-as (pointer gs-reg64) a3-4) 1) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-zbuf) a3-4) 2) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1)) + (set! (-> (the-as (pointer gs-reg64) a3-4) 3) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-frame) a3-4) 4) (new 'static 'gs-frame :fbw #x8 :fbmsk #xffffff :fbp a1-0)) + (set! (-> (the-as (pointer gs-reg64) a3-4) 5) (gs-reg64 frame-1)) + (set! (-> (the-as (pointer uint64) a3-4) 6) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a3-4) 7) (gs-reg64 texflush)) + (set! (-> a2-6 base) (&+ a3-4 64)) + ) + ) + ) + (let ((a2-10 (/ (the-as int (+ (- -16 (the-as int v1-7)) (the-as int (-> arg0 base)))) 16))) + (cond + ((nonzero? a2-10) + (logior! (-> (the-as (pointer uint64) v1-7) 0) (shr (shl a2-10 48) 48)) + (logior! (-> (the-as (pointer uint64) v1-7) 1) (shl (shr (shl a2-10 48) 48) 32)) + ) + (else + (set! (-> arg0 base) v1-7) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch dma-buffer vs none. +(defun shadow-dma-end ((arg0 dma-buffer) (arg1 gs-rgbaq) (arg2 symbol) (arg3 int)) + (-> *display* on-screen) + (let ((s0-0 408)) + (* s0-0 32) + (let ((v1-4 512) + (s3-0 416) + (s5-0 1792) + (s4-0 1840) + ) + 2304 + 2256 + (let ((s2-0 (/ v1-4 32))) + (* s4-0 16) + (let ((v1-6 (the-as object *shadow-dma-invert-call*)) + (a0-3 *shadow-dma-buf*) + ) + (cond + (arg2 + (set! (-> (the-as (pointer uint64) v1-6)) (logior #x50000000 (shr (shl (the-as int (-> a0-3 data)) 33) 1))) + (set! (-> (the-as (pointer uint64) v1-6) 1) (the-as uint 0)) + (let* ((v1-7 arg0) + (a1-3 (the-as object (-> v1-7 base))) + ) + (set! (-> (the-as dma-packet a1-3) dma) + (new 'static 'dma-tag :id (dma-tag-id call) :addr (the-as int (-> a0-3 data))) + ) + (set! (-> (the-as dma-packet a1-3) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a1-3) vif1) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1)) + (set! (-> v1-7 base) (&+ (the-as pointer a1-3) 16)) + ) + ) + (else + (set! (-> (the-as dma-packet v1-6) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as (pointer uint64) v1-6) 1) (the-as uint 0)) + 0 + ) + ) + ) + (shadow-vu1-patch-consts arg2 arg3) + (let* ((v1-10 arg0) + (a0-12 (the-as object (-> v1-10 base))) + ) + (set! (-> (the-as dma-packet a0-12) dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-12) vif0) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1)) + (set! (-> (the-as dma-packet a0-12) vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-10 base) (&+ (the-as pointer a0-12) 16)) + ) + (let* ((v1-11 arg0) + (a0-14 (the-as object (-> v1-11 base))) + ) + (set! (-> (the-as gs-gif-tag a0-14) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x5)) + (set! (-> (the-as gs-gif-tag a0-14) regs) GIF_REGS_ALL_AD) + (set! (-> v1-11 base) (&+ (the-as pointer a0-14) 16)) + ) + (let* ((v1-12 arg0) + (a0-16 (-> v1-12 base)) + ) + (set! (-> (the-as (pointer uint64) a0-16) 0) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a0-16) 1) (gs-reg64 texflush)) + (set! (-> (the-as (pointer gs-test) a0-16) 2) + (new 'static 'gs-test :ate #x1 :atst (gs-atest not-equal) :aref #x60 :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a0-16) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-frame) a0-16) 4) (new 'static 'gs-frame :fbw #x8 :fbp s0-0)) + (set! (-> (the-as (pointer gs-reg64) a0-16) 5) (gs-reg64 frame-1)) + (set! (-> (the-as (pointer uint64) a0-16) 6) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a0-16) 7) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer uint64) a0-16) 8) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a0-16) 9) (gs-reg64 texflush)) + (set! (-> v1-12 base) (&+ a0-16 80)) + ) + (let ((v1-13 (-> arg0 base))) + (let* ((a0-18 arg0) + (a1-19 (the-as object (-> a0-18 base))) + ) + (set! (-> (the-as dma-packet a1-19) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a1-19) vif0) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1)) + (set! (-> (the-as dma-packet a1-19) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a0-18 base) (&+ (the-as pointer a1-19) 16)) + ) + (let* ((a0-19 arg0) + (a1-21 (the-as object (-> a0-19 base))) + ) + (set! (-> (the-as gs-gif-tag a1-21) tag) + (new 'static 'gif-tag64 :nloop #x1 :flg (gif-flag reg-list) :nreg #x2) + ) + (set! (-> (the-as gs-gif-tag a1-21) regs) (new 'static 'gif-tag-regs :regs1 (gif-reg-id rgbaq))) + (set! (-> (the-as (pointer gs-prim) a1-21) 2) + (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :abe #x1) + ) + (set! (-> (the-as (pointer gs-rgbaq) a1-21) 3) arg1) + (set! (-> (the-as (inline-array gs-gif-tag) a1-21) 2 tag) + (new 'static 'gif-tag64 :eop #x1 :flg (gif-flag reg-list) :nreg #x4 :nloop s2-0) + ) + (set! (-> (the-as (inline-array gs-gif-tag) a1-21) 2 regs) (new 'static 'gif-tag-regs + :regs0 (gif-reg-id st) + :regs1 (gif-reg-id xyz2) + :regs2 (gif-reg-id st) + :regs3 (gif-reg-id xyz2) + ) + ) + (set! (-> a0-19 base) (&+ (the-as pointer a1-21) 48)) + ) + (let ((a0-20 0) + (a1-23 0) + ) + (dotimes (a2-12 s2-0) + (let ((t1-0 a0-20)) + (+! a0-20 32) + (let* ((a3-3 arg0) + (t0-4 (-> a3-3 base)) + ) + (set! (-> (the-as (pointer uint64) t0-4) 0) + (the-as + uint + (logior (shl (the-as int (* 0.001953125 (+ 0.5 (the float a1-23)))) 32) + (shr (shl (the-as int (* 0.001953125 (+ 0.5 (the float t1-0)))) 32) 32) + ) + ) + ) + (set! (-> (the-as (pointer uint64) t0-4) 1) + (the-as + uint + (logior (logior (shl #x1ffff 32) (shr (shl (* (+ s5-0 t1-0) 16) 48) 48)) + (shr (shl (* (+ s4-0 a1-23) 16) 48) 32) + ) + ) + ) + (set! (-> (the-as (pointer uint64) t0-4) 2) + (the-as + uint + (logior (shl (the-as int (* 0.001953125 (+ 0.5 (the float s3-0)))) 32) + (shr (shl (the-as int (* 0.001953125 (+ 0.5 (the float a0-20)))) 32) 32) + ) + ) + ) + (set! (-> (the-as (pointer uint64) t0-4) 3) + (the-as uint (logior (logior (shl #x1ffff 32) (shr (shl (* (+ s5-0 a0-20) 16) 48) 48)) + (shr (shl (* (+ s4-0 s3-0) 16) 48) 32) + ) + ) + ) + (set! (-> a3-3 base) (&+ t0-4 32)) + ) + ) + ) + ) + (let ((a1-27 (/ (the-as int (+ (- -16 (the-as int v1-13)) (the-as int (-> arg0 base)))) 16))) + (cond + ((nonzero? a1-27) + (logior! (-> (the-as (pointer uint64) v1-13) 0) (shr (shl a1-27 48) 48)) + (logior! (-> (the-as (pointer uint64) v1-13) 1) (shl (shr (shl a1-27 48) 48) 32)) + ) + (else + (set! (-> arg0 base) v1-13) + ) + ) + ) + ) + ) + ) + ) + (reset-display-gs-state *display* arg0) + (none) + ) + +(deftype shadow-stats (structure) + ((num-single-tris uint32 :offset-assert 0) + (num-double-tris uint32 :offset-assert 4) + (num-single-edges uint32 :offset-assert 8) + (num-double-edges uint32 :offset-assert 12) + (num-fragments uint16 :offset-assert 16) + (num-objects uint16 :offset-assert 18) + ) + :method-count-assert 9 + :size-assert #x14 + :flag-assert #x900000014 + ) + + +(deftype shadow-dcache (structure) + ((vtx-table uint32 :offset-assert 0) + (single-edge-table uint32 :offset-assert 4) + (double-edge-table uint32 :offset-assert 8) + (double-tri-table uint32 :offset-assert 12) + (dcache-top uint32 :offset-assert 16) + (num-facing-single-tris uint32 :offset-assert 20) + (num-single-edges uint32 :offset-assert 24) + (num-double-edges uint32 :offset-assert 28) + (single-tri-list uint32 :offset-assert 32) + (single-edge-list uint32 :offset-assert 36) + (double-edge-list uint32 :offset-assert 40) + (ptr-dual-verts uint32 :offset-assert 44) + (stats shadow-stats :inline :offset-assert 48) + (frag-qwc uint32 :offset-assert 68) + (center vector :inline :offset-assert 80) + (plane vector :inline :offset-assert 96) + (top-plane vector :inline :offset-assert 112) + (near-plane vector :inline :offset-assert 128) + (light-dir vector :inline :offset-assert 144) + (vtx-min vector :inline :offset-assert 160) + (data uint8 :dynamic :offset-assert 176) + ) + :method-count-assert 9 + :size-assert #xb0 + :flag-assert #x9000000b0 + ) + + +(define shadow-vu0-block (new 'static 'vu-function :length 88 :qlength 44)) + +(def-mips2c shadow-xform-verts function) + +(def-mips2c shadow-calc-dual-verts function) + +(def-mips2c shadow-scissor-edges function) + +(def-mips2c shadow-scissor-top function) + +(def-mips2c shadow-init-vars function) + +(def-mips2c shadow-find-facing-single-tris function) + +(def-mips2c shadow-find-single-edges function) + +(def-mips2c shadow-find-facing-double-tris function) + +(def-mips2c shadow-find-double-edges function) + +(def-mips2c shadow-add-verts function) + +(def-mips2c shadow-add-facing-single-tris function) + +(def-mips2c shadow-add-single-edges function) + +(def-mips2c shadow-add-single-tris function) + +(def-mips2c shadow-add-double-tris function) + +(def-mips2c shadow-add-double-edges function) + +(defmethod shadow-control-method-14 shadow-control ((obj shadow-control) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float) (arg4 float)) + (let ((gp-0 (-> obj settings))) + (let ((s4-0 (-> gp-0 shadow-dir))) + (vector-normalize-copy! s4-0 arg1 1.0) + (set! (-> gp-0 shadow-dir w) (- arg2)) + (when *shadow-debug* + (add-debug-x #t (bucket-id debug-no-zbuf1) arg0 *color-red*) + (add-debug-vector #t (bucket-id debug-no-zbuf1) arg0 s4-0 (meters 3) *color-red*) + ) + (let ((s1-2 (vector+float*! (new 'stack-no-clear 'vector) arg0 s4-0 arg3)) + (s5-2 (vector+float*! (new 'stack-no-clear 'vector) arg0 s4-0 arg4)) + ) + (vector-negate! (-> gp-0 top-plane) s4-0) + (vector-negate! (-> gp-0 bot-plane) s4-0) + (set! (-> gp-0 top-plane w) (- (vector-dot s1-2 (the-as vector (-> gp-0 top-plane))))) + (set! (-> gp-0 bot-plane w) (- (vector-dot s5-2 (the-as vector (-> gp-0 bot-plane))))) + ) + ) + (logior! (-> gp-0 flags) (shadow-flags shdf02 shdf03 shdf04 shdf07)) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun debug-draw-settings ((arg0 matrix)) + (let ((v1-0 (-> arg0 vector 1)) + (a2-0 (-> arg0 vector)) + (s5-0 (-> arg0 trans)) + (s4-0 (-> arg0 vector 2)) + (s3-0 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (cond + ((logtest? (the-as int (-> arg0 vector 0 w)) 4) + (vector+float*! s3-0 (the-as vector a2-0) v1-0 (- (vector-dot s5-0 (the-as vector a2-0)) (-> s5-0 w))) + (vector+float*! s2-0 (the-as vector a2-0) v1-0 (- (vector-dot s4-0 (the-as vector a2-0)) (-> s4-0 w))) + ) + (else + (let ((a0-8 (vector+float*! (new 'stack-no-clear 'vector) (the-as vector a2-0) v1-0 (-> v1-0 w)))) + (vector+float*! s3-0 a0-8 v1-0 (- (vector-dot s5-0 a0-8) (-> s5-0 w))) + (vector+float*! s2-0 a0-8 v1-0 (- (vector-dot s4-0 a0-8) (-> s4-0 w))) + ) + ) + ) + (add-debug-sphere #t (bucket-id debug-no-zbuf1) (the-as vector a2-0) (meters 0.8) *color-magenta*) + (add-debug-x #t (bucket-id debug-no-zbuf1) s3-0 *color-blue*) + (add-debug-vector #t (bucket-id debug-no-zbuf1) s3-0 s5-0 (meters 2) *color-blue*) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + (the-as vector (-> arg0 vector)) + s3-0 + *color-magenta* + #f + (the-as rgba -1) + ) + (add-debug-x #t (bucket-id debug-no-zbuf1) s2-0 *color-green*) + (add-debug-vector #t (bucket-id debug-no-zbuf1) s2-0 s4-0 (meters 2) *color-green*) + (add-debug-line #t (bucket-id debug-no-zbuf1) s3-0 s2-0 *color-green* #f (the-as rgba -1)) + ) + (none) + ) + +(def-mips2c shadow-execute (function shadow-dma-packet pointer pointer)) + +(defun shadow-vu0-upload () + (#unless PC_PORT + (let ((gp-0 *vu0-dma-list*)) + (let ((v1-0 gp-0)) + (set! (-> v1-0 base) (-> v1-0 data)) + (set! (-> v1-0 end) (&-> v1-0 data-buffer (-> v1-0 allocated-length))) + ) + (dma-buffer-add-vu-function gp-0 shadow-vu0-block 0) + (let* ((v1-1 gp-0) + (a0-5 (the-as object (-> v1-1 base))) + ) + (set! (-> (the-as dma-packet a0-5) dma) (new 'static 'dma-tag :id (dma-tag-id end))) + (s.d! (+ (the-as dma-packet a0-5) 8) 0) + (set! (-> v1-1 base) (&+ (the-as pointer a0-5) 16)) + ) + (.sync.l) + (dma-buffer-send-chain (the-as dma-bank-source #x10008000) gp-0) + ) + ) + 0 + (none) + ) + +;; ERROR: Failed store: (s.h! (+ v1-24 18) 0) at op 58 +(defun shadow-execute-all ((arg0 dma-buffer)) + (when *debug-segment* + (let ((gp-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-7 'shadow) + (s5-0 *profile-shadow-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-0 (-> gp-0 data (-> gp-0 count)))) + (let ((s3-0 (-> gp-0 base-time))) + (set! (-> s4-0 name) v1-7) + (set! (-> s4-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-0)))) + ) + (set! (-> s4-0 depth) (the-as uint (-> gp-0 depth))) + (set! (-> s4-0 color) s5-0) + (set! (-> gp-0 segment (-> gp-0 depth)) s4-0) + ) + (+! (-> gp-0 count) 1) + (+! (-> gp-0 depth) 1) + (set! (-> gp-0 max-depth) (max (-> gp-0 max-depth) (-> gp-0 depth))) + ) + ) + 0 + ) + (when (logtest? (vu1-renderer-mask shadow) (-> *display* vu1-enable-user)) + (let ((gp-1 *shadow-globals*)) + (let ((v1-24 (the-as shadow-dcache (-> (the-as shadow-dcache *gsf-buffer*) stats)))) + (set! (-> v1-24 vtx-table) (the-as uint 0)) + (set! (-> v1-24 single-edge-table) (the-as uint 0)) + (set! (-> v1-24 double-edge-table) (the-as uint 0)) + (set! (-> v1-24 double-tri-table) (the-as uint 0)) + ; (s.h! (+ v1-24 18) 0) + ; (s.h! (+ v1-24 16) 0) + (set! (-> v1-24 dcache-top) (the-as uint 0)) + ) + 0 + (let ((v1-26 #f)) + (dotimes (a0-10 2) + (if (nonzero? (-> gp-1 bucket a0-10 first)) + (set! v1-26 #t) + ) + ) + (when v1-26 + (shadow-vu0-upload) + (dotimes (s5-1 2) + (let* ((s2-0 (-> gp-1 bucket s5-1)) + (s1-0 (-> s2-0 first)) + ) + (when (nonzero? s1-0) + (with-dma-buffer-add-bucket ((s3-1 (-> *display* frames (-> *display* on-screen) global-buf)) + (if (zero? s5-1) + (bucket-id shadow) + (bucket-id shadow2) + ) + ) + (set! (-> (scratchpad-object shadow-dcache) ptr-dual-verts) (the-as uint 0)) + (shadow-vu1-init-buffer s3-1 s5-1) + (flush-cache 0) + (shadow-dma-init s3-1) + (set! (-> s3-1 base) (shadow-execute (the-as shadow-dma-packet s1-0) (-> s3-1 base))) + (let ((a2-1 (nonzero? (-> (scratchpad-object shadow-dcache) ptr-dual-verts)))) + (let ((a1-9 (logior (shl #x3f800000 32) (shr (shl (the-as int (the-as uint32 (-> s2-0 shadow-color))) 32) 32)))) + (let ((v1-42 (-> *time-of-day-context* current-shadow-color))) + (if (zero? s5-1) + (set! a1-9 + (logior (logand (logior (logand (logior (logand a1-9 -256) (shr (shl (the int (* 128.0 (-> v1-42 x))) 56) 56)) -65281) + (shr (shl (the int (* 128.0 (-> v1-42 y))) 56) 48) + ) + -16711681 + ) + (shr (shl (the int (* 128.0 (-> v1-42 z))) 56) 40) + ) + ) + ) + ) + ;; modified in pc port so we don't have to do the crazy z buffer flipping stuff. + (shadow-dma-end s3-1 (the-as gs-rgbaq a1-9) #f #|a2-1|# s5-1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let ((gp-2 (the-as shadow-dcache *gsf-buffer*))) + (let ((v1-59 (-> *terrain-stats* shadow))) + (+! (-> v1-59 groups) (-> gp-2 stats num-objects)) + (+! (-> v1-59 fragments) (-> gp-2 stats num-objects)) + (+! (-> v1-59 tris) + (* (+ (-> gp-2 stats num-single-tris) + (-> gp-2 stats num-double-tris) + (-> gp-2 stats num-single-edges) + (-> gp-2 stats num-double-edges) + ) + 2 + ) + ) + (+! (-> v1-59 dverts) ;; manually patched + (+ (* (the-as uint 6) (-> gp-2 stats num-single-tris)) + (* (the-as uint 6) (-> gp-2 stats num-double-tris)) + (* (-> gp-2 stats num-single-edges) 4) + (* (-> gp-2 stats num-double-edges) 4) + ) + ) + ) + (when #f + (format *stdcon* "~%~%~%~%#single tris : ~4d~%" (-> gp-2 stats num-single-tris)) + (format *stdcon* "#double tris : ~4d~%" (-> gp-2 stats num-double-tris)) + (format *stdcon* "#single edges: ~4d~%" (-> gp-2 stats num-single-edges)) + (format *stdcon* "#double edges: ~4d~%" (-> gp-2 stats num-double-edges)) + ) + ) + ) + (when *debug-segment* + (let ((gp-3 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-73 (+ (-> gp-3 depth) -1)) + (s5-2 (-> gp-3 segment v1-73)) + (s4-2 (-> gp-3 base-time)) + ) + (when (>= v1-73 0) + (set! (-> s5-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-2)))) + (+! (-> gp-3 depth) -1) + ) + ) + ) + ) + 0 + ) + 0 + (none) + ) (defmethod shadow-control-method-13 shadow-control ((obj shadow-control) (arg0 vector) (arg1 float) (arg2 float) (arg3 float)) (with-pp @@ -48,30 +831,3 @@ (none) ) ) - -(defmethod shadow-control-method-14 shadow-control ((obj shadow-control) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float) (arg4 float)) - (let ((gp-0 (-> obj settings))) - (let ((s4-0 (-> gp-0 shadow-dir))) - (vector-normalize-copy! s4-0 arg1 1.0) - (set! (-> gp-0 shadow-dir w) (- arg2)) - (when *shadow-debug* - (add-debug-x #t (bucket-id debug-no-zbuf1) arg0 *color-red*) - (add-debug-vector #t (bucket-id debug-no-zbuf1) arg0 s4-0 (meters 3) *color-red*) - ) - (let ((s1-2 (vector+float*! (new 'stack-no-clear 'vector) arg0 s4-0 arg3)) - (s5-2 (vector+float*! (new 'stack-no-clear 'vector) arg0 s4-0 arg4)) - ) - (vector-negate! (-> gp-0 top-plane) s4-0) - (vector-negate! (-> gp-0 bot-plane) s4-0) - (set! (-> gp-0 top-plane w) (- (vector-dot s1-2 (the-as vector (-> gp-0 top-plane))))) - (set! (-> gp-0 bot-plane w) (- (vector-dot s5-2 (the-as vector (-> gp-0 bot-plane))))) - ) - ) - (logior! (-> gp-0 flags) (shadow-flags shdf02 shdf03 shdf04 shdf07)) - ) - 0 - (none) - ) - -;; DECOMP BEGINS - diff --git a/goal_src/jak2/engine/gfx/foreground/shadow-vu1.gc b/goal_src/jak2/engine/gfx/foreground/shadow-vu1.gc index fbed5e2517..1aef8b8a7a 100644 --- a/goal_src/jak2/engine/gfx/foreground/shadow-vu1.gc +++ b/goal_src/jak2/engine/gfx/foreground/shadow-vu1.gc @@ -7,3 +7,228 @@ ;; DECOMP BEGINS +(deftype shadow-vu1-constants (structure) + ((hmgescale vector :inline :offset-assert 0) + (invhscale vector :inline :offset-assert 16) + (texoffset vector :inline :offset-assert 32) + (texscale vector :inline :offset-assert 48) + (hvdfoff vector :inline :offset-assert 64) + (fog vector :inline :offset-assert 80) + (clrs vector 2 :inline :offset-assert 96) + (adgif gs-gif-tag :inline :offset-assert 128) + (texflush gs-adcmd :inline :offset-assert 144) + (flush gs-adcmd :inline :offset-assert 160) + (trigif gs-gif-tag :inline :offset-assert 176) + (quadgif gs-gif-tag :inline :offset-assert 192) + ) + :method-count-assert 9 + :size-assert #xd0 + :flag-assert #x9000000d0 + ) + + +(deftype shadow-vu1-data (structure) + ((adgif gs-gif-tag :inline :offset-assert 0) + (ad gs-adcmd :inline :offset-assert 16) + (flush gs-adcmd :inline :offset-assert 32) + (trigif gs-gif-tag :inline :offset-assert 48) + (quadgif gs-gif-tag :inline :offset-assert 64) + (texoffset vector :inline :offset-assert 80) + (texscale vector :inline :offset-assert 96) + (clrs qword 2 :inline :offset-assert 112) + ) + :method-count-assert 9 + :size-assert #x90 + :flag-assert #x900000090 + ) + + +(define *shadow-vu1-data* (new 'static 'shadow-vu1-data + :adgif (new 'static 'gs-gif-tag + :tag (new 'static 'gif-tag64 :nloop #x1 :nreg #x1) + :regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d)) + ) + :ad (new 'static 'gs-adcmd :cmds (gs-reg64 texflush)) + :flush (new 'static 'gs-adcmd :cmds (gs-reg64 rgbaq) :y #x3f800000) + :trigif (new 'static 'gs-gif-tag + :tag (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1) + :nreg #x7 + ) + :regs (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id st) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id st) + :regs4 (gif-reg-id xyzf2) + :regs5 (gif-reg-id st) + :regs6 (gif-reg-id xyzf2) + ) + ) + :quadgif (new 'static 'gs-gif-tag + :tag (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1) + :nreg #x9 + ) + :regs (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id st) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id st) + :regs4 (gif-reg-id xyzf2) + :regs5 (gif-reg-id st) + :regs6 (gif-reg-id xyzf2) + :regs7 (gif-reg-id st) + :regs8 (gif-reg-id xyzf2) + ) + ) + :texoffset (new 'static 'vector :x 256.5 :y 208.5) + :texscale (new 'static 'vector :x 0.001953125 :y 0.001953125) + :clrs (new 'static 'inline-array qword 2 + (new 'static 'qword :data (new 'static 'array uint32 4 #x80 #x0 #x0 #x82)) + (new 'static 'qword :data (new 'static 'array uint32 4 #x0 #x80 #x0 #x7f)) + ) + ) + ) + +(define shadow-vu1-block (new 'static 'vu-function #|:length #x2e9 :qlength #x175|#)) + +;; WARN: Return type mismatch dma-buffer vs none. +(defun shadow-vu1-add-constants ((arg0 dma-buffer) (arg1 int)) + (let* ((a3-0 13) + (v1-0 arg0) + (a2-0 (the-as object (-> v1-0 base))) + ) + (set! (-> (the-as dma-packet a2-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc a3-0)) + (set! (-> (the-as dma-packet a2-0) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))) + (set! (-> (the-as dma-packet a2-0) vif1) + (new 'static 'vif-tag :imm #x370 :cmd (vif-cmd unpack-v4-32) :num a3-0) + ) + (set! (-> v1-0 base) (the-as pointer (&+ (the-as dma-packet a2-0) 16))) + ) + (let ((v1-1 (the-as object (-> arg0 base)))) + (let ((a3-4 *math-camera*) + (a2-2 *shadow-vu1-data*) + ) + (set! (-> (the-as shadow-vu1-constants v1-1) hmgescale quad) (-> a3-4 hmge-scale quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) invhscale quad) (-> a3-4 inv-hmge-scale quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) hvdfoff quad) (-> a3-4 hvdf-off quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) hvdfoff x) 2048.0) + (set! (-> (the-as shadow-vu1-constants v1-1) hvdfoff y) 2048.0) + (set! (-> (the-as shadow-vu1-constants v1-1) fog x) (-> a3-4 pfog0)) + (set! (-> (the-as shadow-vu1-constants v1-1) clrs 0 quad) (-> a2-2 clrs 0 quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) clrs 1 quad) (-> a2-2 clrs 1 quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) texoffset quad) (-> a2-2 texoffset quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) texscale quad) (-> a2-2 texscale quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) adgif qword) (-> a2-2 adgif qword)) + (set! (-> (the-as shadow-vu1-constants v1-1) texflush quad) (-> a2-2 ad quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) flush quad) (-> a2-2 flush quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) trigif qword) (-> a2-2 trigif qword)) + (set! (-> (the-as shadow-vu1-constants v1-1) quadgif qword) (-> a2-2 quadgif qword)) + ) + (set! (-> *shadow-globals* bucket arg1 constants) (the-as shadow-vu1-constants v1-1)) + ) + (&+! (-> arg0 base) 208) + (let* ((v1-4 arg0) + (a1-3 (the-as object (-> v1-4 base))) + ) + (set! (-> (the-as dma-packet a1-3) dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a1-3) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))) + (set! (-> (the-as dma-packet a1-3) vif1) + (new 'static 'vif-tag :imm #x3ac :num #x4 :cmd (vif-cmd unpack-v4-32)) + ) + (set! (-> v1-4 base) (&+ (the-as pointer a1-3) 16)) + ) + (let* ((v1-5 arg0) + (a1-5 (the-as object (-> v1-5 base))) + ) + (set! (-> (the-as shadow-vu1-data a1-5) adgif tag) (new 'static 'gif-tag64 :nloop #x1 :nreg #x2)) + (set! (-> (the-as shadow-vu1-data a1-5) adgif regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d) :regs1 (gif-reg-id rgbaq)) + ) + (set! (-> (the-as shadow-vu1-data a1-5) ad data) (the-as uint 0)) + (set! (-> (the-as shadow-vu1-data a1-5) ad cmds) (gs-reg64 texflush)) + (set! (-> (the-as shadow-vu1-data a1-5) flush data) (the-as uint 0)) + (set! (-> (the-as shadow-vu1-data a1-5) flush cmds) (gs-reg64 prim)) + (set! (-> (the-as shadow-vu1-data a1-5) trigif tag) + (new 'static 'gif-tag64 + :nloop #x3 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1) + :nreg #x2 + ) + ) + (set! (-> (the-as shadow-vu1-data a1-5) trigif regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id xyzf2)) + ) + (set! (-> v1-5 base) (&+ (the-as pointer a1-5) 64)) + ) + (none) + ) + +(defun shadow-vu1-patch-consts ((arg0 symbol) (arg1 int)) + (let ((v1-2 (-> *shadow-globals* bucket arg1 constants))) + (cond + (arg0 + (set! (-> v1-2 hvdfoff z) (- 1.0 (-> v1-2 hvdfoff z))) + (set! (-> v1-2 fog w) -1.0) + ) + (else + (set! (-> v1-2 fog w) 1.0) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch dma-buffer vs none. +(defun shadow-vu1-add-matrix ((arg0 dma-buffer) (arg1 math-camera)) + (let ((v1-0 4)) + (let* ((a2-4 arg0) + (a3-0 (the-as object (-> a2-4 base))) + ) + (set! (-> (the-as dma-packet a3-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-0)) + (set! (-> (the-as dma-packet a3-0) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))) + (set! (-> (the-as dma-packet a3-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd unpack-v4-32) :num v1-0)) + (set! (-> a2-4 base) (&+ (the-as pointer a3-0) 16)) + ) + ) + (let ((v1-5 (the-as object (-> arg0 base)))) + (let ((a2-5 (-> arg1 perspective quad 0)) + (a3-1 (-> arg1 perspective quad 1)) + (t0-4 (-> arg1 perspective quad 2)) + (a1-1 (-> arg1 perspective trans quad)) + ) + (set! (-> (the-as matrix v1-5) quad 0) a2-5) + (set! (-> (the-as matrix v1-5) quad 1) a3-1) + (set! (-> (the-as matrix v1-5) quad 2) t0-4) + (set! (-> (the-as matrix v1-5) trans quad) a1-1) + ) + (set! (-> arg0 base) (&+ (the-as pointer v1-5) 64)) + ) + (none) + ) + +;; WARN: Return type mismatch dma-buffer vs none. +(defun shadow-vu1-init-buffer ((arg0 dma-buffer) (arg1 int)) + (dma-buffer-add-vu-function arg0 shadow-vu1-block 1) + (shadow-vu1-add-constants arg0 arg1) + (shadow-vu1-add-matrix arg0 *math-camera*) + (let* ((v1-0 arg0) + (a0-4 (the-as object (-> v1-0 base))) + ) + (set! (-> (the-as dma-packet a0-4) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-4) vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #xa)) + (set! (-> (the-as dma-packet a0-4) vif1) (new 'static 'vif-tag :cmd (vif-cmd flushe) :msk #x1)) + (set! (-> v1-0 base) (&+ (the-as pointer a0-4) 16)) + ) + (none) + ) diff --git a/goal_src/jak2/kernel-defs.gc b/goal_src/jak2/kernel-defs.gc index b714717dca..9660dd4c70 100644 --- a/goal_src/jak2/kernel-defs.gc +++ b/goal_src/jak2/kernel-defs.gc @@ -228,6 +228,8 @@ (define-extern kset-language (function language-enum int)) (define-extern syncv (function int int)) +(define-extern put-display-env (function object none)) + ;; +++memcard-h:mc-status-code (defenum mc-status-code :type uint32 diff --git a/test/decompiler/reference/jak2/engine/draw/drawable_REF.gc b/test/decompiler/reference/jak2/engine/draw/drawable_REF.gc index a52d2b4938..a614dcfe3a 100644 --- a/test/decompiler/reference/jak2/engine/draw/drawable_REF.gc +++ b/test/decompiler/reference/jak2/engine/draw/drawable_REF.gc @@ -1330,14 +1330,14 @@ (let ((v1-0 *shadow-globals*)) (dotimes (a0-0 2) (let ((a1-2 (-> v1-0 bucket a0-0))) - (set! (-> a1-2 first) (the-as uint 0)) - (set! (-> a1-2 next) (the-as uint 0)) + (set! (-> a1-2 first) (the-as pointer 0)) + (set! (-> a1-2 next) (the-as pointer 0)) (set! (-> a1-2 shadow-color) (if (zero? a0-0) (new 'static 'rgba :r #xf0 :g #xf0 :b #xf0 :a #x80) (the-as rgba (-> *setting-control* user-current spotlight-color)) ) ) - (set! (-> a1-2 constants) (the-as basic 0)) + (set! (-> a1-2 constants) (the-as shadow-vu1-constants 0)) ) ) ) @@ -2176,3 +2176,7 @@ (display-sync arg0) (none) ) + + + + diff --git a/test/decompiler/reference/jak2/engine/gfx/foreground/shadow-cpu_REF.gc b/test/decompiler/reference/jak2/engine/gfx/foreground/shadow-cpu_REF.gc new file mode 100644 index 0000000000..f6411e51cc --- /dev/null +++ b/test/decompiler/reference/jak2/engine/gfx/foreground/shadow-cpu_REF.gc @@ -0,0 +1,923 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 5 of type shadow-geo +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of shadow-geo ((obj shadow-geo)) + (the-as int (* (-> obj total-qwc) 16)) + ) + +;; definition for method 8 of type shadow-geo +(defmethod mem-usage shadow-geo ((obj shadow-geo) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 111 (-> arg0 length))) + (set! (-> arg0 data 110 name) "shadow-geo") + (+! (-> arg0 data 110 count) 1) + (let ((v1-6 (* (-> obj total-qwc) 16))) + (+! (-> arg0 data 110 used) v1-6) + (+! (-> arg0 data 110 total) (logand -16 (+ v1-6 15))) + ) + obj + ) + +;; definition for symbol *shadow-data*, type shadow-data +(define *shadow-data* (new 'static 'shadow-data + :dma-unpack-template (new 'static 'dma-packet + :dma (new 'static 'dma-tag :id (dma-tag-id cnt)) + :vif0 (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1) + :vif1 (new 'static 'vif-tag :cmd (vif-cmd unpack-v4-32)) + ) + :dma-cnt (new 'static 'dma-tag :id (dma-tag-id cnt)) + :vif-unpack-v4-8 (new 'static 'vif-tag :cmd (vif-cmd unpack-v4-8)) + ) + ) + +;; definition for function shadow-invert-z-buf +;; WARN: Return type mismatch int vs none. +(defun shadow-invert-z-buf ((arg0 dma-buffer)) + (let ((v1-0 (-> arg0 base))) + (let* ((a1-0 arg0) + (a2-0 (the-as object (-> a1-0 base))) + ) + (set! (-> (the-as dma-packet a2-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a2-0) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a2-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a1-0 base) (&+ (the-as pointer a2-0) 16)) + ) + (let* ((a1-1 arg0) + (a2-2 (the-as object (-> a1-1 base))) + ) + (set! (-> (the-as gs-gif-tag a2-2) tag) (new 'static 'gif-tag64 :nloop #x7 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag a2-2) regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))) + (set! (-> a1-1 base) (&+ (the-as pointer a2-2) 16)) + ) + (let ((t1-0 (-> arg0 base)) + (t0-0 512) + ) + 416 + (let ((a1-3 1792) + (a2-4 1840) + ) + 2304 + (let ((a3-5 2256) + (t0-1 (/ t0-0 32)) + ) + (set! (-> (the-as (pointer gs-reg) t1-0) 8) (gs-reg texflush)) + (set! (-> (the-as (pointer gs-reg64) t1-0) 0) (gs-reg64 prim)) + (set! (-> (the-as (pointer gs-reg) t1-0) 24) (gs-reg frame-1)) + (set! (-> (the-as (pointer gs-frame) t1-0) 2) (new 'static 'gs-frame :fbp #x130 :fbw #x8 :fbmsk #xff000000)) + (set! (-> (the-as (pointer gs-reg) t1-0) 40) (gs-reg zbuf-1)) + (set! (-> (the-as (pointer gs-zbuf) t1-0) 4) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1)) + (set! (-> (the-as (pointer gs-reg) t1-0) 56) (gs-reg test-1)) + (set! (-> (the-as (pointer gs-test) t1-0) 6) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg) t1-0) 72) (gs-reg alpha-1)) + (set! (-> (the-as (pointer gs-alpha) t1-0) 8) (new 'static 'gs-alpha :b #x1 :c #x2 :d #x2 :fix #x80)) + (set! (-> (the-as (pointer gs-reg) t1-0) 88) (gs-reg prim)) + (set! (-> (the-as (pointer gs-reg64) t1-0) 10) (gs-reg64 colclamp)) + (set! (-> (the-as (pointer gs-reg) t1-0) 104) (gs-reg rgbaq)) + (set! (-> (the-as (pointer gs-rgbaq) t1-0) 12) (new 'static 'gs-rgbaq :r #xff :g #xff :b #xff :q 1.0)) + (&+! (-> arg0 base) 112) + (let* ((t1-3 arg0) + (t2-12 (the-as object (-> t1-3 base))) + ) + (set! (-> (the-as gs-gif-tag t2-12) tag) + (new 'static 'gif-tag64 :eop #x1 :flg (gif-flag reg-list) :nreg #x2 :nloop t0-1) + ) + (set! (-> (the-as gs-gif-tag t2-12) regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id xyz2) :regs1 (gif-reg-id xyz2)) + ) + (set! (-> t1-3 base) (&+ (the-as pointer t2-12) 16)) + ) + (let ((t1-4 0)) + (dotimes (t2-14 t0-1) + (let* ((t3-3 arg0) + (t4-2 (-> t3-3 base)) + ) + (set! (-> (the-as (pointer gs-xyzf) t4-2) 0) (new 'static 'gs-xyzf :y (* a2-4 16) :x (* (+ t1-4 a1-3) 16))) + (set! (-> (the-as (pointer gs-xyzf) t4-2) 1) (new 'static 'gs-xyzf :y (* a3-5 16) :x (* (+ t1-4 32 a1-3) 16))) + (set! (-> t3-3 base) (&+ t4-2 16)) + ) + (+! t1-4 32) + ) + ) + ) + ) + ) + (nop!) + (nop!) + 0 + (let ((a1-9 (/ (the-as int (+ (- -16 (the-as int v1-0)) (the-as int (-> arg0 base)))) 16))) + (cond + ((nonzero? a1-9) + (logior! (-> (the-as (pointer uint64) v1-0) 0) (shr (shl a1-9 48) 48)) + (logior! (-> (the-as (pointer uint64) v1-0) 1) (shl (shr (shl a1-9 48) 48) 32)) + ) + (else + (set! (-> arg0 base) v1-0) + ) + ) + ) + ) + (none) + ) + +;; definition for function shadow-make-invert-buf +;; WARN: Return type mismatch pointer vs none. +(defun shadow-make-invert-buf () + (let ((gp-0 *shadow-dma-buf*)) + (let ((v1-0 gp-0)) + (set! (-> v1-0 base) (-> v1-0 data)) + (set! (-> v1-0 end) (&-> v1-0 data-buffer (-> v1-0 allocated-length))) + ) + (shadow-invert-z-buf gp-0) + (let ((v1-1 (the-as object (-> gp-0 base)))) + (set! (-> (the-as dma-packet v1-1) dma) (new 'static 'dma-tag :id (dma-tag-id ret))) + (set! (-> (the-as dma-packet v1-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet v1-1) vif1) (new 'static 'vif-tag)) + (set! (-> gp-0 base) (&+ (the-as pointer v1-1) 16)) + ) + ) + (none) + ) + +;; failed to figure out what this is: +(shadow-make-invert-buf) + +;; definition for symbol *shadow-dma-invert-call*, type pointer +(define *shadow-dma-invert-call* (the-as pointer #f)) + +;; definition for function shadow-dma-init +;; WARN: Return type mismatch dma-buffer vs none. +(defun shadow-dma-init ((arg0 dma-buffer)) + (-> *display* on-screen) + (let ((a1-0 408)) + (* a1-0 32) + (let ((t3-0 512) + (t2-0 416) + (a2-0 1792) + (a3-0 1840) + ) + 2304 + (let ((t0-0 2256) + (t1-0 (/ t3-0 32)) + (t5-0 (* a3-0 16)) + ) + (set! *shadow-dma-invert-call* (-> arg0 base)) + (let* ((v1-6 arg0) + (t4-0 (the-as object (-> v1-6 base))) + ) + (set! (-> (the-as dma-packet t4-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet t4-0) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet t4-0) vif1) (new 'static 'vif-tag)) + (set! (-> v1-6 base) (&+ (the-as pointer t4-0) 16)) + ) + (let ((v1-7 (-> arg0 base))) + (let* ((t4-2 arg0) + (t6-1 (the-as object (-> t4-2 base))) + ) + (set! (-> (the-as dma-packet t6-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet t6-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet t6-1) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1)) + (set! (-> t4-2 base) (&+ (the-as pointer t6-1) 16)) + ) + (let* ((t4-3 arg0) + (t6-3 (the-as object (-> t4-3 base))) + ) + (set! (-> (the-as gs-gif-tag t6-3) tag) (new 'static 'gif-tag64 :nloop #xa :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag t6-3) regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))) + (set! (-> t4-3 base) (&+ (the-as pointer t6-3) 16)) + ) + (let ((t4-4 (-> arg0 base))) + (set! (-> (the-as (pointer gs-reg64) t4-4) 1) (gs-reg64 texflush)) + (set! (-> (the-as (pointer gs-reg64) t4-4) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-test) t4-4) 2) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) t4-4) 5) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer gs-alpha) t4-4) 4) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) t4-4) 7) (gs-reg64 frame-1)) + (set! (-> (the-as (pointer gs-frame) t4-4) 6) (new 'static 'gs-frame :fbw #x8 :fbmsk #xffffff :fbp a1-0)) + (set! (-> (the-as (pointer gs-reg64) t4-4) 9) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-zbuf) t4-4) 8) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1)) + (set! (-> (the-as (pointer gs-reg64) t4-4) 11) (gs-reg64 xyoffset-1)) + (set! (-> (the-as (pointer gs-xy-offset) t4-4) 10) (new 'static 'gs-xy-offset :ofx (* a2-0 16) :ofy t5-0)) + (set! (-> (the-as (pointer gs-reg64) t4-4) 13) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer gs-tex0) t4-4) 12) + (new 'static 'gs-tex0 :tbw #x8 :tw #x9 :th #x9 :tcc #x1 :tbp0 (* a1-0 32)) + ) + (set! (-> (the-as (pointer gs-reg) t4-4) 120) (gs-reg tex1-1)) + (set! (-> (the-as (pointer gs-tex1) t4-4) 14) (new 'static 'gs-tex1)) + (set! (-> (the-as (pointer gs-reg) t4-4) 136) (gs-reg miptbp1-1)) + (set! (-> (the-as (pointer gs-miptbp) t4-4) 16) (new 'static 'gs-miptbp)) + (set! (-> (the-as (pointer gs-reg) t4-4) 152) (gs-reg clamp-1)) + (set! (-> (the-as (pointer gs-clamp) t4-4) 18) (new 'static 'gs-clamp + :wms (gs-tex-wrap-mode region-clamp) + :wmt (gs-tex-wrap-mode region-clamp) + :maxv (+ t2-0 -1) + :maxu (+ t3-0 -1) + ) + ) + ) + (&+! (-> arg0 base) 160) + (let* ((t2-7 arg0) + (t3-5 (the-as object (-> t2-7 base))) + ) + (set! (-> (the-as gs-gif-tag t3-5) tag) + (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :flg (gif-flag reg-list) :nreg #x2) + ) + (set! (-> (the-as gs-gif-tag t3-5) regs) (new 'static 'gif-tag-regs :regs1 (gif-reg-id rgbaq))) + (set! (-> t2-7 base) (&+ (the-as pointer t3-5) 16)) + ) + (let* ((t2-8 arg0) + (t3-7 (-> t2-8 base)) + ) + (set! (-> (the-as (pointer gs-prim) t3-7) 0) (new 'static 'gs-prim :prim (gs-prim-type sprite))) + (set! (-> (the-as (pointer gs-rgbaq) t3-7) 1) (new 'static 'gs-rgbaq :a #x60)) + (set! (-> t2-8 base) (&+ t3-7 16)) + ) + (let* ((t2-9 arg0) + (t3-9 (the-as object (-> t2-9 base))) + ) + (set! (-> (the-as gs-gif-tag t3-9) tag) + (new 'static 'gif-tag64 :eop #x1 :flg (gif-flag reg-list) :nreg #x2 :nloop t1-0) + ) + (set! (-> (the-as gs-gif-tag t3-9) regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id xyz2) :regs1 (gif-reg-id xyz2)) + ) + (set! (-> t2-9 base) (&+ (the-as pointer t3-9) 16)) + ) + (let ((t2-10 0)) + (dotimes (t3-11 t1-0) + (let* ((t4-12 arg0) + (t5-12 (-> t4-12 base)) + ) + (set! (-> (the-as (pointer gs-xyzf) t5-12) 0) + (new 'static 'gs-xyzf :z #x1ffff :y (* a3-0 16) :x (* (+ a2-0 t2-10) 16)) + ) + (set! (-> (the-as (pointer gs-xyzf) t5-12) 1) + (new 'static 'gs-xyzf :z #x1ffff :y (* t0-0 16) :x (* (+ t2-10 32 a2-0) 16)) + ) + (set! (-> t4-12 base) (&+ t5-12 16)) + ) + (+! t2-10 32) + ) + ) + (let* ((a2-3 arg0) + (a3-1 (the-as object (-> a2-3 base))) + ) + (set! (-> (the-as gs-gif-tag a3-1) tag) (new 'static 'gif-tag64 :nloop #x4 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag a3-1) regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))) + (set! (-> a2-3 base) (&+ (the-as pointer a3-1) 16)) + ) + (cond + (*shadow-debug* + (let* ((a2-5 arg0) + (a3-3 (-> a2-5 base)) + ) + (set! (-> (the-as (pointer gs-test) a3-3) 0) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest greater-equal)) + ) + (set! (-> (the-as (pointer gs-reg64) a3-3) 1) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-zbuf) a3-3) 2) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (set! (-> (the-as (pointer gs-reg64) a3-3) 3) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-frame) a3-3) 4) (new 'static 'gs-frame :fbw #x8 :fbp a1-0)) + (set! (-> (the-as (pointer gs-reg64) a3-3) 5) (gs-reg64 frame-1)) + (set! (-> (the-as (pointer uint64) a3-3) 6) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a3-3) 7) (gs-reg64 texflush)) + (set! (-> a2-5 base) (&+ a3-3 64)) + ) + ) + (else + (let* ((a2-6 arg0) + (a3-4 (-> a2-6 base)) + ) + (set! (-> (the-as (pointer gs-test) a3-4) 0) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest greater-equal)) + ) + (set! (-> (the-as (pointer gs-reg64) a3-4) 1) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-zbuf) a3-4) 2) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1)) + (set! (-> (the-as (pointer gs-reg64) a3-4) 3) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-frame) a3-4) 4) (new 'static 'gs-frame :fbw #x8 :fbmsk #xffffff :fbp a1-0)) + (set! (-> (the-as (pointer gs-reg64) a3-4) 5) (gs-reg64 frame-1)) + (set! (-> (the-as (pointer uint64) a3-4) 6) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a3-4) 7) (gs-reg64 texflush)) + (set! (-> a2-6 base) (&+ a3-4 64)) + ) + ) + ) + (let ((a2-10 (/ (the-as int (+ (- -16 (the-as int v1-7)) (the-as int (-> arg0 base)))) 16))) + (cond + ((nonzero? a2-10) + (logior! (-> (the-as (pointer uint64) v1-7) 0) (shr (shl a2-10 48) 48)) + (logior! (-> (the-as (pointer uint64) v1-7) 1) (shl (shr (shl a2-10 48) 48) 32)) + ) + (else + (set! (-> arg0 base) v1-7) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for function shadow-dma-end +;; WARN: Return type mismatch dma-buffer vs none. +(defun shadow-dma-end ((arg0 dma-buffer) (arg1 gs-rgbaq) (arg2 symbol) (arg3 int)) + (-> *display* on-screen) + (let ((s0-0 408)) + (* s0-0 32) + (let ((v1-4 512) + (s3-0 416) + (s5-0 1792) + (s4-0 1840) + ) + 2304 + 2256 + (let ((s2-0 (/ v1-4 32))) + (* s4-0 16) + (let ((v1-6 (the-as object *shadow-dma-invert-call*)) + (a0-3 *shadow-dma-buf*) + ) + (cond + (arg2 + (set! (-> (the-as (pointer uint64) v1-6)) (logior #x50000000 (shr (shl (the-as int (-> a0-3 data)) 33) 1))) + (set! (-> (the-as (pointer uint64) v1-6) 1) (the-as uint 0)) + (let* ((v1-7 arg0) + (a1-3 (the-as object (-> v1-7 base))) + ) + (set! (-> (the-as dma-packet a1-3) dma) + (new 'static 'dma-tag :id (dma-tag-id call) :addr (the-as int (-> a0-3 data))) + ) + (set! (-> (the-as dma-packet a1-3) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a1-3) vif1) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1)) + (set! (-> v1-7 base) (&+ (the-as pointer a1-3) 16)) + ) + ) + (else + (set! (-> (the-as dma-packet v1-6) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as (pointer uint64) v1-6) 1) (the-as uint 0)) + 0 + ) + ) + ) + (shadow-vu1-patch-consts arg2 arg3) + (let* ((v1-10 arg0) + (a0-12 (the-as object (-> v1-10 base))) + ) + (set! (-> (the-as dma-packet a0-12) dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-12) vif0) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1)) + (set! (-> (the-as dma-packet a0-12) vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-10 base) (&+ (the-as pointer a0-12) 16)) + ) + (let* ((v1-11 arg0) + (a0-14 (the-as object (-> v1-11 base))) + ) + (set! (-> (the-as gs-gif-tag a0-14) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x5)) + (set! (-> (the-as gs-gif-tag a0-14) regs) GIF_REGS_ALL_AD) + (set! (-> v1-11 base) (&+ (the-as pointer a0-14) 16)) + ) + (let* ((v1-12 arg0) + (a0-16 (-> v1-12 base)) + ) + (set! (-> (the-as (pointer uint64) a0-16) 0) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a0-16) 1) (gs-reg64 texflush)) + (set! (-> (the-as (pointer gs-test) a0-16) 2) + (new 'static 'gs-test :ate #x1 :atst (gs-atest not-equal) :aref #x60 :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a0-16) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-frame) a0-16) 4) (new 'static 'gs-frame :fbw #x8 :fbp s0-0)) + (set! (-> (the-as (pointer gs-reg64) a0-16) 5) (gs-reg64 frame-1)) + (set! (-> (the-as (pointer uint64) a0-16) 6) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a0-16) 7) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer uint64) a0-16) 8) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a0-16) 9) (gs-reg64 texflush)) + (set! (-> v1-12 base) (&+ a0-16 80)) + ) + (let ((v1-13 (-> arg0 base))) + (let* ((a0-18 arg0) + (a1-19 (the-as object (-> a0-18 base))) + ) + (set! (-> (the-as dma-packet a1-19) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a1-19) vif0) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1)) + (set! (-> (the-as dma-packet a1-19) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a0-18 base) (&+ (the-as pointer a1-19) 16)) + ) + (let* ((a0-19 arg0) + (a1-21 (the-as object (-> a0-19 base))) + ) + (set! (-> (the-as gs-gif-tag a1-21) tag) + (new 'static 'gif-tag64 :nloop #x1 :flg (gif-flag reg-list) :nreg #x2) + ) + (set! (-> (the-as gs-gif-tag a1-21) regs) (new 'static 'gif-tag-regs :regs1 (gif-reg-id rgbaq))) + (set! (-> (the-as (pointer gs-prim) a1-21) 2) + (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :abe #x1) + ) + (set! (-> (the-as (pointer gs-rgbaq) a1-21) 3) arg1) + (set! (-> (the-as (inline-array gs-gif-tag) a1-21) 2 tag) + (new 'static 'gif-tag64 :eop #x1 :flg (gif-flag reg-list) :nreg #x4 :nloop s2-0) + ) + (set! (-> (the-as (inline-array gs-gif-tag) a1-21) 2 regs) (new 'static 'gif-tag-regs + :regs0 (gif-reg-id st) + :regs1 (gif-reg-id xyz2) + :regs2 (gif-reg-id st) + :regs3 (gif-reg-id xyz2) + ) + ) + (set! (-> a0-19 base) (&+ (the-as pointer a1-21) 48)) + ) + (let ((a0-20 0) + (a1-23 0) + ) + (dotimes (a2-12 s2-0) + (let ((t1-0 a0-20)) + (+! a0-20 32) + (let* ((a3-3 arg0) + (t0-4 (-> a3-3 base)) + ) + (set! (-> (the-as (pointer uint64) t0-4) 0) + (the-as + uint + (logior (shl (the-as int (* 0.001953125 (+ 0.5 (the float a1-23)))) 32) + (shr (shl (the-as int (* 0.001953125 (+ 0.5 (the float t1-0)))) 32) 32) + ) + ) + ) + (set! (-> (the-as (pointer uint64) t0-4) 1) + (the-as + uint + (logior (logior (shl #x1ffff 32) (shr (shl (* (+ s5-0 t1-0) 16) 48) 48)) + (shr (shl (* (+ s4-0 a1-23) 16) 48) 32) + ) + ) + ) + (set! (-> (the-as (pointer uint64) t0-4) 2) + (the-as + uint + (logior (shl (the-as int (* 0.001953125 (+ 0.5 (the float s3-0)))) 32) + (shr (shl (the-as int (* 0.001953125 (+ 0.5 (the float a0-20)))) 32) 32) + ) + ) + ) + (set! (-> (the-as (pointer uint64) t0-4) 3) + (the-as uint (logior (logior (shl #x1ffff 32) (shr (shl (* (+ s5-0 a0-20) 16) 48) 48)) + (shr (shl (* (+ s4-0 s3-0) 16) 48) 32) + ) + ) + ) + (set! (-> a3-3 base) (&+ t0-4 32)) + ) + ) + ) + ) + (let ((a1-27 (/ (the-as int (+ (- -16 (the-as int v1-13)) (the-as int (-> arg0 base)))) 16))) + (cond + ((nonzero? a1-27) + (logior! (-> (the-as (pointer uint64) v1-13) 0) (shr (shl a1-27 48) 48)) + (logior! (-> (the-as (pointer uint64) v1-13) 1) (shl (shr (shl a1-27 48) 48) 32)) + ) + (else + (set! (-> arg0 base) v1-13) + ) + ) + ) + ) + ) + ) + ) + (reset-display-gs-state *display* arg0) + (none) + ) + +;; definition of type shadow-stats +(deftype shadow-stats (structure) + ((num-single-tris uint32 :offset-assert 0) + (num-double-tris uint32 :offset-assert 4) + (num-single-edges uint32 :offset-assert 8) + (num-double-edges uint32 :offset-assert 12) + (num-fragments uint16 :offset-assert 16) + (num-objects uint16 :offset-assert 18) + ) + :method-count-assert 9 + :size-assert #x14 + :flag-assert #x900000014 + ) + +;; definition for method 3 of type shadow-stats +(defmethod inspect shadow-stats ((obj shadow-stats)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'shadow-stats) + (format #t "~1Tnum-single-tris: ~D~%" (-> obj num-single-tris)) + (format #t "~1Tnum-double-tris: ~D~%" (-> obj num-double-tris)) + (format #t "~1Tnum-single-edges: ~D~%" (-> obj num-single-edges)) + (format #t "~1Tnum-double-edges: ~D~%" (-> obj num-double-edges)) + (format #t "~1Tnum-fragments: ~D~%" (-> obj num-fragments)) + (format #t "~1Tnum-objects: ~D~%" (-> obj num-objects)) + (label cfg-4) + obj + ) + +;; definition of type shadow-dcache +(deftype shadow-dcache (structure) + ((vtx-table uint32 :offset-assert 0) + (single-edge-table uint32 :offset-assert 4) + (double-edge-table uint32 :offset-assert 8) + (double-tri-table uint32 :offset-assert 12) + (dcache-top uint32 :offset-assert 16) + (num-facing-single-tris uint32 :offset-assert 20) + (num-single-edges uint32 :offset-assert 24) + (num-double-edges uint32 :offset-assert 28) + (single-tri-list uint32 :offset-assert 32) + (single-edge-list uint32 :offset-assert 36) + (double-edge-list uint32 :offset-assert 40) + (ptr-dual-verts uint32 :offset-assert 44) + (stats shadow-stats :inline :offset-assert 48) + (frag-qwc uint32 :offset-assert 68) + (center vector :inline :offset-assert 80) + (plane vector :inline :offset-assert 96) + (top-plane vector :inline :offset-assert 112) + (near-plane vector :inline :offset-assert 128) + (light-dir vector :inline :offset-assert 144) + (vtx-min vector :inline :offset-assert 160) + (data uint8 :dynamic :offset-assert 176) + ) + :method-count-assert 9 + :size-assert #xb0 + :flag-assert #x9000000b0 + ) + +;; definition for method 3 of type shadow-dcache +(defmethod inspect shadow-dcache ((obj shadow-dcache)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'shadow-dcache) + (format #t "~1Tvtx-table: #x~X~%" (-> obj vtx-table)) + (format #t "~1Tsingle-edge-table: #x~X~%" (-> obj single-edge-table)) + (format #t "~1Tdouble-edge-table: #x~X~%" (-> obj double-edge-table)) + (format #t "~1Tdouble-tri-table: #x~X~%" (-> obj double-tri-table)) + (format #t "~1Tdcache-top: #x~X~%" (-> obj dcache-top)) + (format #t "~1Tnum-facing-single-tris: ~D~%" (-> obj num-facing-single-tris)) + (format #t "~1Tnum-single-edges: ~D~%" (-> obj num-single-edges)) + (format #t "~1Tnum-double-edges: ~D~%" (-> obj num-double-edges)) + (format #t "~1Tsingle-tri-list: #x~X~%" (-> obj single-tri-list)) + (format #t "~1Tsingle-edge-list: #x~X~%" (-> obj single-edge-list)) + (format #t "~1Tdouble-edge-list: #x~X~%" (-> obj double-edge-list)) + (format #t "~1Tptr-dual-verts: #x~X~%" (-> obj ptr-dual-verts)) + (format #t "~1Tstats: #~%" (-> obj stats)) + (format #t "~1Tfrag-qwc: ~D~%" (-> obj frag-qwc)) + (format #t "~1Tcenter: #~%" (-> obj center)) + (format #t "~1Tplane: #~%" (-> obj plane)) + (format #t "~1Ttop-plane: #~%" (-> obj top-plane)) + (format #t "~1Tnear-plane: #~%" (-> obj near-plane)) + (format #t "~1Tlight-dir: #~%" (-> obj light-dir)) + (format #t "~1Tvtx-min: #~%" (-> obj vtx-min)) + (format #t "~1Tdata[0] @ #x~X~%" (-> obj data)) + (label cfg-4) + obj + ) + +;; definition for symbol shadow-vu0-block, type vu-function +(define shadow-vu0-block (new 'static 'vu-function :length 88 :qlength 44)) + +;; definition for function shadow-xform-verts +;; INFO: function output is handled by mips2c +(def-mips2c shadow-xform-verts function) + +;; definition for function shadow-calc-dual-verts +;; INFO: function output is handled by mips2c +(def-mips2c shadow-calc-dual-verts function) + +;; definition for function shadow-scissor-edges +;; INFO: function output is handled by mips2c +(def-mips2c shadow-scissor-edges function) + +;; definition for function shadow-scissor-top +;; INFO: function output is handled by mips2c +(def-mips2c shadow-scissor-top function) + +;; definition for function shadow-init-vars +;; INFO: function output is handled by mips2c +(def-mips2c shadow-init-vars function) + +;; definition for function shadow-find-facing-single-tris +;; INFO: function output is handled by mips2c +(def-mips2c shadow-find-facing-single-tris function) + +;; definition for function shadow-find-single-edges +;; INFO: function output is handled by mips2c +(def-mips2c shadow-find-single-edges function) + +;; definition for function shadow-find-facing-double-tris +;; INFO: function output is handled by mips2c +(def-mips2c shadow-find-facing-double-tris function) + +;; definition for function shadow-find-double-edges +;; INFO: function output is handled by mips2c +(def-mips2c shadow-find-double-edges function) + +;; definition for function shadow-add-verts +;; INFO: function output is handled by mips2c +(def-mips2c shadow-add-verts function) + +;; definition for function shadow-add-facing-single-tris +;; INFO: function output is handled by mips2c +(def-mips2c shadow-add-facing-single-tris function) + +;; definition for function shadow-add-single-edges +;; INFO: function output is handled by mips2c +(def-mips2c shadow-add-single-edges function) + +;; definition for function shadow-add-single-tris +;; INFO: function output is handled by mips2c +(def-mips2c shadow-add-single-tris function) + +;; definition for function shadow-add-double-tris +;; INFO: function output is handled by mips2c +(def-mips2c shadow-add-double-tris function) + +;; definition for function shadow-add-double-edges +;; INFO: function output is handled by mips2c +(def-mips2c shadow-add-double-edges function) + +;; definition for method 14 of type shadow-control +;; WARN: Return type mismatch int vs none. +(defmethod shadow-control-method-14 shadow-control ((obj shadow-control) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float) (arg4 float)) + (let ((gp-0 (-> obj settings))) + (let ((s4-0 (-> gp-0 shadow-dir))) + (vector-normalize-copy! s4-0 arg1 1.0) + (set! (-> gp-0 shadow-dir w) (- arg2)) + (when *shadow-debug* + (add-debug-x #t (bucket-id debug-no-zbuf1) arg0 *color-red*) + (add-debug-vector #t (bucket-id debug-no-zbuf1) arg0 s4-0 (meters 3) *color-red*) + ) + (let ((s1-2 (vector+float*! (new 'stack-no-clear 'vector) arg0 s4-0 arg3)) + (s5-2 (vector+float*! (new 'stack-no-clear 'vector) arg0 s4-0 arg4)) + ) + (vector-negate! (-> gp-0 top-plane) s4-0) + (vector-negate! (-> gp-0 bot-plane) s4-0) + (set! (-> gp-0 top-plane w) (- (vector-dot s1-2 (the-as vector (-> gp-0 top-plane))))) + (set! (-> gp-0 bot-plane w) (- (vector-dot s5-2 (the-as vector (-> gp-0 bot-plane))))) + ) + ) + (logior! (-> gp-0 flags) (shadow-flags shdf02 shdf03 shdf04 shdf07)) + ) + 0 + (none) + ) + +;; definition for function debug-draw-settings +;; WARN: Return type mismatch symbol vs none. +(defun debug-draw-settings ((arg0 matrix)) + (let ((v1-0 (-> arg0 vector 1)) + (a2-0 (-> arg0 vector)) + (s5-0 (-> arg0 trans)) + (s4-0 (-> arg0 vector 2)) + (s3-0 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (cond + ((logtest? (the-as int (-> arg0 vector 0 w)) 4) + (vector+float*! s3-0 (the-as vector a2-0) v1-0 (- (vector-dot s5-0 (the-as vector a2-0)) (-> s5-0 w))) + (vector+float*! s2-0 (the-as vector a2-0) v1-0 (- (vector-dot s4-0 (the-as vector a2-0)) (-> s4-0 w))) + ) + (else + (let ((a0-8 (vector+float*! (new 'stack-no-clear 'vector) (the-as vector a2-0) v1-0 (-> v1-0 w)))) + (vector+float*! s3-0 a0-8 v1-0 (- (vector-dot s5-0 a0-8) (-> s5-0 w))) + (vector+float*! s2-0 a0-8 v1-0 (- (vector-dot s4-0 a0-8) (-> s4-0 w))) + ) + ) + ) + (add-debug-sphere #t (bucket-id debug-no-zbuf1) (the-as vector a2-0) (meters 0.8) *color-magenta*) + (add-debug-x #t (bucket-id debug-no-zbuf1) s3-0 *color-blue*) + (add-debug-vector #t (bucket-id debug-no-zbuf1) s3-0 s5-0 (meters 2) *color-blue*) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + (the-as vector (-> arg0 vector)) + s3-0 + *color-magenta* + #f + (the-as rgba -1) + ) + (add-debug-x #t (bucket-id debug-no-zbuf1) s2-0 *color-green*) + (add-debug-vector #t (bucket-id debug-no-zbuf1) s2-0 s4-0 (meters 2) *color-green*) + (add-debug-line #t (bucket-id debug-no-zbuf1) s3-0 s2-0 *color-green* #f (the-as rgba -1)) + ) + (none) + ) + +;; definition for function shadow-execute +;; INFO: function output is handled by mips2c +(def-mips2c shadow-execute (function shadow-dma-packet pointer pointer)) + +;; definition for function shadow-vu0-upload +;; WARN: Return type mismatch int vs none. +;; ERROR: Failed store: (s.d! (+ (the-as dma-packet a0-5) 8) 0) at op 17 +(defun shadow-vu0-upload () + (let ((gp-0 *vu0-dma-list*)) + (let ((v1-0 gp-0)) + (set! (-> v1-0 base) (-> v1-0 data)) + (set! (-> v1-0 end) (&-> v1-0 data-buffer (-> v1-0 allocated-length))) + ) + (dma-buffer-add-vu-function gp-0 shadow-vu0-block 0) + (let* ((v1-1 gp-0) + (a0-5 (the-as object (-> v1-1 base))) + ) + (set! (-> (the-as dma-packet a0-5) dma) (new 'static 'dma-tag :id (dma-tag-id end))) + (s.d! (+ (the-as dma-packet a0-5) 8) 0) + (set! (-> v1-1 base) (&+ (the-as pointer a0-5) 16)) + ) + (.sync.l) + (dma-buffer-send-chain (the-as dma-bank-source #x10008000) gp-0) + ) + 0 + (none) + ) + +;; definition for function shadow-execute-all +;; WARN: Return type mismatch int vs none. +;; ERROR: Failed store: (s.h! (+ v1-24 18) 0) at op 58 +;; ERROR: Failed store: (s.h! (+ v1-24 16) 0) at op 59 +(defun shadow-execute-all ((arg0 dma-buffer)) + (when *debug-segment* + (let ((gp-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-7 'shadow) + (s5-0 *profile-shadow-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-0 (-> gp-0 data (-> gp-0 count)))) + (let ((s3-0 (-> gp-0 base-time))) + (set! (-> s4-0 name) v1-7) + (set! (-> s4-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-0)))) + ) + (set! (-> s4-0 depth) (the-as uint (-> gp-0 depth))) + (set! (-> s4-0 color) s5-0) + (set! (-> gp-0 segment (-> gp-0 depth)) s4-0) + ) + (+! (-> gp-0 count) 1) + (+! (-> gp-0 depth) 1) + (set! (-> gp-0 max-depth) (max (-> gp-0 max-depth) (-> gp-0 depth))) + ) + ) + 0 + ) + (when (logtest? (vu1-renderer-mask shadow) (-> *display* vu1-enable-user)) + (let ((gp-1 *shadow-globals*)) + (let ((v1-24 (the-as shadow-dcache (-> (the-as shadow-dcache *gsf-buffer*) stats)))) + (set! (-> v1-24 vtx-table) (the-as uint 0)) + (set! (-> v1-24 single-edge-table) (the-as uint 0)) + (set! (-> v1-24 double-edge-table) (the-as uint 0)) + (set! (-> v1-24 double-tri-table) (the-as uint 0)) + (s.h! (+ v1-24 18) 0) + (s.h! (+ v1-24 16) 0) + ) + 0 + (let ((v1-26 #f)) + (dotimes (a0-11 2) + (if (nonzero? (-> gp-1 bucket a0-11 first)) + (set! v1-26 #t) + ) + ) + (when v1-26 + (shadow-vu0-upload) + (dotimes (s5-1 2) + (let* ((s2-0 (-> gp-1 bucket s5-1)) + (s1-0 (-> s2-0 first)) + ) + (when (nonzero? s1-0) + (with-dma-buffer-add-bucket ((s3-1 (-> *display* frames (-> *display* on-screen) global-buf)) + (if (zero? s5-1) + (bucket-id shadow) + (bucket-id shadow2) + ) + ) + (set! (-> (the-as shadow-dcache #x70000000) ptr-dual-verts) (the-as uint 0)) + (shadow-vu1-init-buffer s3-1 s5-1) + (flush-cache 0) + (shadow-dma-init s3-1) + (set! (-> s3-1 base) (shadow-execute (the-as shadow-dma-packet s1-0) (-> s3-1 base))) + (let ((a2-1 (nonzero? (-> (the-as shadow-dcache #x70000000) ptr-dual-verts))) + (a1-9 (logior (shl #x3f800000 32) (shr (shl (the-as int (the-as uint32 (-> s2-0 shadow-color))) 32) 32))) + ) + (let ((v1-42 (-> *time-of-day-context* current-shadow-color))) + (if (zero? s5-1) + (set! a1-9 + (logior (logand (logior (logand (logior (logand a1-9 -256) (shr (shl (the int (* 128.0 (-> v1-42 x))) 56) 56)) -65281) + (shr (shl (the int (* 128.0 (-> v1-42 y))) 56) 48) + ) + -16711681 + ) + (shr (shl (the int (* 128.0 (-> v1-42 z))) 56) 40) + ) + ) + ) + ) + (shadow-dma-end s3-1 (the-as gs-rgbaq a1-9) a2-1 s5-1) + ) + ) + ) + ) + ) + ) + ) + ) + (let ((gp-2 (the-as shadow-dcache *gsf-buffer*))) + (let ((v1-59 (-> *terrain-stats* shadow))) + (+! (-> v1-59 groups) (-> gp-2 stats num-objects)) + (+! (-> v1-59 fragments) (-> gp-2 stats num-objects)) + (+! (-> v1-59 tris) + (* (+ (-> gp-2 stats num-single-tris) + (-> gp-2 stats num-double-tris) + (-> gp-2 stats num-single-edges) + (-> gp-2 stats num-double-edges) + ) + 2 + ) + ) + (+! (-> v1-59 dverts) + (* (the-as uint 6) (-> gp-2 stats num-single-tris)) + (* (the-as uint 6) (-> gp-2 stats num-double-tris)) + (* (-> gp-2 stats num-single-edges) 4) + (* (-> gp-2 stats num-double-edges) 4) + ) + ) + (when #f + (format *stdcon* "~%~%~%~%#single tris : ~4d~%" (-> gp-2 stats num-single-tris)) + (format *stdcon* "#double tris : ~4d~%" (-> gp-2 stats num-double-tris)) + (format *stdcon* "#single edges: ~4d~%" (-> gp-2 stats num-single-edges)) + (format *stdcon* "#double edges: ~4d~%" (-> gp-2 stats num-double-edges)) + ) + ) + ) + (when *debug-segment* + (let ((gp-3 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-73 (+ (-> gp-3 depth) -1)) + (s5-2 (-> gp-3 segment v1-73)) + (s4-2 (-> gp-3 base-time)) + ) + (when (>= v1-73 0) + (set! (-> s5-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-2)))) + (+! (-> gp-3 depth) -1) + ) + ) + ) + ) + 0 + ) + 0 + (none) + ) + +;; definition for method 13 of type shadow-control +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod shadow-control-method-13 shadow-control ((obj shadow-control) (arg0 vector) (arg1 float) (arg2 float) (arg3 float)) + (with-pp + (let ((s4-0 (new 'stack-no-clear 'collide-query))) + (let ((v1-0 pp)) + (set! (-> s4-0 start-pos quad) (-> arg0 quad)) + (set! (-> s4-0 start-pos y) (+ 4096.0 (-> s4-0 start-pos y))) + (set-vector! (-> s4-0 move-dist) 0.0 (- arg3) 0.0 1.0) + (let ((a0-4 s4-0)) + (set! (-> a0-4 radius) 8192.0) + (set! (-> a0-4 collide-with) (collide-spec backgnd)) + (set! (-> a0-4 ignore-process0) v1-0) + (set! (-> a0-4 ignore-process1) #f) + (set! (-> a0-4 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> a0-4 action-mask) (collide-action solid)) + ) + ) + (cond + ((>= (fill-and-probe-using-line-sphere *collide-cache* s4-0) 0.0) + (let ((v1-5 obj)) + (logclear! (-> v1-5 settings flags) (shadow-flags disable-draw)) + ) + 0 + (let ((v1-7 obj)) + (set! (-> v1-7 settings bot-plane w) (- (+ (-> s4-0 best-other-tri intersect y) arg1))) + ) + 0 + (set! (-> obj settings top-plane w) (- (+ (-> s4-0 best-other-tri intersect y) arg2))) + 0 + ) + (else + (let ((v1-10 obj)) + (logior! (-> v1-10 settings flags) (shadow-flags disable-draw)) + ) + 0 + ) + ) + ) + 0 + (none) + ) + ) diff --git a/test/decompiler/reference/jak2/engine/gfx/foreground/shadow-vu1_REF.gc b/test/decompiler/reference/jak2/engine/gfx/foreground/shadow-vu1_REF.gc new file mode 100644 index 0000000000..389e21ca60 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/gfx/foreground/shadow-vu1_REF.gc @@ -0,0 +1,283 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type shadow-vu1-constants +(deftype shadow-vu1-constants (structure) + ((hmgescale vector :inline :offset-assert 0) + (invhscale vector :inline :offset-assert 16) + (texoffset vector :inline :offset-assert 32) + (texscale vector :inline :offset-assert 48) + (hvdfoff vector :inline :offset-assert 64) + (fog vector :inline :offset-assert 80) + (clrs vector 2 :inline :offset-assert 96) + (adgif gs-gif-tag :inline :offset-assert 128) + (texflush gs-adcmd :inline :offset-assert 144) + (flush gs-adcmd :inline :offset-assert 160) + (trigif gs-gif-tag :inline :offset-assert 176) + (quadgif gs-gif-tag :inline :offset-assert 192) + ) + :method-count-assert 9 + :size-assert #xd0 + :flag-assert #x9000000d0 + ) + +;; definition for method 3 of type shadow-vu1-constants +(defmethod inspect shadow-vu1-constants ((obj shadow-vu1-constants)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'shadow-vu1-constants) + (format #t "~1Thmgescale: #~%" (-> obj hmgescale)) + (format #t "~1Tinvhscale: #~%" (-> obj invhscale)) + (format #t "~1Ttexoffset: #~%" (-> obj texoffset)) + (format #t "~1Ttexscale: #~%" (-> obj texscale)) + (format #t "~1Thvdfoff: #~%" (-> obj hvdfoff)) + (format #t "~1Tfog: #~%" (-> obj fog)) + (format #t "~1Tclrs[2] @ #x~X~%" (-> obj clrs)) + (format #t "~1Tadgif: #~%" (-> obj adgif)) + (format #t "~1Ttexflush: #~%" (-> obj texflush)) + (format #t "~1Tflush: #~%" (-> obj flush)) + (format #t "~1Ttrigif: #~%" (-> obj trigif)) + (format #t "~1Tquadgif: #~%" (-> obj quadgif)) + (label cfg-4) + obj + ) + +;; definition of type shadow-vu1-data +(deftype shadow-vu1-data (structure) + ((adgif gs-gif-tag :inline :offset-assert 0) + (ad gs-adcmd :inline :offset-assert 16) + (flush gs-adcmd :inline :offset-assert 32) + (trigif gs-gif-tag :inline :offset-assert 48) + (quadgif gs-gif-tag :inline :offset-assert 64) + (texoffset vector :inline :offset-assert 80) + (texscale vector :inline :offset-assert 96) + (clrs qword 2 :inline :offset-assert 112) + ) + :method-count-assert 9 + :size-assert #x90 + :flag-assert #x900000090 + ) + +;; definition for method 3 of type shadow-vu1-data +(defmethod inspect shadow-vu1-data ((obj shadow-vu1-data)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'shadow-vu1-data) + (format #t "~1Tadgif: #~%" (-> obj adgif)) + (format #t "~1Tad: #~%" (-> obj ad)) + (format #t "~1Tflush: #~%" (-> obj flush)) + (format #t "~1Ttrigif: #~%" (-> obj trigif)) + (format #t "~1Tquadgif: #~%" (-> obj quadgif)) + (format #t "~1Ttexoffset: #~%" (-> obj texoffset)) + (format #t "~1Ttexscale: #~%" (-> obj texscale)) + (format #t "~1Tclrs[2] @ #x~X~%" (-> obj clrs)) + (label cfg-4) + obj + ) + +;; definition for symbol *shadow-vu1-data*, type shadow-vu1-data +(define *shadow-vu1-data* (new 'static 'shadow-vu1-data + :adgif (new 'static 'gs-gif-tag + :tag (new 'static 'gif-tag64 :nloop #x1 :nreg #x1) + :regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d)) + ) + :ad (new 'static 'gs-adcmd :cmds (gs-reg64 texflush)) + :flush (new 'static 'gs-adcmd :cmds (gs-reg64 rgbaq) :y #x3f800000) + :trigif (new 'static 'gs-gif-tag + :tag (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1) + :nreg #x7 + ) + :regs (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id st) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id st) + :regs4 (gif-reg-id xyzf2) + :regs5 (gif-reg-id st) + :regs6 (gif-reg-id xyzf2) + ) + ) + :quadgif (new 'static 'gs-gif-tag + :tag (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1) + :nreg #x9 + ) + :regs (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id st) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id st) + :regs4 (gif-reg-id xyzf2) + :regs5 (gif-reg-id st) + :regs6 (gif-reg-id xyzf2) + :regs7 (gif-reg-id st) + :regs8 (gif-reg-id xyzf2) + ) + ) + :texoffset (new 'static 'vector :x 256.5 :y 208.5) + :texscale (new 'static 'vector :x 0.001953125 :y 0.001953125) + :clrs (new 'static 'inline-array qword 2 + (new 'static 'qword :data (new 'static 'array uint32 4 #x80 #x0 #x0 #x82)) + (new 'static 'qword :data (new 'static 'array uint32 4 #x0 #x80 #x0 #x7f)) + ) + ) + ) + +;; definition for symbol shadow-vu1-block, type vu-function +(define shadow-vu1-block (new 'static 'vu-function :length #x2e9 :qlength #x175)) + +;; definition for function shadow-vu1-add-constants +;; INFO: Used lq/sq +;; WARN: Return type mismatch dma-buffer vs none. +(defun shadow-vu1-add-constants ((arg0 dma-buffer) (arg1 int)) + (let* ((a3-0 13) + (v1-0 arg0) + (a2-0 (the-as object (-> v1-0 base))) + ) + (set! (-> (the-as dma-packet a2-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc a3-0)) + (set! (-> (the-as dma-packet a2-0) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))) + (set! (-> (the-as dma-packet a2-0) vif1) + (new 'static 'vif-tag :imm #x370 :cmd (vif-cmd unpack-v4-32) :num a3-0) + ) + (set! (-> v1-0 base) (the-as pointer (&+ (the-as dma-packet a2-0) 16))) + ) + (let ((v1-1 (the-as object (-> arg0 base)))) + (let ((a3-4 *math-camera*) + (a2-2 *shadow-vu1-data*) + ) + (set! (-> (the-as shadow-vu1-constants v1-1) hmgescale quad) (-> a3-4 hmge-scale quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) invhscale quad) (-> a3-4 inv-hmge-scale quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) hvdfoff quad) (-> a3-4 hvdf-off quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) hvdfoff x) 2048.0) + (set! (-> (the-as shadow-vu1-constants v1-1) hvdfoff y) 2048.0) + (set! (-> (the-as shadow-vu1-constants v1-1) fog x) (-> a3-4 pfog0)) + (set! (-> (the-as shadow-vu1-constants v1-1) clrs 0 quad) (-> a2-2 clrs 0 quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) clrs 1 quad) (-> a2-2 clrs 1 quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) texoffset quad) (-> a2-2 texoffset quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) texscale quad) (-> a2-2 texscale quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) adgif qword) (-> a2-2 adgif qword)) + (set! (-> (the-as shadow-vu1-constants v1-1) texflush quad) (-> a2-2 ad quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) flush quad) (-> a2-2 flush quad)) + (set! (-> (the-as shadow-vu1-constants v1-1) trigif qword) (-> a2-2 trigif qword)) + (set! (-> (the-as shadow-vu1-constants v1-1) quadgif qword) (-> a2-2 quadgif qword)) + ) + (set! (-> *shadow-globals* bucket arg1 constants) (the-as shadow-vu1-constants v1-1)) + ) + (&+! (-> arg0 base) 208) + (let* ((v1-4 arg0) + (a1-3 (the-as object (-> v1-4 base))) + ) + (set! (-> (the-as dma-packet a1-3) dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a1-3) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))) + (set! (-> (the-as dma-packet a1-3) vif1) + (new 'static 'vif-tag :imm #x3ac :num #x4 :cmd (vif-cmd unpack-v4-32)) + ) + (set! (-> v1-4 base) (&+ (the-as pointer a1-3) 16)) + ) + (let* ((v1-5 arg0) + (a1-5 (the-as object (-> v1-5 base))) + ) + (set! (-> (the-as shadow-vu1-data a1-5) adgif tag) (new 'static 'gif-tag64 :nloop #x1 :nreg #x2)) + (set! (-> (the-as shadow-vu1-data a1-5) adgif regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d) :regs1 (gif-reg-id rgbaq)) + ) + (set! (-> (the-as shadow-vu1-data a1-5) ad data) (the-as uint 0)) + (set! (-> (the-as shadow-vu1-data a1-5) ad cmds) (gs-reg64 texflush)) + (set! (-> (the-as shadow-vu1-data a1-5) flush data) (the-as uint 0)) + (set! (-> (the-as shadow-vu1-data a1-5) flush cmds) (gs-reg64 prim)) + (set! (-> (the-as shadow-vu1-data a1-5) trigif tag) + (new 'static 'gif-tag64 + :nloop #x3 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1) + :nreg #x2 + ) + ) + (set! (-> (the-as shadow-vu1-data a1-5) trigif regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id xyzf2)) + ) + (set! (-> v1-5 base) (&+ (the-as pointer a1-5) 64)) + ) + (none) + ) + +;; definition for function shadow-vu1-patch-consts +;; WARN: Return type mismatch int vs none. +(defun shadow-vu1-patch-consts ((arg0 symbol) (arg1 int)) + (let ((v1-2 (-> *shadow-globals* bucket arg1 constants))) + (cond + (arg0 + (set! (-> v1-2 hvdfoff z) (- 1.0 (-> v1-2 hvdfoff z))) + (set! (-> v1-2 fog w) -1.0) + ) + (else + (set! (-> v1-2 fog w) 1.0) + ) + ) + ) + 0 + (none) + ) + +;; definition for function shadow-vu1-add-matrix +;; INFO: Used lq/sq +;; WARN: Return type mismatch dma-buffer vs none. +(defun shadow-vu1-add-matrix ((arg0 dma-buffer) (arg1 math-camera)) + (let ((v1-0 4)) + (let* ((a2-4 arg0) + (a3-0 (the-as object (-> a2-4 base))) + ) + (set! (-> (the-as dma-packet a3-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-0)) + (set! (-> (the-as dma-packet a3-0) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))) + (set! (-> (the-as dma-packet a3-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd unpack-v4-32) :num v1-0)) + (set! (-> a2-4 base) (&+ (the-as pointer a3-0) 16)) + ) + ) + (let ((v1-5 (the-as object (-> arg0 base)))) + (let ((a2-5 (-> arg1 perspective quad 0)) + (a3-1 (-> arg1 perspective quad 1)) + (t0-4 (-> arg1 perspective quad 2)) + (a1-1 (-> arg1 perspective trans quad)) + ) + (set! (-> (the-as matrix v1-5) quad 0) a2-5) + (set! (-> (the-as matrix v1-5) quad 1) a3-1) + (set! (-> (the-as matrix v1-5) quad 2) t0-4) + (set! (-> (the-as matrix v1-5) trans quad) a1-1) + ) + (set! (-> arg0 base) (&+ (the-as pointer v1-5) 64)) + ) + (none) + ) + +;; definition for function shadow-vu1-init-buffer +;; WARN: Return type mismatch dma-buffer vs none. +(defun shadow-vu1-init-buffer ((arg0 dma-buffer) (arg1 int)) + (dma-buffer-add-vu-function arg0 shadow-vu1-block 1) + (shadow-vu1-add-constants arg0 arg1) + (shadow-vu1-add-matrix arg0 *math-camera*) + (let* ((v1-0 arg0) + (a0-4 (the-as object (-> v1-0 base))) + ) + (set! (-> (the-as dma-packet a0-4) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-4) vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #xa)) + (set! (-> (the-as dma-packet a0-4) vif1) (new 'static 'vif-tag :cmd (vif-cmd flushe) :msk #x1)) + (set! (-> v1-0 base) (&+ (the-as pointer a0-4) 16)) + ) + (none) + ) + + + + diff --git a/test/decompiler/test_VuDisasm.cpp b/test/decompiler/test_VuDisasm.cpp index 3e2bba2ef9..15b96df97b 100644 --- a/test/decompiler/test_VuDisasm.cpp +++ b/test/decompiler/test_VuDisasm.cpp @@ -30,6 +30,20 @@ std::string get_expected(const std::string& name) { } } // namespace +TEST(VuDisasm, ShadowVu0_Jak2) { + auto data = get_test_data("jak2/shadow-vu0"); + VuDisassembler disasm(VuDisassembler::VuKind::VU0); + auto prog = disasm.disassemble(data.data(), data.size() * 4, false); + EXPECT_EQ(disasm.to_string(prog), get_expected("jak2/shadow-vu0")); +} + +TEST(VuDisasm, ShadowVu1_Jak2) { + auto data = get_test_data("jak2/shadow-vu1"); + VuDisassembler disasm(VuDisassembler::VuKind::VU1); + auto prog = disasm.disassemble(data.data(), data.size() * 4, false); + EXPECT_EQ(disasm.to_string(prog), get_expected("jak2/shadow-vu1")); +} + TEST(VuDisasm, OceanTexture_Jak2) { auto data = get_test_data("jak2/ocean-texture"); VuDisassembler disasm(VuDisassembler::VuKind::VU1); diff --git a/test/decompiler/vu_reference/jak2/shadow-vu0-result.txt b/test/decompiler/vu_reference/jak2/shadow-vu0-result.txt new file mode 100644 index 0000000000..9a714a3445 --- /dev/null +++ b/test/decompiler/vu_reference/jak2/shadow-vu0-result.txt @@ -0,0 +1,88 @@ + nop | sub.xyzw vf05, vf03, vf02 + nop | sub.xyzw vf06, vf04, vf02 + nop | sub.xyzw vf10, vf08, vf07 + nop | sub.xyzw vf11, vf09, vf07 + nop | sub.xyzw vf15, vf13, vf12 + nop | sub.xyzw vf16, vf14, vf12 + nop | sub.xyzw vf20, vf18, vf17 + nop | sub.xyzw vf21, vf19, vf17 + nop | opmula.xyz ACC, vf05, vf06 + nop | opmsub.xyz vf05, vf06, vf05 + nop | opmula.xyz ACC, vf10, vf11 + nop | opmsub.xyz vf10, vf11, vf10 + nop | opmula.xyz ACC, vf15, vf16 + nop | opmsub.xyz vf15, vf16, vf15 + nop | opmula.xyz ACC, vf20, vf21 + nop | opmsub.xyz vf20, vf21, vf20 + nop | mul.xyz vf05, vf05, vf01 + nop | mul.xyz vf10, vf10, vf01 + nop | mul.xyz vf15, vf15, vf01 + nop | mul.xyz vf20, vf20, vf01 + nop | addx.y vf05, vf05, vf05 + nop | addx.y vf10, vf10, vf10 + nop | addx.y vf15, vf15, vf15 + nop | addx.y vf20, vf20, vf20 + nop | addz.y vf22, vf05, vf05 + nop | addz.y vf23, vf10, vf10 + nop | addz.y vf24, vf15, vf15 :e + nop | addz.y vf25, vf20, vf20 + nop | mul.xyzw vf27, vf20, Q + div Q, vf13.x, vf17.x | sub.xyzw vf19, vf01, vf03 + move.xyzw vf23, vf07 | sub.xyzw vf20, vf01, vf04 + nop | sub.xyzw vf21, vf01, vf05 + move.xyzw vf25, vf09 | sub.xyzw vf22, vf01, vf06 + move.xyzw vf26, vf10 | sub.xyzw vf24, vf08, vf27 + nop | mul.xyzw vf11, vf03, vf02 + nop | mul.xyz vf15, vf19, vf02 + div Q, vf14.x, vf18.x | mul.xyzw vf12, vf04, vf02 + move.xyzw vf07, vf03 | mul.xyzw vf28, vf28, Q + move.xyzw vf08, vf04 | mul.xyz vf16, vf20, vf02 + move.xyzw vf09, vf05 | addy.x vf11, vf11, vf11 + move.xyzw vf10, vf06 | addy.x vf15, vf15, vf15 + nop | sub.xyzw vf25, vf25, vf28 + nop | addy.x vf12, vf12, vf12 + nop | mul.xyzw vf29, vf29, Q + nop | addy.x vf16, vf16, vf16 + nop | addz.x vf11, vf11, vf11 + nop | addz.x vf15, vf15, vf15 + nop | sub.xyzw vf26, vf26, vf29 + nop | addz.x vf12, vf12, vf12 + nop | addz.x vf16, vf16, vf16 + nop | addw.x vf11, vf11, vf11 + nop | mul.xyzw vf13, vf09, vf02 + nop | addw.x vf12, vf12, vf12 + nop | mul.xyz vf17, vf21, vf02 + nop | mul.xyzw vf14, vf10, vf02 + div Q, vf11.x, vf15.x | mul.xyz vf18, vf22, vf02 + nop | addy.x vf13, vf13, vf13 + nop | addy.x vf17, vf17, vf17 + nop | addy.x vf14, vf14, vf14 + nop | addy.x vf18, vf18, vf18 + nop | addz.x vf13, vf13, vf13 + nop | addz.x vf17, vf17, vf17 + div Q, vf12.x, vf16.x | addz.x vf14, vf14, vf14 + nop | mul.xyzw vf19, vf19, Q + move.xyzw vf28, vf21 | addz.x vf18, vf18, vf18 + move.xyzw vf29, vf22 | addw.x vf13, vf13, vf13 + nop | addw.x vf14, vf14, vf14 :e + nop | sub.xyzw vf07, vf07, vf19 + nop | mul.xyzw vf27, vf20, Q + div Q, vf13.x, vf17.x | nop + move.xyzw vf23, vf07 | nop + nop | nop + move.xyzw vf25, vf09 | nop + move.xyzw vf26, vf10 | sub.xyzw vf24, vf08, vf27 + nop | nop + nop | nop + div Q, vf14.x, vf18.x | nop + nop | mul.xyzw vf28, vf28, Q + nop | nop + nop | nop + nop | nop + nop | sub.xyzw vf25, vf25, vf28 + nop | nop + nop | mul.xyzw vf29, vf29, Q + nop | nop + nop | nop + nop | nop :e + nop | sub.xyzw vf26, vf26, vf29 diff --git a/test/decompiler/vu_reference/jak2/shadow-vu0.txt b/test/decompiler/vu_reference/jak2/shadow-vu0.txt new file mode 100644 index 0000000000..a5c7decf36 --- /dev/null +++ b/test/decompiler/vu_reference/jak2/shadow-vu0.txt @@ -0,0 +1,176 @@ + .word 0x80000030 + .word 0x1e2196c + .word 0x80000030 + .word 0x1e221ac + .word 0x80000030 + .word 0x1e742ac + .word 0x80000030 + .word 0x1e74aec + .word 0x80000030 + .word 0x1ec6bec + .word 0x80000030 + .word 0x1ec742c + .word 0x80000030 + .word 0x1f1952c + .word 0x80000030 + .word 0x1f19d6c + .word 0x80000030 + .word 0x1c62afe + .word 0x80000030 + .word 0x1c5316e + .word 0x80000030 + .word 0x1cb52fe + .word 0x80000030 + .word 0x1ca5aae + .word 0x80000030 + .word 0x1d07afe + .word 0x80000030 + .word 0x1cf83ee + .word 0x80000030 + .word 0x1d5a2fe + .word 0x80000030 + .word 0x1d4ad2e + .word 0x80000030 + .word 0x1c1296a + .word 0x80000030 + .word 0x1c152aa + .word 0x80000030 + .word 0x1c17bea + .word 0x80000030 + .word 0x1c1a52a + .word 0x80000030 + .word 0x852940 + .word 0x80000030 + .word 0x8a5280 + .word 0x80000030 + .word 0x8f7bc0 + .word 0x80000030 + .word 0x94a500 + .word 0x80000030 + .word 0x852d82 + .word 0x80000030 + .word 0x8a55c2 + .word 0x80000030 + .word 0x408f7e02 + .word 0x80000030 + .word 0x94a642 + .word 0x80000030 + .word 0x1e0a6dc + .word 0x80116bbc + .word 0x1e30cec + .word 0x81f73b3c + .word 0x1e40d2c + .word 0x80000030 + .word 0x1e50d6c + .word 0x81f94b3c + .word 0x1e60dac + .word 0x81fa533c + .word 0x1fb462c + .word 0x80000030 + .word 0x1e21aea + .word 0x80000030 + .word 0x1c29bea + .word 0x801273bc + .word 0x1e2232a + .word 0x81e71b3c + .word 0x1e0e71c + .word 0x81e8233c + .word 0x1c2a42a + .word 0x81e92b3c + .word 0x10b5ac1 + .word 0x81ea333c + .word 0x10f7bc1 + .word 0x80000030 + .word 0x1fcce6c + .word 0x80000030 + .word 0x10c6301 + .word 0x80000030 + .word 0x1e0ef5c + .word 0x80000030 + .word 0x1108401 + .word 0x80000030 + .word 0x10b5ac2 + .word 0x80000030 + .word 0x10f7bc2 + .word 0x80000030 + .word 0x1fdd6ac + .word 0x80000030 + .word 0x10c6302 + .word 0x80000030 + .word 0x1108402 + .word 0x80000030 + .word 0x10b5ac3 + .word 0x80000030 + .word 0x1e24b6a + .word 0x80000030 + .word 0x10c6303 + .word 0x80000030 + .word 0x1c2ac6a + .word 0x80000030 + .word 0x1e253aa + .word 0x800f5bbc + .word 0x1c2b4aa + .word 0x80000030 + .word 0x10d6b41 + .word 0x80000030 + .word 0x1118c41 + .word 0x80000030 + .word 0x10e7381 + .word 0x80000030 + .word 0x1129481 + .word 0x80000030 + .word 0x10d6b42 + .word 0x80000030 + .word 0x1118c42 + .word 0x801063bc + .word 0x10e7382 + .word 0x80000030 + .word 0x1e09cdc + .word 0x81fcab3c + .word 0x1129482 + .word 0x81fdb33c + .word 0x10d6b43 + .word 0x80000030 + .word 0x410e7383 + .word 0x80000030 + .word 0x1f339ec + .word 0x80000030 + .word 0x1e0a6dc + .word 0x80116bbc + .word 0x2ff + .word 0x81f73b3c + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x81f94b3c + .word 0x2ff + .word 0x81fa533c + .word 0x1fb462c + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x801273bc + .word 0x2ff + .word 0x80000030 + .word 0x1e0e71c + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x1fcce6c + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x1e0ef5c + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x400002ff + .word 0x80000030 + .word 0x1fdd6ac \ No newline at end of file diff --git a/test/decompiler/vu_reference/jak2/shadow-vu1-result.txt b/test/decompiler/vu_reference/jak2/shadow-vu1-result.txt new file mode 100644 index 0000000000..b7ec618b00 --- /dev/null +++ b/test/decompiler/vu_reference/jak2/shadow-vu1-result.txt @@ -0,0 +1,799 @@ + b L1 | nop + nop | nop + b L2 | nop + nop | nop + b L13 | nop + nop | nop + b L21 | nop + nop | nop + nop | nop :e + nop | nop +L1: + iaddiu vi01, vi00, 0x358 | nop + iaddiu vi02, vi00, 0x364 | nop + mfir.x vf01, vi01 | nop + mfir.y vf01, vi02 | nop + mfir.z vf01, vi01 | nop + mfir.w vf01, vi02 | nop + lq.xyzw vf02, 880(vi00) | nop + lq.xyzw vf03, 882(vi00) | nop + lq.xyzw vf04, 883(vi00) | nop + lq.xyzw vf05, 884(vi00) | nop + lq.xyzw vf12, 885(vi00) | nop :e + lq.xyzw vf13, 881(vi00) | nop +L2: + iaddiu vi03, vi00, 0x158 | nop + ilwr.x vi08, vi03 | nop + mtir vi02, vf01.x | nop + iaddi vi03, vi03, 0x1 | addw.z vf25, vf00, vf00 + lq.xyzw vf25, 888(vi00) | addw.z vf26, vf00, vf00 + lq.xyzw vf29, 889(vi00) | addw.z vf27, vf00, vf00 + lq.xyzw vf30, 891(vi00) | addw.z vf28, vf00, vf00 + lq.xyzw vf06, 0(vi00) | nop + lq.xyzw vf07, 1(vi00) | nop + lq.xyzw vf08, 2(vi00) | nop + lq.xyzw vf09, 3(vi00) | nop + mtir vi01, vf01.y | nop + sq.xyzw vf25, 0(vi02) | nop + sq.xyzw vf29, 1(vi02) | nop + sq.xyzw vf30, 2(vi02) | nop + sq.xyzw vf25, 0(vi01) | nop + sq.xyzw vf29, 1(vi01) | nop + sq.xyzw vf30, 2(vi01) | nop +L3: + lqi.xyzw vf16, vi03 | nop + nop | nop + nop | nop + nop | nop + mtir vi04, vf16.x | nop + mtir vi05, vf16.y | nop + mtir vi06, vf16.z | nop + nop | nop + lq.xyzw vf17, 4(vi04) | nop + lq.xyzw vf18, 4(vi05) | nop + lq.xyzw vf19, 4(vi06) | nop + nop | mulaw.xyzw ACC, vf09, vf00 + move.xyzw vf15, vf17 | maddax.xyzw ACC, vf06, vf17 + nop | madday.xyzw ACC, vf07, vf17 + nop | maddz.xyzw vf17, vf08, vf17 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | sub.xyzw vf29, vf18, vf15 + nop | sub.xyzw vf30, vf19, vf15 + div Q, vf12.x, vf17.w | maddax.xyzw ACC, vf06, vf18 + nop | mul.xyzw vf21, vf17, vf02 + nop | madday.xyzw ACC, vf07, vf18 + nop | maddz.xyzw vf18, vf08, vf18 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf19 + nop | madday.xyzw ACC, vf07, vf19 + div Q, vf12.x, vf18.w | mul.xyz vf17, vf17, Q + nop | maddz.xyzw vf19, vf08, vf19 + nop | mul.xyzw vf22, vf18, vf02 + nop | opmula.xyz ACC, vf29, vf30 + nop | add.xy vf25, vf17, vf03 + nop | mulw.z vf17, vf17, vf12 + nop | opmsub.xyz vf29, vf30, vf29 + div Q, vf12.x, vf19.w | mul.xyz vf18, vf18, Q + nop | mul.xyzw vf23, vf19, vf02 + nop | mul.xyz vf29, vf29, vf15 + nop | add.xy vf26, vf18, vf03 + nop | add.xyzw vf17, vf17, vf05 + nop | mulw.z vf18, vf18, vf12 + nop | mul.xy vf25, vf25, vf04 + nop | mul.xyz vf19, vf19, Q + nop | ftoi4.xyzw vf17, vf17 + fcset 0x0 | addy.x vf29, vf29, vf29 + nop | add.xyzw vf18, vf18, vf05 + nop | clipw.xyz vf21, vf21 + nop | mulw.z vf19, vf19, vf12 + sq.xyzw vf25, 4(vi02) | mul.xy vf26, vf26, vf04 + sq.xyzw vf17, 5(vi02) | addz.x vf29, vf29, vf29 + nop | ftoi4.xyzw vf18, vf18 + nop | add.xy vf27, vf19, vf03 + sq.xyzw vf26, 6(vi02) | add.xyzw vf19, vf19, vf05 + fsand vi01, 0x2 | clipw.xyz vf22, vf22 + sq.xyzw vf18, 7(vi02) | clipw.xyz vf23, vf23 + ibeq vi00, vi01, L4 | mul.xy vf27, vf27, vf04 + nop | nop + b L5 | nop + lq.xyzw vf31, 887(vi00) | nop +L4: + lq.xyzw vf31, 886(vi00) | nop +L5: + fcand vi01, 0x3ffff | ftoi4.xyzw vf19, vf19 + ibne vi00, vi01, L11 | nop + iaddi vi08, vi08, -0x1 | nop + sq.xyzw vf27, 8(vi02) | nop + sq.xyzw vf31, 3(vi02) | nop + sq.xyzw vf19, 9(vi02) | nop + xgkick vi02 | nop + mtir vi02, vf01.y | nop + mr32.xyzw vf01, vf01 | nop +L6: + ibgtz vi08, L3 | nop + nop | nop + iaddiu vi03, vi00, 0x158 | nop + ilwr.x vi08, vi03 | nop + ilwr.y vi01, vi03 | nop + iaddi vi03, vi03, 0x1 | nop +L7: + lqi.xyzw vf16, vi03 | nop + nop | nop + nop | nop + mtir vi04, vf16.x | nop + mtir vi05, vf16.y | nop + mtir vi06, vf16.z | nop + nop | nop + lq.xyzw vf17, 174(vi04) | nop + lq.xyzw vf18, 174(vi06) | nop + lq.xyzw vf19, 174(vi05) | nop + nop | mulaw.xyzw ACC, vf09, vf00 + move.xyzw vf15, vf17 | maddax.xyzw ACC, vf06, vf17 + nop | madday.xyzw ACC, vf07, vf17 + nop | maddz.xyzw vf17, vf08, vf17 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | sub.xyzw vf29, vf18, vf15 + nop | sub.xyzw vf30, vf19, vf15 + div Q, vf12.x, vf17.w | maddax.xyzw ACC, vf06, vf18 + nop | mul.xyzw vf21, vf17, vf02 + nop | madday.xyzw ACC, vf07, vf18 + nop | maddz.xyzw vf18, vf08, vf18 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf19 + nop | madday.xyzw ACC, vf07, vf19 + div Q, vf12.x, vf18.w | mul.xyz vf17, vf17, Q + nop | maddz.xyzw vf19, vf08, vf19 + nop | mul.xyzw vf22, vf18, vf02 + nop | opmula.xyz ACC, vf29, vf30 + nop | add.xy vf25, vf17, vf03 + nop | mulw.z vf17, vf17, vf12 + nop | opmsub.xyz vf29, vf30, vf29 + div Q, vf12.x, vf19.w | mul.xyz vf18, vf18, Q + nop | mul.xyzw vf23, vf19, vf02 + nop | mul.xyz vf29, vf29, vf15 + nop | add.xy vf26, vf18, vf03 + nop | add.xyzw vf17, vf17, vf05 + nop | mulw.z vf18, vf18, vf12 + nop | mul.xy vf25, vf25, vf04 + nop | mul.xyz vf19, vf19, Q + nop | ftoi4.xyzw vf17, vf17 + fcset 0x0 | addy.x vf29, vf29, vf29 + nop | add.xyzw vf18, vf18, vf05 + nop | clipw.xyz vf21, vf21 + sq.xyzw vf25, 4(vi02) | mulw.z vf19, vf19, vf12 + sq.xyzw vf17, 5(vi02) | mul.xy vf26, vf26, vf04 + iaddi vi08, vi08, -0x1 | addz.x vf29, vf29, vf29 + nop | ftoi4.xyzw vf18, vf18 + nop | add.xy vf27, vf19, vf03 + sq.xyzw vf26, 6(vi02) | add.xyzw vf19, vf19, vf05 + fsand vi01, 0x2 | clipw.xyz vf22, vf22 + sq.xyzw vf18, 7(vi02) | clipw.xyz vf23, vf23 + ibeq vi00, vi01, L8 | mul.xy vf27, vf27, vf04 + nop | nop + b L9 | nop + lq.xyzw vf31, 887(vi00) | nop +L8: + lq.xyzw vf31, 886(vi00) | nop +L9: + fcand vi01, 0x3ffff | ftoi4.xyzw vf19, vf19 + ibne vi00, vi01, L12 | nop + sq.xyzw vf27, 8(vi02) | nop + sq.xyzw vf31, 3(vi02) | nop + sq.xyzw vf19, 9(vi02) | nop + xgkick vi02 | nop + mtir vi02, vf01.y | nop + mr32.xyzw vf01, vf01 | nop +L10: + ibgtz vi08, L7 | nop + nop | nop + nop | nop :e + nop | nop +L11: + sq.xyzw vf21, 1000(vi00) | nop + sq.xyzw vf22, 1003(vi00) | nop + sq.xyzw vf23, 1006(vi00) | nop + sq.xyzw vf31, 942(vi00) | nop + mfir.x vf29, vi02 | nop + mfir.y vf29, vi03 | nop + mfir.z vf29, vi07 | nop + bal vi15, L36 | nop + mfir.w vf29, vi08 | nop + mtir vi08, vf29.w | nop + mtir vi03, vf29.y | nop + mtir vi07, vf29.z | nop + b L6 | nop + mtir vi02, vf29.x | nop +L12: + sq.xyzw vf21, 1000(vi00) | nop + sq.xyzw vf22, 1003(vi00) | nop + sq.xyzw vf23, 1006(vi00) | nop + sq.xyzw vf31, 942(vi00) | nop + mfir.x vf29, vi02 | nop + mfir.y vf29, vi03 | nop + mfir.z vf29, vi07 | nop + bal vi15, L36 | nop + mfir.w vf29, vi08 | nop + mtir vi08, vf29.w | nop + mtir vi03, vf29.y | nop + mtir vi07, vf29.z | nop + b L10 | nop + mtir vi02, vf29.x | nop +L13: + iaddiu vi03, vi00, 0x258 | nop + ilwr.x vi08, vi03 | nop + mtir vi02, vf01.x | nop + iaddi vi03, vi03, 0x1 | addw.z vf25, vf00, vf00 + lq.xyzw vf25, 888(vi00) | addw.z vf26, vf00, vf00 + lq.xyzw vf29, 889(vi00) | addw.z vf27, vf00, vf00 + lq.xyzw vf30, 892(vi00) | nop + lq.xyzw vf06, 0(vi00) | nop + lq.xyzw vf07, 1(vi00) | nop + lq.xyzw vf08, 2(vi00) | nop + lq.xyzw vf09, 3(vi00) | nop + mtir vi01, vf01.y | nop + sq.xyzw vf25, 0(vi02) | nop + sq.xyzw vf29, 1(vi02) | nop + sq.xyzw vf30, 2(vi02) | nop + sq.xyzw vf25, 0(vi01) | nop + sq.xyzw vf29, 1(vi01) | nop + sq.xyzw vf30, 2(vi01) | nop +L14: + lqi.xyzw vf16, vi03 | nop + nop | nop + nop | nop + nop | nop + mtir vi06, vf16.z | nop + mtir vi04, vf16.x | nop + mtir vi05, vf16.y | nop + nop | nop + ibeq vi00, vi06, L15 | nop + nop | nop + lq.xyzw vf17, 4(vi04) | nop + lq.xyzw vf18, 4(vi05) | nop + lq.xyzw vf19, 174(vi05) | nop + b L16 | nop + lq.xyzw vf20, 174(vi04) | nop +L15: + lq.xyzw vf17, 4(vi05) | nop + lq.xyzw vf18, 4(vi04) | nop + lq.xyzw vf19, 174(vi04) | nop + lq.xyzw vf20, 174(vi05) | nop +L16: + move.xyzw vf15, vf17 | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf17 + nop | madday.xyzw ACC, vf07, vf17 + nop | maddz.xyzw vf17, vf08, vf17 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | sub.xyzw vf29, vf18, vf15 + nop | sub.xyzw vf30, vf19, vf15 + div Q, vf12.x, vf17.w | maddax.xyzw ACC, vf06, vf18 + nop | mul.xyzw vf21, vf17, vf02 + nop | madday.xyzw ACC, vf07, vf18 + nop | maddz.xyzw vf18, vf08, vf18 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf19 + nop | madday.xyzw ACC, vf07, vf19 + div Q, vf12.x, vf18.w | mul.xyz vf17, vf17, Q + nop | maddz.xyzw vf19, vf08, vf19 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf20 + nop | madday.xyzw ACC, vf07, vf20 + nop | maddz.xyzw vf20, vf08, vf20 + nop | mul.xyzw vf22, vf18, vf02 + div Q, vf12.x, vf19.w | mul.xyz vf18, vf18, Q + nop | add.xy vf25, vf17, vf03 + nop | mulw.z vf17, vf17, vf12 + nop | opmula.xyz ACC, vf29, vf30 + nop | opmsub.xyz vf29, vf30, vf29 + nop | mul.xyzw vf23, vf19, vf02 + nop | mul.xyz vf29, vf29, vf15 + div Q, vf12.x, vf20.w | mul.xyz vf19, vf19, Q + nop | add.xyzw vf17, vf17, vf05 + nop | mul.xyzw vf24, vf20, vf02 + nop | mul.xy vf25, vf25, vf04 + nop | nop + nop | ftoi4.xyzw vf17, vf17 + nop | add.xy vf26, vf18, vf03 + nop | mul.xyz vf20, vf20, Q + nop | mulw.z vf18, vf18, vf12 + nop | addy.x vf29, vf29, vf29 + sq.xyzw vf25, 4(vi02) | nop + sq.xyzw vf17, 5(vi02) | nop + nop | add.xyzw vf18, vf18, vf05 + nop | clipw.xyz vf21, vf21 + nop | mul.xy vf26, vf26, vf04 + nop | addz.x vf29, vf29, vf29 + nop | ftoi4.xyzw vf18, vf18 + nop | add.xy vf27, vf19, vf03 + sq.xyzw vf26, 6(vi02) | mulw.z vf19, vf19, vf12 + fsand vi01, 0x2 | clipw.xyz vf22, vf22 + sq.xyzw vf18, 7(vi02) | clipw.xyz vf23, vf23 + nop | clipw.xyz vf24, vf24 + nop | add.xy vf28, vf20, vf03 + nop | mulw.z vf20, vf20, vf12 + nop | mul.xy vf27, vf27, vf04 + nop | add.xyzw vf19, vf19, vf05 + nop | nop + ibeq vi00, vi01, L17 | mul.xy vf28, vf28, vf04 + nop | add.xyzw vf20, vf20, vf05 + b L18 | nop + lq.xyzw vf31, 887(vi00) | nop +L17: + lq.xyzw vf31, 886(vi00) | nop +L18: + fcand vi01, 0xffffff | ftoi4.xyzw vf19, vf19 + ibne vi00, vi01, L20 | nop + iaddi vi08, vi08, -0x1 | nop + sq.xyzw vf27, 8(vi02) | ftoi4.xyzw vf20, vf20 + sq.xyzw vf31, 3(vi02) | nop + sq.xyzw vf19, 9(vi02) | nop + sq.xyzw vf28, 10(vi02) | nop + sq.xyzw vf20, 11(vi02) | nop + xgkick vi02 | nop + mtir vi02, vf01.y | nop + mr32.xyzw vf01, vf01 | nop +L19: + ibgtz vi08, L14 | nop + nop | nop + nop | nop :e + nop | nop +L20: + sq.xyzw vf21, 1000(vi00) | nop + sq.xyzw vf22, 1003(vi00) | nop + sq.xyzw vf23, 1006(vi00) | nop + sq.xyzw vf24, 1009(vi00) | nop + sq.xyzw vf31, 942(vi00) | nop + mfir.x vf29, vi02 | nop + mfir.y vf29, vi03 | nop + mfir.z vf29, vi07 | nop + bal vi15, L37 | nop + mfir.w vf29, vi08 | nop + mtir vi08, vf29.w | nop + mtir vi03, vf29.y | nop + mtir vi07, vf29.z | nop + b L19 | nop + mtir vi02, vf29.x | nop +L21: + iaddiu vi03, vi00, 0x158 | nop + ilwr.x vi08, vi03 | nop + mtir vi02, vf01.x | nop + iaddi vi03, vi03, 0x1 | addw.z vf25, vf00, vf00 + lq.xyzw vf25, 888(vi00) | addw.z vf26, vf00, vf00 + lq.xyzw vf29, 889(vi00) | addw.z vf27, vf00, vf00 + lq.xyzw vf30, 891(vi00) | addw.z vf28, vf00, vf00 + lq.xyzw vf06, 0(vi00) | nop + lq.xyzw vf07, 1(vi00) | nop + lq.xyzw vf08, 2(vi00) | nop + lq.xyzw vf09, 3(vi00) | nop + mtir vi01, vf01.y | nop + sq.xyzw vf25, 0(vi02) | nop + sq.xyzw vf29, 1(vi02) | nop + sq.xyzw vf30, 2(vi02) | nop + sq.xyzw vf25, 0(vi01) | nop + sq.xyzw vf29, 1(vi01) | nop + sq.xyzw vf30, 2(vi01) | nop +L22: + lqi.xyzw vf16, vi03 | nop + nop | nop + nop | nop + nop | nop + mtir vi01, vf16.w | nop + mtir vi04, vf16.x | nop + mtir vi05, vf16.y | nop + mtir vi06, vf16.z | nop + ibeq vi00, vi01, L23 | nop + lq.xyzw vf17, 4(vi04) | nop + lq.xyzw vf18, 4(vi05) | nop + b L24 | nop + lq.xyzw vf19, 4(vi06) | nop +L23: + lq.xyzw vf19, 4(vi05) | nop + lq.xyzw vf18, 4(vi06) | nop +L24: + nop | mulaw.xyzw ACC, vf09, vf00 + move.xyzw vf15, vf17 | maddax.xyzw ACC, vf06, vf17 + nop | madday.xyzw ACC, vf07, vf17 + nop | sub.xyzw vf29, vf18, vf17 + nop | sub.xyzw vf30, vf19, vf17 + nop | maddz.xyzw vf17, vf08, vf17 + nop | mulaw.xyzw ACC, vf09, vf00 + div Q, vf12.x, vf17.w | maddax.xyzw ACC, vf06, vf18 + nop | madday.xyzw ACC, vf07, vf18 + nop | mul.xyzw vf21, vf17, vf02 + nop | maddz.xyzw vf18, vf08, vf18 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf19 + nop | madday.xyzw ACC, vf07, vf19 + div Q, vf12.x, vf18.w | mul.xyz vf17, vf17, Q + nop | maddz.xyzw vf19, vf08, vf19 + nop | mul.xyzw vf22, vf18, vf02 + nop | opmula.xyz ACC, vf29, vf30 + nop | opmsub.xyz vf29, vf30, vf29 + nop | add.xy vf25, vf17, vf03 + nop | mulw.z vf17, vf17, vf12 + div Q, vf12.x, vf19.w | mul.xyz vf18, vf18, Q + nop | mul.xyzw vf23, vf19, vf02 + nop | mul.xyz vf29, vf29, vf15 + nop | add.xyzw vf17, vf17, vf05 + nop | mul.xy vf25, vf25, vf04 + nop | nop + nop | ftoi4.xyzw vf17, vf17 + nop | add.xy vf26, vf18, vf03 + nop | mulw.z vf18, vf18, vf12 + fcset 0x0 | addy.x vf29, vf29, vf29 + nop | mul.xyz vf19, vf19, Q + sq.xyzw vf25, 4(vi02) | nop + sq.xyzw vf17, 5(vi02) | add.xyzw vf18, vf18, vf05 + nop | clipw.xyz vf21, vf21 + nop | mul.xy vf26, vf26, vf04 + nop | addz.x vf29, vf29, vf29 + nop | ftoi4.xyzw vf18, vf18 + nop | add.xy vf27, vf19, vf03 + sq.xyzw vf26, 6(vi02) | mulw.z vf19, vf19, vf12 + fsand vi01, 0x2 | clipw.xyz vf22, vf22 + sq.xyzw vf18, 7(vi02) | clipw.xyz vf23, vf23 + ibeq vi00, vi01, L25 | mul.xy vf27, vf27, vf04 + nop | add.xyzw vf19, vf19, vf05 + b L26 | nop + lq.xyzw vf31, 887(vi00) | nop +L25: + lq.xyzw vf31, 886(vi00) | nop +L26: + fcand vi01, 0x3ffff | ftoi4.xyzw vf19, vf19 + ibne vi00, vi01, L34 | nop + iaddi vi08, vi08, -0x1 | nop + sq.xyzw vf27, 8(vi02) | nop + sq.xyzw vf31, 3(vi02) | nop + sq.xyzw vf19, 9(vi02) | nop + xgkick vi02 | nop + mtir vi02, vf01.y | nop + mr32.xyzw vf01, vf01 | nop +L27: + ibgtz vi08, L22 | nop + nop | nop + iaddiu vi03, vi00, 0x158 | nop + ilwr.x vi08, vi03 | nop + ilwr.y vi01, vi03 | nop + iaddi vi03, vi03, 0x1 | nop +L28: + lqi.xyzw vf16, vi03 | nop + nop | nop + nop | nop + mtir vi01, vf16.w | nop + mtir vi04, vf16.x | nop + mtir vi05, vf16.y | nop + mtir vi06, vf16.z | nop + ibne vi00, vi01, L29 | nop + lq.xyzw vf17, 174(vi04) | nop + lq.xyzw vf18, 174(vi05) | nop + b L30 | nop + lq.xyzw vf19, 174(vi06) | nop +L29: + lq.xyzw vf19, 174(vi05) | nop + lq.xyzw vf18, 174(vi06) | nop +L30: + nop | mulaw.xyzw ACC, vf09, vf00 + move.xyzw vf15, vf17 | maddax.xyzw ACC, vf06, vf17 + nop | madday.xyzw ACC, vf07, vf17 + nop | maddz.xyzw vf17, vf08, vf17 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | sub.xyzw vf29, vf18, vf15 + nop | sub.xyzw vf30, vf19, vf15 + div Q, vf12.x, vf17.w | maddax.xyzw ACC, vf06, vf18 + nop | mul.xyzw vf21, vf17, vf02 + nop | madday.xyzw ACC, vf07, vf18 + nop | maddz.xyzw vf18, vf08, vf18 + nop | mulaw.xyzw ACC, vf09, vf00 + nop | maddax.xyzw ACC, vf06, vf19 + nop | madday.xyzw ACC, vf07, vf19 + div Q, vf12.x, vf18.w | mul.xyz vf17, vf17, Q + nop | maddz.xyzw vf19, vf08, vf19 + nop | mul.xyzw vf22, vf18, vf02 + nop | opmula.xyz ACC, vf29, vf30 + nop | opmsub.xyz vf29, vf30, vf29 + nop | add.xy vf25, vf17, vf03 + nop | mulw.z vf17, vf17, vf12 + div Q, vf12.x, vf19.w | mul.xyz vf18, vf18, Q + nop | mul.xyzw vf23, vf19, vf02 + nop | mul.xyz vf29, vf29, vf15 + nop | add.xyzw vf17, vf17, vf05 + nop | mul.xy vf25, vf25, vf04 + nop | nop + nop | add.xy vf26, vf18, vf03 + nop | ftoi4.xyzw vf17, vf17 + nop | mulw.z vf18, vf18, vf12 + fcset 0x0 | addy.x vf29, vf29, vf29 + nop | mul.xyz vf19, vf19, Q + sq.xyzw vf25, 4(vi02) | nop + sq.xyzw vf17, 5(vi02) | add.xyzw vf18, vf18, vf05 + nop | clipw.xyz vf21, vf21 + nop | mul.xy vf26, vf26, vf04 + nop | addz.x vf29, vf29, vf29 + nop | ftoi4.xyzw vf18, vf18 + nop | add.xy vf27, vf19, vf03 + sq.xyzw vf26, 6(vi02) | mulw.z vf19, vf19, vf12 + fsand vi01, 0x2 | clipw.xyz vf22, vf22 + sq.xyzw vf18, 7(vi02) | clipw.xyz vf23, vf23 + ibeq vi00, vi01, L31 | mul.xy vf27, vf27, vf04 + nop | add.xyzw vf19, vf19, vf05 + b L32 | nop + lq.xyzw vf31, 887(vi00) | nop +L31: + lq.xyzw vf31, 886(vi00) | nop +L32: + fcand vi01, 0x3ffff | ftoi4.xyzw vf19, vf19 + ibne vi00, vi01, L35 | nop + iaddi vi08, vi08, -0x1 | nop + sq.xyzw vf27, 8(vi02) | nop + sq.xyzw vf31, 3(vi02) | nop + sq.xyzw vf19, 9(vi02) | nop + xgkick vi02 | nop + mtir vi02, vf01.y | nop + mr32.xyzw vf01, vf01 | nop +L33: + ibgtz vi08, L28 | nop + nop | nop + nop | nop :e + nop | nop +L34: + sq.xyzw vf21, 1000(vi00) | nop + sq.xyzw vf22, 1003(vi00) | nop + sq.xyzw vf23, 1006(vi00) | nop + sq.xyzw vf31, 942(vi00) | nop + mfir.x vf29, vi02 | nop + mfir.y vf29, vi03 | nop + mfir.z vf29, vi07 | nop + bal vi15, L36 | nop + mfir.w vf29, vi08 | nop + mtir vi08, vf29.w | nop + mtir vi03, vf29.y | nop + mtir vi07, vf29.z | nop + b L27 | nop + mtir vi02, vf29.x | nop +L35: + sq.xyzw vf21, 1000(vi00) | nop + sq.xyzw vf22, 1003(vi00) | nop + sq.xyzw vf23, 1006(vi00) | nop + sq.xyzw vf31, 942(vi00) | nop + mfir.x vf29, vi02 | nop + mfir.y vf29, vi03 | nop + mfir.z vf29, vi07 | nop + bal vi15, L36 | nop + mfir.w vf29, vi08 | nop + mtir vi08, vf29.w | nop + mtir vi03, vf29.y | nop + mtir vi07, vf29.z | nop + b L33 | nop + mtir vi02, vf29.x | nop +L36: + sq.xyzw vf00, 893(vi00) | nop + sq.xyzw vf00, 900(vi00) | nop + sq.xyzw vf00, 907(vi00) | nop + sq.xyzw vf00, 914(vi00) | nop + sq.xyzw vf00, 921(vi00) | nop + sq.xyzw vf00, 928(vi00) | nop + iaddiu vi01, vi00, 0x2d3 | nop + isw.z vi01, 893(vi00) | nop + iaddiu vi01, vi00, 0x2d5 | nop + isw.z vi01, 900(vi00) | nop + iaddiu vi01, vi00, 0x2d7 | nop + isw.z vi01, 907(vi00) | nop + iaddiu vi01, vi00, 0x2d9 | nop + isw.z vi01, 914(vi00) | nop + iaddiu vi01, vi00, 0x2db | nop + isw.z vi01, 921(vi00) | nop + iaddiu vi01, vi00, 0x2dd | nop + isw.z vi01, 928(vi00) | nop + iaddiu vi03, vi00, 0x3b0 | nop + iaddiu vi04, vi00, 0x3af | nop + mfir.x vf31, vi15 | nop + iaddi vi05, vi00, 0x0 | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3e8 | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3eb | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3ee | nop + b L47 | nop + nop | nop +L37: + sq.xyzw vf00, 893(vi00) | nop + sq.xyzw vf00, 900(vi00) | nop + sq.xyzw vf00, 907(vi00) | nop + sq.xyzw vf00, 914(vi00) | nop + sq.xyzw vf00, 921(vi00) | nop + sq.xyzw vf00, 928(vi00) | nop + iaddiu vi01, vi00, 0x2d3 | nop + isw.z vi01, 893(vi00) | nop + iaddiu vi01, vi00, 0x2d5 | nop + isw.z vi01, 900(vi00) | nop + iaddiu vi01, vi00, 0x2d7 | nop + isw.z vi01, 907(vi00) | nop + iaddiu vi01, vi00, 0x2d9 | nop + isw.z vi01, 914(vi00) | nop + iaddiu vi01, vi00, 0x2db | nop + isw.z vi01, 921(vi00) | nop + iaddiu vi01, vi00, 0x2dd | nop + isw.z vi01, 928(vi00) | nop + iaddiu vi03, vi00, 0x3b0 | nop + iaddiu vi04, vi00, 0x3af | nop + mfir.x vf31, vi15 | nop + iaddi vi05, vi00, 0x0 | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3e8 | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3eb | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3ee | nop + bal vi15, L38 | nop + iaddiu vi07, vi00, 0x3f1 | nop + b L47 | nop + nop | nop +L38: + iaddiu vi09, vi00, 0x37d | nop +L39: + iaddi vi10, vi00, 0x0 | nop +L40: + isubiu vi01, vi09, 0x3a7 | nop + ilwr.y vi08, vi09 | nop + ibgez vi01, L44 | nop + ilwr.z vi06, vi09 | nop + lq.xyzw vf15, 0(vi07) | nop + lq.xyzw vf14, 0(vi08) | nop + ibne vi00, vi08, L41 | nop + iswr.y vi07, vi09 | nop + jalr vi11, vi06 | nop + iswr.x vi07, vi09 | nop + nop | nop + nop | nop + nop | nop + fsand vi02, 0x2 | nop + ibne vi00, vi02, L45 | nop + nop | nop + b L40 | nop + iaddi vi09, vi09, 0x7 | nop +L41: + jalr vi11, vi06 | nop + nop | nop + nop | nop + nop | nop + fsand vi01, 0x2 | nop + fsand vi02, 0x2 | nop + ibne vi00, vi01, L43 | nop + nop | nop + ibne vi00, vi02, L42 | nop + nop | nop + b L40 | nop + iaddi vi09, vi09, 0x7 | nop +L42: + bal vi11, L52 | nop + iaddi vi07, vi09, 0x1 | nop + sq.xyzw vf16, 1(vi09) | nop + b L40 | nop + iaddi vi09, vi09, 0x7 | nop +L43: + ibne vi00, vi02, L45 | nop + nop | nop + bal vi11, L53 | nop + nop | nop + sq.xyzw vf16, 4(vi09) | nop + iaddi vi09, vi09, 0x7 | nop + isw.x vi09, 935(vi10) | nop + isw.y vi07, 935(vi10) | nop + iaddi vi10, vi10, 0x1 | nop + b L40 | nop + iaddi vi07, vi09, -0x3 | nop +L44: + lq.xyzw vf14, 0(vi07) | nop + iaddi vi05, vi05, 0x1 | nop + div Q, vf00.w, vf14.w | nop + nop | mul.xyzw vf14, vf14, vf13 + iaddi vi03, vi03, 0x2 | nop + waitq | subw.w vf14, vf00, vf00 + nop | mul.xyz vf14, vf14, Q + nop | add.xy vf26, vf14, vf03 + nop | mulw.z vf14, vf14, vf12 + nop | add.xyzw vf14, vf14, vf05 + nop | mul.xy vf26, vf26, vf04 + sq.xyzw vf26, -2(vi03) | ftoi4.xyzw vf14, vf14 + sq.xyzw vf14, -1(vi03) | nop +L45: + iblez vi10, L46 | nop + nop | nop + ilw.x vi09, 934(vi10) | nop + ilw.y vi07, 934(vi10) | nop + b L40 | nop + iaddi vi10, vi10, -0x1 | nop +L46: + jr vi15 | nop + nop | nop +L47: + iaddiu vi09, vi00, 0x37d | nop +L48: + ilwr.x vi08, vi09 | nop + ilwr.y vi07, vi09 | nop + ilwr.z vi06, vi09 | nop + nop | nop + ibeq vi00, vi08, L50 | nop + lq.xyzw vf14, 0(vi07) | nop + ibeq vi07, vi08, L50 | nop + lq.xyzw vf15, 0(vi08) | nop + jalr vi11, vi06 | nop + nop | nop + nop | nop + nop | nop + fsand vi01, 0x2 | nop + fsand vi02, 0x2 | nop + ibeq vi02, vi01, L50 | nop + nop | nop + ibeq vi00, vi01, L49 | nop + nop | nop + bal vi11, L53 | nop + nop | nop + sq.xyzw vf16, 4(vi09) | nop + iaddi vi07, vi09, 0x4 | nop + ior vi12, vi09, vi00 | nop + bal vi15, L39 | nop + iaddi vi09, vi09, 0x7 | nop + b L50 | nop + ior vi09, vi12, vi00 | nop +L49: + bal vi11, L52 | nop + nop | nop + sq.xyzw vf16, 1(vi09) | nop + iaddi vi07, vi09, 0x1 | nop + ior vi12, vi09, vi00 | nop + bal vi15, L39 | nop + iaddi vi09, vi09, 0x7 | nop + ior vi09, vi12, vi00 | nop +L50: + isubiu vi01, vi09, 0x3a0 | nop + iswr.x vi00, vi09 | nop + iswr.y vi00, vi09 | nop + ibltz vi01, L48 | nop + iaddi vi09, vi09, 0x7 | nop + ibeq vi00, vi05, L51 | nop + mtir vi15, vf31.x | nop + iaddiu vi05, vi05, 0x4000 | nop + iaddiu vi05, vi05, 0x4000 | nop + iswr.x vi05, vi04 | nop + iaddiu vi01, vi00, 0x3ac | nop + xgkick vi01 | nop + lq.xyzw vf30, 888(vi00) | nop + lq.xyzw vf31, 890(vi00) | nop + iaddiu vi01, vi00, 0x3fe | nop + isubiu vi02, vi00, 0x7fff | nop + sq.xyzw vf30, 0(vi01) | nop + iswr.x vi02, vi01 | nop + sq.xyzw vf31, 1(vi01) | nop + nop | nop + xgkick vi01 | nop +L51: + nop | nop + jr vi15 | nop + nop | nop + jr vi11 | addx.w vf30, vf14, vf14 + nop | addx.w vf31, vf15, vf15 + jr vi11 | subx.w vf30, vf14, vf14 + nop | subx.w vf31, vf15, vf15 + jr vi11 | addy.w vf30, vf14, vf14 + nop | addy.w vf31, vf15, vf15 + jr vi11 | suby.w vf30, vf14, vf14 + nop | suby.w vf31, vf15, vf15 + jr vi11 | addz.w vf30, vf14, vf14 + nop | addz.w vf31, vf15, vf15 + jr vi11 | subz.w vf30, vf14, vf14 + nop | subz.w vf31, vf15, vf15 +L52: + nop | subw.w vf31, vf30, vf31 + div Q, vf30.w, vf31.w | sub.xyzw vf16, vf15, vf14 + waitq | mul.xyzw vf16, vf16, Q + jr vi11 | add.xyzw vf16, vf14, vf16 + nop | nop +L53: + nop | subw.w vf30, vf30, vf31 + div Q, vf31.w, vf30.w | sub.xyzw vf16, vf14, vf15 + waitq | mul.xyzw vf16, vf16, Q + jr vi11 | sub.xyzw vf16, vf15, vf16 + nop | nop + lq. vf00, 0(vi00) | addx. vf00, vf00, vf00 diff --git a/test/decompiler/vu_reference/jak2/shadow-vu1.txt b/test/decompiler/vu_reference/jak2/shadow-vu1.txt new file mode 100644 index 0000000000..10e3f07873 --- /dev/null +++ b/test/decompiler/vu_reference/jak2/shadow-vu1.txt @@ -0,0 +1,1492 @@ + .word 0x40000009 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x40000013 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x400000cb + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x40000148 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x400002ff + .word 0x80000030 + .word 0x2ff + .word 0x10010358 + .word 0x2ff + .word 0x10020364 + .word 0x2ff + .word 0x81010bfd + .word 0x2ff + .word 0x808113fd + .word 0x2ff + .word 0x80410bfd + .word 0x2ff + .word 0x802113fd + .word 0x2ff + .word 0x1e20370 + .word 0x2ff + .word 0x1e30372 + .word 0x2ff + .word 0x1e40373 + .word 0x2ff + .word 0x1e50374 + .word 0x2ff + .word 0x1ec0375 + .word 0x400002ff + .word 0x1ed0371 + .word 0x2ff + .word 0x10030158 + .word 0x2ff + .word 0x81081bfe + .word 0x2ff + .word 0x80020bfc + .word 0x2ff + .word 0x80031872 + .word 0x400643 + .word 0x1f90378 + .word 0x400683 + .word 0x1fd0379 + .word 0x4006c3 + .word 0x1fe037b + .word 0x400703 + .word 0x1e60000 + .word 0x2ff + .word 0x1e70001 + .word 0x2ff + .word 0x1e80002 + .word 0x2ff + .word 0x1e90003 + .word 0x2ff + .word 0x80210bfc + .word 0x2ff + .word 0x3e2c800 + .word 0x2ff + .word 0x3e2e801 + .word 0x2ff + .word 0x3e2f002 + .word 0x2ff + .word 0x3e1c800 + .word 0x2ff + .word 0x3e1e801 + .word 0x2ff + .word 0x3e1f002 + .word 0x2ff + .word 0x81f01b7c + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x800483fc + .word 0x2ff + .word 0x802583fc + .word 0x2ff + .word 0x804683fc + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x1f12004 + .word 0x2ff + .word 0x1f22804 + .word 0x2ff + .word 0x1f33004 + .word 0x2ff + .word 0x80000030 + .word 0x1e049bf + .word 0x81ef8b3c + .word 0x1f130bc + .word 0x80000030 + .word 0x1f138bd + .word 0x80000030 + .word 0x1f1444a + .word 0x80000030 + .word 0x1e049bf + .word 0x80000030 + .word 0x1ef976c + .word 0x80000030 + .word 0x1ef9fac + .word 0x819163bc + .word 0x1f230bc + .word 0x80000030 + .word 0x1e28d6a + .word 0x80000030 + .word 0x1f238bd + .word 0x80000030 + .word 0x1f2448a + .word 0x80000030 + .word 0x1e049bf + .word 0x80000030 + .word 0x1f330bc + .word 0x80000030 + .word 0x1f338bd + .word 0x819263bc + .word 0x1c08c5c + .word 0x80000030 + .word 0x1f344ca + .word 0x80000030 + .word 0x1e295aa + .word 0x80000030 + .word 0x1deeafe + .word 0x80000030 + .word 0x1838e68 + .word 0x80000030 + .word 0x4c8c5b + .word 0x80000030 + .word 0x1ddf76e + .word 0x819363bc + .word 0x1c0949c + .word 0x80000030 + .word 0x1e29dea + .word 0x80000030 + .word 0x1cfef6a + .word 0x80000030 + .word 0x18396a8 + .word 0x80000030 + .word 0x1e58c68 + .word 0x80000030 + .word 0x4c949b + .word 0x80000030 + .word 0x184ce6a + .word 0x80000030 + .word 0x1c09cdc + .word 0x80000030 + .word 0x1f1897d + .word 0x22000000 + .word 0x11def41 + .word 0x80000030 + .word 0x1e594a8 + .word 0x80000030 + .word 0x1d5a9ff + .word 0x80000030 + .word 0x4c9cdb + .word 0x3e2c804 + .word 0x184d6aa + .word 0x3e28805 + .word 0x11def42 + .word 0x80000030 + .word 0x1f2917d + .word 0x80000030 + .word 0x1839ee8 + .word 0x3e2d006 + .word 0x1e59ce8 + .word 0x2c010002 + .word 0x1d6b1ff + .word 0x3e29007 + .word 0x1d7b9ff + .word 0x50000803 + .word 0x184deea + .word 0x80000030 + .word 0x2ff + .word 0x40000002 + .word 0x2ff + .word 0x1ff0377 + .word 0x2ff + .word 0x1ff0376 + .word 0x2ff + .word 0x2403ffff + .word 0x1f3997d + .word 0x52000851 + .word 0x2ff + .word 0x800847f2 + .word 0x2ff + .word 0x3e2d808 + .word 0x2ff + .word 0x3e2f803 + .word 0x2ff + .word 0x3e29809 + .word 0x2ff + .word 0x800016fc + .word 0x2ff + .word 0x80220bfc + .word 0x2ff + .word 0x81e10b3d + .word 0x2ff + .word 0x5a0047bd + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x10030158 + .word 0x2ff + .word 0x81081bfe + .word 0x2ff + .word 0x80811bfe + .word 0x2ff + .word 0x80031872 + .word 0x2ff + .word 0x81f01b7c + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x800483fc + .word 0x2ff + .word 0x802583fc + .word 0x2ff + .word 0x804683fc + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x1f120ae + .word 0x2ff + .word 0x1f230ae + .word 0x2ff + .word 0x1f328ae + .word 0x2ff + .word 0x80000030 + .word 0x1e049bf + .word 0x81ef8b3c + .word 0x1f130bc + .word 0x80000030 + .word 0x1f138bd + .word 0x80000030 + .word 0x1f1444a + .word 0x80000030 + .word 0x1e049bf + .word 0x80000030 + .word 0x1ef976c + .word 0x80000030 + .word 0x1ef9fac + .word 0x819163bc + .word 0x1f230bc + .word 0x80000030 + .word 0x1e28d6a + .word 0x80000030 + .word 0x1f238bd + .word 0x80000030 + .word 0x1f2448a + .word 0x80000030 + .word 0x1e049bf + .word 0x80000030 + .word 0x1f330bc + .word 0x80000030 + .word 0x1f338bd + .word 0x819263bc + .word 0x1c08c5c + .word 0x80000030 + .word 0x1f344ca + .word 0x80000030 + .word 0x1e295aa + .word 0x80000030 + .word 0x1deeafe + .word 0x80000030 + .word 0x1838e68 + .word 0x80000030 + .word 0x4c8c5b + .word 0x80000030 + .word 0x1ddf76e + .word 0x819363bc + .word 0x1c0949c + .word 0x80000030 + .word 0x1e29dea + .word 0x80000030 + .word 0x1cfef6a + .word 0x80000030 + .word 0x18396a8 + .word 0x80000030 + .word 0x1e58c68 + .word 0x80000030 + .word 0x4c949b + .word 0x80000030 + .word 0x184ce6a + .word 0x80000030 + .word 0x1c09cdc + .word 0x80000030 + .word 0x1f1897d + .word 0x22000000 + .word 0x11def41 + .word 0x80000030 + .word 0x1e594a8 + .word 0x80000030 + .word 0x1d5a9ff + .word 0x3e2c804 + .word 0x4c9cdb + .word 0x3e28805 + .word 0x184d6aa + .word 0x800847f2 + .word 0x11def42 + .word 0x80000030 + .word 0x1f2917d + .word 0x80000030 + .word 0x1839ee8 + .word 0x3e2d006 + .word 0x1e59ce8 + .word 0x2c010002 + .word 0x1d6b1ff + .word 0x3e29007 + .word 0x1d7b9ff + .word 0x50000803 + .word 0x184deea + .word 0x80000030 + .word 0x2ff + .word 0x40000002 + .word 0x2ff + .word 0x1ff0377 + .word 0x2ff + .word 0x1ff0376 + .word 0x2ff + .word 0x2403ffff + .word 0x1f3997d + .word 0x52000818 + .word 0x2ff + .word 0x3e2d808 + .word 0x2ff + .word 0x3e2f803 + .word 0x2ff + .word 0x3e29809 + .word 0x2ff + .word 0x800016fc + .word 0x2ff + .word 0x80220bfc + .word 0x2ff + .word 0x81e10b3d + .word 0x2ff + .word 0x5a0047bf + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x400002ff + .word 0x80000030 + .word 0x2ff + .word 0x3e0abe8 + .word 0x2ff + .word 0x3e0b3eb + .word 0x2ff + .word 0x3e0bbee + .word 0x2ff + .word 0x3e0fbae + .word 0x2ff + .word 0x811d13fd + .word 0x2ff + .word 0x809d1bfd + .word 0x2ff + .word 0x805d3bfd + .word 0x2ff + .word 0x420f0158 + .word 0x2ff + .word 0x803d43fd + .word 0x2ff + .word 0x8068ebfc + .word 0x2ff + .word 0x8023ebfc + .word 0x2ff + .word 0x8047ebfc + .word 0x2ff + .word 0x400007a9 + .word 0x2ff + .word 0x8002ebfc + .word 0x2ff + .word 0x3e0abe8 + .word 0x2ff + .word 0x3e0b3eb + .word 0x2ff + .word 0x3e0bbee + .word 0x2ff + .word 0x3e0fbae + .word 0x2ff + .word 0x811d13fd + .word 0x2ff + .word 0x809d1bfd + .word 0x2ff + .word 0x805d3bfd + .word 0x2ff + .word 0x420f014a + .word 0x2ff + .word 0x803d43fd + .word 0x2ff + .word 0x8068ebfc + .word 0x2ff + .word 0x8023ebfc + .word 0x2ff + .word 0x8047ebfc + .word 0x2ff + .word 0x400007e1 + .word 0x2ff + .word 0x8002ebfc + .word 0x2ff + .word 0x10030258 + .word 0x2ff + .word 0x81081bfe + .word 0x2ff + .word 0x80020bfc + .word 0x2ff + .word 0x80031872 + .word 0x400643 + .word 0x1f90378 + .word 0x400683 + .word 0x1fd0379 + .word 0x4006c3 + .word 0x1fe037c + .word 0x2ff + .word 0x1e60000 + .word 0x2ff + .word 0x1e70001 + .word 0x2ff + .word 0x1e80002 + .word 0x2ff + .word 0x1e90003 + .word 0x2ff + .word 0x80210bfc + .word 0x2ff + .word 0x3e2c800 + .word 0x2ff + .word 0x3e2e801 + .word 0x2ff + .word 0x3e2f002 + .word 0x2ff + .word 0x3e1c800 + .word 0x2ff + .word 0x3e1e801 + .word 0x2ff + .word 0x3e1f002 + .word 0x2ff + .word 0x81f01b7c + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x804683fc + .word 0x2ff + .word 0x800483fc + .word 0x2ff + .word 0x802583fc + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x50003006 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x1f12004 + .word 0x2ff + .word 0x1f22804 + .word 0x2ff + .word 0x1f328ae + .word 0x2ff + .word 0x40000005 + .word 0x2ff + .word 0x1f420ae + .word 0x2ff + .word 0x1f12804 + .word 0x2ff + .word 0x1f22004 + .word 0x2ff + .word 0x1f320ae + .word 0x2ff + .word 0x1f428ae + .word 0x2ff + .word 0x81ef8b3c + .word 0x1e049bf + .word 0x80000030 + .word 0x1f130bc + .word 0x80000030 + .word 0x1f138bd + .word 0x80000030 + .word 0x1f1444a + .word 0x80000030 + .word 0x1e049bf + .word 0x80000030 + .word 0x1ef976c + .word 0x80000030 + .word 0x1ef9fac + .word 0x819163bc + .word 0x1f230bc + .word 0x80000030 + .word 0x1e28d6a + .word 0x80000030 + .word 0x1f238bd + .word 0x80000030 + .word 0x1f2448a + .word 0x80000030 + .word 0x1e049bf + .word 0x80000030 + .word 0x1f330bc + .word 0x80000030 + .word 0x1f338bd + .word 0x819263bc + .word 0x1c08c5c + .word 0x80000030 + .word 0x1f344ca + .word 0x80000030 + .word 0x1e049bf + .word 0x80000030 + .word 0x1f430bc + .word 0x80000030 + .word 0x1f438bd + .word 0x80000030 + .word 0x1f4450a + .word 0x80000030 + .word 0x1e295aa + .word 0x819363bc + .word 0x1c0949c + .word 0x80000030 + .word 0x1838e68 + .word 0x80000030 + .word 0x4c8c5b + .word 0x80000030 + .word 0x1deeafe + .word 0x80000030 + .word 0x1ddf76e + .word 0x80000030 + .word 0x1e29dea + .word 0x80000030 + .word 0x1cfef6a + .word 0x819463bc + .word 0x1c09cdc + .word 0x80000030 + .word 0x1e58c68 + .word 0x80000030 + .word 0x1e2a62a + .word 0x80000030 + .word 0x184ce6a + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x1f1897d + .word 0x80000030 + .word 0x18396a8 + .word 0x80000030 + .word 0x1c0a51c + .word 0x80000030 + .word 0x4c949b + .word 0x80000030 + .word 0x11def41 + .word 0x3e2c804 + .word 0x2ff + .word 0x3e28805 + .word 0x2ff + .word 0x80000030 + .word 0x1e594a8 + .word 0x80000030 + .word 0x1d5a9ff + .word 0x80000030 + .word 0x184d6aa + .word 0x80000030 + .word 0x11def42 + .word 0x80000030 + .word 0x1f2917d + .word 0x80000030 + .word 0x1839ee8 + .word 0x3e2d006 + .word 0x4c9cdb + .word 0x2c010002 + .word 0x1d6b1ff + .word 0x3e29007 + .word 0x1d7b9ff + .word 0x80000030 + .word 0x1d8c1ff + .word 0x80000030 + .word 0x183a728 + .word 0x80000030 + .word 0x4ca51b + .word 0x80000030 + .word 0x184deea + .word 0x80000030 + .word 0x1e59ce8 + .word 0x80000030 + .word 0x2ff + .word 0x50000803 + .word 0x184e72a + .word 0x80000030 + .word 0x1e5a528 + .word 0x40000002 + .word 0x2ff + .word 0x1ff0377 + .word 0x2ff + .word 0x1ff0376 + .word 0x2ff + .word 0x24ffffff + .word 0x1f3997d + .word 0x5200080d + .word 0x2ff + .word 0x800847f2 + .word 0x2ff + .word 0x3e2d808 + .word 0x1f4a17d + .word 0x3e2f803 + .word 0x2ff + .word 0x3e29809 + .word 0x2ff + .word 0x3e2e00a + .word 0x2ff + .word 0x3e2a00b + .word 0x2ff + .word 0x800016fc + .word 0x2ff + .word 0x80220bfc + .word 0x2ff + .word 0x81e10b3d + .word 0x2ff + .word 0x5a0047a5 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x400002ff + .word 0x80000030 + .word 0x2ff + .word 0x3e0abe8 + .word 0x2ff + .word 0x3e0b3eb + .word 0x2ff + .word 0x3e0bbee + .word 0x2ff + .word 0x3e0c3f1 + .word 0x2ff + .word 0x3e0fbae + .word 0x2ff + .word 0x811d13fd + .word 0x2ff + .word 0x809d1bfd + .word 0x2ff + .word 0x805d3bfd + .word 0x2ff + .word 0x420f00e9 + .word 0x2ff + .word 0x803d43fd + .word 0x2ff + .word 0x8068ebfc + .word 0x2ff + .word 0x8023ebfc + .word 0x2ff + .word 0x8047ebfc + .word 0x2ff + .word 0x400007ee + .word 0x2ff + .word 0x8002ebfc + .word 0x2ff + .word 0x10030158 + .word 0x2ff + .word 0x81081bfe + .word 0x2ff + .word 0x80020bfc + .word 0x2ff + .word 0x80031872 + .word 0x400643 + .word 0x1f90378 + .word 0x400683 + .word 0x1fd0379 + .word 0x4006c3 + .word 0x1fe037b + .word 0x400703 + .word 0x1e60000 + .word 0x2ff + .word 0x1e70001 + .word 0x2ff + .word 0x1e80002 + .word 0x2ff + .word 0x1e90003 + .word 0x2ff + .word 0x80210bfc + .word 0x2ff + .word 0x3e2c800 + .word 0x2ff + .word 0x3e2e801 + .word 0x2ff + .word 0x3e2f002 + .word 0x2ff + .word 0x3e1c800 + .word 0x2ff + .word 0x3e1e801 + .word 0x2ff + .word 0x3e1f002 + .word 0x2ff + .word 0x81f01b7c + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x806183fc + .word 0x2ff + .word 0x800483fc + .word 0x2ff + .word 0x802583fc + .word 0x2ff + .word 0x804683fc + .word 0x2ff + .word 0x50000804 + .word 0x2ff + .word 0x1f12004 + .word 0x2ff + .word 0x1f22804 + .word 0x2ff + .word 0x40000003 + .word 0x2ff + .word 0x1f33004 + .word 0x2ff + .word 0x1f32804 + .word 0x2ff + .word 0x1f23004 + .word 0x2ff + .word 0x80000030 + .word 0x1e049bf + .word 0x81ef8b3c + .word 0x1f130bc + .word 0x80000030 + .word 0x1f138bd + .word 0x80000030 + .word 0x1f1976c + .word 0x80000030 + .word 0x1f19fac + .word 0x80000030 + .word 0x1f1444a + .word 0x80000030 + .word 0x1e049bf + .word 0x819163bc + .word 0x1f230bc + .word 0x80000030 + .word 0x1f238bd + .word 0x80000030 + .word 0x1e28d6a + .word 0x80000030 + .word 0x1f2448a + .word 0x80000030 + .word 0x1e049bf + .word 0x80000030 + .word 0x1f330bc + .word 0x80000030 + .word 0x1f338bd + .word 0x819263bc + .word 0x1c08c5c + .word 0x80000030 + .word 0x1f344ca + .word 0x80000030 + .word 0x1e295aa + .word 0x80000030 + .word 0x1deeafe + .word 0x80000030 + .word 0x1ddf76e + .word 0x80000030 + .word 0x1838e68 + .word 0x80000030 + .word 0x4c8c5b + .word 0x819363bc + .word 0x1c0949c + .word 0x80000030 + .word 0x1e29dea + .word 0x80000030 + .word 0x1cfef6a + .word 0x80000030 + .word 0x1e58c68 + .word 0x80000030 + .word 0x184ce6a + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x1f1897d + .word 0x80000030 + .word 0x18396a8 + .word 0x80000030 + .word 0x4c949b + .word 0x22000000 + .word 0x11def41 + .word 0x80000030 + .word 0x1c09cdc + .word 0x3e2c804 + .word 0x2ff + .word 0x3e28805 + .word 0x1e594a8 + .word 0x80000030 + .word 0x1d5a9ff + .word 0x80000030 + .word 0x184d6aa + .word 0x80000030 + .word 0x11def42 + .word 0x80000030 + .word 0x1f2917d + .word 0x80000030 + .word 0x1839ee8 + .word 0x3e2d006 + .word 0x4c9cdb + .word 0x2c010002 + .word 0x1d6b1ff + .word 0x3e29007 + .word 0x1d7b9ff + .word 0x50000803 + .word 0x184deea + .word 0x80000030 + .word 0x1e59ce8 + .word 0x40000002 + .word 0x2ff + .word 0x1ff0377 + .word 0x2ff + .word 0x1ff0376 + .word 0x2ff + .word 0x2403ffff + .word 0x1f3997d + .word 0x52000857 + .word 0x2ff + .word 0x800847f2 + .word 0x2ff + .word 0x3e2d808 + .word 0x2ff + .word 0x3e2f803 + .word 0x2ff + .word 0x3e29809 + .word 0x2ff + .word 0x800016fc + .word 0x2ff + .word 0x80220bfc + .word 0x2ff + .word 0x81e10b3d + .word 0x2ff + .word 0x5a0047b8 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x10030158 + .word 0x2ff + .word 0x81081bfe + .word 0x2ff + .word 0x80811bfe + .word 0x2ff + .word 0x80031872 + .word 0x2ff + .word 0x81f01b7c + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x806183fc + .word 0x2ff + .word 0x800483fc + .word 0x2ff + .word 0x802583fc + .word 0x2ff + .word 0x804683fc + .word 0x2ff + .word 0x52000804 + .word 0x2ff + .word 0x1f120ae + .word 0x2ff + .word 0x1f228ae + .word 0x2ff + .word 0x40000003 + .word 0x2ff + .word 0x1f330ae + .word 0x2ff + .word 0x1f328ae + .word 0x2ff + .word 0x1f230ae + .word 0x2ff + .word 0x80000030 + .word 0x1e049bf + .word 0x81ef8b3c + .word 0x1f130bc + .word 0x80000030 + .word 0x1f138bd + .word 0x80000030 + .word 0x1f1444a + .word 0x80000030 + .word 0x1e049bf + .word 0x80000030 + .word 0x1ef976c + .word 0x80000030 + .word 0x1ef9fac + .word 0x819163bc + .word 0x1f230bc + .word 0x80000030 + .word 0x1e28d6a + .word 0x80000030 + .word 0x1f238bd + .word 0x80000030 + .word 0x1f2448a + .word 0x80000030 + .word 0x1e049bf + .word 0x80000030 + .word 0x1f330bc + .word 0x80000030 + .word 0x1f338bd + .word 0x819263bc + .word 0x1c08c5c + .word 0x80000030 + .word 0x1f344ca + .word 0x80000030 + .word 0x1e295aa + .word 0x80000030 + .word 0x1deeafe + .word 0x80000030 + .word 0x1ddf76e + .word 0x80000030 + .word 0x1838e68 + .word 0x80000030 + .word 0x4c8c5b + .word 0x819363bc + .word 0x1c0949c + .word 0x80000030 + .word 0x1e29dea + .word 0x80000030 + .word 0x1cfef6a + .word 0x80000030 + .word 0x1e58c68 + .word 0x80000030 + .word 0x184ce6a + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x18396a8 + .word 0x80000030 + .word 0x1f1897d + .word 0x80000030 + .word 0x4c949b + .word 0x22000000 + .word 0x11def41 + .word 0x80000030 + .word 0x1c09cdc + .word 0x3e2c804 + .word 0x2ff + .word 0x3e28805 + .word 0x1e594a8 + .word 0x80000030 + .word 0x1d5a9ff + .word 0x80000030 + .word 0x184d6aa + .word 0x80000030 + .word 0x11def42 + .word 0x80000030 + .word 0x1f2917d + .word 0x80000030 + .word 0x1839ee8 + .word 0x3e2d006 + .word 0x4c9cdb + .word 0x2c010002 + .word 0x1d6b1ff + .word 0x3e29007 + .word 0x1d7b9ff + .word 0x50000803 + .word 0x184deea + .word 0x80000030 + .word 0x1e59ce8 + .word 0x40000002 + .word 0x2ff + .word 0x1ff0377 + .word 0x2ff + .word 0x1ff0376 + .word 0x2ff + .word 0x2403ffff + .word 0x1f3997d + .word 0x52000819 + .word 0x2ff + .word 0x800847f2 + .word 0x2ff + .word 0x3e2d808 + .word 0x2ff + .word 0x3e2f803 + .word 0x2ff + .word 0x3e29809 + .word 0x2ff + .word 0x800016fc + .word 0x2ff + .word 0x80220bfc + .word 0x2ff + .word 0x81e10b3d + .word 0x2ff + .word 0x5a0047b9 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x400002ff + .word 0x80000030 + .word 0x2ff + .word 0x3e0abe8 + .word 0x2ff + .word 0x3e0b3eb + .word 0x2ff + .word 0x3e0bbee + .word 0x2ff + .word 0x3e0fbae + .word 0x2ff + .word 0x811d13fd + .word 0x2ff + .word 0x809d1bfd + .word 0x2ff + .word 0x805d3bfd + .word 0x2ff + .word 0x420f0014 + .word 0x2ff + .word 0x803d43fd + .word 0x2ff + .word 0x8068ebfc + .word 0x2ff + .word 0x8023ebfc + .word 0x2ff + .word 0x8047ebfc + .word 0x2ff + .word 0x400007a3 + .word 0x2ff + .word 0x8002ebfc + .word 0x2ff + .word 0x3e0abe8 + .word 0x2ff + .word 0x3e0b3eb + .word 0x2ff + .word 0x3e0bbee + .word 0x2ff + .word 0x3e0fbae + .word 0x2ff + .word 0x811d13fd + .word 0x2ff + .word 0x809d1bfd + .word 0x2ff + .word 0x805d3bfd + .word 0x2ff + .word 0x420f0006 + .word 0x2ff + .word 0x803d43fd + .word 0x2ff + .word 0x8068ebfc + .word 0x2ff + .word 0x8023ebfc + .word 0x2ff + .word 0x8047ebfc + .word 0x2ff + .word 0x400007e1 + .word 0x2ff + .word 0x8002ebfc + .word 0x2ff + .word 0x3e0037d + .word 0x2ff + .word 0x3e00384 + .word 0x2ff + .word 0x3e0038b + .word 0x2ff + .word 0x3e00392 + .word 0x2ff + .word 0x3e00399 + .word 0x2ff + .word 0x3e003a0 + .word 0x2ff + .word 0x100102d3 + .word 0x2ff + .word 0xa41037d + .word 0x2ff + .word 0x100102d5 + .word 0x2ff + .word 0xa410384 + .word 0x2ff + .word 0x100102d7 + .word 0x2ff + .word 0xa41038b + .word 0x2ff + .word 0x100102d9 + .word 0x2ff + .word 0xa410392 + .word 0x2ff + .word 0x100102db + .word 0x2ff + .word 0xa410399 + .word 0x2ff + .word 0x100102dd + .word 0x2ff + .word 0xa4103a0 + .word 0x2ff + .word 0x100303b0 + .word 0x2ff + .word 0x100403af + .word 0x2ff + .word 0x811f7bfd + .word 0x2ff + .word 0x80050032 + .word 0x2ff + .word 0x420f0027 + .word 0x2ff + .word 0x100703e8 + .word 0x2ff + .word 0x420f0025 + .word 0x2ff + .word 0x100703eb + .word 0x2ff + .word 0x420f0023 + .word 0x2ff + .word 0x100703ee + .word 0x2ff + .word 0x40000066 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x3e0037d + .word 0x2ff + .word 0x3e00384 + .word 0x2ff + .word 0x3e0038b + .word 0x2ff + .word 0x3e00392 + .word 0x2ff + .word 0x3e00399 + .word 0x2ff + .word 0x3e003a0 + .word 0x2ff + .word 0x100102d3 + .word 0x2ff + .word 0xa41037d + .word 0x2ff + .word 0x100102d5 + .word 0x2ff + .word 0xa410384 + .word 0x2ff + .word 0x100102d7 + .word 0x2ff + .word 0xa41038b + .word 0x2ff + .word 0x100102d9 + .word 0x2ff + .word 0xa410392 + .word 0x2ff + .word 0x100102db + .word 0x2ff + .word 0xa410399 + .word 0x2ff + .word 0x100102dd + .word 0x2ff + .word 0xa4103a0 + .word 0x2ff + .word 0x100303b0 + .word 0x2ff + .word 0x100403af + .word 0x2ff + .word 0x811f7bfd + .word 0x2ff + .word 0x80050032 + .word 0x2ff + .word 0x420f0009 + .word 0x2ff + .word 0x100703e8 + .word 0x2ff + .word 0x420f0007 + .word 0x2ff + .word 0x100703eb + .word 0x2ff + .word 0x420f0005 + .word 0x2ff + .word 0x100703ee + .word 0x2ff + .word 0x420f0003 + .word 0x2ff + .word 0x100703f1 + .word 0x2ff + .word 0x40000046 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x1009037d + .word 0x2ff + .word 0x800a0032 + .word 0x2ff + .word 0x12014ba7 + .word 0x2ff + .word 0x80884bfe + .word 0x2ff + .word 0x5e00082b + .word 0x2ff + .word 0x80464bfe + .word 0x2ff + .word 0x1ef3800 + .word 0x2ff + .word 0x1ee4000 + .word 0x2ff + .word 0x5200400b + .word 0x2ff + .word 0x80874bff + .word 0x2ff + .word 0x4a0b3000 + .word 0x2ff + .word 0x81074bff + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x2c020002 + .word 0x2ff + .word 0x5200102c + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x400007ef + .word 0x2ff + .word 0x800949f2 + .word 0x2ff + .word 0x4a0b3000 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x2c010002 + .word 0x2ff + .word 0x2c020002 + .word 0x2ff + .word 0x5200080a + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x52001003 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x400007e3 + .word 0x2ff + .word 0x800949f2 + .word 0x2ff + .word 0x420b006c + .word 0x2ff + .word 0x80074872 + .word 0x2ff + .word 0x3e98001 + .word 0x2ff + .word 0x400007de + .word 0x2ff + .word 0x800949f2 + .word 0x2ff + .word 0x52001017 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x420b006a + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x3e98004 + .word 0x2ff + .word 0x800949f2 + .word 0x2ff + .word 0xb0953a7 + .word 0x2ff + .word 0xa8753a7 + .word 0x2ff + .word 0x800a5072 + .word 0x2ff + .word 0x400007d3 + .word 0x2ff + .word 0x80074f72 + .word 0x2ff + .word 0x1ee3800 + .word 0x2ff + .word 0x80052872 + .word 0x2ff + .word 0x81ee03bc + .word 0x2ff + .word 0x80000030 + .word 0x1ed73aa + .word 0x800318b2 + .word 0x2ff + .word 0x800003bf + .word 0x200387 + .word 0x80000030 + .word 0x1c0739c + .word 0x80000030 + .word 0x18376a8 + .word 0x80000030 + .word 0x4c739b + .word 0x80000030 + .word 0x1e573a8 + .word 0x80000030 + .word 0x184d6aa + .word 0x3e3d7fe + .word 0x1ee717d + .word 0x3e377ff + .word 0x2ff + .word 0x5c005005 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x90953a6 + .word 0x2ff + .word 0x88753a6 + .word 0x2ff + .word 0x400007c0 + .word 0x2ff + .word 0x800a57f2 + .word 0x2ff + .word 0x48007800 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x1009037d + .word 0x2ff + .word 0x81084bfe + .word 0x2ff + .word 0x80874bfe + .word 0x2ff + .word 0x80464bfe + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x5000401e + .word 0x2ff + .word 0x1ee3800 + .word 0x2ff + .word 0x5007401c + .word 0x2ff + .word 0x1ef4000 + .word 0x2ff + .word 0x4a0b3000 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x2c010002 + .word 0x2ff + .word 0x2c020002 + .word 0x2ff + .word 0x50020814 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x5000080a + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x420b0039 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x3e98004 + .word 0x2ff + .word 0x80074932 + .word 0x2ff + .word 0x80004b35 + .word 0x2ff + .word 0x420f07a3 + .word 0x2ff + .word 0x800949f2 + .word 0x2ff + .word 0x40000009 + .word 0x2ff + .word 0x80006275 + .word 0x2ff + .word 0x420b002b + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x3e98001 + .word 0x2ff + .word 0x80074872 + .word 0x2ff + .word 0x80004b35 + .word 0x2ff + .word 0x420f079a + .word 0x2ff + .word 0x800949f2 + .word 0x2ff + .word 0x80006275 + .word 0x2ff + .word 0x12014ba0 + .word 0x2ff + .word 0x81004bff + .word 0x2ff + .word 0x80804bff + .word 0x2ff + .word 0x58000fd9 + .word 0x2ff + .word 0x800949f2 + .word 0x2ff + .word 0x5000280f + .word 0x2ff + .word 0x800ffbfc + .word 0x2ff + .word 0x11052800 + .word 0x2ff + .word 0x11052800 + .word 0x2ff + .word 0x810523ff + .word 0x2ff + .word 0x100103ac + .word 0x2ff + .word 0x80000efc + .word 0x2ff + .word 0x1fe0378 + .word 0x2ff + .word 0x1ff037a + .word 0x2ff + .word 0x100103fe + .word 0x2ff + .word 0x13e207ff + .word 0x2ff + .word 0x3e1f000 + .word 0x2ff + .word 0x81020bff + .word 0x2ff + .word 0x3e1f801 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x80000efc + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x48007800 + .word 0x2ff + .word 0x80000030 + .word 0x2ff + .word 0x48005800 + .word 0x2e7780 + .word 0x80000030 + .word 0x2f7fc0 + .word 0x48005800 + .word 0x2e7784 + .word 0x80000030 + .word 0x2f7fc4 + .word 0x48005800 + .word 0x2e7781 + .word 0x80000030 + .word 0x2f7fc1 + .word 0x48005800 + .word 0x2e7785 + .word 0x80000030 + .word 0x2f7fc5 + .word 0x48005800 + .word 0x2e7782 + .word 0x80000030 + .word 0x2f7fc2 + .word 0x48005800 + .word 0x2e7786 + .word 0x80000030 + .word 0x2f7fc6 + .word 0x80000030 + .word 0x3ff7c7 + .word 0x81fff3bc + .word 0x1ee7c2c + .word 0x800003bf + .word 0x1e0841c + .word 0x48005800 + .word 0x1f07428 + .word 0x80000030 + .word 0x2ff + .word 0x80000030 + .word 0x3ff787 + .word 0x81fefbbc + .word 0x1ef742c + .word 0x800003bf + .word 0x1e0841c + .word 0x48005800 + .word 0x1f07c2c + .word 0x80000030 + .word 0x2ff + .word 0x0 + .word 0x0 \ No newline at end of file diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index d865a103cf..7520046927 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -311,7 +311,9 @@ "(method 224 crimson-guard)", // .mula.s "metalkor-egg-reaction", // .mula.s "init-vortex-polys", - "(method 11 cty-guard-turret)" // handle casts + "(method 11 cty-guard-turret)", // handle casts + "shadow-execute-all", + "shadow-vu0-upload" ], "skip_compile_states": {