[decomp] finish up debug.gc, get boundary rendering working (#1944)

![image](https://user-images.githubusercontent.com/48171810/194726152-74167185-0297-4982-8ed9-42936ad80fe7.png)
This commit is contained in:
water111
2022-10-08 17:02:40 -04:00
committed by GitHub
parent 3d4dfb2077
commit 405a144815
22 changed files with 1479 additions and 302 deletions
+5
View File
@@ -28,9 +28,14 @@
#define ASSERT(EX) \
(void)((EX) || (private_assert_failed(#EX, __FILE__, __LINE__, __PRETTY_FUNCTION__), 0))
#define ASSERT_NOT_REACHED() \
(void)((private_assert_failed("not reached", __FILE__, __LINE__, __PRETTY_FUNCTION__), 0))
#define ASSERT_MSG(EXPR, STR) \
(void)((EXPR) || (private_assert_failed(#EXPR, __FILE__, __LINE__, __PRETTY_FUNCTION__, STR), 0))
#define ASSERT_NOT_REACHED_MSG(STR) \
(void)((private_assert_failed("not reached", __FILE__, __LINE__, __PRETTY_FUNCTION__, STR), 0))
#else
#define ASSERT(EX) ((void)0)
+12 -8
View File
@@ -556,12 +556,13 @@ Mips2C_Line handle_lwc1(const Instruction& i0,
Mips2C_Line handle_lw(Mips2C_Output& out,
const Instruction& i0,
const std::string& instr_str,
const LinkedObjectFile* file) {
const LinkedObjectFile* file,
GameVersion version) {
if (i0.get_src(1).is_reg(rs7()) && i0.get_src(0).is_sym()) {
// symbol load.
out.require_symbol(i0.get_src(0).get_sym());
return {fmt::format("c->load_symbol({}, cache.{});", reg_to_name(i0.get_dst(0)),
goal_to_c_name(i0.get_src(0).get_sym())),
return {fmt::format("c->load_symbol{}({}, cache.{});", version == GameVersion::Jak1 ? "" : "2",
reg_to_name(i0.get_dst(0)), goal_to_c_name(i0.get_src(0).get_sym())),
instr_str};
}
if (i0.get_src(1).is_reg(rfp()) && i0.get_src(0).is_label()) {
@@ -888,11 +889,14 @@ Mips2C_Line handle_vopmsub(const Instruction& i0, const std::string& instr_strin
instr_string};
}
Mips2C_Line handle_lui(const Instruction& i0, const std::string& instr_string, Mips2C_Output& op) {
Mips2C_Line handle_lui(const Instruction& i0,
const std::string& instr_string,
Mips2C_Output& op,
GameVersion version) {
if (i0.get_src(0).get_imm() == 0x7000) {
op.require_symbol("*fake-scratchpad-data*");
return {fmt::format("get_fake_spad_addr({}, cache.fake_scratchpad_data, 0, c);",
reg_to_name(i0.get_dst(0))),
return {fmt::format("get_fake_spad_addr{}({}, cache.fake_scratchpad_data, 0, c);",
version == GameVersion::Jak1 ? "" : "2", reg_to_name(i0.get_dst(0))),
instr_string};
} else {
return {fmt::format("c->lui({}, {});", reg_to_name(i0.get_dst(0)), i0.get_src(0).get_imm()),
@@ -946,7 +950,7 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output,
case InstructionKind::CFC2:
return handle_cfc2(i0, instr_str);
case InstructionKind::LW:
return handle_lw(output, i0, instr_str, file);
return handle_lw(output, i0, instr_str, file, version);
case InstructionKind::LB:
case InstructionKind::LWL:
case InstructionKind::LWR:
@@ -1148,7 +1152,7 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output,
case InstructionKind::PROT3W:
return handle_generic_op2(i0, instr_str, "prot3w");
case InstructionKind::LUI:
return handle_lui(i0, instr_str, output);
return handle_lui(i0, instr_str, output, version);
case InstructionKind::CLTS:
output.needs_cop1_bc = true;
return handle_clts(i0, instr_str);
+9 -9
View File
@@ -22476,7 +22476,7 @@
(define-extern ray-sphere-intersect (function vector vector vector float float))
(define-extern ray-circle-intersect (function vector vector vector float float)) ;;
(define-extern ray-cylinder-intersect (function vector vector vector vector float float vector float))
(define-extern ray-plane-intersect (function vector vector vector vector vector vector vector float)) ;;
(define-extern ray-plane-intersect (function vector vector vector vector vector vector vector float)) ;;
;; (define-extern ray-triangle-intersect function) ;; (function vector vector float matrix vector vector float)
;; (define-extern collide-do-primitives function) ;; (function float)
(define-extern moving-sphere-triangle-intersect (function vector vector float collide-cache-tri vector vector float)) ;;
@@ -23002,14 +23002,14 @@
(define-extern dma-timeout-cam (function vector))
(define-extern display-file-info (function int))
(define-extern add-debug-cursor (function symbol bucket-id int int int none))
(define-extern *boundary-polygon* none) ;; (inline-array lbvtx) ;; TODO: figure out what this actually is
(define-extern *boundary-polygon* (inline-array sky-vertex))
(define-extern init-boundary-regs (function none))
(define-extern add-boundary-shader (function texture-id dma-buffer none))
;; (define-extern draw-boundary-polygon function) ;; function
;; (define-extern render-boundary-quad function) ;; (function lbvtx dma-buffer none)
;; (define-extern render-boundary-tri function) ;; (function lbvtx dma-buffer none)
;; (define-extern add-debug-bound-internal function)
(define-extern add-debug-bound (function int transform int rgba rgba int none))
(define-extern render-boundary-tri (function sky-vertex dma-buffer none))
(define-extern add-debug-bound-internal (function dma-buffer (inline-array vector) int rgba rgba int none))
(define-extern add-debug-bound (function bucket-id (inline-array vector) int rgba rgba int none))
(define-extern cpu-delay (function int none))
(define-extern qword-read-time (function (array uint128) int int))
(define-extern bugfix? (function symbol))
@@ -25618,7 +25618,7 @@
;; (define-extern clip-polygon-against-negative-hyperplane function) ;; function
;; (define-extern render-sky-quad function) ;; (function int dma-buffer none)
;; (define-extern render-sky-tri function) ;; (function (inline-array sky-vertex) dma-buffer none)
;; (define-extern close-sky-buffer function) ;; (function dma-buffer none)
(define-extern close-sky-buffer (function dma-buffer none))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; load-state ;;
@@ -27024,8 +27024,8 @@
;; (define-extern transform-and-sleep function)
;; (define-extern transform-and-sleep-code function)
(define-extern transform-post (function int :behavior process-drawable)) ;;
(define-extern rider-trans (function none :behavior process-drawable)) ;;
(define-extern rider-post (function none :behavior process-drawable)) ;;
(define-extern rider-trans (function none :behavior process-drawable)) ;;
(define-extern rider-post (function none :behavior process-drawable)) ;;
;; (define-extern pusher-post function) ;; (function int :behavior process-drawable)
;; (define-extern process-drawable-delay-player function) ;; (function time-frame int :behavior process-drawable)
;; (define-extern process-drawable-fuel-cell-handler function) ;; (function process int symbol event-message-block none :behavior process-drawable)
@@ -33218,7 +33218,7 @@
)
)
(define-extern simple-focus-init-by-other
(define-extern simple-focus-init-by-other
"Initializes the new [[simple-focus]]. `first-time?` will be set to [[#t]]"
(function none :behavior simple-focus))
+6 -1
View File
@@ -358,7 +358,12 @@
"draw-string",
"get-string-length",
"adgif-shader<-texture-with-update!",
"init-boundary-regs"
"init-boundary-regs",
"draw-boundary-polygon",
"render-boundary-quad",
"render-boundary-tri",
"clip-polygon-against-negative-hyperplane",
"clip-polygon-against-positive-hyperplane"
],
"mips2c_jump_table_functions": {},
+3 -1
View File
@@ -73,7 +73,9 @@
["L256", "vector"],
["L257", "vector"],
["L258", "vector"],
["L259", "vector"]
["L259", "vector"],
["L231", "matrix"],
["L232", "matrix"]
],
"mood-funcs": [
["L231", "vector"],
+14
View File
@@ -2925,5 +2925,19 @@
[129, "a1", "region-prim-area"],
[103, "v1", "region-prim-area"],
[[19, 29], "v1", "region-prim-area"]
],
"add-debug-bound": [
[[33, 41], "a0", "dma-packet"],
[[42, 50], "a0", "gs-gif-tag"],
[53, "a0", "(pointer gs-zbuf)"],
[55, "a0", "(pointer gs-reg64)"],
[57, "a0", "(pointer gs-test)"],
[59, "a0", "(pointer gs-reg64)"],
[61, "a0", "(pointer gs-alpha)"],
[63, "a0", "(pointer gs-reg64)"],
[[107, 114], "v1", "dma-packet"],
[105, "v1", "dma-packet"],
[99, "a0", "dma-packet"],
[97, "a1", "dma-packet"]
]
}
+6
View File
@@ -1967,5 +1967,11 @@
},
"(method 18 drawable-region-volume)": {
"args": ["obj", "area"]
},
"add-debug-bound-internal": {
"args": ["buf", "pts", "num-pts", "color0", "color1", "flip-tex"]
},
"add-debug-bound": {
"args": ["buf", "pts", "c0", "c1", "flash"]
}
}
+1
View File
@@ -86,6 +86,7 @@ set(RUNTIME_SOURCE
mips2c/jak2_functions/debug.cpp
mips2c/jak2_functions/font.cpp
mips2c/jak2_functions/joint.cpp
mips2c/jak2_functions/sky.cpp
mips2c/jak2_functions/texture.cpp
overlord/dma.cpp
overlord/fake_iso.cpp
+457
View File
@@ -3,6 +3,8 @@
// clang-format off
#include "game/mips2c/mips2c_private.h"
#include "game/kernel/jak2/kscheme.h"
#include "game/mips2c/jak2_functions/sky.h"
using ::jak2::intern_from_c;
namespace Mips2C::jak2 {
namespace debug_line_clip {
@@ -133,3 +135,458 @@ void link() {
} // namespace debug_line_clip
} // namespace Mips2C
//--------------------------MIPS2C---------------------
// clang-format off
using ::jak2::intern_from_c;
namespace Mips2C::jak2 {
namespace init_boundary_regs {
struct Cache {
void* math_camera; // *math-camera*
void* sky_work; // *sky-work*
} cache;
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
c->load_symbol2(v1, cache.math_camera); // lw v1, *math-camera*(s7)
c->load_symbol2(a0, cache.sky_work); // lw a0, *sky-work*(s7)
c->daddiu(a0, a0, 1008); // daddiu a0, a0, 1008
c->lwc1(f0, 908, v1); // lwc1 f0, 908(v1)
c->swc1(f0, 0, a0); // swc1 f0, 0(a0)
c->lwc1(f0, 128, v1); // lwc1 f0, 128(v1)
c->swc1(f0, 4, a0); // swc1 f0, 4(a0)
c->lwc1(f0, 124, v1); // lwc1 f0, 124(v1)
c->swc1(f0, 8, a0); // swc1 f0, 8(a0)
c->lui(a1, 17727); // lui a1, 17727
c->ori(a1, a1, 61440); // ori a1, a1, 61440
c->mtc1(f0, a1); // mtc1 f0, a1
c->swc1(f0, 12, a0); // swc1 f0, 12(a0)
c->lqc2(vf31, 572, v1); // lqc2 vf31, 572(v1)
c->lqc2(vf30, 588, v1); // lqc2 vf30, 588(v1)
c->lqc2(vf29, 604, v1); // lqc2 vf29, 604(v1)
c->lqc2(vf28, 620, v1); // lqc2 vf28, 620(v1)
c->lqc2(vf14, 780, v1); // lqc2 vf14, 780(v1)
c->lqc2(vf26, 796, v1); // lqc2 vf26, 796(v1)
c->lqc2(vf25, 812, v1); // lqc2 vf25, 812(v1)
c->load_symbol2(v1, cache.sky_work); // lw v1, *sky-work*(s7)
c->lqc2(vf13, 1008, v1); // lqc2 vf13, 1008(v1)
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::xyzw, vf24, vf0); // vmove.xyzw vf24, vf0
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->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:
sky_regs_vfs.copy_vfs_from_other(c);
return c->gprs[v0].du64[0];
}
void link() {
cache.math_camera = intern_from_c("*math-camera*").c();
cache.sky_work = intern_from_c("*sky-work*").c();
gLinkedFunctionTable.reg("init-boundary-regs", execute, 128);
}
} // namespace init_boundary_regs
} // namespace Mips2C
//--------------------------MIPS2C---------------------
// clang-format off
using ::jak2::intern_from_c;
namespace Mips2C::jak2 {
namespace draw_boundary_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;
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, L32
// 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, L32
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, L32
// 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, L32
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->vmax_bc(DEST::z, BC::z, vf1, vf1, vf0); // vmaxz.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->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, L31
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("clip-polygon-against-negative-hyperplane").c();
cache.clip_polygon_against_positive_hyperplane = intern_from_c("clip-polygon-against-positive-hyperplane").c();
gLinkedFunctionTable.reg("draw-boundary-polygon", execute, 1024);
}
} // namespace draw_boundary_polygon
} // namespace Mips2C
//--------------------------MIPS2C---------------------
// clang-format off
#include "game/mips2c/mips2c_private.h"
#include "game/kernel/jak2/kscheme.h"
using ::jak2::intern_from_c;
namespace Mips2C::jak2 {
namespace render_boundary_quad {
struct Cache {
void* fake_scratchpad_data; // *fake-scratchpad-data*
void* math_camera; // *math-camera*
void* draw_boundary_polygon; // draw-boundary-polygon
} cache;
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
c->copy_vfs_from_other(&sky_regs_vfs);
bool bc = false;
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::xyzw, BC::w, vf1, vf28, vf1); // vmaddw.xyzw vf1, vf28, vf1
c->lqc2(vf7, 96, a0); // lqc2 vf7, 96(a0)
// nop // sll r0, r0, 0
c->lqc2(vf8, 112, a0); // lqc2 vf8, 112(a0)
c->vmula_bc(DEST::xyzw, BC::x, vf31, vf4); // vmulax.xyzw acc, vf31, vf4
// nop // sll r0, r0, 0
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::xyzw, BC::w, vf4, vf28, vf4); // vmaddw.xyzw vf4, vf28, vf4
// nop // sll r0, r0, 0
// nop // sll r0, r0, 0
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(vf3, 80, a3); // sqc2 vf3, 80(a3)
c->vmadd_bc(DEST::xyzw, BC::w, vf7, vf28, vf7); // vmaddw.xyzw vf7, vf28, vf7
c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3)
// nop // sll r0, r0, 0
c->sqc2(vf3, 128, a3); // sqc2 vf3, 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(vf3, 176, a3); // sqc2 vf3, 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::xyzw, BC::w, vf10, vf28, vf10); // vmaddw.xyzw vf10, vf28, vf10
c->sqc2(vf3, 224, a3); // sqc2 vf3, 224(a3)
// nop // sll r0, r0, 0
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_boundary_polygon); // lw t9, draw-boundary-polygon(s7)
c->vsub(DEST::xyzw, vf4, vf4, vf1); // vsub.xyzw vf4, vf4, vf1
// nop // sll r0, r0, 0
c->vsub(DEST::xyzw, vf7, vf7, vf1); // vsub.xyzw vf7, vf7, vf1
// nop // sll r0, r0, 0
c->vopmula(vf4, vf7); // vopmula.xyz acc, vf4, vf7
// nop // sll r0, r0, 0
c->vopmsub(vf10, vf7, vf4); // vopmsub.xyz vf10, vf7, vf4
// nop // sll r0, r0, 0
c->vmul(DEST::xyzw, vf10, vf10, vf1); // vmul.xyzw vf10, vf10, vf1
// nop // sll r0, r0, 0
c->vadd_bc(DEST::y, BC::x, vf10, vf10, vf10); // vaddx.y vf10, vf10, vf10
// nop // sll r0, r0, 0
c->vadd_bc(DEST::y, BC::z, vf10, vf10, vf10); // vaddz.y vf10, vf10, vf10
// nop // sll r0, r0, 0
c->mov128_gpr_vf(v0, vf10); // qmfc2.i v0, vf10
// nop // sll r0, r0, 0
bc = ((s64)c->sgpr64(v0)) >= 0; // bgez v0, L29
// nop // sll r0, r0, 0
if (bc) {goto block_2;} // branch non-likely
// Unknown instr: jr t9
// nop // sll r0, r0, 0
draw_boundary_polygon::execute(ctxt);
goto end_of_function;
block_2:
c->sqc2(vf6, 32, a3); // sqc2 vf6, 32(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 80, a3); // sqc2 vf6, 80(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 128, a3); // sqc2 vf6, 128(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 176, a3); // sqc2 vf6, 176(a3)
// nop // sll r0, r0, 0
// Unknown instr: jr t9
draw_boundary_polygon::execute(ctxt);
goto end_of_function;
// 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("*fake-scratchpad-data*").c();
cache.math_camera = intern_from_c("*math-camera*").c();
cache.draw_boundary_polygon = intern_from_c("draw-boundary-polygon").c();
gLinkedFunctionTable.reg("render-boundary-quad", execute, 32);
}
} // namespace render_boundary_quad
} // namespace Mips2C
//--------------------------MIPS2C---------------------
// clang-format off
using ::jak2::intern_from_c;
namespace Mips2C::jak2 {
namespace render_boundary_tri {
struct Cache {
void* fake_scratchpad_data; // *fake-scratchpad-data*
void* draw_boundary_polygon; // draw-boundary-polygon
} cache;
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
c->copy_vfs_from_other(&sky_regs_vfs);
bool bc = false;
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::xyzw, BC::w, vf1, vf28, vf1); // vmaddw.xyzw vf1, vf28, vf1
c->lqc2(vf7, 96, a0); // lqc2 vf7, 96(a0)
// nop // sll r0, r0, 0
c->lqc2(vf8, 112, a0); // lqc2 vf8, 112(a0)
c->vmula_bc(DEST::xyzw, BC::x, vf31, vf4); // vmulax.xyzw acc, vf31, vf4
// nop // sll r0, r0, 0
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::xyzw, BC::w, vf4, vf28, vf4); // vmaddw.xyzw vf4, vf28, vf4
c->sqc2(vf5, 64, a3); // sqc2 vf5, 64(a3)
// nop // sll r0, r0, 0
c->sqc2(vf3, 80, a3); // sqc2 vf3, 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(vf3, 128, a3); // sqc2 vf3, 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::xyzw, BC::w, vf7, vf28, vf7); // vmaddw.xyzw vf7, vf28, vf7
c->sqc2(vf3, 176, a3); // sqc2 vf3, 176(a3)
// nop // sll r0, r0, 0
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_boundary_polygon); // lw t9, draw-boundary-polygon(s7)
c->vsub(DEST::xyzw, vf4, vf4, vf1); // vsub.xyzw vf4, vf4, vf1
// nop // sll r0, r0, 0
c->vsub(DEST::xyzw, vf7, vf7, vf1); // vsub.xyzw vf7, vf7, vf1
// nop // sll r0, r0, 0
c->vopmula(vf4, vf7); // vopmula.xyz acc, vf4, vf7
// nop // sll r0, r0, 0
c->vopmsub(vf10, vf7, vf4); // vopmsub.xyz vf10, vf7, vf4
// nop // sll r0, r0, 0
c->vmul(DEST::xyzw, vf10, vf10, vf1); // vmul.xyzw vf10, vf10, vf1
// nop // sll r0, r0, 0
c->vadd_bc(DEST::y, BC::x, vf10, vf10, vf10); // vaddx.y vf10, vf10, vf10
// nop // sll r0, r0, 0
c->vadd_bc(DEST::y, BC::z, vf10, vf10, vf10); // vaddz.y vf10, vf10, vf10
// nop // sll r0, r0, 0
c->mov128_gpr_vf(v0, vf10); // qmfc2.i v0, vf10
// nop // sll r0, r0, 0
bc = ((s64)c->sgpr64(v0)) >= 0; // bgez v0, L27
// nop // sll r0, r0, 0
if (bc) {goto block_2;} // branch non-likely
// Unknown instr: jr t9
draw_boundary_polygon::execute(ctxt);
goto end_of_function;
// nop // sll r0, r0, 0
block_2:
c->sqc2(vf6, 32, a3); // sqc2 vf6, 32(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 80, a3); // sqc2 vf6, 80(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 128, a3); // sqc2 vf6, 128(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 176, a3); // sqc2 vf6, 176(a3)
// nop // sll r0, r0, 0
// Unknown instr: jr t9
draw_boundary_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("*fake-scratchpad-data*").c();
cache.draw_boundary_polygon = intern_from_c("draw-boundary-polygon").c();
gLinkedFunctionTable.reg("render-boundary-tri", execute, 32);
}
} // namespace render_boundary_tri
} // namespace Mips2C
+599
View File
@@ -0,0 +1,599 @@
#include "sky.h"
#include "game/kernel/jak2/kscheme.h"
#include "game/mips2c/mips2c_private.h"
namespace Mips2C::jak2 {
ExecutionContext sky_regs_vfs;
namespace set_sky_vf27 {
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
// sky_regs_vfs.vfs[27]
memcpy(&sky_regs_vfs.vfs[27].f[0], g_ee_main_mem + c->gpr_addr(a0), 16);
return 0;
}
void link() {
gLinkedFunctionTable.reg("set-sky-vf27", execute, 64);
}
} // namespace set_sky_vf27
} // namespace Mips2C::jak2
//--------------------------MIPS2C---------------------
// clang-format off
using ::jak2::intern_from_c;
namespace Mips2C::jak2 {
namespace clip_polygon_against_positive_hyperplane {
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
bool bc = false;
bool cop1_bc = false;
// nop // sll r0, r0, 0
c->mov64(t1, t0); // or t1, t0, r0
c->addiu(t0, r0, 0); // addiu t0, r0, 0
c->lwc1(f1, 0, t2); // lwc1 f1, 0(t2)
c->daddiu(t2, t2, 48); // daddiu t2, t2, 48
c->lwc1(f0, 12, a2); // lwc1 f0, 12(a2)
c->mov64(t3, a3); // or t3, a3, r0
c->lqc2(vf1, 0, a2); // lqc2 vf1, 0(a2)
c->daddiu(a2, a2, 48); // daddiu a2, a2, 48
cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1
c->lqc2(vf2, -32, a2); // lqc2 vf2, -32(a2)
bc = !cop1_bc; // bc1f L112
c->lqc2(vf3, -16, a2); // lqc2 vf3, -16(a2)
if (bc) {goto block_9;} // branch non-likely
block_1:
c->lwc1(f3, 0, t2); // lwc1 f3, 0(t2)
c->daddiu(t2, t2, 48); // daddiu t2, t2, 48
c->lwc1(f2, 12, a2); // lwc1 f2, 12(a2)
c->daddiu(t1, t1, -1); // daddiu t1, t1, -1
c->lqc2(vf4, 0, a2); // lqc2 vf4, 0(a2)
c->daddiu(a2, a2, 48); // daddiu a2, a2, 48
cop1_bc = c->fprs[f2] < c->fprs[f3]; // c.lt.s f2, f3
c->lqc2(vf5, -32, a2); // lqc2 vf5, -32(a2)
bc = !cop1_bc; // bc1f L110
c->lqc2(vf6, -16, a2); // lqc2 vf6, -16(a2)
if (bc) {goto block_6;} // branch non-likely
bc = c->sgpr64(t1) == 0; // beq t1, r0, L116
// nop // sll r0, r0, 0
if (bc) {goto block_17;} // branch non-likely
block_3:
c->lwc1(f1, 0, t2); // lwc1 f1, 0(t2)
c->daddiu(t2, t2, 48); // daddiu t2, t2, 48
c->lwc1(f0, 12, a2); // lwc1 f0, 12(a2)
c->daddiu(t1, t1, -1); // daddiu t1, t1, -1
c->lqc2(vf1, 0, a2); // lqc2 vf1, 0(a2)
c->daddiu(a2, a2, 48); // daddiu a2, a2, 48
cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1
c->lqc2(vf2, -32, a2); // lqc2 vf2, -32(a2)
bc = !cop1_bc; // bc1f L111
c->lqc2(vf3, -16, a2); // lqc2 vf3, -16(a2)
if (bc) {goto block_8;} // branch non-likely
bc = c->sgpr64(t1) != 0; // bne t1, r0, L108
// nop // sll r0, r0, 0
if (bc) {goto block_1;} // branch non-likely
//beq r0, r0, L116 // beq r0, r0, L116
// nop // sll r0, r0, 0
goto block_17; // branch always
block_6:
c->subs(f7, f0, f1); // sub.s f7, f0, f1
c->vsub(DEST::xyzw, vf7, vf4, vf1); // vsub.xyzw vf7, vf4, vf1
c->subs(f8, f2, f3); // sub.s f8, f2, f3
c->vsub(DEST::xyzw, vf8, vf5, vf2); // vsub.xyzw vf8, vf5, vf2
c->subs(f5, f7, f8); // sub.s f5, f7, f8
c->vsub(DEST::xyzw, vf9, vf6, vf3); // vsub.xyzw vf9, vf6, vf3
c->divs(f6, f7, f5); // div.s f6, f7, f5
c->daddiu(a3, a3, 48); // daddiu a3, a3, 48
c->mfc1(v1, f6); // mfc1 v1, f6
c->mov128_vf_gpr(vf10, v1); // qmtc2.i vf10, v1
c->daddiu(t0, t0, 1); // daddiu t0, t0, 1
c->vmula_bc(DEST::xyzw, BC::w, vf1, vf0); // vmulaw.xyzw acc, vf1, vf0
c->daddiu(t6, s7, 4); // daddiu t6, s7, 4
c->vmadd_bc(DEST::xyzw, BC::x, vf7, vf7, vf10); // vmaddx.xyzw vf7, vf7, vf10
// nop // sll r0, r0, 0
c->vmula_bc(DEST::xyzw, BC::w, vf2, vf0); // vmulaw.xyzw acc, vf2, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf8, vf8, vf10); // vmaddx.xyzw vf8, vf8, vf10
// nop // sll r0, r0, 0
c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf9, vf10); // vmaddx.xyzw vf9, vf9, vf10
// nop // sll r0, r0, 0
c->sqc2(vf7, -48, a3); // sqc2 vf7, -48(a3)
// nop // sll r0, r0, 0
c->sqc2(vf8, -32, a3); // sqc2 vf8, -32(a3)
// nop // sll r0, r0, 0
bc = c->sgpr64(t1) != 0; // bne t1, r0, L113
c->sqc2(vf9, -16, a3); // sqc2 vf9, -16(a3)
if (bc) {goto block_11;} // branch non-likely
//beq r0, r0, L116 // beq r0, r0, L116
// nop // sll r0, r0, 0
goto block_17; // branch always
block_8:
c->subs(f7, f0, f1); // sub.s f7, f0, f1
c->vsub(DEST::xyzw, vf7, vf1, vf4); // vsub.xyzw vf7, vf1, vf4
c->subs(f8, f2, f3); // sub.s f8, f2, f3
c->vsub(DEST::xyzw, vf8, vf2, vf5); // vsub.xyzw vf8, vf2, vf5
c->subs(f5, f8, f7); // sub.s f5, f8, f7
c->vsub(DEST::xyzw, vf9, vf3, vf6); // vsub.xyzw vf9, vf3, vf6
c->divs(f6, f8, f5); // div.s f6, f8, f5
c->daddiu(a3, a3, 48); // daddiu a3, a3, 48
c->mfc1(v1, f6); // mfc1 v1, f6
c->mov128_vf_gpr(vf10, v1); // qmtc2.i vf10, v1
c->daddiu(t0, t0, 1); // daddiu t0, t0, 1
c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0
c->daddiu(t6, s7, 4); // daddiu t6, s7, 4
c->vmadd_bc(DEST::xyzw, BC::x, vf7, vf7, vf10); // vmaddx.xyzw vf7, vf7, vf10
// nop // sll r0, r0, 0
c->vmula_bc(DEST::xyzw, BC::w, vf5, vf0); // vmulaw.xyzw acc, vf5, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf8, vf8, vf10); // vmaddx.xyzw vf8, vf8, vf10
// nop // sll r0, r0, 0
c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf9, vf10); // vmaddx.xyzw vf9, vf9, vf10
// nop // sll r0, r0, 0
c->sqc2(vf7, -48, a3); // sqc2 vf7, -48(a3)
// nop // sll r0, r0, 0
c->sqc2(vf8, -32, a3); // sqc2 vf8, -32(a3)
// nop // sll r0, r0, 0
bc = c->sgpr64(t1) == 0; // beq t1, r0, L116
c->sqc2(vf9, -16, a3); // sqc2 vf9, -16(a3)
if (bc) {goto block_17;} // branch non-likely
block_9:
c->lwc1(f3, 0, t2); // lwc1 f3, 0(t2)
c->daddiu(t2, t2, 48); // daddiu t2, t2, 48
c->lwc1(f2, 12, a2); // lwc1 f2, 12(a2)
c->daddiu(t1, t1, -1); // daddiu t1, t1, -1
c->lqc2(vf4, 0, a2); // lqc2 vf4, 0(a2)
c->daddiu(a2, a2, 48); // daddiu a2, a2, 48
cop1_bc = c->fprs[f2] < c->fprs[f3]; // c.lt.s f2, f3
c->lqc2(vf5, -32, a2); // lqc2 vf5, -32(a2)
bc = cop1_bc; // bc1t L114
c->lqc2(vf6, -16, a2); // lqc2 vf6, -16(a2)
if (bc) {goto block_14;} // branch non-likely
c->sqc2(vf1, 0, a3); // sqc2 vf1, 0(a3)
c->daddiu(a3, a3, 48); // daddiu a3, a3, 48
c->sqc2(vf2, -32, a3); // sqc2 vf2, -32(a3)
c->daddiu(t0, t0, 1); // daddiu t0, t0, 1
bc = c->sgpr64(t1) == 0; // beq t1, r0, L116
c->sqc2(vf3, -16, a3); // sqc2 vf3, -16(a3)
if (bc) {goto block_17;} // branch non-likely
block_11:
c->lwc1(f1, 0, t2); // lwc1 f1, 0(t2)
c->daddiu(t2, t2, 48); // daddiu t2, t2, 48
c->lwc1(f0, 12, a2); // lwc1 f0, 12(a2)
c->daddiu(t1, t1, -1); // daddiu t1, t1, -1
c->lqc2(vf1, 0, a2); // lqc2 vf1, 0(a2)
c->daddiu(a2, a2, 48); // daddiu a2, a2, 48
cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1
c->lqc2(vf2, -32, a2); // lqc2 vf2, -32(a2)
bc = cop1_bc; // bc1t L115
c->lqc2(vf3, -16, a2); // lqc2 vf3, -16(a2)
if (bc) {goto block_16;} // branch non-likely
c->sqc2(vf4, 0, a3); // sqc2 vf4, 0(a3)
c->daddiu(a3, a3, 48); // daddiu a3, a3, 48
c->sqc2(vf5, -32, a3); // sqc2 vf5, -32(a3)
c->daddiu(t0, t0, 1); // daddiu t0, t0, 1
bc = c->sgpr64(t1) != 0; // bne t1, r0, L112
c->sqc2(vf6, -16, a3); // sqc2 vf6, -16(a3)
if (bc) {goto block_9;} // branch non-likely
//beq r0, r0, L116 // beq r0, r0, L116
// nop // sll r0, r0, 0
goto block_17; // branch always
block_14:
c->subs(f7, f0, f1); // sub.s f7, f0, f1
c->vsub(DEST::xyzw, vf7, vf1, vf4); // vsub.xyzw vf7, vf1, vf4
c->subs(f8, f2, f3); // sub.s f8, f2, f3
c->vsub(DEST::xyzw, vf8, vf2, vf5); // vsub.xyzw vf8, vf2, vf5
c->subs(f5, f8, f7); // sub.s f5, f8, f7
c->vsub(DEST::xyzw, vf9, vf3, vf6); // vsub.xyzw vf9, vf3, vf6
c->divs(f6, f8, f5); // div.s f6, f8, f5
c->daddiu(a3, a3, 96); // daddiu a3, a3, 96
c->mfc1(v1, f6); // mfc1 v1, f6
c->mov128_vf_gpr(vf10, v1); // qmtc2.i vf10, v1
c->sqc2(vf1, -96, a3); // sqc2 vf1, -96(a3)
c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0
c->sqc2(vf2, -80, a3); // sqc2 vf2, -80(a3)
c->vmadd_bc(DEST::xyzw, BC::x, vf7, vf7, vf10); // vmaddx.xyzw vf7, vf7, vf10
c->sqc2(vf3, -64, a3); // sqc2 vf3, -64(a3)
c->vmula_bc(DEST::xyzw, BC::w, vf5, vf0); // vmulaw.xyzw acc, vf5, vf0
c->daddiu(t0, t0, 2); // daddiu t0, t0, 2
c->vmadd_bc(DEST::xyzw, BC::x, vf8, vf8, vf10); // vmaddx.xyzw vf8, vf8, vf10
c->daddiu(t6, s7, 4); // daddiu t6, s7, 4
c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf9, vf10); // vmaddx.xyzw vf9, vf9, vf10
// nop // sll r0, r0, 0
c->sqc2(vf7, -48, a3); // sqc2 vf7, -48(a3)
// nop // sll r0, r0, 0
c->sqc2(vf8, -32, a3); // sqc2 vf8, -32(a3)
// nop // sll r0, r0, 0
bc = c->sgpr64(t1) != 0; // bne t1, r0, L109
c->sqc2(vf9, -16, a3); // sqc2 vf9, -16(a3)
if (bc) {goto block_3;} // branch non-likely
//beq r0, r0, L116 // beq r0, r0, L116
// nop // sll r0, r0, 0
goto block_17; // branch always
block_16:
c->subs(f7, f0, f1); // sub.s f7, f0, f1
c->vsub(DEST::xyzw, vf7, vf4, vf1); // vsub.xyzw vf7, vf4, vf1
c->subs(f8, f2, f3); // sub.s f8, f2, f3
c->vsub(DEST::xyzw, vf8, vf5, vf2); // vsub.xyzw vf8, vf5, vf2
c->subs(f5, f7, f8); // sub.s f5, f7, f8
c->vsub(DEST::xyzw, vf9, vf6, vf3); // vsub.xyzw vf9, vf6, vf3
c->divs(f6, f7, f5); // div.s f6, f7, f5
c->daddiu(a3, a3, 96); // daddiu a3, a3, 96
c->mfc1(v1, f6); // mfc1 v1, f6
c->mov128_vf_gpr(vf10, v1); // qmtc2.i vf10, v1
c->sqc2(vf4, -96, a3); // sqc2 vf4, -96(a3)
c->vmula_bc(DEST::xyzw, BC::w, vf1, vf0); // vmulaw.xyzw acc, vf1, vf0
c->sqc2(vf5, -80, a3); // sqc2 vf5, -80(a3)
c->vmadd_bc(DEST::xyzw, BC::x, vf7, vf7, vf10); // vmaddx.xyzw vf7, vf7, vf10
c->sqc2(vf6, -64, a3); // sqc2 vf6, -64(a3)
c->vmula_bc(DEST::xyzw, BC::w, vf2, vf0); // vmulaw.xyzw acc, vf2, vf0
c->daddiu(t0, t0, 2); // daddiu t0, t0, 2
c->vmadd_bc(DEST::xyzw, BC::x, vf8, vf8, vf10); // vmaddx.xyzw vf8, vf8, vf10
c->daddiu(t6, s7, 4); // daddiu t6, s7, 4
c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf9, vf10); // vmaddx.xyzw vf9, vf9, vf10
// nop // sll r0, r0, 0
c->sqc2(vf7, -48, a3); // sqc2 vf7, -48(a3)
// nop // sll r0, r0, 0
c->sqc2(vf8, -32, a3); // sqc2 vf8, -32(a3)
// nop // sll r0, r0, 0
bc = c->sgpr64(t1) != 0; // bne t1, r0, L108
c->sqc2(vf9, -16, a3); // sqc2 vf9, -16(a3)
if (bc) {goto block_1;} // branch non-likely
block_17:
c->lqc2(vf1, 0, t3); // lqc2 vf1, 0(t3)
// nop // sll r0, r0, 0
c->lqc2(vf2, 16, t3); // lqc2 vf2, 16(t3)
// nop // sll r0, r0, 0
c->lqc2(vf3, 32, t3); // lqc2 vf3, 32(t3)
// nop // sll r0, r0, 0
c->sqc2(vf1, 0, a3); // sqc2 vf1, 0(a3)
// nop // sll r0, r0, 0
c->sqc2(vf2, 16, a3); // sqc2 vf2, 16(a3)
// nop // sll r0, r0, 0
//jr ra // jr ra
c->sqc2(vf3, 32, a3); // sqc2 vf3, 32(a3)
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];
}
} // namespace clip_polygon_against_positive_hyperplane
} // namespace Mips2C
//--------------------------MIPS2C---------------------
// clang-format off
#include "game/mips2c/mips2c_private.h"
#include "game/kernel/jak2/kscheme.h"
using ::jak2::intern_from_c;
namespace Mips2C::jak2 {
namespace clip_polygon_against_negative_hyperplane {
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
bool bc = false;
bool cop1_bc = false;
// nop // sll r0, r0, 0
c->mov64(t1, t0); // or t1, t0, r0
c->addiu(t0, r0, 0); // addiu t0, r0, 0
c->lwc1(f0, 12, a2); // lwc1 f0, 12(a2)
c->mov64(t3, a3); // or t3, a3, r0
c->lwc1(f1, 0, t2); // lwc1 f1, 0(t2)
c->daddiu(t2, t2, 48); // daddiu t2, t2, 48
c->lqc2(vf1, 0, a2); // lqc2 vf1, 0(a2)
c->negs(f0, f0); // neg.s f0, f0
// nop // sll r0, r0, 0
c->lqc2(vf2, 16, a2); // lqc2 vf2, 16(a2)
cop1_bc = c->fprs[f1] < c->fprs[f0]; // c.lt.s f1, f0
c->daddiu(a2, a2, 48); // daddiu a2, a2, 48
bc = !cop1_bc; // bc1f L102
c->lqc2(vf3, -16, a2); // lqc2 vf3, -16(a2)
if (bc) {goto block_9;} // branch non-likely
block_1:
c->lwc1(f2, 12, a2); // lwc1 f2, 12(a2)
c->daddiu(t1, t1, -1); // daddiu t1, t1, -1
c->lwc1(f3, 0, t2); // lwc1 f3, 0(t2)
c->daddiu(t2, t2, 48); // daddiu t2, t2, 48
c->lqc2(vf4, 0, a2); // lqc2 vf4, 0(a2)
c->negs(f2, f2); // neg.s f2, f2
// nop // sll r0, r0, 0
c->lqc2(vf5, 16, a2); // lqc2 vf5, 16(a2)
cop1_bc = c->fprs[f3] < c->fprs[f2]; // c.lt.s f3, f2
c->daddiu(a2, a2, 48); // daddiu a2, a2, 48
bc = !cop1_bc; // bc1f L100
c->lqc2(vf6, -16, a2); // lqc2 vf6, -16(a2)
if (bc) {goto block_6;} // branch non-likely
bc = c->sgpr64(t1) == 0; // beq t1, r0, L106
// nop // sll r0, r0, 0
if (bc) {goto block_17;} // branch non-likely
block_3:
c->lwc1(f0, 12, a2); // lwc1 f0, 12(a2)
c->daddiu(t1, t1, -1); // daddiu t1, t1, -1
c->lwc1(f1, 0, t2); // lwc1 f1, 0(t2)
c->daddiu(t2, t2, 48); // daddiu t2, t2, 48
c->lqc2(vf1, 0, a2); // lqc2 vf1, 0(a2)
c->negs(f0, f0); // neg.s f0, f0
// nop // sll r0, r0, 0
c->lqc2(vf2, 16, a2); // lqc2 vf2, 16(a2)
cop1_bc = c->fprs[f1] < c->fprs[f0]; // c.lt.s f1, f0
c->daddiu(a2, a2, 48); // daddiu a2, a2, 48
bc = !cop1_bc; // bc1f L101
c->lqc2(vf3, -16, a2); // lqc2 vf3, -16(a2)
if (bc) {goto block_8;} // branch non-likely
bc = c->sgpr64(t1) != 0; // bne t1, r0, L98
// nop // sll r0, r0, 0
if (bc) {goto block_1;} // branch non-likely
//beq r0, r0, L106 // beq r0, r0, L106
// nop // sll r0, r0, 0
goto block_17; // branch always
block_6:
c->subs(f7, f0, f1); // sub.s f7, f0, f1
c->vsub(DEST::xyzw, vf7, vf4, vf1); // vsub.xyzw vf7, vf4, vf1
c->subs(f8, f2, f3); // sub.s f8, f2, f3
c->vsub(DEST::xyzw, vf8, vf5, vf2); // vsub.xyzw vf8, vf5, vf2
c->subs(f5, f7, f8); // sub.s f5, f7, f8
c->vsub(DEST::xyzw, vf9, vf6, vf3); // vsub.xyzw vf9, vf6, vf3
c->divs(f6, f7, f5); // div.s f6, f7, f5
c->daddiu(a3, a3, 48); // daddiu a3, a3, 48
c->mfc1(v1, f6); // mfc1 v1, f6
c->mov128_vf_gpr(vf10, v1); // qmtc2.i vf10, v1
c->daddiu(t0, t0, 1); // daddiu t0, t0, 1
c->vmula_bc(DEST::xyzw, BC::w, vf1, vf0); // vmulaw.xyzw acc, vf1, vf0
c->daddiu(t6, s7, 4); // daddiu t6, s7, 4
c->vmadd_bc(DEST::xyzw, BC::x, vf7, vf7, vf10); // vmaddx.xyzw vf7, vf7, vf10
// nop // sll r0, r0, 0
c->vmula_bc(DEST::xyzw, BC::w, vf2, vf0); // vmulaw.xyzw acc, vf2, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf8, vf8, vf10); // vmaddx.xyzw vf8, vf8, vf10
// nop // sll r0, r0, 0
c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf9, vf10); // vmaddx.xyzw vf9, vf9, vf10
// nop // sll r0, r0, 0
c->sqc2(vf7, -48, a3); // sqc2 vf7, -48(a3)
// nop // sll r0, r0, 0
c->sqc2(vf8, -32, a3); // sqc2 vf8, -32(a3)
// nop // sll r0, r0, 0
bc = c->sgpr64(t1) != 0; // bne t1, r0, L103
c->sqc2(vf9, -16, a3); // sqc2 vf9, -16(a3)
if (bc) {goto block_11;} // branch non-likely
//beq r0, r0, L106 // beq r0, r0, L106
// nop // sll r0, r0, 0
goto block_17; // branch always
block_8:
c->subs(f7, f0, f1); // sub.s f7, f0, f1
c->vsub(DEST::xyzw, vf7, vf1, vf4); // vsub.xyzw vf7, vf1, vf4
c->subs(f8, f2, f3); // sub.s f8, f2, f3
c->vsub(DEST::xyzw, vf8, vf2, vf5); // vsub.xyzw vf8, vf2, vf5
c->subs(f5, f8, f7); // sub.s f5, f8, f7
c->vsub(DEST::xyzw, vf9, vf3, vf6); // vsub.xyzw vf9, vf3, vf6
c->divs(f6, f8, f5); // div.s f6, f8, f5
c->daddiu(a3, a3, 48); // daddiu a3, a3, 48
c->mfc1(v1, f6); // mfc1 v1, f6
c->mov128_vf_gpr(vf10, v1); // qmtc2.i vf10, v1
c->daddiu(t0, t0, 1); // daddiu t0, t0, 1
c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0
c->daddiu(t6, s7, 4); // daddiu t6, s7, 4
c->vmadd_bc(DEST::xyzw, BC::x, vf7, vf7, vf10); // vmaddx.xyzw vf7, vf7, vf10
// nop // sll r0, r0, 0
c->vmula_bc(DEST::xyzw, BC::w, vf5, vf0); // vmulaw.xyzw acc, vf5, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf8, vf8, vf10); // vmaddx.xyzw vf8, vf8, vf10
// nop // sll r0, r0, 0
c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf9, vf10); // vmaddx.xyzw vf9, vf9, vf10
// nop // sll r0, r0, 0
c->sqc2(vf7, -48, a3); // sqc2 vf7, -48(a3)
// nop // sll r0, r0, 0
c->sqc2(vf8, -32, a3); // sqc2 vf8, -32(a3)
// nop // sll r0, r0, 0
bc = c->sgpr64(t1) == 0; // beq t1, r0, L106
c->sqc2(vf9, -16, a3); // sqc2 vf9, -16(a3)
if (bc) {goto block_17;} // branch non-likely
block_9:
c->lwc1(f2, 12, a2); // lwc1 f2, 12(a2)
c->daddiu(t1, t1, -1); // daddiu t1, t1, -1
c->lwc1(f3, 0, t2); // lwc1 f3, 0(t2)
c->daddiu(t2, t2, 48); // daddiu t2, t2, 48
c->lqc2(vf4, 0, a2); // lqc2 vf4, 0(a2)
c->negs(f2, f2); // neg.s f2, f2
// nop // sll r0, r0, 0
c->lqc2(vf5, 16, a2); // lqc2 vf5, 16(a2)
cop1_bc = c->fprs[f3] < c->fprs[f2]; // c.lt.s f3, f2
c->daddiu(a2, a2, 48); // daddiu a2, a2, 48
bc = cop1_bc; // bc1t L104
c->lqc2(vf6, -16, a2); // lqc2 vf6, -16(a2)
if (bc) {goto block_14;} // branch non-likely
c->sqc2(vf1, 0, a3); // sqc2 vf1, 0(a3)
c->daddiu(a3, a3, 48); // daddiu a3, a3, 48
c->sqc2(vf2, -32, a3); // sqc2 vf2, -32(a3)
c->daddiu(t0, t0, 1); // daddiu t0, t0, 1
bc = c->sgpr64(t1) == 0; // beq t1, r0, L106
c->sqc2(vf3, -16, a3); // sqc2 vf3, -16(a3)
if (bc) {goto block_17;} // branch non-likely
block_11:
c->lwc1(f0, 12, a2); // lwc1 f0, 12(a2)
c->daddiu(t1, t1, -1); // daddiu t1, t1, -1
c->lwc1(f1, 0, t2); // lwc1 f1, 0(t2)
c->daddiu(t2, t2, 48); // daddiu t2, t2, 48
c->lqc2(vf1, 0, a2); // lqc2 vf1, 0(a2)
c->negs(f0, f0); // neg.s f0, f0
// nop // sll r0, r0, 0
c->lqc2(vf2, 16, a2); // lqc2 vf2, 16(a2)
cop1_bc = c->fprs[f1] < c->fprs[f0]; // c.lt.s f1, f0
c->daddiu(a2, a2, 48); // daddiu a2, a2, 48
bc = cop1_bc; // bc1t L105
c->lqc2(vf3, -16, a2); // lqc2 vf3, -16(a2)
if (bc) {goto block_16;} // branch non-likely
c->sqc2(vf4, 0, a3); // sqc2 vf4, 0(a3)
c->daddiu(a3, a3, 48); // daddiu a3, a3, 48
c->sqc2(vf5, -32, a3); // sqc2 vf5, -32(a3)
c->daddiu(t0, t0, 1); // daddiu t0, t0, 1
bc = c->sgpr64(t1) != 0; // bne t1, r0, L102
c->sqc2(vf6, -16, a3); // sqc2 vf6, -16(a3)
if (bc) {goto block_9;} // branch non-likely
//beq r0, r0, L106 // beq r0, r0, L106
// nop // sll r0, r0, 0
goto block_17; // branch always
block_14:
c->subs(f7, f0, f1); // sub.s f7, f0, f1
c->vsub(DEST::xyzw, vf7, vf1, vf4); // vsub.xyzw vf7, vf1, vf4
c->subs(f8, f2, f3); // sub.s f8, f2, f3
c->vsub(DEST::xyzw, vf8, vf2, vf5); // vsub.xyzw vf8, vf2, vf5
c->subs(f5, f8, f7); // sub.s f5, f8, f7
c->vsub(DEST::xyzw, vf9, vf3, vf6); // vsub.xyzw vf9, vf3, vf6
c->divs(f6, f8, f5); // div.s f6, f8, f5
c->daddiu(a3, a3, 96); // daddiu a3, a3, 96
c->mfc1(v1, f6); // mfc1 v1, f6
c->mov128_vf_gpr(vf10, v1); // qmtc2.i vf10, v1
c->sqc2(vf1, -96, a3); // sqc2 vf1, -96(a3)
c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0
c->sqc2(vf2, -80, a3); // sqc2 vf2, -80(a3)
c->vmadd_bc(DEST::xyzw, BC::x, vf7, vf7, vf10); // vmaddx.xyzw vf7, vf7, vf10
c->sqc2(vf3, -64, a3); // sqc2 vf3, -64(a3)
c->vmula_bc(DEST::xyzw, BC::w, vf5, vf0); // vmulaw.xyzw acc, vf5, vf0
c->daddiu(t0, t0, 2); // daddiu t0, t0, 2
c->vmadd_bc(DEST::xyzw, BC::x, vf8, vf8, vf10); // vmaddx.xyzw vf8, vf8, vf10
c->daddiu(t6, s7, 4); // daddiu t6, s7, 4
c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf9, vf10); // vmaddx.xyzw vf9, vf9, vf10
// nop // sll r0, r0, 0
c->sqc2(vf7, -48, a3); // sqc2 vf7, -48(a3)
// nop // sll r0, r0, 0
c->sqc2(vf8, -32, a3); // sqc2 vf8, -32(a3)
// nop // sll r0, r0, 0
bc = c->sgpr64(t1) != 0; // bne t1, r0, L99
c->sqc2(vf9, -16, a3); // sqc2 vf9, -16(a3)
if (bc) {goto block_3;} // branch non-likely
//beq r0, r0, L106 // beq r0, r0, L106
// nop // sll r0, r0, 0
goto block_17; // branch always
block_16:
c->subs(f7, f0, f1); // sub.s f7, f0, f1
c->vsub(DEST::xyzw, vf7, vf4, vf1); // vsub.xyzw vf7, vf4, vf1
c->subs(f8, f2, f3); // sub.s f8, f2, f3
c->vsub(DEST::xyzw, vf8, vf5, vf2); // vsub.xyzw vf8, vf5, vf2
c->subs(f5, f7, f8); // sub.s f5, f7, f8
c->vsub(DEST::xyzw, vf9, vf6, vf3); // vsub.xyzw vf9, vf6, vf3
c->divs(f6, f7, f5); // div.s f6, f7, f5
c->daddiu(a3, a3, 96); // daddiu a3, a3, 96
c->mfc1(v1, f6); // mfc1 v1, f6
c->mov128_vf_gpr(vf10, v1); // qmtc2.i vf10, v1
c->sqc2(vf4, -96, a3); // sqc2 vf4, -96(a3)
c->vmula_bc(DEST::xyzw, BC::w, vf1, vf0); // vmulaw.xyzw acc, vf1, vf0
c->sqc2(vf5, -80, a3); // sqc2 vf5, -80(a3)
c->vmadd_bc(DEST::xyzw, BC::x, vf7, vf7, vf10); // vmaddx.xyzw vf7, vf7, vf10
c->sqc2(vf6, -64, a3); // sqc2 vf6, -64(a3)
c->vmula_bc(DEST::xyzw, BC::w, vf2, vf0); // vmulaw.xyzw acc, vf2, vf0
c->daddiu(t0, t0, 2); // daddiu t0, t0, 2
c->vmadd_bc(DEST::xyzw, BC::x, vf8, vf8, vf10); // vmaddx.xyzw vf8, vf8, vf10
c->daddiu(t6, s7, 4); // daddiu t6, s7, 4
c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0
// nop // sll r0, r0, 0
c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf9, vf10); // vmaddx.xyzw vf9, vf9, vf10
// nop // sll r0, r0, 0
c->sqc2(vf7, -48, a3); // sqc2 vf7, -48(a3)
// nop // sll r0, r0, 0
c->sqc2(vf8, -32, a3); // sqc2 vf8, -32(a3)
// nop // sll r0, r0, 0
bc = c->sgpr64(t1) != 0; // bne t1, r0, L98
c->sqc2(vf9, -16, a3); // sqc2 vf9, -16(a3)
if (bc) {goto block_1;} // branch non-likely
block_17:
c->lqc2(vf1, 0, t3); // lqc2 vf1, 0(t3)
// nop // sll r0, r0, 0
c->lqc2(vf2, 16, t3); // lqc2 vf2, 16(t3)
// nop // sll r0, r0, 0
c->lqc2(vf3, 32, t3); // lqc2 vf3, 32(t3)
// nop // sll r0, r0, 0
c->sqc2(vf1, 0, a3); // sqc2 vf1, 0(a3)
// nop // sll r0, r0, 0
c->sqc2(vf2, 16, a3); // sqc2 vf2, 16(a3)
// nop // sll r0, r0, 0
//jr ra // jr ra
c->sqc2(vf3, 32, a3); // sqc2 vf3, 32(a3)
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];
}
} // namespace clip_polygon_against_negative_hyperplane
} // namespace Mips2C
+14
View File
@@ -0,0 +1,14 @@
#pragma once
#include "game/mips2c/mips2c_private.h"
namespace Mips2C::jak2 {
extern ExecutionContext sky_regs_vfs;
namespace clip_polygon_against_positive_hyperplane {
extern u64 execute(void* ctxt);
}
namespace clip_polygon_against_negative_hyperplane {
extern u64 execute(void* ctxt);
}
} // namespace Mips2C::jak2
+6
View File
@@ -1444,6 +1444,12 @@ inline void get_fake_spad_addr(int dst, void* sym_addr, u32 offset, ExecutionCon
c->gprs[dst].du64[0] = val + offset;
}
inline void get_fake_spad_addr2(int dst, void* sym_addr, u32 offset, ExecutionContext* c) {
u32 val;
memcpy(&val, (u8*)sym_addr - 1, 4);
c->gprs[dst].du64[0] = val + offset;
}
inline void spad_to_dma(void* spad_sym_addr, u32 madr, u32 sadr, u32 qwc) {
u32 spad_addr_goal;
memcpy(&spad_addr_goal, spad_sym_addr, 4);
+10 -2
View File
@@ -124,6 +124,11 @@ namespace draw_string { extern void link(); }
namespace get_string_length { extern void link(); }
namespace adgif_shader_texture_with_update { extern void link(); }
namespace debug_line_clip { extern void link(); }
namespace init_boundary_regs { extern void link(); }
namespace render_boundary_tri { extern void link(); }
namespace render_boundary_quad { extern void link(); }
namespace set_sky_vf27 { extern void link(); }
namespace draw_boundary_polygon { extern void link(); }
}
// clang-format on
@@ -205,7 +210,10 @@ PerGameVersion<std::unordered_map<std::string, std::vector<void (*)()>>> gMips2C
{"font",
{jak2::draw_string::link, jak2::get_string_length::link, jak2::draw_string_asm::link}},
{"texture", {jak2::adgif_shader_texture_with_update::link}},
{"debug", {jak2::debug_line_clip::link}}},
{"debug",
{jak2::debug_line_clip::link, jak2::init_boundary_regs::link,
jak2::render_boundary_quad::link, jak2::render_boundary_tri::link, jak2::set_sky_vf27::link,
jak2::draw_boundary_polygon::link}}},
};
void LinkedFunctionTable::reg(const std::string& name, u64 (*exec)(void*), u32 stack_size) {
@@ -285,7 +293,7 @@ void LinkedFunctionTable::reg(const std::string& name, u64 (*exec)(void*), u32 s
u32 LinkedFunctionTable::get(const std::string& name) {
auto it = m_executes.find(name);
if (it == m_executes.end()) {
ASSERT(false);
ASSERT_NOT_REACHED_MSG(fmt::format("mips2c function {} is unknown", name));
}
return it->second.goal_trampoline.offset;
}
-1
View File
@@ -13,7 +13,6 @@
;; NOTE - for editable
(define-extern add-debug-x (function symbol bucket-id vector rgba symbol))
(define-extern add-debug-vector (function symbol bucket-id vector vector meters rgba symbol))
(define-extern add-debug-bound (function int transform int rgba rgba int none))
(define-extern add-debug-line2d (function symbol bucket-id vector vector vector symbol))
(define-extern add-debug-text-3d (function symbol bucket-id string vector font-color vector2h symbol))
+164 -55
View File
@@ -538,23 +538,6 @@
:flag-assert #x90000003c
)
(defmethod inspect debug-line ((obj debug-line))
(when (not obj)
(set! obj obj)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" obj 'debug-line)
(format #t "~1Tflags: ~D~%" (-> obj flags))
(format #t "~1Tbucket: ~D~%" (-> obj bucket))
(format #t "~1Tv1: #<vector @ #x~X>~%" (-> obj v1))
(format #t "~1Tv2: #<vector @ #x~X>~%" (-> obj v2))
(format #t "~1Tcolor: ~D~%" (-> obj color))
(format #t "~1Tmode: ~A~%" (-> obj mode))
(format #t "~1Tcolor2: ~D~%" (-> obj color2))
(label cfg-4)
obj
)
(deftype debug-text-3d (structure)
((flags int32 :offset-assert 0)
(bucket bucket-id :offset-assert 4)
@@ -568,22 +551,6 @@
:flag-assert #x90000002c
)
(defmethod inspect debug-text-3d ((obj debug-text-3d))
(when (not obj)
(set! obj obj)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" obj 'debug-text-3d)
(format #t "~1Tflags: ~D~%" (-> obj flags))
(format #t "~1Tbucket: ~D~%" (-> obj bucket))
(format #t "~1Tpos: #<vector @ #x~X>~%" (-> obj pos))
(format #t "~1Tcolor: ~D~%" (-> obj color))
(format #t "~1Toffset: #<vector2h @ #x~X>~%" (-> obj offset))
(format #t "~1Tstr: ~A~%" (-> obj str))
(label cfg-4)
obj
)
(deftype debug-tracking-thang (basic)
((length int32 :offset-assert 4)
(allocated-length int32 :offset-assert 8)
@@ -593,17 +560,6 @@
:flag-assert #x90000000c
)
(defmethod inspect debug-tracking-thang ((obj debug-tracking-thang))
(when (not obj)
(set! obj obj)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" obj (-> obj type))
(format #t "~1Tlength: ~D~%" (-> obj length))
(format #t "~1Tallocated-length: ~D~%" (-> obj allocated-length))
(label cfg-4)
obj
)
(define *debug-lines* (the-as (inline-array debug-line) (malloc 'debug #x100000)))
(define *debug-lines-trk* (new 'debug 'debug-tracking-thang))
@@ -1789,11 +1745,20 @@
;; Boundary Debug
;;;;;;;;;;;;;;;;;;
;; TODO: missing a bunch of functions here
;; the debug drawing for boundaries reuses the sky polygon drawing code.
;; this does a bunch of crazy that violate calling conventions, so it's all in C++ and patched.
(define-extern init-boundary-regs (function none))
(when *debug-segment*
(define *boundary-polygon* (the-as (inline-array sky-vertex) (malloc 'debug 768)))
)
(defun-debug add-boundary-shader ((tex-id texture-id) (buf dma-buffer))
;; init-boundary-regs loads vf registers with math camera values and stuff from sky-work
(def-mips2c init-boundary-regs (function none))
;; add-boundary-shader
(defun add-boundary-shader ((tex-id texture-id) (buf dma-buffer))
"Generate adgif shader data (including GIF tag, but not VIF/DMA) for the given
texture, and write to the given dma-buffer."
(let ((tex (lookup-texture-by-id tex-id)))
(when tex
(let* ((v1-0 buf)
@@ -1824,14 +1789,158 @@
(none)
)
;; draw-boundary-polygon : this is handled entirely in mips2c
;; render-boundary-quad
;; render-boundary-tri
(def-mips2c render-boundary-tri (function sky-vertex dma-buffer none))
;;;;;;;;;;;;;;;;;;
;; More Misc
;;;;;;;;;;;;;;;;;;
;; add-debug-bound-internal sneaks an extra value in vf27 - so this set-sky-vf27 function
;; was added so we can pass this value down to c++.
(def-mips2c set-sky-vf27 (function object none))
(define-extern cpu-delay (function int none))
(defun add-debug-bound-internal ((buf dma-buffer) (pts (inline-array vector)) (num-pts int) (color0 rgba) (color1 rgba) (flip-tex int))
"Draw a boundary polygon using the boundary renderer. This renderer reuses components of the sky render
to properly clip (and subdivide) very large polgons.
This is intended to be called by add-debug-bound, after it has set up dma buffers for the boundary rendering."
(rlet ((vf27 :class vf))
(set-vector!
(-> *boundary-polygon* 0 col)
(the float (-> color0 r))
(the float (-> color0 g))
(the float (-> color0 b))
(the float (-> color0 a))
)
(set-vector!
(-> *boundary-polygon* 1 col)
(the float (-> color1 r))
(the float (-> color1 g))
(the float (-> color1 b))
(the float (-> color1 a))
)
(init-boundary-regs)
;;(.lvf vf27 (&-> *sky-work* giftag-roof quad))
(set-sky-vf27 (&-> *sky-work* giftag-roof quad))
(let ((s3-0 0)
(s2-1 (if (nonzero? flip-tex)
(new 'static 'matrix :vector (new 'static 'inline-array vector 4
(new 'static 'vector :x 1.0 :y 8.0 :z 1.0 :w 1.0)
(new 'static 'vector :z 1.0 :w 1.0)
(new 'static 'vector :y 8.0 :z 1.0 :w 1.0)
(new 'static 'vector :x 1.0 :z 1.0 :w 1.0)
)
)
(new 'static 'matrix :vector (new 'static 'inline-array vector 4
(new 'static 'vector :z 1.0 :w 1.0)
(new 'static 'vector :y 8.0 :z 1.0 :w 1.0)
(new 'static 'vector :x 1.0 :z 1.0 :w 1.0)
(new 'static 'vector :x 1.0 :y 8.0 :z 1.0 :w 1.0)
)
)
)
)
)
(while (< s3-0 (+ num-pts -2))
(cond
((not (logtest? s3-0 1))
(dotimes (v1-6 3)
(set! (-> *boundary-polygon* v1-6 pos quad) (-> pts (+ s3-0 v1-6) quad))
(set! (-> *boundary-polygon* v1-6 stq quad) (-> s2-1 vector (+ s3-0 v1-6) quad))
)
)
(else
(set! (-> *boundary-polygon* 0 pos quad) (-> pts (+ s3-0 1) quad))
(set! (-> *boundary-polygon* 1 pos quad) (-> pts s3-0 quad))
(set! (-> *boundary-polygon* 2 pos quad) (-> pts (+ s3-0 2) quad))
(set! (-> *boundary-polygon* 0 stq quad) (-> s2-1 vector (+ s3-0 1) quad))
(set! (-> *boundary-polygon* 1 stq quad) (-> s2-1 vector s3-0 quad))
(set! (-> *boundary-polygon* 2 stq quad) (-> s2-1 vector (+ s3-0 2) quad))
)
)
(render-boundary-tri (-> *boundary-polygon* 0) buf)
(+! s3-0 1)
)
)
(none)
)
)
(define-extern qword-read-time (function (array uint128) int int))
;; Returns whether some workaround for an EE memory controller bug is enabled.
(define-extern bugfix? (function symbol))
(defun add-debug-bound ((buf bucket-id) (pts (inline-array vector)) (c0 int) (c1 rgba) (flash rgba) (arg5 int))
"Draw a debug boundary polygon."
(local-vars (sv-16 pointer) (sv-32 int))
(set! sv-32 arg5)
(if (< c0 3)
(return 0)
)
(case sv-32
((1)
(if (logtest? (-> *display* real-frame-clock integral-frame-counter) 4)
(set! sv-32 1)
(set! sv-32 0)
)
sv-32
)
)
(let* ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf))
(s5-0 (-> s4-0 base))
)
(let* ((v1-16 s4-0)
(a0-3 (the-as dma-packet (-> v1-16 base)))
)
(set! (-> a0-3 dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt)))
(set! (-> a0-3 vif0) (new 'static 'vif-tag))
(set! (-> a0-3 vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1))
(set! (-> v1-16 base) (the-as pointer (the-as dma-packet (&+ a0-3 16))))
)
(let* ((v1-17 s4-0)
(a0-5 (the-as gs-gif-tag (-> v1-17 base)))
)
(set! (-> a0-5 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3))
(set! (-> a0-5 regs) GIF_REGS_ALL_AD)
(set! (-> v1-17 base) (the-as pointer (the-as gs-gif-tag (&+ a0-5 16))))
)
(let* ((v1-18 s4-0)
(a0-7 (-> v1-18 base))
)
(set! (-> (the-as (pointer gs-zbuf) a0-7) 0) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24)))
(set! (-> (the-as (pointer gs-reg64) a0-7) 1) (gs-reg64 zbuf-1))
(set! (-> (the-as (pointer gs-test) a0-7) 2) (new 'static 'gs-test
:ate #x1
:atst (gs-atest greater-equal)
:aref #x26
:zte #x1
:ztst (gs-ztest greater-equal)
)
)
(set! (-> (the-as (pointer gs-reg64) a0-7) 3) (gs-reg64 test-1))
(set! (-> (the-as (pointer gs-alpha) a0-7) 4) (new 'static 'gs-alpha :b #x1 :d #x1))
(set! (-> (the-as (pointer gs-reg64) a0-7) 5) (gs-reg64 alpha-1))
(set! (-> v1-18 base) (&+ a0-7 48))
)
(set! sv-16 (-> s4-0 base))
(&+! (-> s4-0 base) 16)
(add-boundary-shader (new 'static 'texture-id :index #x3 :page #x70c) s4-0)
(add-debug-bound-internal s4-0 pts c0 c1 flash sv-32)
(close-sky-buffer s4-0)
(let ((v1-25 (/ (the-as int (+ (- -16 (the-as int sv-16)) (the-as int (-> s4-0 base)))) 16)))
(set! (-> (the-as dma-packet sv-16) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-25))
(set! (-> (the-as dma-packet sv-16) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet sv-16) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm v1-25))
)
(let ((a3-2 (-> s4-0 base)))
(let ((v1-29 (the-as dma-packet (-> s4-0 base))))
(set! (-> v1-29 dma) (new 'static 'dma-tag :id (dma-tag-id next)))
(set! (-> v1-29 vif0) (new 'static 'vif-tag))
(set! (-> v1-29 vif1) (new 'static 'vif-tag))
(set! (-> s4-0 base) (the-as pointer (the-as dma-packet (&+ v1-29 16))))
)
(dma-bucket-insert-tag
(-> *display* frames (-> *display* on-screen) bucket-group)
buf
s5-0
(the-as (pointer dma-tag) a3-2)
)
)
)
0
(none)
)
+6 -6
View File
@@ -1164,14 +1164,14 @@
)
)
(add-debug-bound
324
(the-as transform gp-0)
(bucket-id debug2)
gp-0
sv-112
(if (logtest? (-> obj flags) (editable-flag orient))
(the-as rgba (-> (new 'static 'array uint64 1 #x800000ff) 0))
(the-as rgba (-> (new 'static 'array uint64 1 #x8000ffff) 0))
)
(if (zero? (logand (-> obj flags) (editable-flag orient)))
(if (not (logtest? (-> obj flags) (editable-flag orient)))
(the-as rgba (-> (new 'static 'array uint64 1 #x800000ff) 0))
(the-as rgba (-> (new 'static 'array uint64 1 #x8000ffff) 0))
)
@@ -1454,14 +1454,14 @@
(the-as rgba -1)
)
(add-debug-bound
324
(the-as transform gp-0)
(bucket-id debug2)
(the-as (inline-array vector) gp-0)
s4-0
(if (logtest? (-> obj flags) (editable-flag orient))
(the-as rgba (-> (new 'static 'array uint64 1 #x800000ff) 0))
(the-as rgba (-> (new 'static 'array uint64 1 #x8000ffff) 0))
)
(if (zero? (logand (-> obj flags) (editable-flag orient)))
(if (not (logtest? (-> obj flags) (editable-flag orient)))
(the-as rgba (-> (new 'static 'array uint64 1 #x800000ff) 0))
(the-as rgba (-> (new 'static 'array uint64 1 #x8000ffff) 0))
)
+2
View File
@@ -5,6 +5,8 @@
;; name in dgo: sky-h
;; dgos: ENGINE, GAME
(define-extern close-sky-buffer (function dma-buffer none))
;; DECOMP BEGINS
(deftype sky-color-hour (structure)
+18
View File
@@ -9,6 +9,24 @@
;; TODO
(defun close-sky-buffer ((arg0 dma-buffer))
(nop!)
(let ((v1-0 #x8000)
(v0-0 (-> arg0 base))
)
(set! (-> (the-as (pointer uint128) v0-0)) (the uint128 0))
(nop!)
(set! (-> (the-as (pointer int32) v0-0)) v1-0)
(let ((v0-1 (&+ v0-0 16)))
;; to save like 1 instruction they put this in the delay slot of the jr-ra
;;(.jr ra-0)
(set! (-> arg0 base) v0-1)
)
)
(none)
)
(defmethod update-time-and-speed sky-work ((obj sky-work) (arg0 float) (arg1 float))
(if (and (level-get-target-inside *level*) (= (-> (level-get-target-inside *level*) info taskname) 'nest))
(set! arg1 (* 10.0 arg1))
+2 -2
View File
@@ -300,8 +300,8 @@
(add-debug-sphere #t (bucket-id debug2) s5-0 (-> obj bsphere w) (new 'static 'rgba :r #xff :a #x30))
)
(add-debug-bound
324
(the-as transform (-> obj data points))
(bucket-id debug2)
(-> obj data points)
(the-as int (-> obj data num-points))
(new 'static 'rgba :r #xff :g #xff :a #x80)
(new 'static 'rgba :r #xff :a #x80)
+139 -211
View File
@@ -1877,8 +1877,8 @@
;; this part is debug only
(when *debug-segment*
;; definition for symbol *boundary-polygon*, type none
(define *boundary-polygon* (the-as none (malloc 'debug 768)))
;; definition for symbol *boundary-polygon*, type (inline-array sky-vertex)
(define *boundary-polygon* (the-as (inline-array sky-vertex) (malloc 'debug 768)))
)
;; definition (debug) for function init-boundary-regs
@@ -1927,224 +1927,152 @@
;; ERROR: function was not converted to expressions. Cannot decompile.
;; definition (debug) for function add-debug-bound-internal
;; ERROR: function has no type analysis. Cannot decompile.
;; INFO: Used lq/sq
;; WARN: Return type mismatch symbol vs none.
(defun-debug add-debug-bound-internal ((buf dma-buffer) (pts (inline-array vector)) (num-pts int) (color0 rgba) (color1 rgba) (flip-tex int))
(rlet ((vf27 :class vf))
(set-vector!
(-> *boundary-polygon* 0 col)
(the float (-> color0 r))
(the float (-> color0 g))
(the float (-> color0 b))
(the float (-> color0 a))
)
(set-vector!
(-> *boundary-polygon* 1 col)
(the float (-> color1 r))
(the float (-> color1 g))
(the float (-> color1 b))
(the float (-> color1 a))
)
(init-boundary-regs)
(.lvf vf27 (&-> *sky-work* giftag-roof quad))
(let ((s3-0 0)
(s2-1 (if (nonzero? flip-tex)
(new 'static 'matrix :vector (new 'static 'inline-array vector 4
(new 'static 'vector :x 1.0 :y 8.0 :z 1.0 :w 1.0)
(new 'static 'vector :z 1.0 :w 1.0)
(new 'static 'vector :y 8.0 :z 1.0 :w 1.0)
(new 'static 'vector :x 1.0 :z 1.0 :w 1.0)
)
)
(new 'static 'matrix :vector (new 'static 'inline-array vector 4
(new 'static 'vector :z 1.0 :w 1.0)
(new 'static 'vector :y 8.0 :z 1.0 :w 1.0)
(new 'static 'vector :x 1.0 :z 1.0 :w 1.0)
(new 'static 'vector :x 1.0 :y 8.0 :z 1.0 :w 1.0)
)
)
)
)
)
(while (< s3-0 (+ num-pts -2))
(cond
((not (logtest? s3-0 1))
(dotimes (v1-6 3)
(set! (-> *boundary-polygon* v1-6 pos quad) (-> pts (+ s3-0 v1-6) quad))
(set! (-> *boundary-polygon* v1-6 stq quad) (-> s2-1 vector (+ s3-0 v1-6) quad))
)
)
(else
(set! (-> *boundary-polygon* 0 pos quad) (-> pts (+ s3-0 1) quad))
(set! (-> *boundary-polygon* 1 pos quad) (-> pts s3-0 quad))
(set! (-> *boundary-polygon* 2 pos quad) (-> pts (+ s3-0 2) quad))
(set! (-> *boundary-polygon* 0 stq quad) (-> s2-1 vector (+ s3-0 1) quad))
(set! (-> *boundary-polygon* 1 stq quad) (-> s2-1 vector s3-0 quad))
(set! (-> *boundary-polygon* 2 stq quad) (-> s2-1 vector (+ s3-0 2) quad))
)
)
(render-boundary-tri (-> *boundary-polygon* 0) buf)
(+! s3-0 1)
)
)
(none)
)
)
;; definition (debug) for function add-debug-bound
;; INFO: Used lq/sq
;; ERROR: failed type prop at 82: Called a function, but we do not know its type
;; WARN: Return type mismatch int vs none.
(defun-debug add-debug-bound ((a0-0 int) (a1-0 transform) (a2-0 int) (a3-0 rgba) (t0-0 rgba) (t1-0 int))
(local-vars
(v0-0 int)
(v0-1 none)
(v0-2 none)
(v0-3 none)
(v0-4 none)
(v0-5 none)
(v1-2 int)
(v1-4 display)
(v1-5 clock)
(v1-6 uint)
(v1-7 uint)
(v1-8 int)
(v1-9 int)
(v1-10 int)
(v1-11 display)
(v1-12 int)
(v1-13 int)
(v1-14 int)
(v1-15 display-frame)
(v1-16 dma-buffer)
(v1-17 dma-buffer)
(v1-18 dma-buffer)
(v1-19 pointer)
(v1-20 pointer)
(v1-21 pointer)
(v1-22 none)
(v1-23 none)
(v1-24 none)
(v1-25 none)
(v1-26 none)
(v1-27 none)
(v1-28 none)
(v1-29 none)
(v1-30 none)
(v1-31 none)
(v1-32 none)
(v1-33 none)
(v1-34 none)
(v1-35 none)
(a0-1 int)
(a0-2 display)
(a0-3 pointer)
(a0-4 pointer)
(a0-5 pointer)
(a0-6 pointer)
(a0-7 pointer)
(a0-8 pointer)
(a0-9 int)
(a0-12 none)
(a0-13 none)
(a0-14 none)
(a0-15 none)
(a0-16 none)
(a0-17 none)
(a0-18 none)
(a0-19 none)
(a0-20 none)
(a0-21 none)
(a1-1 int)
(a1-2 int)
(a1-3 uint)
(a1-4 uint)
(a1-5 uint)
(a1-6 int)
(a1-7 int)
(a1-8 int)
(a1-9 int)
(a1-10 int)
(a1-11 int)
(a1-12 dma-buffer)
(a1-14 none)
(a1-15 none)
(a1-16 none)
(a3-2 none)
(t1-1 int)
(s4-0 dma-buffer)
(s5-0 pointer)
(t9-0 (function texture-id dma-buffer none))
(t9-1 function)
(t9-2 none)
(t9-3 none)
(sv-16 pointer)
(sv-32 int)
)
(if (begin (set! sv-32 t1-0) (<.si a2-0 3))
(return (set! v0-0 0))
;; WARN: Function add-debug-bound has a return type of none, but the expression builder found a return statement.
(defun-debug add-debug-bound ((buf bucket-id) (pts (inline-array vector)) (c0 int) (c1 rgba) (flash rgba) (arg5 int))
(local-vars (sv-16 pointer) (sv-32 int))
(set! sv-32 arg5)
(if (< c0 3)
(return 0)
)
(when (begin (set! v1-2 sv-32) (set! a0-1 1) (= v1-2 a0-1))
(cond
((begin
(set! v1-4 *display*)
(set! v1-5 (-> v1-4 real-frame-clock))
(set! v1-6 (-> v1-5 integral-frame-counter))
(set! v1-7 (logand v1-6 4))
(nonzero? v1-7)
(case sv-32
((1)
(if (logtest? (-> *display* real-frame-clock integral-frame-counter) 4)
(set! sv-32 1)
(set! sv-32 0)
)
(set! v1-8 1)
(set! sv-32 v1-8)
)
(else
(set! v1-9 0)
(set! sv-32 v1-9)
sv-32
)
)
(let* ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf))
(s5-0 (-> s4-0 base))
)
(let* ((v1-16 s4-0)
(a0-3 (the-as dma-packet (-> v1-16 base)))
)
(set! (-> a0-3 dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt)))
(set! (-> a0-3 vif0) (new 'static 'vif-tag))
(set! (-> a0-3 vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1))
(set! (-> v1-16 base) (the-as pointer (the-as dma-packet (&+ a0-3 16))))
)
(let* ((v1-17 s4-0)
(a0-5 (the-as gs-gif-tag (-> v1-17 base)))
)
(set! (-> a0-5 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3))
(set! (-> a0-5 regs) GIF_REGS_ALL_AD)
(set! (-> v1-17 base) (the-as pointer (the-as gs-gif-tag (&+ a0-5 16))))
)
(let* ((v1-18 s4-0)
(a0-7 (-> v1-18 base))
)
(set! (-> (the-as (pointer gs-zbuf) a0-7) 0) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24)))
(set! (-> (the-as (pointer gs-reg64) a0-7) 1) (gs-reg64 zbuf-1))
(set! (-> (the-as (pointer gs-test) a0-7) 2) (new 'static 'gs-test
:ate #x1
:atst (gs-atest greater-equal)
:aref #x26
:zte #x1
:ztst (gs-ztest greater-equal)
)
)
(set! (-> (the-as (pointer gs-reg64) a0-7) 3) (gs-reg64 test-1))
(set! (-> (the-as (pointer gs-alpha) a0-7) 4) (new 'static 'gs-alpha :b #x1 :d #x1))
(set! (-> (the-as (pointer gs-reg64) a0-7) 5) (gs-reg64 alpha-1))
(set! (-> v1-18 base) (&+ a0-7 48))
)
(set! sv-16 (-> s4-0 base))
(&+! (-> s4-0 base) 16)
(add-boundary-shader (new 'static 'texture-id :index #x3 :page #x70c) s4-0)
(add-debug-bound-internal s4-0 pts c0 c1 flash sv-32)
(close-sky-buffer s4-0)
(let ((v1-25 (/ (the-as int (+ (- -16 (the-as int sv-16)) (the-as int (-> s4-0 base)))) 16)))
(set! (-> (the-as dma-packet sv-16) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-25))
(set! (-> (the-as dma-packet sv-16) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet sv-16) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm v1-25))
)
(let ((a3-2 (-> s4-0 base)))
(let ((v1-29 (the-as dma-packet (-> s4-0 base))))
(set! (-> v1-29 dma) (new 'static 'dma-tag :id (dma-tag-id next)))
(set! (-> v1-29 vif0) (new 'static 'vif-tag))
(set! (-> v1-29 vif1) (new 'static 'vif-tag))
(set! (-> s4-0 base) (the-as pointer (the-as dma-packet (&+ v1-29 16))))
)
(dma-bucket-insert-tag
(-> *display* frames (-> *display* on-screen) bucket-group)
buf
s5-0
(the-as (pointer dma-tag) a3-2)
)
)
(set! v1-10 sv-32)
)
(set! v1-11 *display*)
(set! v1-12 (-> v1-11 on-screen))
(set! v1-13 (sll v1-12 2))
(set! a0-2 *display*)
(set! v1-14 (+ v1-13 a0-2))
(set! v1-15 (dynamic-array-field-access v1-14 frames PLACEHOLDER))
(set! s4-0 (-> v1-15 global-buf))
(set! s5-0 (-> s4-0 base))
(set! v1-16 s4-0)
(set! a0-3 (-> v1-16 base))
(set! a1-1 #x10000004)
(set! (the-as (pointer int64) (-> (the-as (pointer int64) a0-3))) a1-1)
(s.w! (+ a0-3 8) 0)
(set! a1-2 #x50000004)
(s.w! (+ a0-3 12) a1-2)
(set! a0-4 (+ a0-3 16))
(set! (-> v1-16 base) a0-4)
(set! v1-17 s4-0)
(set! a0-5 (-> v1-17 base))
(set! a1-3 (the-as uint #x3000000000008001))
(set! a1-4 (pcypld 0 a1-3))
(set! (the-as (pointer uint64) (-> (the-as (pointer uint64) a0-5))) a1-4)
(set! a1-5 (the-as uint #xeeeeeeeeeeeeeeee))
(s.d! (+ a0-5 8) a1-5)
(set! a0-6 (+ a0-5 16))
(set! (-> v1-17 base) a0-6)
(set! v1-18 s4-0)
(set! a0-7 (-> v1-18 base))
(set! a1-6 #x1000130)
(set! (the-as (pointer int64) (-> (the-as (pointer int64) a0-7))) a1-6)
(set! a1-7 78)
(s.d! (+ a0-7 8) a1-7)
(set! a1-8 #x5026b)
(s.d! (+ a0-7 16) a1-8)
(set! a1-9 71)
(s.d! (+ a0-7 24) a1-9)
(set! a1-10 68)
(s.d! (+ a0-7 32) a1-10)
(set! a1-11 66)
(s.d! (+ a0-7 40) a1-11)
(set! a0-8 (+ a0-7 48))
(set! (-> v1-18 base) a0-8)
(set! v1-19 (-> s4-0 base))
(set! sv-16 v1-19)
(set! v1-20 (-> s4-0 base))
(set! v1-21 (+ v1-20 16))
(set! (-> s4-0 base) v1-21)
(set! t9-0 add-boundary-shader)
(set! a0-9 #x70c00300)
(set! a1-12 s4-0)
(call! a0-9 a1-12)
(set! t9-1 add-debug-bound-internal)
(set! a0-10 s4-0)
(set! a1-13 a1-0)
(set! a2-1 a2-0)
(set! a3-1 a3-0)
(set! t0-1 t0-0)
(set! t1-1 sv-32)
(call!)
(set! t9-2 (the-as none close-sky-buffer))
(set! a0-11 (the-as none s4-0))
(call!)
(set! v1-22 (the-as none -16))
(set! a0-12 (the-as none sv-16))
(set! v1-23 (the-as none (- v1-22 a0-12)))
(set! a0-13 (the-as none (-> s4-0 base)))
(set! v1-24 (the-as none (+ v1-23 a0-13)))
(set! v1-25 (the-as none (sra v1-24 4)))
(set! a0-14 (the-as none #x10000000))
(set! a1-14 (the-as none (sll v1-25 48)))
(set! a1-15 (the-as none (srl a1-14 48)))
(set! a0-15 (the-as none (logior a0-14 a1-15)))
(set! a1-16 (the-as none sv-16))
(s.d! a1-16 a0-15)
(set! a0-16 (the-as none sv-16))
(s.w! (+ a0-16 8) 0)
(set! a0-17 (the-as none #x50000000))
(set! v1-26 (the-as none (sll v1-25 48)))
(set! v1-27 (the-as none (srl v1-26 48)))
(set! a0-18 (the-as none (logior a0-17 v1-27)))
(set! v1-28 (the-as none sv-16))
(s.w! (+ v1-28 12) a0-18)
(set! a3-2 (the-as none (-> s4-0 base)))
(set! v1-29 (the-as none (-> s4-0 base)))
(set! a0-19 (the-as none #x20000000))
(s.d! v1-29 a0-19)
(s.w! (+ v1-29 8) 0)
(s.w! (+ v1-29 12) 0)
(set! v1-30 (the-as none (+ v1-29 16)))
(set! (-> s4-0 base) (the-as pointer v1-30))
(set! t9-3 (the-as none dma-bucket-insert-tag))
(set! v1-31 (the-as none *display*))
(set! v1-32 (the-as none (l.w v1-31)))
(set! v1-33 (the-as none (sll v1-32 2)))
(set! a0-20 (the-as none *display*))
(set! v1-34 (the-as none (+ v1-33 a0-20)))
(set! v1-35 (the-as none (l.wu (+ v1-34 8))))
(set! a0-21 (the-as none (l.wu (+ v1-35 40))))
(set! a1-17 (the-as none a0-0))
(set! a2-2 (the-as none s5-0))
(call!)
(set! v1-36 (the-as none v0-4))
(set! v0-5 (the-as none 0))
(ret-none)
0
(none)
)
;; definition (debug) for function cpu-delay
+4 -4
View File
@@ -1416,8 +1416,8 @@
)
)
(add-debug-bound
324
(the-as transform gp-0)
(bucket-id debug2)
gp-0
sv-112
(if (logtest? (-> obj flags) (editable-flag orient))
(the-as rgba (-> (new 'static 'array uint64 1 #x800000ff) 0))
@@ -1778,8 +1778,8 @@
(the-as rgba -1)
)
(add-debug-bound
324
(the-as transform gp-0)
(bucket-id debug2)
(the-as (inline-array vector) gp-0)
s4-0
(if (logtest? (-> obj flags) (editable-flag orient))
(the-as rgba (-> (new 'static 'array uint64 1 #x800000ff) 0))
+2 -2
View File
@@ -323,8 +323,8 @@
(add-debug-sphere #t (bucket-id debug2) s5-0 (-> obj bsphere w) (new 'static 'rgba :r #xff :a #x30))
)
(add-debug-bound
324
(the-as transform (-> obj data points))
(bucket-id debug2)
(-> obj data points)
(the-as int (-> obj data num-points))
(new 'static 'rgba :r #xff :g #xff :a #x80)
(new 'static 'rgba :r #xff :a #x80)