Files
libretro-atari800/libretro/cmdline.c
T
greenchili2 20d59afb3f Fix first run crashing on Xbox One. Added savestate support. Rewind … (#87)
* Fix first run crashing on Xbox One.
* Added savestate support.
* Rewind works.  Fixes issue #83 and possibly #49.
* Added Disc Control menu.  Supports Disks, Tapes and M3U files (issue #66).
* Added in support for 5200 Super Carts.
* Better support for 5200 controller.
* Added Paddle support.
* Converted Core Options menu to v2.
* Moved some core options into submenus.
* Added controller mappings for Ports 2-4.
* Added options for Dual Stick and Swap Ports.  Fixes issue #76.
* Joystick/Console now controlled more easily with device type Atari Keyboard.
* Added 4 Hi-Res Artifacting modes.  Restart does something now.
* When core option changed only reboot if necessary.  Removed several hardcoded controller binds.  Fixed issue #29.  Joypad input ignored when virtual keyboard active.
* SIO Acceleration now defaults to enabled.  Fix for Bounty Bob (5200 & lift fix A800).
* Added Atari 800 carts to autodetect DB.
* Added more Carts to DB.
* Fixed Drive Index not being reset on 'restart'.
* Changed Atari Joystick default mappings to something more reasonable.
2023-07-31 23:35:21 +02:00

124 lines
3.1 KiB
C

#include <ctype.h>
//Args for experimental_cmdline
static char ARGUV[64][1024];
static unsigned char ARGUC=0;
// Args for Core
static char XARGV[64][1024];
static const char* xargv_cmd[64];
int PARAMCOUNT=0;
extern int skel_main(int argc, char *argv[]);
void parse_cmdline( const char *argv );
void Add_Option(const char* option)
{
static int first=0;
if(first==0)
{
PARAMCOUNT=0;
first++;
}
sprintf(XARGV[PARAMCOUNT++],"%s", option);
}
int pre_main(const char *argv)
{
int i;
bool Only1Arg;
parse_cmdline(argv);
Only1Arg = (strcmp(ARGUV[0],"prg") == 0) ? 0 : 1;
for (i = 0; i<64; i++)
xargv_cmd[i] = NULL;
if(Only1Arg)
{
Add_Option("prg");
Add_Option(RPATH/*ARGUV[0]*/);
}
else
{ // Pass all cmdline args
for(i = 0; i < ARGUC; i++)
Add_Option(ARGUV[i]);
}
for (i = 0; i < PARAMCOUNT; i++)
{
xargv_cmd[i] = (char*)(XARGV[i]);
log_cb(RETRO_LOG_INFO, "%2d %s\n",i,XARGV[i]);
}
skel_main(PARAMCOUNT,( char **)xargv_cmd);
xargv_cmd[PARAMCOUNT - 2] = NULL;
return 0;
}
void parse_cmdline(const char *argv)
{
char *p,*p2,*start_of_word;
int c,c2;
static char buffer[512*4];
enum states { DULL, IN_WORD, IN_STRING } state = DULL;
strcpy(buffer,argv);
strcat(buffer," \0");
for (p = buffer; *p != '\0'; p++)
{
c = (unsigned char) *p; /* convert to unsigned char for is* functions */
switch (state)
{
case DULL: /* not in a word, not in a double quoted string */
if (isspace(c)) /* still not in a word, so ignore this char */
continue;
/* not a space -- if it's a double quote we go to IN_STRING, else to IN_WORD */
if (c == '"')
{
state = IN_STRING;
start_of_word = p + 1; /* word starts at *next* char, not this one */
continue;
}
state = IN_WORD;
start_of_word = p; /* word starts here */
continue;
case IN_STRING:
/* we're in a double quoted string, so keep going until we hit a close " */
if (c == '"')
{
/* word goes from start_of_word to p-1 */
//... do something with the word ...
for (c2 = 0,p2 = start_of_word; p2 < p; p2++, c2++)
ARGUV[ARGUC][c2] = (unsigned char) *p2;
ARGUC++;
state = DULL; /* back to "not in word, not in string" state */
}
continue; /* either still IN_STRING or we handled the end above */
case IN_WORD:
/* we're in a word, so keep going until we get to a space */
if (isspace(c))
{
/* word goes from start_of_word to p-1 */
//... do something with the word ...
for (c2 = 0,p2 = start_of_word; p2 <p; p2++,c2++)
ARGUV[ARGUC][c2] = (unsigned char) *p2;
ARGUC++;
state = DULL; /* back to "not in word, not in string" state */
}
continue; /* either still IN_WORD or we handled the end above */
}
}
}