Add sin/cos support

This commit is contained in:
2024-01-31 21:29:57 -05:00
parent a7b5e35916
commit d9aa03e6fe
5 changed files with 79 additions and 5 deletions

View File

@@ -15,7 +15,7 @@ namespace JabyEngine {
output: Output vector
flag: flag output
*/
void rot_trans(const SVECTOR& input, VECTOR& output, int32_t& flag) {
static void rot_trans(const SVECTOR& input, VECTOR& output, int32_t& flag) {
ldv0(input);
rt();
stlvnl(output);
@@ -28,7 +28,7 @@ namespace JabyEngine {
Sets a 3x3 matrix m as a constant rotation matrix.
matrix: The rotation matrix to set
*/
void set_rot_matrix(const MATRIX& matrix) {
static 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");
@@ -46,7 +46,7 @@ namespace JabyEngine {
Sets a constant parallel transfer vector specified by m
*/
void set_trans_matrix(const MATRIX& matrix) {
static 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");
@@ -73,7 +73,7 @@ namespace JabyEngine {
Load GTE-offset.
*/
void set_geom_offset(int32_t off_x, int32_t off_y) {
static 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");
@@ -85,7 +85,7 @@ namespace JabyEngine {
Load distance from viewpoint to screen.
*/
void set_geom_screen(int32_t h) {
static void set_geom_screen(int32_t h) {
__asm__ volatile("ctc2 %0, $26" :: "r"(h));
}
}

View File

@@ -1,5 +1,6 @@
#pragma once
#include "../GPU/gpu_types.hpp"
#include "../../math.h"
namespace JabyEngine {
namespace GTE {
@@ -49,5 +50,24 @@ namespace JabyEngine {
using VECTOR = internal::VECTOR<int32_t>;
using SVECTOR = internal::VECTOR<int16_t>;
static constexpr auto one_degree = FULL_CIRCLE/360;
static constexpr auto one_tenth_degree = FULL_CIRCLE/3600;
static constexpr int16_t in_degree(int32_t degree) {
return degree*one_degree;
}
static constexpr int16_t in_degree10(int32_t degree) {
return degree*one_tenth_degree;
}
}
static constexpr unsigned long long operator""_DEG(unsigned long long degree) {
return GTE::in_degree(degree);
}
static constexpr unsigned long long operator""_DEG10(unsigned long long degree) {
return GTE::in_degree10(degree);
}
}