Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
gte-avsz.c
Go to the documentation of this file.
1// AVSZ3 / AVSZ4: Average Z value computation
2
3// clang-format off
4
5CESTER_TEST(avsz3_basic, gte_tests,
6 cop2_put(17, 100);
7 cop2_put(18, 200);
8 cop2_put(19, 300);
9 cop2_putc(29, 0x555); // ZSF3 ~ 4096/3
12 int32_t mac0;
13 uint32_t otz;
14 cop2_get(24, mac0);
15 cop2_get(7, otz);
17 cester_assert_uint_eq(199, otz);
18)
19
20CESTER_TEST(avsz4_basic, gte_tests,
21 cop2_put(16, 100);
22 cop2_put(17, 200);
23 cop2_put(18, 300);
24 cop2_put(19, 400);
25 cop2_putc(30, 0x400); // ZSF4 = 4096/4
28 int32_t mac0;
29 uint32_t otz;
30 cop2_get(24, mac0);
31 cop2_get(7, otz);
32 cester_assert_int_eq(1024000, mac0);
33 cester_assert_uint_eq(250, otz);
34)
35
36// Verify AVSZ3 uses SZ1+SZ2+SZ3, not SZ0+SZ1+SZ2
37CESTER_TEST(avsz3_uses_sz123, gte_tests,
38 cop2_put(16, 1000); // SZ0 - should be ignored
39 cop2_put(17, 2000); // SZ1
40 cop2_put(18, 3000); // SZ2
41 cop2_put(19, 4000); // SZ3
42 cop2_putc(29, 0x1000); // ZSF3 = 1.0 in 4.12
45 int32_t mac0;
46 cop2_get(24, mac0);
47 // SZ1+SZ2+SZ3 = 9000, * 4096 = 36864000
48 cester_assert_int_eq(36864000, mac0);
49)
50
51// OTZ saturation: result > 0xffff
52CESTER_TEST(avsz3_otz_saturate, gte_tests,
53 cop2_put(17, 0xffff);
54 cop2_put(18, 0xffff);
55 cop2_put(19, 0xffff);
56 cop2_putc(29, 0x1000);
59 uint32_t otz, flag;
60 cop2_get(7, otz);
61 flag = gte_read_flag();
62 cester_assert_uint_eq(0xffff, otz);
63 // FLAG.18 (OTZ saturation) should be set
64 uint32_t flag18 = (flag >> 18) & 1;
65 cester_assert_uint_eq(1, flag18);
66)
67
68// Negative ZSF producing negative MAC0
69CESTER_TEST(avsz3_negative_zsf, gte_tests,
70 cop2_put(17, 100);
71 cop2_put(18, 200);
72 cop2_put(19, 300);
73 cop2_putc(29, 0xf000); // ZSF3 = negative (sign-extended)
76 int32_t mac0;
77 uint32_t otz, flag;
78 cop2_get(24, mac0);
79 cop2_get(7, otz);
80 flag = gte_read_flag();
81 ramsyscall_printf("AVSZ3 neg ZSF: MAC0=%d OTZ=%u FLAG=0x%08x\n", mac0, otz, flag);
82 // Negative result should saturate OTZ to 0
84)
CESTER_TEST(cddaLevelHalf, test_instances, static const uint8_t atv[4]={0x40, 0x00, 0x40, 0x00};unsigned changes=0;int peak=cddaPeak(atv, 1, &changes);ramsyscall_printf("CD-DA level at half ATV: peak %i, %u sign changes\n", peak, changes);cester_assert_int_ge(peak, 11300);cester_assert_int_le(peak, 11800);cester_assert_uint_ge(changes, 4);) CESTER_TEST(cddaLevelClipped
cester_assert_uint_eq(5, cause1)
ramsyscall_printf("T21 phase=%s t=%u v=%02x cause=%u size=%u stat=%02x\n", phase, t/1000, response[0], cause, size,(nopCause==3 &&nopSize >=1) ? stat[0] :0xff)
#define cop2_cmd(op)
Definition cop2.h:175
#define cop2_put(reg, val)
Definition cop2.h:191
#define cop2_putc(reg, val)
Definition cop2.h:205
#define COP2_AVSZ3
Definition cop2.h:164
#define cop2_get(reg, dest)
Definition cop2.h:198
#define COP2_AVSZ4
Definition cop2.h:165
gte_tests
Definition gte-depthcue.c:31
gte_clear_flag()
uint32_t flag
Definition gte-edgecase.c:38
int32_t mac0
Definition gte-edgecase.c:151
cester_assert_int_eq(3, xaCommand(CDL_SETMODE, &mode, 1, NULL, NULL))