Removes 4 unneeded values in the GL plugin, Makes less buffer underruns in ALSA in DSP_NULL, and case sensitivity so Wii games get just a 'wii' bit farther

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@216 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2008-08-14 23:04:24 +00:00
parent 7937befe73
commit 9b676c0a01
9 changed files with 45 additions and 46 deletions

View File

@ -211,26 +211,26 @@ bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
// load settings.txt // load settings.txt
{ {
std::string filename("wii/setting-eur.txt"); std::string filename("WII/setting-eur.txt");
if (VolumeHandler::IsValid()) if (VolumeHandler::IsValid())
{ {
switch(VolumeHandler::GetVolume()->GetCountry()) switch(VolumeHandler::GetVolume()->GetCountry())
{ {
case DiscIO::IVolume::COUNTRY_JAP: case DiscIO::IVolume::COUNTRY_JAP:
filename = "wii/setting-jpn.txt"; filename = "WII/setting-jpn.txt";
break; break;
case DiscIO::IVolume::COUNTRY_USA: case DiscIO::IVolume::COUNTRY_USA:
filename = "wii/setting-usa.txt"; filename = "WII/setting-usa.txt";
break; break;
case DiscIO::IVolume::COUNTRY_EUROPE: case DiscIO::IVolume::COUNTRY_EUROPE:
filename = "wii/setting-eur.txt"; filename = "WII/setting-eur.txt";
break; break;
default: default:
PanicAlert("Unknown country. Wii boot process will be switched to European settings."); PanicAlert("Unknown country. Wii boot process will be switched to European settings.");
filename = "wii/setting-eur.txt"; filename = "WII/setting-eur.txt";
break; break;
} }
} }

View File

@ -49,7 +49,7 @@ CWII_IPC_HLE_Device_FileIO::~CWII_IPC_HLE_Device_FileIO()
bool bool
CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress) CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress)
{ {
std::string Filename("wii"); std::string Filename("WII");
Filename += GetDeviceName(); Filename += GetDeviceName();
m_pFileHandle = fopen(Filename.c_str(), "r+b"); m_pFileHandle = fopen(Filename.c_str(), "r+b");

View File

@ -54,7 +54,8 @@ namespace AOSound
} }
return(false);*/ return(false);*/
ao_play(device, soundData, dwSoundBytes); if(soundData[0] != 0)
ao_play(device, soundData, dwSoundBytes);
return true; return true;
} }

View File

@ -541,7 +541,7 @@ bool SetScissorRect()
PRIM_LOG("scissor: lt=(%d,%d),rb=(%d,%d),off=(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom, xoff, yoff); PRIM_LOG("scissor: lt=(%d,%d),rb=(%d,%d),off=(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom, xoff, yoff);
if( rc.right>=rc.left && rc.bottom>=rc.top ) { if( rc.right>=rc.left && rc.bottom>=rc.top ) {
glScissor(rc.left<<g_AAx, Renderer::GetTargetHeight()-(rc.bottom<<g_AAy), (rc.right-rc.left)<<g_AAx, (rc.bottom-rc.top)<<g_AAy); glScissor(rc.left, Renderer::GetTargetHeight()-(rc.bottom), (rc.right-rc.left), (rc.bottom-rc.top));
return true; return true;
} }
@ -626,10 +626,10 @@ void LoadBPReg(u32 value0)
u32 nRestoreZBufferTarget = Renderer::GetZBufferTarget(); u32 nRestoreZBufferTarget = Renderer::GetZBufferTarget();
glViewport(0, 0, Renderer::GetTargetWidth()<<g_AAx, Renderer::GetTargetHeight()<<g_AAy); glViewport(0, 0, Renderer::GetTargetWidth(), Renderer::GetTargetHeight());
// if copied to texture, set the dimensions to the source copy dims, otherwise, clear the entire buffer // if copied to texture, set the dimensions to the source copy dims, otherwise, clear the entire buffer
if( PE_copy.copy_to_xfb == 0 ) if( PE_copy.copy_to_xfb == 0 )
glScissor(rc.left<<g_AAx, (Renderer::GetTargetHeight()-rc.bottom)<<g_AAy, (rc.right-rc.left)<<g_AAx, (rc.bottom-rc.top)<<g_AAy); glScissor(rc.left, (Renderer::GetTargetHeight()-rc.bottom), (rc.right-rc.left), (rc.bottom-rc.top));
VertexShaderMngr::SetViewportChanged(); VertexShaderMngr::SetViewportChanged();
// since clear operations use the source rectangle, have to do regular renders (glClear clears the entire buffer) // since clear operations use the source rectangle, have to do regular renders (glClear clears the entire buffer)

View File

@ -51,8 +51,6 @@ extern GLWindow GLWin;
// yeah yeah, these should be hidden // yeah yeah, these should be hidden
extern int nBackbufferWidth, nBackbufferHeight; extern int nBackbufferWidth, nBackbufferHeight;
extern u32 s_nTargetWidth, s_nTargetHeight;
extern u32 g_AAx, g_AAy;
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height); bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
bool OpenGL_MakeCurrent(); bool OpenGL_MakeCurrent();

