jak-project/game/mips2c/functions/test_func.cpp
water111 f0ceea8b2e
[sparticle] 2d hud particles (#849)
* wip, taking a break to work on asm stuff first

* the goal code for sparticle

* mips2c the first sparticle asm function

* temp

* particle processing no longer crashing

* temp

* working texture cache for vi1 and hud textures

* sprites

* cleanup 1

* temp

* temp

* add zstd library

* temp

* working

* tests

* include fix

* uncomment

* better decomp of sparticle stuff, part 1

* update references
2021-09-26 11:41:58 -04:00

69 lines
2 KiB
C++

//--------------------------MIPS2C---------------------
#include "game/mips2c/mips2c_private.h"
#include "game/kernel/kscheme.h"
namespace Mips2C {
namespace test_func {
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
u64 result = 0;
for (int i = a0; i < t4; i++) {
result += c->sgpr64(i);
}
c->gprs[v0].du64[0] = result;
return 0;
}
} // namespace test_func
} // namespace Mips2C
//--------------------------MIPS2C---------------------
#include "game/mips2c/mips2c_private.h"
#include "game/kernel/kscheme.h"
#include "game/kernel/kprint.h"
namespace Mips2C {
namespace goal_call_test {
struct Cache {
void* goal_check_function;
} cache;
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
u32 call_addr = 0;
c->daddiu(sp, sp, -128); // daddiu sp, sp, -128
c->sd(ra, 0, sp); // sd ra, 0(sp)
c->sq(s0, 16, sp); // sq s0, 16(sp)
c->sq(s1, 32, sp); // sq s1, 32(sp)
c->sq(s2, 48, sp); // sq s2, 48(sp)
c->sq(s3, 64, sp); // sq s3, 64(sp)
c->sq(s4, 80, sp); // sq s4, 80(sp)
c->sq(s5, 96, sp); // sq s5, 96(sp)
c->sq(gp, 112, sp); // sq gp, 112(sp)
c->load_symbol(t9, cache.goal_check_function);
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->ld(ra, 0, sp); // ld ra, 0(sp)
c->lq(gp, 112, sp); // lq gp, 112(sp)
c->lq(s5, 96, sp); // lq s5, 96(sp)
c->lq(s4, 80, sp); // lq s4, 80(sp)
c->lq(s3, 64, sp); // lq s3, 64(sp)
c->lq(s2, 48, sp); // lq s2, 48(sp)
c->lq(s1, 32, sp); // lq s1, 32(sp)
c->lq(s0, 16, sp); // lq s0, 16(sp)
c->daddiu(sp, sp, 128); // daddiu sp, sp, 128
goto end_of_function; // return
end_of_function:
return c->gprs[v0].du64[0];
}
void link() {
cache.goal_check_function = intern_from_c("goal_check_function").c();
}
} // namespace goal_call_test
} // namespace Mips2C