Nugget
Loading...
Searching...
No Matches
gte-avsz.c
Go to the documentation of this file.
1// AVSZ3 / AVSZ4: Average Z value computation
2
3CESTER_TEST(avsz3_basic, gte_tests,
4 cop2_put(17, 100);
5 cop2_put(18, 200);
6 cop2_put(19, 300);
7 cop2_putc(29, 0x555); // ZSF3 ~ 4096/3
10 int32_t mac0;
11 uint32_t otz;
12 cop2_get(24, mac0);
13 cop2_get(7, otz);
15 cester_assert_uint_eq(199, otz);
16)
17
18CESTER_TEST(avsz4_basic, gte_tests,
19 cop2_put(16, 100);
20 cop2_put(17, 200);
21 cop2_put(18, 300);
22 cop2_put(19, 400);
23 cop2_putc(30, 0x400); // ZSF4 = 4096/4
26 int32_t mac0;
27 uint32_t otz;
28 cop2_get(24, mac0);
29 cop2_get(7, otz);
30 cester_assert_int_eq(1024000, mac0);
31 cester_assert_uint_eq(250, otz);
32)
33
34// Verify AVSZ3 uses SZ1+SZ2+SZ3, not SZ0+SZ1+SZ2
35CESTER_TEST(avsz3_uses_sz123, gte_tests,
36 cop2_put(16, 1000); // SZ0 - should be ignored
37 cop2_put(17, 2000); // SZ1
38 cop2_put(18, 3000); // SZ2
39 cop2_put(19, 4000); // SZ3
40 cop2_putc(29, 0x1000); // ZSF3 = 1.0 in 4.12
43 int32_t mac0;
44 cop2_get(24, mac0);
45 // SZ1+SZ2+SZ3 = 9000, * 4096 = 36864000
46 cester_assert_int_eq(36864000, mac0);
47)
48
49// OTZ saturation: result > 0xffff
50CESTER_TEST(avsz3_otz_saturate, gte_tests,
51 cop2_put(17, 0xffff);
52 cop2_put(18, 0xffff);
53 cop2_put(19, 0xffff);
54 cop2_putc(29, 0x1000);
57 uint32_t otz, flag;
58 cop2_get(7, otz);
59 flag = gte_read_flag();
60 cester_assert_uint_eq(0xffff, otz);
61 // FLAG.18 (OTZ saturation) should be set
62 uint32_t flag18 = (flag >> 18) & 1;
63 cester_assert_uint_eq(1, flag18);
64)
65
66// Negative ZSF producing negative MAC0
67CESTER_TEST(avsz3_negative_zsf, gte_tests,
68 cop2_put(17, 100);
69 cop2_put(18, 200);
70 cop2_put(19, 300);
71 cop2_putc(29, 0xf000); // ZSF3 = negative (sign-extended)
74 int32_t mac0;
75 uint32_t otz, flag;
76 cop2_get(24, mac0);
77 cop2_get(7, otz);
78 flag = gte_read_flag();
79 ramsyscall_printf("AVSZ3 neg ZSF: MAC0=%d OTZ=%u FLAG=0x%08x\n", mac0, otz, flag);
80 // Negative result should saturate OTZ to 0
82)
CESTER_TEST(cpu_cop0_basic_write_bp, cpu_tests, uint32_t expectedEPC;uint32_t t;volatile uint32_t *ptr=(volatile uint32_t *) 0x58; *ptr=1;__asm__ volatile("" " lui %0, 0b1100101010000000\n" " mtc0 %0, $7\n" " li %0, 0x58\n" " mtc0 %0, $5\n" " li %0, 0xfffffff0\n" " mtc0 %0, $9\n" :"=r"(t));cester_assert_uint_eq(1, *ptr);__asm__ volatile("la %0, 1f\n1:\nsw $0, 0x58($0)" :"=r"(expectedEPC));__asm__ volatile("mtc0 $0, $7\n");cester_assert_uint_eq(0, *ptr);cester_assert_uint_eq(1, s_got40);cester_assert_uint_eq(0, s_got80);cester_assert_uint_eq(0x40, s_from);cester_assert_uint_eq(expectedEPC, s_epc);) CESTER_TEST(cpu_cop0_kseg_write_bp
cester_assert_uint_eq(1, *ptr)
#define cop2_cmd(op)
Definition cop2.h:175
#define cop2_put(reg, val)
Definition cop2.h:182
#define cop2_putc(reg, val)
Definition cop2.h:196
#define COP2_AVSZ3
Definition cop2.h:164
#define cop2_get(reg, dest)
Definition cop2.h:189
#define COP2_AVSZ4
Definition cop2.h:165
cester_assert_int_eq(0, hi)
gte_tests
Definition gte-depthcue.c:29
gte_clear_flag()
ramsyscall_printf("DCPL: MAC=(%d,%d,%d) RGB2=0x%08x\n", mac1, mac2, mac3, rgb2)
uint32_t flag
Definition gte-edgecase.c:36
int32_t mac0
Definition gte-edgecase.c:149
void uint32_t(classId, spec)