added VolumeDirectory and modified ELF boot code to allow a directory on the user's computer to appear as the DVD drive. Linux support needs to be added. Added functionality to the Wii DI. Clicking on a data symbol in the code window sets the memory list to that address.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@624 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
donkopunchstania
2008-09-23 00:05:08 +00:00
parent ef1aba784e
commit 29664c880a
14 changed files with 795 additions and 11 deletions
+48 -4
View File
@@ -393,6 +393,33 @@ bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
return true;
}
void CBoot::Load_FST(bool _bIsWii)
{
if(VolumeHandler::IsValid())
{
// copy first 20 bytes of disc to start of Mem 1
VolumeHandler::ReadToPtr(Memory::GetPointer(0x80000000), 0, 0x20);
// copy of game id
Memory::Write_U32(Memory::Read_U32(0x80000000), 0x80003180);
u32 shift = 0;
if(_bIsWii)
shift = 2;
u32 fstOffset = VolumeHandler::Read32(0x0424) << shift;
u32 fstSize = VolumeHandler::Read32(0x0428) << shift;
u32 maxFstSize = VolumeHandler::Read32(0x042c) << shift;
u32 arenaHigh = 0x817FFFF4 - maxFstSize;
Memory::Write_U32(arenaHigh, 0x00000034);
// load FST
VolumeHandler::ReadToPtr(Memory::GetPointer(arenaHigh), fstOffset, fstSize);
Memory::Write_U32(arenaHigh, 0x00000038);
Memory::Write_U32(maxFstSize, 0x0000003c);
}
}
void CBoot::UpdateDebugger_MapLoaded(const char *_gameID)
{
@@ -546,12 +573,11 @@ bool CBoot::BootUp(const SCoreStartupParameter& _StartupPara)
PanicAlert("Warning - starting ELF in wrong console mode!");
}
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM);
// stop apploader from running when BIOS boots
VolumeHandler::SetVolumeName("");
if (elfWii)
{
if (VolumeHandler::IsWii() && (!_StartupPara.m_strDefaultGCM.empty()))
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
EmulatedBIOS_Wii(false);
}
else
@@ -562,6 +588,24 @@ bool CBoot::BootUp(const SCoreStartupParameter& _StartupPara)
EmulatedBIOS(false);
}
}
// load image or create virtual drive from directory
if(!_StartupPara.m_strDVDRoot.empty())
{
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, elfWii);
}
else if(!_StartupPara.m_strDefaultGCM.empty())
{
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM);
}
else
{
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strFilename, elfWii);
}
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
Load_FST(elfWii);
Boot_ELF(_StartupPara.m_strFilename.c_str());
UpdateDebugger_MapLoaded();
+2
View File
@@ -57,6 +57,8 @@ private:
static void EmulatedBIOS(bool _bDebug);
static bool EmulatedBIOS_Wii(bool _bDebug);
static bool Load_BIOS(const std::string& _rBiosFilename);
static void Load_FST(bool _bIsWii);
};
#endif
+1
View File
@@ -80,6 +80,7 @@ struct SCoreStartupParameter
std::string m_strMemoryCardB;
std::string m_strSRAM;
std::string m_strDefaultGCM;
std::string m_strDVDRoot;
std::string m_strUniqueID;
//
@@ -28,6 +28,7 @@
#include "VolumeCreator.h"
#include "Filesystem.h"
// __________________________________________________________________________________________________
//
CWII_IPC_HLE_Device_di::CWII_IPC_HLE_Device_di(u32 _DeviceID, const std::string& _rDeviceName )
@@ -36,7 +37,7 @@ CWII_IPC_HLE_Device_di::CWII_IPC_HLE_Device_di(u32 _DeviceID, const std::string&
, m_pFileSystem(NULL)
{
m_pVolume = DiscIO::CreateVolumeFromFilename(Core::GetStartupParameter().m_strFilename);
m_pVolume = VolumeHandler::GetVolume();
if (m_pVolume)
m_pFileSystem = DiscIO::CreateFileSystem(m_pVolume);
}
@@ -103,6 +104,9 @@ bool CWII_IPC_HLE_Device_di::IOCtlV(u32 _CommandAddress)
return true;
}
// Hack
u8 coverByte = 0;
// __________________________________________________________________________________________________
//
u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut, u32 _BufferOutSize)
@@ -114,13 +118,46 @@ u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32
case 0x12:
{
Memory::Memset(_BufferOut, 0, _BufferOutSize);
LOG(WII_IPC_HLE, "%s executes DVDLowInquiry (Buffer 0x%08x, 0x%x)", GetDeviceName().c_str(), _BufferOut, _BufferOutSize);
u8* buffer = Memory::GetPointer(_BufferOut);
// rev
buffer[0] = 0x01;
buffer[1] = 0x02;
// dev code
buffer[2] = 0x03;
buffer[3] = 0x04;
// firmware date
buffer[4] = 0x20;
buffer[5] = 0x08;
buffer[6] = 0x08;
buffer[7] = 0x29;
LOG(WII_IPC_HLE, "%s executes DVDLowInquiry (Buffer 0x%08x, 0x%x)", GetDeviceName().c_str(), _BufferOut, _BufferOutSize);
return 0x1;
}
break;
// DVDLowReadDiskID
case 0x70:
{
// TODO - verify that this is correct
VolumeHandler::ReadToPtr(Memory::GetPointer(_BufferOut), 0, _BufferOutSize);
LOG(WII_IPC_HLE, "%s executes DVDLowReadDiskID (Buffer 0x%08x, 0x%x)", GetDeviceName().c_str(), _BufferOut, _BufferOutSize);
return 0x1;
}
break;
// DVDLowRead
// TODO - find out if 80, 8d, or and d0 need to do something specific
case 0x80:
case 0x8d:
case 0xd0:
case 0x71:
{
u32 Size = Memory::Read_U32(_BufferIn+0x04);
@@ -151,10 +188,30 @@ u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32
}
break;
// DVDLowGetCoverReg - called by "Legend of Spyro"
case 0x7a:
// DVDLowWaitForCoverClose
case 0x79:
{
Memory::Memset(_BufferOut, 0, _BufferOutSize);
LOG(WII_IPC_HLE, "%s executes DVDLowWaitForCoverClose (Buffer 0x%08x, 0x%x)", GetDeviceName().c_str(), _BufferOut, _BufferOutSize);
return 4;
}
break;
// DVDLowGetCoverReg - called by "Legend of Spyro"
case 0x7a:
{
// HACK - swiching the 4th byte between 0 and 1 gets through this check
Memory::Memset(_BufferOut, 0, _BufferOutSize);
u8* buffer = Memory::GetPointer(_BufferOut);
buffer[3] = coverByte;
if(coverByte)
coverByte = 0;
else
coverByte = 0x01;
return 1;
}
break;
@@ -166,6 +223,25 @@ u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32
}
break;
// DVDLowGetCoverStatus
case 0x88:
{
Memory::Memset(_BufferOut, 0, _BufferOutSize);
LOG(WII_IPC_HLE, "%s executes DVDLowGetCoverStatus (Buffer 0x%08x, 0x%x)", GetDeviceName().c_str(), _BufferOut, _BufferOutSize);
return 1;
}
break;
// DVDLowReset
case 0x8a:
{
Memory::Memset(_BufferOut, 0, _BufferOutSize);
LOG(WII_IPC_HLE, "%s executes DVDLowReset (Buffer 0x%08x, 0x%x)", GetDeviceName().c_str(), _BufferOut, _BufferOutSize);
return 1;
}
break;
// DVDLowSeek
case 0xab:
{}
@@ -175,8 +251,15 @@ u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32
case 0xe3:
{
Memory::Memset(_BufferOut, 0, _BufferOutSize);
u32 eject = Memory::Read_U32(_BufferIn + 0x04);
LOG(WII_IPC_HLE, "%s executes DVDLowStopMotor (Buffer 0x%08x, 0x%x)", GetDeviceName().c_str(), _BufferOut, _BufferOutSize);
PanicAlert("Weird. Nobody should call DVDLowStopMotor.");
if(eject)
{
LOG(WII_IPC_HLE, "Eject disc", GetDeviceName().c_str(), _BufferOut, _BufferOutSize);
// TODO: eject the disc
}
}
break;
@@ -103,6 +103,7 @@ void SymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const char *name, int typ
Symbol tf;
tf.name = name;
tf.type = type;
tf.address = startAddr;
if (tf.type == Symbol::SYMBOL_FUNCTION) {
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
checksumToFunction[tf.hash] = &(functions[startAddr]);
+11 -1
View File
@@ -38,6 +38,16 @@ void SetVolumeName(const std::string& _rFullPath)
g_pVolume = DiscIO::CreateVolumeFromFilename(_rFullPath);
}
void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii)
{
if (g_pVolume)
{
delete g_pVolume;
g_pVolume = NULL;
}
g_pVolume = DiscIO::CreateVolumeFromDirectory(_rFullPath, _bIsWii);
}
u32 Read32(u64 _Offset)
{
@@ -52,7 +62,7 @@ u32 Read32(u64 _Offset)
bool ReadToPtr(u8* ptr, u64 _dwOffset, u64 _dwLength)
{
if (g_pVolume != NULL)
if (g_pVolume != NULL && ptr)
{
g_pVolume->Read(_dwOffset, _dwLength, ptr);
return true;
+2
View File
@@ -28,6 +28,8 @@ namespace VolumeHandler
void SetVolumeName(const std::string& _rFullPath);
void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii);
u32 Read32(u64 _Offset);
bool ReadToPtr(u8* ptr, u64 _dwOffset, u64 _dwLength);
+9 -1
View File
@@ -645,7 +645,15 @@ void CCodeWindow::OnSymbolListChange(wxCommandEvent& event)
Symbol* pSymbol = static_cast<Symbol *>(symbols->GetClientData(index));
if (pSymbol != NULL)
{
JumpToAddress(pSymbol->address);
if(pSymbol->type == Symbol::SYMBOL_DATA)
{
if(m_MemoryWindow && m_MemoryWindow->IsVisible())
m_MemoryWindow->JumpToAddress(pSymbol->address);
}
else
{
JumpToAddress(pSymbol->address);
}
}
}
}
+8
View File
@@ -597,6 +597,14 @@
RelativePath=".\Src\VolumeCreator.h"
>
</File>
<File
RelativePath=".\Src\VolumeDirectory.cpp"
>
</File>
<File
RelativePath=".\Src\VolumeDirectory.h"
>
</File>
<File
RelativePath=".\Src\VolumeGC.cpp"
>
+9
View File
@@ -22,6 +22,7 @@
#include "VolumeCreator.h"
#include "Volume.h"
#include "VolumeDirectory.h"
#include "VolumeGC.h"
#include "VolumeWiiCrypted.h"
@@ -103,6 +104,14 @@ IVolume* CreateVolumeFromFilename(const std::string& _rFilename)
return NULL;
}
IVolume* CreateVolumeFromDirectory(const std::string& _rDirectory, bool _bIsWii)
{
if(CVolumeDirectory::IsValidDirectory(_rDirectory))
return new CVolumeDirectory(_rDirectory, _bIsWii);
return NULL;
}
bool IsVolumeWiiDisc(const IVolume *_rVolume)
{
u32 MagicWord = 0;
+1
View File
@@ -23,6 +23,7 @@
namespace DiscIO
{
IVolume* CreateVolumeFromFilename(const std::string& _rFilename);
IVolume* CreateVolumeFromDirectory(const std::string& _rDirectory, bool _bIsWii);
bool IsVolumeWiiDisc(const IVolume *_rVolume);
} // namespace
File diff suppressed because it is too large Load Diff
+109
View File
@@ -0,0 +1,109 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#pragma once
#include "Volume.h"
#include "Common.h"
#include <vector>
#include <string>
#include <map>
//
// --- this volume type is used for reading files directly from the hard drive ---
//
namespace DiscIO
{
class CVolumeDirectory
: public IVolume
{
public:
CVolumeDirectory(const std::string& _rDirectory, bool _bIsWii);
~CVolumeDirectory();
static bool IsValidDirectory(const std::string& _rDirectory);
bool Read(u64 _Offset, u64 _Length, u8* _pBuffer) const;
std::string GetName() const;
void SetName(std::string);
std::string GetUniqueID() const;
void SetUniqueID(std::string _ID);
ECountry GetCountry() const;
u64 GetSize() const;
void BuildFST();
struct FSTEntry
{
bool isDirectory;
u32 size; // file length or number of entries from children
std::string physicalName; // name on disk
std::string virtualName; // name in FST names table
std::vector<FSTEntry> children;
};
private:
static std::string ExtractDirectoryName(const std::string& _rDirectory);
void SetDiskTypeWii();
void SetDiskTypeGC();
// writing to read buffer
void WriteToBuffer(u64 _SrcStartAddress, u64 _SrcLength, u8* _Src,
u64& _Address, u64& _Length, u8*& _pBuffer) const;
void PadToAddress(u64 _StartAddress, u64& _Address, u64& _Length, u8*& _pBuffer) const;
void Write32(u32 data, u32 offset, u8* buffer);
// FST creation
void WriteEntryData(u32& entryOffset, u8 type, u32 nameOffset, u64 dataOffset, u32 length);
void WriteEntryName(u32& nameOffset, const std::string& name);
void WriteEntry(const FSTEntry& entry, u32& fstOffset, u32& nameOffset, u64& dataOffset, u32 parentEntryNum);
// returns number of entries found in _Directory
u32 AddDirectoryEntries(const std::string& _Directory, FSTEntry& parentEntry);
std::string m_rootDirectory;
std::map<u64, std::string> m_virtualDisk;
u32 m_totalNameSize;
// gc has no shift, wii has 2 bit shift
u32 m_addressShift;
// first address on disk containing file data
u64 m_dataStartAddress;
u64 m_fstNameOffset;
u64 m_fstSize;
u8* m_FSTData;
u8* m_diskHeader;
};
} // namespace
+2
View File
@@ -70,6 +70,7 @@ void SConfig::SaveSettings()
ini.Set("Core", "SkipIdle", m_LocalCoreStartupParameter.bSkipIdle);
ini.Set("Core", "LockThreads", m_LocalCoreStartupParameter.bLockThreads);
ini.Set("Core", "DefaultGCM", m_LocalCoreStartupParameter.m_strDefaultGCM);
ini.Set("Core", "DVDRoot", m_LocalCoreStartupParameter.m_strDVDRoot);
ini.Set("Core", "OptimizeQuantizers", m_LocalCoreStartupParameter.bOptimizeQuantizers);
}
@@ -122,6 +123,7 @@ void SConfig::LoadSettings()
ini.Get("Core", "SkipIdle", &m_LocalCoreStartupParameter.bSkipIdle, true);
ini.Get("Core", "LockThreads", &m_LocalCoreStartupParameter.bLockThreads, true);
ini.Get("Core", "DefaultGCM", &m_LocalCoreStartupParameter.m_strDefaultGCM);
ini.Get("Core", "DVDRoot", &m_LocalCoreStartupParameter.m_strDVDRoot);
ini.Get("Core", "OptimizeQuantizers", &m_LocalCoreStartupParameter.bOptimizeQuantizers, true);
}
}