Fix for read from raw drive on some machines,

must have been a fluke that it worked for me and a few others
thanks to shuffle2 and daxtsu for testing patch

some linux compile fixes

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2360 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2009-02-22 07:52:02 +00:00
parent 42101f0ce6
commit e5cf9c8b8c
4 changed files with 17 additions and 30 deletions

View File

@ -64,6 +64,7 @@ public:
~SectorReader(); ~SectorReader();
const u8 *GetBlockData(u64 block_num); const u8 *GetBlockData(u64 block_num);
bool Read(u64 offset, u64 size, u8* out_ptr); bool Read(u64 offset, u64 size, u8* out_ptr);
friend class DriveReader;
}; };
// Factory function - examines the path to choose the right type of IBlobReader, and returns one. // Factory function - examines the path to choose the right type of IBlobReader, and returns one.

View File

@ -36,7 +36,7 @@ namespace DiscIO
} }
else else
{ {
SetSectorSize(2048); SectorReader::SetSectorSize(2048);
#ifdef _LOCKDRIVE #ifdef _LOCKDRIVE
// Lock the compact disc in the CD-ROM drive to prevent accidental // Lock the compact disc in the CD-ROM drive to prevent accidental
// removal while reading from it. // removal while reading from it.
@ -127,27 +127,17 @@ namespace DiscIO
delete lpSector; delete lpSector;
} }
void DriveReader::SetSectorSize(int blocksize)
{
for (int i = 0; i < CACHE_SIZE; i++)
{
cache[i] = new u8[blocksize];
cache_tags[i] = (u64)(s64) - 1;
}
m_blocksize = blocksize;
}
const u8 *DriveReader::GetBlockData(u64 block_num) const u8 *DriveReader::GetBlockData(u64 block_num)
{ {
if (cache_tags[0] == block_num) if (SectorReader::cache_tags[0] == block_num)
{ {
return cache[0]; return SectorReader::cache[0];
} }
else else
{ {
GetBlock(block_num, cache[0]); GetBlock(block_num, cache[0]);
cache_tags[0] = block_num; SectorReader::cache_tags[0] = block_num;
return cache[0]; return SectorReader::cache[0];
} }
} }

View File

