/[pcsx2_0.9.7]/trunk/pcsx2/Elfheader.cpp
ViewVC logotype

Diff of /trunk/pcsx2/Elfheader.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/pcsx2/Elfheader.cpp	2010/09/07 03:24:11	31
+++ trunk/pcsx2/Elfheader.cpp	2010/09/07 11:08:22	62
@@ -37,7 +37,7 @@
 
 static bool isEmpty(int addr)
 {
-	return ((PS2MEM_BASE[addr] == 0) || (PS2MEM_BASE[addr] == 32));
+	return ((eeMem->Main[addr] == 0) || (eeMem->Main[addr] == 32));
 }
 
 //in a0 is passed the address of the command line args,
@@ -70,8 +70,8 @@
 
 		// Copy the parameters into the section of memory at args_ptr,
 		// then zero out anything past the end of args till 256 chars is reached.
-		memcpy( &PS2MEM_BASE[ args_ptr ], args, 256 );
-		memset( &PS2MEM_BASE[ args_ptr + strlen( args ) ], 0, 256 - strlen( args ) );
+		memcpy( &eeMem->Main[ args_ptr ], args, 256 );
+		memset( &eeMem->Main[ args_ptr + strlen( args ) ], 0, 256 - strlen( args ) );
 		args_end = args_ptr + strlen( args );
 
 		// Set p to just the filename, no path.
@@ -90,7 +90,7 @@
 		args_ptr -= strlen( p ) + 1;
 
 		//fill param 0; i.e. name of the program
-		strcpy( (char*)&PS2MEM_BASE[ args_ptr ], p );
+		strcpy( (char*)&eeMem->Main[ args_ptr ], p );
 
 		// Start from the end of where we wrote to, not including all the zero'd out area.
 		for ( i = args_end - args_ptr + 1, argc = 0; i > 0; i-- )
@@ -98,7 +98,7 @@
 			while (i && isEmpty(args_ptr + i ))  { i--; }
 
 			// If the last char is a space, set it to 0.
-			if ( PS2MEM_BASE[ args_ptr + i + 1 ] == ' ') PS2MEM_BASE[ args_ptr + i + 1 ] = 0;
+			if ( eeMem->Main[ args_ptr + i + 1 ] == ' ') eeMem->Main[ args_ptr + i + 1 ] = 0;
 
 			while (i && !isEmpty(args_ptr + i )) { i--; }
 
@@ -111,7 +111,7 @@
 				ret = args_ptr - 4 - 4 - argc * 4;
 
 				if (ret < 0 ) return 0;
-				((u32*)PS2MEM_BASE)[ args_ptr / 4 - argc ] = args_ptr + i;
+				((u32*)eeMem->Main)[ args_ptr / 4 - argc ] = args_ptr + i;
 			}
 			else
 			{
@@ -122,14 +122,14 @@
 					ret = args_ptr - 4 - 4 - argc * 4;
 
 					if (ret < 0 ) return 0;
-					((u32*)PS2MEM_BASE)[ args_ptr / 4 - argc ] = args_ptr + i + 1;
+					((u32*)eeMem->Main)[ args_ptr / 4 - argc ] = args_ptr + i + 1;
 				}
 			}
 		}
 
 		// Pass the number of arguments, and if we have arguments.
-		((u32*)PS2MEM_BASE)[ args_ptr /4 - argc - 1 ] = argc;		      //how many args
-		((u32*)PS2MEM_BASE)[ args_ptr /4 - argc - 2 ] = ( argc > 0);	//have args?	//not used, cannot be filled at all
+		((u32*)eeMem->Main)[ args_ptr /4 - argc - 1 ] = argc;		      //how many args
+		((u32*)eeMem->Main)[ args_ptr /4 - argc - 2 ] = ( argc > 0);	//have args?	//not used, cannot be filled at all
 
 		return ret;
 	}
@@ -219,7 +219,7 @@
 	if (machine != NULL) ELF_LOG( "machine:  %s", machine );
 
 	ELF_LOG("version:   %d",header.e_version);
-	ELF_LOG("entry:	 %08x",header.e_entry);
+	ELF_LOG("entry:	    %08x",header.e_entry);
 	ELF_LOG("flags:     %08x",header.e_flags);
 	ELF_LOG("eh size:   %08x",header.e_ehsize);
 	ELF_LOG("ph off:    %08x",header.e_phoff);
