From 695f7eeec5dfa360fae13b45669510c995f49962 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 22 Jun 2013 05:14:01 -0400 Subject: [PATCH] Fix more style issues, and abstract most of the init code from MemMap.cpp. --- Core/MemMap.cpp | 25 +++++-------------------- Core/MemMap.h | 2 +- Core/PSPLoaders.cpp | 11 +++++++++-- Core/PSPLoaders.h | 2 +- Core/System.cpp | 11 +++++++++-- GPU/GLES/VertexDecoder.cpp | 1 - 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 36d0cbf1e6..1a6500a5ed 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -65,8 +65,7 @@ u32 g_MemoryMask; u32 g_MemorySize; // We don't declare the IO region in here since its handled by other means. -const int VIEWS_COUNT = 7; -static MemoryView views[VIEWS_COUNT] = +static MemoryView views[] = { {&m_pScratchPad, &m_pPhysicalScratchPad, 0x00010000, SCRATCHPAD_SIZE, 0}, {NULL, &m_pUncachedScratchPad, 0x40010000, SCRATCHPAD_SIZE, MV_MIRROR_PREVIOUS}, @@ -82,27 +81,11 @@ static MemoryView views[VIEWS_COUNT] = static const int num_views = sizeof(views) / sizeof(MemoryView); -void Init(std::string fileToStart) +void Init() { int flags = 0; - // Default memory settings - // TODO: Should DoubleTex really be initialized here? - // Seems to be the safest place currently.. - g_MemoryEnd = 0x0A000000; - g_MemorySize = 0x2000000; - g_RemasterMode = false; - g_DoubleTextureCoordinates = false; - - switch(Identify_File(fileToStart)) { - case FILETYPE_PSP_ISO: - case FILETYPE_PSP_ISO_NP: - InitGameISO(fileToStart); - break; - } - - g_MemoryMask = g_MemorySize - 1; - for(int i = 0; i < VIEWS_COUNT; i++) { + for(int i = 0; i < ARRAY_SIZE(views); i++) { if(views[i].size == 0) views[i].size = g_MemorySize; } @@ -126,6 +109,8 @@ void DoState(PointerWrap &p) p.DoMarker("MemoryEnd"); p.Do(g_MemoryMask); p.DoMarker("MemoryMask"); + p.Do(g_DoubleTextureCoordinates); // TODO: Is there a more appropriate place for this? + p.DoMarker("DoubleTextureCoordinates"); } void Shutdown() diff --git a/Core/MemMap.h b/Core/MemMap.h index e752dc47cb..fb35e30df2 100644 --- a/Core/MemMap.h +++ b/Core/MemMap.h @@ -102,7 +102,7 @@ enum }; // Init and Shutdown -void Init(std::string fileToStart); +void Init(); void Shutdown(); void DoState(PointerWrap &p); void Clear(); diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index 159e4d20b3..dc0dc1df2f 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -42,11 +42,18 @@ #include "Core/MemMap.h" -// TODO: Come up with a better name for this thing // We gather the game info before actually loading/booting the ISO // to determine if the emulator should enable extra memory and // double-sized texture coordinates. -void InitGameISO(std::string fileToStart) { +void InitMemoryForGameISO(std::string fileToStart) { + // Default memory settings + // Seems to be the safest place currently.. + Memory::g_MemoryEnd = 0x0A000000; + Memory::g_MemorySize = 0x2000000; + g_RemasterMode = false; + g_DoubleTextureCoordinates = false; + Memory::g_MemoryMask = Memory::g_MemorySize - 1; + ISOFileSystem *umd2 = new ISOFileSystem(&pspFileSystem, constructBlockDevice(fileToStart.c_str())); // Parse PARAM.SFO diff --git a/Core/PSPLoaders.h b/Core/PSPLoaders.h index b679e38169..5ebf339520 100644 --- a/Core/PSPLoaders.h +++ b/Core/PSPLoaders.h @@ -23,4 +23,4 @@ bool Load_PSP_ISO(const char *filename, std::string *error_string); bool Load_PSP_ELF_PBP(const char *filename, std::string *error_string); -void InitGameISO(std::string fileToStart); +void InitMemoryForGameISO(std::string fileToStart); diff --git a/Core/System.cpp b/Core/System.cpp index 35674a1a37..92d0017b4a 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -44,6 +44,7 @@ #include "CoreParameter.h" #include "FileSystems/MetaFileSystem.h" #include "Loaders.h" +#include "PSPLoaders.h" #include "ELF/ParamSFO.h" #include "../Common/LogManager.h" @@ -72,7 +73,14 @@ bool PSP_Init(const CoreParameter &coreParam, std::string *error_string) coreParameter = coreParam; currentCPU = &mipsr4k; numCPUs = 1; - Memory::Init(coreParam.fileToStart); + + std::string filename = coreParameter.fileToStart; + EmuFileType type = Identify_File(filename); + + if(type == FILETYPE_PSP_ISO || type == FILETYPE_PSP_ISO_NP) + InitMemoryForGameISO(filename); + + Memory::Init(); mipsr4k.Reset(); mipsr4k.pc = 0; @@ -96,7 +104,6 @@ bool PSP_Init(const CoreParameter &coreParam, std::string *error_string) // TODO: Check Game INI here for settings, patches and cheats, and modify coreParameter accordingly - std::string filename = coreParameter.fileToStart; if (!LoadFile(filename, error_string) || coreState == CORE_POWERDOWN) { pspFileSystem.Shutdown(); diff --git a/GPU/GLES/VertexDecoder.cpp b/GPU/GLES/VertexDecoder.cpp index a208b57bc6..65e73eed27 100644 --- a/GPU/GLES/VertexDecoder.cpp +++ b/GPU/GLES/VertexDecoder.cpp @@ -627,7 +627,6 @@ void VertexDecoder::SetVertexType(u32 fmt) { steps_[numSteps_++] = throughmode ? tcstep_through[tc] : tcstep[tc]; switch (tc) { - case GE_VTYPE_TC_8BIT >> GE_VTYPE_TC_SHIFT: decFmt.uvfmt = throughmode ? DEC_U8A_2 : DEC_U8_2; break;