summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/BPFunctions.cpp
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-05-03 12:45:10 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2014-05-20 11:14:00 -0400
commite81b62aad14ec9ef2532b4d5423e2dad69e08b6e (patch)
tree472c52f02b67dddfb3e997b6f9f89d8faf1896f6 /Source/Core/VideoCommon/BPFunctions.cpp
parentada6434b8ef8794bb6c7476726fb014299bbdd06 (diff)
BPFunctions: Clean up math slightly
No need for magic 342 numbers.
Diffstat (limited to 'Source/Core/VideoCommon/BPFunctions.cpp')
-rw-r--r--Source/Core/VideoCommon/BPFunctions.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/Source/Core/VideoCommon/BPFunctions.cpp b/Source/Core/VideoCommon/BPFunctions.cpp
index 0b468d1cf8..aa2343d97a 100644
--- a/Source/Core/VideoCommon/BPFunctions.cpp
+++ b/Source/Core/VideoCommon/BPFunctions.cpp
@@ -34,11 +34,22 @@ void SetGenerationMode()
void SetScissor()
{
- const int xoff = bpmem.scissorOffset.x * 2 - 342;
- const int yoff = bpmem.scissorOffset.y * 2 - 342;
-
- EFBRectangle rc (bpmem.scissorTL.x - xoff - 342, bpmem.scissorTL.y - yoff - 342,
- bpmem.scissorBR.x - xoff - 341, bpmem.scissorBR.y - yoff - 341);
+ /* NOTE: the minimum value here for the scissor rect and offset is -342.
+ * GX internally adds on an offset of 342 to both the offset and scissor
+ * coords to ensure that the register was always unsigned.
+ *
+ * The code that was here before tried to "undo" this offset, but
+ * since we always take the difference, the +342 added to both
+ * sides cancels out. */
+
+ /* The scissor offset is always even, so to save space, the scissor offset
+ * register is scaled down by 2. So, if somebody calls
+ * GX_SetScissorBoxOffset(20, 20); the registers will be set to 10, 10. */
+ const int xoff = bpmem.scissorOffset.x * 2;
+ const int yoff = bpmem.scissorOffset.y * 2;
+
+ EFBRectangle rc (bpmem.scissorTL.x - xoff, bpmem.scissorTL.y - yoff,
+ bpmem.scissorBR.x - xoff + 1, bpmem.scissorBR.y - yoff + 1);
if (rc.left < 0) rc.left = 0;
if (rc.top < 0) rc.top = 0;