diff --git a/src/86box.c b/src/86box.c index 19465a17f..6e8fa52dd 100644 --- a/src/86box.c +++ b/src/86box.c @@ -403,10 +403,12 @@ pc_init(int argc, char *argv[]) { char *ppath = NULL, *rpath = NULL; char *cfg = NULL, *p; - char temp[2048]; + char temp[2048], *fn[FDD_NUM] = { NULL }; + char drive = 0, *temp2 = NULL; struct tm *info; time_t now; int c, lvmp = 0; + int i; #ifdef ENABLE_NG int ng = 0; #endif @@ -456,6 +458,13 @@ pc_init(int argc, char *argv[]) if (!strcasecmp(argv[c], "--help") || !strcasecmp(argv[c], "-?")) { usage: + for (i = 0; i < FDD_NUM; i++) { + if (fn[i] != NULL) { + free(fn[i]); + fn[i] = NULL; + } + } + printf("\nUsage: 86box [options] [cfg-file]\n\n"); printf("Valid options are:\n\n"); printf("-? or --help - show this information\n"); @@ -471,6 +480,7 @@ usage: #ifdef _WIN32 printf("-H or --hwnd id,hwnd - sends back the main dialog's hwnd\n"); #endif + printf("-I or --image d:path - load 'path' as floppy image on drive d\n"); printf("-L or --logfile path - set 'path' to be the logfile\n"); printf("-N or --noconfirm - do not ask for confirmation on quit\n"); printf("-O or --dumpcfg - dump config file after loading\n"); @@ -519,6 +529,25 @@ usage: goto usage; cfg = argv[++c]; + } else if (!strcasecmp(argv[c], "--image") || !strcasecmp(argv[c], "-I")) { + if ((c + 1) == argc) + goto usage; + + temp2 = (char *) calloc(2048, 1); + sscanf(argv[++c], "%c:%s", &drive, temp2); + if (drive > 0x40) + drive = (drive & 0x1f) - 1; + else + drive = drive & 0x1f; + if (drive < 0) + drive = 0; + if (drive >= FDD_NUM) + drive = FDD_NUM - 1; + fn[(int) drive] = (char *) calloc(2048, 1); + strcpy(fn[(int) drive], temp2); + pclog("Drive %c: %s\n", drive + 0x41, fn[(int) drive]); + free(temp2); + temp2 = NULL; } else if (!strcasecmp(argv[c], "--vmname") || !strcasecmp(argv[c], "-V")) { if ((c + 1) == argc) goto usage; @@ -738,6 +767,15 @@ usage: /* Load the configuration file. */ config_load(); + for (i = 0; i < FDD_NUM; i++) { + if (fn[i] != NULL) { + if (strlen(fn[i]) <= 511) + strncpy(floppyfns[i], fn[i], 511); + free(fn[i]); + fn[i] = NULL; + } + } + /* Load the desired language */ if (lang_init) lang_id = lang_init; diff --git a/src/scsi/scsi_cdrom.c b/src/scsi/scsi_cdrom.c index b7bf4fcfe..c004a8044 100644 --- a/src/scsi/scsi_cdrom.c +++ b/src/scsi/scsi_cdrom.c @@ -17,6 +17,7 @@ */ #include #include +#include #include #include #include @@ -594,7 +595,7 @@ scsi_cdrom_update_request_length(scsi_cdrom_t *dev, int len, int block_len) that a media access comand does not DRQ in the middle of a sector. One of the drivers that relies on the correctness of this behavior is MTMCDAI.SYS (the Mitsumi CD-ROM driver) for DOS which uses the READ CD command to read data on some CD types. */ - if (dev->current_cdb[0] == 0xb9) || (dev->current_cdb[0] == 0xbe) { + if ((dev->current_cdb[0] == 0xb9) || (dev->current_cdb[0] == 0xbe)) { /* Round to sector length. */ dlen = ((double) dev->request_length) / ((double) block_len); dev->request_length = ((uint16_t) floor(dlen)) * block_len;