diff --git a/src/fixed/common.cpp b/src/fixed/common.cpp index 84d104ab..bf474ad1 100644 --- a/src/fixed/common.cpp +++ b/src/fixed/common.cpp @@ -1335,6 +1335,28 @@ void matrixRotateYXZ_c(int32 angleX, int32 angleY, int32 angleZ) if (angleZ) matrixRotateZ(angleZ); } +void matrixFrame_c(const void* pos, const void* angles) +{ + int16 aX, aY, aZ; + DECODE_ANGLES(*(uint32*)angles, aX, aY, aZ); + + uint32 xy = ((uint32*)pos)[0]; + uint32 zu = ((uint32*)pos)[1]; + +#ifdef CPU_BIG_ENDIAN + int32 posX = int16(xy >> 16); + int32 posY = int16(xy & 0xFFFF); + int32 posZ = int16(zu >> 16); +#else + int32 posX = int16(xy & 0xFFFF); + int32 posY = int16(xy >> 16); + int32 posZ = int16(zu & 0xFFFF); +#endif + + matrixTranslateRel(posX, posY, posZ); + matrixRotateYXZ(aX, aY, aZ); +} + void boxTranslate_c(AABBi &box, int32 x, int32 y, int32 z) { box.minX += x; @@ -1374,28 +1396,6 @@ void boxRotateYQ_c(AABBi &box, int32 quadrant) } #endif -void matrixFrame(const void* pos, const void* angles) -{ - int16 aX, aY, aZ; - DECODE_ANGLES(*(uint32*)angles, aX, aY, aZ); - - uint32 xy = ((uint32*)pos)[0]; - uint32 zu = ((uint32*)pos)[1]; - -#ifdef CPU_BIG_ENDIAN - int32 posX = int16(xy >> 16); - int32 posY = int16(xy & 0xFFFF); - int32 posZ = int16(zu >> 16); -#else - int32 posX = int16(xy & 0xFFFF); - int32 posY = int16(xy >> 16); - int32 posZ = int16(zu & 0xFFFF); -#endif - - matrixTranslateRel(posX, posY, posZ); - matrixRotateYXZ(aX, aY, aZ); -} - void matrixFrameLerp(const void* pos, const void* anglesA, const void* anglesB, int32 delta, int32 rate) { int16 aX, aY, aZ; diff --git a/src/fixed/common.h b/src/fixed/common.h index f8e2e540..62ca36c1 100644 --- a/src/fixed/common.h +++ b/src/fixed/common.h @@ -2649,6 +2649,7 @@ vec3i boxPushOut(const AABBi &a, const AABBi &b); void matrixRotateZ_asm(int32 angle); void matrixRotateYQ_asm(int32 quadrant); void matrixRotateYXZ_asm(int32 angleX, int32 angleY, int32 angleZ); + void matrixFrame_asm(const void* pos, const void* angles); void boxTranslate_asm(AABBi &box, int32 x, int32 y, int32 z); void boxRotateYQ_asm(AABBi &box, int32 quadrant); int32 sphereIsVisible_asm(int32 x, int32 y, int32 z, int32 r); @@ -2667,6 +2668,7 @@ vec3i boxPushOut(const AABBi &a, const AABBi &b); #define matrixRotateZ matrixRotateZ_asm #define matrixRotateYXZ matrixRotateYXZ_asm #define matrixRotateYQ matrixRotateYQ_asm + #define matrixFrame matrixFrame_asm #define boxTranslate boxTranslate_asm #define boxRotateYQ boxRotateYQ_asm #define sphereIsVisible sphereIsVisible_asm @@ -2684,6 +2686,7 @@ vec3i boxPushOut(const AABBi &a, const AABBi &b); #define matrixRotateZ matrixRotateZ_c #define matrixRotateYXZ matrixRotateYXZ_c #define matrixRotateYQ matrixRotateYQ_c + #define matrixFrame matrixFrame_c #define boxTranslate boxTranslate_c #define boxRotateYQ boxRotateYQ_c #define sphereIsVisible sphereIsVisible_c @@ -2701,6 +2704,7 @@ vec3i boxPushOut(const AABBi &a, const AABBi &b); void matrixRotateZ_c(int32 angle); void matrixRotateYQ_c(int32 quadrant); void matrixRotateYXZ_c(int32 angleX, int32 angleY, int32 angleZ); + void matrixFrame_c(const void* pos, const void* angles); void boxTranslate_c(AABBi &box, int32 x, int32 y, int32 z); void boxRotateYQ_c(AABBi &box, int32 quadrant); @@ -2771,7 +2775,7 @@ X_INLINE vec3i matrixGetDir(const Matrix &m) return _vec3i(m.e20, m.e21, m.e22); } -void matrixFrame(const void* pos, const void* angles); +void matrixFrame_c(const void* pos, const void* angles); void matrixFrameLerp(const void* pos, const void* anglesA, const void* anglesB, int32 delta, int32 rate); void matrixSetView(const vec3i &pos, int32 angleX, int32 angleY); diff --git a/src/platform/gba/asm/flush.s b/src/platform/gba/asm/flush.s index 5035c4a2..999f71a0 100644 --- a/src/platform/gba/asm/flush.s +++ b/src/platform/gba/asm/flush.s @@ -51,7 +51,7 @@ sprites .req index01 SP_SIZE = (8 * VERTEX_SIZEOF) + 4 SP_SPRITES = SP_SIZE - 4 -.extern rasterize_c, drawPoly +.extern drawPoly .global flush_asm flush_asm: diff --git a/src/platform/gba/asm/matrixFrame.s b/src/platform/gba/asm/matrixFrame.s new file mode 100644 index 00000000..d028d1f7 --- /dev/null +++ b/src/platform/gba/asm/matrixFrame.s @@ -0,0 +1,39 @@ +#include "common_asm.inc" + +pos .req r0 // arg +angles .req r1 // arg +x .req pos +y .req angles +z .req r2 +packed .req r12 + +.extern matrixTranslateRel_asm, matrixRotateYXZ_asm + +.global matrixFrame_asm +matrixFrame_asm: + stmfd sp!, {lr} + + ldr packed, [angles] + ldrsh z, [pos, #4] + ldrsh y, [pos, #2] + ldrsh x, [pos, #0] + + bl matrixTranslateRel_asm // doesn't affect user mode r12 + + lsl z, packed, #22 + asr z, #16 + + lsr packed, #10 + + lsl y, packed, #22 + asr y, #16 + + lsr packed, #10 + + lsl x, packed, #22 + asr x, #16 + + ldmfd sp!, {lr} + b matrixRotateYXZ_asm + +// TODO matrixFrameLerp \ No newline at end of file