Nugget
Loading...
Searching...
No Matches
gte-gpf-gpl.c
Go to the documentation of this file.
1// GPF: general purpose interpolation (IR0 * IR -> MAC/IR, push color)
2// GPL: general purpose interpolation with base (MAC + IR0 * IR -> MAC/IR, push color)
3
4CESTER_TEST(gpf_shifted_unity, gte_tests,
5 cop2_put(8, 0x1000); // IR0 = 1.0
6 cop2_put(9, 100);
7 cop2_put(10, 200);
8 cop2_put(11, 300);
9 cop2_put(6, 0x00204060); // RGBC
11 cop2_cmd(COP2_GPF(1, 0));
12 int32_t mac1, mac2, mac3;
13 cop2_get(25, mac1);
14 cop2_get(26, mac2);
15 cop2_get(27, mac3);
19)
20
21CESTER_TEST(gpf_shifted_half, gte_tests,
22 cop2_put(8, 0x0800); // IR0 = 0.5
23 cop2_put(9, 1000);
24 cop2_put(10, 2000);
25 cop2_put(11, 4000);
26 cop2_put(6, 0x00808080);
29 int32_t mac1, mac2, mac3;
33 // IR0*IR >> 12 = 0x800*IR >> 12 = IR/2
37)
38
39// GPF pushes color FIFO
40CESTER_TEST(gpf_color_fifo_push, gte_tests,
41 cop2_put(8, 0x1000); // IR0 = 1.0
42 cop2_put(9, 0x0800); // IR1 -> MAC1=0x800, /16=128
43 cop2_put(10, 0x0400); // IR2 -> MAC2=0x400, /16=64
44 cop2_put(11, 0x0200); // IR3 -> MAC3=0x200, /16=32
45 cop2_put(6, 0xaa000000); // RGBC: CODE=0xaa
47 cop2_cmd(COP2_GPF(1, 0));
49 cop2_get(22, rgb2);
50 uint8_t r = rgb2 & 0xff;
51 uint8_t g = (rgb2 >> 8) & 0xff;
52 uint8_t b = (rgb2 >> 16) & 0xff;
53 uint8_t cd = (rgb2 >> 24) & 0xff;
54 ramsyscall_printf("GPF color: R=%u G=%u B=%u CD=0x%02x\n", r, g, b, cd);
55 cester_assert_uint_eq(0xaa, cd); // CODE byte preserved
56 // R = MAC1/16 = 0x800/16 = 128
60)
61
62// GPF unshifted (sf=0)
63CESTER_TEST(gpf_unshifted, gte_tests,
64 cop2_put(8, 2); // IR0 = 2
65 cop2_put(9, 100);
66 cop2_put(10, 200);
67 cop2_put(11, 300);
68 cop2_put(6, 0x00808080);
71 int32_t mac1, mac2, mac3;
72 cop2_get(25, mac1);
73 cop2_get(26, mac2);
74 cop2_get(27, mac3);
75 // sf=0: no shift, MAC = IR0*IR
79)
80
81// GPL shifted with base
83 cop2_put(25, 1000); // MAC1 base
84 cop2_put(26, 2000); // MAC2 base
85 cop2_put(27, 3000); // MAC3 base
86 cop2_put(8, 0x1000); // IR0 = 1.0
87 cop2_put(9, 100);
88 cop2_put(10, 200);
89 cop2_put(11, 300);
90 cop2_put(6, 0x00808080);
92 cop2_cmd(COP2_GPL(1, 0));
93 int32_t mac1, mac2, mac3;
94 cop2_get(25, mac1);
95 cop2_get(26, mac2);
96 cop2_get(27, mac3);
97 // GPL sf=1: MAC_new = (MAC_old << 12 + IR0 * IR) >> 12
98 // = ((1000<<12) + 4096*100) >> 12 = (4096000+409600)>>12 = 1100
102)
103
104// GPL unshifted (sf=0): MAC base used as-is, no shift
105CESTER_TEST(gpl_unshifted, gte_tests,
106 cop2_put(25, 100);
107 cop2_put(26, 200);
108 cop2_put(27, 300);
109 cop2_put(8, 3); // IR0 = 3
110 cop2_put(9, 10);
111 cop2_put(10, 20);
112 cop2_put(11, 30);
113 cop2_put(6, 0x00808080);
116 int32_t mac1, mac2, mac3;
117 cop2_get(25, mac1);
118 cop2_get(26, mac2);
119 cop2_get(27, mac3);
120 // sf=0: MAC_new = MAC_old + IR0*IR = 100+30=130, 200+60=260, 300+90=390
124)
125
126// GPL pushes color FIFO
127CESTER_TEST(gpl_color_fifo, gte_tests,
128 cop2_put(25, 0);
129 cop2_put(26, 0);
130 cop2_put(27, 0);
131 cop2_put(8, 0x1000);
132 cop2_put(9, 0x0ff0); // /16 = 255
133 cop2_put(10, 0x0800); // /16 = 128
134 cop2_put(11, 0x0010); // /16 = 1
135 cop2_put(6, 0x55000000); // CODE=0x55
137 cop2_cmd(COP2_GPL(1, 0));
139 cop2_get(22, rgb2);
140 uint8_t r = rgb2 & 0xff;
141 uint8_t g = (rgb2 >> 8) & 0xff;
142 uint8_t b = (rgb2 >> 16) & 0xff;
143 uint8_t cd = (rgb2 >> 24) & 0xff;
148)
cester_assert_uint_eq(1, *ptr)
#define cop2_cmd(op)
Definition cop2.h:175
#define COP2_GPL(sf, lm)
Definition cop2.h:169
#define cop2_put(reg, val)
Definition cop2.h:182
#define COP2_GPF(sf, lm)
Definition cop2.h:168
#define cop2_get(reg, dest)
Definition cop2.h:189
uint32_t r
Definition cpu.c:222
uint8_t g
Definition gte-depthcue.c:38
uint8_t cd
Definition gte-depthcue.c:206
uint8_t b
Definition gte-depthcue.c:39
uint32_t rgb2
Definition gte-depthcue.c:35
ramsyscall_printf("DCPL: MAC=(%d,%d,%d) RGB2=0x%08x\n", mac1, mac2, mac3, rgb2)
int32_t mac1
Definition gte-gpf-gpl.c:29
CESTER_TEST(gpf_shifted_unity, gte_tests, cop2_put(8, 0x1000);cop2_put(9, 100);cop2_put(10, 200);cop2_put(11, 300);cop2_put(6, 0x00204060);gte_clear_flag();cop2_cmd(COP2_GPF(1, 0));int32_t mac1, mac2, mac3;cop2_get(25, mac1);cop2_get(26, mac2);cop2_get(27, mac3);cester_assert_int_eq(100, mac1);cester_assert_int_eq(200, mac2);cester_assert_int_eq(300, mac3);) CESTER_TEST(gpf_shifted_half
cester_assert_int_eq(500, mac1)
gte_tests
Definition gte-gpf-gpl.c:21
int32_t mac2
Definition gte-gpf-gpl.c:29
gte_clear_flag()
int32_t mac3
Definition gte-gpf-gpl.c:29
void uint32_t(classId, spec)