-Added a very basic fix to the graphics scaling issue per adelikat's advice.

--Gets worse as the scale increases.
--For x3, the box doesn't increase size, but the box still changes position. I think there might be a difference between the TargetZoomFactor and the actual screen size, so perhaps we should tie this to something else.
-Working on very small optimizations to the NES PPU with CorruptedSyntax...this is more fun, so we'll do this first.
--Eliminated an entire loop.
--Branched to two loops instead of branching for every iteration in one loop.
--Got rid of some redundant instructions using temporary variables.
--This may be completely premature, but I seem to have gained a few FPS from doing this. For me, I get 38-39 FPS where I'd previously get 33-34.
This commit is contained in:
brandman211 2012-05-06 04:09:28 +00:00
parent 5fa0a681e1
commit 05157997f1
2 changed files with 20 additions and 34 deletions

View File

@ -167,17 +167,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo
oamcount = oamcounts[renderslot]; oamcount = oamcounts[renderslot];
//the main scanline rendering loop: //ok, we're also going to draw here.
//32 times, we will fetch a tile and then render 8 pixels. //unless we're on the first dummy scanline
//two of those tiles were read in the last scanline. if (sl != 0)
for (int xt = 0; xt < 32; xt++) //the main scanline rendering loop:
{ //32 times, we will fetch a tile and then render 8 pixels.
//ok, we're also going to draw here. //two of those tiles were read in the last scanline.
//unless we're on the first dummy scanline for (int xt = 0; xt < 32; xt++)
if (sl != 0)
{ {
int xstart = xt << 3; int xstart = xt << 3;
oamcount = oamcounts[renderslot]; oamcount = oamcounts[renderslot];
int target = (yp << 8) + xstart; int target = (yp << 8) + xstart;
@ -267,7 +264,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
{ {
Reg2002_objhit = true; Reg2002_objhit = true;
} }
bool drawsprite = true; bool drawsprite = true;
//priority handling //priority handling
if ((oam->oam[2] & 0x20) != 0) if ((oam->oam[2] & 0x20) != 0)
@ -278,7 +274,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
drawsprite = false; drawsprite = false;
} }
} }
if (drawsprite && nes.CoreInputComm.NES_ShowOBJ) if (drawsprite && nes.CoreInputComm.NES_ShowOBJ)
{ {
//bring in the palette bits and palettize //bring in the palette bits and palettize
@ -287,13 +282,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
pixelcolor = PALRAM[0x10 + spixel]; pixelcolor = PALRAM[0x10 + spixel];
} }
} //rasterpos in sprite range } //rasterpos in sprite range
} //c# fixed oam ptr } //c# fixed oam ptr
}//oamcount loop }//oamcount loop
if (reg_2001.color_disable) if (reg_2001.color_disable)
pixelcolor &= 0x30; pixelcolor &= 0x30;
@ -302,24 +292,21 @@ namespace BizHawk.Emulation.Consoles.Nintendo
target++; target++;
} //loop across 8 pixels } //loop across 8 pixels
} //scanline != 0 } //loop across 32 tiles
else else
{ for (int xt = 0; xt < 32; xt++)
Read_bgdata(ref bgdata[xt + 2]); Read_bgdata(ref bgdata[xt + 2]);
}
} //loop across 32 tiles
//look for sprites (was supposed to run concurrent with bg rendering) //look for sprites (was supposed to run concurrent with bg rendering)
oamcounts[scanslot] = 0; oamcounts[scanslot] = 0;
oamcount = 0; oamcount = 0;
int spriteHeight = reg_2000.obj_size_16 ? 16 : 8; int spriteHeight = reg_2000.obj_size_16 ? 16 : 8;
for (int i = 0; i < 64; i++) int scanslot_lshift = scanslot << 6;
oams[(scanslot<<6)+i].present = 0;
for (int i = 0; i < 64; i++) for (int i = 0; i < 64; i++)
{ {
oams[scanslot_lshift + i].present = 0;
int spr = i * 4; int spr = i * 4;
{ {
if (yp >= OAM[spr] && yp < OAM[spr] + spriteHeight) if (yp >= OAM[spr] && yp < OAM[spr] + spriteHeight)
@ -335,18 +322,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo
break; break;
} }
} }
//just copy some bytes into the internal sprite buffer //just copy some bytes into the internal sprite buffer
TempOAM* oam = &oams[(scanslot << 6) + oamcount]; TempOAM* oam = &oams[scanslot_lshift + oamcount];
{ {
for (int j = 0; j < 4; j++) for (int j = 0; j < 4; j++)
oam->oam[j] = OAM[spr + j]; oam->oam[j] = OAM[spr + j];
oam->present = 1; oam->present = 1;
} }
//note that we stuff the oam index into [6]. //note that we stuff the oam index into [6].
//i need to turn this into a struct so we can have fewer magic numbers //i need to turn this into a struct so we can have fewer magic numbers
oams[(scanslot<<6)+oamcount].index = (byte)i; oams[scanslot_lshift + oamcount].index = (byte)i;
oamcount++; oamcount++;
} }
} }

View File

@ -508,12 +508,13 @@ namespace BizHawk.MultiClient
{ {
try try
{ {
g.DrawRectangle(GetPen(line), LuaInt(X), LuaInt(Y), LuaInt(width), LuaInt(height)); int int_x = LuaInt(X) * Global.Config.TargetZoomFactor;
int int_y = LuaInt(Y) * Global.Config.TargetZoomFactor;
int int_width = LuaInt(width) * Global.Config.TargetZoomFactor;
int int_height = LuaInt(height) * Global.Config.TargetZoomFactor;
g.DrawRectangle(GetPen(line), int_x, int_y, int_width, int_height);
if (background != null) if (background != null)
{ g.FillRectangle(GetBrush(background), int_x, int_y, int_width, int_height);
g.FillRectangle(GetBrush(background), LuaInt(X), LuaInt(Y), LuaInt(width), LuaInt(height));
}
} }
catch(Exception e) catch(Exception e)
{ {