Nugget
Loading...
Searching...
No Matches
raster-expected-phase10.h
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#pragma once
28
29// Phase-10 expected hardware-truth values. Initial placeholders are
30// best guesses; first hardware run captures the OBS log and patches
31// to HW_VERIFIED.
32//
33// Naming: LS_OCT<N> = flat shallow / steep line in octant N
34// LR = reverse-direction line
35// LC = clipped at draw-area edge
36// LG = gouraud line
37// LP = polyline
38// LST = semi-trans line
39
40#include "raster-helpers.h"
41
42// Octant 2: steep down-right (0,0) -> (3, 10). Bresenham at y=5
43// has x somewhere between 1 and 2. One of the two is drawn (the
44// other is sentinel); the OBS log will tell us which.
45#define LS_OCT2_Y5_X1 RASTER_VRAM_RED /* HW_TODO */
46#define LS_OCT2_Y5_X2 RASTER_SENTINEL /* HW_TODO */
47#define LS_OCT2_END RASTER_VRAM_RED /* HW_TODO endpoint inclusive */
48
49// Octant 3: steep down-left (10, 0) -> (7, 10). At y=5 Bresenham
50// midpoint x=8.5 - hardware picks x=8 (rounds down), x=9 reads sentinel.
51#define LS_OCT3_MID RASTER_SENTINEL /* (9, 5) - empty - Bresenham picks (8, 5) */
52#define LS_OCT3_END RASTER_VRAM_GREEN /* endpoint inclusive */
53
54// Octant 4: shallow down-left (10, 0) -> (0, 3).
55#define LS_OCT4_MID RASTER_VRAM_BLUE /* HW_TODO at (5, 1) */
56#define LS_OCT4_END RASTER_VRAM_BLUE /* HW_TODO */
57
58// Octant 5: shallow up-left (10, 10) -> (0, 7).
59#define LS_OCT5_MID RASTER_VRAM_WHITE /* HW_TODO */
60#define LS_OCT5_END RASTER_VRAM_WHITE /* HW_TODO */
61
62// Octant 6: steep up-left (10, 10) -> (7, 0). At y=5 x=8.5 -> hardware
63// picks (8, 5) same as octant 3 - vertical-step octant has same rounding.
64#define LS_OCT6_MID RASTER_SENTINEL /* (9, 5) - empty */
65#define LS_OCT6_END RASTER_VRAM_RED /* endpoint inclusive */
66
67// Octant 7: steep up-right (0, 10) -> (3, 0).
68#define LS_OCT7_MID RASTER_VRAM_GREEN /* HW_TODO at (1, 5) */
69#define LS_OCT7_END RASTER_VRAM_GREEN /* HW_TODO */
70
71// Octant 8: shallow up-right (0, 3) -> (10, 0). At x=5 y=1.5 -> picks
72// y=1, y=2 reads sentinel.
73#define LS_OCT8_MID RASTER_SENTINEL /* (5, 2) - empty - line passes through (5, 1) */
74#define LS_OCT8_END RASTER_VRAM_BLUE /* endpoint inclusive */
75
76// Reverse-direction endpoint inclusion. Phase-2 found the END vertex
77// is exclusive for forward-direction lines on Bresenham flat paths
78// (depends on the specific path - "INCLUSIVE" or "EXCLUSIVE" varies).
79// Reverse-direction may flip what counts as "end."
80#define LR_HORIZ_END RASTER_VRAM_RED /* HW_TODO */
81#define LR_VERT_END RASTER_VRAM_GREEN /* HW_TODO */
82
83// Clipping at draw-area X=12 (exclusive): pixel at x=11 is the last
84// inside-draw-area column.
85#define LC_RIGHT_JUST_INSIDE RASTER_VRAM_WHITE /* HW_TODO */
86#define LC_BOTTOM_JUST_INSIDE RASTER_VRAM_BLUE /* HW_TODO */
87
88// Gouraud line: red -> blue over 10 pixels.
89// (0, 5): pure red R=31 -> 0x001f
90// (5, 5): half R + half B -> 0x4010 nominally
91// (10, 5): pure blue -> 0x7c00
92// LG_MID: hardware drops 1 LSB on blue at midpoint (0x3c0f = B=15
93// instead of 0x400f = B=16). Same 8-bit-accumulator truncation pattern
94// as phase-7's gouraud findings, applied to the line color walker.
95#define LG_START 0x001fu /* pure R at start vertex */
96#define LG_MID 0x3c0fu /* B=15 - one LSB short of half-blend */
97#define LG_END 0x7c00u /* pure B at end vertex */
98
99// Polyline endpoint (last segment's terminal vertex).
100#define LP_END RASTER_VRAM_GREEN /* HW_TODO */
101
102// Semi-trans line over red background.
103// GP0(0x42) green-line semi-trans, ABR = 0 (0.5*FG + 0.5*BG)
104// FG = green = (R=0, G=31, B=0); BG = red = (R=31, G=0, B=0)
105// Blend per channel (0.5 each, hardware uses bit-shifted average):
106// R = (31 + 0) / 2 = 15
107// G = (0 + 31) / 2 = 15
108// B = 0
109// vram555(15, 15, 0) = 15 | (15 << 5) = 15 | 480 = 495 = 0x01ef
110#define LST_MID 0x01efu /* HW_TODO blended green/red */