From ded0aabaa53d9a5b81b553f39a842e75ff59d366 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Fri, 27 Nov 2009 19:23:21 +0000 Subject: [PATCH] Signed/Unsigned bug introduced from r2217 squashed (fixes Issue 483: Extreme G3 crash); also added some more complete filesystem partition detection and logging to IsoFS. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2263 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/CDVD/IsoFS/IsoDirectory.h | 14 ++++- pcsx2/CDVD/IsoFS/IsoFS.cpp | 84 ++++++++++++++++++++++++---- pcsx2/CDVD/IsoFS/IsoFileDescriptor.h | 2 + pcsx2/CDVD/IsoFileFormats.cpp | 14 ++--- pcsx2/CDVD/IsoFileFormats.h | 6 +- pcsx2/Vif1Dma.cpp | 2 +- 6 files changed, 98 insertions(+), 24 deletions(-) diff --git a/pcsx2/CDVD/IsoFS/IsoDirectory.h b/pcsx2/CDVD/IsoFS/IsoDirectory.h index c5c5024318..52d3d2932d 100644 --- a/pcsx2/CDVD/IsoFS/IsoDirectory.h +++ b/pcsx2/CDVD/IsoFS/IsoDirectory.h @@ -1,16 +1,24 @@ #pragma once +enum IsoFS_Type +{ + FStype_ISO9660 = 1, + FStype_Joliet = 2, +}; + class IsoDirectory { public: - SectorSource& internalReader; - std::vector files; + SectorSource& internalReader; + std::vector files; + IsoFS_Type m_fstype; public: IsoDirectory(SectorSource& r); IsoDirectory(SectorSource& r, IsoFileDescriptor directoryEntry); - ~IsoDirectory() throw(); + virtual ~IsoDirectory() throw(); + wxString FStype_ToString() const; SectorSource& GetReader() const { return internalReader; } bool Exists(const wxString& filePath) const; diff --git a/pcsx2/CDVD/IsoFS/IsoFS.cpp b/pcsx2/CDVD/IsoFS/IsoFS.cpp index 9c0bed47b9..baf65f5eaa 100644 --- a/pcsx2/CDVD/IsoFS/IsoFS.cpp +++ b/pcsx2/CDVD/IsoFS/IsoFS.cpp @@ -23,22 +23,81 @@ // IsoDirectory ////////////////////////////////////////////////////////////////////////// -// Used to load the Root directory from an image -IsoDirectory::IsoDirectory(SectorSource& r) : - internalReader(r) +//u8 filesystemType; // 0x01 = ISO9660, 0x02 = Joliet, 0xFF = NULL +//u8 volID[5]; // "CD001" + + +wxString IsoDirectory::FStype_ToString() const { - u8 sector[2048]; + switch( m_fstype ) + { + case FStype_ISO9660: L"ISO9660"; break; + case FStype_Joliet: L"Joliet"; break; + } - internalReader.readSector(sector,16); + return wxsFormat( L"Unrecognized Code (0x%x)", m_fstype ); +} - IsoFileDescriptor rootDirEntry(sector+156,38); +// Used to load the Root directory from an image +IsoDirectory::IsoDirectory(SectorSource& r) + : internalReader(r) +{ + m_fstype = FStype_ISO9660; - Init(rootDirEntry); + IsoFileDescriptor rootDirEntry; + bool isValid = false; + uint i = 16; + while( true ) + { + u8 sector[2048]; + internalReader.readSector(sector,i); + if( memcmp( §or[1], "CD001", 5 ) == 0 ) + { + if( sector[0] == 0 ) + { + Console.WriteLn( Color_Green, "(IsoFS) Block 0x%x: Boot partition info.", i ); + } + + else if( sector[0] == 1 ) + { + Console.WriteLn( "(IsoFS) Block 0x%x: Primary partition info.", i ); + rootDirEntry.Load( sector+156, 38 ); + isValid = true; + } + + else if( sector[0] == 2 ) + { + // Probably means Joliet (long filenames support), which PCSX2 doesn't care about. + Console.WriteLn( Color_Green, "(IsoFS) Block 0x%x: Extended partition info.", i ); + m_fstype = FStype_Joliet; + } + + else if( sector[0] == 0xff ) + { + // Null terminator. End of partition information. + break; + } + } + else + { + sector[9] = 0; + Console.Error( "(IsoFS) Invalid partition descriptor encountered at block 0x%x: '%s'", i, §or[1] ); + break; // if no valid root partition was found, an exception will be thrown below. + } + + ++i; + } + + if( !isValid ) + throw Exception::BadStream( "IsoFS", "Root directory not found on ISO image." ); + + DevCon.WriteLn( "(IsoFS) Filesystem is %s", FStype_ToString() ); + Init( rootDirEntry ); } // Used to load a specific directory from a file descriptor -IsoDirectory::IsoDirectory(SectorSource& r, IsoFileDescriptor directoryEntry) : - internalReader(r) +IsoDirectory::IsoDirectory(SectorSource& r, IsoFileDescriptor directoryEntry) + : internalReader(r) { Init(directoryEntry); } @@ -54,7 +113,7 @@ void IsoDirectory::Init(const IsoFileDescriptor& directoryEntry) files.clear(); - int remainingSize = directoryEntry.size; + uint remainingSize = directoryEntry.size; u8 b[257]; @@ -150,6 +209,11 @@ IsoFileDescriptor::IsoFileDescriptor() } IsoFileDescriptor::IsoFileDescriptor(const u8* data, int length) +{ + Load( data, length ); +} + +void IsoFileDescriptor::Load( const u8* data, int length ) { lba = (u32&)data[2]; size = (u32&)data[10]; diff --git a/pcsx2/CDVD/IsoFS/IsoFileDescriptor.h b/pcsx2/CDVD/IsoFS/IsoFileDescriptor.h index ac2dd8eb78..8467633b75 100644 --- a/pcsx2/CDVD/IsoFS/IsoFileDescriptor.h +++ b/pcsx2/CDVD/IsoFS/IsoFileDescriptor.h @@ -22,6 +22,8 @@ struct IsoFileDescriptor IsoFileDescriptor(); IsoFileDescriptor(const u8* data, int length); + void Load( const u8* data, int length ); + bool IsFile() const { return !(flags & 2); } bool IsDir() const { return !IsFile(); } }; \ No newline at end of file diff --git a/pcsx2/CDVD/IsoFileFormats.cpp b/pcsx2/CDVD/IsoFileFormats.cpp index 70e4a4390a..fbb7f6e834 100644 --- a/pcsx2/CDVD/IsoFileFormats.cpp +++ b/pcsx2/CDVD/IsoFileFormats.cpp @@ -25,7 +25,7 @@ static bool detect(isoFile *iso) { - u8 buf[2448]; + u8 buf[2456]; u8* pbuf; if (!isoReadBlock(iso, buf, 16)) return false; // Not readable @@ -60,7 +60,7 @@ static bool _isoReadDtable(isoFile *iso) return true; } -static bool tryIsoType(isoFile *iso, u32 size, u32 offset, u32 blockofs) +static bool tryIsoType(isoFile *iso, u32 size, s32 offset, s32 blockofs) { iso->blocksize = size; iso->offset = offset; @@ -182,8 +182,8 @@ isoFile *isoOpen(const char *filename) } Console.WriteLn("isoOpen: %s ok", iso->filename); - Console.WriteLn("offset = %u", iso->offset); - Console.WriteLn("blockofs = %u", iso->blockofs); + Console.WriteLn("offset = %d", iso->offset); + Console.WriteLn("blockofs = %d", iso->blockofs); Console.WriteLn("blocksize = %u", iso->blocksize); Console.WriteLn("blocks = %u", iso->blocks); Console.WriteLn("type = %u", iso->type); @@ -224,18 +224,18 @@ isoFile *isoCreate(const char *filename, int flags) } Console.WriteLn("isoCreate: %s ok", iso->filename); - Console.WriteLn("offset = %u", iso->offset); + Console.WriteLn("offset = %d", iso->offset); return iso; } -bool isoSetFormat(isoFile *iso, uint blockofs, uint blocksize, uint blocks) +bool isoSetFormat(isoFile *iso, int blockofs, uint blocksize, uint blocks) { iso->blocksize = blocksize; iso->blocks = blocks; iso->blockofs = blockofs; - Console.WriteLn("blockofs = %u", iso->blockofs); + Console.WriteLn("blockofs = %d", iso->blockofs); Console.WriteLn("blocksize = %u", iso->blocksize); Console.WriteLn("blocks = %u", iso->blocks); diff --git a/pcsx2/CDVD/IsoFileFormats.h b/pcsx2/CDVD/IsoFileFormats.h index 5ac271784a..3f22e186d4 100644 --- a/pcsx2/CDVD/IsoFileFormats.h +++ b/pcsx2/CDVD/IsoFileFormats.h @@ -56,8 +56,8 @@ struct isoFile char filename[256]; isoType type; u32 flags; - u32 offset; - u32 blockofs; + s32 offset; + s32 blockofs; u32 blocksize; u32 blocks; void *handle; @@ -73,7 +73,7 @@ struct isoFile extern isoFile *isoOpen(const char *filename); extern isoFile *isoCreate(const char *filename, int mode); -extern bool isoSetFormat(isoFile *iso, uint blockofs, uint blocksize, uint blocks); +extern bool isoSetFormat(isoFile *iso, int blockofs, uint blocksize, uint blocks); extern bool isoDetect(isoFile *iso); extern bool isoReadBlock(isoFile *iso, u8 *dst, uint lsn); extern bool isoWriteBlock(isoFile *iso, u8 *src, uint lsn); diff --git a/pcsx2/Vif1Dma.cpp b/pcsx2/Vif1Dma.cpp index 12503e3a61..907bd8b129 100644 --- a/pcsx2/Vif1Dma.cpp +++ b/pcsx2/Vif1Dma.cpp @@ -1112,7 +1112,7 @@ void vif1Write32(u32 mem, u32 value) #ifdef PCSX2_DEVBUILD /* Only FDR bit is writable, so mask the rest */ - if ((vif1Regs->stat.FDR) ^(value & VIF1_STAT_FDR)) + if ((vif1Regs->stat.FDR) ^ ((tVIF_STAT&)value).FDR) { // different so can't be stalled if (vif1Regs->stat.test(VIF1_STAT_INT | VIF1_STAT_VSS | VIF1_STAT_VIS | VIF1_STAT_VFS))