@ -32,13 +32,8 @@ class DriveReader : public SectorReader
{ {
private: private:
DriveReader(const char *drive); DriveReader(const char *drive);
void SetSectorSize(int blocksize);
enum { CACHE_SIZE = 32 };
int m_blocksize;
u8* cache[CACHE_SIZE];
u64 cache_tags[CACHE_SIZE];
int cache_age[CACHE_SIZE];
void GetBlock(u64 block_num, u8 *out_ptr); void GetBlock(u64 block_num, u8 *out_ptr);
#ifdef _WIN32 #ifdef _WIN32
HANDLE hDisc; HANDLE hDisc;
PREVENT_MEDIA_REMOVAL pmrLockCDROM; PREVENT_MEDIA_REMOVAL pmrLockCDROM;
@ -47,6 +42,7 @@ private:
#endif #endif
s64 size; s64 size;
u64 *block_pointers; u64 *block_pointers;
public: public:
static DriveReader *Create(const char *drive); static DriveReader *Create(const char *drive);
~DriveReader(); ~DriveReader();

View File

@ -206,22 +206,22 @@ void CMemcardManager::CreateGUIControls()
{ {
// Create the controls for both memcards // Create the controls for both memcards
char ARROW[2][3] = {'<','-',0,'-','>',0}; char ARROW[2][3] = {{'<','-',0,}, {'-','>',0}};
m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, wxT("Convert to GCI"), DEFAULTS); m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, wxT("Convert to GCI"), DEFAULTS);
for (int slot = SLOT_A; slot < SLOT_B + 1; slot++) for (int slot = SLOT_A; slot < SLOT_B + 1; slot++)
{ {
m_CopyFrom[slot] = new wxButton(this, ID_COPYFROM_A + slot, m_CopyFrom[slot] = new wxButton(this, ID_COPYFROM_A + slot,
wxString::Format("%1$sCopy%1$s", ARROW[slot ? 0 : 1]), DEFAULTS); wxString::Format(wxT("%1$sCopy%1$s"), ARROW[slot ? 0 : 1]), DEFAULTS);
m_FixChecksum[slot] = new wxButton(this, ID_FIXCHECKSUM_A + slot, m_FixChecksum[slot] = new wxButton(this, ID_FIXCHECKSUM_A + slot,
wxString::Format("%sFix Checksum%s", ARROWS), DEFAULTS); wxString::Format(wxT("%sFix Checksum%s"), ARROWS), DEFAULTS);
m_SaveImport[slot] = new wxButton(this, ID_SAVEIMPORT_A + slot, m_SaveImport[slot] = new wxButton(this, ID_SAVEIMPORT_A + slot,
wxString::Format("%sImport GCI%s", ARROWS), DEFAULTS); wxString::Format(wxT("%sImport GCI%s"), ARROWS), DEFAULTS);
m_SaveExport[slot] = new wxButton(this, ID_SAVEEXPORT_A + slot, m_SaveExport[slot] = new wxButton(this, ID_SAVEEXPORT_A + slot,
wxString::Format("%sExport GCI%s", ARROWS), DEFAULTS); wxString::Format(wxT("%sExport GCI%s"), ARROWS), DEFAULTS);
m_Delete[slot] = new wxButton(this, ID_DELETE_A + slot, m_Delete[slot] = new wxButton(this, ID_DELETE_A + slot,
wxString::Format("%sDelete%s", ARROWS), DEFAULTS); wxString::Format(wxT("%sDelete%s"), ARROWS), DEFAULTS);
m_PrevPage[slot] = new wxButton(this, ID_PREVPAGE_A + slot, wxT("Prev Page"), DEFAULTS); m_PrevPage[slot] = new wxButton(this, ID_PREVPAGE_A + slot, wxT("Prev Page"), DEFAULTS);
@ -243,7 +243,7 @@ char ARROW[2][3] = {'<','-',0,'-','>',0};
m_MemcardList[slot]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL); m_MemcardList[slot]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL);
sMemcard[slot] = new wxStaticBoxSizer(wxVERTICAL, this, wxString::Format("Memory Card %c", 'A' + slot)); sMemcard[slot] = new wxStaticBoxSizer(wxVERTICAL, this, wxString::Format(wxT("Memory Card %c"), 'A' + slot));
sMemcard[slot]->Add(m_MemcardPath[slot], 0, wxEXPAND|wxALL, 5); sMemcard[slot]->Add(m_MemcardPath[slot], 0, wxEXPAND|wxALL, 5);
sMemcard[slot]->Add(m_MemcardList[slot], 1, wxEXPAND|wxALL, 5); sMemcard[slot]->Add(m_MemcardList[slot], 1, wxEXPAND|wxALL, 5);
sMemcard[slot]->Add(sPages[slot], 0, wxEXPAND|wxALL, 1); sMemcard[slot]->Add(sPages[slot], 0, wxEXPAND|wxALL, 1);
@ -551,7 +551,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
{ {
wxString temp = wxFileSelector(_T("Select a save file to import"), wxString temp = wxFileSelector(_T("Select a save file to import"),
(strcmp(DefaultIOPath.c_str(), "/Users/GC") == 0) ? wxEmptyString : (strcmp(DefaultIOPath.c_str(), "/Users/GC") == 0) ? wxEmptyString :
DefaultIOPath.c_str(), wxEmptyString, wxEmptyString, wxString::Format wxString::FromAscii(DefaultIOPath.c_str()), wxEmptyString, wxEmptyString, wxString::Format
( (
_T("Gamecube save files(*.gci,*.gcs,*.sav)|*.gci;*.gcs;*.sav|" _T("Gamecube save files(*.gci,*.gcs,*.sav)|*.gci;*.gcs;*.sav|"
"Native GCI files (*.gci)|*.gci|" "Native GCI files (*.gci)|*.gci|"
@ -592,7 +592,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
memoryCard[slot]->DEntry_FileName(index,tempC2); memoryCard[slot]->DEntry_FileName(index,tempC2);
sprintf(tempC, "%s_%s.gci", tempC, tempC2); sprintf(tempC, "%s_%s.gci", tempC, tempC2);
wxString temp = wxFileSelector(_T("Save GCI as.."), _T(DefaultIOPath.c_str()), wxString temp = wxFileSelector(_T("Save GCI as.."), _T(DefaultIOPath.c_str()),
_T(tempC), _T(".gci"), wxString::Format wxString::FromAscii(tempC), _T(".gci"), wxString::Format
( (
_T("GCI File(*.gci)|*.gci"), _T("GCI File(*.gci)|*.gci"),
wxFileSelectorDefaultWildcardStr, wxFileSelectorDefaultWildcardStr,