Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
upload.c
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2026 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27// GP0(0xA0) CPU-to-VRAM upload under the E6 mask setting. Same rules as the
28// GP0(0x80) copy in copy.c: set-mask forces bit 15 on every uploaded pixel,
29// and check-mask leaves destination pixels that already have bit 15 set alone.
30// rasterFillRect is the GP0(0xA0) upload, so the tests below drive it with
31// E6 set, and prepare destinations with E6 clear.
32
33// clang-format off
34
35// --------------------------------------------------------------------------
36// 6. The upload honors set-mask: 0x001F lands as 0x801F, and 0x0000 lands as
37// 0x8000, so an uploaded transparent CLUT entry becomes opaque black.
38// --------------------------------------------------------------------------
39CESTER_TEST(vram_upload_honors_set_mask, gpu_vram_move,
40 rasterReset();
41 rasterClearTestRegion(0, 0, 128, 64);
42 rasterSetMaskCtrl(1, 0); // set-mask on
43 rasterFillRect(16, 8, 8, 8, RASTER_VRAM_RED);
44 rasterFillRect(32, 8, 8, 8, 0x0000);
45 rasterSetMaskCtrl(0, 0);
47 ASSERT_PIXEL_EQ(0x8000, 34, 10);
49)
50
51// --------------------------------------------------------------------------
52// 7. The upload honors check-mask: a destination pixel with bit 15 set keeps
53// its value, one with bit 15 clear takes the uploaded pixel.
54// --------------------------------------------------------------------------
55CESTER_TEST(vram_upload_honors_check_mask, gpu_vram_move,
56 rasterReset();
57 rasterClearTestRegion(0, 0, 128, 64);
58 rasterFillRect(16, 8, 8, 8, VM_GREEN_MASKED); // protected
59 rasterFillRect(24, 8, 8, 8, RASTER_VRAM_GREEN); // not protected
60 rasterSetMaskCtrl(0, 1); // check-mask on
61 rasterFillRect(16, 8, 16, 8, RASTER_VRAM_RED);
62 rasterSetMaskCtrl(0, 0);
65)
66
67// --------------------------------------------------------------------------
68// 8. Both bits on: protected pixels keep their value, the others take the
69// uploaded pixel with bit 15 forced.
70// --------------------------------------------------------------------------
71CESTER_TEST(vram_upload_honors_set_and_check_mask, gpu_vram_move,
72 rasterReset();
73 rasterClearTestRegion(0, 0, 128, 64);
74 rasterFillRect(16, 8, 8, 8, VM_GREEN_MASKED);
75 rasterFillRect(24, 8, 8, 8, RASTER_VRAM_GREEN);
76 rasterSetMaskCtrl(1, 1);
77 rasterFillRect(16, 8, 16, 8, RASTER_VRAM_RED);
78 rasterSetMaskCtrl(0, 0);
81)
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
#define VM_RED_MASKED
#define VM_GREEN_MASKED
#define RASTER_VRAM_GREEN
Definition raster-helpers.h:127
#define ASSERT_PIXEL_UNTOUCHED(x_, y_)
Definition raster-helpers.h:486
#define RASTER_VRAM_RED
Definition raster-helpers.h:125
#define ASSERT_PIXEL_EQ(expected, x_, y_)
Definition raster-helpers.h:473