94 lines
4.7 KiB
C++
94 lines
4.7 KiB
C++
#pragma once
|
|
#include "gte_types.hpp"
|
|
|
|
#ifdef __INTELLISENSE__
|
|
// Load vertex or normal to vertex register 0
|
|
void __jaby_engine_gte_ldv0(const JabyEngine::GTE::SVECTOR& vector);
|
|
|
|
// Load vertex or normal to vertex register 1
|
|
void __jaby_engine_gte_ldv1(const JabyEngine::GTE::SVECTOR& vector);
|
|
|
|
// Load vertex or normal to vertex register 2
|
|
void __jaby_engine_gte_ldv2(const JabyEngine::GTE::SVECTOR& vector);
|
|
|
|
// Load column vector of JabyEngine::GTE::MATRIX to universal register
|
|
void __jaby_engine_gte_ldclmv(const JabyEngine::GTE::MATRIX& matrix, size_t col);
|
|
|
|
// Store flag
|
|
void __jaby_engine_gte_stflg(int32_t& flag);
|
|
|
|
// Store JabyEngine::GTE::MATRIX column from 16 bit universal register
|
|
void __jaby_engine_gte_stclmv(JabyEngine::GTE::MATRIX& matrix, size_t col);
|
|
|
|
// Store VECTOR from 32 bit universal register
|
|
void __jaby_engine_gte_stlvnl(JabyEngine::GTE::VECTOR& out_vector);
|
|
|
|
/*
|
|
Kernel of RotTrans
|
|
(Transfer vector)+(Rotation Matrix)*(vertex register 0)
|
|
*/
|
|
void __jaby_engine_gte_rt();
|
|
|
|
/*
|
|
Variation of gte_rt
|
|
(Rotation Matrix)*(16 bit universal vector)
|
|
*/
|
|
void __jaby_engine_gte_rtir();
|
|
#else
|
|
#define __jaby_engine_gte_ldv0(vector) { \
|
|
__asm__ volatile("lwc2 $0, 0(%0)" :: "r"(&vector)); \
|
|
__asm__ volatile("lwc2 $1, 4(%0)" :: "r"(&vector)); \
|
|
}
|
|
|
|
#define __jaby_engine_gte_ldv1(vector) { \
|
|
__asm__ volatile("lwc2 $2, 0(%0)" :: "r"(&vector)); \
|
|
__asm__ volatile("lwc2 $3, 4(%0)" :: "r"(&vector)); \
|
|
}
|
|
|
|
#define __jaby_engine_gte_ldv2(vector) { \
|
|
__asm__ volatile("lwc2 $4, 0(%0)" :: "r"(&vector)); \
|
|
__asm__ volatile("lwc2 $5, 4(%0)" :: "r"(&vector)); \
|
|
}
|
|
|
|
#define __jaby_engine_gte_ldclmv(matrix, col) { \
|
|
__asm__ volatile("lhu $12, 0(%0)" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14"); \
|
|
__asm__ volatile("lhu $13, 6(%0)" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14"); \
|
|
__asm__ volatile("lhu $14, 12(%0)" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14"); \
|
|
__asm__ volatile("mtc2 $12, $9" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14"); \
|
|
__asm__ volatile("mtc2 $13, $10" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14"); \
|
|
__asm__ volatile("mtc2 $14, $11" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14"); \
|
|
}
|
|
|
|
#define __jaby_engine_gte_stflg(flag) { \
|
|
__asm__ volatile("cfc2 $12, $31" :: "r"(&flag) : "$12", "memory"); \
|
|
__asm__ volatile("nop" :: "r"(&flag) : "$12", "memory"); \
|
|
__asm__ volatile("sw $12, 0(%0)" :: "r"(&flag) : "$12", "memory"); \
|
|
}
|
|
|
|
#define __jaby_engine_gte_stclmv(matrix, col) { \
|
|
__asm__ volatile("mfc2 $12, $9" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14", "memory"); \
|
|
__asm__ volatile("mfc2 $13, $10" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14", "memory"); \
|
|
__asm__ volatile("mfc2 $14, $11" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14", "memory"); \
|
|
__asm__ volatile("sh $12, 0(%0)" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14", "memory"); \
|
|
__asm__ volatile("sh $13, 6(%0)" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14", "memory"); \
|
|
__asm__ volatile("sh $14, 12(%0)" :: "r"(reinterpret_cast<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14", "memory"); \
|
|
}
|
|
|
|
#define __jaby_engine_gte_stlvnl(out_vector) { \
|
|
__asm__ volatile("swc2 $25, 0(%0)" :: "r"(&out_vector) : "memory"); \
|
|
__asm__ volatile("swc2 $26, 4(%0)" :: "r"(&out_vector) : "memory"); \
|
|
__asm__ volatile("swc2 $27, 8(%0)" :: "r"(&out_vector) : "memory"); \
|
|
}
|
|
|
|
#define __jaby_engine_gte_rt() { \
|
|
__asm__ volatile("nop"); \
|
|
__asm__ volatile("nop"); \
|
|
__asm__ volatile("cop2 0x0480012"); \
|
|
}
|
|
|
|
#define __jaby_engine_gte_rtir() { \
|
|
__asm__ volatile("nop"); \
|
|
__asm__ volatile("nop"); \
|
|
__asm__ volatile("cop2 0x049E012"); \
|
|
}
|
|
#endif |