View File

@ -152,7 +152,7 @@ bool Renderer::Create2()
for(int i = 0; i < ARRAYSIZE(s_RenderTargets); ++i) { for(int i = 0; i < ARRAYSIZE(s_RenderTargets); ++i) {
glBindTexture(GL_TEXTURE_RECTANGLE_NV, s_RenderTargets[i]); glBindTexture(GL_TEXTURE_RECTANGLE_NV, s_RenderTargets[i]);
// initialize to default // initialize to default
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 4, s_nTargetWidth, s_nTargetHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 4, nBackbufferWidth, nBackbufferHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if( glGetError() != GL_NO_ERROR) { if( glGetError() != GL_NO_ERROR) {
@ -174,7 +174,7 @@ bool Renderer::Create2()
// create zbuffer target // create zbuffer target
glGenTextures(1, (GLuint *)&s_ZBufferTarget); glGenTextures(1, (GLuint *)&s_ZBufferTarget);
glBindTexture(GL_TEXTURE_RECTANGLE_NV, s_ZBufferTarget); glBindTexture(GL_TEXTURE_RECTANGLE_NV, s_ZBufferTarget);
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 4, s_nTargetWidth, s_nTargetHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 4, nBackbufferWidth, nBackbufferHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
@ -190,9 +190,9 @@ bool Renderer::Create2()
// create the depth buffer // create the depth buffer
glGenRenderbuffersEXT( 1, (GLuint *)&s_DepthTarget); glGenRenderbuffersEXT( 1, (GLuint *)&s_DepthTarget);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, s_DepthTarget); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, s_DepthTarget);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, s_nTargetWidth, s_nTargetHeight); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, nBackbufferWidth, nBackbufferHeight);
if( glGetError() != GL_NO_ERROR ) { if( glGetError() != GL_NO_ERROR ) {
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, s_nTargetWidth, s_nTargetHeight); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, nBackbufferWidth, nBackbufferHeight);
s_bHaveStencilBuffer = false; s_bHaveStencilBuffer = false;
} }
else s_bHaveStencilBuffer = true; else s_bHaveStencilBuffer = true;
@ -310,7 +310,7 @@ bool Renderer::Initialize()
glStencilFunc(GL_ALWAYS, 0, 0); glStencilFunc(GL_ALWAYS, 0, 0);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glViewport(0,0,s_nTargetWidth,s_nTargetWidth); // Reset The Current Viewport glViewport(0,0,GetTargetWidth(),GetTargetHeight()); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
@ -448,10 +448,17 @@ void Renderer::ReinitView(int nNewWidth, int nNewHeight)
nBackbufferWidth = nNewWidth > 16 ? nNewWidth : 16; nBackbufferWidth = nNewWidth > 16 ? nNewWidth : 16;
nBackbufferHeight = nNewHeight > 16 ? nNewHeight : 16; nBackbufferHeight = nNewHeight > 16 ? nNewHeight : 16;
} }
//TODO: Return correct Values
int Renderer::GetTargetWidth() int Renderer::GetTargetWidth()
{ {
return s_nTargetWidth; return 640;
//return nBackbufferWidth;
}
int Renderer::GetTargetHeight()
{
return 480;
//return nBackbufferHeight;
} }
bool Renderer::CanBlendLogicOp() bool Renderer::CanBlendLogicOp()
@ -459,11 +466,6 @@ bool Renderer::CanBlendLogicOp()
return g_bBlendLogicOp; return g_bBlendLogicOp;
} }
int Renderer::GetTargetHeight()
{
return s_nTargetHeight;
}
void Renderer::SetRenderTarget(u32 targ) void Renderer::SetRenderTarget(u32 targ)
{ {
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, targ!=0?targ:s_RenderTargets[s_nCurTarget], 0 ); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, targ!=0?targ:s_RenderTargets[s_nCurTarget], 0 );
@ -538,7 +540,7 @@ void Renderer::FlushZBufferAlphaToTarget()
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
glViewport(0, 0, GetTargetWidth()<<g_AAx, GetTargetHeight()<<g_AAy); glViewport(0, 0, GetTargetWidth(), GetTargetHeight());
// texture map s_RenderTargets[s_curtarget] onto the main buffer // texture map s_RenderTargets[s_curtarget] onto the main buffer
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
@ -554,9 +556,9 @@ void Renderer::FlushZBufferAlphaToTarget()
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-1,-1); glTexCoord2f(0, 0); glVertex2f(-1,-1);
glTexCoord2f(0, (float)(GetTargetHeight()<<g_AAy)); glVertex2f(-1,1); glTexCoord2f(0, (float)(GetTargetHeight())); glVertex2f(-1,1);
glTexCoord2f((float)(GetTargetWidth()<<g_AAx), (float)(GetTargetHeight()<<g_AAy)); glVertex2f(1,1); glTexCoord2f((float)(GetTargetWidth()), (float)(GetTargetHeight())); glVertex2f(1,1);
glTexCoord2f((float)(GetTargetWidth()<<g_AAx), 0); glVertex2f(1,-1); glTexCoord2f((float)(GetTargetWidth()), 0); glVertex2f(1,-1);
glEnd(); glEnd();
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
@ -661,9 +663,9 @@ void Renderer::Swap(const TRectangle& rc)
for(int i = 1; i < 8; ++i) TextureMngr::DisableStage(i); for(int i = 1; i < 8; ++i) TextureMngr::DisableStage(i);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
//TODO: Do Correctly in a bit
float FactorW = (float)s_nTargetWidth / (float)nBackbufferWidth; float FactorW = (float)640 / (float)nBackbufferWidth;
float FactorH = (float)s_nTargetHeight / (float)nBackbufferHeight; float FactorH = (float)480 / (float)nBackbufferHeight;
float Max = (FactorW < FactorH) ? FactorH : FactorW; float Max = (FactorW < FactorH) ? FactorH : FactorW;
float Temp = 1 / Max; float Temp = 1 / Max;
@ -673,9 +675,9 @@ void Renderer::Swap(const TRectangle& rc)
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-FactorW,-FactorH); glTexCoord2f(0, 0); glVertex2f(-FactorW,-FactorH);
glTexCoord2f(0, (float)s_nTargetHeight); glVertex2f(-FactorW,FactorH); glTexCoord2f(0, (float)GetTargetHeight()); glVertex2f(-FactorW,FactorH);
glTexCoord2f((float)s_nTargetWidth, (float)s_nTargetHeight); glVertex2f(FactorW,FactorH); glTexCoord2f((float)GetTargetWidth(), (float)GetTargetHeight()); glVertex2f(FactorW,FactorH);
glTexCoord2f((float)s_nTargetWidth, 0); glVertex2f(FactorW,-FactorH); glTexCoord2f((float)GetTargetWidth(), 0); glVertex2f(FactorW,-FactorH);
glEnd(); glEnd();
glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0);
@ -782,24 +784,24 @@ void Renderer::Swap(const TRectangle& rc)
bool Renderer::SaveRenderTarget(const char* filename, int jpeg) bool Renderer::SaveRenderTarget(const char* filename, int jpeg)
{ {
bool bflip = true; bool bflip = true;
vector<u32> data(s_nTargetWidth*s_nTargetHeight); vector<u32> data(nBackbufferWidth*nBackbufferHeight);
glReadPixels(0, 0, s_nTargetWidth, s_nTargetHeight, GL_BGRA, GL_UNSIGNED_BYTE, &data[0]); glReadPixels(0, 0, nBackbufferWidth, nBackbufferHeight, GL_BGRA, GL_UNSIGNED_BYTE, &data[0]);
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
return false; return false;
if (bflip) { if (bflip) {
// swap scanlines // swap scanlines
vector<u32> scanline(s_nTargetWidth); vector<u32> scanline(nBackbufferWidth);
for(u32 i = 0; i < s_nTargetHeight/2; ++i) { for(u32 i = 0; i < nBackbufferHeight/2; ++i) {
memcpy(&scanline[0], &data[i*s_nTargetWidth], s_nTargetWidth*4); memcpy(&scanline[0], &data[i*nBackbufferWidth], nBackbufferWidth*4);
memcpy(&data[i*s_nTargetWidth], &data[(s_nTargetHeight-i-1)*s_nTargetWidth], s_nTargetWidth*4); memcpy(&data[i*nBackbufferWidth], &data[(nBackbufferHeight-i-1)*nBackbufferWidth], nBackbufferWidth*4);
memcpy(&data[(s_nTargetHeight-i-1)*s_nTargetWidth], &scanline[0], s_nTargetWidth*4); memcpy(&data[(nBackbufferHeight-i-1)*nBackbufferWidth], &scanline[0], nBackbufferWidth*4);
} }
} }
if (jpeg) return SaveJPEG(filename, s_nTargetWidth, s_nTargetHeight, &data[0], 70); if (jpeg) return SaveJPEG(filename, nBackbufferWidth, nBackbufferHeight, &data[0], 70);
return SaveTGA(filename, s_nTargetWidth, s_nTargetHeight, &data[0]); return SaveTGA(filename, nBackbufferWidth, nBackbufferHeight, &data[0]);
} }
void Renderer::SetCgErrorOutput(bool bOutput) void Renderer::SetCgErrorOutput(bool bOutput)

