--- np2/x11/main.c 2003/11/23 12:46:55 1.5 +++ np2/x11/main.c 2007/01/23 15:48:20 1.27 @@ -10,8 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -27,6 +25,7 @@ #include "compiler.h" +#include #include #include @@ -42,16 +41,23 @@ #include "timing.h" #include "toolkit.h" -#include "keydisp.h" +#include "kdispwin.h" +#include "sysmenu.h" #include "toolwin.h" +#include "viewer.h" +#include "debugwin.h" +#include "skbdwin.h" #include "commng.h" +#include "fontmng.h" +#include "inputmng.h" #include "joymng.h" #include "kbdmng.h" #include "mousemng.h" #include "scrnmng.h" #include "soundmng.h" #include "sysmng.h" +#include "taskmng.h" /* @@ -94,6 +100,9 @@ sighandler(int signo) static struct option longopts[] = { { "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' }, { 0, 0, 0, 0 }, }; @@ -104,7 +113,14 @@ static void usage(void) { - printf("Usage: %s [options] [[FD1 image] [[FD2 image] [[FD3 image] [FD4 image]]]]\n", progname); + printf("Usage: %s [options] [[FD1 image] [[FD2 image] [[FD3 image] [FD4 image]]]]\n\n", progname); + printf("options:\n"); + printf("\t--help [-h] : print this message\n"); + printf("\t--config [-c] : specify config file\n"); + printf("\t--timidity-config [-C] : specify timidity config file\n"); +#if defined(USE_SDL) || defined(USE_SYSMENU) + printf("\t--ttfont [-t] : specify TrueType font\n"); +#endif exit(1); } @@ -126,7 +142,7 @@ main(int argc, char *argv[]) toolkit_initialize(); toolkit_arginit(&argc, &argv); - while ((ch = getopt_long(argc, argv, "c:C:h", longopts, NULL)) != -1) { + while ((ch = getopt_long(argc, argv, "c:C:t:vh", longopts, NULL)) != -1) { switch (ch) { case 'c': if (stat(optarg, &sb) < 0 || !S_ISREG(sb.st_mode)) { @@ -149,6 +165,18 @@ main(int argc, char *argv[]) sizeof(timidity_cfgfile_path)); 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': + verbose = 1; + break; + case 'h': case '?': default: @@ -215,34 +243,44 @@ main(int argc, char *argv[]) file_setcd(modulefile); initload(); toolwin_readini(); - keydisp_readini(); + kdispwin_readini(); + skbdwin_readini(); rand_setseed((SINT32)time(NULL)); -#if defined(__GNUC__) && (defined(i386) || defined(__i386__)) +#if defined(GCC_CPU_ARCH_IA32) mmxflag = havemmx() ? 0 : MMXFLAG_NOTSUPPORT; mmxflag += np2oscfg.disablemmx ? MMXFLAG_DISABLE : 0; #endif TRACEINIT(); - keystat_reset(); + if (fontmng_init() != SUCCESS) + goto fontmng_failure; + + kdispwin_initialize(); + viewer_init(); + skbdwin_initialize(); toolkit_widget_create(); scrnmng_initialize(); kbdmng_init(); + inputmng_init(); + keystat_initialize(); scrnmode = 0; if (np2cfg.RASTER) { scrnmode |= SCRNMODE_HIGHCOLOR; } + if (sysmenu_create() != SUCCESS) + goto sysmenu_failure; if (scrnmng_create(scrnmode) != SUCCESS) - goto resource_cleanup; + goto scrnmng_failure; if (soundmng_initialize() == SUCCESS) { result = soundmng_pcmload(SOUND_PCMSEEK, file_getcd("fddseek.wav")); if (!result) { - result = soundmng_pcmload(SOUND_PCMSEEK, SYSRESPATH "/wav/fddseek.wav"); + result = soundmng_pcmload(SOUND_PCMSEEK, SYSRESPATH "/fddseek.wav"); } if (result) { soundmng_pcmvolume(SOUND_PCMSEEK, np2cfg.MOTORVOL); @@ -250,13 +288,14 @@ main(int argc, char *argv[]) result = soundmng_pcmload(SOUND_PCMSEEK1, file_getcd("fddseek1.wav")); if (!result) { - result = soundmng_pcmload(SOUND_PCMSEEK1, SYSRESPATH "/wav/fddseek1.wav"); + result = soundmng_pcmload(SOUND_PCMSEEK1, SYSRESPATH "/fddseek1.wav"); } if (result) { soundmng_pcmvolume(SOUND_PCMSEEK1, np2cfg.MOTORVOL); } } + joymng_initialize(); mousemng_initialize(); if (np2oscfg.MOUSE_SW) { mouse_running(MOUSE_ON); @@ -264,8 +303,8 @@ main(int argc, char *argv[]) commng_initialize(); sysmng_initialize(); + taskmng_initialize(); - joy_init(); pccore_init(); S98_init(); @@ -279,57 +318,76 @@ main(int argc, char *argv[]) toolwin_create(); } if (np2oscfg.keydisp) { - keydisp_create(); + kdispwin_create(); + } + if (np2oscfg.softkbd) { + skbdwin_create(); } } +#if !defined(CPUCORE_IA32) if (np2oscfg.resume) { flagload(np2resumeext, "Resume", FALSE); } +#endif sysmng_workclockreset(); drvmax = (argc < 4) ? argc : 4; for (i = 0; i < drvmax; i++) { - milstr_ncpy(diskdrv_fname[i],argv[i],sizeof(diskdrv_fname[0])); - diskdrv_delay[i] = 1; + diskdrv_readyfdd(i, argv[i], 0); } setup_signal(SIGINT, sighandler); setup_signal(SIGTERM, sighandler); - np2running = TRUE; toolkit_widget_mainloop(); - np2running = FALSE; rv = 0; - keydisp_destroy(); + kdispwin_destroy(); toolwin_destroy(); + skbdwin_destroy(); pccore_cfgupdate(); mouse_running(MOUSE_OFF); + joymng_deinitialize(); S98_trash(); +#if !defined(CPUCORE_IA32) if (np2oscfg.resume) { flagsave(np2resumeext); } else { flagdelete(np2resumeext); } +#endif pccore_term(); + debugwin_destroy(); soundmng_deinitialize(); scrnmng_destroy(); -resource_cleanup: +scrnmng_failure: + sysmenu_destroy(); + +sysmenu_failure: + fontmng_terminate(); + +fontmng_failure: if (sys_updates & (SYS_UPDATECFG|SYS_UPDATEOSCFG)) { initsave(); toolwin_writeini(); - keydisp_writeini(); + kdispwin_writeini(); + skbdwin_writeini(); } + skbdwin_deinitialize(); + TRACETERM(); dosio_term(); + viewer_term(); + toolkit_terminate(); + return rv; }