Use accessors for offsetx/y.

This commit is contained in:
Unknown W. Brackets 2013-09-14 11:06:48 -07:00
parent 606e2f2802
commit 7b2dea4429
3 changed files with 16 additions and 10 deletions

View File

@ -371,8 +371,8 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
int regionX2 = gstate_c.curRTWidth;
int regionY2 = gstate_c.curRTHeight;
float offsetX = (float)(gstate.offsetx & 0xFFFF) / 16.0f;
float offsetY = (float)(gstate.offsety & 0xFFFF) / 16.0f;
float offsetX = gstate.getOffsetX();
float offsetY = gstate.getOffsetY();
if (throughmode) {
// No viewport transform here. Let's experiment with using region.

View File

@ -354,8 +354,14 @@ struct GPUgstate
int getRegionY1() const { return (region1 >> 10) & 0x3FF; }
int getRegionX2() const { return (region2 & 0x3FF); }
int getRegionY2() const { return (region2 >> 10) & 0x3FF; }
float getViewportX1() const { return fabsf(getFloat24(viewportx1) * 2.0f); }
float getViewportY1() const { return fabsf(getFloat24(viewporty1) * 2.0f); }
float getViewportX1() const { return fabsf(getFloat24(viewportx1) * 2.0f); }
float getViewportY1() const { return fabsf(getFloat24(viewporty1) * 2.0f); }
// Fixed 16 point.
int getOffsetX16() const { return offsetx & 0xFFFF; }
// Fixed 16 point.
int getOffsetY16() const { return offsety & 0xFFFF; }
float getOffsetX() const { return (float)getOffsetX16() / 16.0f; }
float getOffsetY() const { return (float)getOffsetY16() / 16.0f; }
// Vertex type
bool isModeThrough() const { return (vertType & GE_VTYPE_THROUGH) != 0; }

View File

@ -80,8 +80,8 @@ DrawingCoords TransformUnit::ScreenToDrawing(const ScreenCoords& coords)
{
DrawingCoords ret;
// TODO: What to do when offset > coord?
ret.x = (((u32)coords.x - (gstate.offsetx&0xffff))/16) & 0x3ff;
ret.y = (((u32)coords.y - (gstate.offsety&0xffff))/16) & 0x3ff;
ret.x = (((u32)coords.x - gstate.getOffsetX16())/16) & 0x3ff;
ret.y = (((u32)coords.y - gstate.getOffsetY16())/16) & 0x3ff;
ret.z = coords.z;
return ret;
}
@ -89,8 +89,8 @@ DrawingCoords TransformUnit::ScreenToDrawing(const ScreenCoords& coords)
ScreenCoords TransformUnit::DrawingToScreen(const DrawingCoords& coords)
{
ScreenCoords ret;
ret.x = (((u32)coords.x * 16 + (gstate.offsetx&0xffff)));
ret.y = (((u32)coords.y * 16 + (gstate.offsety&0xffff)));
ret.x = (((u32)coords.x * 16 + gstate.getOffsetX16()));
ret.y = (((u32)coords.y * 16 + gstate.getOffsetY16()));
ret.z = coords.z;
return ret;
}
@ -167,8 +167,8 @@ static VertexData ReadVertex(VertexReader& vreader)
Lighting::Process(vertex);
} else {
vertex.screenpos.x = (u32)pos[0] * 16 + (gstate.offsetx&0xffff);
vertex.screenpos.y = (u32)pos[1] * 16 + (gstate.offsety&0xffff);
vertex.screenpos.x = (u32)pos[0] * 16 + gstate.getOffsetX16();
vertex.screenpos.y = (u32)pos[1] * 16 + gstate.getOffsetY16();
vertex.screenpos.z = pos[2];
vertex.clippos.w = 1.f;
}