(Xbox 1) Freed up some more memory (32MB to 36MB free in VBA Next)

This commit is contained in:
twinaphex 2012-07-24 17:45:28 +02:00
parent 2240e96b20
commit a82d0c7a9e
7 changed files with 6 additions and 96 deletions

View File

@ -38,10 +38,7 @@ bool Font::Create()
if (m_pFont) if (m_pFont)
m_pFont->Release(); m_pFont->Release();
word *wcPathBuf = StringToWChar("D:\\Media\\arial.ttf"); HRESULT g_hResult = XFONT_OpenTrueTypeFont(L"D:\\Media\\arial.ttf", 256 * 1024, &m_pFont);
HRESULT g_hResult = XFONT_OpenTrueTypeFont(wcPathBuf, 256 * 1024, &m_pFont);
delete [] wcPathBuf;
if (FAILED(g_hResult)) if (FAILED(g_hResult))
return false; return false;

View File

@ -26,30 +26,10 @@ CMenuMain::CMenuMain()
{ {
// we think that the rom list is unloaded until we know otherwise // we think that the rom list is unloaded until we know otherwise
m_bRomListLoadedState = false; m_bRomListLoadedState = false;
ifstream stateFile;
stateFile.open("T:\\RomlistState.dat");
if (stateFile.is_open())
{
int baseIndex;
stateFile >> baseIndex;
g_romList.m_iBaseIndex = baseIndex;
stateFile.close();
}
} }
CMenuMain::~CMenuMain() CMenuMain::~CMenuMain()
{ {
ofstream stateFile;
stateFile.open("T:\\RomlistState.dat");
stateFile << g_romList.GetBaseIndex() << endl;
stateFile.close();
} }
bool CMenuMain::Create() bool CMenuMain::Create()

View File

@ -47,7 +47,7 @@ bool CMenuManager::SetMenuState(int nMenuID)
case MENU_MAIN: case MENU_MAIN:
//Create the Main Menu //Create the Main Menu
g_menuMain.Create(); g_menuMain.Create();
break; break;
} }
return true; return true;
} }
@ -60,8 +60,8 @@ void CMenuManager::Update()
{ {
case MENU_MAIN: case MENU_MAIN:
g_menuMain.ProcessInput(); g_menuMain.ProcessInput();
g_menuMain.Render(); g_menuMain.Render();
break; break;
} }
} }

View File

@ -36,27 +36,11 @@ bool Rom::Load(const char *szFilename)
return true; return true;
} }
bool Rom::LoadFromCache(const string &szFilename)
{
m_szFilename = szFilename;
m_bLoaded = true;
return true;
}
string Rom::GetFileName() string Rom::GetFileName()
{ {
return m_szFilename; return m_szFilename;
} }
string Rom::GetComments()
{
//return string(m_iniEntry->szComments);
return "blah";
}
CSurface &Rom::GetTexture() CSurface &Rom::GetTexture()
{ {
return m_texture; return m_texture;

View File

@ -25,10 +25,8 @@ public:
~Rom(); ~Rom();
bool Load(const char *szFilename); bool Load(const char *szFilename);
bool LoadFromCache(const string &szFilename);
string GetFileName(); string GetFileName();
string GetComments();
CSurface &GetTexture(); CSurface &GetTexture();
private: private:
string m_szFilename; string m_szFilename;

View File

@ -36,62 +36,14 @@ RomList::~RomList(void)
void RomList::Load() void RomList::Load()
{ {
ifstream cacheFile; Build();
cacheFile.open("T:\\RomlistCache.dat");
// try and open the cache file, if it doesnt exist, generate the rom list
if (!cacheFile.is_open())
{
Build();
}
else
{
while (!cacheFile.eof())
{
string szFilename;
getline(cacheFile, szFilename);
Rom *rom = new Rom();
bool bSuccess = rom->LoadFromCache(szFilename);
if (bSuccess)
m_romList.push_back(rom);
else
delete rom;
}
cacheFile.close();
}
m_bLoaded = true; m_bLoaded = true;
} }
void RomList::Save()
{
vector<Rom *>::iterator i;
ofstream cacheFile;
// open/overwrite the rom cache
cacheFile.open("T:\\RomlistCache.dat");
for (i = m_romList.begin(); i != m_romList.end(); i++)
{
Rom *rom = *i;
cacheFile << rom->GetFileName() << endl;
}
cacheFile.close();
}
void RomList::Refresh() void RomList::Refresh()
{ {
Destroy(); Destroy();
DeleteFile("T:\\RomlistCache.dat");
DeleteFile("T:\\RomlistState.dat");
} }
bool RomList::IsLoaded() bool RomList::IsLoaded()

View File

@ -22,10 +22,9 @@ class RomList
{ {
public: public:
RomList(void); RomList(void);
virtual ~RomList(void); ~RomList(void);
void Load(); void Load();
void Save();
void Refresh(); void Refresh();
bool IsLoaded(); bool IsLoaded();