📄 dos.c
字号:
{
printf("SNEeSe requires a 486 or better!\n");
return 1;
}
set_display_switch_mode(SWITCH_BACKGROUND);
#ifdef ALLEGRO_WINDOWS
set_window_title("SNEeSeW");
#else
set_window_title("SNEeSe");
#endif
/* Should hook this for exit, actually... */
set_close_button_callback(NULL);
/* This helps SNEeSe find it's home directory, for .cfg/.dat file,
* when started from a different directory
* (ie, drag-and-drop via Windows Explorer)
*/
{
char exe_name[MAXPATH];
get_executable_name(exe_name, MAXPATH);
fnsplit(exe_name, f_drive, f_dir, f_file, f_ext);
}
fnmerge(home_dir, f_drive, f_dir, "", "");
if (getcwd(start_dir, MAXPATH) == NULL)
{
printf("Failure getting current directory!\n");
printf("Report this immediately!\n");
return 1;
}
strcpy(cfg_name, home_dir);
strcpy(dat_name, home_dir);
#ifdef ALLEGRO_WINDOWS
strcat(cfg_name, "sneesew.cfg");
#else
strcat(cfg_name, "sneese.cfg");
#endif
strcat(dat_name, "sneese.dat");
set_config_file(cfg_name); /* Yup, config files exist */
mouse_available = install_mouse();
if (mouse_available == -1) mouse_available = 0;
install_keyboard();
install_key_release_callback();
#if 0
#ifdef ALLEGRO_DOS
if (load_joystick_data(NULL))
{
install_joystick(JOY_TYPE_6BUTTON);
}
#else
#endif
#endif
if (load_joystick_data(NULL))
{
install_joystick(JOY_TYPE_AUTODETECT);
}
#if 0
#endif
#ifndef NO_GUI
#if GUI_DEFAULT
GUI_ENABLED = 1;
#else
GUI_ENABLED = 0;
#endif
#endif
return 0;
}
void platform_exit(void)
{
if (strlen(start_dir))
{
chdir(start_dir);
}
}
int parse_args(int argc, char **argv, char **names, int maxnames)
{
/* Start: command line parser */
char *tv;
int tc;
int numnames;
numnames = 0;
for (tc = 1; tc < argc; tc++)
{
int i;
tv = argv[tc];
#if defined(UNIX) || defined(__BEOS__)
if ((*tv == '-'))
#else
if ((*tv == '-') || (*tv == '/'))
#endif
{
switch (*(tv + 1))
{
#ifndef NO_GUI
case 'c':
case 'C':
if (!stricmp(tv + 1, "cli")) /* Disable enabled GUI */
{
GUI_ENABLED = 0;
}
else
{
printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
#endif
case 'd':
case 'D':
if (!stricmp(tv + 1, "ds"))
{
sound_enabled = 0;
}
else
{
printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
case 'm':
case 'M':
if (sscanf(tv + 2, "%u", &i) != 1) cmdhelp();
if (i > 6) cmdhelp();
SCREEN_MODE = i;
cfg_changed = -1;
break;
case 'f':
case 'F':
switch (strlen(tv + 1))
{
case 2:
switch(*(tv + 2))
{
case 'l': case 'L': /* Force LoROM */
ROM_memory_map = LoROM; break;
case 'h': case 'H': /* Force HiROM */
ROM_memory_map = HiROM; break;
case 'n': case 'N': /* Force non-interleaved */
ROM_interleaved = Off; break;
case 'i': case 'I': /* Force interleaved */
ROM_interleaved = On; break;
default: printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
case 3:
switch(*(tv + 2))
{
case 'v': case 'V': /* Force video standard */
switch(*(tv + 3))
{
case 'n': case 'N': /* Force NTSC video standard */
ROM_video_standard = NTSC_video; break;
case 'p': case 'P': /* Force PAL video standard */
ROM_video_standard = PAL_video; break;
default: printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
case 'p': case 'P': /* FPS counter */
switch(*(tv + 3))
{
case 's': case 'S': /* FPS counter */
FPS_ENABLED = (0 - 1); break;
default: printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
default: printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
default: printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
case 'n': case 'N': /* Force no header */
if (strlen(tv + 1) != 1)
{
printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
ROM_has_header = Off; break;
case 'h': case 'H': /* Force header */
if (strlen(tv + 1) != 1)
{
printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
ROM_has_header = On; break;
case '?':
if (strlen(tv + 1) != 1)
{
printf("Invalid switch: %s\n", tv);
}
cmdhelp(); return 1;
#ifndef NO_GUI
case 'g':
case 'G':
if (!stricmp(tv + 1, "gui")) /* Enable disabled GUI */
{
GUI_ENABLED = (0 - 1);
}
else
{
printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
#endif
case 'p':
case 'P':
switch (strlen(tv + 1))
{
case 2:
switch(*(tv + 2))
{
case 'b': case 'B': /* Enable cache preloads */
cfg_changed = (0 - 1);
preload_cache = TRUE; break;
case 'm': case 'M': /* Enable MMX support */
cfg_changed = (0 - 1);
use_mmx = TRUE; use_fpu_copies = FALSE; break;
case 'f': case 'F': /* Enable FPU copies */
cfg_changed = (0 - 1);
use_fpu_copies = TRUE; break;
case 'd': case 'D': /* Disable MMX/FPU support */
cfg_changed = (0 - 1);
use_mmx = use_fpu_copies = FALSE; break;
case 't': case 'T': /* Disable cache preloads */
cfg_changed = (0 - 1);
preload_cache = FALSE; break;
default: printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
case 3:
switch(*(tv + 2))
{
case 'b': case 'B': /* Enable cache preloads (alternate) */
if (*(tv + 3) == '2')
{
cfg_changed = (0 - 1);
preload_cache_2 = TRUE; break;
}
else
{
printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
case 't': case 'T': /* Disable cache preloads (alternate) */
if (*(tv + 3) == '2')
{
cfg_changed = (0 - 1);
preload_cache_2 = FALSE; break;
}
else
{
printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
default: printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
default: printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
case 's':
case 'S':
if (!stricmp(tv + 1, "savedir"))
{
if (tc + 1 >= argc)
{
printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
if (strlen(argv[tc + 1]) > MAXPATH - 1)
{
printf("Path too long: %s\n", argv[tc + 1]); cmdhelp(); return 1;
}
memset(save_dir, 0, MAXPATH);
strcpy(save_dir, argv[++tc]);
cfg_changed = -1;
}
else if (!stricmp(tv + 1, "saveext"))
{
if (tc + 1 >= argc)
{
printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
if (strlen(argv[tc + 1]) > MAXEXT - 1)
{
printf("Extension too long: %s\n", argv[tc + 1]); cmdhelp(); return 1;
}
memset(save_extension, 0, MAXEXT);
strcpy(save_extension, argv[++tc]);
cfg_changed = -1;
}
else if (!stricmp(tv + 1, "sm"))
{
sound_enabled = 1;
}
else if (!stricmp(tv + 1, "s"))
{
sound_enabled = 2;
}
else if (!stricmp(tv + 1, "se"))
{
sound_echo_enabled = 1;
}
else if (!stricmp(tv + 1, "sde"))
{
sound_echo_enabled = 0;
}
else if (!stricmp(tv + 1, "sg"))
{
sound_gauss_enabled = 1;
}
else if (!stricmp(tv + 1, "sdg"))
{
sound_gauss_enabled = 0;
}
else
{
printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
break;
default:
printf("Invalid switch: %s\n", tv); cmdhelp(); return 1;
}
} else {
if (numnames < maxnames) names[numnames++] = tv;
else { cmdhelp(); return 1; }
}
}
#ifndef NO_GUI
if (!GUI_ENABLED)
{
if (numnames == 0)
{
if (cfg_changed == 0) cmdhelp();
if (cfg_changed != 0)
{
printf("Configuration updated\n");
SaveConfig();
}
return 1;
}
}
#endif
if (numnames < maxnames) names[numnames] = NULL;
return 0;
/* End: command line parser */
}
void *platform_get_gfx_buffer(
int depth, int width, int height, int hslack, int vslack,
SNEESE_GFX_BUFFER *gfx_buffer)
{
int needed_w, needed_h;
needed_w = width + hslack;
needed_h = height + vslack * 2 + (hslack ? 1 : 0);
gfx_buffer->depth = depth;
gfx_buffer->width = width;
gfx_buffer->height = height;
gfx_buffer->hslack = hslack;
gfx_buffer->vslack = vslack;
gfx_buffer->needed_w = needed_w;
gfx_buffer->needed_h = needed_h;
if (gfx_buffer->subbitmap)
{
destroy_bitmap(gfx_buffer->subbitmap);
gfx_buffer->subbitmap = NULL;
}
if (gfx_buffer->bitmap)
{
destroy_bitmap(gfx_buffer->bitmap);
gfx_buffer->bitmap = NULL;
}
gfx_buffer->bitmap = create_bitmap_ex(depth, needed_w, needed_h);
if (!gfx_buffer->bitmap)
{
printf("Failure creating internal render bitmap!\n");
return 0;
}
gfx_buffer->subbitmap =
create_sub_bitmap(gfx_buffer->bitmap, hslack, vslack, width, height);
if (!gfx_buffer->subbitmap)
{
printf("Failure creating internal render bitmap!\n");
return 0;
}
return gfx_buffer->buffer = ((BITMAP *) gfx_buffer->subbitmap)->line[0];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -