Process Win32 commandline
This commit is contained in:
parent
e4b3ca7109
commit
d809adb540
139
src/main.c
139
src/main.c
@ -37,6 +37,10 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#else
|
||||||
|
#if _MSC_VER < 1900
|
||||||
|
#define snprintf _snprintf
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
@ -104,35 +108,45 @@ static int setsize_height;
|
|||||||
//--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles ---
|
//--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles ---
|
||||||
void Display_syntax(void)
|
void Display_syntax(void)
|
||||||
{
|
{
|
||||||
int mode_index;
|
int mode_index, i;
|
||||||
printf("Syntax: grafx2 [<arguments>] [<picture1>] [<picture2>]\n\n");
|
char modes[1024*2];
|
||||||
printf("<arguments> can be:]\n");
|
const char * syntax =
|
||||||
printf("\t-? -h -H -help for this help screen\n");
|
"Syntax: grafx2 [<arguments>] [<picture1>] [<picture2>]\n\n"
|
||||||
printf("\t-wide to emulate a video mode with wide pixels (2x1)\n");
|
"<arguments> can be:\n"
|
||||||
printf("\t-tall to emulate a video mode with tall pixels (1x2)\n");
|
"\t-? -h -H -help for this help screen\n"
|
||||||
printf("\t-double to emulate a video mode with double pixels (2x2)\n");
|
"\t-wide to emulate a video mode with wide pixels (2x1)\n"
|
||||||
printf("\t-wide2 to emulate a video mode with double wide pixels (4x2)\n");
|
"\t-tall to emulate a video mode with tall pixels (1x2)\n"
|
||||||
printf("\t-tall2 to emulate a video mode with double tall pixels (2x4)\n");
|
"\t-double to emulate a video mode with double pixels (2x2)\n"
|
||||||
printf("\t-triple to emulate a video mode with triple pixels (3x3)\n");
|
"\t-wide2 to emulate a video mode with double wide pixels (4x2)\n"
|
||||||
printf("\t-quadruple to emulate a video mode with quadruple pixels (4x4)\n");
|
"\t-tall2 to emulate a video mode with double tall pixels (2x4)\n"
|
||||||
printf("\t-rgb n to reduce RGB precision (2 to 256, 256=max precision)\n");
|
"\t-triple to emulate a video mode with triple pixels (3x3)\n"
|
||||||
printf("\t-gamma n to adjust Gamma correction (1 to 30, 10=no correction)\n");
|
"\t-quadruple to emulate a video mode with quadruple pixels (4x4)\n"
|
||||||
printf("\t-skin <filename> to use an alternate file with the menu graphics\n");
|
"\t-rgb n to reduce RGB precision (2 to 256, 256=max precision)\n"
|
||||||
printf("\t-mode <videomode> to set a video mode\n");
|
"\t-gamma n to adjust Gamma correction (1 to 30, 10=no correction)\n"
|
||||||
printf("\t-size <resolution> to set the image size\n");
|
"\t-skin <filename> to use an alternate file with the menu graphics\n"
|
||||||
printf("Arguments can be prefixed either by / - or --\n");
|
"\t-mode <videomode> to set a video mode\n"
|
||||||
printf("They can also be abbreviated.\n\n");
|
"\t-size <resolution> to set the image size\n"
|
||||||
printf("Available video modes:\n\n");
|
"Arguments can be prefixed either by / - or --\n"
|
||||||
|
"They can also be abbreviated.\n\n";
|
||||||
|
fputs(syntax, stdout);
|
||||||
|
|
||||||
|
i = snprintf(modes, sizeof(modes), "Available video modes:\n\n");
|
||||||
for (mode_index = 0; mode_index < Nb_video_modes; mode_index += 12)
|
for (mode_index = 0; mode_index < Nb_video_modes; mode_index += 12)
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
for (k = 0; k < 6; k++)
|
for (k = 0; k < 6; k++)
|
||||||
{
|
{
|
||||||
if (mode_index + k >= Nb_video_modes) break;
|
if (mode_index + k >= Nb_video_modes) break;
|
||||||
printf("%12s",Mode_label(mode_index + k));
|
i += snprintf(modes + i, sizeof(modes) - i, "%12s", Mode_label(mode_index + k));
|
||||||
}
|
}
|
||||||
puts("");
|
i += snprintf(modes + i, sizeof(modes) - i, "\n");
|
||||||
}
|
}
|
||||||
|
fputs(modes, stdout);
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
|
MessageBoxA(NULL, syntax, "GrafX2", MB_OK);
|
||||||
|
MessageBoxA(NULL, modes, "GrafX2", MB_OK);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------- Sortie impromptue ----------------------------
|
// ---------------------------- Sortie impromptue ----------------------------
|
||||||
@ -1169,21 +1183,84 @@ int main(int argc,char * argv[])
|
|||||||
{
|
{
|
||||||
#if defined(WIN32) && !defined(USE_SDL) && !defined(USE_SDL2)
|
#if defined(WIN32) && !defined(USE_SDL) && !defined(USE_SDL2)
|
||||||
TCHAR ModuleFileName[MAX_PATH];
|
TCHAR ModuleFileName[MAX_PATH];
|
||||||
TCHAR ModuleShortFileName[MAX_PATH];
|
TCHAR TmpArg[MAX_PATH];
|
||||||
int i;
|
TCHAR ShortFileName[MAX_PATH];
|
||||||
|
int i, j, k;
|
||||||
|
int inquote = 0;
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
char arg_buffer[4096];
|
char arg_buffer[4096];
|
||||||
char * argv[16] = {NULL};
|
char * argv[64] = {NULL};
|
||||||
|
|
||||||
Init_Win32(hInstance, hPrevInstance);
|
Init_Win32(hInstance, hPrevInstance);
|
||||||
GetModuleFileName(NULL, ModuleFileName, MAX_PATH);
|
if (GetModuleFileName(NULL, ModuleFileName, MAX_PATH) == 0)
|
||||||
GetShortPathName(ModuleFileName, ModuleShortFileName, MAX_PATH);
|
{
|
||||||
argv[argc++] = arg_buffer;
|
MessageBoxA(NULL, "Error initializing program", NULL, MB_OK | MB_ICONERROR);
|
||||||
for (i = 0; i < (int)sizeof(arg_buffer); i++) {
|
return 1;
|
||||||
arg_buffer[i] = (char)ModuleShortFileName[i];
|
|
||||||
if (arg_buffer[i] == 0) break;
|
|
||||||
}
|
}
|
||||||
// TODO : parse command line
|
GetShortPathName(ModuleFileName, ShortFileName, MAX_PATH);
|
||||||
|
argv[argc++] = arg_buffer;
|
||||||
|
for (i = 0; i < (int)sizeof(arg_buffer); )
|
||||||
|
{
|
||||||
|
arg_buffer[i] = (char)ShortFileName[i];
|
||||||
|
if (arg_buffer[i++] == 0) break;
|
||||||
|
}
|
||||||
|
k = 0;
|
||||||
|
for (j = 0; pCmdLine[j] != 0 && k < MAX_PATH - 1; j++)
|
||||||
|
{
|
||||||
|
if (inquote)
|
||||||
|
{
|
||||||
|
if (pCmdLine[j] == '"')
|
||||||
|
{
|
||||||
|
inquote = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (pCmdLine[j] == '"')
|
||||||
|
{
|
||||||
|
inquote = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (pCmdLine[j] == ' ' || pCmdLine[j] == '\t')
|
||||||
|
{ // next argument
|
||||||
|
TmpArg[k++] = '\0';
|
||||||
|
argv[argc++] = arg_buffer + i;
|
||||||
|
if (GetShortPathName(TmpArg, ShortFileName, MAX_PATH) > 0)
|
||||||
|
{
|
||||||
|
for (k = 0; ShortFileName[k] != 0; k++)
|
||||||
|
arg_buffer[i++] = ShortFileName[k];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (k = 0; TmpArg[k] != 0; k++)
|
||||||
|
arg_buffer[i++] = TmpArg[k];
|
||||||
|
}
|
||||||
|
arg_buffer[i++] = 0;
|
||||||
|
k = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TmpArg[k++] = pCmdLine[j];
|
||||||
|
}
|
||||||
|
TmpArg[k] = '\0';
|
||||||
|
if (k > 0)
|
||||||
|
{
|
||||||
|
argv[argc++] = arg_buffer + i;
|
||||||
|
if (GetShortPathName(TmpArg, ShortFileName, MAX_PATH) > 0)
|
||||||
|
{
|
||||||
|
for (k = 0; ShortFileName[k] != 0; k++)
|
||||||
|
arg_buffer[i++] = ShortFileName[k];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (k = 0; TmpArg[k] != 0; k++)
|
||||||
|
arg_buffer[i++] = TmpArg[k];
|
||||||
|
}
|
||||||
|
arg_buffer[i++] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO : nCmdShow indicates if the window must be maximized, etc.
|
||||||
#endif
|
#endif
|
||||||
if(!Init_program(argc,argv))
|
if(!Init_program(argc,argv))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user