diff --git a/Source/SysPSP/Graphics/GraphicsContext.cpp b/Source/SysPSP/Graphics/GraphicsContext.cpp index 9519f9d91..24b98c476 100644 --- a/Source/SysPSP/Graphics/GraphicsContext.cpp +++ b/Source/SysPSP/Graphics/GraphicsContext.cpp @@ -150,8 +150,9 @@ class IGraphicsContext : public CGraphicsContext //************************************************************************************* template<> bool CSingleton< CGraphicsContext >::Create() { + #ifdef DAEDALUS_ENABLE_ASSERTS DAEDALUS_ASSERT_Q(mpInstance == nullptr); - +#endif mpInstance = new IGraphicsContext(); return mpInstance->Initialise(); } diff --git a/Source/SysPSP/Graphics/NativeTexturePSP.cpp b/Source/SysPSP/Graphics/NativeTexturePSP.cpp index 1dc65ecaf..b33b195a7 100644 --- a/Source/SysPSP/Graphics/NativeTexturePSP.cpp +++ b/Source/SysPSP/Graphics/NativeTexturePSP.cpp @@ -74,7 +74,9 @@ EPspTextureFormat GetPspTextureFormat( ETextureFormat texture_format ) case TexFmt_CI8_8888: return PspTexFmt_T8; } +#ifdef DAEDALUS_DEBUG_CONSOLE DAEDALUS_ERROR( "Unhandled texture format" ); + #endif return PspTexFmt_8888; } @@ -488,10 +490,11 @@ namespace CRefPtr texture = CNativeTexture::Create( width, height, texture_format ); + #ifdef DAEDALUS_ENABLE_ASSERTS DAEDALUS_ASSERT( texture->GetWidth() >= width, "Width is unexpectedly small" ); DAEDALUS_ASSERT( texture->GetHeight() >= height, "Height is unexpectedly small" ); DAEDALUS_ASSERT( texture_format == texture->GetFormat(), "Texture format doesn't match" ); - + #endif u8 * p_dest( new u8[ texture->GetBytesRequired() ] ); if( !p_dest ) { @@ -518,11 +521,15 @@ namespace case TexFmt_CI4_8888: case TexFmt_CI8_8888: + #ifdef DAEDALUS_DEBUG_CONSOLE DAEDALUS_ERROR( "Can't use palettised format for png." ); + #endif break; default: + #ifdef DAEDALUS_DEBUG_CONSOLE DAEDALUS_ERROR( "Unhandled texture format" ); + #endif break; } @@ -568,10 +575,9 @@ void CNativeTexture::SetData( void * data, void * palette ) if( mpPalette != nullptr ) { - DAEDALUS_ASSERT( palette != nullptr, "No palette provided" ); - #ifdef DAEDALUS_ENABLE_ASSERTS - mPaletteSet = true; + DAEDALUS_ASSERT( palette != nullptr, "No palette provided" ); + mPaletteSet = true; #endif switch( mTextureFormat ) @@ -584,7 +590,9 @@ void CNativeTexture::SetData( void * data, void * palette ) break; default: + #ifdef DAEDALUS_DEBUG_CONSOLE DAEDALUS_ERROR( "Unhandled palette format" ); + #endif break; } @@ -597,7 +605,9 @@ void CNativeTexture::SetData( void * data, void * palette ) } else { + #ifdef DAEDALUS_ENABLE_ASSERTS DAEDALUS_ASSERT( palette == nullptr, "Palette provided when not needed" ); + #endif } } } diff --git a/Source/SysPSP/Graphics/VideoMemoryManager.cpp b/Source/SysPSP/Graphics/VideoMemoryManager.cpp index cb8ffcea3..7f1ea860f 100644 --- a/Source/SysPSP/Graphics/VideoMemoryManager.cpp +++ b/Source/SysPSP/Graphics/VideoMemoryManager.cpp @@ -44,8 +44,9 @@ class IVideoMemoryManager : public CVideoMemoryManager //***************************************************************************** template<> bool CSingleton< CVideoMemoryManager >::Create() { + #ifdef DAEDALUS_ENABLE_ASSERTS DAEDALUS_ASSERT_Q(mpInstance == nullptr); - +#endif mpInstance = new IVideoMemoryManager(); return mpInstance != nullptr; } diff --git a/Source/SysPSP/HLEGraphics/ColourAdjuster.cpp b/Source/SysPSP/HLEGraphics/ColourAdjuster.cpp index 64cbc6200..5c8b99513 100644 --- a/Source/SysPSP/HLEGraphics/ColourAdjuster.cpp +++ b/Source/SysPSP/HLEGraphics/ColourAdjuster.cpp @@ -49,7 +49,7 @@ void CColourAdjuster::Process( DaedalusVtx * p_vertices, u32 num_verts ) const case COL32_MASK_RGBA: { - for(u32 v = 0; v < num_verts; v++) + for(u32 v {} ; v < num_verts; v++) { p_vertices[v].Colour = mSetColour; } @@ -58,10 +58,10 @@ void CColourAdjuster::Process( DaedalusVtx * p_vertices, u32 num_verts ) const default: { - u32 clear_bits( ~mSetMask ); - u32 set_bits( mSetColour.GetColour() & mSetMask ); + u32 clear_bits {~mSetMask}; + u32 set_bits {mSetColour.GetColour() & mSetMask}; - for(u32 v = 0; v < num_verts; v++) + for(u32 v {}; v < num_verts; v++) { p_vertices[v].Colour = c32( (p_vertices[v].Colour.GetColour() & clear_bits) | set_bits ); } @@ -73,7 +73,7 @@ void CColourAdjuster::Process( DaedalusVtx * p_vertices, u32 num_verts ) const { case COL32_MASK_RGB: { - for(u32 v = 0; v < num_verts; v++) + for(u32 v {}; v < num_verts; v++) { p_vertices[v].Colour = p_vertices[v].Colour.SubRGB( mSubtractColour ); } @@ -82,7 +82,7 @@ void CColourAdjuster::Process( DaedalusVtx * p_vertices, u32 num_verts ) const case COL32_MASK_A: { - for(u32 v = 0; v < num_verts; v++) + for(u32 v {}; v < num_verts; v++) { p_vertices[v].Colour = p_vertices[v].Colour.SubA( mSubtractColour ); } @@ -112,7 +112,7 @@ void CColourAdjuster::Process( DaedalusVtx * p_vertices, u32 num_verts ) const case COL32_MASK_A: { - for(u32 v = 0; v < num_verts; v++) + for(u32 v {}; v < num_verts; v++) { p_vertices[v].Colour = p_vertices[v].Colour.ModulateA( mModulateColour ); } @@ -121,7 +121,7 @@ void CColourAdjuster::Process( DaedalusVtx * p_vertices, u32 num_verts ) const case COL32_MASK_RGBA: { - for(u32 v = 0; v < num_verts; v++) + for(u32 v {}; v < num_verts; v++) { p_vertices[v].Colour = p_vertices[v].Colour.Modulate( mModulateColour ); } @@ -141,8 +141,8 @@ void CColourAdjuster::Set( u32 mask, c32 colour ) #endif mSetMask |= mask; - u32 current( mSetColour.GetColour() ); - u32 col( colour.GetColour() ); + u32 current {mSetColour.GetColour()}; + u32 col {colour.GetColour()}; mSetColour = c32( ( current & ~mask) | (col & mask) ); } @@ -157,8 +157,8 @@ void CColourAdjuster::Modulate( u32 mask, c32 colour ) #endif mModulateMask |= mask; - u32 current( mModulateColour.GetColour() ); - u32 col( colour.GetColour() ); + u32 current {mModulateColour.GetColour()}; + u32 col {colour.GetColour()}; mModulateColour = c32( ( current & ~mask) | (col & mask) ); } @@ -173,8 +173,8 @@ void CColourAdjuster::Subtract( u32 mask, c32 colour ) #endif mSubtractMask |= mask; - u32 current( mSubtractColour.GetColour() ); - u32 col( colour.GetColour() ); + u32 current {mSubtractColour.GetColour()}; + u32 col {colour.GetColour() }; mSubtractColour = c32( ( current & ~mask) | (col & mask) ); } diff --git a/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp b/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp index 0eb6406a4..1771a263d 100644 --- a/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp +++ b/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp @@ -57,7 +57,7 @@ namespace //u32 gVblCount = 0; u32 gFlipCount {}; //float gCurrentVblrate = 0.0f; - float gCurrentFramerate = 0.0f; + float gCurrentFramerate {0.0f}; u64 gLastFramerateCalcTime {}; u64 gTicksPerSecond {}; @@ -74,7 +74,7 @@ static void UpdateFramerate() #endif gFlipCount++; - u64 now; + u64 now {}; NTiming::GetPreciseTime( &now ); if(gLastFramerateCalcTime == 0) @@ -238,7 +238,7 @@ void CGraphicsPluginImpl::UpdateScreen() HandleEndOfFrame(); } - static u32 current_frame = 0; + static u32 current_frame {}; current_frame++; diff --git a/Source/SysPSP/HLEGraphics/RendererPSP.cpp b/Source/SysPSP/HLEGraphics/RendererPSP.cpp index 0694488a3..0f9b4d8c4 100644 --- a/Source/SysPSP/HLEGraphics/RendererPSP.cpp +++ b/Source/SysPSP/HLEGraphics/RendererPSP.cpp @@ -324,12 +324,12 @@ void RendererPSP::RenderTriangles( DaedalusVtx * p_vertices, u32 num_vertices, b { UpdateTileSnapshots( mTextureTile ); - const CNativeTexture * texture = mBoundTexture[0]; + const CNativeTexture * texture {mBoundTexture[0]}; if( texture && (mTnL.Flags._u32 & (TNL_LIGHT|TNL_TEXGEN)) != (TNL_LIGHT|TNL_TEXGEN) ) { - float scale_x = texture->GetScaleX(); - float scale_y = texture->GetScaleY(); + float scale_x {texture->GetScaleX()}; + float scale_y {texture->GetScaleY()}; // Hack to fix the sun in Zelda OOT/MM if( g_ROM.ZELDA_HACK && (gRDPOtherMode.L == 0x0c184241) ) //&& ti.GetFormat() == G_IM_FMT_I && (ti.GetWidth() == 64) @@ -365,12 +365,12 @@ inline void RendererPSP::RenderFog( DaedalusVtx * p_vertices, u32 num_vertices, sceGuDisable(GU_ALPHA_TEST); sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); - u32 FogColor = mFogColour.GetColour(); + u32 FogColor {mFogColour.GetColour()}; //Copy fog color to vertices - for(u32 i = 0 ; i < num_vertices ; i++) + for(u32 i {} ; i < num_vertices ; i++) { - u32 alpha = p_vertices[i].Colour.GetColour() & 0xFF000000; + u32 alpha {p_vertices[i].Colour.GetColour() & 0xFF000000}; p_vertices[i].Colour = (c32)(alpha | FogColor); } @@ -382,7 +382,7 @@ inline void RendererPSP::RenderFog( DaedalusVtx * p_vertices, u32 num_vertices, void RendererPSP::RenderUsingCurrentBlendMode( DaedalusVtx * p_vertices, u32 num_vertices, u32 triangle_mode, u32 render_mode, bool disable_zbuffer ) { - static bool ZFightingEnabled( false ); + static bool ZFightingEnabled {false}; DAEDALUS_PROFILE( "RendererPSP::RenderUsingCurrentBlendMode" ); @@ -436,7 +436,7 @@ void RendererPSP::RenderUsingCurrentBlendMode( DaedalusVtx * p_vertices, u32 num sceGuTexFilter(GU_NEAREST,GU_NEAREST); } - u32 cycle_mode = gRDPOtherMode.cycle_type; + u32 cycle_mode {gRDPOtherMode.cycle_type}; // Initiate Blender // @@ -453,7 +453,7 @@ void RendererPSP::RenderUsingCurrentBlendMode( DaedalusVtx * p_vertices, u32 num // if( (gRDPOtherMode.alpha_compare == G_AC_THRESHOLD) && !gRDPOtherMode.alpha_cvg_sel ) { - u8 alpha_threshold = mBlendColour.GetA(); + u8 alpha_threshold {mBlendColour.GetA()}; sceGuAlphaFunc( (alpha_threshold | g_ROM.ALPHA_HACK) ? GU_GEQUAL : GU_GREATER, alpha_threshold, 0xff); sceGuEnable(GU_ALPHA_TEST); } @@ -479,7 +479,7 @@ void RendererPSP::RenderUsingCurrentBlendMode( DaedalusVtx * p_vertices, u32 num case CYCLE_2CYCLE: blend_entry = LookupBlendState( mMux, true ); break; } - u32 render_flags( GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF | render_mode ); + u32 render_flags {GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF | render_mode}; #ifdef DAEDALUS_DEBUG_DISPLAYLIST // Used for Blend Explorer, or Nasty texture @@ -508,11 +508,11 @@ void RendererPSP::RenderUsingCurrentBlendMode( DaedalusVtx * p_vertices, u32 num blend_entry.OverrideFunction( details ); - bool installed_texture( false ); + bool installed_texture {false}; if( details.InstallTexture ) { - u32 texture_idx = g_ROM.T1_HACK ? 1 : 0; + u32 texture_idx {g_ROM.T1_HACK ? 1 : 0}; if( mBoundTexture[ texture_idx ] ) { @@ -584,7 +584,7 @@ void RendererPSP::RenderUsingRenderSettings( const CBlendStates * states, Daedal memcpy( mVtx_Save, p_vertices, num_vertices * sizeof( DaedalusVtx ) ); } - for( u32 i = 0; i < states->GetNumStates(); ++i ) + for( u32 i {}; i < states->GetNumStates(); ++i ) { const CRenderSettings * settings( states->GetColourSettings( i ) ); @@ -613,13 +613,13 @@ void RendererPSP::RenderUsingRenderSettings( const CBlendStates * states, Daedal out.VertexExpressionA->ApplyExpressionAlpha( state ); } - bool installed_texture = false; + bool installed_texture {false}; - u32 texture_idx = 0; + u32 texture_idx {}; if(install_texture0 || install_texture1) { - u32 tfx( GU_TFX_MODULATE ); + u32 tfx {GU_TFX_MODULATE}; switch( out.BlendMode ) { case PBM_MODULATE: tfx = GU_TFX_MODULATE; break; @@ -720,7 +720,7 @@ void RendererPSP::TexRect( u32 tile_idx, const v2 & xy0, const v2 & xy1, TexCoor DL_PF( " Screen: %.1f,%.1f -> %.1f,%.1f", screen0.x, screen0.y, screen1.x, screen1.y ); DL_PF( " Texture: %.1f,%.1f -> %.1f,%.1f", uv0.x, uv0.y, uv1.x, uv1.y ); #endif - const f32 depth = gRDPOtherMode.depth_source ? mPrimDepth : 0.0f; + const f32 depth {gRDPOtherMode.depth_source ? mPrimDepth : 0.0f}; #if 1 //1->SPRITE, 0->STRIP DaedalusVtx * p_vertices = static_cast(sceGuGetMemory(2 * sizeof(DaedalusVtx))); @@ -1024,30 +1024,30 @@ void RendererPSP::Draw2DTextureBlit(f32 x, f32 y, f32 width, f32 height, return; } - f32 cur_v = v0; - f32 cur_y = y; - f32 v_end = v1; - f32 y_end = height; - f32 vslice = 512.f; - f32 ystep = (height/(v1-v0) * vslice); - f32 vstep = ((v1-v0) > 0 ? vslice : -vslice); + f32 cur_v {v0}; + f32 cur_y {y}; + f32 v_end {v1}; + f32 y_end {height}; + f32 vslice {512.f}; + f32 ystep {(height/(v1-v0) * vslice)}; + f32 vstep {(v1-v0) > 0 ? vslice : -vslice}; - f32 x_end = width; - f32 uslice = 64.f; + f32 x_end {width}; + f32 uslice {64.f}; //f32 ustep = (u1-u0)/width * xslice; - f32 xstep = (width/(u1-u0) * uslice); - f32 ustep = ((u1-u0) > 0 ? uslice : -uslice); + f32 xstep {(width/(u1-u0) * uslice)}; + f32 ustep {(u1-u0) > 0 ? uslice : -uslice}; - const u8* data = static_cast(texture->GetData()); + const u8* data {static_cast(texture->GetData())}; for ( ; cur_y < y_end; cur_y+=ystep, cur_v+=vstep ) { - f32 cur_u = u0; - f32 cur_x = x; - f32 u_end = u1; + f32 cur_u {u0}; + f32 cur_x {x}; + f32 u_end {u1}; - f32 poly_height = ((cur_y+ystep) > y_end) ? (y_end-cur_y) : ystep; - f32 source_height = vstep; + f32 poly_height {((cur_y+ystep) > y_end) ? (y_end-cur_y) : ystep}; + f32 source_height {vstep}; // support negative vsteps if ((vstep > 0) && (cur_v+vstep > v_end)) @@ -1059,7 +1059,7 @@ void RendererPSP::Draw2DTextureBlit(f32 x, f32 y, f32 width, f32 height, source_height = (cur_v-v_end); } - const u8* udata = data; + const u8* udata {data}; // blit maximizing the use of the texture-cache for( ; cur_x < x_end; cur_x+=xstep, cur_u+=ustep ) { @@ -1076,8 +1076,8 @@ void RendererPSP::Draw2DTextureBlit(f32 x, f32 y, f32 width, f32 height, TextureVtx *p_verts = (TextureVtx*)sceGuGetMemory(2*sizeof(TextureVtx)); //f32 poly_width = ((cur_x+xstep) > x_end) ? (x_end-cur_x) : xstep; - f32 poly_width = xstep; - f32 source_width = ustep; + f32 poly_width {xstep}; + f32 source_width {ustep}; // support negative usteps if ((ustep > 0) && (cur_u+ustep > u_end)) diff --git a/Source/SysPSP/UI/MainMenuScreen.cpp b/Source/SysPSP/UI/MainMenuScreen.cpp index a5a9a2594..5988683c0 100644 --- a/Source/SysPSP/UI/MainMenuScreen.cpp +++ b/Source/SysPSP/UI/MainMenuScreen.cpp @@ -131,9 +131,9 @@ IMainMenuScreen::IMainMenuScreen( CUIContext * p_context ) , mCurrentOption( MO_ROMS ) , mCurrentDisplayOption( mCurrentOption ) { - for( u32 i = 0; i < NUM_MENU_OPTIONS; ++i ) + for( u32 i {0}; i < NUM_MENU_OPTIONS; ++i ) { - mOptionComponents[ i ] = NULL; + mOptionComponents[ i ] = nullptr; } mSelectedRomComponent = CSelectedRomComponent::Create( mpContext, new CMemberFunctor< IMainMenuScreen >( this, &IMainMenuScreen::OnStartEmulation ) ); diff --git a/Source/SysPSP/main.cpp b/Source/SysPSP/main.cpp index 782b62c01..c92b01daa 100644 --- a/Source/SysPSP/main.cpp +++ b/Source/SysPSP/main.cpp @@ -101,7 +101,6 @@ extern int PSP_TV_CABLE; extern int PSP_TV_LACED; - bool g32bitColorMode = false; bool PSP_IS_SLIM = false; @@ -332,13 +331,6 @@ void HandleEndOfFrame() if(activate_pause_menu) { - // See how much texture memory we're using - //CTextureCache::Get()->DropTextures(); -//#ifdef DAEDALUS_DEBUG_MEMORY - //CVideoMemoryManager::Get()->DisplayDebugInfo(); -//#endif - - CGraphicsContext::Get()->SwitchToLcdDisplay(); CGraphicsContext::Get()->ClearAllSurfaces();