/** * Show and process the floppy disk image dialog. */ void DlgFloppy_Main(void) { int but, i; char *newdisk; char dlgname[MAX_FLOPPYDRIVES][64], dlgdiskdir[64]; SDLGui_CenterDlg(floppydlg); /* Set up dialog to actual values: */ const char *name; floppydlg[FLOPPYDLG_AUTORUN].state &= ~SG_SELECTED; name = DISKA_NAME; /* Filename */ if (!name)dlgname[0][0] = '\0'; else File_ShrinkName(dlgname[0], name,floppydlg[FLOPPYDLG_DISKA].w); floppydlg[FLOPPYDLG_DISKA].txt = dlgname[0]; name = DISKB_NAME; /* Filename */ if (!name)dlgname[1][0] = '\0'; else File_ShrinkName(dlgname[1], name,floppydlg[FLOPPYDLG_DISKB].w); floppydlg[FLOPPYDLG_DISKB].txt = dlgname[1]; name = TAPE_NAME; /* Filename */ if (!name)dlgname[2][0] = '\0'; else File_ShrinkName(dlgname[2], name,floppydlg[FLOPPYDLG_DISK2].w); floppydlg[FLOPPYDLG_DISK2].txt = dlgname[2]; name = CART_NAME; /* Filename */ if (!name)dlgname[3][0] = '\0'; else File_ShrinkName(dlgname[3], name,floppydlg[FLOPPYDLG_DISK3].w); floppydlg[FLOPPYDLG_DISK3].txt = dlgname[3]; /* Default image directory: */ File_ShrinkName(dlgdiskdir,szDiskImageDirectory, floppydlg[FLOPPYDLG_IMGDIR].w); floppydlg[FLOPPYDLG_IMGDIR].txt = dlgdiskdir; /* Draw and process the dialog */ do { but = SDLGui_DoDialog(floppydlg, NULL); switch (but) { case FLOPPYDLG_EJECTA: /* Eject disk in drive A: */ Floppy_SetDiskFileNameNone(0); dlgname[0][0] = '\0'; DiskImage_RemoveDisk(0); break; case FLOPPYDLG_BROWSEA: /* Choose a new disk A: */ DlgDisk_BrowseDisk(dlgname[0], 0, FLOPPYDLG_DISKA); if (strlen(szDiskFileName[0]) > 0){ if (GenericInterface_InsertDiskImage(0, szDiskFileName[0])) { printf("Error loading drivea:%s\n", szDiskFileName[0]); } else { if(floppydlg[FLOPPYDLG_AUTORUN].state & SG_SELECTED){ char AutoType_String[256]; char *pBuffer = malloc(512*5); int nAutoRunResult = AMSDOS_GenerateAutorunCommand(pBuffer,AutoType_String); if(nAutoRunResult==0){ printf("auto(%s)\n",AutoType_String); AutoType_SetString(AutoType_String, TRUE, TRUE); } else printf("error auto(%d)\n",nAutoRunResult); free(pBuffer); } sprintf(DISKA_NAME,"%s",szDiskFileName[0]); } } break; case FLOPPYDLG_EJECTB: /* Eject disk in drive B: */ Floppy_SetDiskFileNameNone(1); dlgname[1][0] = '\0'; DiskImage_RemoveDisk(1); break; case FLOPPYDLG_BROWSEB: /* Choose a new disk B: */ DlgDisk_BrowseDisk(dlgname[1], 1, FLOPPYDLG_DISKB); if (strlen(szDiskFileName[1]) > 0){ if (GenericInterface_InsertDiskImage(1, szDiskFileName[1])) { printf("Error loading driveb:%s\n", szDiskFileName[1]); } else sprintf(DISKB_NAME,"%s",szDiskFileName[1]); } case FLOPPYDLG_EJECT2: /* Eject tape */ Floppy_SetDiskFileNameNone(2); dlgname[2][0] = '\0'; Tape_Remove(); sprintf(TAPE_NAME,"\0"); break; case FLOPPYDLG_BROWSE2: /* Choose a new tape */ DlgDisk_BrowseDisk(dlgname[2], 2, FLOPPYDLG_DISK2); if (strlen(szDiskFileName[2]) > 0){ if (GenericInterface_InsertTape(szDiskFileName[2])) { printf("Error loading Tape:%s\n", szDiskFileName[2]); } else { sprintf(TAPE_NAME,"%s",szDiskFileName[2]); AutoType_SetString( "|TAPE\nRUN\"\n\n", TRUE, TRUE); } } break; case FLOPPYDLG_EJECT3: /* Eject cart */ Floppy_SetDiskFileNameNone(3); dlgname[3][0] = '\0'; GenericInterface_RemoveCartridge(); sprintf(CART_NAME,"\0"); break; case FLOPPYDLG_BROWSE3: /* Choose a new cart */ DlgDisk_BrowseDisk(dlgname[3], 3, FLOPPYDLG_DISK3); if (strlen(szDiskFileName[3]) > 0){ if(strcmp (szDiskFileName[3],"/home/tech/Bureau/GIT/arnold/roms/parados.rom") == 0){ GenericInterface_LoadRom(7, szDiskFileName[3]); CPC_Reset(); break; } if (GenericInterface_InsertCartridge(szDiskFileName[3])) { printf("Error loading cart:%s\n",szDiskFileName[3]); } else sprintf(CART_NAME,"%s",szDiskFileName[3]); // strcpy(prefs->DrivePath[3], szDiskFileName[3]); } break; case FLOPPYDLG_BROWSEIMG: DlgDisk_BrowseDir(dlgdiskdir,szDiskImageDirectory,floppydlg[FLOPPYDLG_IMGDIR].w); break; /* case FLOPPYDLG_CREATEIMG: newdisk = DlgNewDisk_Main(); if (newdisk) { DlgFloppy_QueryInsert(dlgname[0], FLOPPYDLG_DISKA, dlgname[1], FLOPPYDLG_DISKB, newdisk); free(newdisk); } break; */ } gui_poll_events(); } while (but != FLOPPYDLG_EXIT && but != SDLGUI_QUIT && but != SDLGUI_ERROR && !bQuitProgram); }
void init_main(int argc, char *argv[]) { int kbd = -1; /* name, has_arg, flag, val */ static struct option long_options[] = { {"tape", 1, 0, 't'}, {"drivea", 1, 0, 'a'}, {"driveb", 1, 0, 'b'}, {"cart", 1, 0, 'c'}, {"frameskip", 1, 0, 'f'}, {"fps", 1, 0, 'z'}, {"sync", 0, 0, 'y'}, #ifdef HAVE_GL {"opengl", 1, 0, 'g'}, #endif {"crtctype", 1, 0, 'r'}, {"cpctype", 1, 0, 'p'}, {"snapshot", 1, 0, 's'}, {"kbdtype", 1, 0, 'k'}, {"soundplugin", 1, 0, 'o'}, #ifdef HAVE_SDL {"doublesize", 0, 0, 'd'}, {"fullscreen", 0, 0, 'u'}, #endif {"help", 0, 0, 'h'}, {0, 0, 0, 0} }; int c; int digit_optind = 0; /* Default is 50 frames per second without sync to screen refresh rate */ int fps = 50; int sync = 0; int refresh; char *tape = NULL; char *drivea = NULL; char *driveb = NULL; char *cart = NULL; char *frameskip = NULL; char *crtctype = NULL; char *cpctype = NULL; char *snapshot = NULL; char *kbdtype = NULL; char *soundplugin = NULL; #ifdef HAVE_SDL BOOL doubled = FALSE; BOOL fullscreen = FALSE; #endif do { int this_option_optind = optind ? optind : 1; int option_index = 0; c = getopt_long_only (argc, argv, "", long_options, &option_index); printf("c: %i %c\n", c, c); switch(c) { case 'h': case '?': help_exit(); break; case 't': tape = optarg; break; case 'a': drivea = optarg; break; case 'b': driveb = optarg; break; case 'c': cart = optarg; break; #ifdef HAVE_SDL case 'd': doubled = TRUE; break; case 'u': fullscreen = TRUE; break; #endif case 'f': frameskip = optarg; break; case 'y': /* Activate sync to screen refresh rate */ sync=1; #ifdef HAVE_GL /* Activate sync on nVIDIA chips */ putenv("__GL_SYNC_TO_VBLANK=1"); #endif break; case 'z': /* Set refresh rate in Hz directly */ fps = atoi(optarg); break; case 'r': crtctype = optarg; break; case 'p': cpctype = optarg; break; case 's': snapshot = optarg; break; case 'k': kbdtype = optarg; break; case 'o': soundplugin = optarg; break; } } while (c != -1); printf("tape: %s\n", tape); CPCEmulation_InitialiseDefaultSetup(); ConfigCPC6128(); if (tape) { if (!GenericInterface_InsertTape(tape)) { printf(Messages[73], tape); } } if (drivea) { if (!GenericInterface_InsertDiskImage(0, drivea)) { printf(Messages[74], drivea); } } if (driveb) { if (!GenericInterface_InsertDiskImage(1, driveb)) { printf(Messages[74], driveb); } } if (cart) { if (!GenericInterface_InsertCartridge(cart)) { printf(Messages[75], cart); } } if (frameskip) { int fskip; fskip = atoi(frameskip); CPC_SetFrameSkip(fskip); } if (crtctype) { int crtc; crtc = atoi(crtctype); CRTC_SetType(crtc); } if (cpctype) { int cpc; cpc = atoi(cpctype); switch (cpc) { case 0: { ConfigCPC464(); } break; case 1: { ConfigCPC664(); } break; case 2: { ConfigCPC6128(); } break; case 3: { ConfigCPC6128s(); } break; case 4: { Config464Plus(); } break; case 5: { Config6128Plus(); } break; case 6: { ConfigKCCompact(); } break; default: { ConfigCPC6128(); } break; } } if (snapshot) { if (!GenericInterface_LoadSnapshot(snapshot)) { printf(Messages[78], snapshot); } } if ( kbdtype ) kbd = atoi(kbdtype); printf("kbdtype: %i\n",kbd); if ( soundplugin ) { sound_plugin = getSoundplugin(soundplugin); } else { sound_plugin = SOUND_PLUGIN_AUTO; } if ( sound_plugin == SOUND_PLUGIN_AUTO ) { sound_plugin = autoDetectSoundplugin(); } printf("soundplugin: %i (%s)\n",sound_plugin,soundpluginNames[sound_plugin]); #ifdef HAVE_SDL fprintf(stderr, "Initializing SDL\n"); if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO|SDL_INIT_TIMER |SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE) < 0 ) { fprintf(stderr, "SDL could not be initialized: %s\n", SDL_GetError()); exit(1); } sdl_InitialiseKeyboardMapping(0); sdl_InitialiseJoysticks(); atexit(SDL_Quit); #endif Host_InitDriveLEDIndicator(); Render_SetDisplayWindowed(); /* This hardly ever works, because SDL_Flip is often not capable of waiting for a vertical retrace */ if (sync) { /* Synchronize to vertical retrace */ #ifndef HAVE_SDL fprintf(stderr,"SDL must be present to enable vertical sync.\n"); #else refresh = sdl_RefreshRate(); if (!refresh) fprintf(stderr,"Refresh rate cannot be determined, using %d FPS.\n",fps); else { fps = refresh; fprintf(stderr,"Running Arnold with screen refresh rate of %d FPS.\n",fps); } #endif } /* Set refresh rate */ fprintf(stderr,"Running emulation with %d fps\n",fps); #ifdef HAVE_SDL sdl_SetFPS(fps); #endif /* Set also fps in Arnold */ CPC_SetAudioActive(TRUE,fps); printf("%s", Messages[77]); #ifdef HAVE_SDL if (doubled) { #ifdef HAVE_GTK gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON (btn_double), TRUE ); #else sdl_SetDoubled(doubled); #endif } if (fullscreen) { toggleFullscreenLater = TRUE; } if (kbd != -1) sdl_InitialiseKeyboardMapping(kbd); #endif printf("%s", Messages[76]); /* Enter GTK+ event loop when GTK+ is compiled in. Use own main loop * otherwise. */ #ifdef HAVE_GTK /*while (1) { CPCEmulation_Run(); SDL_Delay(20); }*/ /* gtkui_init must be called after CPC_SetAudioActive */ gtkui_init(argc, argv); gtkui_run(); #else CPCEmulation_Run(); #endif //printf("aaaa"); //CPCEmulation_Finish(); //printf("bbbb"); Host_FreeDriveLEDIndicator(); }