@@ -242,7 +242,7 @@
 void ElfObject::readIso(IsoFile file)
 {
 	int rsize = file.read(data.GetPtr(), data.GetSizeInBytes());
-	if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream( filename );
+	if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream(filename);
 }
 
 void ElfObject::readFile()
@@ -257,19 +257,19 @@
 	rsize = fread(data.GetPtr(), 1, data.GetSizeInBytes(), f);
 	fclose( f );
 
-	if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream( filename );
+	if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream(filename);
 }
 
 void ElfObject::checkElfSize(s64 elfsize)
 {
 	if (elfsize > 0xfffffff)
-		throw Exception::BadStream( filename, wxLt("Illegal ELF file size, over 2GB!") );
+		throw Exception::BadStream(filename).SetBothMsgs(wxLt("Illegal ELF file size over 2GB!"));
 
 	if (elfsize == -1)
-		throw Exception::BadStream( filename, wxLt("Elf file does not exist! ") );
+		throw Exception::BadStream(filename).SetBothMsgs(wxLt("ELF file does not exist!"));
 
 	if (elfsize == 0)
-		throw Exception::BadStream( filename, wxLt("Unexpected end of ELF file: ") );
+		throw Exception::BadStream(filename).SetBothMsgs(wxLt("Unexpected end of ELF file."));
 }
 
 u32 ElfObject::getCRC()
@@ -318,7 +318,7 @@
 
 					// used to be paddr
 					memcpy_fast(
-						&PS2MEM_BASE[proghead[ i ].p_vaddr & 0x1ffffff],
+						&eeMem->Main[proghead[ i ].p_vaddr & 0x1ffffff],
 						data.GetPtr(proghead[ i ].p_offset), size
 					);
 
@@ -431,16 +431,15 @@
 		int size = file.getLength();
 		if( size == 0 ) return 0;
 
-
 		while( !file.eof() )
 		{
-			wxString original( fromUTF8(file.readLine().c_str()) );
-			ParsedAssignmentString parts( original );
+			const wxString original( fromUTF8(file.readLine().c_str()) );
+			const ParsedAssignmentString parts( original );
 
 			if( parts.lvalue.IsEmpty() && parts.rvalue.IsEmpty() ) continue;
 			if( parts.rvalue.IsEmpty() )
 			{
-				Console.Error( "(GetElfName) Unusual or malformed entry in SYSTEM.CNF ignored:" );
+				Console.Warning( "(SYSTEM.CNF) Unusual or malformed entry in SYSTEM.CNF ignored:" );
 				Console.Indent().WriteLn( original );
 				continue;
 			}
@@ -448,22 +447,22 @@
 			if( parts.lvalue == L"BOOT2" )
 			{
 				name = parts.rvalue;
-				Console.WriteLn( Color_StrongBlue, L"(GetElfName) Detected PS2 Disc = " + name );
+				Console.WriteLn( Color_StrongBlue, L"(SYSTEM.CNF) Detected PS2 Disc = " + name );
 				retype = 2;
 			}
 			else if( parts.lvalue == L"BOOT" )
 			{
 				name = parts.rvalue;
-				Console.WriteLn( Color_StrongBlue, L"(GetElfName) Detected PSX/PSone Disc = " + name );
+				Console.WriteLn( Color_StrongBlue, L"(SYSTEM.CNF) Detected PSX/PSone Disc = " + name );
 				retype = 1;
 			}
 			else if( parts.lvalue == L"VMODE" )
 			{
-				Console.WriteLn( Color_StrongBlue, L"(GetElfName) Disc region type = " + parts.rvalue );
+				Console.WriteLn( Color_Blue, L"(SYSTEM.CNF) Disc region type = " + parts.rvalue );
 			}
 			else if( parts.lvalue == L"VER" )
 			{
-				Console.WriteLn( Color_StrongBlue, L"(GetElfName) Software version = " + parts.rvalue );
+				Console.WriteLn( Color_Blue, L"(SYSTEM.CNF) Software version = " + parts.rvalue );
 			}
 		}
 
@@ -473,12 +472,14 @@
 			return 0;
 		}
 	}
-	catch (Exception::BadStream&)
+	catch (Exception::BadStream& ex)
 	{
+		Console.Error(ex.FormatDiagnosticMessage());
 		return 0;		// ISO error
 	}
 	catch( Exception::FileNotFound& )
 	{
+		//Console.Warning(ex.FormatDiagnosticMessage());
 		return 0;		// no SYSTEM.CNF, not a PS1/PS2 disc.
 	}
 

 

  ViewVC Help
Powered by ViewVC 1.1.22