static LRESULT CALLBACK PAD1optDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { int i; UINT8 renewal; switch(msg) { case WM_INITDIALOG: for (i=0; i<13; i++) { checkbtnres_load(hWnd, pad1opt + i); } if (np2oscfg.JOYPAD1 & 2) { EnableWindow(GetDlgItem(hWnd, IDC_JOYPAD1), FALSE); } return(TRUE); case WM_NOTIFY: if ((((NMHDR *)lp)->code) == (UINT)PSN_APPLY) { renewal = 0; for (i=0; i<13; i++) { renewal |= checkbtnres_store(hWnd, pad1opt + i); } if (renewal) { joymng_initialize(); sysmng_update(SYS_UPDATECFG); } return(TRUE); } break; } return(FALSE); }
static void dlgupdate(void) { BOOL renewal; int val; renewal = FALSE; val = menudlg_getval(DID_JOYPAD1); if (np2oscfg.JOYPAD1 != (UINT8)val) { np2oscfg.JOYPAD1 = (UINT8)val; renewal = TRUE; } val = menudlg_getval(DID_PAD1_1A) + (menudlg_getval(DID_PAD1_2A) << 1); if (np2oscfg.JOY1BTN[0] != (UINT8)val) { np2oscfg.JOY1BTN[0] = (UINT8)val; renewal = TRUE; } val = menudlg_getval(DID_PAD1_1B) + (menudlg_getval(DID_PAD1_2B) << 1); if (np2oscfg.JOY1BTN[1] != (UINT8)val) { np2oscfg.JOY1BTN[1] = (UINT8)val; renewal = TRUE; } val = menudlg_getval(DID_PAD1_1C) + (menudlg_getval(DID_PAD1_2C) << 1); if (np2oscfg.JOY1BTN[2] != (UINT8)val) { np2oscfg.JOY1BTN[2] = (UINT8)val; renewal = TRUE; } val = menudlg_getval(DID_PAD1_1D) + (menudlg_getval(DID_PAD1_2D) << 1); if (np2oscfg.JOY1BTN[3] != (UINT8)val) { np2oscfg.JOY1BTN[3] = (UINT8)val; renewal = TRUE; } if (renewal) { joymng_initialize(); sysmng_update(SYS_UPDATECFG); } }
/* * main */ int main(int argc, char *argv[]) { struct stat sb; BOOL result; int rv = 1; int ch; int i, drvmax; progname = argv[0]; toolkit_initialize(); toolkit_arginit(&argc, &argv); 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)) { fprintf(stderr, "Can't access %s.\n", optarg); exit(1); } milstr_ncpy(modulefile, optarg, sizeof(modulefile)); /* resume/statsave dir */ file_cpyname(statpath, modulefile, sizeof(statpath)); file_cutname(statpath); break; case 'C': if (stat(optarg, &sb) < 0 || !S_ISREG(sb.st_mode)) { fprintf(stderr, "Can't access %s.\n", optarg); exit(1); } milstr_ncpy(timidity_cfgfile_path, optarg, 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: usage(); break; } } argc -= optind; argv += optind; if (modulefile[0] == '\0') { char *env = getenv("HOME"); if (env) { /* base dir */ snprintf(modulefile, sizeof(modulefile), "%s/.np2", env); if (stat(modulefile, &sb) < 0) { if (mkdir(modulefile, 0700) < 0) { perror(modulefile); exit(1); } } else if (!S_ISDIR(sb.st_mode)) { fprintf(stderr, "%s isn't directory.\n", modulefile); 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 */ milstr_ncat(modulefile, "/np2rc", sizeof(modulefile)); if ((stat(modulefile, &sb) >= 0) && !S_ISREG(sb.st_mode)) { fprintf(stderr, "%s isn't regular file.\n", modulefile); } } } if (timidity_cfgfile_path[0] == '\0') { file_cpyname(timidity_cfgfile_path, modulefile, sizeof(timidity_cfgfile_path)); file_cutname(timidity_cfgfile_path); file_catname(timidity_cfgfile_path, "timidity.cfg", sizeof(timidity_cfgfile_path)); } dosio_init(); file_setcd(modulefile); initload(); toolwin_readini(); kdispwin_readini(); skbdwin_readini(); rand_setseed((SINT32)time(NULL)); #if defined(GCC_CPU_ARCH_IA32) mmxflag = havemmx() ? 0 : MMXFLAG_NOTSUPPORT; mmxflag += np2oscfg.disablemmx ? MMXFLAG_DISABLE : 0; #endif TRACEINIT(); 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 scrnmng_failure; if (soundmng_initialize() == SUCCESS) { result = soundmng_pcmload(SOUND_PCMSEEK, file_getcd("fddseek.wav")); if (!result) { result = soundmng_pcmload(SOUND_PCMSEEK, SYSRESPATH "/fddseek.wav"); } if (result) { soundmng_pcmvolume(SOUND_PCMSEEK, np2cfg.MOTORVOL); } result = soundmng_pcmload(SOUND_PCMSEEK1, file_getcd("fddseek1.wav")); if (!result) { 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); } commng_initialize(); sysmng_initialize(); taskmng_initialize(); pccore_init(); S98_init(); toolkit_widget_show(); scrndraw_redraw(); pccore_reset(); if (!(scrnmode & SCRNMODE_FULLSCREEN)) { if (np2oscfg.toolwin) { toolwin_create(); } if (np2oscfg.keydisp) { 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++) { diskdrv_readyfdd(i, argv[i], 0); } setup_signal(SIGINT, sighandler); setup_signal(SIGTERM, sighandler); toolkit_widget_mainloop(); rv = 0; 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(); scrnmng_failure: sysmenu_destroy(); sysmenu_failure: fontmng_terminate(); fontmng_failure: if (sys_updates & (SYS_UPDATECFG|SYS_UPDATEOSCFG)) { initsave(); toolwin_writeini(); kdispwin_writeini(); skbdwin_writeini(); } skbdwin_deinitialize(); TRACETERM(); dosio_term(); viewer_term(); toolkit_terminate(); return rv; }
int main(void) { NP2MAIN np2main; #ifndef NOSERIAL serial_init(57600); usleep(20000); printf("Serial OK\n"); #endif maple_init(); dc_setup_ta(); init_arm(); __dc_avail = true; dc_savedtimes = 0; dc_joyinput = 0; dc_mouseaxis1 = 0; dc_mouseaxis2 = 0; ui_init(); dosio_init(); file_setcd(modulefile); initload(); TRACEINIT(); keystat_initialize(); mousemng_initialize(); scrnmng_initialize(); UINT8 scrnmode = 0; if (scrnmng_create(scrnmode) != SUCCESS) { return -1; } softkbddc_initialize(); dckbd_bindinit(); dckbd_bindcur(np2oscfg.bindcur); dckbd_bindbtn(np2oscfg.bindbtn); soundmng_initialize(); commng_initialize(); sysmng_initialize(); taskmng_initialize(); joymng_initialize(); pccore_init(); S98_init(); pccore_reset(); scrndraw_redraw(); np2main.uFrameCount = 0; np2main.uWaitCount = 0; np2main.uFrameMax = 1; #if 0 if (np2oscfg.resume) { id = flagload(str_sav, str_resume, FALSE); if (id == DID_CANCEL) { DestroyWindow(hWnd); goto np2main_err4; } } #endif while (dcsys_task()) { if (np2oscfg.NOWAIT) { exec1frame(np2main); if (np2oscfg.DRAW_SKIP) { // nowait frame skip if (np2main.uFrameCount >= np2oscfg.DRAW_SKIP) { processwait(np2main, 0); } } else { // nowait auto skip if (timing_getcount()) { processwait(np2main, 0); } } } else if (np2oscfg.DRAW_SKIP) { // frame skip if (np2main.uFrameCount < np2oscfg.DRAW_SKIP) { exec1frame(np2main); } else { processwait(np2main, np2oscfg.DRAW_SKIP); } } else { // auto skip if (!np2main.uWaitCount) { exec1frame(np2main); const UINT uCount = timing_getcount(); if (np2main.uFrameCount > uCount) { np2main.uWaitCount = np2main.uFrameCount; if (np2main.uFrameMax > 1) { np2main.uFrameMax--; } } else if (np2main.uFrameCount >= np2main.uFrameMax) { if (np2main.uFrameMax < MAX_FRAMESKIP) { np2main.uFrameMax++; } if (uCount >= MAX_FRAMESKIP) { timing_reset(); } else { timing_setcount(uCount - np2main.uFrameCount); } framereset(np2main, 0); } } else { processwait(np2main, np2main.uWaitCount); np2main.uWaitCount = np2main.uFrameCount; } } } pccore_cfgupdate(); #if 0 if (np2oscfg.resume) { flagsave(str_sav); } else { flagdelete(str_sav); } #endif pccore_term(); S98_trash(); scrnmng_destroy(); if (sys_updates & (SYS_UPDATECFG | SYS_UPDATEOSCFG)) { initsave(); } TRACETERM(); dosio_term(); #ifdef NOSERIAL (*(void(**)(int))0x8c0000e0)(1); while (1) { } #endif return 0; }