diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index 6bf1868980..d2ad2e54d5 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -3540,7 +3540,7 @@ (bucket2 2) ;; pc vis stuff (bucket3 3) ;; blit? (tex-lcom-sky-pre 4) - (bucket5 5) ;; sky + (sky 5) ;; sky (bucket6 6) ;; ocean (bucket7 7) ;; unknown new jak 3 texture upload, for all levels. (hfrag 8) ;; hfrag @@ -4234,7 +4234,7 @@ (rn0) (rn1) (rn2) - (rn3) + (sky) (rn4) (rn5) (hfrag) @@ -4468,6 +4468,8 @@ (deftype dma-gif (structure) "Believed unused GIF header type." ((gif uint64 2 :offset-assert 0) ;; guessed by decompiler + (gif0 uint64 :overlay-at (-> gif 0) :score 1) + (gif1 uint64 :overlay-at (-> gif 1) :score 1) (quad uint128 :offset-assert 0 :overlay-at gif) ) :method-count-assert 9 @@ -4479,6 +4481,8 @@ "The header for a DMA transfer that goes directly to GIF, containing DMA, VIF, GIF tags." ((dma-vif dma-packet :inline :offset-assert 0) (gif uint64 2 :offset-assert 16) ;; guessed by decompiler + (gif0 uint64 :offset 16 :score -1) + (gif1 uint64 :offset 24 :score -1) (quad uint128 2 :offset-assert 0 :overlay-at dma-vif) ;; guessed by decompiler ) :method-count-assert 9 @@ -5519,6 +5523,32 @@ :flag-assert #x900000010 ) +; (deftype dma-gif-packet (structure) +; "The header for a DMA transfer that goes directly to GIF, containing DMA, VIF, GIF tags." +; ((dma-vif dma-packet :inline :offset-assert 0) +; ;;(gif uint64 2 :offset-assert 16) ;; guessed by decompiler +; (gif0 gif-tag64 :offset 16 :score 1) +; (gif1 gif-tag-regs :offset 24 :score 1) +; (quad uint128 2 :offset-assert 0 :overlay-at dma-vif) ;; guessed by decompiler +; ) +; :method-count-assert 9 +; :size-assert #x20 +; :flag-assert #x900000020 +; ) + +; (deftype dma-gif (structure) +; "Believed unused GIF header type." +; ((gif uint64 2 :offset-assert 0) ;; guessed by decompiler +; (gif0 gif-tag64 :overlay-at (-> gif 0) :score 1) +; (gif1 gif-tag-regs :overlay-at (-> gif 1) :score 1) +; (quad uint128 :offset-assert 0 :overlay-at gif) +; ) +; :method-count-assert 9 +; :size-assert #x10 +; :flag-assert #x900000010 +; ) + + (deftype gif-packet (basic) "Unused type for building a dynamically sized gif packet." ((reg-count int32 :offset-assert 4) @@ -11484,7 +11514,7 @@ (blit-displays-work-method-17 (_type_ vector int float symbol) none) ;; 17 (blit-displays-work-method-18 () none) ;; 18 (blit-displays-work-method-19 (_type_) none) ;; 19 (called from main.gc) - (blit-displays-work-method-20 () none) ;; 20 + (blit-displays-work-method-20 (_type_) none) ;; 20 (get-menu-mode (_type_) symbol) ;; 21 (get-screen-copied (_type_) symbol) ;; 22 (get-horizontal-flip-flag (_type_) symbol) ;; 23 @@ -11715,33 +11745,33 @@ (init-sun-data! (_type_ int float float float) none) ;; 9 (init-orbit-settings! (_type_ int float float float float float float) none) ;; 10 (update-colors-for-time (_type_ float) none) ;; 11 - (update-time-and-speed (_type_ float float) none) ;; 12 - (sky-work-method-13 () none) ;; 13 - (draw (_type_) none) ;; 14 ;; (update-matrix (_type_ matrix) none) - (sky-work-method-15 () none) ;; 15 ;; (update-template-colors (_type_) none) - (sky-work-method-16 () none) ;; 16 ;; (init-regs-for-large-polygon-draw (_type_) none) - (sky-work-method-17 () none) ;; 17 ;; (init-regs-for-sky-asm (_type_) none) - (sky-work-method-18 () none) ;; 18 ;; (cloud-vtx-light-update (_type_ vector vector cloud-lights vector vector) none) - (sky-work-method-19 () none) ;; 19 ;; (cloud-vtx-tex-update (_type_ vector vector vector cloud-lights) none) - (sky-work-method-20 () none) ;; 20 ;; (adjust-cloud-lighting (_type_) none) - (sky-work-method-21 () none) ;; 21 ;; (cloud-vtx1-to-sky (_type_ sky-vertex cloud-vertex) none) - (sky-work-method-22 () none) ;; 22 ;; (cloud-vtx2-to-sky (_type_ sky-vertex cloud-vertex) none) - (sky-work-method-23 () none) ;; 23 ;; (draw-clouds (_type_ dma-buffer) none) - (sky-work-method-24 () none) ;; 24 ;; (apply-haze-light (_type_ vector vector haze-lights) none) - (sky-work-method-25 () none) ;; 25 ;; (adjust-haze-lighting (_type_) none) - (sky-work-method-26 () none) ;; 26 ;; (haze-vtx-to-sky (_type_ sky-vertex sky-vertex haze-vertex) none) - (sky-work-method-27 () none) ;; 27 ;; (draw-haze (_type_ dma-buffer) none) - (sky-work-method-28 () none) ;; 28 ;; (sun-dma (_type_ dma-buffer) none) - (sky-work-method-29 () none) ;; 29 ;; (green-sun-dma (_type_ dma-buffer) none) - (sky-work-method-30 () none) ;; 30 ;; (moon-dma (_type_ dma-buffer) none) - (sky-work-method-31 () none) ;; 31 ;; (setup-stars (_type_ matrix sky-upload-data) none) - (sky-work-method-32 () none) ;; 32 ;; (stars-transform-asm (_type_) none) - (sky-work-method-33 () none) ;; 33 ;; (stars-dma (_type_ dma-buffer) none) - (sky-work-method-34 () none) ;; 34 ;; (draw-roof (_type_ dma-buffer) none) - (sky-work-method-35 () none) ;; 35 ;; (draw-base (_type_ dma-buffer) none) - (sky-work-method-36 () none) ;; 36 ;; (draw-fog (_type_ dma-buffer) none) - (sky-work-method-37 () none) ;; 37 - (sky-work-method-38 () none) ;; 38 + (update-time-and-speed "Update cloud sroll and sun/moon position for the time." (_type_ float float) none) ;; 12 + (draw-erase (_type_ dma-buffer vector) none) ;; 13 + (draw (_type_) none) ;; 14 + (update-camera-matrix "Set the camera matrix (no perspective) for sky drawing." (_type_ matrix) none) ;; 15 + (update-template-colors "Update work with sky/erase colors from time-of-day/level." (_type_) none) ;; 16 + (init-regs-for-large-polygon-draw (_type_) none) ;; 17 + (init-regs-for-sky-asm (_type_) none) ;; 18 + (cloud-vtx-light-update (_type_ vector vector cloud-lights vector vector) none) ;; 19 + (cloud-vtx-tex-update (_type_ vector vector vector cloud-lights) none) ;; 20 + (adjust-cloud-lighting (_type_) none) ;; 21 + (cloud-vtx1-to-sky (_type_ sky-vertex cloud-vertex) none) ;; 22 + (cloud-vtx2-to-sky (_type_ sky-vertex cloud-vertex) none) ;; 23 + (draw-clouds (_type_ dma-buffer) none) ;; 24 + (apply-haze-light (_type_ vector vector haze-lights float) none) ;; 25 + (adjust-haze-lighting (_type_) none) ;; 26 + (haze-vtx-to-sky (_type_ sky-vertex sky-vertex haze-vertex) none) ;; 27 + (draw-haze (_type_ dma-buffer) none) ;; 28 + (sun-dma (_type_ dma-buffer) none) ;; 29 + (green-sun-dma (_type_ dma-buffer) none) ;; 30 + (moon-dma (_type_ dma-buffer) none) ;; 31 + (day-star-dma (_type_ dma-buffer) none) ;; 32 + (setup-stars (_type_ matrix sky-upload-data) none) ;; 33 + (stars-transform-asm (_type_) none) ;; 34 + (stars-dma (_type_ dma-buffer) none) ;; 35 + (draw-roof (_type_ dma-buffer) none) ;; 36 + (draw-base (_type_ dma-buffer) none) ;; 37 + (draw-fog (_type_ dma-buffer) none) ;; 38 ) ) @@ -32458,13 +32488,13 @@ ;; sky-tng ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern set-tex-offset function) ;; (function int int none) +(define-extern set-tex-offset (function int int none)) ;; (define-extern draw-large-polygon function) ;; (define-extern clip-polygon-against-positive-hyperplane function) ;; (define-extern clip-polygon-against-negative-hyperplane function) -;; (define-extern render-sky-quad function) ;; (function (inline-array sky-vertex) dma-buffer none) -;; (define-extern render-sky-tri function) ;; (function (inline-array sky-vertex) dma-buffer none) -(define-extern close-sky-buffer (function dma-buffer none)) +(define-extern render-sky-quad (function (inline-array sky-vertex) dma-buffer none)) +(define-extern render-sky-tri (function (inline-array sky-vertex) dma-buffer none)) +(define-extern close-sky-buffer "Close DMA buffer for large polygon drawing." (function dma-buffer none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; load-state ;; diff --git a/decompiler/config/jak3/ntsc_v1/hacks.jsonc b/decompiler/config/jak3/ntsc_v1/hacks.jsonc index f7d6bbbc00..9baba6bbca 100644 --- a/decompiler/config/jak3/ntsc_v1/hacks.jsonc +++ b/decompiler/config/jak3/ntsc_v1/hacks.jsonc @@ -608,13 +608,14 @@ "draw-large-polygon", "render-sky-quad", "render-sky-tri", - "(method 16 sky-work)", "(method 17 sky-work)", + "(method 18 sky-work)", "(method 32 sky-work)", - "(method 33 sky-work)", - // "(method 28 sky-work)", + "(method 31 sky-work)", + "(method 34 sky-work)", "(method 29 sky-work)", "(method 30 sky-work)", + "(method 35 sky-work)", "(method 11 collide-hash)", "(method 12 collide-hash)", "fill-bg-using-box-new", diff --git a/decompiler/config/jak3/ntsc_v1/label_types.jsonc b/decompiler/config/jak3/ntsc_v1/label_types.jsonc index beed0bd268..61f4e35f0c 100644 --- a/decompiler/config/jak3/ntsc_v1/label_types.jsonc +++ b/decompiler/config/jak3/ntsc_v1/label_types.jsonc @@ -575,6 +575,15 @@ ["L23", "(inline-array sky-vertex)", 648], ["L21", "(inline-array sky-vertex)", 144] ], + "sky-tng": [ + ["L130", "vector"], + ["L131", "uint64", true], + ["L132", "uint64", true], + ["L133", "uint64", true], + ["L134", "uint64", true], + ["L135", "uint64", true], + ["L136", "uint64", true] + ], "mood-funcs": [ ["L198", "uint64", true], ["L197", "uint64", true], diff --git a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc index 2acf1c13d0..749c793109 100644 --- a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc @@ -10845,5 +10845,35 @@ "(method 32 bt-vehicle)": [ ["_stack_", 76, "float"], ["_stack_", 100, "float"] + ], + "real-wang-texture-anim-func": [ + [[3, 31], "v1", "mood-context"] + ], + "(method 24 sky-work)": [ + [256, "s4", "(pointer int32)"], + [261, "s4", "(pointer int32)"] + ], + "(method 28 sky-work)": [ + [143, "s4", "(pointer int32)"], + [148, "s4", "(pointer int32)"] + ], + "(method 36 sky-work)": [ + [81, "s5", "(pointer int32)"], + [86, "s5", "(pointer int32)"] + ], + "(method 37 sky-work)": [ + [67, "s5", "(pointer int32)"], + [72, "s5", "(pointer int32)"] + ], + "(method 38 sky-work)": [ + [[83, 179], "v1", "(inline-array qword)"] + ], + "(method 14 sky-work)": [ + [[80, 256], "s4", "sky-work"] + ], + "(method 13 sky-work)": [ + [65, "v1", "(pointer uint128)"], + [[70, 77], "a0", "vector4w"], + [[78, 84], "v1", "vector4w"] ] } diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index d41cc49c4e..00e7c087fb 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -141,6 +141,7 @@ void OpenGLRenderer::init_bucket_renderers_jak3() { // 4 init_bucket_renderer("tex-lcom-sky-pre", BucketCategory::TEX, BucketId::TEX_LCOM_SKY_PRE, texture_animator); + init_bucket_renderer("sky", BucketCategory::OTHER, BucketId::SKY, 1024 * 8); init_bucket_renderer("ocean-mid-far", BucketCategory::OCEAN, BucketId::OCEAN_MID_FAR); diff --git a/game/graphics/opengl_renderer/buckets.h b/game/graphics/opengl_renderer/buckets.h index fb667456a9..359dd57caa 100644 --- a/game/graphics/opengl_renderer/buckets.h +++ b/game/graphics/opengl_renderer/buckets.h @@ -417,6 +417,7 @@ enum class BucketId { BUCKET_2 = 2, BLIT_START = 3, TEX_LCOM_SKY_PRE = 4, + SKY = 5, OCEAN_MID_FAR = 6, HFRAG = 8, diff --git a/game/mips2c/jak3_functions/sky.cpp b/game/mips2c/jak3_functions/sky.cpp index e10239b8b1..9a450430fd 100644 --- a/game/mips2c/jak3_functions/sky.cpp +++ b/game/mips2c/jak3_functions/sky.cpp @@ -21,6 +21,218 @@ void link() { } } // namespace set_sky_vf27 + +namespace set_sky_vf23_value { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + // sky_regs_vfs.vfs[27] + u64 value = c->sgpr64(a0); + memcpy(&sky_regs_vfs.vfs[23].f[0], &value, 8); + return 0; +} + +void link() { + gLinkedFunctionTable.reg("set-sky-vf23-value", execute, 64); +} + +} // namespace set_sky_vf23_value +} // namespace Mips2C::jak3 + +namespace Mips2C::jak3 { +namespace set_tex_offset { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->daddiu(sp, sp, -32); // daddiu sp, sp, -32 + c->daddiu(v1, sp, 16); // daddiu v1, sp, 16 + c->sq(r0, 0, v1); // sq r0, 0(v1) + c->lui(a2, 14208); // lui a2, 14208 + c->mtc1(f0, a2); // mtc1 f0, a2 + c->mtc1(f1, a0); // mtc1 f1, a0 + c->cvtsw(f1, f1); // cvt.s.w f1, f1 + c->muls(f0, f0, f1); // mul.s f0, f0, f1 + c->swc1(f0, 0, v1); // swc1 f0, 0(v1) + c->lui(a0, 14208); // lui a0, 14208 + c->mtc1(f0, a0); // mtc1 f0, a0 + c->mtc1(f1, a1); // mtc1 f1, a1 + c->cvtsw(f1, f1); // cvt.s.w f1, f1 + c->muls(f0, f0, f1); // mul.s f0, f0, f1 + c->swc1(f0, 4, v1); // swc1 f0, 4(v1) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->swc1(f0, 8, v1); // swc1 f0, 8(v1) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->swc1(f0, 12, v1); // swc1 f0, 12(v1) + c->lqc2(vf24, 0, v1); // lqc2 vf24, 0(v1) + c->mov128_gpr_vf(v1, vf24); // qmfc2.i v1, vf24 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + // jr ra // jr ra + c->daddiu(sp, sp, 32); // daddiu sp, sp, 32 + goto end_of_function; // return + +end_of_function: + memcpy(&sky_regs_vfs.vfs[vf24].f[0], c->gprs[v1].du32, 16); + return c->gprs[v0].du64[0]; +} + +void link() { + gLinkedFunctionTable.reg("set-tex-offset", execute, 16); +} + +} // namespace set_tex_offset +} // namespace Mips2C::jak3 +using ::jak3::intern_from_c; + +namespace Mips2C::jak3 { +namespace draw_large_polygon { +struct Cache { + void* clip_polygon_against_negative_hyperplane; // clip-polygon-against-negative-hyperplane + void* clip_polygon_against_positive_hyperplane; // clip-polygon-against-positive-hyperplane +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + [[maybe_unused]] u32 call_addr = 0; + // nop // sll r0, r0, 0 + c->daddiu(sp, sp, -8); // daddiu sp, sp, -8 + // nop // sll r0, r0, 0 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->load_symbol2( + t9, + cache + .clip_polygon_against_positive_hyperplane); // lw t9, + // clip-polygon-against-positive-hyperplane(s7) + c->mov64(a2, t4); // or a2, t4, r0 + c->mov64(a3, t5); // or a3, t5, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->daddu(t2, a2, r0); // daddu t2, a2, r0 + // c->jalr(call_addr); // jalr ra, t9 + clip_polygon_against_positive_hyperplane::execute(ctxt); + bc = c->sgpr64(t0) == 0; // beq t0, r0, L126 + // nop // sll r0, r0, 0 + if (bc) { + goto block_7; + } // branch non-likely + + c->mov64(a2, t5); // or a2, t5, r0 + c->mov64(a3, t4); // or a3, t4, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->daddiu(t2, a2, 4); // daddiu t2, a2, 4 + // c->jalr(call_addr); // jalr ra, t9 + clip_polygon_against_positive_hyperplane::execute(ctxt); + bc = c->sgpr64(t0) == 0; // beq t0, r0, L126 + c->load_symbol2( + t9, + cache + .clip_polygon_against_negative_hyperplane); // lw t9, + // clip-polygon-against-negative-hyperplane(s7) + if (bc) { + goto block_7; + } // branch non-likely + + c->mov64(a2, t4); // or a2, t4, r0 + c->mov64(a3, t5); // or a3, t5, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->daddu(t2, a2, r0); // daddu t2, a2, r0 + // c->jalr(call_addr); // jalr ra, t9 + clip_polygon_against_negative_hyperplane::execute(ctxt); + bc = c->sgpr64(t0) == 0; // beq t0, r0, L126 + // nop // sll r0, r0, 0 + if (bc) { + goto block_7; + } // branch non-likely + + c->mov64(a2, t5); // or a2, t5, r0 + c->mov64(a3, t4); // or a3, t4, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->daddiu(t2, a2, 4); // daddiu t2, a2, 4 + // c->jalr(call_addr); // jalr ra, t9 + clip_polygon_against_negative_hyperplane::execute(ctxt); + bc = c->sgpr64(t0) == 0; // beq t0, r0, L126 + c->lw(a3, 4, a1); // lw a3, 4(a1) + if (bc) { + goto block_7; + } // branch non-likely + + c->mov64(a2, t4); // or a2, t4, r0 + // nop // sll r0, r0, 0 + c->sqc2(vf27, 0, a3); // sqc2 vf27, 0(a3) + c->daddiu(a3, a3, 16); // daddiu a3, a3, 16 + c->sw(t0, -16, a3); // sw t0, -16(a3) + // nop // sll r0, r0, 0 + +block_5: + c->lqc2(vf1, 0, a2); // lqc2 vf1, 0(a2) + // nop // sll r0, r0, 0 + c->lqc2(vf2, 16, a2); // lqc2 vf2, 16(a2) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 32, a2); // lqc2 vf3, 32(a2) + c->vdiv(vf0, BC::w, vf1, BC::w); // vdiv Q, vf0.w, vf1.w + c->vmul(DEST::xyzw, vf1, vf1, vf26); // vmul.xyzw vf1, vf1, vf26 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf3, vf3); // vftoi0.xyzw vf3, vf3 + // nop // sll r0, r0, 0 + c->vadd(DEST::xyzw, vf2, vf2, vf24); // vadd.xyzw vf2, vf2, vf24 + // nop // sll r0, r0, 0 + c->vwaitq(); // vwaitq + // nop // sll r0, r0, 0 + c->vmulq(DEST::xyz, vf1, vf1); // vmulq.xyz vf1, vf1, Q + c->sqc2(vf3, 16, a3); // sqc2 vf3, 16(a3) + c->vmulq(DEST::xyzw, vf2, vf2); // vmulq.xyzw vf2, vf2, Q + c->daddiu(a2, a2, 48); // daddiu a2, a2, 48 + c->vadd(DEST::xyzw, vf1, vf1, vf25); // vadd.xyzw vf1, vf1, vf25 + c->daddiu(a3, a3, 48); // daddiu a3, a3, 48 + c->vmul_bc(DEST::z, BC::z, vf1, vf1, vf0); // vmulz.z vf1, vf1, vf0 + // nop // sll r0, r0, 0 + c->vmini_bc(DEST::w, BC::z, vf1, vf1, vf13); // vminiz.w vf1, vf1, vf13 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::z, BC::x, vf1, vf1, vf23); // vaddx.z vf1, vf1, vf23 + // nop // sll r0, r0, 0 + c->vmax_bc(DEST::w, BC::y, vf1, vf1, vf13); // vmaxy.w vf1, vf1, vf13 + // nop // sll r0, r0, 0 + c->sqc2(vf2, -48, a3); // sqc2 vf2, -48(a3) + c->daddiu(t0, t0, -1); // daddiu t0, t0, -1 + c->vftoi4(DEST::xyzw, vf1, vf1); // vftoi4.xyzw vf1, vf1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t0) != 0; // bne t0, r0, L125 + c->sqc2(vf1, -16, a3); // sqc2 vf1, -16(a3) + if (bc) { + goto block_5; + } // branch non-likely + + c->sw(a3, 4, a1); // sw a3, 4(a1) + // nop // sll r0, r0, 0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->daddiu(v0, s7, 4); // daddiu v0, s7, 4 + // jr ra // jr ra + c->daddiu(sp, sp, 8); // daddiu sp, sp, 8 + goto end_of_function; // return + +block_7: + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->mov64(v0, s7); // or v0, s7, r0 + // jr ra // jr ra + c->daddiu(sp, sp, 8); // daddiu sp, sp, 8 + goto end_of_function; // return + + // 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.clip_polygon_against_negative_hyperplane = + intern_from_c(-1, 0, "clip-polygon-against-negative-hyperplane").c(); + cache.clip_polygon_against_positive_hyperplane = + intern_from_c(-1, 0, "clip-polygon-against-positive-hyperplane").c(); + gLinkedFunctionTable.reg("draw-large-polygon", execute, 1024); +} + +} // namespace draw_large_polygon } // namespace Mips2C::jak3 //--------------------------MIPS2C--------------------- @@ -605,4 +817,1566 @@ void link() { } } // namespace clip_polygon_against_negative_hyperplane -} // namespace Mips2C \ No newline at end of file +} // namespace Mips2C + +namespace Mips2C::jak3 { +namespace render_sky_quad { +struct Cache { + void* fake_scratchpad_data; // *fake-scratchpad-data* + void* math_camera; // *math-camera* + void* draw_large_polygon; // draw-large-polygon +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->copy_vfs_from_other(&sky_regs_vfs); + // bool bc = false; + // u32 call_addr = 0; + c->mov64(v1, a0); // or v1, a0, r0 + c->load_symbol2(v1, cache.math_camera); // lw v1, *math-camera*(s7) + c->lqc2(vf14, 780, v1); // lqc2 vf14, 780(v1) + get_fake_spad_addr2(t4, cache.fake_scratchpad_data, 0, c);// lui t4, 28672 + c->ori(t4, t4, 12288); // ori t4, t4, 12288 + get_fake_spad_addr2(t5, cache.fake_scratchpad_data, 0, c);// lui t5, 28672 + c->ori(t5, t5, 14336); // ori t5, t5, 14336 + c->mov64(a3, t4); // or a3, t4, r0 + // nop // sll r0, r0, 0 + c->lqc2(vf1, 0, a0); // lqc2 vf1, 0(a0) + c->addiu(t0, r0, 4); // addiu t0, r0, 4 + c->lqc2(vf2, 16, a0); // lqc2 vf2, 16(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 32, a0); // lqc2 vf3, 32(a0) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf1); // vmulax.xyzw acc, vf31, vf1 + c->lqc2(vf4, 48, a0); // lqc2 vf4, 48(a0) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf1); // vmadday.xyzw acc, vf30, vf1 + c->lqc2(vf5, 64, a0); // lqc2 vf5, 64(a0) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf1); // vmaddaz.xyzw acc, vf29, vf1 + c->lqc2(vf6, 80, a0); // lqc2 vf6, 80(a0) + c->vmadd_bc(DEST::xyw, BC::w, vf1, vf28, vf1); // vmaddw.xyw vf1, vf28, vf1 + c->lqc2(vf7, 96, a0); // lqc2 vf7, 96(a0) + c->vmove(DEST::z, vf1, vf0); // vmove.z vf1, vf0 + c->lqc2(vf8, 112, a0); // lqc2 vf8, 112(a0) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf4); // vmulax.xyzw acc, vf31, vf4 + c->lqc2(vf9, 128, a0); // lqc2 vf9, 128(a0) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf4); // vmadday.xyzw acc, vf30, vf4 + c->lqc2(vf10, 144, a0); // lqc2 vf10, 144(a0) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf4); // vmaddaz.xyzw acc, vf29, vf4 + c->lqc2(vf11, 160, a0); // lqc2 vf11, 160(a0) + c->vmadd_bc(DEST::xyw, BC::w, vf4, vf28, vf4); // vmaddw.xyw vf4, vf28, vf4 + c->lqc2(vf12, 176, a0); // lqc2 vf12, 176(a0) + c->vmove(DEST::z, vf4, vf0); // vmove.z vf4, vf0 + c->sqc2(vf2, 16, a3); // sqc2 vf2, 16(a3) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf7); // vmulax.xyzw acc, vf31, vf7 + c->sqc2(vf3, 32, a3); // sqc2 vf3, 32(a3) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf7); // vmadday.xyzw acc, vf30, vf7 + c->sqc2(vf5, 64, a3); // sqc2 vf5, 64(a3) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf7); // vmaddaz.xyzw acc, vf29, vf7 + c->sqc2(vf6, 80, a3); // sqc2 vf6, 80(a3) + c->vmadd_bc(DEST::xyw, BC::w, vf7, vf28, vf7); // vmaddw.xyw vf7, vf28, vf7 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + c->vmove(DEST::z, vf7, vf0); // vmove.z vf7, vf0 + c->sqc2(vf9, 128, a3); // sqc2 vf9, 128(a3) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf10); // vmulax.xyzw acc, vf31, vf10 + c->sqc2(vf11, 160, a3); // sqc2 vf11, 160(a3) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf10); // vmadday.xyzw acc, vf30, vf10 + c->sqc2(vf12, 176, a3); // sqc2 vf12, 176(a3) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf10); // vmaddaz.xyzw acc, vf29, vf10 + c->sqc2(vf2, 208, a3); // sqc2 vf2, 208(a3) + c->vmadd_bc(DEST::xyw, BC::w, vf10, vf28, vf10); // vmaddw.xyw vf10, vf28, vf10 + c->sqc2(vf3, 224, a3); // sqc2 vf3, 224(a3) + c->vmove(DEST::z, vf10, vf0); // vmove.z vf10, vf0 + c->sqc2(vf1, 0, a3); // sqc2 vf1, 0(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf1, 192, a3); // sqc2 vf1, 192(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf4, 48, a3); // sqc2 vf4, 48(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf7, 96, a3); // sqc2 vf7, 96(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf10, 144, a3); // sqc2 vf10, 144(a3) + c->load_symbol2(t9, cache.draw_large_polygon); // lw t9, draw-large-polygon(s7) + // Unknown instr: jr t9 + draw_large_polygon::execute(ctxt); + // nop // sll r0, r0, 0 + //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.fake_scratchpad_data = intern_from_c(-1, 0, "*fake-scratchpad-data*").c(); + cache.math_camera = intern_from_c(-1, 0, "*math-camera*").c(); + cache.draw_large_polygon = intern_from_c(-1, 0, "draw-large-polygon").c(); + gLinkedFunctionTable.reg("render-sky-quad", execute, 1024); +} + +} // namespace render_sky_quad +} // namespace Mips2C + +namespace Mips2C::jak3 { +namespace render_sky_tri { +struct Cache { + void* fake_scratchpad_data; // *fake-scratchpad-data* + void* draw_large_polygon; // draw-large-polygon +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->copy_vfs_from_other(&sky_regs_vfs); + // bool bc = false; + // u32 call_addr = 0; + c->mov64(v1, a0); // or v1, a0, r0 + get_fake_spad_addr2(t4, cache.fake_scratchpad_data, 0, c);// lui t4, 28672 + c->ori(t4, t4, 12288); // ori t4, t4, 12288 + get_fake_spad_addr2(t5, cache.fake_scratchpad_data, 0, c);// lui t5, 28672 + c->ori(t5, t5, 14336); // ori t5, t5, 14336 + c->mov64(a3, t4); // or a3, t4, r0 + // nop // sll r0, r0, 0 + c->lqc2(vf1, 0, a0); // lqc2 vf1, 0(a0) + c->addiu(t0, r0, 3); // addiu t0, r0, 3 + c->lqc2(vf2, 16, a0); // lqc2 vf2, 16(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 32, a0); // lqc2 vf3, 32(a0) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf1); // vmulax.xyzw acc, vf31, vf1 + c->lqc2(vf4, 48, a0); // lqc2 vf4, 48(a0) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf1); // vmadday.xyzw acc, vf30, vf1 + c->lqc2(vf5, 64, a0); // lqc2 vf5, 64(a0) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf1); // vmaddaz.xyzw acc, vf29, vf1 + c->lqc2(vf6, 80, a0); // lqc2 vf6, 80(a0) + c->vmadd_bc(DEST::xyw, BC::w, vf1, vf28, vf1); // vmaddw.xyw vf1, vf28, vf1 + c->lqc2(vf7, 96, a0); // lqc2 vf7, 96(a0) + c->vmove(DEST::z, vf1, vf0); // vmove.z vf1, vf0 + c->lqc2(vf8, 112, a0); // lqc2 vf8, 112(a0) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf4); // vmulax.xyzw acc, vf31, vf4 + c->lqc2(vf9, 128, a0); // lqc2 vf9, 128(a0) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf4); // vmadday.xyzw acc, vf30, vf4 + c->sqc2(vf2, 16, a3); // sqc2 vf2, 16(a3) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf4); // vmaddaz.xyzw acc, vf29, vf4 + c->sqc2(vf3, 32, a3); // sqc2 vf3, 32(a3) + c->vmadd_bc(DEST::xyw, BC::w, vf4, vf28, vf4); // vmaddw.xyw vf4, vf28, vf4 + c->sqc2(vf5, 64, a3); // sqc2 vf5, 64(a3) + c->vmove(DEST::z, vf4, vf0); // vmove.z vf4, vf0 + c->sqc2(vf6, 80, a3); // sqc2 vf6, 80(a3) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf7); // vmulax.xyzw acc, vf31, vf7 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf7); // vmadday.xyzw acc, vf30, vf7 + c->sqc2(vf9, 128, a3); // sqc2 vf9, 128(a3) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf7); // vmaddaz.xyzw acc, vf29, vf7 + c->sqc2(vf2, 160, a3); // sqc2 vf2, 160(a3) + c->vmadd_bc(DEST::xyw, BC::w, vf7, vf28, vf7); // vmaddw.xyw vf7, vf28, vf7 + c->sqc2(vf3, 176, a3); // sqc2 vf3, 176(a3) + c->vmove(DEST::z, vf7, vf0); // vmove.z vf7, vf0 + c->sqc2(vf1, 0, a3); // sqc2 vf1, 0(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf1, 144, a3); // sqc2 vf1, 144(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf4, 48, a3); // sqc2 vf4, 48(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf7, 96, a3); // sqc2 vf7, 96(a3) + c->load_symbol2(t9, cache.draw_large_polygon); // lw t9, draw-large-polygon(s7) + // Unknown instr: jr t9 + draw_large_polygon::execute(ctxt); + // nop // sll r0, r0, 0 + //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.fake_scratchpad_data = intern_from_c(-1, 0, "*fake-scratchpad-data*").c(); + cache.draw_large_polygon = intern_from_c(-1, 0, "draw-large-polygon").c(); + gLinkedFunctionTable.reg("render-sky-tri", execute, 1024); +} + +} // namespace render_sky_tri +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak3/kscheme.h" +using ::jak3::intern_from_c; +namespace Mips2C::jak3 { +namespace method_17_sky_work { +struct Cache { + void* math_camera; // *math-camera* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->copy_vfs_from_other(&sky_regs_vfs); + bool bc = false; + // u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -32); // daddiu sp, sp, -32 + c->load_symbol2(v1, cache.math_camera); // lw v1, *math-camera*(s7) + c->daddiu(a1, sp, 16); // daddiu a1, sp, 16 + c->sq(r0, 0, a1); // sq r0, 0(a1) + c->daddiu(a2, a0, 1600); // daddiu a2, a0, 1600 + c->mov64(a3, a1); // or a3, a1, r0 + c->daddiu(t0, v1, 812); // daddiu t0, v1, 812 + c->lq(t0, 0, t0); // lq t0, 0(t0) + c->sq(t0, 0, a3); // sq t0, 0(a3) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->lwc1(f1, 928, v1); // lwc1 f1, 928(v1) + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L92 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + c->lui(a3, 17664); // lui a3, 17664 + c->ori(a3, a3, 4096); // ori a3, a3, 4096 + c->mtc1(f0, a3); // mtc1 f0, a3 + c->swc1(f0, 4, a1); // swc1 f0, 4(a1) + c->mfc1(a3, f0); // mfc1 a3, f0 + //beq r0, r0, L93 // beq r0, r0, L93 + // nop // sll r0, r0, 0 + goto block_3; // branch always + + +block_2: + c->lui(a3, 17663); // lui a3, 17663 + c->ori(a3, a3, 57344); // ori a3, a3, 57344 + c->mtc1(f0, a3); // mtc1 f0, a3 + c->swc1(f0, 4, a1); // swc1 f0, 4(a1) + c->mfc1(a3, f0); // mfc1 a3, f0 + +block_3: + c->daddiu(a3, a0, 1088); // daddiu a3, a0, 1088 + c->lwc1(f0, 908, v1); // lwc1 f0, 908(v1) + c->swc1(f0, 0, a3); // swc1 f0, 0(a3) + c->lwc1(f0, 128, v1); // lwc1 f0, 128(v1) + c->swc1(f0, 4, a3); // swc1 f0, 4(a3) + c->lwc1(f0, 124, v1); // lwc1 f0, 124(v1) + c->swc1(f0, 8, a3); // swc1 f0, 8(a3) + c->lui(t0, 16256); // lui t0, 16256 + c->mtc1(f0, t0); // mtc1 f0, t0 + c->swc1(f0, 12, a3); // swc1 f0, 12(a3) + c->lqc2(vf31, 0, a2); // lqc2 vf31, 0(a2) + c->lqc2(vf30, 16, a2); // lqc2 vf30, 16(a2) + c->lqc2(vf29, 32, a2); // lqc2 vf29, 32(a2) + c->lqc2(vf28, 48, a2); // lqc2 vf28, 48(a2) + c->lqc2(vf14, 780, v1); // lqc2 vf14, 780(v1) + c->lqc2(vf26, 796, v1); // lqc2 vf26, 796(v1) + c->lqc2(vf25, 0, a1); // lqc2 vf25, 0(a1) + c->lqc2(vf13, 1088, a0); // lqc2 vf13, 1088(a0) + c->vmul(DEST::xyzw, vf31, vf31, vf14); // vmul.xyzw vf31, vf31, vf14 + c->vmul(DEST::xyzw, vf30, vf30, vf14); // vmul.xyzw vf30, vf30, vf14 + c->vmul(DEST::xyzw, vf29, vf29, vf14); // vmul.xyzw vf29, vf29, vf14 + c->vmul(DEST::xyzw, vf28, vf28, vf14); // vmul.xyzw vf28, vf28, vf14 + c->vmove(DEST::z, vf25, vf0); // vmove.z vf25, vf0 + c->vmove(DEST::xyzw, vf24, vf0); // vmove.xyzw vf24, vf0 + c->vmove(DEST::xyzw, vf23, vf0); // vmove.xyzw vf23, vf0 + c->mov128_gpr_vf(v1, vf23); // qmfc2.i v1, vf23 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddiu(sp, sp, 32); // daddiu sp, sp, 32 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.math_camera = intern_from_c(-1, 0, "*math-camera*").c(); + gLinkedFunctionTable.reg("(method 17 sky-work)", execute, 64); +} + +} // namespace method_17_sky_work +} // namespace Mips2C + + +using ::jak3::intern_from_c; +namespace Mips2C::jak3 { +namespace method_18_sky_work { +struct Cache { + void* math_camera; // *math-camera* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + // bool bc = false; + c->copy_vfs_from_other(&sky_regs_vfs); + // u32 call_addr = 0; + c->daddiu(sp, sp, -32); // daddiu sp, sp, -32 + c->load_symbol2(a1, cache.math_camera); // lw a1, *math-camera*(s7) + c->daddiu(v1, a0, 1600); // daddiu v1, a0, 1600 + c->lqc2(vf31, 0, v1); // lqc2 vf31, 0(v1) + c->lqc2(vf30, 16, v1); // lqc2 vf30, 16(v1) + c->lqc2(vf29, 32, v1); // lqc2 vf29, 32(v1) + c->lqc2(vf28, 48, v1); // lqc2 vf28, 48(v1) + c->lqc2(vf14, 780, a1); // lqc2 vf14, 780(a1) + c->lqc2(vf25, 812, a1); // lqc2 vf25, 812(a1) + c->lqc2(vf13, 1088, a0); // lqc2 vf13, 1088(a0) + c->vmove(DEST::z, vf25, vf0); // vmove.z vf25, vf0 + c->vmove(DEST::xyzw, vf23, vf0); // vmove.xyzw vf23, vf0 + c->daddiu(v1, sp, 16); // daddiu v1, sp, 16 + c->sq(r0, 0, v1); // sq r0, 0(v1) + c->lui(a0, 16256); // lui a0, 16256 + c->mtc1(f0, a0); // mtc1 f0, a0 + c->lui(a0, 17974); // lui a0, 17974 + c->ori(a0, a0, 2913); // ori a0, a0, 2913 + c->mtc1(f1, a0); // mtc1 f1, a0 + c->lwc1(f2, 8, a1); // lwc1 f2, 8(a1) + c->divs(f1, f1, f2); // div.s f1, f1, f2 + c->mins(f0, f0, f1); // min.s f0, f0, f1 + c->swc1(f0, 12, v1); // swc1 f0, 12(v1) + c->lqc2(vf26, 0, v1); // lqc2 vf26, 0(v1) + c->mov128_gpr_vf(v1, vf26); // qmfc2.i v1, vf26 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddiu(sp, sp, 32); // daddiu sp, sp, 32 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.math_camera = intern_from_c(-1, 0, "*math-camera*").c(); + gLinkedFunctionTable.reg("(method 18 sky-work)", execute, 64); +} + +} // namespace method_18_sky_work +} // namespace Mips2C + +namespace Mips2C::jak3 { +namespace method_29_sky_work { +struct Cache { + void* adgif_shader_texture_simple; // adgif-shader<-texture-simple! + void* lookup_texture_by_id_fast; // lookup-texture-by-id-fast +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->copy_vfs_from_other(&sky_regs_vfs); + c->daddiu(sp, sp, -64); // daddiu sp, sp, -64 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s5, 32, sp); // sq s5, 32(sp) + c->sq(gp, 48, sp); // sq gp, 48(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->sw(a1, 2044, gp); // sw a1, 2044(gp) + c->load_symbol2(t9, cache.lookup_texture_by_id_fast);// lw t9, lookup-texture-by-id-fast(s7) + c->lui(v1, 128); // lui v1, 128 + c->ori(a0, v1, 768); // ori a0, v1, 768 + 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->sw(v0, 16, sp); // sw v0, 16(sp) + c->lwu(v1, 16, sp); // lwu v1, 16(sp) + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L62 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_14;} // branch non-likely + + c->lqc2(vf15, 1248, gp); // lqc2 vf15, 1248(gp) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf15); // vmulax.xyzw acc, vf31, vf15 + c->lqc2(vf1, 224, gp); // lqc2 vf1, 224(gp) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf15); // vmadday.xyzw acc, vf30, vf15 + c->lqc2(vf4, 240, gp); // lqc2 vf4, 240(gp) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf15); // vmaddaz.xyzw acc, vf29, vf15 + c->lqc2(vf2, 864, gp); // lqc2 vf2, 864(gp) + c->vmadd_bc(DEST::xyzw, BC::w, vf15, vf28, vf0); // vmaddw.xyzw vf15, vf28, vf0 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf16, vf15, vf14); // vmul.xyzw vf16, vf15, vf14 + c->lqc2(vf5, 880, gp); // lqc2 vf5, 880(gp) + c->vdiv(vf0, BC::w, vf16, BC::w); // vdiv Q, vf0.w, vf16.w + c->lqc2(vf8, 32, gp); // lqc2 vf8, 32(gp) + c->lqc2(vf11, 48, gp); // lqc2 vf11, 48(gp) + c->lqc2(vf3, 448, gp); // lqc2 vf3, 448(gp) + c->lqc2(vf6, 464, gp); // lqc2 vf6, 464(gp) + c->vwaitq(); // vwaitq + c->vmulq(DEST::xyz, vf15, vf15); // vmulq.xyz vf15, vf15, Q + c->vmulq(DEST::xyzw, vf16, vf26); // vmulq.xyzw vf16, vf26, Q + c->vmul_bc(DEST::xyzw, BC::w, vf1, vf1, vf16); // vmulw.xyzw vf1, vf1, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf4, vf4, vf16); // vmulw.xyzw vf4, vf4, vf16 + c->vadd(DEST::xyzw, vf15, vf15, vf25); // vadd.xyzw vf15, vf15, vf25 + c->vadd(DEST::xyz, vf1, vf1, vf15); // vadd.xyz vf1, vf1, vf15 + c->vadd(DEST::xyz, vf4, vf4, vf15); // vadd.xyz vf4, vf4, vf15 + c->vftoi4(DEST::xyz, vf1, vf1); // vftoi4.xyz vf1, vf1 + c->vftoi4(DEST::xyzw, vf4, vf4); // vftoi4.xyzw vf4, vf4 + c->sqc2(vf1, 1728, gp); // sqc2 vf1, 1728(gp) + c->sqc2(vf4, 1744, gp); // sqc2 vf4, 1744(gp) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(a3, 4, v1); // lwu a3, 4(v1) + c->lw(v1, 1740, gp); // lw v1, 1740(gp) + c->mtc1(f0, v1); // mtc1 f0, v1 + c->mtc1(f1, r0); // mtc1 f1, r0 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L60 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + if (bc) {goto block_3;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + +block_3: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(v1))) {// beql s7, v1, L61 + c->mov64(v1, v1); // or v1, v1, r0 + goto block_12; + } + +// block_5: + c->lw(v1, 1728, gp); // lw v1, 1728(gp) + c->ori(a0, r0, 36864); // ori a0, r0, 36864 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L61 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + +// block_7: + c->lw(v1, 1732, gp); // lw v1, 1732(gp) + c->ori(a0, r0, 36096); // ori a0, r0, 36096 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L61 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + +// block_9: + c->addiu(v1, r0, 28672); // addiu v1, r0, 28672 + c->lw(a0, 1744, gp); // lw a0, 1744(gp) + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L61 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + +// block_11: + c->addiu(v1, r0, 29440); // addiu v1, r0, 29440 + c->lw(a0, 1748, gp); // lw a0, 1748(gp) + c->slt(a0, v1, a0); // slt a0, v1, a0 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + c->movz(v1, s7, a0); // movz v1, s7, a0 + +block_12: + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L62 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_14;} // branch non-likely + + c->vsub(DEST::z, vf1, vf0, vf0); // vsub.z vf1, vf0, vf0 + c->vsub(DEST::z, vf4, vf0, vf0); // vsub.z vf4, vf0, vf0 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + c->sqc2(vf11, 128, a3); // sqc2 vf11, 128(a3) + c->sqc2(vf3, 144, a3); // sqc2 vf3, 144(a3) + c->sqc2(vf2, 160, a3); // sqc2 vf2, 160(a3) + c->sqc2(vf1, 176, a3); // sqc2 vf1, 176(a3) + c->sqc2(vf5, 192, a3); // sqc2 vf5, 192(a3) + c->sqc2(vf4, 208, a3); // sqc2 vf4, 208(a3) + c->sqc2(vf8, 224, a3); // sqc2 vf8, 224(a3) + c->sqc2(vf11, 240, a3); // sqc2 vf11, 240(a3) + c->sqc2(vf6, 256, a3); // sqc2 vf6, 256(a3) + c->sqc2(vf2, 272, a3); // sqc2 vf2, 272(a3) + c->sqc2(vf1, 288, a3); // sqc2 vf1, 288(a3) + c->sqc2(vf5, 304, a3); // sqc2 vf5, 304(a3) + c->sqc2(vf4, 320, a3); // sqc2 vf4, 320(a3) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->lq(a0, 0, gp); // lq a0, 0(gp) + c->sq(a0, 0, v1); // sq a0, 0(v1) + c->lq(a0, 16, gp); // lq a0, 16(gp) + c->sq(a0, 16, v1); // sq a0, 16(v1) + c->daddiu(s5, v1, 32); // daddiu s5, v1, 32 + c->load_symbol2(t9, cache.adgif_shader_texture_simple);// lw t9, adgif-shader<-texture-simple!(s7) + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(a1, 16, sp); // lwu a1, 16(sp) + 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->addiu(v1, r0, 72); // addiu v1, r0, 72 + c->sd(v1, 64, s5); // sd v1, 64(s5) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->daddiu(v1, v1, 336); // daddiu v1, v1, 336 + c->lwu(a0, 2044, gp); // lwu a0, 2044(gp) + c->sw(v1, 4, a0); // sw v1, 4(a0) + +block_14: + 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) + //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 +end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.adgif_shader_texture_simple = intern_from_c(-1, 0, "adgif-shader<-texture-simple!").c(); + cache.lookup_texture_by_id_fast = intern_from_c(-1, 0, "lookup-texture-by-id-fast").c(); + gLinkedFunctionTable.reg("(method 29 sky-work)", execute, 128); +} + +} // namespace method_29_sky_work +} // namespace Mips2C + +namespace Mips2C::jak3 { +namespace method_30_sky_work { +struct Cache { + void* adgif_shader_texture_simple; // adgif-shader<-texture-simple! + void* lookup_texture_by_id_fast; // lookup-texture-by-id-fast +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->copy_vfs_from_other(&sky_regs_vfs); + c->daddiu(sp, sp, -64); // daddiu sp, sp, -64 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s5, 32, sp); // sq s5, 32(sp) + c->sq(gp, 48, sp); // sq gp, 48(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->sw(a1, 2044, gp); // sw a1, 2044(gp) + c->load_symbol2(t9, cache.lookup_texture_by_id_fast);// lw t9, lookup-texture-by-id-fast(s7) + c->lui(v1, 128); // lui v1, 128 + c->ori(a0, v1, 768); // ori a0, v1, 768 + 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->sw(v0, 16, sp); // sw v0, 16(sp) + c->lwu(v1, 16, sp); // lwu v1, 16(sp) + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L58 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_14;} // branch non-likely + + c->lqc2(vf15, 1312, gp); // lqc2 vf15, 1312(gp) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf15); // vmulax.xyzw acc, vf31, vf15 + c->lqc2(vf1, 256, gp); // lqc2 vf1, 256(gp) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf15); // vmadday.xyzw acc, vf30, vf15 + c->lqc2(vf4, 272, gp); // lqc2 vf4, 272(gp) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf15); // vmaddaz.xyzw acc, vf29, vf15 + c->lqc2(vf2, 864, gp); // lqc2 vf2, 864(gp) + c->vmadd_bc(DEST::xyzw, BC::w, vf15, vf28, vf0); // vmaddw.xyzw vf15, vf28, vf0 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf16, vf15, vf14); // vmul.xyzw vf16, vf15, vf14 + c->lqc2(vf5, 880, gp); // lqc2 vf5, 880(gp) + c->vdiv(vf0, BC::w, vf16, BC::w); // vdiv Q, vf0.w, vf16.w + c->lqc2(vf8, 32, gp); // lqc2 vf8, 32(gp) + c->lqc2(vf11, 48, gp); // lqc2 vf11, 48(gp) + c->lqc2(vf3, 480, gp); // lqc2 vf3, 480(gp) + c->lqc2(vf6, 496, gp); // lqc2 vf6, 496(gp) + c->vwaitq(); // vwaitq + c->vmulq(DEST::xyz, vf15, vf15); // vmulq.xyz vf15, vf15, Q + c->vmulq(DEST::xyzw, vf16, vf26); // vmulq.xyzw vf16, vf26, Q + c->vmul_bc(DEST::xyzw, BC::w, vf1, vf1, vf16); // vmulw.xyzw vf1, vf1, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf4, vf4, vf16); // vmulw.xyzw vf4, vf4, vf16 + c->vadd(DEST::xyzw, vf15, vf15, vf25); // vadd.xyzw vf15, vf15, vf25 + c->vadd(DEST::xyz, vf1, vf1, vf15); // vadd.xyz vf1, vf1, vf15 + c->vadd(DEST::xyz, vf4, vf4, vf15); // vadd.xyz vf4, vf4, vf15 + c->vftoi4(DEST::xyz, vf1, vf1); // vftoi4.xyz vf1, vf1 + c->vftoi4(DEST::xyzw, vf4, vf4); // vftoi4.xyzw vf4, vf4 + c->sqc2(vf1, 1728, gp); // sqc2 vf1, 1728(gp) + c->sqc2(vf4, 1744, gp); // sqc2 vf4, 1744(gp) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(a3, 4, v1); // lwu a3, 4(v1) + c->lw(v1, 1740, gp); // lw v1, 1740(gp) + c->mtc1(f0, v1); // mtc1 f0, v1 + c->mtc1(f1, r0); // mtc1 f1, r0 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L56 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + if (bc) {goto block_3;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + +block_3: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(v1))) {// beql s7, v1, L57 + c->mov64(v1, v1); // or v1, v1, r0 + goto block_12; + } + +// block_5: + c->lw(v1, 1728, gp); // lw v1, 1728(gp) + c->ori(a0, r0, 36864); // ori a0, r0, 36864 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L57 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + +// block_7: + c->lw(v1, 1732, gp); // lw v1, 1732(gp) + c->ori(a0, r0, 36096); // ori a0, r0, 36096 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L57 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + +// block_9: + c->addiu(v1, r0, 28672); // addiu v1, r0, 28672 + c->lw(a0, 1744, gp); // lw a0, 1744(gp) + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L57 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + +// block_11: + c->addiu(v1, r0, 29440); // addiu v1, r0, 29440 + c->lw(a0, 1748, gp); // lw a0, 1748(gp) + c->slt(a0, v1, a0); // slt a0, v1, a0 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + c->movz(v1, s7, a0); // movz v1, s7, a0 + +block_12: + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L58 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_14;} // branch non-likely + + c->vsub(DEST::z, vf1, vf0, vf0); // vsub.z vf1, vf0, vf0 + c->vsub(DEST::z, vf4, vf0, vf0); // vsub.z vf4, vf0, vf0 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + c->sqc2(vf11, 128, a3); // sqc2 vf11, 128(a3) + c->sqc2(vf3, 144, a3); // sqc2 vf3, 144(a3) + c->sqc2(vf2, 160, a3); // sqc2 vf2, 160(a3) + c->sqc2(vf1, 176, a3); // sqc2 vf1, 176(a3) + c->sqc2(vf5, 192, a3); // sqc2 vf5, 192(a3) + c->sqc2(vf4, 208, a3); // sqc2 vf4, 208(a3) + c->sqc2(vf8, 224, a3); // sqc2 vf8, 224(a3) + c->sqc2(vf11, 240, a3); // sqc2 vf11, 240(a3) + c->sqc2(vf6, 256, a3); // sqc2 vf6, 256(a3) + c->sqc2(vf2, 272, a3); // sqc2 vf2, 272(a3) + c->sqc2(vf1, 288, a3); // sqc2 vf1, 288(a3) + c->sqc2(vf5, 304, a3); // sqc2 vf5, 304(a3) + c->sqc2(vf4, 320, a3); // sqc2 vf4, 320(a3) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->lq(a0, 0, gp); // lq a0, 0(gp) + c->sq(a0, 0, v1); // sq a0, 0(v1) + c->lq(a0, 16, gp); // lq a0, 16(gp) + c->sq(a0, 16, v1); // sq a0, 16(v1) + c->daddiu(s5, v1, 32); // daddiu s5, v1, 32 + c->load_symbol2(t9, cache.adgif_shader_texture_simple);// lw t9, adgif-shader<-texture-simple!(s7) + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(a1, 16, sp); // lwu a1, 16(sp) + 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->addiu(v1, r0, 72); // addiu v1, r0, 72 + c->sd(v1, 64, s5); // sd v1, 64(s5) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->daddiu(v1, v1, 336); // daddiu v1, v1, 336 + c->lwu(a0, 2044, gp); // lwu a0, 2044(gp) + c->sw(v1, 4, a0); // sw v1, 4(a0) + +block_14: + 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) + //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 +end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.adgif_shader_texture_simple = intern_from_c(-1, 0, "adgif-shader<-texture-simple!").c(); + cache.lookup_texture_by_id_fast = intern_from_c(-1, 0, "lookup-texture-by-id-fast").c(); + gLinkedFunctionTable.reg("(method 30 sky-work)", execute, 128); +} + +} // namespace method_30_sky_work +} // namespace Mips2C + + +namespace Mips2C::jak3 { +namespace method_31_sky_work { +struct Cache { + void* adgif_shader_texture_simple; // adgif-shader<-texture-simple! + void* lookup_texture_by_id_fast; // lookup-texture-by-id-fast +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->copy_vfs_from_other(&sky_regs_vfs); + + c->daddiu(sp, sp, -80); // daddiu sp, sp, -80 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s4, 32, sp); // sq s4, 32(sp) + c->sq(s5, 48, sp); // sq s5, 48(sp) + c->sq(gp, 64, sp); // sq gp, 64(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->sw(a1, 2044, gp); // sw a1, 2044(gp) + c->load_symbol2(t9, cache.lookup_texture_by_id_fast);// lw t9, lookup-texture-by-id-fast(s7) + c->lui(v1, 128); // lui v1, 128 + c->ori(a0, v1, 768); // ori a0, v1, 768 + 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->sw(v0, 16, sp); // sw v0, 16(sp) + c->load_symbol2(t9, cache.lookup_texture_by_id_fast);// lw t9, lookup-texture-by-id-fast(s7) + c->lui(v1, 128); // lui v1, 128 + c->ori(a0, v1, 512); // ori a0, v1, 512 + 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->sw(v0, 20, sp); // sw v0, 20(sp) + c->lwu(v1, 16, sp); // lwu v1, 16(sp) + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(v1))) {// beql s7, v1, L51 + c->mov64(v1, v1); // or v1, v1, r0 + goto block_3; + } + +// block_2: + c->lwu(v1, 20, sp); // lwu v1, 20(sp) + +block_3: + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L54 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_17;} // branch non-likely + + c->lqc2(vf15, 1376, gp); // lqc2 vf15, 1376(gp) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf15); // vmulax.xyzw acc, vf31, vf15 + c->lqc2(vf1, 288, gp); // lqc2 vf1, 288(gp) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf15); // vmadday.xyzw acc, vf30, vf15 + c->lqc2(vf4, 304, gp); // lqc2 vf4, 304(gp) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf15); // vmaddaz.xyzw acc, vf29, vf15 + c->lqc2(vf2, 864, gp); // lqc2 vf2, 864(gp) + c->vmadd_bc(DEST::xyzw, BC::w, vf15, vf28, vf0); // vmaddw.xyzw vf15, vf28, vf0 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf16, vf15, vf14); // vmul.xyzw vf16, vf15, vf14 + c->lqc2(vf5, 880, gp); // lqc2 vf5, 880(gp) + c->vdiv(vf0, BC::w, vf16, BC::w); // vdiv Q, vf0.w, vf16.w + c->lqc2(vf8, 32, gp); // lqc2 vf8, 32(gp) + c->lqc2(vf11, 48, gp); // lqc2 vf11, 48(gp) + c->lqc2(vf7, 320, gp); // lqc2 vf7, 320(gp) + c->lqc2(vf10, 336, gp); // lqc2 vf10, 336(gp) + c->lqc2(vf17, 352, gp); // lqc2 vf17, 352(gp) + c->lqc2(vf18, 368, gp); // lqc2 vf18, 368(gp) + c->lqc2(vf3, 512, gp); // lqc2 vf3, 512(gp) + c->lqc2(vf6, 528, gp); // lqc2 vf6, 528(gp) + c->lqc2(vf9, 544, gp); // lqc2 vf9, 544(gp) + c->vwaitq(); // vwaitq + c->vmulq(DEST::xyz, vf15, vf15); // vmulq.xyz vf15, vf15, Q + c->vmulq(DEST::xyzw, vf16, vf26); // vmulq.xyzw vf16, vf26, Q + c->vmul_bc(DEST::xyzw, BC::w, vf1, vf1, vf16); // vmulw.xyzw vf1, vf1, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf4, vf4, vf16); // vmulw.xyzw vf4, vf4, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf7, vf7, vf16); // vmulw.xyzw vf7, vf7, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf10, vf10, vf16); // vmulw.xyzw vf10, vf10, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf17, vf17, vf16); // vmulw.xyzw vf17, vf17, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf18, vf18, vf16); // vmulw.xyzw vf18, vf18, vf16 + c->vadd(DEST::xyzw, vf15, vf15, vf25); // vadd.xyzw vf15, vf15, vf25 + c->vadd(DEST::xyz, vf1, vf1, vf15); // vadd.xyz vf1, vf1, vf15 + c->vadd(DEST::xyz, vf4, vf4, vf15); // vadd.xyz vf4, vf4, vf15 + c->vadd(DEST::xyz, vf7, vf7, vf15); // vadd.xyz vf7, vf7, vf15 + c->vadd(DEST::xyz, vf10, vf10, vf15); // vadd.xyz vf10, vf10, vf15 + c->vadd(DEST::xyz, vf17, vf17, vf15); // vadd.xyz vf17, vf17, vf15 + c->vadd(DEST::xyz, vf18, vf18, vf15); // vadd.xyz vf18, vf18, vf15 + c->vftoi4(DEST::xyzw, vf1, vf1); // vftoi4.xyzw vf1, vf1 + c->vftoi4(DEST::xyzw, vf4, vf4); // vftoi4.xyzw vf4, vf4 + c->vftoi4(DEST::xyz, vf7, vf7); // vftoi4.xyz vf7, vf7 + c->vftoi4(DEST::xyzw, vf10, vf10); // vftoi4.xyzw vf10, vf10 + c->vftoi4(DEST::xyzw, vf17, vf17); // vftoi4.xyzw vf17, vf17 + c->vftoi4(DEST::xyzw, vf18, vf18); // vftoi4.xyzw vf18, vf18 + c->sqc2(vf7, 1728, gp); // sqc2 vf7, 1728(gp) + c->sqc2(vf10, 1744, gp); // sqc2 vf10, 1744(gp) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(a3, 4, v1); // lwu a3, 4(v1) + c->lw(v1, 1740, gp); // lw v1, 1740(gp) + c->mtc1(f0, v1); // mtc1 f0, v1 + c->mtc1(f1, r0); // mtc1 f1, r0 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L52 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + if (bc) {goto block_6;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + +block_6: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(v1))) {// beql s7, v1, L53 + c->mov64(v1, v1); // or v1, v1, r0 + goto block_15; + } + +// block_8: + c->lw(v1, 1728, gp); // lw v1, 1728(gp) + c->ori(a0, r0, 36864); // ori a0, r0, 36864 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L53 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_15; + } + +// block_10: + c->lw(v1, 1732, gp); // lw v1, 1732(gp) + c->ori(a0, r0, 36096); // ori a0, r0, 36096 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L53 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_15; + } + +// block_12: + c->addiu(v1, r0, 28672); // addiu v1, r0, 28672 + c->lw(a0, 1744, gp); // lw a0, 1744(gp) + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L53 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_15; + } + +// block_14: + c->addiu(v1, r0, 29440); // addiu v1, r0, 29440 + c->lw(a0, 1748, gp); // lw a0, 1748(gp) + c->slt(a0, v1, a0); // slt a0, v1, a0 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + c->movz(v1, s7, a0); // movz v1, s7, a0 + +block_15: + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L54 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_17;} // branch non-likely + + c->vsub(DEST::z, vf1, vf0, vf0); // vsub.z vf1, vf0, vf0 + c->vsub(DEST::z, vf4, vf0, vf0); // vsub.z vf4, vf0, vf0 + c->vsub(DEST::z, vf7, vf0, vf0); // vsub.z vf7, vf0, vf0 + c->vsub(DEST::z, vf10, vf0, vf0); // vsub.z vf10, vf0, vf0 + c->vsub(DEST::z, vf17, vf0, vf0); // vsub.z vf17, vf0, vf0 + c->vsub(DEST::z, vf18, vf0, vf0); // vsub.z vf18, vf0, vf0 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + c->sqc2(vf11, 128, a3); // sqc2 vf11, 128(a3) + c->sqc2(vf3, 144, a3); // sqc2 vf3, 144(a3) + c->sqc2(vf2, 160, a3); // sqc2 vf2, 160(a3) + c->sqc2(vf1, 176, a3); // sqc2 vf1, 176(a3) + c->sqc2(vf5, 192, a3); // sqc2 vf5, 192(a3) + c->sqc2(vf4, 208, a3); // sqc2 vf4, 208(a3) + c->sqc2(vf8, 224, a3); // sqc2 vf8, 224(a3) + c->sqc2(vf11, 240, a3); // sqc2 vf11, 240(a3) + c->sqc2(vf6, 256, a3); // sqc2 vf6, 256(a3) + c->sqc2(vf2, 272, a3); // sqc2 vf2, 272(a3) + c->sqc2(vf7, 288, a3); // sqc2 vf7, 288(a3) + c->sqc2(vf5, 304, a3); // sqc2 vf5, 304(a3) + c->sqc2(vf10, 320, a3); // sqc2 vf10, 320(a3) + c->sqc2(vf8, 448, a3); // sqc2 vf8, 448(a3) + c->sqc2(vf11, 464, a3); // sqc2 vf11, 464(a3) + c->sqc2(vf9, 480, a3); // sqc2 vf9, 480(a3) + c->sqc2(vf2, 496, a3); // sqc2 vf2, 496(a3) + c->sqc2(vf17, 512, a3); // sqc2 vf17, 512(a3) + c->sqc2(vf5, 528, a3); // sqc2 vf5, 528(a3) + c->sqc2(vf18, 544, a3); // sqc2 vf18, 544(a3) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(s5, 4, v1); // lwu s5, 4(v1) + c->lq(v1, 0, gp); // lq v1, 0(gp) + c->sq(v1, 0, s5); // sq v1, 0(s5) + c->lq(v1, 16, gp); // lq v1, 16(gp) + c->sq(v1, 16, s5); // sq v1, 16(s5) + c->daddiu(s4, s5, 32); // daddiu s4, s5, 32 + c->load_symbol2(t9, cache.adgif_shader_texture_simple);// lw t9, adgif-shader<-texture-simple!(s7) + c->mov64(a0, s4); // or a0, s4, r0 + c->lwu(a1, 16, sp); // lwu a1, 16(sp) + 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->addiu(v1, r0, 72); // addiu v1, r0, 72 + c->sd(v1, 64, s4); // sd v1, 64(s4) + c->lq(v1, 0, gp); // lq v1, 0(gp) + c->sq(v1, 336, s5); // sq v1, 336(s5) + c->lq(v1, 16, gp); // lq v1, 16(gp) + c->sq(v1, 352, s5); // sq v1, 352(s5) + c->daddiu(s5, s5, 368); // daddiu s5, s5, 368 + c->load_symbol2(t9, cache.adgif_shader_texture_simple);// lw t9, adgif-shader<-texture-simple!(s7) + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(a1, 20, sp); // lwu a1, 20(sp) + 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->addiu(v1, r0, 68); // addiu v1, r0, 68 + c->sd(v1, 64, s5); // sd v1, 64(s5) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->daddiu(v1, v1, 560); // daddiu v1, v1, 560 + c->lwu(a0, 2044, gp); // lwu a0, 2044(gp) + c->sw(v1, 4, a0); // sw v1, 4(a0) + +block_17: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 64, sp); // lq gp, 64(sp) + c->lq(s5, 48, sp); // lq s5, 48(sp) + c->lq(s4, 32, sp); // lq s4, 32(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 80); // daddiu sp, sp, 80 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.adgif_shader_texture_simple = intern_from_c(-1, 0, "adgif-shader<-texture-simple!").c(); + cache.lookup_texture_by_id_fast = intern_from_c(-1, 0, "lookup-texture-by-id-fast").c(); + gLinkedFunctionTable.reg("(method 31 sky-work)", execute, 128); +} + +} // namespace method_31_sky_work +} // namespace Mips2C + +namespace Mips2C::jak3 { +namespace method_34_sky_work { +struct Cache { + void* vector_normalize; // vector-normalize! +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->copy_vfs_from_other(&sky_regs_vfs); + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -48); // daddiu sp, sp, -48 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s5, 16, sp); // sq s5, 16(sp) + c->sq(gp, 32, sp); // sq gp, 32(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->addiu(a1, r0, 0); // addiu a1, r0, 0 + c->mov64(v1, gp); // or v1, gp, r0 + c->lqc2(vf31, 1664, gp); // lqc2 vf31, 1664(gp) + c->lqc2(vf30, 1680, gp); // lqc2 vf30, 1680(gp) + c->lqc2(vf29, 1696, gp); // lqc2 vf29, 1696(gp) + c->addiu(a0, r0, 0); // addiu a0, r0, 0 + //beq r0, r0, L43 // beq r0, r0, L43 + // nop // sll r0, r0, 0 + goto block_10; // branch always + + +block_1: + c->daddiu(a2, a1, 3); // daddiu a2, a1, 3 + c->daddiu(t0, a1, 5); // daddiu t0, a1, 5 + c->daddiu(a3, a1, 7); // daddiu a3, a1, 7 + c->andi(a2, a2, 7); // andi a2, a2, 7 + c->andi(t1, t0, 7); // andi t1, t0, 7 + c->andi(t2, a3, 7); // andi t2, a3, 7 + c->dsll(a3, a1, 4); // dsll a3, a1, 4 + c->dsll(t0, a2, 4); // dsll t0, a2, 4 + c->dsll(t1, t1, 4); // dsll t1, t1, 4 + c->dsll(a2, t2, 4); // dsll a2, t2, 4 + c->daddu(t3, a3, gp); // daddu t3, a3, gp + c->daddu(t2, t0, gp); // daddu t2, t0, gp + c->daddu(a3, t1, gp); // daddu a3, t1, gp + c->lq(t0, 896, t3); // lq t0, 896(t3) + c->daddu(a2, a2, gp); // daddu a2, a2, gp + c->lq(t1, 896, t2); // lq t1, 896(t2) + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + c->lq(a3, 896, a3); // lq a3, 896(a3) + c->paddb(t0, t0, t1); // paddb t0, t0, t1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->paddb(a3, t0, a3); // paddb a3, t0, a3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->andi(a1, a1, 7); // andi a1, a1, 7 + c->sq(a3, 896, a2); // sq a3, 896(a2) + c->pextlb(t0, a3, r0); // pextlb t0, a3, r0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextub(a2, a3, r0); // pextub a2, a3, r0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextuh(a3, t0, r0); // pextuh a3, t0, r0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlh(t0, t0, r0); // pextlh t0, t0, r0 + c->mov128_vf_gpr(vf15, a3); // qmtc2.i vf15, a3 + c->pextuh(a3, a2, r0); // pextuh a3, a2, r0 + c->mov128_vf_gpr(vf16, t0); // qmtc2.i vf16, t0 + c->pextlh(a2, a2, r0); // pextlh a2, a2, r0 + c->mov128_vf_gpr(vf17, a3); // qmtc2.i vf17, a3 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf18, a2); // qmtc2.i vf18, a2 + c->vitof15(DEST::xyzw, vf15, vf15); // vitof15.xyzw vf15, vf15 + // nop // sll r0, r0, 0 + c->vitof15(DEST::xyzw, vf16, vf16); // vitof15.xyzw vf16, vf16 + // nop // sll r0, r0, 0 + c->vitof15(DEST::xyzw, vf17, vf17); // vitof15.xyzw vf17, vf17 + // nop // sll r0, r0, 0 + c->vitof15(DEST::xyzw, vf18, vf18); // vitof15.xyzw vf18, vf18 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf15); // vmulax.xyzw acc, vf31, vf15 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf15); // vmadday.xyzw acc, vf30, vf15 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf15, vf29, vf15); // vmaddz.xyzw vf15, vf29, vf15 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf16); // vmulax.xyzw acc, vf31, vf16 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf16); // vmadday.xyzw acc, vf30, vf16 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf16, vf29, vf16); // vmaddz.xyzw vf16, vf29, vf16 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf17); // vmulax.xyzw acc, vf31, vf17 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf17); // vmadday.xyzw acc, vf30, vf17 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf17, vf29, vf17); // vmaddz.xyzw vf17, vf29, vf17 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf18); // vmulax.xyzw acc, vf31, vf18 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf18); // vmadday.xyzw acc, vf30, vf18 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf18, vf29, vf18); // vmaddz.xyzw vf18, vf29, vf18 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a2, vf15); // qmfc2.i a2, vf15 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a3, vf16); // qmfc2.i a3, vf16 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t0, vf17); // qmfc2.i t0, vf17 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t1, vf18); // qmfc2.i t1, vf18 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(a2)) >= 0; // bgez a2, L39 + // nop // sll r0, r0, 0 + if (bc) {goto block_3;} // branch non-likely + + c->vsub(DEST::xyz, vf15, vf0, vf15); // vsub.xyz vf15, vf0, vf15 + // nop // sll r0, r0, 0 + +block_3: + bc = ((s64)c->sgpr64(a3)) >= 0; // bgez a3, L40 + // nop // sll r0, r0, 0 + if (bc) {goto block_5;} // branch non-likely + + c->vsub(DEST::xyz, vf16, vf0, vf16); // vsub.xyz vf16, vf0, vf16 + // nop // sll r0, r0, 0 + +block_5: + bc = ((s64)c->sgpr64(t0)) >= 0; // bgez t0, L41 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + c->vsub(DEST::xyz, vf17, vf0, vf17); // vsub.xyz vf17, vf0, vf17 + // nop // sll r0, r0, 0 + +block_7: + bc = ((s64)c->sgpr64(t1)) >= 0; // bgez t1, L42 + // nop // sll r0, r0, 0 + if (bc) {goto block_9;} // branch non-likely + + c->vsub(DEST::xyz, vf18, vf0, vf18); // vsub.xyz vf18, vf0, vf18 + // nop // sll r0, r0, 0 + +block_9: + c->sqc2(vf15, 2064, v1); // sqc2 vf15, 2064(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf16, 2080, v1); // sqc2 vf16, 2080(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf17, 2096, v1); // sqc2 vf17, 2096(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf18, 2112, v1); // sqc2 vf18, 2112(v1) + c->daddiu(v1, v1, 64); // daddiu v1, v1, 64 + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + +block_10: + c->slti(a2, a0, 128); // slti a2, a0, 128 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L38 + // nop // sll r0, r0, 0 + if (bc) {goto block_1;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + c->mov64(v1, s7); // or v1, s7, r0 + c->addiu(s5, r0, 0); // addiu s5, r0, 0 + //beq r0, r0, L45 // beq r0, r0, L45 + // nop // sll r0, r0, 0 + goto block_13; // branch always + + +block_12: + c->load_symbol2(t9, cache.vector_normalize); // lw t9, vector-normalize!(s7) + c->dsll(v1, s5, 4); // dsll v1, s5, 4 + c->daddiu(v1, v1, 2064); // daddiu v1, v1, 2064 + c->daddu(a0, v1, gp); // daddu a0, v1, gp + c->lui(v1, 18243); // lui v1, 18243 + c->ori(a1, v1, 20480); // ori a1, v1, 20480 + 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->daddiu(s5, s5, 1); // daddiu s5, s5, 1 + +block_13: + c->slti(v1, s5, 512); // slti v1, s5, 512 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L44 + // nop // sll r0, r0, 0 + if (bc) {goto block_12;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + c->mov64(v1, s7); // or v1, s7, r0 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 32, sp); // lq gp, 32(sp) + c->lq(s5, 16, sp); // lq s5, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 48); // daddiu sp, sp, 48 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 +end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.vector_normalize = intern_from_c(-1, 0, "vector-normalize!").c(); + gLinkedFunctionTable.reg("(method 34 sky-work)", execute, 128); +} + +} // namespace method_34_sky_work +} // namespace Mips2C + +namespace Mips2C::jak3 { +namespace method_35_sky_work { +struct Cache { + void* adgif_shader_texture_simple; // adgif-shader<-texture-simple! + void* lookup_texture_by_id_fast; // lookup-texture-by-id-fast +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->copy_vfs_from_other(&sky_regs_vfs); + u32 call_addr = 0; + 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->mov64(s5, a0); // or s5, a0, r0 + c->mov64(gp, a1); // or gp, a1, r0 + c->sw(gp, 2044, s5); // sw gp, 2044(s5) + c->load_symbol2(t9, cache.lookup_texture_by_id_fast);// lw t9, lookup-texture-by-id-fast(s7) + c->lui(v1, 128); // lui v1, 128 + c->ori(a0, v1, 1024); // ori a0, v1, 1024 + 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(a1, v0); // or a1, v0, r0 + bc = c->sgpr64(s7) == c->sgpr64(a1); // beq s7, a1, L36 + c->mov64(a3, s7); // or a3, s7, r0 + if (bc) {goto block_15;} // branch non-likely + + c->lwu(v1, 2044, s5); // lwu v1, 2044(s5) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->lq(a0, 0, s5); // lq a0, 0(s5) + c->sq(a0, 0, v1); // sq a0, 0(v1) + c->lq(a0, 16, s5); // lq a0, 16(s5) + c->sq(a0, 16, v1); // sq a0, 16(v1) + c->daddiu(s4, v1, 32); // daddiu s4, v1, 32 + c->load_symbol2(t9, cache.adgif_shader_texture_simple);// lw t9, adgif-shader<-texture-simple!(s7) + c->mov64(a0, s4); // or a0, s4, 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->addiu(v1, r0, 72); // addiu v1, r0, 72 + c->sd(v1, 64, s4); // sd v1, 64(s4) + c->lwu(v1, 2044, s5); // lwu v1, 2044(s5) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->daddiu(v1, v1, 112); // daddiu v1, v1, 112 + c->lwu(a0, 2044, s5); // lwu a0, 2044(s5) + c->sw(v1, 4, a0); // sw v1, 4(a0) + c->lw(a3, 4, gp); // lw a3, 4(gp) + c->mov64(v1, s5); // or v1, s5, r0 + c->addiu(a1, r0, 0); // addiu a1, r0, 0 + c->lqc2(vf2, 864, s5); // lqc2 vf2, 864(s5) + c->lqc2(vf5, 880, s5); // lqc2 vf5, 880(s5) + c->lqc2(vf8, 32, s5); // lqc2 vf8, 32(s5) + c->lqc2(vf11, 48, s5); // lqc2 vf11, 48(s5) + c->addiu(a0, r0, 0); // addiu a0, r0, 0 + //beq r0, r0, L35 // beq r0, r0, L35 + // nop // sll r0, r0, 0 + goto block_13; // branch always + + // nop // sll r0, r0, 0 + +block_3: + c->lqc2(vf15, 2064, v1); // lqc2 vf15, 2064(v1) + c->daddiu(v1, v1, 16); // daddiu v1, v1, 16 + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf15); // vmulax.xyzw acc, vf31, vf15 + c->lqc2(vf1, 416, s5); // lqc2 vf1, 416(s5) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf15); // vmadday.xyzw acc, vf30, vf15 + c->lqc2(vf4, 432, s5); // lqc2 vf4, 432(s5) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf15); // vmaddaz.xyzw acc, vf29, vf15 + c->daddu(a2, s5, a1); // daddu a2, s5, a1 + c->vmadd_bc(DEST::xyzw, BC::w, vf15, vf28, vf0); // vmaddw.xyzw vf15, vf28, vf0 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf16, vf15, vf14); // vmul.xyzw vf16, vf15, vf14 + c->lqc2(vf3, 608, a2); // lqc2 vf3, 608(a2) + c->vdiv(vf0, BC::w, vf16, BC::w); // vdiv Q, vf0.w, vf16.w + c->daddiu(a1, a1, 16); // daddiu a1, a1, 16 + c->vwaitq(); // vwaitq + c->andi(a1, a1, 255); // andi a1, a1, 255 + c->vmulq(DEST::xyz, vf15, vf15); // vmulq.xyz vf15, vf15, Q + c->vadd(DEST::xyzw, vf15, vf15, vf25); // vadd.xyzw vf15, vf15, vf25 + c->vadd(DEST::xyz, vf1, vf1, vf15); // vadd.xyz vf1, vf1, vf15 + c->vadd(DEST::xyz, vf4, vf4, vf15); // vadd.xyz vf4, vf4, vf15 + c->vftoi4(DEST::xyzw, vf1, vf1); // vftoi4.xyzw vf1, vf1 + c->vftoi4(DEST::xyzw, vf4, vf4); // vftoi4.xyzw vf4, vf4 + c->sqc2(vf1, 1728, s5); // sqc2 vf1, 1728(s5) + c->sqc2(vf4, 1744, s5); // sqc2 vf4, 1744(s5) + c->lw(a2, 1728, s5); // lw a2, 1728(s5) + c->ori(t0, r0, 36864); // ori t0, r0, 36864 + c->slt(a2, a2, t0); // slt a2, a2, t0 + c->daddiu(t0, s7, 4); // daddiu t0, s7, 4 + c->movz(t0, s7, a2); // movz t0, s7, a2 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(t0))) {// beql s7, t0, L33 + c->mov64(a2, t0); // or a2, t0, r0 + goto block_10; + } + +// block_5: + c->lw(a2, 1732, s5); // lw a2, 1732(s5) + c->ori(t0, r0, 36096); // ori t0, r0, 36096 + c->slt(a2, a2, t0); // slt a2, a2, t0 + c->daddiu(t0, s7, 4); // daddiu t0, s7, 4 + c->movz(t0, s7, a2); // movz t0, s7, a2 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(t0))) {// beql s7, t0, L33 + c->mov64(a2, t0); // or a2, t0, r0 + goto block_10; + } + +// block_7: + c->addiu(a2, r0, 28672); // addiu a2, r0, 28672 + c->lw(t0, 1744, s5); // lw t0, 1744(s5) + c->slt(a2, a2, t0); // slt a2, a2, t0 + c->daddiu(t0, s7, 4); // daddiu t0, s7, 4 + c->movz(t0, s7, a2); // movz t0, s7, a2 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(t0))) {// beql s7, t0, L33 + c->mov64(a2, t0); // or a2, t0, r0 + goto block_10; + } + +// block_9: + c->addiu(a2, r0, 29440); // addiu a2, r0, 29440 + c->lw(t0, 1748, s5); // lw t0, 1748(s5) + c->slt(t0, a2, t0); // slt t0, a2, t0 + c->daddiu(a2, s7, 4); // daddiu a2, s7, 4 + c->movz(a2, s7, t0); // movz a2, s7, t0 + +block_10: + bc = c->sgpr64(s7) == c->sgpr64(a2); // beq s7, a2, L34 + c->mov64(a2, s7); // or a2, s7, r0 + if (bc) {goto block_12;} // branch non-likely + + c->vsub(DEST::z, vf1, vf0, vf0); // vsub.z vf1, vf0, vf0 + c->vsub(DEST::z, vf4, vf0, vf0); // vsub.z vf4, vf0, vf0 + c->sqc2(vf8, 0, a3); // sqc2 vf8, 0(a3) + c->sqc2(vf11, 16, a3); // sqc2 vf11, 16(a3) + c->sqc2(vf3, 32, a3); // sqc2 vf3, 32(a3) + c->sqc2(vf2, 48, a3); // sqc2 vf2, 48(a3) + c->sqc2(vf1, 64, a3); // sqc2 vf1, 64(a3) + c->sqc2(vf5, 80, a3); // sqc2 vf5, 80(a3) + c->sqc2(vf4, 96, a3); // sqc2 vf4, 96(a3) + c->daddiu(a3, a3, 112); // daddiu a3, a3, 112 + c->mov64(a2, a3); // or a2, a3, r0 + +block_12: + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + +block_13: + c->slti(a2, a0, 512); // slti a2, a0, 512 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L32 + // nop // sll r0, r0, 0 + if (bc) {goto block_3;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + c->mov64(v1, s7); // or v1, s7, r0 + c->sw(a3, 4, gp); // sw a3, 4(gp) + +block_15: + c->mov64(v1, a3); // or v1, a3, r0 + 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 +end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.adgif_shader_texture_simple = intern_from_c(-1, 0, "adgif-shader<-texture-simple!").c(); + cache.lookup_texture_by_id_fast = intern_from_c(-1, 0, "lookup-texture-by-id-fast").c(); + gLinkedFunctionTable.reg("(method 35 sky-work)", execute, 256); +} + +} // namespace method_35_sky_work +} // namespace Mips2C + +namespace Mips2C::jak3 { +namespace method_32_sky_work { +struct Cache { + void* game_info; // *game-info* + void* adgif_shader_texture_simple; // adgif-shader<-texture-simple! + void* lookup_texture_by_id_fast; // lookup-texture-by-id-fast +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->copy_vfs_from_other(&sky_regs_vfs); + c->daddiu(sp, sp, -64); // daddiu sp, sp, -64 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s5, 32, sp); // sq s5, 32(sp) + c->sq(gp, 48, sp); // sq gp, 48(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->sw(a1, 2044, gp); // sw a1, 2044(gp) + c->load_symbol2(t9, cache.lookup_texture_by_id_fast);// lw t9, lookup-texture-by-id-fast(s7) + c->lui(v1, 128); // lui v1, 128 + c->ori(a0, v1, 768); // ori a0, v1, 768 + 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->sw(v0, 16, sp); // sw v0, 16(sp) + c->lwu(v1, 16, sp); // lwu v1, 16(sp) + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L26 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_14;} // branch non-likely + + c->lui(v1, 17148); // lui v1, 17148 + c->mtc1(f0, v1); // mtc1 f0, v1 + c->lui(v1, 16025); // lui v1, 16025 + c->ori(v1, v1, 39322); // ori v1, v1, 39322 + c->mtc1(f1, v1); // mtc1 f1, v1 + c->lui(v1, 16256); // lui v1, 16256 + c->mtc1(f2, v1); // mtc1 f2, v1 + c->lui(v1, 15395); // lui v1, 15395 + c->ori(v1, v1, 55050); // ori v1, v1, 55050 + c->mtc1(f3, v1); // mtc1 f3, v1 + c->load_symbol2(v1, cache.game_info); // lw v1, *game-info*(s7) + c->lwc1(f4, 800, v1); // lwc1 f4, 800(v1) + c->muls(f3, f3, f4); // mul.s f3, f3, f4 + c->mins(f2, f2, f3); // min.s f2, f2, f3 + c->maxs(f1, f1, f2); // max.s f1, f1, f2 + c->muls(f0, f0, f1); // mul.s f0, f0, f1 + c->negs(f1, f0); // neg.s f1, f0 + c->daddiu(v1, gp, 384); // daddiu v1, gp, 384 + c->swc1(f1, 0, v1); // swc1 f1, 0(v1) + c->swc1(f1, 4, v1); // swc1 f1, 4(v1) + c->mtc1(f1, r0); // mtc1 f1, r0 + c->swc1(f1, 8, v1); // swc1 f1, 8(v1) + c->mtc1(f1, r0); // mtc1 f1, r0 + c->swc1(f1, 12, v1); // swc1 f1, 12(v1) + c->daddiu(v1, gp, 400); // daddiu v1, gp, 400 + c->swc1(f0, 0, v1); // swc1 f0, 0(v1) + c->swc1(f0, 4, v1); // swc1 f0, 4(v1) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->swc1(f0, 8, v1); // swc1 f0, 8(v1) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->swc1(f0, 12, v1); // swc1 f0, 12(v1) + c->lqc2(vf15, 1440, gp); // lqc2 vf15, 1440(gp) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf15); // vmulax.xyzw acc, vf31, vf15 + c->lqc2(vf1, 384, gp); // lqc2 vf1, 384(gp) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf15); // vmadday.xyzw acc, vf30, vf15 + c->lqc2(vf4, 400, gp); // lqc2 vf4, 400(gp) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf15); // vmaddaz.xyzw acc, vf29, vf15 + c->lqc2(vf2, 864, gp); // lqc2 vf2, 864(gp) + c->vmadd_bc(DEST::xyzw, BC::w, vf15, vf28, vf0); // vmaddw.xyzw vf15, vf28, vf0 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf16, vf15, vf14); // vmul.xyzw vf16, vf15, vf14 + c->lqc2(vf5, 880, gp); // lqc2 vf5, 880(gp) + c->vdiv(vf0, BC::w, vf16, BC::w); // vdiv Q, vf0.w, vf16.w + c->lqc2(vf8, 32, gp); // lqc2 vf8, 32(gp) + c->lqc2(vf11, 48, gp); // lqc2 vf11, 48(gp) + c->lqc2(vf3, 560, gp); // lqc2 vf3, 560(gp) + c->lqc2(vf6, 576, gp); // lqc2 vf6, 576(gp) + c->vwaitq(); // vwaitq + c->vmulq(DEST::xyz, vf15, vf15); // vmulq.xyz vf15, vf15, Q + c->vmulq(DEST::xyzw, vf16, vf26); // vmulq.xyzw vf16, vf26, Q + c->vmul_bc(DEST::xyzw, BC::w, vf1, vf1, vf16); // vmulw.xyzw vf1, vf1, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf4, vf4, vf16); // vmulw.xyzw vf4, vf4, vf16 + c->vadd(DEST::xyzw, vf15, vf15, vf25); // vadd.xyzw vf15, vf15, vf25 + c->vadd(DEST::xyz, vf1, vf1, vf15); // vadd.xyz vf1, vf1, vf15 + c->vadd(DEST::xyz, vf4, vf4, vf15); // vadd.xyz vf4, vf4, vf15 + c->vftoi4(DEST::xyz, vf1, vf1); // vftoi4.xyz vf1, vf1 + c->vftoi4(DEST::xyzw, vf4, vf4); // vftoi4.xyzw vf4, vf4 + c->sqc2(vf1, 1728, gp); // sqc2 vf1, 1728(gp) + c->sqc2(vf4, 1744, gp); // sqc2 vf4, 1744(gp) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(a3, 4, v1); // lwu a3, 4(v1) + c->lw(v1, 1740, gp); // lw v1, 1740(gp) + c->mtc1(f0, v1); // mtc1 f0, v1 + c->mtc1(f1, r0); // mtc1 f1, r0 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L24 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + if (bc) {goto block_3;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + +block_3: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(v1))) {// beql s7, v1, L25 + c->mov64(v1, v1); // or v1, v1, r0 + goto block_12; + } + +// block_5: + c->lw(v1, 1728, gp); // lw v1, 1728(gp) + c->ori(a0, r0, 36864); // ori a0, r0, 36864 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L25 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + +// block_7: + c->lw(v1, 1732, gp); // lw v1, 1732(gp) + c->ori(a0, r0, 36096); // ori a0, r0, 36096 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L25 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + +// block_9: + c->addiu(v1, r0, 28672); // addiu v1, r0, 28672 + c->lw(a0, 1744, gp); // lw a0, 1744(gp) + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L25 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + +// block_11: + c->addiu(v1, r0, 29440); // addiu v1, r0, 29440 + c->lw(a0, 1748, gp); // lw a0, 1748(gp) + c->slt(a0, v1, a0); // slt a0, v1, a0 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + c->movz(v1, s7, a0); // movz v1, s7, a0 + +block_12: + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L26 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_14;} // branch non-likely + + c->vsub(DEST::z, vf1, vf0, vf0); // vsub.z vf1, vf0, vf0 + c->vsub(DEST::z, vf4, vf0, vf0); // vsub.z vf4, vf0, vf0 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + c->sqc2(vf11, 128, a3); // sqc2 vf11, 128(a3) + c->sqc2(vf3, 144, a3); // sqc2 vf3, 144(a3) + c->sqc2(vf2, 160, a3); // sqc2 vf2, 160(a3) + c->sqc2(vf1, 176, a3); // sqc2 vf1, 176(a3) + c->sqc2(vf5, 192, a3); // sqc2 vf5, 192(a3) + c->sqc2(vf4, 208, a3); // sqc2 vf4, 208(a3) + c->sqc2(vf8, 224, a3); // sqc2 vf8, 224(a3) + c->sqc2(vf11, 240, a3); // sqc2 vf11, 240(a3) + c->sqc2(vf6, 256, a3); // sqc2 vf6, 256(a3) + c->sqc2(vf2, 272, a3); // sqc2 vf2, 272(a3) + c->sqc2(vf1, 288, a3); // sqc2 vf1, 288(a3) + c->sqc2(vf5, 304, a3); // sqc2 vf5, 304(a3) + c->sqc2(vf4, 320, a3); // sqc2 vf4, 320(a3) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->lq(a0, 0, gp); // lq a0, 0(gp) + c->sq(a0, 0, v1); // sq a0, 0(v1) + c->lq(a0, 16, gp); // lq a0, 16(gp) + c->sq(a0, 16, v1); // sq a0, 16(v1) + c->daddiu(s5, v1, 32); // daddiu s5, v1, 32 + c->load_symbol2(t9, cache.adgif_shader_texture_simple);// lw t9, adgif-shader<-texture-simple!(s7) + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(a1, 16, sp); // lwu a1, 16(sp) + 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->addiu(v1, r0, 72); // addiu v1, r0, 72 + c->sd(v1, 64, s5); // sd v1, 64(s5) + c->lwu(v1, 2044, gp); // lwu v1, 2044(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->daddiu(v1, v1, 336); // daddiu v1, v1, 336 + c->lwu(a0, 2044, gp); // lwu a0, 2044(gp) + c->sw(v1, 4, a0); // sw v1, 4(a0) + +block_14: + 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) + //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: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.game_info = intern_from_c(-1, 0, "*game-info*").c(); + cache.adgif_shader_texture_simple = intern_from_c(-1, 0, "adgif-shader<-texture-simple!").c(); + cache.lookup_texture_by_id_fast = intern_from_c(-1, 0, "lookup-texture-by-id-fast").c(); + gLinkedFunctionTable.reg("(method 32 sky-work)", execute, 128); +} + +} // namespace method_32_sky_work +} // namespace Mips2C + diff --git a/game/mips2c/mips2c_table.cpp b/game/mips2c/mips2c_table.cpp index e724c5f354..2bcb183eab 100644 --- a/game/mips2c/mips2c_table.cpp +++ b/game/mips2c/mips2c_table.cpp @@ -365,6 +365,19 @@ namespace generic_translucent { extern void link(); } namespace high_speed_reject { extern void link(); } namespace mercneric_convert { extern void link(); } namespace generic_merc_init_asm { extern void link(); } +namespace set_tex_offset { extern void link(); } +namespace draw_large_polygon { extern void link(); } +namespace render_sky_quad { extern void link(); } +namespace render_sky_tri { extern void link(); } +namespace method_17_sky_work { extern void link(); } +namespace method_18_sky_work { extern void link(); } +namespace method_29_sky_work { extern void link(); } +namespace method_30_sky_work { extern void link(); } +namespace method_31_sky_work { extern void link(); } +namespace method_34_sky_work { extern void link(); } +namespace method_35_sky_work { extern void link(); } +namespace method_32_sky_work { extern void link(); } +namespace set_sky_vf23_value { extern void link(); } } // clang-format on @@ -535,86 +548,90 @@ PerGameVersion>> gMips2C jak2::shadow_scissor_top::link, jak2::shadow_scissor_edges::link, jak2::shadow_calc_dual_verts::link, jak2::shadow_xform_verts::link}}}, /////////// JAK 3 - { - {"lights", - {jak3::light_hash_get_bucket_index::link, jak3::add_light_sphere_to_light_group::link, - jak3::light_hash_count_items::link, jak3::light_hash_add_items::link}}, - {"debug", - {jak3::debug_line_clip::link, jak3::init_boundary_regs::link, - jak3::draw_boundary_polygon::link, jak3::render_boundary_quad::link, - jak3::render_boundary_tri::link, jak3::set_sky_vf27::link}}, - {"generic-effect", - {jak3::generic_light_proc::link, jak3::generic_envmap_proc::link, - jak3::generic_prepare_dma_double::link, jak3::generic_prepare_dma_single::link, - jak3::generic_warp_source_proc::link, jak3::generic_warp_dest_proc::link, - jak3::generic_warp_dest::link, jak3::generic_warp_envmap_dest::link, - jak3::generic_no_light_proc::link}}, - {"font", - {jak3::method_9_font_work::link, jak3::draw_string_asm::link, - jak3::get_string_length::link}}, - {"texture", {jak3::adgif_shader_texture_with_update::link}}, - {"collide-func", - {jak3::moving_sphere_triangle_intersect::link, jak3::collide_do_primitives::link}}, - {"prim", {jak3::method_9_prim_strip::link}}, - {"joint", {jak3::cspace_parented_transformq_joint::link}}, - {"foreground", - {jak3::foreground_check_longest_edge_asm::link, jak3::foreground_generic_merc::link, - jak3::foreground_merc::link, jak3::foreground_draw_hud::link}}, - {"particle-curves", {jak3::live_func_curve::link, jak3::birth_func_curve::link}}, - {"collide-hash", - {jak3::method_11_collide_hash::link, jak3::method_12_collide_hash::link, - jak3::fill_bg_using_box_new::link, jak3::fill_bg_using_line_sphere_new::link}}, - {"collide-mesh", - {jak3::method_12_collide_mesh::link, jak3::method_14_collide_mesh::link, - jak3::method_15_collide_mesh::link, jak3::method_10_collide_shape_prim_mesh::link}}, - {"collide-cache", - {jak3::method_10_collide_shape_prim_mesh::link, - jak3::method_10_collide_shape_prim_sphere::link, - jak3::method_10_collide_shape_prim_group::link, - jak3::method_11_collide_shape_prim_mesh::link, - jak3::method_11_collide_shape_prim_sphere::link, - jak3::method_11_collide_shape_prim_group::link, jak3::method_9_collide_cache_prim::link, - jak3::method_10_collide_cache_prim::link, jak3::method_17_collide_cache::link, - jak3::method_9_collide_puss_work::link, jak3::method_10_collide_puss_work::link}}, - {"collide-edge-grab", - {jak3::method_10_collide_edge_hold_list::link, jak3::method_19_collide_edge_work::link, - jak3::method_9_edge_grab_info::link, jak3::method_17_collide_edge_work::link, - jak3::method_16_collide_edge_work::link, jak3::method_18_collide_edge_work::link}}, - {"spatial-hash", - {jak3::method_18_grid_hash::link, jak3::method_19_grid_hash::link, - jak3::method_20_grid_hash::link, jak3::method_22_grid_hash::link, - jak3::method_28_sphere_hash::link, jak3::method_32_sphere_hash::link, - jak3::method_29_sphere_hash::link, jak3::method_30_sphere_hash::link, - jak3::method_31_sphere_hash::link, jak3::method_32_spatial_hash::link, - jak3::method_38_spatial_hash::link, jak3::method_35_spatial_hash::link, - jak3::method_36_spatial_hash::link, jak3::method_34_spatial_hash::link}}, - {"sparticle-launcher", - {jak3::sparticle_motion_blur::link, jak3::sp_launch_particles_var::link, - jak3::particle_adgif::link, jak3::sp_init_fields::link}}, - {"sparticle", {jak3::sp_process_block_2d::link, jak3::sp_process_block_3d::link}}, - {"nav-engine", - {jak3::method_21_nav_engine::link, jak3::method_20_nav_engine::link, - jak3::method_18_nav_engine::link, jak3::method_17_nav_engine::link, - jak3::nav_state_patch_pointers::link, jak3::nav_dma_send_from_spr_no_flush::link, - jak3::nav_dma_send_to_spr_no_flush::link}}, - {"nav-control", {jak3::method_39_nav_state::link}}, - {"merc-blend-shape", - {jak3::blerc_execute::link, jak3::setup_blerc_chains_for_one_fragment::link}}, - {"wvehicle-part", {jak3::sparticle_motion_blur_dirt::link}}, - {"ripple", - {jak3::ripple_matrix_scale::link, jak3::ripple_apply_wave_table::link, - jak3::ripple_create_wave_table::link, jak3::ripple_execute_init::link}}, - {"ocean-vu0", - {jak3::method_14_ocean::link, jak3::method_15_ocean::link, jak3::method_16_ocean::link}}, - {"ocean", - {jak3::init_ocean_far_regs::link, jak3::draw_large_polygon_ocean::link, - jak3::render_ocean_quad::link}}, - {"generic-merc", - {jak3::generic_merc_do_chain::link, jak3::generic_merc_execute_asm::link, - jak3::generic_merc_death::link, jak3::generic_merc_query::link, - jak3::generic_translucent::link, jak3::high_speed_reject::link, - jak3::mercneric_convert::link, jak3::generic_merc_init_asm::link}}, - }}; + {{"lights", + {jak3::light_hash_get_bucket_index::link, jak3::add_light_sphere_to_light_group::link, + jak3::light_hash_count_items::link, jak3::light_hash_add_items::link}}, + {"debug", + {jak3::debug_line_clip::link, jak3::init_boundary_regs::link, + jak3::draw_boundary_polygon::link, jak3::render_boundary_quad::link, + jak3::render_boundary_tri::link, jak3::set_sky_vf27::link}}, + {"generic-effect", + {jak3::generic_light_proc::link, jak3::generic_envmap_proc::link, + jak3::generic_prepare_dma_double::link, jak3::generic_prepare_dma_single::link, + jak3::generic_warp_source_proc::link, jak3::generic_warp_dest_proc::link, + jak3::generic_warp_dest::link, jak3::generic_warp_envmap_dest::link, + jak3::generic_no_light_proc::link}}, + {"font", + {jak3::method_9_font_work::link, jak3::draw_string_asm::link, jak3::get_string_length::link}}, + {"texture", {jak3::adgif_shader_texture_with_update::link}}, + {"collide-func", + {jak3::moving_sphere_triangle_intersect::link, jak3::collide_do_primitives::link}}, + {"prim", {jak3::method_9_prim_strip::link}}, + {"joint", {jak3::cspace_parented_transformq_joint::link}}, + {"foreground", + {jak3::foreground_check_longest_edge_asm::link, jak3::foreground_generic_merc::link, + jak3::foreground_merc::link, jak3::foreground_draw_hud::link}}, + {"particle-curves", {jak3::live_func_curve::link, jak3::birth_func_curve::link}}, + {"collide-hash", + {jak3::method_11_collide_hash::link, jak3::method_12_collide_hash::link, + jak3::fill_bg_using_box_new::link, jak3::fill_bg_using_line_sphere_new::link}}, + {"collide-mesh", + {jak3::method_12_collide_mesh::link, jak3::method_14_collide_mesh::link, + jak3::method_15_collide_mesh::link, jak3::method_10_collide_shape_prim_mesh::link}}, + {"collide-cache", + {jak3::method_10_collide_shape_prim_mesh::link, + jak3::method_10_collide_shape_prim_sphere::link, + jak3::method_10_collide_shape_prim_group::link, + jak3::method_11_collide_shape_prim_mesh::link, + jak3::method_11_collide_shape_prim_sphere::link, + jak3::method_11_collide_shape_prim_group::link, jak3::method_9_collide_cache_prim::link, + jak3::method_10_collide_cache_prim::link, jak3::method_17_collide_cache::link, + jak3::method_9_collide_puss_work::link, jak3::method_10_collide_puss_work::link}}, + {"collide-edge-grab", + {jak3::method_10_collide_edge_hold_list::link, jak3::method_19_collide_edge_work::link, + jak3::method_9_edge_grab_info::link, jak3::method_17_collide_edge_work::link, + jak3::method_16_collide_edge_work::link, jak3::method_18_collide_edge_work::link}}, + {"spatial-hash", + {jak3::method_18_grid_hash::link, jak3::method_19_grid_hash::link, + jak3::method_20_grid_hash::link, jak3::method_22_grid_hash::link, + jak3::method_28_sphere_hash::link, jak3::method_32_sphere_hash::link, + jak3::method_29_sphere_hash::link, jak3::method_30_sphere_hash::link, + jak3::method_31_sphere_hash::link, jak3::method_32_spatial_hash::link, + jak3::method_38_spatial_hash::link, jak3::method_35_spatial_hash::link, + jak3::method_36_spatial_hash::link, jak3::method_34_spatial_hash::link}}, + {"sparticle-launcher", + {jak3::sparticle_motion_blur::link, jak3::sp_launch_particles_var::link, + jak3::particle_adgif::link, jak3::sp_init_fields::link}}, + {"sparticle", {jak3::sp_process_block_2d::link, jak3::sp_process_block_3d::link}}, + {"nav-engine", + {jak3::method_21_nav_engine::link, jak3::method_20_nav_engine::link, + jak3::method_18_nav_engine::link, jak3::method_17_nav_engine::link, + jak3::nav_state_patch_pointers::link, jak3::nav_dma_send_from_spr_no_flush::link, + jak3::nav_dma_send_to_spr_no_flush::link}}, + {"nav-control", {jak3::method_39_nav_state::link}}, + {"merc-blend-shape", + {jak3::blerc_execute::link, jak3::setup_blerc_chains_for_one_fragment::link}}, + {"wvehicle-part", {jak3::sparticle_motion_blur_dirt::link}}, + {"ripple", + {jak3::ripple_matrix_scale::link, jak3::ripple_apply_wave_table::link, + jak3::ripple_create_wave_table::link, jak3::ripple_execute_init::link}}, + {"ocean-vu0", + {jak3::method_14_ocean::link, jak3::method_15_ocean::link, jak3::method_16_ocean::link}}, + {"ocean", + {jak3::init_ocean_far_regs::link, jak3::draw_large_polygon_ocean::link, + jak3::render_ocean_quad::link}}, + {"generic-merc", + {jak3::generic_merc_do_chain::link, jak3::generic_merc_execute_asm::link, + jak3::generic_merc_death::link, jak3::generic_merc_query::link, + jak3::generic_translucent::link, jak3::high_speed_reject::link, + jak3::mercneric_convert::link, jak3::generic_merc_init_asm::link}}, + {"sky-tng", + {jak3::set_tex_offset::link, jak3::render_sky_quad::link, jak3::render_sky_tri::link, + jak3::method_17_sky_work::link, jak3::method_18_sky_work::link, + jak3::method_29_sky_work::link, jak3::method_30_sky_work::link, + jak3::method_31_sky_work::link, jak3::method_34_sky_work::link, + jak3::method_35_sky_work::link, jak3::method_32_sky_work::link, + jak3::set_sky_vf23_value::link, jak3::draw_large_polygon::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/jak3/engine/dma/dma-buffer.gc b/goal_src/jak3/engine/dma/dma-buffer.gc index c428cf4983..40c198c863 100644 --- a/goal_src/jak3/engine/dma/dma-buffer.gc +++ b/goal_src/jak3/engine/dma/dma-buffer.gc @@ -354,6 +354,8 @@ (deftype dma-gif (structure) "Believed unused GIF header type." ((gif uint64 2) + (gif0 uint64 :overlay-at (-> gif 0)) + (gif1 uint64 :overlay-at (-> gif 1)) (quad uint128 :overlay-at (-> gif 0)) ) ) @@ -363,6 +365,8 @@ "The header for a DMA transfer that goes directly to GIF, containing DMA, VIF, GIF tags." ((dma-vif dma-packet :inline) (gif uint64 2) + (gif0 uint64 :overlay-at (-> gif 0)) + (gif1 uint64 :overlay-at (-> gif 1)) (quad uint128 2 :overlay-at (-> dma-vif dma)) ) ) diff --git a/goal_src/jak3/engine/draw/drawable.gc b/goal_src/jak3/engine/draw/drawable.gc index 7c7523f468..13ecdf570e 100644 --- a/goal_src/jak3/engine/draw/drawable.gc +++ b/goal_src/jak3/engine/draw/drawable.gc @@ -1536,14 +1536,14 @@ (set! (-> pp clock) gp-2) ) - ; ;; draw sky - ; (with-profiler 'sky *profile-sky-color* - ; (if (-> *sky-work* draw-vortex) - ; (draw-vortex) - ; (draw *sky-work*) - ; ) - ; (flush-cache 0) - ; ) + ;; draw sky + (with-profiler 'sky *profile-sky-color* + (if (-> *sky-work* draw-vortex) + (draw-vortex) + (draw *sky-work*) + ) + (flush-cache 0) + ) ; ;; draw ocean diff --git a/goal_src/jak3/engine/gfx/blit-displays-h.gc b/goal_src/jak3/engine/gfx/blit-displays-h.gc index 33177d7164..d41ea279b5 100644 --- a/goal_src/jak3/engine/gfx/blit-displays-h.gc +++ b/goal_src/jak3/engine/gfx/blit-displays-h.gc @@ -49,7 +49,7 @@ (blit-displays-work-method-17 (_type_ vector int float symbol) none) (blit-displays-work-method-18 () none) (blit-displays-work-method-19 (_type_) none) - (blit-displays-work-method-20 () none) + (blit-displays-work-method-20 (_type_) none) (get-menu-mode (_type_) symbol) (get-screen-copied (_type_) symbol) (get-horizontal-flip-flag (_type_) symbol) diff --git a/goal_src/jak3/engine/gfx/foreground/foreground.gc b/goal_src/jak3/engine/gfx/foreground/foreground.gc index f0ccbe4e11..5c6f86da1d 100644 --- a/goal_src/jak3/engine/gfx/foreground/foreground.gc +++ b/goal_src/jak3/engine/gfx/foreground/foreground.gc @@ -239,7 +239,7 @@ (bucket-id-16 gmerc-l5-tfrag) (bucket-id-16 tex-l5-tfrag) (bucket-id-16 gmerc2-l5-tfrag) - (bucket-id-16 bucket5) + (bucket-id-16 sky) (bucket-id-16 merc-l5-pris) (bucket-id-16 emerc-l5-pris) (bucket-id-16 gmerc-l5-pris) diff --git a/goal_src/jak3/engine/gfx/hw/display-h.gc b/goal_src/jak3/engine/gfx/hw/display-h.gc index 1614d4aab0..f7d07d504b 100644 --- a/goal_src/jak3/engine/gfx/hw/display-h.gc +++ b/goal_src/jak3/engine/gfx/hw/display-h.gc @@ -114,7 +114,7 @@ At any point in time, there are 3 frames in progress: (set! (-> gp-0 pmode) (new 'static 'gs-pmode :en1 #x1 :crtmd #x1 :mmod #x1 :slbg #x1)) (set! (-> gp-0 run-half-speed) #f) (set! (-> gp-0 vu1-enable-user-menu) (vu1-renderer-mask - rn3 + sky rn4 rn5 hfrag @@ -150,7 +150,7 @@ At any point in time, there are 3 frames in progress: ) ) (set! (-> gp-0 vu1-enable-user) (vu1-renderer-mask - rn3 + sky rn4 rn5 hfrag diff --git a/goal_src/jak3/engine/gfx/sky/sky-data.gc b/goal_src/jak3/engine/gfx/sky/sky-data.gc index f12e8ba570..3508f98ceb 100644 --- a/goal_src/jak3/engine/gfx/sky/sky-data.gc +++ b/goal_src/jak3/engine/gfx/sky/sky-data.gc @@ -14,49 +14,120 @@ :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) ) - :gif (new 'static 'array uint64 2 #x1000000000008005 #xe) + :gif0 (new 'static 'gif-tag64 :nloop #x5 :eop #x1 :nreg #x1) + :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d)) ) :draw-tmpl (new 'static 'dma-gif-packet :dma-vif (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) ) - :gif (new 'static 'array uint64 2 #x502b400000008001 #x42421) + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :abe #x1) + :nreg #x5 + ) + :gif1 (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) + ) ) :draw-tmpl2 (new 'static 'dma-gif-packet :dma-vif (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) ) - :gif (new 'static 'array uint64 2 #x50ab400000008001 #x43431) + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :abe #x1 :fst #x1) + :nreg #x5 + ) + :gif1 (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id uv) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id uv) + :regs4 (gif-reg-id xyzf2) + ) ) :fog-tmpl (new 'static 'dma-gif-packet :dma-vif (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #xa :id (dma-tag-id cnt)) :vif1 (new 'static 'vif-tag :imm #xa :cmd (vif-cmd direct) :msk #x1) ) - :gif (new 'static 'array uint64 2 #x902a400000008001 #x424242421) + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :tme #x1 :abe #x1) + :nreg #x9 + ) + :gif1 (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) + ) ) :blend-tmpl (new 'static 'dma-gif-packet :dma-vif (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) ) - :gif (new 'static 'array uint64 2 #x50ab400000008001 #x43431) + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :abe #x1 :fst #x1) + :nreg #x5 + ) + :gif1 (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id uv) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id uv) + :regs4 (gif-reg-id xyzf2) + ) ) :sprite-tmpl (new 'static 'dma-gif-packet :dma-vif (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)) :vif1 (new 'static 'vif-tag :imm #x3 :cmd (vif-cmd direct) :msk #x1) ) - :gif (new 'static 'array uint64 2 #x2003400000008001 #x55) + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type sprite)) + :nreg #x2 + ) + :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id xyz2) :regs1 (gif-reg-id xyz2)) ) :sprite-tmpl2 (new 'static 'dma-gif-packet :dma-vif (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x21 :id (dma-tag-id cnt)) :vif1 (new 'static 'vif-tag :imm #x21 :cmd (vif-cmd direct) :msk #x1) ) - :gif (new 'static 'array uint64 2 #x2003400000008010 #x55) + :gif0 (new 'static 'gif-tag64 + :nloop #x10 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type sprite)) + :nreg #x2 + ) + :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id xyz2) :regs1 (gif-reg-id xyz2)) ) :sun-coords (new 'static 'inline-array vector 2 (new 'static 'vector :x -267.0 :y -267.0 :w 1.0) @@ -112,10 +183,46 @@ (new 'static 'vector4w :x #x387528 :y #x723099 :z #x140983 :w #x874310) (new 'static 'vector4w :x #x2387 :y #x129818 :z #x219810 :w #x623790) ) - :giftag-base (new 'static 'dma-gif :gif (new 'static 'array uint64 2 #x3002c00000008001 #x412)) - :giftag-haze (new 'static 'dma-gif :gif (new 'static 'array uint64 2 #x3026c00000008001 #x412)) - :giftag-roof (new 'static 'dma-gif :gif (new 'static 'array uint64 2 #x302ec00000008001 #x412)) - :giftag-ocean (new 'static 'dma-gif :gif (new 'static 'array uint64 2 #x301ec00000008001 #x412)) + :giftag-base (new 'static 'dma-gif + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan)) + :nreg #x3 + ) + :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + :giftag-haze (new 'static 'dma-gif + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :abe #x1) + :nreg #x3 + ) + :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + :giftag-roof (new 'static 'dma-gif + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :tme #x1 :abe #x1) + :nreg #x3 + ) + :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + :giftag-ocean (new 'static 'dma-gif + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) :draw-vortex #f :day-star-scale 1.0 :disable-day-star #f diff --git a/goal_src/jak3/engine/gfx/sky/sky-h.gc b/goal_src/jak3/engine/gfx/sky/sky-h.gc index 417817391c..7c6c383a28 100644 --- a/goal_src/jak3/engine/gfx/sky/sky-h.gc +++ b/goal_src/jak3/engine/gfx/sky/sky-h.gc @@ -198,32 +198,32 @@ (init-orbit-settings! (_type_ int float float float float float float) none) (update-colors-for-time (_type_ float) none) (update-time-and-speed (_type_ float float) none) - (sky-work-method-13 () none) + (draw-erase (_type_ dma-buffer vector) none) (draw (_type_) none) - (sky-work-method-15 () none) - (sky-work-method-16 () none) - (sky-work-method-17 () none) - (sky-work-method-18 () none) - (sky-work-method-19 () none) - (sky-work-method-20 () none) - (sky-work-method-21 () none) - (sky-work-method-22 () none) - (sky-work-method-23 () none) - (sky-work-method-24 () none) - (sky-work-method-25 () none) - (sky-work-method-26 () none) - (sky-work-method-27 () none) - (sky-work-method-28 () none) - (sky-work-method-29 () none) - (sky-work-method-30 () none) - (sky-work-method-31 () none) - (sky-work-method-32 () none) - (sky-work-method-33 () none) - (sky-work-method-34 () none) - (sky-work-method-35 () none) - (sky-work-method-36 () none) - (sky-work-method-37 () none) - (sky-work-method-38 () none) + (update-camera-matrix (_type_ matrix) none) + (update-template-colors (_type_) none) + (init-regs-for-large-polygon-draw (_type_) none) + (init-regs-for-sky-asm (_type_) none) + (cloud-vtx-light-update (_type_ vector vector cloud-lights vector vector) none) + (cloud-vtx-tex-update (_type_ vector vector vector cloud-lights) none) + (adjust-cloud-lighting (_type_) none) + (cloud-vtx1-to-sky (_type_ sky-vertex cloud-vertex) none) + (cloud-vtx2-to-sky (_type_ sky-vertex cloud-vertex) none) + (draw-clouds (_type_ dma-buffer) none) + (apply-haze-light (_type_ vector vector haze-lights float) none) + (adjust-haze-lighting (_type_) none) + (haze-vtx-to-sky (_type_ sky-vertex sky-vertex haze-vertex) none) + (draw-haze (_type_ dma-buffer) none) + (sun-dma (_type_ dma-buffer) none) + (green-sun-dma (_type_ dma-buffer) none) + (moon-dma (_type_ dma-buffer) none) + (day-star-dma (_type_ dma-buffer) none) + (setup-stars (_type_ matrix sky-upload-data) none) + (stars-transform-asm (_type_) none) + (stars-dma (_type_ dma-buffer) none) + (draw-roof (_type_ dma-buffer) none) + (draw-base (_type_ dma-buffer) none) + (draw-fog (_type_ dma-buffer) none) ) ) diff --git a/goal_src/jak3/engine/gfx/sky/sky-tng.gc b/goal_src/jak3/engine/gfx/sky/sky-tng.gc index 4c10895d47..6af35cf552 100644 --- a/goal_src/jak3/engine/gfx/sky/sky-tng.gc +++ b/goal_src/jak3/engine/gfx/sky/sky-tng.gc @@ -5,16 +5,31 @@ ;; name in dgo: sky-tng ;; dgos: GAME +(def-mips2c set-sky-vf23-value (function int none)) + ;; DECOMP BEGINS +(def-mips2c set-tex-offset (function int int none)) + +;; these can't be called directly from GOAL +;; (def-mips2c draw-large-polygon function) +;; (def-mips2c clip-polygon-against-positive-hyperplane function) +;; (def-mips2c clip-polygon-against-negative-hyperplane function) + +(def-mips2c render-sky-quad (function (inline-array sky-vertex) dma-buffer none)) +(def-mips2c render-sky-tri (function (inline-array sky-vertex) dma-buffer none)) + +;; WARN: Return type mismatch pointer vs none. +;; ERROR: Function may read a register that is not set: ra +;; ERROR: Unsupported inline assembly instruction kind - [jr ra] (defun close-sky-buffer ((arg0 dma-buffer)) - "Terminate dma from large polygon renderer. This should be called after the last - call to render-sky-tri/quad." + "Close DMA buffer for large polygon drawing." + (local-vars (ra-0 none)) (nop!) (let ((v1-0 #x8000) (v0-0 (-> arg0 base)) ) - (set! (-> (the-as (pointer uint128) v0-0)) (the uint128 0)) + (set! (-> (the-as (pointer int128) v0-0)) (the int128 0)) (nop!) (set! (-> (the-as (pointer int32) v0-0)) v1-0) (let ((v0-1 (&+ v0-0 16))) @@ -26,7 +41,47 @@ (none) ) +(defmethod update-camera-matrix ((this sky-work) (arg0 matrix)) + "Set the camera matrix (no perspective) for sky drawing." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (let ((v1-0 (-> this cam-mat))) + (let* ((a0-1 v1-0) + (t0-0 arg0) + (a1-1 (-> t0-0 rvec quad)) + (a2-0 (-> t0-0 uvec quad)) + (a3-0 (-> t0-0 fvec quad)) + (t0-1 (-> t0-0 trans quad)) + ) + (set! (-> a0-1 rvec quad) a1-1) + (set! (-> a0-1 uvec quad) a2-0) + (set! (-> a0-1 fvec quad) a3-0) + (set! (-> a0-1 trans quad) t0-1) + ) + (.svf (&-> v1-0 trans quad) vf0) + (matrix*! v1-0 v1-0 (-> *math-camera* perspective)) + ) + 0 + (none) + ) + ) + +(defmethod update-template-colors ((this sky-work)) + "Update work with sky/erase colors from time-of-day/level." + (let ((v1-1 (-> *time-of-day-context* current-fog erase-color)) + (a0-2 (-> *level* level-default mood-context current-sky-color)) + ) + (dotimes (a1-1 12) + (set! (-> sky-base-polygons a1-1 col quad) (-> v1-1 quad)) + (set! (-> sky-roof-polygons a1-1 col quad) (-> a0-2 quad)) + ) + ) + 0 + (none) + ) + (defmethod update-time-and-speed ((this sky-work) (arg0 float) (arg1 float)) + "Update cloud sroll and sun/moon position for the time." (if (and (level-get-target-inside *level*) (= (-> (level-get-target-inside *level*) info taskname) 'nest)) (set! arg1 (* 10.0 arg1)) ) @@ -40,6 +95,10 @@ (none) ) +(defmethod-mips2c "(method 17 sky-work)" 17 sky-work) + +(defmethod-mips2c "(method 18 sky-work)" 18 sky-work) + (defmethod update-colors-for-time ((this sky-work) (arg0 float)) 0 0 @@ -82,3 +141,618 @@ 0 (none) ) + +(defmethod cloud-vtx-light-update ((this sky-work) (arg0 vector) (arg1 vector) (arg2 cloud-lights) (arg3 vector) (arg4 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector4))) + (let* ((f0-1 (vector-dot (-> arg2 sun0-normal) arg1)) + (f1-1 (vector-dot (-> arg2 sun1-normal) arg1)) + (f2-1 (vector-dot (-> arg2 moon-normal) arg1)) + (f0-2 (fmax 0.0 f0-1)) + (f30-0 (fmax 0.0 f1-1)) + (f28-0 (fmax 0.0 f2-1)) + ) + (set! (-> s5-0 quad) (-> arg4 quad)) + (vector4-madd! s5-0 s5-0 (the-as vector4 arg3) f0-2) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun1-color)) f30-0) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 moon-color)) f28-0) + ) + (vector4-scale! s5-0 s5-0 128.0) + (set! (-> arg0 x) (fmax 0.0 (fmin 255.0 (-> s5-0 x)))) + (set! (-> arg0 y) (fmax 0.0 (fmin 255.0 (-> s5-0 y)))) + (set! (-> arg0 z) (fmax 0.0 (fmin 255.0 (-> s5-0 z)))) + ) + 0 + (none) + ) + +(defmethod cloud-vtx-tex-update ((this sky-work) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 cloud-lights)) + (let ((s5-0 (new 'stack-no-clear 'vector4)) + (s2-0 (new 'stack-no-clear 'vector4)) + (s4-0 (new 'stack-no-clear 'vector4)) + (f28-0 0.00390625) + (f30-0 0.015625) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (vector--float*! (the-as vector s5-0) arg2 (-> arg3 sun0-normal) 9.0) + (vector--float*! (the-as vector s2-0) arg2 (-> arg3 sun1-normal) 9.0) + (vector--float*! (the-as vector s4-0) arg2 (-> arg3 moon-normal) 9.0) + (vector4-scale! s5-0 s5-0 (* (-> arg3 sun0-scale) f28-0)) + (vector4-madd! s5-0 s5-0 s2-0 (* 0.25 f28-0 (-> arg3 sun1-scale))) + (vector4-madd! s5-0 s5-0 s4-0 (* (-> arg3 moon-scale) f28-0)) + (+! (-> arg0 x) (fmax (fmin (-> s5-0 x) f30-0) (- f30-0))) + (+! (-> arg0 y) (fmax (fmin (-> s5-0 z) f30-0) (- f30-0))) + ) + 0 + (none) + ) + +(defmethod adjust-cloud-lighting ((this sky-work)) + (let ((s5-0 *cloud-vert-array*) + (s4-0 (-> this cloud-lights)) + ) + (set! (-> s4-0 sun0-normal quad) (-> this upload-data data 0)) + (set! (-> s4-0 sun1-normal quad) (-> (&-> this upload-data data 4) 0)) + (set! (-> s4-0 moon-normal quad) (-> this upload-data moon pos quad)) + (vector-normalize! (-> s4-0 sun0-normal) 1.0) + (vector-normalize! (-> s4-0 sun1-normal) 1.0) + (vector-normalize! (-> s4-0 moon-normal) 1.0) + (set! (-> s4-0 sun0-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun0-normal y)))))) + (set! (-> s4-0 sun1-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun1-normal y)))))) + (set! (-> s4-0 moon-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 moon-normal y)))))) + (let ((s1-0 (-> s4-0 ambi-color)) + (s2-0 (-> s4-0 ambi-color-lower)) + (s3-0 (-> this sun0-color-lower)) + ) + (let ((f30-0 (- 1.0 (fmax 0.0 (fmin 0.75 (* 4.0 (-> s4-0 moon-normal y)))))) + (f28-0 (* 0.3333 (fmax 0.0 (fmin 1.0 (+ -1.0 (* 8.0 (-> s4-0 sun0-normal y))))))) + ) + (vector4-scale! (the-as vector4 s2-0) (the-as vector4 (-> this ambi-color-lower)) f30-0) + (vector4-madd! (the-as vector4 s2-0) (the-as vector4 s2-0) (the-as vector4 s3-0) f28-0) + (vector4-scale! (the-as vector4 s1-0) (the-as vector4 (-> this ambi-color)) f30-0) + (vector4-madd! (the-as vector4 s1-0) (the-as vector4 s1-0) (the-as vector4 s3-0) f28-0) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun0-color)) + (the-as vector4 (-> this sun0-color)) + (-> s4-0 sun0-scale) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun1-color)) + (the-as vector4 (-> this sun1-color)) + (* 0.5 (-> s4-0 sun1-scale)) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 moon-color)) + (the-as vector4 (-> this moon-color)) + (-> s4-0 moon-scale) + ) + (vector4-scale! (the-as vector4 (-> s4-0 sun0-color-lower)) (the-as vector4 s3-0) (-> s4-0 sun0-scale)) + ) + (dotimes (s3-1 100) + (let ((s2-1 (-> s5-0 data s3-1))) + (cloud-vtx-light-update this (-> s2-1 col) (-> s2-1 nrm) s4-0 (-> s4-0 sun0-color) (-> s4-0 ambi-color)) + (cloud-vtx-light-update + this + (-> s2-1 col2) + (-> s2-1 nrm2) + s4-0 + (-> s4-0 sun0-color-lower) + (-> s4-0 ambi-color-lower) + ) + (cloud-vtx-tex-update this (-> s2-1 stq2) (-> s2-1 stq) (-> s2-1 pos) s4-0) + ) + ) + ) + 0 + (none) + ) + +(defmethod cloud-vtx1-to-sky ((this sky-work) (arg0 sky-vertex) (arg1 cloud-vertex)) + (set! (-> arg0 pos quad) (-> arg1 pos quad)) + (set! (-> arg0 stq quad) (-> arg1 stq quad)) + (set! (-> arg0 col quad) (-> arg1 col quad)) + 0 + (none) + ) + +(defmethod cloud-vtx2-to-sky ((this sky-work) (arg0 sky-vertex) (arg1 cloud-vertex)) + (set! (-> arg0 pos quad) (-> arg1 pos quad)) + (set! (-> arg0 stq quad) (-> arg1 stq2 quad)) + (set! (-> arg0 col quad) (-> arg1 col2 quad)) + 0 + (none) + ) + +(defmethod draw-clouds ((this sky-work) (arg0 dma-buffer)) + (local-vars (v1-19 float) (sv-16 cloud-vert-array) (sv-20 (inline-array sky-vertex)) (sv-32 int)) + + (when (zero? *sky-texture-anim-array*) ;; added + (return #f) + ) + + (rlet ((vf23 :class vf) + (vf27 :class vf) + ) + (dma-buffer-add-gs-set arg0 + (test-1 (new 'static 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x50 + :afail #x1 + :zte #x1 + :ztst (gs-ztest greater-equal) + ) + ) + (tex0-1 (new 'static 'gs-tex0 + :tbp0 #x100 + :tbw #x2 + :psm #x1b + :tcc #x1 + :cbp #x300 + :cld #x1 + :th (log2 128) + :tw (log2 128) + ) + ) + (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (clamp-1 (new 'static 'gs-clamp)) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + (texflush 0) + ) + ; (.lvf vf27 (&-> this giftag-roof quad)) + ; (let ((v1-18 #x43c80000)) + ; (.mov vf23 v1-18) + ; ) + ; (.mov v1-19 vf23) + ;; og:preserve-this + (set-sky-vf27 (&-> this giftag-roof quad)) + (set-sky-vf23-value #x43c80000) + (set-tex-offset (the-as int (-> this off-s)) (the-as int (-> this off-t))) + (let ((s4-1 (-> arg0 base))) + (&+! (-> arg0 base) 16) + (set! sv-16 *cloud-vert-array*) + (set! sv-20 *cloud-poly*) + (dotimes (s3-1 9) + (dotimes (s2-2 9) + (let ((s1-0 (+ (* 10 s3-1) s2-2))) + (set! sv-32 (+ (* 9 s3-1) s2-2)) + (let ((s0-0 (+ s2-2 81 (* 9 s3-1)))) + (cloud-vtx1-to-sky this (-> sv-20 (* sv-32 4)) (-> sv-16 data s1-0)) + (cloud-vtx1-to-sky this (-> sv-20 (+ (* sv-32 4) 1)) (-> sv-16 data (+ s1-0 1))) + (cloud-vtx1-to-sky this (-> sv-20 (+ (* sv-32 4) 2)) (-> sv-16 data (+ s1-0 11))) + (cloud-vtx1-to-sky this (-> sv-20 (+ (* sv-32 4) 3)) (-> sv-16 data (+ s1-0 10))) + (cloud-vtx2-to-sky this (-> sv-20 (* s0-0 4)) (-> sv-16 data s1-0)) + (cloud-vtx2-to-sky this (-> sv-20 (+ (* s0-0 4) 1)) (-> sv-16 data (+ s1-0 1))) + (cloud-vtx2-to-sky this (-> sv-20 (+ (* s0-0 4) 2)) (-> sv-16 data (+ s1-0 11))) + (cloud-vtx2-to-sky this (-> sv-20 (+ (* s0-0 4) 3)) (-> sv-16 data (+ s1-0 10))) + ) + ) + ) + ) + (dotimes (s5-1 162) + (render-sky-quad (the-as (inline-array sky-vertex) (-> sv-20 (* s5-1 4))) arg0) + ) + (close-sky-buffer arg0) + (let ((v1-81 (/ (the-as int (+ (- -16 (the-as int s4-1)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as (pointer uint64) s4-1)) (logior #x10000000 (shr (shl v1-81 48) 48))) + (set! (-> (the-as (pointer int32) s4-1) 2) 0) + (set! (-> (the-as (pointer int32) s4-1) 3) (the-as int (logior #x50000000 (shr (shl v1-81 48) 48)))) + ) + ) + 0 + (none) + ) + ) + +(defmethod apply-haze-light ((this sky-work) (arg0 vector) (arg1 vector) (arg2 haze-lights) (arg3 float)) + (let* ((s5-0 (new 'stack-no-clear 'vector4)) + (f0-1 (vector-dot (-> arg2 sun0-normal) arg1)) + (f1-1 (vector-dot (-> arg2 sun1-normal) arg1)) + (f2-1 (vector-dot (-> arg2 moon-normal) arg1)) + (s3-0 (* arg3 (fmax 0.0 (fmin 1.0 (- 1.0 f0-1))))) + ) + (let ((f0-2 (fmax 0.0 f0-1)) + (f30-0 (fmax 0.0 f1-1)) + (f28-0 (fmax 0.0 f2-1)) + ) + (set! (-> s5-0 quad) (-> arg2 ambi-color quad)) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun0-color)) f0-2) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun1-color)) f30-0) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 moon-color)) f28-0) + ) + (vector4-scale! s5-0 s5-0 128.0) + (set! (-> arg0 x) (fmax (fmin 255.0 (-> s5-0 x)) s3-0)) + (set! (-> arg0 y) (fmax (fmin 255.0 (-> s5-0 y)) s3-0)) + (set! (-> arg0 z) (fmax (fmin 255.0 (-> s5-0 z)) s3-0)) + ) + 0 + (none) + ) + +(defmethod adjust-haze-lighting ((this sky-work)) + (let ((s5-0 *haze-vert-array*) + (s4-0 (-> this haze-lights)) + ) + (set! (-> s4-0 sun0-normal quad) (-> this upload-data data 0)) + (set! (-> s4-0 sun1-normal quad) (-> (&-> this upload-data data 4) 0)) + (set! (-> s4-0 moon-normal quad) (-> this upload-data moon pos quad)) + (vector-normalize! (-> s4-0 sun0-normal) 1.0) + (vector-normalize! (-> s4-0 sun1-normal) 1.0) + (vector-normalize! (-> s4-0 moon-normal) 1.0) + (set! (-> s4-0 sun0-scale) (fmax 0.0 (fmin 1.0 (* 4.0 (+ 0.25 (-> s4-0 sun0-normal y)))))) + (set! (-> s4-0 sun1-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun1-normal y)))))) + (set! (-> s4-0 moon-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 moon-normal y)))))) + (let ((s3-0 (-> s4-0 ambi-color))) + (-> this sun0-color-lower) + (let ((f30-0 (- 1.0 (fmax 0.0 (fmin 0.75 (* 4.0 (-> s4-0 moon-normal y)))))) + (f0-8 (fmax 0.0 (fmin 1.0 (* 5.0 (+ 0.125 (-> s4-0 sun0-normal y)))))) + (s2-0 (new 'stack-no-clear 'vector4)) + ) + (set-vector! s2-0 1.15 0.0 0.5 1.0) + (vector4-lerp! (the-as vector s2-0) (the-as vector s2-0) (-> this sun0-color) f0-8) + (vector4-scale! (the-as vector4 s3-0) (the-as vector4 (-> this ambi-color)) f30-0) + (vector4-scale! (the-as vector4 (-> s4-0 sun0-color)) s2-0 (-> s4-0 sun0-scale)) + ) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun1-color)) + (the-as vector4 (-> this sun1-color)) + (* 0.5 (-> s4-0 sun1-scale)) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 moon-color)) + (the-as vector4 (-> this moon-color)) + (-> s4-0 moon-scale) + ) + (let ((f30-1 (* 144.0 (fmax 0.0 (fmin 1.0 (* 16.0 (-> s4-0 sun0-normal y))))))) + (dotimes (s3-1 36) + (let ((v1-28 (-> s5-0 data s3-1))) + (apply-haze-light this (-> v1-28 col) (-> v1-28 nrm) s4-0 f30-1) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod haze-vtx-to-sky ((this sky-work) (arg0 sky-vertex) (arg1 sky-vertex) (arg2 haze-vertex)) + (set! (-> arg0 pos quad) (-> arg2 pos quad)) + (set! (-> arg0 col quad) (-> arg2 col quad)) + (set! (-> arg0 col w) 128.0) + (set! (-> arg1 pos quad) (-> arg2 pos quad)) + (set! (-> arg1 col quad) (-> arg2 col quad)) + (set! (-> arg1 pos y) 3.0) + (set! (-> arg1 col w) 0.0) + 0 + (none) + ) + +(defmethod draw-haze ((this sky-work) (arg0 dma-buffer)) + (local-vars (sv-16 haze-vert-array) (sv-20 (inline-array sky-vertex))) + (rlet ((vf27 :class vf)) + (dma-buffer-add-gs-set arg0 (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))) + (init-regs-for-large-polygon-draw this) + ;; (.lvf vf27 (&-> this giftag-haze quad)) + (set-sky-vf27 (&-> this giftag-haze quad)) + (let ((s4-0 (-> arg0 base))) + (&+! (-> arg0 base) 16) + (set! sv-16 *haze-vert-array*) + (set! sv-20 *haze-poly*) + (dotimes (s3-0 35) + (haze-vtx-to-sky this (-> sv-20 (* s3-0 4)) (-> sv-20 (+ (* s3-0 4) 1)) (-> sv-16 data s3-0)) + (haze-vtx-to-sky this (-> sv-20 (+ (* s3-0 4) 3)) (-> sv-20 (+ (* s3-0 4) 2)) (-> sv-16 data (+ s3-0 1))) + ) + (haze-vtx-to-sky this (-> sv-20 140) (-> sv-20 141) (-> sv-16 data 35)) + (haze-vtx-to-sky this (-> sv-20 143) (-> sv-20 142) (the-as haze-vertex (-> sv-16 data))) + (dotimes (s5-1 36) + (render-sky-quad (the-as (inline-array sky-vertex) (-> sv-20 (* s5-1 4))) arg0) + ) + (close-sky-buffer arg0) + (let ((v1-41 (/ (the-as int (+ (- -16 (the-as int s4-0)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as (pointer uint64) s4-0)) (logior #x10000000 (shr (shl v1-41 48) 48))) + (set! (-> (the-as (pointer int32) s4-0) 2) 0) + (set! (-> (the-as (pointer int32) s4-0) 3) (the-as int (logior #x50000000 (shr (shl v1-41 48) 48)))) + ) + ) + 0 + (none) + ) + ) + +(defmethod-mips2c "(method 29 sky-work)" 29 sky-work) + +(defmethod-mips2c "(method 30 sky-work)" 30 sky-work) + +(defmethod-mips2c "(method 31 sky-work)" 31 sky-work) + +(defmethod setup-stars ((this sky-work) (arg0 matrix) (arg1 sky-upload-data)) + (set! (-> arg0 fvec quad) (-> arg1 data 0)) + (vector-normalize! (-> arg0 fvec) 1.0) + (vector-cross! (-> arg0 rvec) *z-vector* (-> arg0 fvec)) + (vector-normalize! (-> arg0 rvec) 1.0) + (vector-cross! (-> arg0 uvec) (-> arg0 fvec) (-> arg0 rvec)) + (vector-normalize! (-> arg0 uvec) 1.0) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> s4-1 quad) (-> arg1 data 0)) + (vector-normalize! s4-1 -1.0) + (let ((f0-1 (fmax 0.0 (fmin 1.0 (* 20.0 (+ 0.05 (-> s4-1 y))))))) + (if (= (-> *setting-control* user-current sky-type) 'star-field) + (set! f0-1 1.0) + ) + (dotimes (v1-11 16) + (let ((f1-4 (* (- 128.0 (* 8.0 (the float v1-11))) f0-1))) + (set-vector! (-> this star-colors v1-11) (the int f1-4) (the int f1-4) (the int f1-4) 128) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod-mips2c "(method 34 sky-work)" 34 sky-work) + +(defmethod-mips2c "(method 35 sky-work)" 35 sky-work) + +(defmethod draw-roof ((this sky-work) (arg0 dma-buffer)) + (rlet ((vf27 :class vf)) + (dma-buffer-add-gs-set arg0 + (zbuf-1 (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + ) + (init-regs-for-large-polygon-draw this) + ;; (.lvf vf27 (&-> this giftag-base quad)) + (set-sky-vf27 (&-> this giftag-base quad)) + (let ((s5-1 (-> arg0 base))) + (&+! (-> arg0 base) 16) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 0)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 3)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 6)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 9)) arg0) + (close-sky-buffer arg0) + (let ((v1-14 (/ (the-as int (+ (- -16 (the-as int s5-1)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as (pointer uint64) s5-1)) (logior #x10000000 (shr (shl v1-14 48) 48))) + (set! (-> (the-as (pointer int32) s5-1) 2) 0) + (set! (-> (the-as (pointer int32) s5-1) 3) (the-as int (logior #x50000000 (shr (shl v1-14 48) 48)))) + ) + ) + 0 + (none) + ) + ) + +(defmethod draw-base ((this sky-work) (arg0 dma-buffer)) + (rlet ((vf27 :class vf)) + (dma-buffer-add-gs-set arg0 + (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) + ) + (let ((s5-0 (-> arg0 base))) + (&+! (-> arg0 base) 16) + ;; (.lvf vf27 (&-> this giftag-base quad)) + (set-sky-vf27 (&-> this giftag-base quad)) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 0)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 3)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 6)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 9)) arg0) + (close-sky-buffer arg0) + (let ((v1-12 (/ (the-as int (+ (- -16 (the-as int s5-0)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as (pointer uint64) s5-0)) (logior #x10000000 (shr (shl v1-12 48) 48))) + (set! (-> (the-as (pointer int32) s5-0) 2) 0) + (set! (-> (the-as (pointer int32) s5-0) 3) (the-as int (logior #x50000000 (shr (shl v1-12 48) 48)))) + ) + ) + 0 + (none) + ) + ) + +(defmethod draw-fog ((this sky-work) (arg0 dma-buffer)) + (when (zero? *sky-texture-anim-array*) ;; added + (return #f) + ) + (let ((s4-0 (-> *sky-texture-anim-array* array-data 8 tex))) + (if s4-0 + (dma-buffer-add-gs-set arg0 + (tex0-1 (new 'static 'gs-tex0 + :tcc #x1 + :cld #x1 + :psm (the-as int (-> s4-0 psm)) + :cpsm (-> s4-0 clutpsm) + :cbp (-> s4-0 clutdest) + :th (log2 (-> s4-0 h)) + :tw (log2 (-> s4-0 w)) + :tbw (-> s4-0 width 0) + :tbp0 (-> s4-0 dest 0) + ) + ) + (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (test-1 (new 'static 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x70 + :afail #x3 + :zte #x1 + :ztst (gs-ztest greater-equal) + ) + ) + (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + ) + ) + ) + + (let* ((v1-26 (the-as (inline-array qword) (-> arg0 base))) + (a0-22 *fog-texture-work*) + (f0-0 (-> a0-22 min-corner y)) + (f4-0 (- (-> a0-22 max-corner y) f0-0)) + (f3-0 (/ (- (-> a0-22 corner 1 y) f0-0) f4-0)) + (f2-0 (/ (- (-> a0-22 corner 0 y) f0-0) f4-0)) + (f1-7 (/ (- (-> a0-22 corner 3 y) f0-0) f4-0)) + (f0-2 (/ (- (-> a0-22 corner 2 y) f0-0) f4-0)) + (a0-23 6400) + ) + (set! (-> v1-26 0 quad) (-> this fog-tmpl dma-vif quad)) + (set! (-> v1-26 1 quad) (-> this fog-tmpl quad 1)) + (set-vector! (-> v1-26 2 vector4w) 128 128 128 128) + (set-vector! (-> v1-26 3 vector4w) (the-as int f3-0) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (set-vector! (-> v1-26 4 vector4w) #x7000 #x7300 a0-23 0) + (set-vector! (-> v1-26 5 vector4w) (the-as int f2-0) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (set-vector! (-> v1-26 6 vector4w) #x9000 #x7300 a0-23 0) + (set-vector! (-> v1-26 7 vector4w) (the-as int f1-7) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (set-vector! (-> v1-26 8 vector4w) #x7000 #x8d00 a0-23 0) + (set-vector! (-> v1-26 9 vector4w) (the-as int f0-2) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (let ((v1-27 (the-as (inline-array qword) (-> v1-26 10)))) + (set! (-> v1-27 0 vector4w x) #x9000) + (set! (-> v1-27 0 vector4w y) #x8d00) + (set! (-> v1-27 0 vector4w z) a0-23) + (set! (-> v1-27 0 vector4w w) 0) + ) + ) + (&+! (-> arg0 base) 176) + 0 + (none) + ) + +(defmethod-mips2c "(method 32 sky-work)" 32 sky-work) + +(defmethod draw-erase ((this sky-work) (arg0 dma-buffer) (arg1 vector)) + (dma-buffer-add-gs-set arg0 + (zbuf-1 (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) + (rgbaq (new 'static 'gs-rgbaq + :q 1.0 + :a (the int (-> arg1 w)) + :b (the int (-> arg1 z)) + :g (the int (-> arg1 y)) + :r (the int (-> arg1 x)) + ) + ) + ) + (let ((v1-3 (-> arg0 base))) + (set! (-> (the-as (pointer uint128) v1-3)) (-> this sprite-tmpl dma-vif quad)) + (set! (-> (the-as (pointer uint128) v1-3) 1) (-> this sprite-tmpl quad 1)) + ) + (&+! (-> arg0 base) 32) + (let ((v1-6 (-> arg0 base))) + (set-vector! (the-as vector4w (&+ v1-6 0)) #x7000 #x7300 0 0) + (set-vector! (the-as vector4w (&+ v1-6 16)) #x9000 #x8d00 0 0) + ) + (&+! (-> arg0 base) 32) + 0 + (none) + ) + +(defmethod draw ((this sky-work)) + (let ((s4-0 *time-of-day-context*) + (v1-0 #f) + ) + (dotimes (a0-1 (-> *level* length)) + (let ((a1-3 (-> *level* level a0-1))) + (when (= (-> a1-3 status) 'active) + (if (and (= (-> a1-3 display?) 'display) (logtest? (-> a1-3 info level-flags) (level-flags lf9))) + (set! v1-0 #t) + ) + ) + ) + ) + (cond + ((and v1-0 + (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask sky)) + (logtest? (-> *texture-pool* texture-enable-user) (texture-enable-mask sky)) + ) + (let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf base))) + (let ((a1-9 (if (-> s4-0 use-camera-other) + (-> *math-camera* camera-rot-other) + (-> *math-camera* camera-rot) + ) + ) + ) + (update-camera-matrix this a1-9) + ) + (update-template-colors this) + (adjust-haze-lighting this) + (adjust-cloud-lighting this) + (let ((s4-1 (the-as sky-work *fake-scratchpad-data*))) + (mem-copy! (the-as pointer s4-1) (the-as pointer this) #x2814) + (setup-stars s4-1 (-> s4-1 star-mat) (-> this upload-data)) + (when (nonzero? (-> s4-1 star-colors 0 x)) + (format *stdcon* "doing stars asm!~%") + (format *stdcon* "~`matrix`I~%" (-> s4-1 star-mat)) + (stars-transform-asm s4-1) + ) + (cond + ((= (-> *setting-control* user-current sky-type) 'star-field) + (with-dma-buffer-add-bucket ((s3-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id sky) + ) + (draw-erase s4-1 s3-0 (new 'static 'vector :w 128.0)) + (init-regs-for-sky-asm s4-1) + (stars-dma s4-1 s3-0) + (sun-dma s4-1 s3-0) + (green-sun-dma s4-1 s3-0) + (moon-dma s4-1 s3-0) + ) + ) + (else + (with-dma-buffer-add-bucket ((s2-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id sky) + ) + (draw-roof s4-1 s2-0) + (init-regs-for-sky-asm s4-1) + (if (nonzero? (-> s4-1 star-colors 0 x)) + (stars-dma s4-1 s2-0) + ) + (sun-dma s4-1 s2-0) + (green-sun-dma s4-1 s2-0) + (moon-dma s4-1 s2-0) + (cond + ((or (task-node-closed? (game-task-node precursor-destroy-ship-resolution)) (-> this disable-day-star)) + (set! (-> *time-of-day* 0 day-star-enable) #f) + ) + (else + (set! (-> *time-of-day* 0 day-star-enable) #t) + (day-star-dma s4-1 s2-0) + ) + ) + (draw-haze s4-1 s2-0) + (draw-clouds s4-1 s2-0) + (draw-base s4-1 s2-0) + (draw-fog s4-1 s2-0) + ) + ) + ) + ) + (let ((a0-45 *dma-mem-usage*)) + (when (nonzero? a0-45) + (set! (-> a0-45 length) (max 90 (-> a0-45 length))) + (set! (-> a0-45 data 89 name) "sky") + (+! (-> a0-45 data 89 count) 1) + (+! (-> a0-45 data 89 used) + (&- (-> *display* frames (-> *display* on-screen) global-buf base) (the-as uint gp-0)) + ) + (set! (-> a0-45 data 89 total) (-> a0-45 data 89 used)) + ) + ) + ) + ) + ((get-menu-mode *blit-displays-work*) + (with-dma-buffer-add-bucket ((s5-2 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id sky) + ) + (blit-displays-work-method-20 *blit-displays-work*) + ) + ) + (else + (with-dma-buffer-add-bucket ((s3-2 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id sky) + ) + (draw-erase this s3-2 (-> s4-0 current-fog erase-color)) + ) + ) + ) + ) + 0 + (none) + ) diff --git a/goal_src/jak3/engine/gfx/vu1-user-h.gc b/goal_src/jak3/engine/gfx/vu1-user-h.gc index 63df0c7b5e..6845af2e81 100644 --- a/goal_src/jak3/engine/gfx/vu1-user-h.gc +++ b/goal_src/jak3/engine/gfx/vu1-user-h.gc @@ -31,7 +31,7 @@ (bucket2 2) ;; pc vis stuff (bucket3 3) ;; blit? (tex-lcom-sky-pre 4) - (bucket5 5) ;; sky + (sky 5) ;; sky (bucket6 6) ;; ocean (bucket7 7) ;; unknown new jak 3 texture upload, for all levels. (hfrag 8) ;; hfrag @@ -700,7 +700,7 @@ (rn0) (rn1) (rn2) - (rn3) + (sky) (rn4) (rn5) (hfrag) diff --git a/test/decompiler/reference/jak3/engine/dma/dma-buffer_REF.gc b/test/decompiler/reference/jak3/engine/dma/dma-buffer_REF.gc index d8bbb3c33b..ad2085b00d 100644 --- a/test/decompiler/reference/jak3/engine/dma/dma-buffer_REF.gc +++ b/test/decompiler/reference/jak3/engine/dma/dma-buffer_REF.gc @@ -55,6 +55,8 @@ (deftype dma-gif (structure) "Believed unused GIF header type." ((gif uint64 2) + (gif0 uint64 :overlay-at (-> gif 0)) + (gif1 uint64 :overlay-at (-> gif 1)) (quad uint128 :overlay-at (-> gif 0)) ) ) @@ -67,7 +69,7 @@ (goto cfg-4) ) (format #t "[~8x] ~A~%" this 'dma-gif) - (format #t "~1Tgif[2] @ #x~X~%" (-> this gif)) + (format #t "~1Tgif[2] @ #x~X~%" (&-> this gif0)) (format #t "~1Tquad: ~D~%" (-> this quad)) (label cfg-4) this @@ -78,6 +80,8 @@ "The header for a DMA transfer that goes directly to GIF, containing DMA, VIF, GIF tags." ((dma-vif dma-packet :inline) (gif uint64 2) + (gif0 uint64 :overlay-at (-> gif 0)) + (gif1 uint64 :overlay-at (-> gif 1)) (quad uint128 2 :overlay-at (-> dma-vif dma)) ) ) diff --git a/test/decompiler/reference/jak3/engine/gfx/blit-displays-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/blit-displays-h_REF.gc index 6d9d62bf96..44600e6774 100644 --- a/test/decompiler/reference/jak3/engine/gfx/blit-displays-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/blit-displays-h_REF.gc @@ -44,7 +44,7 @@ (blit-displays-work-method-17 (_type_ vector int float symbol) none) (blit-displays-work-method-18 () none) (blit-displays-work-method-19 (_type_) none) - (blit-displays-work-method-20 () none) + (blit-displays-work-method-20 (_type_) none) (get-menu-mode (_type_) symbol) (get-screen-copied (_type_) symbol) (get-horizontal-flip-flag (_type_) symbol) diff --git a/test/decompiler/reference/jak3/engine/gfx/foreground/foreground_REF.gc b/test/decompiler/reference/jak3/engine/gfx/foreground/foreground_REF.gc index 04121be87d..a68c48b67a 100644 --- a/test/decompiler/reference/jak3/engine/gfx/foreground/foreground_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/foreground/foreground_REF.gc @@ -221,7 +221,7 @@ (bucket-id-16 gmerc-l5-tfrag) (bucket-id-16 tex-l5-tfrag) (bucket-id-16 gmerc2-l5-tfrag) - (bucket-id-16 bucket5) + (bucket-id-16 sky) (bucket-id-16 merc-l5-pris) (bucket-id-16 emerc-l5-pris) (bucket-id-16 gmerc-l5-pris) diff --git a/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc index 9ecc2a2e92..37eddf562d 100644 --- a/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc @@ -157,7 +157,7 @@ (set! (-> gp-0 pmode) (new 'static 'gs-pmode :en1 #x1 :crtmd #x1 :mmod #x1 :slbg #x1)) (set! (-> gp-0 run-half-speed) #f) (set! (-> gp-0 vu1-enable-user-menu) (vu1-renderer-mask - rn3 + sky rn4 rn5 hfrag @@ -193,7 +193,7 @@ ) ) (set! (-> gp-0 vu1-enable-user) (vu1-renderer-mask - rn3 + sky rn4 rn5 hfrag diff --git a/test/decompiler/reference/jak3/engine/gfx/sky/sky-data_REF.gc b/test/decompiler/reference/jak3/engine/gfx/sky/sky-data_REF.gc new file mode 100644 index 0000000000..5189997813 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/sky/sky-data_REF.gc @@ -0,0 +1,1163 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *sky-work*, type sky-work +(define *sky-work* + (new 'static 'sky-work + :adgif-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x1000000000008005 #xe) + ) + :draw-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x502b400000008001 #x42421) + ) + :draw-tmpl2 (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x50ab400000008001 #x43431) + ) + :fog-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xa :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #xa :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x902a400000008001 #x424242421) + ) + :blend-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x50ab400000008001 #x43431) + ) + :sprite-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x3 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x2003400000008001 #x55) + ) + :sprite-tmpl2 (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x21 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x21 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x2003400000008010 #x55) + ) + :sun-coords (new 'static 'inline-array vector 2 + (new 'static 'vector :x -267.0 :y -267.0 :w 1.0) + (new 'static 'vector :x 267.0 :y 267.0) + ) + :green-coords (new 'static 'inline-array vector 2 + (new 'static 'vector :x -126.0 :y -126.0 :w 1.0) + (new 'static 'vector :x 126.0 :y 126.0) + ) + :moon0-coords (new 'static 'inline-array vector 2 + (new 'static 'vector :x -357.0 :y -357.0) + (new 'static 'vector :x 357.0 :y 357.0) + ) + :moon1-coords (new 'static 'inline-array vector 2 + (new 'static 'vector :x -1207.0 :y -1207.0 :w 1.0) + (new 'static 'vector :x 1207.0 :y 1207.0) + ) + :moon2-coords (new 'static 'inline-array vector 2 + (new 'static 'vector :x -232.0 :y -232.0) + (new 'static 'vector :x 232.0 :y 232.0) + ) + :day-star-coords (new 'static 'inline-array vector 2 + (new 'static 'vector :x -126.0 :y -126.0 :w 1.0) + (new 'static 'vector :x 126.0 :y 126.0) + ) + :star-coords (new 'static 'inline-array vector 2 (new 'static 'vector :x -1.5 :y -1.5) (new 'static 'vector :x 1.5 :y 1.5)) + :sun-colors (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #xff :y 64 :w 64) + (new 'static 'vector4w :x #xff :y #xff :z #x80 :w 64) + ) + :green-colors (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :y #xc4 :w #x80) + (new 'static 'vector4w :x #xc4 :y #xff :z #xff :w #x80) + ) + :moon-colors (new 'static 'inline-array vector4w 3 + (new 'static 'vector4w :x 16 :y 32 :z 64 :w 96) + (new 'static 'vector4w :x 16 :y 32 :z 64 :w 64) + (new 'static 'vector4w :x 80 :y 80 :z 80 :w #x80) + ) + :day-star-colors (new 'static 'inline-array vector4w 3 + (new 'static 'vector4w :z #xc4 :w #x80) + (new 'static 'vector4w :x #xc4 :y #xff :z #xff :w #x80) + (new 'static 'vector4w) + ) + :st-coords (new 'static 'inline-array vector 2 (new 'static 'vector :z 1.0) (new 'static 'vector :x 1.0 :y 1.0 :z 1.0)) + :random (new 'static 'inline-array vector4w 8 + (new 'static 'vector4w :x #x181920 :y #x141516 :z #x101112 :w #x234567) + (new 'static 'vector4w :x #x878237 :y #x48778 :z #x489197 :w #x893830) + (new 'static 'vector4w :x #x24762 :y #x289278 :z #x724781 :w #x712983) + (new 'static 'vector4w :x #x176128 :y #x387487 :z #x780983 :w #x723176) + (new 'static 'vector4w :x #x987239 :y #x699872 :z #x987165 :w #x982397) + (new 'static 'vector4w :x #x723897 :y #x238723 :z #x987293 :w #x102981) + (new 'static 'vector4w :x #x387528 :y #x723099 :z #x140983 :w #x874310) + (new 'static 'vector4w :x #x2387 :y #x129818 :z #x219810 :w #x623790) + ) + :giftag-base (new 'static 'dma-gif + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan)) + :nreg #x3 + ) + :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + :giftag-haze (new 'static 'dma-gif + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :abe #x1) + :nreg #x3 + ) + :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + :giftag-roof (new 'static 'dma-gif + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :tme #x1 :abe #x1) + :nreg #x3 + ) + :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + :giftag-ocean (new 'static 'dma-gif + :gif0 (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + :draw-vortex #f + :day-star-scale 1.0 + :disable-day-star #f + ) + ) + +;; definition for symbol sky-base-polygons, type (inline-array sky-vertex) +(define sky-base-polygons (new 'static 'inline-array sky-vertex 12 + (new 'static 'sky-vertex :pos (new 'static 'vector :z -40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :x 40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :y -40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :x 40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :z 40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :y -40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :z 40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :x -40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :y -40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :x -40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :z -40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :y -40960000.0)) + ) + ) + +;; definition for symbol sky-roof-polygons, type (inline-array sky-vertex) +(define sky-roof-polygons (new 'static 'inline-array sky-vertex 12 + (new 'static 'sky-vertex :pos (new 'static 'vector :z -40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :x 40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :y 10240000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :x 40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :z 40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :y 10240000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :z 40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :x -40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :y 10240000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :x -40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :z -40960000.0)) + (new 'static 'sky-vertex :pos (new 'static 'vector :y 10240000.0)) + ) + ) + +;; definition for symbol *cloud-vert-array*, type cloud-vert-array +(define *cloud-vert-array* (new 'static 'cloud-vert-array)) + +;; definition for symbol *cloud-poly*, type (inline-array sky-vertex) +(define *cloud-poly* (new 'static 'inline-array sky-vertex 648 + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + ) + ) + +;; definition for function init-cloud-vert-array +;; INFO: Used lq/sq +(defun init-cloud-vert-array () + (let ((gp-0 *cloud-vert-array*)) + (dotimes (s5-0 10) + (dotimes (s4-0 10) + (let ((s3-0 (-> gp-0 data (+ (* 10 s5-0) s4-0)))) + (set! (-> s3-0 pos x) (* 2.0 (+ -4.5 (the float s4-0)))) + (set! (-> s3-0 pos z) (* 2.0 (+ -4.5 (the float s5-0)))) + (set! (-> s3-0 pos y) + (fmin (cos (* 182.04445 (* 10.0 (-> s3-0 pos x)))) (cos (* 182.04445 (* 10.0 (-> s3-0 pos z))))) + ) + (set-vector! (-> s3-0 stq) (* 0.25 (the float (+ s4-0 -4))) (* 0.25 (the float (+ s5-0 -4))) 1.0 1.0) + (set! (-> s3-0 nrm quad) (-> s3-0 pos quad)) + (+! (-> s3-0 nrm y) 1.0) + (vector-normalize! (-> s3-0 nrm) 1.0) + (vector-negate! (-> s3-0 nrm2) (-> s3-0 nrm)) + (cond + ((or (zero? s5-0) (= s5-0 9) (zero? s4-0) (= s4-0 9)) + (set! (-> s3-0 col w) 0.0) + (set! (-> s3-0 col2 w) 0.0) + ) + ((or (= s5-0 1) (= s5-0 8) (= s4-0 1) (= s4-0 8)) + (set! (-> s3-0 col w) 48.0) + (set! (-> s3-0 col2 w) 48.0) + ) + (else + (set! (-> s3-0 col w) 128.0) + (set! (-> s3-0 col2 w) 128.0) + ) + ) + ) + ) + ) + ) + #f + ) + +;; failed to figure out what this is: +(init-cloud-vert-array) + +;; definition for symbol *haze-vert-array*, type haze-vert-array +(define *haze-vert-array* (new 'static 'haze-vert-array)) + +;; definition for symbol *haze-poly*, type (inline-array sky-vertex) +(define *haze-poly* (new 'static 'inline-array sky-vertex 144 + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + ) + ) + +;; definition for function init-haze-vert-array +;; INFO: Used lq/sq +(defun init-haze-vert-array () + (let ((gp-0 *haze-vert-array*)) + (dotimes (s5-0 36) + (let ((s4-0 (-> gp-0 data s5-0))) + (set! (-> s4-0 pos x) (* 9.0 (sin (* 182.04445 (* 10.0 (the float s5-0)))))) + (set! (-> s4-0 pos z) (* 9.0 (cos (* 182.04445 (* 10.0 (the float s5-0)))))) + (set! (-> s4-0 pos y) 0.0) + (set! (-> s4-0 nrm quad) (-> s4-0 pos quad)) + (+! (-> s4-0 nrm y) 1.0) + (vector-normalize! (-> s4-0 nrm) 1.0) + ) + ) + ) + #f + ) + +;; failed to figure out what this is: +(init-haze-vert-array) + +;; definition for method 9 of type sky-work +;; WARN: Return type mismatch int vs none. +(defmethod init-sun-data! ((this sky-work) (arg0 int) (arg1 float) (arg2 float) (arg3 float)) + (let ((v1-0 (logand arg0 1))) + (set! (-> this upload-data sun v1-0 r-sun) arg1) + (set! (-> this upload-data sun v1-0 r-halo) arg2) + (set! (-> this upload-data sun v1-0 r-aurora) arg3) + ) + 0 + (none) + ) + +;; definition for method 10 of type sky-work +;; WARN: Return type mismatch int vs none. +(defmethod init-orbit-settings! ((this sky-work) (arg0 int) (arg1 float) (arg2 float) (arg3 float) (arg4 float) (arg5 float) (arg6 float)) + (set! (-> this orbit arg0 high-noon) arg1) + (set! (-> this orbit arg0 tilt) (* 0.017453292 arg2)) + (set! (-> this orbit arg0 rise) (* 0.017453292 arg3)) + (set! (-> this orbit arg0 dist) arg4) + (set! (-> this orbit arg0 min-halo) arg5) + (set! (-> this orbit arg0 max-halo) arg6) + 0 + (none) + ) + +;; definition for function sky-make-sun-data +;; WARN: Return type mismatch int vs none. +(defun sky-make-sun-data ((arg0 sky-work) (arg1 int) (arg2 float)) + (let* ((s4-0 (-> arg0 orbit arg1)) + (s3-0 (the-as sky-sun-data (+ (the-as uint (-> arg0 upload-data)) (* arg1 64)))) + (f0-1 (- arg2 (-> s4-0 high-noon))) + (f30-0 (* 2730.6667 f0-1)) + (f28-0 (* (sin f30-0) (-> s4-0 dist))) + (f30-1 (cos f30-0)) + ) + (let* ((f24-0 (* f30-1 (-> s4-0 dist))) + (f26-0 (* f24-0 (cos-rad (-> s4-0 tilt)))) + (f24-1 (* f24-0 (sin-rad (-> s4-0 tilt)))) + (f22-0 (sin-rad (-> s4-0 rise))) + (f0-10 (cos-rad (-> s4-0 rise))) + ) + (set! (-> s3-0 pos z) (- (+ (* f28-0 f0-10) (* f24-1 f22-0)))) + (set! (-> s3-0 pos y) f26-0) + (set! (-> s3-0 pos x) (- (* f24-1 f0-10) (* f28-0 f22-0))) + ) + (let ((f0-14 (if (< f30-1 0.0) + 0.0 + f30-1 + ) + ) + ) + (set! (-> arg0 upload-data sun arg1 r-aurora) + (+ (* (-> s4-0 min-halo) (- 1.0 f0-14)) (* (-> s4-0 max-halo) f0-14)) + ) + ) + ) + 0 + (none) + ) + +;; definition for function sky-make-moon-data +;; WARN: Return type mismatch int vs none. +(defun sky-make-moon-data ((arg0 sky-work) (arg1 float)) + (let* ((s5-0 (-> arg0 orbit 2)) + (gp-0 (-> arg0 upload-data moon)) + (f0-1 (- arg1 (-> s5-0 high-noon))) + (f28-0 (* 2730.6667 f0-1)) + (f30-0 (* (sin f28-0) (-> s5-0 dist))) + (f26-0 (* (cos f28-0) (-> s5-0 dist))) + (f28-1 (* f26-0 (cos-rad (-> s5-0 tilt)))) + (f26-1 (* f26-0 (sin-rad (-> s5-0 tilt)))) + (f24-0 (sin-rad (-> s5-0 rise))) + (f0-10 (cos-rad (-> s5-0 rise))) + ) + (set! (-> gp-0 pos z) (- (+ (* f30-0 f0-10) (* f26-1 f24-0)))) + (set! (-> gp-0 pos y) f28-1) + (set! (-> gp-0 pos x) (- (* f26-1 f0-10) (* f30-0 f24-0))) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(init-sun-data! *sky-work* 0 60.0 200.0 300.0) + +;; failed to figure out what this is: +(init-sun-data! *sky-work* 1 15.0 20.0 300.0) + +;; failed to figure out what this is: +(init-orbit-settings! *sky-work* 0 12.5 -20.0 90.0 9950.0 300.0 300.0) + +;; failed to figure out what this is: +(init-orbit-settings! *sky-work* 1 4.0 0.0 90.0 9950.0 300.0 300.0) + +;; failed to figure out what this is: +(init-orbit-settings! *sky-work* 2 0.5 -40.0 90.0 9950.0 300.0 300.0) + +;; failed to figure out what this is: +(let ((v0-9 (-> *sky-work* upload-data day-star))) + (set! (-> v0-9 pos x) 0.0) + (set! (-> v0-9 pos y) 2000.0) + (set! (-> v0-9 pos z) -9000.0) + (set! (-> v0-9 pos w) 1.0) + ) diff --git a/test/decompiler/reference/jak3/engine/gfx/sky/sky-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/sky/sky-h_REF.gc index f797ae02d5..d14f93f1fe 100644 --- a/test/decompiler/reference/jak3/engine/gfx/sky/sky-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/sky/sky-h_REF.gc @@ -410,32 +410,32 @@ (init-orbit-settings! (_type_ int float float float float float float) none) (update-colors-for-time (_type_ float) none) (update-time-and-speed (_type_ float float) none) - (sky-work-method-13 () none) + (draw-erase (_type_ dma-buffer vector) none) (draw (_type_) none) - (sky-work-method-15 () none) - (sky-work-method-16 () none) - (sky-work-method-17 () none) - (sky-work-method-18 () none) - (sky-work-method-19 () none) - (sky-work-method-20 () none) - (sky-work-method-21 () none) - (sky-work-method-22 () none) - (sky-work-method-23 () none) - (sky-work-method-24 () none) - (sky-work-method-25 () none) - (sky-work-method-26 () none) - (sky-work-method-27 () none) - (sky-work-method-28 () none) - (sky-work-method-29 () none) - (sky-work-method-30 () none) - (sky-work-method-31 () none) - (sky-work-method-32 () none) - (sky-work-method-33 () none) - (sky-work-method-34 () none) - (sky-work-method-35 () none) - (sky-work-method-36 () none) - (sky-work-method-37 () none) - (sky-work-method-38 () none) + (update-camera-matrix (_type_ matrix) none) + (update-template-colors (_type_) none) + (init-regs-for-large-polygon-draw (_type_) none) + (init-regs-for-sky-asm (_type_) none) + (cloud-vtx-light-update (_type_ vector vector cloud-lights vector vector) none) + (cloud-vtx-tex-update (_type_ vector vector vector cloud-lights) none) + (adjust-cloud-lighting (_type_) none) + (cloud-vtx1-to-sky (_type_ sky-vertex cloud-vertex) none) + (cloud-vtx2-to-sky (_type_ sky-vertex cloud-vertex) none) + (draw-clouds (_type_ dma-buffer) none) + (apply-haze-light (_type_ vector vector haze-lights float) none) + (adjust-haze-lighting (_type_) none) + (haze-vtx-to-sky (_type_ sky-vertex sky-vertex haze-vertex) none) + (draw-haze (_type_ dma-buffer) none) + (sun-dma (_type_ dma-buffer) none) + (green-sun-dma (_type_ dma-buffer) none) + (moon-dma (_type_ dma-buffer) none) + (day-star-dma (_type_ dma-buffer) none) + (setup-stars (_type_ matrix sky-upload-data) none) + (stars-transform-asm (_type_) none) + (stars-dma (_type_ dma-buffer) none) + (draw-roof (_type_ dma-buffer) none) + (draw-base (_type_ dma-buffer) none) + (draw-fog (_type_ dma-buffer) none) ) ) diff --git a/test/decompiler/reference/jak3/engine/gfx/sky/sky-tng_REF.gc b/test/decompiler/reference/jak3/engine/gfx/sky/sky-tng_REF.gc new file mode 100644 index 0000000000..dc24194da7 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/sky/sky-tng_REF.gc @@ -0,0 +1,819 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function set-tex-offset +;; INFO: function output is handled by mips2c +(def-mips2c set-tex-offset (function int int none)) + +;; definition for function draw-large-polygon +;; INFO: function output is handled by mips2c +(def-mips2c draw-large-polygon function) + +;; definition for function clip-polygon-against-positive-hyperplane +;; INFO: function output is handled by mips2c +(def-mips2c clip-polygon-against-positive-hyperplane function) + +;; definition for function clip-polygon-against-negative-hyperplane +;; INFO: function output is handled by mips2c +(def-mips2c clip-polygon-against-negative-hyperplane function) + +;; definition for function render-sky-quad +;; INFO: function output is handled by mips2c +(def-mips2c render-sky-quad (function (inline-array sky-vertex) dma-buffer none)) + +;; definition for function render-sky-tri +;; INFO: function output is handled by mips2c +(def-mips2c render-sky-tri (function (inline-array sky-vertex) dma-buffer none)) + +;; definition for function close-sky-buffer +;; INFO: Used lq/sq +;; WARN: Return type mismatch pointer vs none. +;; ERROR: Function may read a register that is not set: ra +;; ERROR: Unsupported inline assembly instruction kind - [jr ra] +(defun close-sky-buffer ((arg0 dma-buffer)) + "Close DMA buffer for large polygon drawing." + (local-vars (ra-0 none)) + (nop!) + (let ((v1-0 #x8000) + (v0-0 (-> arg0 base)) + ) + (set! (-> (the-as (pointer int128) v0-0)) 0) + (nop!) + (set! (-> (the-as (pointer int32) v0-0)) v1-0) + (let ((v0-1 (&+ v0-0 16))) + (.jr ra-0) + (set! (-> arg0 base) v0-1) + ) + ) + (none) + ) + +;; definition for method 15 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod update-camera-matrix ((this sky-work) (arg0 matrix)) + "Set the camera matrix (no perspective) for sky drawing." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (let ((v1-0 (-> this cam-mat))) + (let* ((a0-1 v1-0) + (t0-0 arg0) + (a1-1 (-> t0-0 rvec quad)) + (a2-0 (-> t0-0 uvec quad)) + (a3-0 (-> t0-0 fvec quad)) + (t0-1 (-> t0-0 trans quad)) + ) + (set! (-> a0-1 rvec quad) a1-1) + (set! (-> a0-1 uvec quad) a2-0) + (set! (-> a0-1 fvec quad) a3-0) + (set! (-> a0-1 trans quad) t0-1) + ) + (.svf (&-> v1-0 trans quad) vf0) + (matrix*! v1-0 v1-0 (-> *math-camera* perspective)) + ) + 0 + (none) + ) + ) + +;; definition for method 16 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod update-template-colors ((this sky-work)) + "Update work with sky/erase colors from time-of-day/level." + (let ((v1-1 (-> *time-of-day-context* current-fog erase-color)) + (a0-2 (-> *level* level-default mood-context current-sky-color)) + ) + (dotimes (a1-1 12) + (set! (-> sky-base-polygons a1-1 col quad) (-> v1-1 quad)) + (set! (-> sky-roof-polygons a1-1 col quad) (-> a0-2 quad)) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type sky-work +;; WARN: Return type mismatch int vs none. +(defmethod update-time-and-speed ((this sky-work) (arg0 float) (arg1 float)) + "Update cloud sroll and sun/moon position for the time." + (if (and (level-get-target-inside *level*) (= (-> (level-get-target-inside *level*) info taskname) 'nest)) + (set! arg1 (* 10.0 arg1)) + ) + (sky-make-sun-data this 0 arg0) + (sky-make-sun-data this 1 arg0) + (sky-make-moon-data this arg0) + (+! (-> this off-s) (the int (* -8.0 arg1))) + (+! (-> this off-t) (the int (* 2.0 arg1))) + (set! (-> this time) arg0) + 0 + (none) + ) + +;; definition for method 17 of type sky-work +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 17 sky-work)" 17 sky-work) + +;; definition for method 18 of type sky-work +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 18 sky-work)" 18 sky-work) + +;; definition for method 11 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod update-colors-for-time ((this sky-work) (arg0 float)) + 0 + 0 + 0.0 + (let ((s5-0 *no-cloud-mood-color-table*)) + (let ((s3-0 (-> *level* level-default mood-context)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (let* ((v1-3 (the int arg0)) + (f0-4 (- arg0 (the float v1-3))) + (f1-3 (- 1.0 f0-4)) + (a0-4 (/ v1-3 24)) + (a1-2 (-> *mood-interp-table* hour (- v1-3 (* 24 a0-4)))) + (a0-7 (-> a1-2 snapshot1)) + (v1-7 (-> a1-2 snapshot2)) + (f0-6 (+ (* f1-3 (-> a1-2 morph-start)) (* f0-4 (-> a1-2 morph-end)))) + ) + (cond + ((= a0-7 v1-7) + (set! (-> this sun0-color quad) (-> s5-0 data a0-7 lgt-color quad)) + ) + (else + (let ((a1-5 (-> s5-0 data a0-7)) + (v1-11 (-> s5-0 data v1-7)) + ) + (vector4-lerp! (-> this sun0-color) (-> a1-5 lgt-color) (-> v1-11 lgt-color) f0-6) + ) + ) + ) + ) + (set! (-> this sun0-color-lower quad) (-> s3-0 times 1 quad)) + (set! (-> this ambi-color-lower quad) (-> s3-0 times 0 quad)) + (set-vector! s4-0 1.9921875 1.9921875 1.9921875 1.0) + (vector4-lerp! (-> this ambi-color) (-> this ambi-color-lower) s4-0 (-> *mood-control* lightning-flash)) + ) + (set! (-> this sun0-color quad) (-> this sun0-color quad)) + (set! (-> this sun1-color quad) (-> s5-0 data 7 lgt-color quad)) + (set! (-> this moon-color quad) (-> s5-0 data 6 lgt-color quad)) + ) + 0 + (none) + ) + +;; definition for method 19 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod cloud-vtx-light-update ((this sky-work) (arg0 vector) (arg1 vector) (arg2 cloud-lights) (arg3 vector) (arg4 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector4))) + (let* ((f0-1 (vector-dot (-> arg2 sun0-normal) arg1)) + (f1-1 (vector-dot (-> arg2 sun1-normal) arg1)) + (f2-1 (vector-dot (-> arg2 moon-normal) arg1)) + (f0-2 (fmax 0.0 f0-1)) + (f30-0 (fmax 0.0 f1-1)) + (f28-0 (fmax 0.0 f2-1)) + ) + (set! (-> s5-0 quad) (-> arg4 quad)) + (vector4-madd! s5-0 s5-0 (the-as vector4 arg3) f0-2) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun1-color)) f30-0) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 moon-color)) f28-0) + ) + (vector4-scale! s5-0 s5-0 128.0) + (set! (-> arg0 x) (fmax 0.0 (fmin 255.0 (-> s5-0 x)))) + (set! (-> arg0 y) (fmax 0.0 (fmin 255.0 (-> s5-0 y)))) + (set! (-> arg0 z) (fmax 0.0 (fmin 255.0 (-> s5-0 z)))) + ) + 0 + (none) + ) + +;; definition for method 20 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod cloud-vtx-tex-update ((this sky-work) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 cloud-lights)) + (let ((s5-0 (new 'stack-no-clear 'vector4)) + (s2-0 (new 'stack-no-clear 'vector4)) + (s4-0 (new 'stack-no-clear 'vector4)) + (f28-0 0.00390625) + (f30-0 0.015625) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (vector--float*! (the-as vector s5-0) arg2 (-> arg3 sun0-normal) 9.0) + (vector--float*! (the-as vector s2-0) arg2 (-> arg3 sun1-normal) 9.0) + (vector--float*! (the-as vector s4-0) arg2 (-> arg3 moon-normal) 9.0) + (vector4-scale! s5-0 s5-0 (* (-> arg3 sun0-scale) f28-0)) + (vector4-madd! s5-0 s5-0 s2-0 (* 0.25 f28-0 (-> arg3 sun1-scale))) + (vector4-madd! s5-0 s5-0 s4-0 (* (-> arg3 moon-scale) f28-0)) + (+! (-> arg0 x) (fmax (fmin (-> s5-0 x) f30-0) (- f30-0))) + (+! (-> arg0 y) (fmax (fmin (-> s5-0 z) f30-0) (- f30-0))) + ) + 0 + (none) + ) + +;; definition for method 21 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod adjust-cloud-lighting ((this sky-work)) + (let ((s5-0 *cloud-vert-array*) + (s4-0 (-> this cloud-lights)) + ) + (set! (-> s4-0 sun0-normal quad) (-> this upload-data data 0)) + (set! (-> s4-0 sun1-normal quad) (-> (&-> this upload-data data 4) 0)) + (set! (-> s4-0 moon-normal quad) (-> this upload-data moon pos quad)) + (vector-normalize! (-> s4-0 sun0-normal) 1.0) + (vector-normalize! (-> s4-0 sun1-normal) 1.0) + (vector-normalize! (-> s4-0 moon-normal) 1.0) + (set! (-> s4-0 sun0-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun0-normal y)))))) + (set! (-> s4-0 sun1-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun1-normal y)))))) + (set! (-> s4-0 moon-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 moon-normal y)))))) + (let ((s1-0 (-> s4-0 ambi-color)) + (s2-0 (-> s4-0 ambi-color-lower)) + (s3-0 (-> this sun0-color-lower)) + ) + (let ((f30-0 (- 1.0 (fmax 0.0 (fmin 0.75 (* 4.0 (-> s4-0 moon-normal y)))))) + (f28-0 (* 0.3333 (fmax 0.0 (fmin 1.0 (+ -1.0 (* 8.0 (-> s4-0 sun0-normal y))))))) + ) + (vector4-scale! (the-as vector4 s2-0) (the-as vector4 (-> this ambi-color-lower)) f30-0) + (vector4-madd! (the-as vector4 s2-0) (the-as vector4 s2-0) (the-as vector4 s3-0) f28-0) + (vector4-scale! (the-as vector4 s1-0) (the-as vector4 (-> this ambi-color)) f30-0) + (vector4-madd! (the-as vector4 s1-0) (the-as vector4 s1-0) (the-as vector4 s3-0) f28-0) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun0-color)) + (the-as vector4 (-> this sun0-color)) + (-> s4-0 sun0-scale) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun1-color)) + (the-as vector4 (-> this sun1-color)) + (* 0.5 (-> s4-0 sun1-scale)) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 moon-color)) + (the-as vector4 (-> this moon-color)) + (-> s4-0 moon-scale) + ) + (vector4-scale! (the-as vector4 (-> s4-0 sun0-color-lower)) (the-as vector4 s3-0) (-> s4-0 sun0-scale)) + ) + (dotimes (s3-1 100) + (let ((s2-1 (-> s5-0 data s3-1))) + (cloud-vtx-light-update this (-> s2-1 col) (-> s2-1 nrm) s4-0 (-> s4-0 sun0-color) (-> s4-0 ambi-color)) + (cloud-vtx-light-update + this + (-> s2-1 col2) + (-> s2-1 nrm2) + s4-0 + (-> s4-0 sun0-color-lower) + (-> s4-0 ambi-color-lower) + ) + (cloud-vtx-tex-update this (-> s2-1 stq2) (-> s2-1 stq) (-> s2-1 pos) s4-0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 22 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod cloud-vtx1-to-sky ((this sky-work) (arg0 sky-vertex) (arg1 cloud-vertex)) + (set! (-> arg0 pos quad) (-> arg1 pos quad)) + (set! (-> arg0 stq quad) (-> arg1 stq quad)) + (set! (-> arg0 col quad) (-> arg1 col quad)) + 0 + (none) + ) + +;; definition for method 23 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod cloud-vtx2-to-sky ((this sky-work) (arg0 sky-vertex) (arg1 cloud-vertex)) + (set! (-> arg0 pos quad) (-> arg1 pos quad)) + (set! (-> arg0 stq quad) (-> arg1 stq2 quad)) + (set! (-> arg0 col quad) (-> arg1 col2 quad)) + 0 + (none) + ) + +;; definition for method 24 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod draw-clouds ((this sky-work) (arg0 dma-buffer)) + (local-vars (v1-19 float) (sv-16 cloud-vert-array) (sv-20 (inline-array sky-vertex)) (sv-32 int)) + (rlet ((vf23 :class vf) + (vf27 :class vf) + ) + (dma-buffer-add-gs-set arg0 + (test-1 (new 'static 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x50 + :afail #x1 + :zte #x1 + :ztst (gs-ztest greater-equal) + ) + ) + (tex0-1 (new 'static 'gs-tex0 + :tbp0 #x100 + :tbw #x2 + :psm #x1b + :tcc #x1 + :cbp #x300 + :cld #x1 + :th (log2 128) + :tw (log2 128) + ) + ) + (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (clamp-1 (new 'static 'gs-clamp)) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + (texflush 0) + ) + (.lvf vf27 (&-> this giftag-roof quad)) + (let ((v1-18 #x43c80000)) + (.mov vf23 v1-18) + ) + (.mov v1-19 vf23) + (set-tex-offset (the-as int (-> this off-s)) (the-as int (-> this off-t))) + (let ((s4-1 (-> arg0 base))) + (&+! (-> arg0 base) 16) + (set! sv-16 *cloud-vert-array*) + (set! sv-20 *cloud-poly*) + (dotimes (s3-1 9) + (dotimes (s2-2 9) + (let ((s1-0 (+ (* 10 s3-1) s2-2))) + (set! sv-32 (+ (* 9 s3-1) s2-2)) + (let ((s0-0 (+ s2-2 81 (* 9 s3-1)))) + (cloud-vtx1-to-sky this (-> sv-20 (* sv-32 4)) (-> sv-16 data s1-0)) + (cloud-vtx1-to-sky this (-> sv-20 (+ (* sv-32 4) 1)) (-> sv-16 data (+ s1-0 1))) + (cloud-vtx1-to-sky this (-> sv-20 (+ (* sv-32 4) 2)) (-> sv-16 data (+ s1-0 11))) + (cloud-vtx1-to-sky this (-> sv-20 (+ (* sv-32 4) 3)) (-> sv-16 data (+ s1-0 10))) + (cloud-vtx2-to-sky this (-> sv-20 (* s0-0 4)) (-> sv-16 data s1-0)) + (cloud-vtx2-to-sky this (-> sv-20 (+ (* s0-0 4) 1)) (-> sv-16 data (+ s1-0 1))) + (cloud-vtx2-to-sky this (-> sv-20 (+ (* s0-0 4) 2)) (-> sv-16 data (+ s1-0 11))) + (cloud-vtx2-to-sky this (-> sv-20 (+ (* s0-0 4) 3)) (-> sv-16 data (+ s1-0 10))) + ) + ) + ) + ) + (dotimes (s5-1 162) + (render-sky-quad (the-as (inline-array sky-vertex) (-> sv-20 (* s5-1 4))) arg0) + ) + (close-sky-buffer arg0) + (let ((v1-81 (/ (the-as int (+ (- -16 (the-as int s4-1)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as (pointer uint64) s4-1)) (logior #x10000000 (shr (shl v1-81 48) 48))) + (set! (-> (the-as (pointer int32) s4-1) 2) 0) + (set! (-> (the-as (pointer int32) s4-1) 3) (the-as int (logior #x50000000 (shr (shl v1-81 48) 48)))) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 25 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod apply-haze-light ((this sky-work) (arg0 vector) (arg1 vector) (arg2 haze-lights) (arg3 float)) + (let* ((s5-0 (new 'stack-no-clear 'vector4)) + (f0-1 (vector-dot (-> arg2 sun0-normal) arg1)) + (f1-1 (vector-dot (-> arg2 sun1-normal) arg1)) + (f2-1 (vector-dot (-> arg2 moon-normal) arg1)) + (s3-0 (* arg3 (fmax 0.0 (fmin 1.0 (- 1.0 f0-1))))) + ) + (let ((f0-2 (fmax 0.0 f0-1)) + (f30-0 (fmax 0.0 f1-1)) + (f28-0 (fmax 0.0 f2-1)) + ) + (set! (-> s5-0 quad) (-> arg2 ambi-color quad)) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun0-color)) f0-2) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun1-color)) f30-0) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 moon-color)) f28-0) + ) + (vector4-scale! s5-0 s5-0 128.0) + (set! (-> arg0 x) (fmax (fmin 255.0 (-> s5-0 x)) s3-0)) + (set! (-> arg0 y) (fmax (fmin 255.0 (-> s5-0 y)) s3-0)) + (set! (-> arg0 z) (fmax (fmin 255.0 (-> s5-0 z)) s3-0)) + ) + 0 + (none) + ) + +;; definition for method 26 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod adjust-haze-lighting ((this sky-work)) + (let ((s5-0 *haze-vert-array*) + (s4-0 (-> this haze-lights)) + ) + (set! (-> s4-0 sun0-normal quad) (-> this upload-data data 0)) + (set! (-> s4-0 sun1-normal quad) (-> (&-> this upload-data data 4) 0)) + (set! (-> s4-0 moon-normal quad) (-> this upload-data moon pos quad)) + (vector-normalize! (-> s4-0 sun0-normal) 1.0) + (vector-normalize! (-> s4-0 sun1-normal) 1.0) + (vector-normalize! (-> s4-0 moon-normal) 1.0) + (set! (-> s4-0 sun0-scale) (fmax 0.0 (fmin 1.0 (* 4.0 (+ 0.25 (-> s4-0 sun0-normal y)))))) + (set! (-> s4-0 sun1-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun1-normal y)))))) + (set! (-> s4-0 moon-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 moon-normal y)))))) + (let ((s3-0 (-> s4-0 ambi-color))) + (-> this sun0-color-lower) + (let ((f30-0 (- 1.0 (fmax 0.0 (fmin 0.75 (* 4.0 (-> s4-0 moon-normal y)))))) + (f0-8 (fmax 0.0 (fmin 1.0 (* 5.0 (+ 0.125 (-> s4-0 sun0-normal y)))))) + (s2-0 (new 'stack-no-clear 'vector4)) + ) + (set-vector! s2-0 1.15 0.0 0.5 1.0) + (vector4-lerp! (the-as vector s2-0) (the-as vector s2-0) (-> this sun0-color) f0-8) + (vector4-scale! (the-as vector4 s3-0) (the-as vector4 (-> this ambi-color)) f30-0) + (vector4-scale! (the-as vector4 (-> s4-0 sun0-color)) s2-0 (-> s4-0 sun0-scale)) + ) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun1-color)) + (the-as vector4 (-> this sun1-color)) + (* 0.5 (-> s4-0 sun1-scale)) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 moon-color)) + (the-as vector4 (-> this moon-color)) + (-> s4-0 moon-scale) + ) + (let ((f30-1 (* 144.0 (fmax 0.0 (fmin 1.0 (* 16.0 (-> s4-0 sun0-normal y))))))) + (dotimes (s3-1 36) + (let ((v1-28 (-> s5-0 data s3-1))) + (apply-haze-light this (-> v1-28 col) (-> v1-28 nrm) s4-0 f30-1) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 27 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod haze-vtx-to-sky ((this sky-work) (arg0 sky-vertex) (arg1 sky-vertex) (arg2 haze-vertex)) + (set! (-> arg0 pos quad) (-> arg2 pos quad)) + (set! (-> arg0 col quad) (-> arg2 col quad)) + (set! (-> arg0 col w) 128.0) + (set! (-> arg1 pos quad) (-> arg2 pos quad)) + (set! (-> arg1 col quad) (-> arg2 col quad)) + (set! (-> arg1 pos y) 3.0) + (set! (-> arg1 col w) 0.0) + 0 + (none) + ) + +;; definition for method 28 of type sky-work +;; WARN: Return type mismatch int vs none. +(defmethod draw-haze ((this sky-work) (arg0 dma-buffer)) + (local-vars (sv-16 haze-vert-array) (sv-20 (inline-array sky-vertex))) + (rlet ((vf27 :class vf)) + (dma-buffer-add-gs-set arg0 (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))) + (init-regs-for-large-polygon-draw this) + (.lvf vf27 (&-> this giftag-haze quad)) + (let ((s4-0 (-> arg0 base))) + (&+! (-> arg0 base) 16) + (set! sv-16 *haze-vert-array*) + (set! sv-20 *haze-poly*) + (dotimes (s3-0 35) + (haze-vtx-to-sky this (-> sv-20 (* s3-0 4)) (-> sv-20 (+ (* s3-0 4) 1)) (-> sv-16 data s3-0)) + (haze-vtx-to-sky this (-> sv-20 (+ (* s3-0 4) 3)) (-> sv-20 (+ (* s3-0 4) 2)) (-> sv-16 data (+ s3-0 1))) + ) + (haze-vtx-to-sky this (-> sv-20 140) (-> sv-20 141) (-> sv-16 data 35)) + (haze-vtx-to-sky this (-> sv-20 143) (-> sv-20 142) (the-as haze-vertex (-> sv-16 data))) + (dotimes (s5-1 36) + (render-sky-quad (the-as (inline-array sky-vertex) (-> sv-20 (* s5-1 4))) arg0) + ) + (close-sky-buffer arg0) + (let ((v1-41 (/ (the-as int (+ (- -16 (the-as int s4-0)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as (pointer uint64) s4-0)) (logior #x10000000 (shr (shl v1-41 48) 48))) + (set! (-> (the-as (pointer int32) s4-0) 2) 0) + (set! (-> (the-as (pointer int32) s4-0) 3) (the-as int (logior #x50000000 (shr (shl v1-41 48) 48)))) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 29 of type sky-work +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 29 sky-work)" 29 sky-work) + +;; definition for method 30 of type sky-work +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 30 sky-work)" 30 sky-work) + +;; definition for method 31 of type sky-work +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 31 sky-work)" 31 sky-work) + +;; definition for method 33 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod setup-stars ((this sky-work) (arg0 matrix) (arg1 sky-upload-data)) + (set! (-> arg0 fvec quad) (-> arg1 data 0)) + (vector-normalize! (-> arg0 fvec) 1.0) + (vector-cross! (-> arg0 rvec) *z-vector* (-> arg0 fvec)) + (vector-normalize! (-> arg0 rvec) 1.0) + (vector-cross! (-> arg0 uvec) (-> arg0 fvec) (-> arg0 rvec)) + (vector-normalize! (-> arg0 uvec) 1.0) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> s4-1 quad) (-> arg1 data 0)) + (vector-normalize! s4-1 -1.0) + (let ((f0-1 (fmax 0.0 (fmin 1.0 (* 20.0 (+ 0.05 (-> s4-1 y))))))) + (if (= (-> *setting-control* user-current sky-type) 'star-field) + (set! f0-1 1.0) + ) + (dotimes (v1-11 16) + (let ((f1-4 (* (- 128.0 (* 8.0 (the float v1-11))) f0-1))) + (set-vector! (-> this star-colors v1-11) (the int f1-4) (the int f1-4) (the int f1-4) 128) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 34 of type sky-work +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 34 sky-work)" 34 sky-work) + +;; definition for method 35 of type sky-work +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 35 sky-work)" 35 sky-work) + +;; definition for method 36 of type sky-work +;; WARN: Return type mismatch int vs none. +(defmethod draw-roof ((this sky-work) (arg0 dma-buffer)) + (rlet ((vf27 :class vf)) + (dma-buffer-add-gs-set arg0 + (zbuf-1 (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + ) + (init-regs-for-large-polygon-draw this) + (.lvf vf27 (&-> this giftag-base quad)) + (let ((s5-1 (-> arg0 base))) + (&+! (-> arg0 base) 16) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 0)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 3)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 6)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 9)) arg0) + (close-sky-buffer arg0) + (let ((v1-14 (/ (the-as int (+ (- -16 (the-as int s5-1)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as (pointer uint64) s5-1)) (logior #x10000000 (shr (shl v1-14 48) 48))) + (set! (-> (the-as (pointer int32) s5-1) 2) 0) + (set! (-> (the-as (pointer int32) s5-1) 3) (the-as int (logior #x50000000 (shr (shl v1-14 48) 48)))) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 37 of type sky-work +;; WARN: Return type mismatch int vs none. +(defmethod draw-base ((this sky-work) (arg0 dma-buffer)) + (rlet ((vf27 :class vf)) + (dma-buffer-add-gs-set arg0 + (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) + ) + (let ((s5-0 (-> arg0 base))) + (&+! (-> arg0 base) 16) + (.lvf vf27 (&-> this giftag-base quad)) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 0)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 3)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 6)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 9)) arg0) + (close-sky-buffer arg0) + (let ((v1-12 (/ (the-as int (+ (- -16 (the-as int s5-0)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as (pointer uint64) s5-0)) (logior #x10000000 (shr (shl v1-12 48) 48))) + (set! (-> (the-as (pointer int32) s5-0) 2) 0) + (set! (-> (the-as (pointer int32) s5-0) 3) (the-as int (logior #x50000000 (shr (shl v1-12 48) 48)))) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 38 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod draw-fog ((this sky-work) (arg0 dma-buffer)) + (let ((s4-0 (-> *sky-texture-anim-array* array-data 8 tex))) + (if s4-0 + (dma-buffer-add-gs-set arg0 + (tex0-1 (new 'static 'gs-tex0 + :tcc #x1 + :cld #x1 + :psm (the-as int (-> s4-0 psm)) + :cpsm (-> s4-0 clutpsm) + :cbp (-> s4-0 clutdest) + :th (log2 (-> s4-0 h)) + :tw (log2 (-> s4-0 w)) + :tbw (-> s4-0 width 0) + :tbp0 (-> s4-0 dest 0) + ) + ) + (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (test-1 (new 'static 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x70 + :afail #x3 + :zte #x1 + :ztst (gs-ztest greater-equal) + ) + ) + (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + ) + ) + ) + (let* ((v1-26 (the-as (inline-array qword) (-> arg0 base))) + (a0-22 *fog-texture-work*) + (f0-0 (-> a0-22 min-corner y)) + (f4-0 (- (-> a0-22 max-corner y) f0-0)) + (f3-0 (/ (- (-> a0-22 corner 1 y) f0-0) f4-0)) + (f2-0 (/ (- (-> a0-22 corner 0 y) f0-0) f4-0)) + (f1-7 (/ (- (-> a0-22 corner 3 y) f0-0) f4-0)) + (f0-2 (/ (- (-> a0-22 corner 2 y) f0-0) f4-0)) + (a0-23 6400) + ) + (set! (-> v1-26 0 quad) (-> this fog-tmpl dma-vif quad)) + (set! (-> v1-26 1 quad) (-> this fog-tmpl quad 1)) + (set-vector! (-> v1-26 2 vector4w) 128 128 128 128) + (set-vector! (-> v1-26 3 vector4w) (the-as int f3-0) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (set-vector! (-> v1-26 4 vector4w) #x7000 #x7300 a0-23 0) + (set-vector! (-> v1-26 5 vector4w) (the-as int f2-0) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (set-vector! (-> v1-26 6 vector4w) #x9000 #x7300 a0-23 0) + (set-vector! (-> v1-26 7 vector4w) (the-as int f1-7) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (set-vector! (-> v1-26 8 vector4w) #x7000 #x8d00 a0-23 0) + (set-vector! (-> v1-26 9 vector4w) (the-as int f0-2) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (let ((v1-27 (the-as (inline-array qword) (-> v1-26 10)))) + (set! (-> v1-27 0 vector4w x) #x9000) + (set! (-> v1-27 0 vector4w y) #x8d00) + (set! (-> v1-27 0 vector4w z) a0-23) + (set! (-> v1-27 0 vector4w w) 0) + ) + ) + (&+! (-> arg0 base) 176) + 0 + (none) + ) + +;; definition for method 32 of type sky-work +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 32 sky-work)" 32 sky-work) + +;; definition for method 13 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod draw-erase ((this sky-work) (arg0 dma-buffer) (arg1 vector)) + (dma-buffer-add-gs-set arg0 + (zbuf-1 (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) + (rgbaq (new 'static 'gs-rgbaq + :q 1.0 + :a (the int (-> arg1 w)) + :b (the int (-> arg1 z)) + :g (the int (-> arg1 y)) + :r (the int (-> arg1 x)) + ) + ) + ) + (let ((v1-3 (-> arg0 base))) + (set! (-> (the-as (pointer uint128) v1-3)) (-> this sprite-tmpl dma-vif quad)) + (set! (-> (the-as (pointer uint128) v1-3) 1) (-> this sprite-tmpl quad 1)) + ) + (&+! (-> arg0 base) 32) + (let ((v1-6 (-> arg0 base))) + (set-vector! (the-as vector4w (&+ v1-6 0)) #x7000 #x7300 0 0) + (set-vector! (the-as vector4w (&+ v1-6 16)) #x9000 #x8d00 0 0) + ) + (&+! (-> arg0 base) 32) + 0 + (none) + ) + +;; definition for method 14 of type sky-work +;; WARN: Return type mismatch int vs none. +(defmethod draw ((this sky-work)) + (let ((s4-0 *time-of-day-context*) + (v1-0 #f) + ) + (dotimes (a0-1 (-> *level* length)) + (let ((a1-3 (-> *level* level a0-1))) + (when (= (-> a1-3 status) 'active) + (if (and (= (-> a1-3 display?) 'display) (logtest? (-> a1-3 info level-flags) (level-flags lf9))) + (set! v1-0 #t) + ) + ) + ) + ) + (cond + ((and v1-0 + (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask sky)) + (logtest? (-> *texture-pool* texture-enable-user) (texture-enable-mask sky)) + ) + (let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf base))) + (let ((a1-9 (if (-> s4-0 use-camera-other) + (-> *math-camera* camera-rot-other) + (-> *math-camera* camera-rot) + ) + ) + ) + (update-camera-matrix this a1-9) + ) + (update-template-colors this) + (adjust-haze-lighting this) + (adjust-cloud-lighting this) + (let ((s4-1 (the-as sky-work #x70000000))) + (mem-copy! (the-as pointer s4-1) (the-as pointer this) #x2814) + (setup-stars s4-1 (-> s4-1 star-mat) (-> this upload-data)) + (if (nonzero? (-> s4-1 star-colors 0 x)) + (stars-transform-asm s4-1) + ) + (cond + ((= (-> *setting-control* user-current sky-type) 'star-field) + (with-dma-buffer-add-bucket ((s3-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id sky) + ) + (draw-erase s4-1 s3-0 (new 'static 'vector :w 128.0)) + (init-regs-for-sky-asm s4-1) + (stars-dma s4-1 s3-0) + (sun-dma s4-1 s3-0) + (green-sun-dma s4-1 s3-0) + (moon-dma s4-1 s3-0) + ) + ) + (else + (with-dma-buffer-add-bucket ((s2-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id sky) + ) + (draw-roof s4-1 s2-0) + (init-regs-for-sky-asm s4-1) + (if (nonzero? (-> s4-1 star-colors 0 x)) + (stars-dma s4-1 s2-0) + ) + (sun-dma s4-1 s2-0) + (green-sun-dma s4-1 s2-0) + (moon-dma s4-1 s2-0) + (cond + ((or (task-node-closed? (game-task-node precursor-destroy-ship-resolution)) (-> this disable-day-star)) + (set! (-> *time-of-day* 0 day-star-enable) #f) + ) + (else + (set! (-> *time-of-day* 0 day-star-enable) #t) + (day-star-dma s4-1 s2-0) + ) + ) + (draw-haze s4-1 s2-0) + (draw-clouds s4-1 s2-0) + (draw-base s4-1 s2-0) + (draw-fog s4-1 s2-0) + ) + ) + ) + ) + (let ((a0-45 *dma-mem-usage*)) + (when (nonzero? a0-45) + (set! (-> a0-45 length) (max 90 (-> a0-45 length))) + (set! (-> a0-45 data 89 name) "sky") + (+! (-> a0-45 data 89 count) 1) + (+! (-> a0-45 data 89 used) + (&- (-> *display* frames (-> *display* on-screen) global-buf base) (the-as uint gp-0)) + ) + (set! (-> a0-45 data 89 total) (-> a0-45 data 89 used)) + ) + ) + ) + ) + ((get-menu-mode *blit-displays-work*) + (with-dma-buffer-add-bucket ((s5-2 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id sky) + ) + (blit-displays-work-method-20 *blit-displays-work*) + ) + ) + (else + (with-dma-buffer-add-bucket ((s3-2 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id sky) + ) + (draw-erase this s3-2 (-> s4-0 current-fog erase-color)) + ) + ) + ) + ) + 0 + (none) + ) diff --git a/test/offline/config/jak3/config.jsonc b/test/offline/config/jak3/config.jsonc index 547a99f149..792d6894d4 100644 --- a/test/offline/config/jak3/config.jsonc +++ b/test/offline/config/jak3/config.jsonc @@ -373,7 +373,9 @@ "grunt-part-callback", // cty-blow-tower "(method 47 bt-hellcat)", - "(method 19 bt-gun-manager)" + "(method 19 bt-gun-manager)", + // asm + "close-sky-buffer" ], "skip_compile_states": {