View File

@ -22,7 +22,6 @@
extern CGcontext g_cgcontext; extern CGcontext g_cgcontext;
extern CGprofile g_cgvProf, g_cgfProf; extern CGprofile g_cgvProf, g_cgfProf;
extern u32 g_AAx, g_AAy; // anti-aliasing
class Renderer class Renderer
{ {

View File

@ -322,7 +322,7 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
// [5] = 16777215 * farz // [5] = 16777215 * farz
INFO_LOG("view: topleft=(%f,%f), wh=(%f,%f), z=(%f,%f)\n",rawViewport[3]-rawViewport[0]-342,rawViewport[4]+rawViewport[1]-342, INFO_LOG("view: topleft=(%f,%f), wh=(%f,%f), z=(%f,%f)\n",rawViewport[3]-rawViewport[0]-342,rawViewport[4]+rawViewport[1]-342,
2 * rawViewport[0], 2 * rawViewport[1], (rawViewport[5]-rawViewport[2])/16777215.0f, rawViewport[5]/16777215.0f); 2 * rawViewport[0], 2 * rawViewport[1], (rawViewport[5]-rawViewport[2])/16777215.0f, rawViewport[5]/16777215.0f);
glViewport((int)(rawViewport[3]-rawViewport[0]-342)<<g_AAx,Renderer::GetTargetHeight()-((int)(rawViewport[4]-rawViewport[1]-342)<<g_AAy), abs((int)(2 * rawViewport[0])), abs((int)(2 * rawViewport[1]))); glViewport((int)(rawViewport[3]-rawViewport[0]-342),Renderer::GetTargetHeight()-((int)(rawViewport[4]-rawViewport[1]-342)), abs((int)(2 * rawViewport[0])), abs((int)(2 * rawViewport[1])));
glDepthRange((rawViewport[5]-rawViewport[2])/16777215.0f, rawViewport[5]/16777215.0f); glDepthRange((rawViewport[5]-rawViewport[2])/16777215.0f, rawViewport[5]/16777215.0f);
} }

View File

@ -18,7 +18,6 @@
// Preliminary non-working code. // Preliminary non-working code.
#include "Common.h"
#include "Globals.h" #include "Globals.h"
#include "Render.h" #include "Render.h"
#include "TextureMngr.h" #include "TextureMngr.h"