Integrate all the progress into master #6
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "gte_instruction.hpp"
|
#include "gte_types.hpp"
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace GTE {
|
namespace GTE {
|
||||||
|
@ -15,12 +15,7 @@ namespace JabyEngine {
|
||||||
output: Output vector
|
output: Output vector
|
||||||
flag: flag output
|
flag: flag output
|
||||||
*/
|
*/
|
||||||
static void rot_trans(const SVECTOR& input, VECTOR& output, int32_t& flag) {
|
void rot_trans(const SVECTOR& input, VECTOR& output, int32_t& flag);
|
||||||
ldv0(input);
|
|
||||||
rt();
|
|
||||||
stlvnl(output);
|
|
||||||
stflg(flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SetRotMatrix
|
SetRotMatrix
|
||||||
|
@ -28,32 +23,14 @@ namespace JabyEngine {
|
||||||
Sets a 3x3 matrix m as a constant rotation matrix.
|
Sets a 3x3 matrix m as a constant rotation matrix.
|
||||||
matrix: The rotation matrix to set
|
matrix: The rotation matrix to set
|
||||||
*/
|
*/
|
||||||
static void set_rot_matrix(const MATRIX& matrix) {
|
void set_rot_matrix(const MATRIX& matrix);
|
||||||
__asm__ volatile("lw $12, 0(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("lw $13, 4(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("ctc2 $12, $0" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("ctc2 $13, $1" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("lw $12, 8(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("lw $13, 12(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("lw $14, 16(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("ctc2 $12, $2" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("ctc2 $13, $3" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("ctc2 $14, $4" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SetTransMatrix
|
SetTransMatrix
|
||||||
|
|
||||||
Sets a constant parallel transfer vector specified by m
|
Sets a constant parallel transfer vector specified by m
|
||||||
*/
|
*/
|
||||||
static void set_trans_matrix(const MATRIX& matrix) {
|
void set_trans_matrix(const MATRIX& matrix);
|
||||||
__asm__ volatile("lw $12, 20(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("lw $13, 24(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("ctc2 $12, $5" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("lw $14, 28(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("ctc2 $13, $6" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
__asm__ volatile("ctc2 $14, $7" :: "r"(&matrix) : "$12", "$13", "$14");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MulMatrix0
|
MulMatrix0
|
||||||
|
@ -66,46 +43,20 @@ namespace JabyEngine {
|
||||||
Multiplies two matrices m0 and m1.
|
Multiplies two matrices m0 and m1.
|
||||||
The function destroys the constant rotation matrix
|
The function destroys the constant rotation matrix
|
||||||
*/
|
*/
|
||||||
static MATRIX& mult_matrix(const MATRIX& m0, const MATRIX& m1, MATRIX& result) {
|
MATRIX& mult_matrix(const MATRIX& m0, const MATRIX& m1, MATRIX& result);
|
||||||
/*
|
|
||||||
Jaby: Somehow this code creates stack usage.... Investigate!!
|
|
||||||
*/
|
|
||||||
set_rot_matrix(m0);
|
|
||||||
|
|
||||||
ldclmv(m1, 0);
|
|
||||||
rtir();
|
|
||||||
stclmv(result, 0);
|
|
||||||
|
|
||||||
ldclmv(m1, 1);
|
|
||||||
rtir();
|
|
||||||
stclmv(result, 1);
|
|
||||||
|
|
||||||
ldclmv(m1, 2);
|
|
||||||
rtir();
|
|
||||||
stclmv(result, 2);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SetGeomOffset(ofx,ofy)
|
SetGeomOffset(ofx,ofy)
|
||||||
|
|
||||||
Load GTE-offset.
|
Load GTE-offset.
|
||||||
*/
|
*/
|
||||||
static void set_geom_offset(int32_t off_x, int32_t off_y) {
|
void set_geom_offset(int32_t off_x, int32_t off_y);
|
||||||
__asm__ volatile("sll $12, %0, 16" :: "r"(off_x), "r"(off_y) : "$12", "$13");
|
|
||||||
__asm__ volatile("sll $13, %1, 16" :: "r"(off_x), "r"(off_y) : "$12", "$13");
|
|
||||||
__asm__ volatile("ctc2 $12, $24" :: "r"(off_x), "r"(off_y) : "$12", "$13");
|
|
||||||
__asm__ volatile("ctc2 $13, $25" :: "r"(off_x), "r"(off_y) : "$12", "$13");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SetGeomScreen(h)
|
SetGeomScreen(h)
|
||||||
|
|
||||||
Load distance from viewpoint to screen.
|
Load distance from viewpoint to screen.
|
||||||
*/
|
*/
|
||||||
static void set_geom_screen(int32_t h) {
|
void set_geom_screen(int32_t h);
|
||||||
__asm__ volatile("ctc2 %0, $26" :: "r"(h));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -69,14 +69,26 @@ namespace JabyEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_gte() {
|
static void test_gte() {
|
||||||
const auto data = GTE::SVECTOR::create();
|
#define gte_MulMatrix0(r1,r2,r3) \
|
||||||
|
{ gte_SetRotMatrix(r1); \
|
||||||
|
gte_ldclmv(r2); \
|
||||||
|
gte_rtir(); \
|
||||||
|
gte_stclmv(r3); \
|
||||||
|
gte_ldclmv((char*)r2+2);\
|
||||||
|
gte_rtir(); \
|
||||||
|
gte_stclmv((char*)r3+2);\
|
||||||
|
gte_ldclmv((char*)r2+4);\
|
||||||
|
gte_rtir(); \
|
||||||
|
gte_stclmv((char*)r3+4); }
|
||||||
|
|
||||||
asm("# MY PLANSCHI START");
|
const auto m0 = GTE::MATRIX::identity();
|
||||||
GTE::ldv0(data);
|
const auto m1 = GTE::MATRIX::identity();
|
||||||
asm("# MY PLANSCHI END");
|
auto m2 = GTE::MATRIX::identity();
|
||||||
|
|
||||||
|
|
||||||
|
GTE::mult_matrix(m0, m1, m2);
|
||||||
asm("# THEIR PLANSCHI START");
|
asm("# THEIR PLANSCHI START");
|
||||||
gte_ldv0(&data);
|
gte_MulMatrix0(&m0, &m1, &m2);
|
||||||
asm("# THEIR PLANSCHI END");
|
asm("# THEIR PLANSCHI END");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
#include "gte_instruction.hpp"
|
||||||
|
#include <PSX/GTE/gte.hpp>
|
||||||
|
|
||||||
|
namespace JabyEngine {
|
||||||
|
namespace GTE {
|
||||||
|
void rot_trans(const SVECTOR& input, VECTOR& output, int32_t& flag) {
|
||||||
|
ldv0(input);
|
||||||
|
rt();
|
||||||
|
stlvnl(output);
|
||||||
|
stflg(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_rot_matrix(const MATRIX& matrix) {
|
||||||
|
__asm__ volatile("lw $12, 0(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("lw $13, 4(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("ctc2 $12, $0" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("ctc2 $13, $1" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("lw $12, 8(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("lw $13, 12(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("lw $14, 16(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("ctc2 $12, $2" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("ctc2 $13, $3" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("ctc2 $14, $4" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_trans_matrix(const MATRIX& matrix) {
|
||||||
|
__asm__ volatile("lw $12, 20(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("lw $13, 24(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("ctc2 $12, $5" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("lw $14, 28(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("ctc2 $13, $6" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
__asm__ volatile("ctc2 $14, $7" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||||
|
}
|
||||||
|
|
||||||
|
MATRIX& mult_matrix(const MATRIX& m0, const MATRIX& m1, MATRIX& result) {
|
||||||
|
/*
|
||||||
|
Jaby: Somehow this code creates stack usage.... Investigate!!
|
||||||
|
*/
|
||||||
|
asm("# MY PLANSCHI START");
|
||||||
|
set_rot_matrix(m0);
|
||||||
|
|
||||||
|
ldclmv(m1, 0);
|
||||||
|
rtir();
|
||||||
|
stclmv(result, 0);
|
||||||
|
|
||||||
|
ldclmv(m1, 1);
|
||||||
|
rtir();
|
||||||
|
stclmv(result, 1);
|
||||||
|
|
||||||
|
ldclmv(m1, 2);
|
||||||
|
rtir();
|
||||||
|
stclmv(result, 2);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
asm("# MY PLANSCHI END");
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_geom_offset(int32_t off_x, int32_t off_y) {
|
||||||
|
__asm__ volatile("sll $12, %0, 16" :: "r"(off_x), "r"(off_y) : "$12", "$13");
|
||||||
|
__asm__ volatile("sll $13, %1, 16" :: "r"(off_x), "r"(off_y) : "$12", "$13");
|
||||||
|
__asm__ volatile("ctc2 $12, $24" :: "r"(off_x), "r"(off_y) : "$12", "$13");
|
||||||
|
__asm__ volatile("ctc2 $13, $25" :: "r"(off_x), "r"(off_y) : "$12", "$13");
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_geom_screen(int32_t h) {
|
||||||
|
__asm__ volatile("ctc2 %0, $26" :: "r"(h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "gte_types.hpp"
|
#include <PSX/GTE/gte_types.hpp>
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace GTE {
|
namespace GTE {
|
Loading…
Reference in New Issue