Browse Source

Interpolate vertex color and UV values using GTE instructions as well

master
Nico de Poel 3 years ago
parent
commit
d7ec9a85a4
  1. 35
      draw.h

35
draw.h

@ -5,6 +5,28 @@
#include "display.h" #include "display.h"
#include <inline_c.h> #include <inline_c.h>
#define gte_ld_intpol_cv0( r0 ) __asm__ volatile ( \
"lbu $12, 0( %0 );" \
"lbu $13, 1( %0 );" \
"lbu $14, 2( %0 );" \
"ctc2 $12, $21;" \
"ctc2 $13, $22;" \
"ctc2 $14, $23;" \
: \
: "r"( r0 ) \
: "$12", "$13", "$14" )
#define gte_ld_intpol_cv1( r0 ) __asm__ volatile ( \
"lbu $12, 0( %0 );" \
"lbu $13, 1( %0 );" \
"lbu $14, 2( %0 );" \
"mtc2 $12, $9;" \
"mtc2 $13, $10;" \
"mtc2 $13, $11;" \
: \
: "r"( r0 ) \
: "$12", "$13", "$14" )
// Macros for quickly blitting RGB and UV values with a single copy // Macros for quickly blitting RGB and UV values with a single copy
// This is faster than copying each value individually // This is faster than copying each value individually
#define setColorFast(pr, r) *((u_int*)(pr)) = *((u_int*)(r)) #define setColorFast(pr, r) *((u_int*)(pr)) = *((u_int*)(r))
@ -354,11 +376,14 @@ typedef struct _TMPVERT
gte_ld_intpol_sv0(&(src1).vx); \ gte_ld_intpol_sv0(&(src1).vx); \
gte_intpl(); \ gte_intpl(); \
gte_stsv(&(dst).vx); \ gte_stsv(&(dst).vx); \
(dst).r = (uint8_t)(((uint16_t)(src0).r + (uint16_t)(src1).r) >> 1); \
(dst).g = (uint8_t)(((uint16_t)(src0).g + (uint16_t)(src1).g) >> 1); \
(dst).b = (uint8_t)(((uint16_t)(src0).b + (uint16_t)(src1).b) >> 1); \
(dst).u = (uint8_t)(((uint16_t)(src0).u + (uint16_t)(src1).u) >> 1); \
(dst).v = (uint8_t)(((uint16_t)(src0).v + (uint16_t)(src1).v) >> 1);
gte_ld_intpol_cv1(&(src0).r); \
gte_ld_intpol_cv0(&(src1).r); \
gte_intpl(); \
gte_stcv(&(dst).r); \
gte_ld_intpol_uv1(&(src0).u); \
gte_ld_intpol_uv0(&(src1).u); \
gte_intpl(); \
gte_stbv(&(dst).u);
#define blitVert(dst, i, src) \ #define blitVert(dst, i, src) \
blit32(&(dst)->x ## i, &(src).vx); \ blit32(&(dst)->x ## i, &(src).vx); \

Loading…
Cancel
Save