|
|
| version 1.27, 2007/01/23 15:48:20 | version 1.30, 2008/04/02 13:03:35 |
|---|---|
| Line 1 | Line 1 |
| /* $Id$ */ | |
| /* | /* |
| * Copyright (c) 2003 NONAKA Kimihiro | * Copyright (c) 2003 NONAKA Kimihiro |
| * All rights reserved. | * All rights reserved. |
| Line 29 | Line 31 |
| #include <getopt.h> | #include <getopt.h> |
| #include <signal.h> | #include <signal.h> |
| #if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER) | |
| #include <SDL.h> | |
| #endif | |
| #include "np2.h" | #include "np2.h" |
| #include "diskdrv.h" | #include "diskdrv.h" |
| #include "dosio.h" | #include "dosio.h" |
| Line 42 | Line 48 |
| #include "toolkit.h" | #include "toolkit.h" |
| #include "kdispwin.h" | #include "kdispwin.h" |
| #include "sysmenu.h" | |
| #include "toolwin.h" | #include "toolwin.h" |
| #include "viewer.h" | #include "viewer.h" |
| #include "debugwin.h" | #include "debugwin.h" |
| Line 50 | Line 55 |
| #include "commng.h" | #include "commng.h" |
| #include "fontmng.h" | #include "fontmng.h" |
| #include "inputmng.h" | |
| #include "joymng.h" | #include "joymng.h" |
| #include "kbdmng.h" | #include "kbdmng.h" |
| #include "mousemng.h" | #include "mousemng.h" |
| Line 61 | Line 65 |
| /* | /* |
| * resume | |
| */ | |
| static const char np2resumeext[] = "sav"; | |
| /* | |
| * failure signale handler | * failure signale handler |
| */ | */ |
| typedef void sigfunc(int); | typedef void sigfunc(int); |
| Line 100 sighandler(int signo) | Line 98 sighandler(int signo) |
| static struct option longopts[] = { | static struct option longopts[] = { |
| { "config", required_argument, 0, 'c' }, | { "config", required_argument, 0, 'c' }, |
| { "timidity-config", required_argument, 0, 'C' }, | { "timidity-config", required_argument, 0, 'C' }, |
| #if defined(USE_SDL) || defined(USE_SYSMENU) | |
| { "ttfont", required_argument, 0, 't' }, | |
| #endif | |
| { "help", no_argument, 0, 'h' }, | { "help", no_argument, 0, 'h' }, |
| { 0, 0, 0, 0 }, | { 0, 0, 0, 0 }, |
| }; | }; |
| Line 118 usage(void) | Line 113 usage(void) |
| printf("\t--help [-h] : print this message\n"); | printf("\t--help [-h] : print this message\n"); |
| printf("\t--config [-c] <file> : specify config file\n"); | printf("\t--config [-c] <file> : specify config file\n"); |
| printf("\t--timidity-config [-C] <file> : specify timidity config file\n"); | printf("\t--timidity-config [-C] <file> : specify timidity config file\n"); |
| #if defined(USE_SDL) || defined(USE_SYSMENU) | |
| printf("\t--ttfont [-t] <file> : specify TrueType font\n"); | |
| #endif | |
| exit(1); | exit(1); |
| } | } |
| Line 150 main(int argc, char *argv[]) | Line 142 main(int argc, char *argv[]) |
| exit(1); | exit(1); |
| } | } |
| milstr_ncpy(modulefile, optarg, sizeof(modulefile)); | milstr_ncpy(modulefile, optarg, sizeof(modulefile)); |
| /* resume/statsave dir */ | |
| file_cpyname(statpath, modulefile, sizeof(statpath)); | |
| file_cutname(statpath); | |
| break; | break; |
| case 'C': | case 'C': |
| Line 165 main(int argc, char *argv[]) | Line 153 main(int argc, char *argv[]) |
| sizeof(timidity_cfgfile_path)); | sizeof(timidity_cfgfile_path)); |
| break; | break; |
| case 't': | |
| if (stat(optarg, &sb) < 0 || !S_ISREG(sb.st_mode)) { | |
| fprintf(stderr, "Can't access %s.\n", optarg); | |
| exit(1); | |
| } | |
| milstr_ncpy(fontfilename, optarg, sizeof(fontfilename)); | |
| break; | |
| case 'v': | case 'v': |
| verbose = 1; | verbose = 1; |
| break; | break; |
| Line 192 main(int argc, char *argv[]) | Line 172 main(int argc, char *argv[]) |
| if (env) { | if (env) { |
| /* base dir */ | /* base dir */ |
| snprintf(modulefile, sizeof(modulefile), | snprintf(modulefile, sizeof(modulefile), |
| "%s/.np2", env); | "%s/.%s", env, np2appname); |
| if (stat(modulefile, &sb) < 0) { | if (stat(modulefile, &sb) < 0) { |
| if (mkdir(modulefile, 0700) < 0) { | if (mkdir(modulefile, 0700) < 0) { |
| perror(modulefile); | perror(modulefile); |
| Line 204 main(int argc, char *argv[]) | Line 184 main(int argc, char *argv[]) |
| exit(1); | exit(1); |
| } | } |
| /* font file */ | |
| snprintf(np2cfg.fontfile, sizeof(np2cfg.fontfile), | |
| "%s/font.bmp", modulefile); | |
| /* resume/statsave dir */ | |
| file_cpyname(statpath, modulefile, sizeof(statpath)); | |
| file_catname(statpath, "/sav/", sizeof(statpath)); | |
| if (stat(statpath, &sb) < 0) { | |
| if (mkdir(statpath, 0700) < 0) { | |
| perror(statpath); | |
| exit(1); | |
| } | |
| } else if (!S_ISDIR(sb.st_mode)) { | |
| fprintf(stderr, "%s isn't directory.\n", | |
| statpath); | |
| exit(1); | |
| } | |
| /* config file */ | /* config file */ |
| milstr_ncat(modulefile, "/np2rc", sizeof(modulefile)); | milstr_ncat(modulefile, "/np2rc", sizeof(modulefile)); |
| if ((stat(modulefile, &sb) >= 0) | if ((stat(modulefile, &sb) >= 0) |
| Line 231 main(int argc, char *argv[]) | Line 193 main(int argc, char *argv[]) |
| } | } |
| } | } |
| } | } |
| if (modulefile[0] != '\0') { | |
| /* font file */ | |
| snprintf(np2cfg.fontfile, sizeof(np2cfg.fontfile), | |
| "%s/font.bmp", modulefile); | |
| /* resume/statsave dir */ | |
| file_cpyname(statpath, modulefile, sizeof(statpath)); | |
| file_cutname(statpath); | |
| file_catname(statpath, "/sav/", sizeof(statpath)); | |
| if (stat(statpath, &sb) < 0) { | |
| if (mkdir(statpath, 0700) < 0) { | |
| perror(statpath); | |
| exit(1); | |
| } | |
| } else if (!S_ISDIR(sb.st_mode)) { | |
| fprintf(stderr, "%s isn't directory.\n", | |
| statpath); | |
| exit(1); | |
| } | |
| file_catname(statpath, np2appname, sizeof(statpath)); | |
| } | |
| if (timidity_cfgfile_path[0] == '\0') { | if (timidity_cfgfile_path[0] == '\0') { |
| file_cpyname(timidity_cfgfile_path, modulefile, | file_cpyname(timidity_cfgfile_path, modulefile, |
| sizeof(timidity_cfgfile_path)); | sizeof(timidity_cfgfile_path)); |
| Line 248 main(int argc, char *argv[]) | Line 231 main(int argc, char *argv[]) |
| rand_setseed((SINT32)time(NULL)); | rand_setseed((SINT32)time(NULL)); |
| #if defined(GCC_CPU_ARCH_IA32) | |
| mmxflag = havemmx() ? 0 : MMXFLAG_NOTSUPPORT; | mmxflag = havemmx() ? 0 : MMXFLAG_NOTSUPPORT; |
| mmxflag += np2oscfg.disablemmx ? MMXFLAG_DISABLE : 0; | mmxflag += np2oscfg.disablemmx ? MMXFLAG_DISABLE : 0; |
| #endif | |
| TRACEINIT(); | TRACEINIT(); |
| #if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER) | |
| SDL_Init(0); | |
| #endif | |
| if (fontmng_init() != SUCCESS) | if (fontmng_init() != SUCCESS) |
| goto fontmng_failure; | goto fontmng_failure; |
| Line 265 main(int argc, char *argv[]) | Line 250 main(int argc, char *argv[]) |
| toolkit_widget_create(); | toolkit_widget_create(); |
| scrnmng_initialize(); | scrnmng_initialize(); |
| kbdmng_init(); | kbdmng_init(); |
| inputmng_init(); | |
| keystat_initialize(); | keystat_initialize(); |
| scrnmode = 0; | scrnmode = 0; |
| if (np2cfg.RASTER) { | if (np2cfg.RASTER) { |
| scrnmode |= SCRNMODE_HIGHCOLOR; | scrnmode |= SCRNMODE_HIGHCOLOR; |
| } | } |
| if (sysmenu_create() != SUCCESS) | |
| goto sysmenu_failure; | |
| if (scrnmng_create(scrnmode) != SUCCESS) | if (scrnmng_create(scrnmode) != SUCCESS) |
| goto scrnmng_failure; | goto scrnmng_failure; |
| Line 325 main(int argc, char *argv[]) | Line 307 main(int argc, char *argv[]) |
| } | } |
| } | } |
| #if !defined(CPUCORE_IA32) | #if defined(SUPPORT_RESUME) |
| if (np2oscfg.resume) { | if (np2oscfg.resume) { |
| flagload(np2resumeext, "Resume", FALSE); | flagload(np2resumeext, "Resume", FALSE); |
| } | } |
| Line 368 main(int argc, char *argv[]) | Line 350 main(int argc, char *argv[]) |
| scrnmng_destroy(); | scrnmng_destroy(); |
| scrnmng_failure: | scrnmng_failure: |
| sysmenu_destroy(); | |
| sysmenu_failure: | |
| fontmng_terminate(); | fontmng_terminate(); |
| fontmng_failure: | fontmng_failure: |
| if (sys_updates & (SYS_UPDATECFG|SYS_UPDATEOSCFG)) { | if (!np2oscfg.cfgreadonly |
| && (sys_updates & (SYS_UPDATECFG|SYS_UPDATEOSCFG))) { | |
| initsave(); | initsave(); |
| toolwin_writeini(); | toolwin_writeini(); |
| kdispwin_writeini(); | kdispwin_writeini(); |
| Line 383 fontmng_failure: | Line 363 fontmng_failure: |
| skbdwin_deinitialize(); | skbdwin_deinitialize(); |
| #if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER) | |
| SDL_Quit(); | |
| #endif | |
| TRACETERM(); | TRACETERM(); |
| dosio_term(); | dosio_term(); |