Removed long disabled code for inserting command line parameters for ELFs into EE memory. We'd have to do this completely differently in the current system anyway.

This commit is contained in:
Pseudonym 2014-08-15 18:41:24 +01:00
parent 4400b56fb5
commit 9ebd9c4447
1 changed files with 0 additions and 114 deletions

View File

@ -25,120 +25,6 @@ u32 ElfEntry;
std::pair<u32,u32> ElfTextRange;
wxString LastELF;
#if 0
// fixme: ELF command line option system.
// It parses a command line and pastes it into PS2 memory, and then points the a0 register at it.
// A user-written ELF can then load the data and respond accordingly. Needs a rewrite using modern
// string parsing utils. :)
//2002-09-19 (Florin)
char args[256]="ez.m2v"; //to be accessed by other files
uptr args_ptr; //a big value; in fact, it is an address
static bool isEmpty(int addr)
{
return ((eeMem->Main[addr] == 0) || (eeMem->Main[addr] == 32));
}
//in a0 is passed the address of the command line args,
//i.e. a pointer to an area like this:
//+00 unknown/unused
//+04 argc; number of arguments
//+08 argv[0]; address of the first parameter - program name (char*) -
//+08 argv[1]; address of the second parameter (char*) |
//+0C argv[2]; and so on |
//........ |
//+08+4*argc the program name(first param) <--
//+08+4*argc+strlen(argv[0]+1) the rest of params; i.e. a copy of 'args'
// see above 'char args[256];'
// The results of this function will normally be that it finds an arg at 13 chars, and another at 0.
// It'd probably be easier to 0 out all 256 chars, split args, copy all the arguments in, and note
// the locations of each split... --arcum42
static uint parseCommandLine( const wxString& filename )
{
if ( ( args_ptr != 0xFFFFFFFF ) && ( args_ptr > (4 + 4 + 256) ) )
{
const char *p;
int argc, i, ret = 0;
u32 args_end;
args_ptr -= 256;
args[ 255 ] = 0;
// 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( &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.
#ifdef _WIN32
p = strrchr( filename, '\\' );
#else //linux
p = strrchr( filename, '/' );
if( p == NULL ) p = strchr(filename, '\\');
#endif
if (p)
p++;
else
p = filename;
args_ptr -= strlen( p ) + 1;
//fill param 0; i.e. name of the program
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-- )
{
while (i && isEmpty(args_ptr + i )) { i--; }
// If the last char is a space, set it to 0.
if ( eeMem->Main[ args_ptr + i + 1 ] == ' ') eeMem->Main[ args_ptr + i + 1 ] = 0;
while (i && !isEmpty(args_ptr + i )) { i--; }
// Now that we've gone back a word, increase the number of arguments,
// and mark the location of the argument.
if (!isEmpty(args_ptr + i )) // i <= 0
{
// If the spot we are on is not a space or null , use it.
argc++;
ret = args_ptr - 4 - 4 - argc * 4;
if (ret < 0 ) return 0;
((u32*)eeMem->Main)[ args_ptr / 4 - argc ] = args_ptr + i;
}
else
{
if (!isEmpty(args_ptr + i + 1))
{
// Otherwise, use the next character .
argc++;
ret = args_ptr - 4 - 4 - argc * 4;
if (ret < 0 ) return 0;
((u32*)eeMem->Main)[ args_ptr / 4 - argc ] = args_ptr + i + 1;
}
}
}
// Pass the number of arguments, and if we have arguments.
((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;
}
return 0;
}
#endif
//---------------
// All of ElfObjects functions.
ElfObject::ElfObject(const wxString& srcfile, IsoFile isofile)
: data( wxULongLong(isofile.getLength()).GetLo(), L"ELF headers" )