static void init_mio(void) { free(mio_rom); mio_rom = (UBYTE *)Util_malloc(mio_rom_size); if (!Atari800_LoadImage(mio_rom_filename, mio_rom, mio_rom_size)) { free(mio_rom); mio_rom = NULL; return; } D(printf("Loaded mio rom image\n")); PBI_MIO_enabled = TRUE; if (PBI_SCSI_disk != NULL) fclose(PBI_SCSI_disk); if (!Util_filenamenotset(mio_scsi_disk_filename)) { PBI_SCSI_disk = fopen(mio_scsi_disk_filename, "rb+"); if (PBI_SCSI_disk == NULL) { Log_print("Error opening SCSI disk image:%s", mio_scsi_disk_filename); } else { D(printf("Opened SCSI disk image\n")); mio_scsi_enabled = TRUE; } } if (!mio_scsi_enabled) { PBI_SCSI_BSY = TRUE; /* makes MIO give up easier */ } free(mio_ram); mio_ram = (UBYTE *)Util_malloc(mio_ram_size); memset(mio_ram, 0, mio_ram_size); }
void PBI_MIO_WriteConfig(FILE *fp) { fprintf(fp, "MIO_ROM=%s\n", mio_rom_filename); if (!Util_filenamenotset(mio_scsi_disk_filename)) { fprintf(fp, "MIO_SCSI_DISK=%s\n", mio_scsi_disk_filename); } }
int Atari800_Initialise(int *argc, char *argv[]) { int i, j; const char *rom_filename = NULL; const char *rom2_filename = NULL; const char *run_direct = NULL; #ifndef BASIC const char *state_file = NULL; #endif #ifdef __PLUS /* Atari800Win PLus doesn't use configuration files, it reads configuration from the Registry */ #ifndef _WX_ int bUpdateRegistry = (*argc > 1); #endif int bTapeFile = FALSE; int nCartType = CARTRIDGE_type; /* It is necessary because of the CARTRIDGE_Start (there must not be the registry-read value available at startup) */ CARTRIDGE_type = CARTRIDGE_NONE; #ifndef _WX_ /* Print the time info in the "Log file" window */ Misc_PrintTime(); /* Force screen refreshing */ g_nTestVal = _GetRefreshRate() - 1; g_ulAtariState = ATARI_UNINITIALIZED; #endif /* _WX_ */ #elif defined(MACOSX) #else /* __PLUS */ const char *rtconfig_filename = NULL; int got_config; int help_only = FALSE; if (*argc > 1) { for (i = j = 1; i < *argc; i++) { if (strcmp(argv[i], "-config") == 0) { rtconfig_filename = argv[++i]; } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "--version") == 0) { printf("%s\n", Atari800_TITLE); return FALSE; } else if (strcmp(argv[i], "--usage") == 0 || strcmp(argv[i], "--help") == 0) { argv[j++] = "-help"; } else if (strcmp(argv[i], "-verbose") == 0) { verbose = TRUE; } else { argv[j++] = argv[i]; } } *argc = j; } got_config = CFG_LoadConfig(rtconfig_filename); /* try to find ROM images if the configuration file is not found or it does not specify some ROM paths (blank paths count as specified) */ CFG_FindROMImages("", TRUE); /* current directory */ #if defined(unix) || defined(__unix__) || defined(__linux__) CFG_FindROMImages("/usr/share/atari800", TRUE); #endif if (*argc > 0 && argv[0] != NULL) { char atari800_exe_dir[FILENAME_MAX]; char atari800_exe_rom_dir[FILENAME_MAX]; /* the directory of the Atari800 program */ Util_splitpath(argv[0], atari800_exe_dir, NULL); CFG_FindROMImages(atari800_exe_dir, TRUE); /* "rom" and "ROM" subdirectories of this directory */ Util_catpath(atari800_exe_rom_dir, atari800_exe_dir, "rom"); CFG_FindROMImages(atari800_exe_rom_dir, TRUE); /* skip "ROM" on systems that are known to be case-insensitive */ #if !defined(DJGPP) && !defined(WIN32) Util_catpath(atari800_exe_rom_dir, atari800_exe_dir, "ROM"); CFG_FindROMImages(atari800_exe_rom_dir, TRUE); #endif } /* finally if nothing is found, set some defaults to make the configuration file easier to edit */ if (Util_filenamenotset(CFG_osa_filename)) strcpy(CFG_osa_filename, "atariosa.rom"); if (Util_filenamenotset(CFG_osb_filename)) strcpy(CFG_osb_filename, "atariosb.rom"); if (Util_filenamenotset(CFG_xlxe_filename)) strcpy(CFG_xlxe_filename, "atarixl.rom"); if (Util_filenamenotset(CFG_5200_filename)) strcpy(CFG_5200_filename, "5200.rom"); if (Util_filenamenotset(CFG_basic_filename)) strcpy(CFG_basic_filename, "ataribas.rom"); /* if no configuration file read, try to save one with the defaults */ if (!got_config) CFG_WriteConfig(); #endif /* __PLUS */ for (i = j = 1; i < *argc; i++) { if (strcmp(argv[i], "-atari") == 0) { if (Atari800_machine_type != Atari800_MACHINE_OSA) { Atari800_machine_type = Atari800_MACHINE_OSB; MEMORY_ram_size = 48; } } else if (strcmp(argv[i], "-xl") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = 64; } else if (strcmp(argv[i], "-xe") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = 128; } else if (strcmp(argv[i], "-320xe") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = MEMORY_RAM_320_COMPY_SHOP; } else if (strcmp(argv[i], "-rambo") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = MEMORY_RAM_320_RAMBO; } else if (strcmp(argv[i], "-5200") == 0) { Atari800_machine_type = Atari800_MACHINE_5200; MEMORY_ram_size = 16; } else if (strcmp(argv[i], "-nobasic") == 0) Atari800_disable_basic = TRUE; else if (strcmp(argv[i], "-basic") == 0) Atari800_disable_basic = FALSE; else if (strcmp(argv[i], "-nopatch") == 0) ESC_enable_sio_patch = FALSE; else if (strcmp(argv[i], "-nopatchall") == 0) #ifdef D_PATCH ESC_enable_sio_patch = Devices_enable_h_patch = Devices_enable_d_patch = Devices_enable_p_patch = Devices_enable_r_patch = FALSE; #else ESC_enable_sio_patch = Devices_enable_h_patch = Devices_enable_p_patch = Devices_enable_r_patch = FALSE; #endif else if (strcmp(argv[i], "-pal") == 0) Atari800_tv_mode = Atari800_TV_PAL; else if (strcmp(argv[i], "-ntsc") == 0) Atari800_tv_mode = Atari800_TV_NTSC; else if (strcmp(argv[i], "-a") == 0) { Atari800_machine_type = Atari800_MACHINE_OSA; MEMORY_ram_size = 48; } else if (strcmp(argv[i], "-b") == 0) { Atari800_machine_type = Atari800_MACHINE_OSB; MEMORY_ram_size = 48; } else if (strcmp(argv[i], "-emuos") == 0) emuos_mode = 2; else if (strcmp(argv[i], "-c") == 0) { if (MEMORY_ram_size == 48) MEMORY_ram_size = 52; } else { /* parameters that take additional argument follow here */ int i_a = (i + 1 < *argc); /* is argument available? */ int a_m = FALSE; /* error, argument missing! */ if (strcmp(argv[i], "-osa_rom") == 0) { if (i_a) Util_strlcpy(CFG_osa_filename, argv[++i], sizeof(CFG_osa_filename)); else a_m = TRUE; } #if 0 /* TBD what to do with R device */ #ifdef R_IO_DEVICE else if (strcmp(argv[i], "-rdevice") == 0) { Devices_enable_r_patch = TRUE; #ifdef R_SERIAL if (i_a && i + 2 < *argc && *argv[i + 1] != '-') { /* optional serial device name */ struct stat statbuf; if (! stat(argv[i + 1], &statbuf)) { if (S_ISCHR(statbuf.st_mode)) { /* only accept devices as serial device */ Util_strlcpy(RDevice_serial_device, argv[++i], FILENAME_MAX); RDevice_serial_enabled = TRUE; } } } #endif /* R_SERIAL */ } #endif #endif else if (strcmp(argv[i], "-osb_rom") == 0) { if (i_a) Util_strlcpy(CFG_osb_filename, argv[++i], sizeof(CFG_osb_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-xlxe_rom") == 0) { if (i_a) Util_strlcpy(CFG_xlxe_filename, argv[++i], sizeof(CFG_xlxe_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-5200_rom") == 0) { if (i_a) Util_strlcpy(CFG_5200_filename, argv[++i], sizeof(CFG_5200_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-basic_rom") == 0) { if (i_a) Util_strlcpy(CFG_basic_filename, argv[++i], sizeof(CFG_basic_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-cart") == 0) { if (i_a) rom_filename = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-cart2") == 0) { if (i_a) rom2_filename = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-run") == 0) { if (i_a) run_direct = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-mosaic") == 0) { int total_ram = Util_sscandec(argv[++i]); MEMORY_mosaic_enabled = TRUE; MEMORY_mosaic_maxbank = (total_ram - 48)/4 - 1; if (((total_ram - 48) % 4 != 0) || (MEMORY_mosaic_maxbank > 0x3e) || (MEMORY_mosaic_maxbank < 0)) { Log_print("Invalid Mosaic total RAM size"); return FALSE; } if (MEMORY_axlon_enabled) { Log_print("Axlon and Mosaic can not both be enabled, because they are incompatible"); return FALSE; } } else if (strcmp(argv[i], "-axlon") == 0) { int total_ram = Util_sscandec(argv[++i]); int banks = ((total_ram) - 32) / 16; MEMORY_axlon_enabled = TRUE; if (((total_ram - 32) % 16 != 0) || ((banks != 8) && (banks != 16) && (banks != 32) && (banks != 64) && (banks != 128) && (banks != 256))) { Log_print("Invalid Axlon total RAM size"); return FALSE; } if (MEMORY_mosaic_enabled) { Log_print("Axlon and Mosaic can not both be enabled, because they are incompatible"); return FALSE; } MEMORY_axlon_bankmask = banks - 1; } else if (strcmp(argv[i], "-axlon0f") == 0) { MEMORY_axlon_0f_mirror = TRUE; } #ifndef BASIC /* The BASIC version does not support state files, because: 1. It has no ability to save state files, because of lack of UI. 2. It uses a simplified emulation, so the state files would be incompatible with other versions. 3. statesav is not compiled in to make the executable smaller. */ else if (strcmp(argv[i], "-state") == 0) { if (i_a) state_file = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-refresh") == 0) { if (i_a) { Atari800_refresh_rate = Util_sscandec(argv[++i]); if (Atari800_refresh_rate < 1) { Log_print("Invalid refresh rate, using 1"); Atari800_refresh_rate = 1; } } else a_m = TRUE; } #endif /* BASIC */ #ifdef STEREO_SOUND else if (strcmp(argv[i], "-stereo") == 0) { POKEYSND_stereo_enabled = TRUE; } else if (strcmp(argv[i], "-nostereo") == 0) { POKEYSND_stereo_enabled = FALSE; } #endif /* STEREO_SOUND */ else { /* all options known to main module tried but none matched */ if (strcmp(argv[i], "-help") == 0) { #if !defined(__PLUS) && !defined(MACOSX) help_only = TRUE; Log_print("\t-config <file> Specify Alternate Configuration File"); #endif Log_print("\t-atari Emulate Atari 800"); Log_print("\t-xl Emulate Atari 800XL"); Log_print("\t-xe Emulate Atari 130XE"); Log_print("\t-320xe Emulate Atari 320XE (COMPY SHOP)"); Log_print("\t-rambo Emulate Atari 320XE (RAMBO)"); Log_print("\t-5200 Emulate Atari 5200 Games System"); Log_print("\t-nobasic Turn off Atari BASIC ROM"); Log_print("\t-basic Turn on Atari BASIC ROM"); Log_print("\t-pal Enable PAL TV mode"); Log_print("\t-ntsc Enable NTSC TV mode"); Log_print("\t-osa_rom <file> Load OS A ROM from file"); Log_print("\t-osb_rom <file> Load OS B ROM from file"); Log_print("\t-xlxe_rom <file> Load XL/XE ROM from file"); Log_print("\t-5200_rom <file> Load 5200 ROM from file"); Log_print("\t-basic_rom <fil> Load BASIC ROM from file"); Log_print("\t-cart <file> Install cartridge (raw or CART format)"); Log_print("\t-run <file> Run Atari program (COM, EXE, XEX, BAS, LST)"); #ifndef BASIC Log_print("\t-state <file> Load saved-state file"); Log_print("\t-refresh <rate> Specify screen refresh rate"); #endif Log_print("\t-nopatch Don't patch SIO routine in OS"); Log_print("\t-nopatchall Don't patch OS at all, H: device won't work"); Log_print("\t-a Use OS A"); Log_print("\t-b Use OS B"); Log_print("\t-c Enable RAM between 0xc000 and 0xcfff in Atari 800"); Log_print("\t-axlon <n> Use Atari 800 Axlon memory expansion: <n> k total RAM"); Log_print("\t-axlon0f Use Axlon shadow at 0x0fc0-0x0fff"); Log_print("\t-mosaic <n> Use 400/800 Mosaic memory expansion: <n> k total RAM"); #ifdef R_IO_DEVICE Log_print("\t-rdevice [<dev>] Enable R: emulation (using serial device <dev>)"); #endif Log_print("\t-v Show version/release number"); } /* copy this option for platform/module specific evaluation */ argv[j++] = argv[i]; } /* this is the end of the additional argument check */ if (a_m) { printf("Missing argument for '%s'\n", argv[i]); return FALSE; } } }