From: Toni Wilen Date: Sat, 10 Apr 2010 13:21:32 +0000 (+0300) Subject: 2100b21 X-Git-Tag: 2100~7 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=bceb78721a312316d4a9c06cc42442d2eb28d1aa;p=francis%2Fwinuae.git 2100b21 --- diff --git a/akiko.cpp b/akiko.cpp index 0c4a252f..8d714713 100644 --- a/akiko.cpp +++ b/akiko.cpp @@ -1150,7 +1150,7 @@ static void do_hunt (void) } if (sys_command_open (DF_IOCTL, i) > 0) { struct device_info di = { 0 }; - sys_command_info (DF_IOCTL, 0, &di); + sys_command_info (DF_IOCTL, i, &di); unitnum = i; cd_hunt = 0; write_log (L"CD32: autodetected unit %d ('%s')\n", unitnum, di.label); diff --git a/blkdev_cdimage.cpp b/blkdev_cdimage.cpp index 51e980d4..090d32d7 100644 --- a/blkdev_cdimage.cpp +++ b/blkdev_cdimage.cpp @@ -15,6 +15,7 @@ #include "gui.h" #include "fsdb.h" #include "threaddep/thread.h" +#include "scsidev.h" #ifdef RETROPLATFORM #include "rp.h" #endif @@ -47,6 +48,7 @@ struct cdtoc static uae_u8 buffer[2352]; static struct cdtoc toc[102]; static int tracks; +static uae_u64 cdsize; static int cdda_play_finished; static int cdda_play; @@ -56,6 +58,9 @@ static int cdda_volume_main; static uae_u32 cd_last_pos; static int cdda_start, cdda_end; +static int imagechange; +static TCHAR newfile[MAX_DPATH]; + /* convert minutes, seconds and frames -> logical sector number */ static int msf2lsn (int msf) { @@ -599,9 +604,22 @@ static void command_volume (int unitnum, uae_u16 volume) uae_u8 *command_rawread (int unitnum, int sector, int sectorsize) { + struct cdtoc *t = findtoc (§or); + int offset; + if (!t || t->handle == NULL) + return NULL; + cdda_stop (); - return NULL; + if (sectorsize > t->size) + return NULL; + offset = 0; + if (sectorsize == 2336 && t->size == 2352) + offset = 16; + zfile_fseek (t->handle, t->offset + sector * t->size + offset, SEEK_SET); + zfile_fread (buffer, sectorsize, 1, t->handle); + return buffer; } + static uae_u8 *command_read (int unitnum, int sector) { struct cdtoc *t = findtoc (§or); @@ -813,9 +831,9 @@ static int parse_image (void) size = 2048; else if (!_tcsicmp (tracktype, L"MODE1/2352")) size = 2352; - else if (!_tcsicmp (tracktype, L"MODE2/2336")) + else if (!_tcsicmp (tracktype, L"MODE2/2336") || !_tcsicmp (tracktype, L"CDI/2336")) size = 2336; - else if (!_tcsicmp (tracktype, L"MODE2/2352")) + else if (!_tcsicmp (tracktype, L"MODE2/2352") || !_tcsicmp (tracktype, L"CDI/2352")) size = 2352; else { write_log (L"CUE: unknown tracktype '%s' ('%s')\n", tracktype, fname); @@ -940,12 +958,13 @@ static int parse_image (void) isodone: if (tracks && toc[tracks - 1].handle) { struct cdtoc *t = &toc[tracks - 1]; - int size = t->filesize ; + int size = t->filesize; if (!secoffset) size -= offset * t->size; if (size < 0) size = 0; toc[tracks].address = t->address + size / t->size; + cdsize = toc[tracks].address * t->size; } xfree (fname); if (oldcurdir[0]) @@ -982,6 +1001,7 @@ static void unload_image (void) } memset (toc, 0, sizeof toc); tracks = 0; + cdsize = 0; } static int open_device (int unitnum) @@ -996,11 +1016,20 @@ static void close_device (int unitnum) unload_image (); } -static int imagechange; -static TCHAR newfile[MAX_DPATH]; - void cdimage_vsync (void) { + int media = 0; + if (_tcscmp (changed_prefs.cdimagefile, currprefs.cdimagefile)) { + _tcscpy (newfile, changed_prefs.cdimagefile); + changed_prefs.cdimagefile[0] = currprefs.cdimagefile[0] = 0; + imagechange = 3 * 50; + write_log (L"CD: eject\n"); + unload_image (); + scsi_do_disk_change (-1, 0); +#ifdef RETROPLATFORM + rp_cd_image_change (0, NULL); +#endif + } if (imagechange == 0) return; imagechange--; @@ -1009,10 +1038,16 @@ void cdimage_vsync (void) _tcscpy (currprefs.cdimagefile, newfile); _tcscpy (changed_prefs.cdimagefile, newfile); newfile[0] = 0; - write_log (L"CD: delayed insert '%s'\n", currprefs.cdimagefile); - parse_image (); + write_log (L"CD: delayed insert '%s'\n", currprefs.cdimagefile[0] ? currprefs.cdimagefile : L""); + int un = scsi_do_disk_change (-1, 1); + if (un >= 0) { + media = sys_command_ismedia (DF_IOCTL, un, 1); + } else { + parse_image (); + media = tracks > 0; + } #ifdef RETROPLATFORM - rp_cd_change (0, 0); + rp_cd_image_change (0, media ? currprefs.cdimagefile : NULL); #endif config_changed = 1; } @@ -1021,17 +1056,7 @@ static int ismedia (int unitnum, int quick) { if (unitnum) return 0; - if (_tcscmp (changed_prefs.cdimagefile, currprefs.cdimagefile)) { - _tcscpy (newfile, changed_prefs.cdimagefile); - changed_prefs.cdimagefile[0] = currprefs.cdimagefile[0] = 0; - imagechange = 5 * 50; - write_log (L"CD: eject\n"); - unload_image (); -#ifdef RETROPLATFORM - rp_cd_change (unitnum, 1); -#endif - } - return currprefs.cdimagefile[0] ? 1 : 0; + return tracks > 0 ? 1 : 0; } static int open_bus (int flags) @@ -1039,9 +1064,10 @@ static int open_bus (int flags) int v; if (imagechange) return 1; - v = ismedia (0, 1); + v = currprefs.cdimagefile[0] ? 1 : 0; #ifdef RETROPLATFORM - rp_cd_change (0, v ? 0 : 1); + rp_cd_change (0, 0); + rp_cd_image_change (0, currprefs.cdimagefile[0] ? currprefs.cdimagefile : NULL); #endif return v; } @@ -1049,25 +1075,32 @@ static int open_bus (int flags) static void close_bus (void) { mp3decoder_close (); +#ifdef RETROPLATFORM + rp_cd_change (0, 1); +#endif } static struct device_info *info_device (int unitnum, struct device_info *di) { if (unitnum) return 0; + di->removable = 1; di->bus = unitnum; di->target = 0; di->lun = 0; di->media_inserted = 0; di->bytespersector = 2048; di->mediapath[0] = 0; + di->cylinders = 1; + di->trackspercylinder = 1; + di->sectorspertrack = cdsize / di->bytespersector; if (ismedia (unitnum, 1)) { di->media_inserted = 1; _tcscpy (di->mediapath, currprefs.cdimagefile); } di->write_protected = 1; di->type = INQ_ROMD; - di->id = 1; + di->id = -1; _tcscpy (di->label, L"IMG_EMU"); return di; } diff --git a/cdtv.cpp b/cdtv.cpp index b76886c6..d85f8894 100644 --- a/cdtv.cpp +++ b/cdtv.cpp @@ -584,7 +584,7 @@ static void cdrom_command_thread (uae_u8 b) static uae_u8 *read_raw (int sector, int size) { - int osector = sector; + int osector = sector - 150; static struct zfile *f; static int track; int trackcnt; @@ -613,9 +613,7 @@ static uae_u8 *read_raw (int sector, int size) _stprintf (fname, L"track%d.bin", trackcnt); zfile_fclose (f); f = zfile_fopen (fname, L"rb", ZFD_NORMAL); - if (!f) - write_log (L"failed to open '%s'\n", fname); - else + if (f) write_log (L"opened '%s'\n", fname); track = trackcnt; } @@ -893,7 +891,7 @@ static void do_hunt (void) } if (sys_command_open (DF_IOCTL, i) > 0) { struct device_info di = { 0 }; - sys_command_info (DF_IOCTL, 0, &di); + sys_command_info (DF_IOCTL, i, &di); unitnum = i; cd_hunt = 0; write_log (L"CDTV: autodetected unit %d ('%s')\n", unitnum, di.label); diff --git a/epsonprinter.cpp b/epsonprinter.cpp index 9b4f2c37..790bc5c5 100644 --- a/epsonprinter.cpp +++ b/epsonprinter.cpp @@ -36,8 +36,8 @@ #include -//#define DEBUGPRINT -static int pngprint = 0; +//#define DEBUGPRINT L"c:\\d\\data_epsonq_raw_fixed_superscript_subscript_multi-strike.bin" +int pngprint = 0; #ifdef C_LIBPNG #include @@ -77,6 +77,7 @@ static Bit8u numVertTabs, curCharTable, printQuality; static enum Typeface LQtypeFace; static Real64 extraIntraSpace; static int charRead, autoFeed, printUpperContr; +static int printColor, colorPrinted; static struct bitGraphicParams { Bit16u horizDens, vertDens; int adjacent; @@ -100,7 +101,7 @@ static int justification; static int charcnt; static Bit8u charbuffer[CHARBUFFERSIZE]; -static uae_u8 *page; +static uae_u8 *page, *cpage; static int page_w, page_h, page_pitch; static int pagesize; static HMODULE ft; @@ -108,6 +109,15 @@ static int pins = 24; static void printCharBuffer(void); +static Bit8u colors[] = { + 0x00, 0x00, 0x00, // 0 black + 0xff, 0x00, 0xff, // 1 magenta (/green) + 0x00, 0xff, 0xff, // 2 cyan (/red) + 0xff, 0x00, 0xff, // 3 violet + 0xff, 0xff, 0x00, // 4 yellow (/blue) + 0xff, 0x00, 0x00, // 5 red + 0x00, 0xff, 0x00 // 6 green +}; // Various ASCII codepage to unicode maps @@ -472,14 +482,13 @@ static int selectfont(Bit16u style) break; if (thisFontVertPoints != curFontVertPoints) break; - if (thisStyle != style) + if ((thisStyle & (STYLE_ITALICS | STYLE_PROP)) != (style & (STYLE_ITALICS | STYLE_PROP))) break; // still using same font return 1; } DeleteObject (curFont); curFont = NULL; - xfree (thisFontName); thisFontName = NULL; xfree (otm); otm = NULL; @@ -674,6 +683,29 @@ static void getfname (TCHAR *fname) static int volatile prt_thread_mode; +STATIC_INLINE void getcolor (uae_u8 *Tpage, uae_u8 *Tcpage, int x, int y, int Tpage_pitch, Bit8u *r, Bit8u *g, Bit8u *b) +{ + Bit8u pixel = *((Bit8u*)Tpage + x + (y*Tpage_pitch)); + Bit8u c = *((Bit8u*)Tcpage + x + (y*Tpage_pitch)); + Bit8u color_r = 0, color_g = 0, color_b = 0; + if (c) { + Bit32u color = 0; + int cindex = 0; + while (c) { + if (c & 1) { + color_r |= (255 - colors[cindex * 3 + 0]) * pixel / 256; + color_g |= (255 - colors[cindex * 3 + 1]) * pixel / 256; + color_b |= (255 - colors[cindex * 3 + 2]) * pixel / 256; + } + cindex++; + c >>= 1; + } + } + *r = 255 - color_r; + *g = 255 - color_g; + *b = 255 - color_b; +} + static void *prt_thread (void *p) { Bit16u x, y; @@ -683,6 +715,7 @@ static void *prt_thread (void *p) int Tpage_h = page_h; int Tpage_pitch = page_pitch; uae_u8 *Tpage = page; + uae_u8 *Tcpage = cpage; write_log (L"EPSONPRINTER: background print thread started\n"); prt_thread_mode = 1; @@ -694,11 +727,14 @@ static void *prt_thread (void *p) int vz = GetDeviceCaps (TprinterDC, PHYSICALHEIGHT); int topmargin = GetDeviceCaps (TprinterDC, PHYSICALOFFSETX); int leftmargin = GetDeviceCaps (TprinterDC, PHYSICALOFFSETY); + HDC dc = NULL; write_log (L"EPSONPRINTER: HP=%d WP=%d TM=%d LM=%d W=%d H=%d\n", hz, vz, topmargin, leftmargin, Tpage_w, Tpage_h); - HBITMAP bitmap = CreateCompatibleBitmap (memHDC, Tpage_w, Tpage_h); + if (colorPrinted) + dc = GetDC (NULL); + HBITMAP bitmap = CreateCompatibleBitmap (dc, Tpage_w, Tpage_h); SelectObject (TmemHDC, bitmap); BitBlt (TmemHDC, 0, 0, Tpage_w, Tpage_h, NULL, 0, 0, WHITENESS); @@ -723,23 +759,22 @@ static void *prt_thread (void *p) { for (x=0; x 6) + printColor = 0; break; case 0x73: // Select low-speed mode (ESC s) // Ignore @@ -1921,8 +1984,10 @@ static void printBitGraph(Bit8u ch) for (xx=0; xx= 0) && (desty+y >= 0)) { Bit8u* target = (Bit8u*)page + (x+destx) + (y+desty)*page_pitch; + Bit8u* ctarget = (Bit8u*)cpage + (x+destx) + (y+desty)*page_pitch; Bit8u b = *source; if (b >= 64) { b = 255; @@ -1966,16 +2032,20 @@ static void blitGlyph(uae_u8 *gbitmap, int width, int rows, int pitch, int destx } if (add) { - if (*target + b > 255) + if (*target + (unsigned int)b > 255) *target = 255; else *target += b; } else *target = b; + *ctarget |= 1 << printColor; + } } } + if (printColor) + colorPrinted = true; } static void drawLine(int fromx, int tox, int y, int broken) @@ -1993,20 +2063,28 @@ static void drawLine(int fromx, int tox, int y, int broken) { if (y < 0) continue; - if (y > 0 && (y-1) < page_h) + if (y > 0 && (y-1) < page_h) { *((Bit8u*)page + x + (y-1)*page_pitch) = 120; - if (y < page_h) + *((Bit8u*)cpage + x + (y-1)*page_pitch) |= 1 << printColor; + } + if (y < page_h) { *((Bit8u*)page + x + y*page_pitch) = !broken?255:120; - if (y+1 < page_h) + *((Bit8u*)cpage + x + y*page_pitch) |= 1 << printColor; + } + if (y+1 < page_h) { *((Bit8u*)page + x + (y+1)*page_pitch) = 120; + *((Bit8u*)cpage + x + (y+1)*page_pitch) |= 1 << printColor; + } } } + if (printColor) + colorPrinted = true; } static void printSingleChar(Bit8u ch, int doprint) { - int penX; - int penY; + int penX = PIXX; + int penY = PIXY; Bit16u lineStart; int bitmap_left = 0; @@ -2061,12 +2139,15 @@ static void printSingleChar(Bit8u ch, int doprint) } #endif + int deltaY = 0; + if (style & STYLE_SUBSCRIPT) + deltaY = rows / 2; + else if (style & STYLE_SUPERSCRIPT) + deltaY = rows / 2; + if (gbitmap) { penX = PIXX + bitmap_left; - penY = PIXY - bitmap_top + ascender; - - if (style & STYLE_SUBSCRIPT) - penY += rows / 2; + penY = PIXY - bitmap_top + ascender + deltaY; if (doprint) { // Copy bitmap into page @@ -2077,8 +2158,10 @@ static void printSingleChar(Bit8u ch, int doprint) blitGlyph(gbitmap, width, rows, pitch, penX, penY+1, true); // Bold => Print the glyph a second time one pixel to the right - if (style & STYLE_BOLD) + if (style & STYLE_BOLD) { + printColor = 0; blitGlyph(gbitmap, width, rows, pitch, penX+1, penY, true); + } } } @@ -2101,19 +2184,19 @@ static void printSingleChar(Bit8u ch, int doprint) if (doprint && score != SCORE_NONE && (style & (STYLE_UNDERLINE|STYLE_STRIKETHROUGH|STYLE_OVERSCORE))) { // Find out where to put the line - Bit16u lineY = PIXY; + Bit16u lineY = PIXY + deltaY; + Bit16u xEnd = lineStart + advancex; if (style & STYLE_UNDERLINE) - lineY = PIXY + height - 1; + lineY = PIXY + deltaY + ascender * 100 / 70; if (style & STYLE_STRIKETHROUGH) - lineY = PIXY + ascender / 2; + lineY = PIXY + deltaY + ascender / 2; if (style & STYLE_OVERSCORE) - lineY = PIXY - ((score == SCORE_DOUBLE || score == SCORE_DOUBLEBROKEN) ? 5 : 0); - - drawLine(penX - 1, PIXX + 1, lineY, score==SCORE_SINGLEBROKEN || score==SCORE_DOUBLEBROKEN); + lineY = PIXY + deltaY - otm->otmTextMetrics.tmDescent - ((score == SCORE_DOUBLE || score == SCORE_DOUBLEBROKEN) ? 5 : 0); + drawLine(lineStart, xEnd, lineY, score == SCORE_SINGLEBROKEN || score == SCORE_DOUBLEBROKEN); if (score == SCORE_DOUBLE || score == SCORE_DOUBLEBROKEN) - drawLine(lineStart, PIXX + 1, lineY + 5, score==SCORE_SINGLEBROKEN || score==SCORE_DOUBLEBROKEN); + drawLine(lineStart, xEnd, lineY + 5, score == SCORE_SINGLEBROKEN || score == SCORE_DOUBLEBROKEN); } #ifdef WINFONT xfree (gbitmap); @@ -2241,7 +2324,7 @@ void epson_printchar(uae_u8 c) if (printed) return; printed = 1; - struct zfile *zf = zfile_fopen (L"c:\\d\\data_epsonq_raw.bin", L"rb", ZFD_ALL); + struct zfile *zf = zfile_fopen (DEBUGPRINT, L"rb", ZFD_ALL); for (;;) { int v = zfile_getc (zf); if (v < 0) diff --git a/include/scsidev.h b/include/scsidev.h index fe5fc450..64c1a2f0 100644 --- a/include/scsidev.h +++ b/include/scsidev.h @@ -12,7 +12,7 @@ uaecptr scsidev_startup (uaecptr resaddr); void scsidev_install (void); void scsidev_reset (void); void scsidev_start_threads (void); -void scsi_do_disk_change (int device_id, int insert); +int scsi_do_disk_change (int device_id, int insert); extern int log_scsi; diff --git a/inputdevice.cpp b/inputdevice.cpp index 51cd9942..4cedf82b 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -4630,7 +4630,6 @@ int jsem_iskbdjoy (int port, const struct uae_prefs *p) int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum, int mode, int type) { - config_changed = 1; switch (type) { case 1: diff --git a/od-win32/blkdev_win32_ioctl.cpp b/od-win32/blkdev_win32_ioctl.cpp index 731d2c65..87706eeb 100644 --- a/od-win32/blkdev_win32_ioctl.cpp +++ b/od-win32/blkdev_win32_ioctl.cpp @@ -40,6 +40,7 @@ struct dev_info_ioctl { HANDLE h; uae_u8 *tempbuffer; TCHAR drvletter; + TCHAR drvlettername[10]; TCHAR devname[30]; int mediainserted; int type; @@ -234,7 +235,7 @@ static int open_mci (int unitnum) ciw->playend = -1; closed = close_createfile (unitnum); if (log_scsi) - write_log (L"IOCTL: MCI opening %c:\n", ciw->drvletter); + write_log (L"IOCTL: MCI opening %s\n", ciw->drvlettername); memset (&mciOpen, 0, sizeof (mciOpen)); mciOpen.lpstrDeviceType = (LPWSTR)MCI_DEVTYPE_CD_AUDIO; _stprintf (elname, L"%c:", ciw->drvletter); @@ -359,9 +360,9 @@ static void *cdda_play (void *v) rri.TrackMode = CDDA; if (!DeviceIoControl (ciw->h, IOCTL_CDROM_RAW_READ, &rri, sizeof rri, px[bufnum], num_sectors * 2352, &len, NULL)) { DWORD err = GetLastError (); - write_log (L"IOCTL_CDROM_RAW_READ CDDA returned %d\n", err); - ciw->cdda_play_finished = 1; - ciw->cdda_play = -1; + write_log (L"IOCTL_CDROM_RAW_READ CDDA sector %d returned %d\n", cdda_pos - 150, err); + //ciw->cdda_play_finished = 1; + //ciw->cdda_play = -1; } } else { for (i = 0; i < num_sectors; i++) { @@ -842,6 +843,7 @@ uae_u8 *ioctl_command_rawread (int unitnum, int sector, int sectorsize) if (!DeviceIoControl (ciw32[unitnum].h, IOCTL_CDROM_RAW_READ, &rri, sizeof rri, p, IOCTL_DATA_BUFFER, &len, NULL)) { DWORD err = GetLastError (); + write_log (L"IOCTL rawread unit=%d sector=%d blocksize=%d, ERR=%d\n", unitnum, sector, sectorsize, err); } reseterrormode (unitnum); ciw32[unitnum].cd_last_pos = sector + sectorsize; @@ -1167,6 +1169,7 @@ static int open_bus (int flags) if (log_scsi) write_log (L"IOCTL: drive %c: = unit %d\n", drive, total_devices); ciw32[total_devices].drvletter = drive; + _tcscpy (ciw32[total_devices].drvlettername, tmp); ciw32[total_devices].type = dt; ciw32[total_devices].blocksize = 2048; _stprintf (ciw32[total_devices].devname, L"\\\\.\\%c:", drive); @@ -1206,7 +1209,7 @@ static struct device_info *info_device (int unitnum, struct device_info *di) di->write_protected = ciw32[unitnum].type == DRIVE_CDROM ? 1 : 0; di->type = ciw32[unitnum].type == DRIVE_CDROM ? INQ_ROMD : INQ_DASD; di->id = ciw32[unitnum].drvletter; - _stprintf (di->label, L"Drive %c:", ciw32[unitnum].drvletter); + _tcscpy (di->label, ciw32[unitnum].drvlettername); return di; } @@ -1216,11 +1219,11 @@ void win32_ioctl_media_change (TCHAR driveletter, int insert) for (i = 0; i < MAX_TOTAL_DEVICES; i++) { if (ciw32[i].drvletter == driveletter && ciw32[i].mediainserted != insert) { - write_log (L"IOCTL: media change %c %d\n", driveletter, insert); + write_log (L"IOCTL: media change %s %d\n", ciw32[i].drvlettername, insert); ciw32[i].mediainserted = insert; scsi_do_disk_change (driveletter, insert); #ifdef RETROPLATFORM - rp_cd_change (i, insert ? 0 : 1); + rp_cd_image_change (i, insert ? ciw32[i].drvlettername : NULL); #endif } } diff --git a/od-win32/blkdev_win32_spti.cpp b/od-win32/blkdev_win32_spti.cpp index 0ac18c1f..e0e2da61 100644 --- a/od-win32/blkdev_win32_spti.cpp +++ b/od-win32/blkdev_win32_spti.cpp @@ -52,6 +52,8 @@ struct dev_info_spti { TCHAR *name; uae_u8 *inquirydata; TCHAR *ident; + TCHAR drvletter; + TCHAR drvlettername[10]; int mediainserted; HANDLE handle; int isatapi; @@ -255,7 +257,7 @@ static void free_scsi_device(int dev) memset(&dev_info[dev], 0, sizeof (struct dev_info_spti)); } -static int rescan(void); +static int rescan (void); static int open_scsi_bus (int flags) { int i; @@ -266,7 +268,7 @@ static int open_scsi_bus (int flags) memset (&dev_info[i], 0, sizeof (struct dev_info_spti)); dev_info[i].handle = INVALID_HANDLE_VALUE; } - rescan(); + rescan (); return total_devices; } @@ -421,7 +423,8 @@ int open_scsi_device (int unitnum) di->name = my_strdup_ansi ((char*)inqdata + 8); if (di->type == INQ_ROMD) { dev_info[unitnum].mediainserted = mediacheck (unitnum); - write_log (L"SPTI: unit %d opened [%s], %s, '%s'\n", unitnum, + write_log (L"SPTI: unit %d (%c:\\) opened [%s], %s, '%s'\n", + unitnum, di->drvletter ? di->drvletter : '*', di->isatapi ? L"ATAPI" : L"SCSI", di->mediainserted ? L"media inserted" : L"drive empty", di->name); @@ -460,6 +463,26 @@ static int adddrive (TCHAR *drvpath, int bus, int pathid, int targetid, int luni di->target = targetid; di->lun = lunid; di->scanmode = scanmode; + di->drvletter = 0; + + for (TCHAR drvletter = 'C'; drvletter <= 'Z'; drvletter++) { + TCHAR drvname[10]; + TCHAR volname[MAX_DPATH], volname2[MAX_DPATH]; + _stprintf (drvname, L"%c:\\", drvletter); + if (GetVolumeNameForVolumeMountPoint (drvname, volname, sizeof volname / sizeof (TCHAR))) { + TCHAR drvpath2[MAX_DPATH]; + _stprintf (drvpath2, L"%s\\", di->drvpath); + if (GetVolumeNameForVolumeMountPoint (drvpath2, volname2, sizeof volname2 / sizeof (TCHAR))) { + if (!_tcscmp (volname, volname2)) { + di->drvletter = drvletter; + _tcscpy (di->drvlettername, drvname); + break; + } + } + } + } + + total_devices++; if (open_scsi_device (cnt)) { for (i = 0; i < cnt; i++) { @@ -480,13 +503,18 @@ static int adddrive (TCHAR *drvpath, int bus, int pathid, int targetid, int luni return 1; } +static int getid (int unitnum) +{ + return dev_info[unitnum].drvletter ? dev_info[unitnum].drvletter : unitnum + 1; +} + static struct device_info *info_device (int unitnum, struct device_info *di) { struct dev_info_spti *dispti; if (unitnum >= MAX_TOTAL_DEVICES || dev_info[unitnum].handle == INVALID_HANDLE_VALUE) return NULL; dispti = &dev_info[unitnum]; - _tcscpy (di->label, dispti->name); + _tcscpy (di->label, dispti->drvletter ? dispti->drvlettername : dispti->name); _tcscpy (di->mediapath, dispti->drvpath); di->bus = 0; di->target = unitnum; @@ -495,7 +523,7 @@ static struct device_info *info_device (int unitnum, struct device_info *di) di->removable = dispti->removable; mediacheck_full (unitnum, di); di->type = dispti->type; - di->id = unitnum + 1; + di->id = getid (unitnum); if (log_scsi) { write_log (L"MI=%d TP=%d WP=%d CY=%d BK=%d RMB=%d '%s'\n", di->media_inserted, di->type, di->write_protected, di->cylinders, di->bytespersector, di->removable, di->label); @@ -511,11 +539,11 @@ void win32_spti_media_change (TCHAR driveletter, int insert) if (dev_info[i].type == INQ_ROMD) { now = mediacheck (i); if (now != dev_info[i].mediainserted) { - write_log (L"SPTI: media change %c %d\n", driveletter, insert); + write_log (L"SPTI: media change %c %d\n", dev_info[i].drvletter, insert); dev_info[i].mediainserted = now; - scsi_do_disk_change (i + 1, insert); + scsi_do_disk_change (getid (i), insert); #ifdef RETROPLATFORM - rp_cd_change (i, now ? 0 : 1); + rp_cd_image_change (i, now ? (dev_info[i].drvletter ? dev_info[i].drvlettername : dev_info[i].name) : NULL); #endif } } @@ -689,49 +717,49 @@ static const GUID *guids[] = { &GUID_DEVCLASS_IMAGE, &GUID_DEVCLASS_TAPEDRIVE, NULL }; - static const TCHAR *scsinames[] = { L"Tape", L"Scanner", L"Changer", NULL }; - - static int rescan (void) - { - int idx, idx2; - - for (idx2 = 0; guids[idx2]; idx2++) { - HDEVINFO hDevInfo = SetupDiGetClassDevs( - guids[idx2], - NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE); - if (hDevInfo != INVALID_HANDLE_VALUE) { - for (idx = 0; ; idx++) { - if (!getCDROMProperty (idx, hDevInfo, guids[idx2])) - break; - } - SetupDiDestroyDeviceInfoList (hDevInfo); +static const TCHAR *scsinames[] = { L"Tape", L"Scanner", L"Changer", NULL }; + +static int rescan (void) +{ + int idx, idx2; + + for (idx2 = 0; guids[idx2]; idx2++) { + HDEVINFO hDevInfo = SetupDiGetClassDevs( + guids[idx2], + NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE); + if (hDevInfo != INVALID_HANDLE_VALUE) { + for (idx = 0; ; idx++) { + if (!getCDROMProperty (idx, hDevInfo, guids[idx2])) + break; } + SetupDiDestroyDeviceInfoList (hDevInfo); } + } - for (idx2 = 0; scsinames[idx2]; idx2++) { - int max = 10; - for (idx = 0; idx < max; idx++) { - TCHAR tmp[100]; - HANDLE h; - _stprintf (tmp, L"\\\\.\\%s%d", scsinames[idx2], idx); - h = CreateFile (tmp, GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, 0, NULL); - if (h != INVALID_HANDLE_VALUE) { - adddrive (tmp, -1, -1, -1, -1, 2); - CloseHandle (h); - if (idx == max - 1) - max++; - } + for (idx2 = 0; scsinames[idx2]; idx2++) { + int max = 10; + for (idx = 0; idx < max; idx++) { + TCHAR tmp[100]; + HANDLE h; + _stprintf (tmp, L"\\\\.\\%s%d", scsinames[idx2], idx); + h = CreateFile (tmp, GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, 0, NULL); + if (h != INVALID_HANDLE_VALUE) { + adddrive (tmp, -1, -1, -1, -1, 2); + CloseHandle (h); + if (idx == max - 1) + max++; } } - if (currprefs.win32_uaescsimode == UAESCSI_SPTISCAN) { - write_log (L"SCSI adapter enumeration..\n"); - scanscsi (); - write_log (L"SCSI adapter enumeration ends\n"); - } - return 1; } + if (currprefs.win32_uaescsimode == UAESCSI_SPTISCAN) { + write_log (L"SCSI adapter enumeration..\n"); + scanscsi (); + write_log (L"SCSI adapter enumeration ends\n"); + } + return 1; +} #endif diff --git a/od-win32/rp.cpp b/od-win32/rp.cpp index e9db9aad..f5caa750 100644 --- a/od-win32/rp.cpp +++ b/od-win32/rp.cpp @@ -126,7 +126,7 @@ static void trimws (TCHAR *s) static int port_insert2 (int num, const TCHAR *name) { - TCHAR tmp2[1000]; + TCHAR tmp2[MAX_DPATH]; int i, type; type = 1; @@ -282,6 +282,7 @@ static void fixup_size (struct uae_prefs *prefs) if (hres > RES_MAX) hres = RES_MAX; prefs->gfx_size_win.width = prefs->gfx_xcenter_size >> (RES_MAX - hres); + prefs->gfx_filter_autoscale = 0; } if (prefs->gfx_ycenter_size > 0) { int vres = prefs->gfx_linedbl ? 1 : 0; @@ -293,6 +294,7 @@ static void fixup_size (struct uae_prefs *prefs) if (vres > RES_MAX) vres = RES_MAX; prefs->gfx_size_win.height = (prefs->gfx_ycenter_size * 2) >> (RES_MAX - vres); + prefs->gfx_filter_autoscale = 0; } } @@ -357,6 +359,8 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) } if (full && p->gfx_filter && p->gfx_filter_horiz_zoom_mult == 0) m = RP_SCREENMODE_XX; + if (p->gfx_filter_scanlines || p->gfx_linedbl == 2) + m |= RP_SCREENMODE_SCANLINES; } if (full) { m &= ~0x0000ff00; @@ -364,8 +368,6 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) } if (full > 1) m |= RP_SCREENMODE_FULLWINDOW; - if (p->gfx_filter_scanlines || p->gfx_linedbl == 2) - m |= RP_SCREENMODE_SCANLINES; sm->dwScreenMode = m; if (log_rp) @@ -374,6 +376,16 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) totalhdbl, hres, totalvdbl, vres, p->gfx_display, full); } + +static int shift (int val, int shift) +{ + if (shift >= 0) + val >>= shift; + else + val <<= -shift; + return val; +} + static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) { int smm = RP_SCREENMODE_MODE (sm->dwScreenMode); @@ -428,17 +440,17 @@ static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) p->gfx_linedbl = vres ? 1 : 0; if (sm->lClipWidth <= 0) - p->gfx_size_win.width = LORES_WIDTH << hdbl; + p->gfx_size_win.width = shift (LORES_WIDTH, -hdbl); else p->gfx_size_win.width = sm->lClipWidth >> (RES_MAX - hdbl); if (sm->lClipHeight <= 0) { - p->gfx_size_win.height = LORES_HEIGHT << vdbl; + p->gfx_size_win.height = shift (LORES_HEIGHT, -vdbl); } else { if (vdbl == 2) p->gfx_size_win.height = sm->lClipHeight * 2; else - p->gfx_size_win.height = sm->lClipHeight >> (1 - vdbl); + p->gfx_size_win.height = shift (sm->lClipHeight, 1 - vdbl); } if (fs == 1) { @@ -452,21 +464,23 @@ static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) p->gfx_filter = rp_filter_default; p->gfx_filter_horiz_zoom_mult = 1000; p->gfx_filter_vert_zoom_mult = 1000; + //p->gfx_filter_autoscale = 0; if (log_rp) write_log (L"WW=%d WH=%d FW=%d FH=%d\n", - p->gfx_size_win.width, p->gfx_size_win.height, - p->gfx_size_fs.width, p->gfx_size_fs.height); + p->gfx_size_win.width, p->gfx_size_win.height, + p->gfx_size_fs.width, p->gfx_size_fs.height); if (fs) { if (smm == RP_SCREENMODE_XX) { p->gfx_filter = rp_filter; p->gfx_filter_horiz_zoom_mult = 0; p->gfx_filter_vert_zoom_mult = 0; + //p->gfx_filter_autoscale = 1; } else { int mult; int prevmult = 1; int xmult = uaefilters[p->gfx_filter].intmul; int ymult = uaefilters[p->gfx_filter].intmul ; - for (mult = 2; mult <= 4; mult+=2) { + for (mult = 2; mult <= 4; mult += 2) { int w = p->gfx_size_win.width; int h = p->gfx_size_win.height; if (p->gfx_size_fs.width * xmult < w * mult || p->gfx_size_fs.height * ymult < h * mult) { @@ -484,14 +498,23 @@ static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) } else { if (hdbl != hres || vdbl != vres) { p->gfx_filter = rp_filter; - p->gfx_filter_horiz_zoom_mult = 1000 >> (hdbl - hres); - p->gfx_filter_vert_zoom_mult = 1000 >> (vdbl - vres); + p->gfx_filter_horiz_zoom_mult = shift (1000, hdbl - hres); + p->gfx_filter_vert_zoom_mult = shift (1000, vdbl - vres); } } } p->gfx_pfullscreen = fs; p->gfx_afullscreen = fs; +#if 1 + if (fs) { + p->gfx_filter_aspect = -1; + p->gfx_filter_keep_aspect = 1; + } else { + p->gfx_filter_aspect = 0; + p->gfx_filter_keep_aspect = 0; + } +#endif p->gfx_xcenter_pos = sm->lClipLeft; p->gfx_ycenter_pos = sm->lClipTop; p->gfx_xcenter_size = sm->lClipWidth; @@ -583,7 +606,6 @@ static LRESULT CALLBACK RPHostMsgFunction2 (UINT uMessage, WPARAM wParam, LPARAM ok = cd_insert (num, n); break; } - xfree (n); return ok; } case RPIPCHM_SCREENMODE: @@ -969,8 +991,8 @@ void rp_cd_activity (int num, int onoff) return; if (num < 0) return; - if ((cd_mask & (1 << num)) != ((onoff ? 1 : 0) << num)) { - cd_mask ^= 1 << num; + if (onoff && !(cd_mask & (1 << num))) { + cd_mask |= 1 << num; RPSendMessagex (RPIPCGM_DEVICES, RP_DEVICE_CD, cd_mask, NULL, 0, &guestinfo, NULL); } if (onoff) { diff --git a/od-win32/sounddep/sound.cpp b/od-win32/sounddep/sound.cpp index 75784fe0..e09b1711 100644 --- a/od-win32/sounddep/sound.cpp +++ b/od-win32/sounddep/sound.cpp @@ -147,6 +147,7 @@ static int isvsync (void) } float scaled_sample_evtime_orig; +extern float sampler_evtime; void update_sound (int freq, int longframe, int linetoggle) { @@ -179,6 +180,7 @@ void update_sound (int freq, int longframe, int linetoggle) lines += maxvpos_nom; scaled_sample_evtime_orig = hpos * lines * freq * CYCLE_UNIT / (float)sdp->obtainedfreq; scaled_sample_evtime = scaled_sample_evtime_orig; + sampler_evtime = hpos * lines * freq * CYCLE_UNIT; } static void clearbuffer_ds (struct sound_data *sd) diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 6c567009..8924ccd4 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -2754,7 +2754,7 @@ int target_parse_option (struct uae_prefs *p, TCHAR *option, TCHAR *value) return 1; if (cfgfile_string (option, value, L"serial_port", &p->sername[0], 256)) { - sernametodev(p->sername); + sernametodev (p->sername); if (p->sername[0]) p->use_serial = 1; else @@ -2763,8 +2763,13 @@ int target_parse_option (struct uae_prefs *p, TCHAR *option, TCHAR *value) } if (cfgfile_string (option, value, L"parallel_port", &p->prtname[0], 256)) { - if (!_tcscmp(p->prtname, L"none")) + if (!_tcscmp (p->prtname, L"none")) p->prtname[0] = 0; + if (!_tcscmp (p->prtname, L"default")) { + p->prtname[0] = 0; + DWORD size = 256; + GetDefaultPrinter (p->prtname, &size); + } return 1; } @@ -3905,6 +3910,7 @@ static void getstartpaths (void) extern void test (void); extern int screenshotmode, postscript_print_debugging, sound_debug, log_uaeserial, clipboard_debug; extern int force_direct_catweasel, sound_mode_skip, maxmem; +extern int pngprint; extern DWORD_PTR cpu_affinity, cpu_paffinity; static DWORD_PTR original_affinity = -1; @@ -3978,6 +3984,10 @@ static int parseargs (const TCHAR *arg, const TCHAR *np, const TCHAR *np2) return 1; } #endif + if (!_tcscmp (arg, L"-pngprint")) { + pngprint = 1; + return 1; + } if (!_tcscmp (arg, L"-norawinput")) { no_rawinput = 1; return 1; diff --git a/od-win32/win32.h b/od-win32/win32.h index 3bb971cb..7e832b38 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -18,8 +18,8 @@ #define WINUAEPUBLICBETA 1 #define LANG_DLL 1 -#define WINUAEBETA L"20" -#define WINUAEDATE MAKEBD(2010, 4, 3) +#define WINUAEBETA L"21" +#define WINUAEDATE MAKEBD(2010, 4, 10) #define WINUAEEXTRA L"" #define WINUAEREV L"" diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 1bdb7d0b..b843d549 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -10020,7 +10020,7 @@ static void values_from_portsdlg (HWND hDlg) workprefs.win32_midioutdev = SendDlgItemMessage (hDlg, IDC_MIDIOUTLIST, CB_GETCURSEL, 0, 0); workprefs.win32_midioutdev -= 2; - if( bNoMidiIn) { + if (bNoMidiIn) { workprefs.win32_midiindev = -1; } else { workprefs.win32_midiindev = SendDlgItemMessage (hDlg, IDC_MIDIINLIST, CB_GETCURSEL, 0, 0); diff --git a/sampler.cpp b/sampler.cpp index 7bbc44a3..69a4a6ce 100644 --- a/sampler.cpp +++ b/sampler.cpp @@ -16,11 +16,13 @@ #include +#include + #include "win32.h" #define SAMPLESIZE 4 -#define RECORDBUFFER 40000 -#define SAMPLEBUFFER 4000 +#define RECORDBUFFER 10000 +#define SAMPLEBUFFER 2000 static LPDIRECTSOUNDCAPTURE lpDS2r = NULL; static LPDIRECTSOUNDCAPTUREBUFFER lpDSBprimary2r = NULL; @@ -30,6 +32,8 @@ static uae_u8 *samplebuffer; static int samplerate = 44100; static float clockspersample; static int vsynccnt; +static int safepos; +float sampler_evtime; static int capture_init (void) { @@ -94,6 +98,7 @@ uae_u8 sampler_getsample (int channel) { HRESULT hr; static DWORD cap_pos; + static float diffsample; DWORD t, cur_pos; void *p1, *p2; DWORD len1, len2; @@ -113,19 +118,29 @@ uae_u8 sampler_getsample (int channel) inited = 1; oldcycles = get_cycles (); oldoffset = -1; + safepos = -RECORDBUFFER / 10 * SAMPLESIZE; hr = lpDSB2r->GetCurrentPosition (&t, &cap_pos); + cap_pos += safepos; + if (cap_pos > 10 * RECORDBUFFER * SAMPLESIZE) + cap_pos += RECORDBUFFER * SAMPLESIZE; + if (cap_pos >= RECORDBUFFER * SAMPLESIZE) + cap_pos -= RECORDBUFFER * SAMPLESIZE; if (FAILED (hr)) { sampler_free (); return 0; - } + } + clockspersample = sampler_evtime / samplerate + 41000; } + if (clockspersample < 1) + return 0; uae_s16 *sbuf = (uae_s16*)samplebuffer; vsynccnt = 0; sample = 0; samplecnt = 0; cycles = get_cycles () - oldcycles; - offset = cycles / clockspersample; + float cps = clockspersample + diffsample; + offset = (cycles + cps - 1) / cps; if (oldoffset < 0 || offset >= SAMPLEBUFFER || offset < 0) { if (oldoffset >= 0 && offset >= SAMPLEBUFFER) { while (oldoffset < SAMPLEBUFFER) { @@ -134,7 +149,6 @@ uae_u8 sampler_getsample (int channel) samplecnt++; } } - //write_log (L"%d\n", cur_pos - cap_pos); hr = lpDSB2r->Lock (cap_pos, SAMPLEBUFFER * SAMPLESIZE, &p1, &len1, &p2, &len2, 0); if (FAILED (hr)) return 0; @@ -147,20 +161,28 @@ uae_u8 sampler_getsample (int channel) hr = lpDSB2r->GetCurrentPosition (&t, &cur_pos); if (FAILED (hr)) return 0; + cur_pos += safepos; + if (cur_pos >= 10 * RECORDBUFFER * SAMPLESIZE) + cur_pos += RECORDBUFFER * SAMPLESIZE; + if (cur_pos >= RECORDBUFFER * SAMPLESIZE) + cur_pos -= RECORDBUFFER * SAMPLESIZE; if (cur_pos >= cap_pos) diff = cur_pos - cap_pos; else diff = RECORDBUFFER * SAMPLESIZE - cap_pos + cur_pos; - if (diff > RECORDBUFFER * SAMPLESIZE - 4 * SAMPLEBUFFER * SAMPLESIZE) { - write_log (L"!"); - diff -= RECORDBUFFER * SAMPLESIZE; - } else if (diff > RECORDBUFFER * SAMPLESIZE / 2) { - cap_pos = cur_pos; - write_log (L"*"); - diff = 0; - } + if (diff > RECORDBUFFER * SAMPLESIZE / 2) + diff -= RECORDBUFFER * SAMPLESIZE; + diff /= SAMPLESIZE; + + int diff2 = 100 * diff / (RECORDBUFFER / 2); +#if 0 + diffsample = -pow (diff2 < 0 ? -diff2 : diff2, 3.1); + if (diff2 < 0) + diffsample = -diffsample; +#endif +// write_log (L"%d:%.1f\n", diff, diffsample); - cap_pos += diff; + cap_pos += SAMPLEBUFFER * SAMPLESIZE; if (cap_pos < 0) cap_pos += RECORDBUFFER * SAMPLESIZE; if (cap_pos >= RECORDBUFFER * SAMPLESIZE) @@ -186,7 +208,6 @@ uae_u8 sampler_getsample (int channel) int sampler_init (void) { - clockspersample = (float)maxvpos * maxhpos * vblank_hz * CYCLE_UNIT / samplerate; if (currprefs.win32_samplersoundcard < 0) return 0; return 1; diff --git a/scsiemul.cpp b/scsiemul.cpp index 097ae022..1de355c9 100644 --- a/scsiemul.cpp +++ b/scsiemul.cpp @@ -183,6 +183,13 @@ static int openfail (uaecptr ioreq, int error) return (uae_u32)-1; } +static void setpdev (struct priv_devstruct *pdev, struct devstruct *dev) +{ + pdev->scsi = dev->allow_scsi ? 1 : 0; + pdev->ioctl = dev->allow_scsi ? 0 : 1; + pdev->mode = dev->allow_scsi ? DF_SCSI : DF_IOCTL; +} + static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context, int type) { uaecptr ioreq = m68k_areg (regs, 1); @@ -203,9 +210,8 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context, int type) pdev = &pdevst[i]; if (pdev->inuse == 0) break; } - if (type == UAEDEV_SCSI_ID && sys_command_open (DF_SCSI, dev->unitnum)) { - pdev->scsi = 1; - pdev->mode = DF_SCSI; + if (type == UAEDEV_SCSI_ID && sys_command_open (dev->allow_scsi ? DF_SCSI : DF_IOCTL, dev->unitnum)) { + setpdev (pdev, dev); } if (type == UAEDEV_DISK_ID && sys_command_open (DF_IOCTL, dev->unitnum)) { pdev->ioctl = 1; @@ -264,14 +270,74 @@ static int is_async_request (struct devstruct *dev, uaecptr request) return 0; } -void scsi_do_disk_change (int device_id, int insert) + +int scsiemul_switchscsi (TCHAR *name) { + struct devstruct *dev = NULL; + struct device_info *discsi, discsi2; int i, j; + dev = &devst[0]; + if (dev->allow_scsi) + sys_command_close (DF_SCSI, dev->unitnum); + if (dev->allow_ioctl) + sys_command_close (DF_IOCTL, dev->unitnum); + dev->allow_ioctl = 0; + dev->allow_scsi = 0; + + dev = NULL; + for (j = 0; j < 2; j++) { + int mode = j == 0 ? DF_SCSI : DF_IOCTL; + device_func_init (j == 0 ? DEVICE_TYPE_SCSI : DEVICE_TYPE_ANY); + i = 0; + while (i < MAX_TOTAL_DEVICES && dev == NULL) { + discsi = 0; + if (sys_command_open (mode, i)) { + discsi = sys_command_info (mode, i, &discsi2); + if (discsi && discsi->type == INQ_ROMD) { + if (!_tcsicmp (currprefs.cdimagefile, discsi->label) || j) { + dev = &devst[0]; + dev->unitnum = i; + dev->allow_scsi = j == 0 ? 1 : 0; + dev->allow_ioctl = j != 0 ? 1 : 0; + dev->drivetype = discsi->type; + memcpy (&dev->di, discsi, sizeof (struct device_info)); + dev->iscd = 1; + write_log (L"%s mounted as uaescsi.device:0 (SCSI=%d)\n", discsi->label, dev->allow_scsi); + if (dev->aunit >= 0) { + struct priv_devstruct *pdev = &pdevst[dev->aunit]; + setpdev (pdev, dev); + } + } + } + if (devst[0].opencnt == 0) + sys_command_close (mode, i); + } + i++; + } + if (dev) + return i; + } + return -1; +} + +int scsi_do_disk_change (int device_id, int insert) +{ + int i, j, ret; + + ret = -1; + if (!change_sem) + return ret; uae_sem_wait (&change_sem); + if (device_id < 0 && insert) { + ret = scsiemul_switchscsi (currprefs.cdimagefile); + if (ret < 0) + goto end; + } for (i = 0; i < MAX_TOTAL_DEVICES; i++) { struct devstruct *dev = &devst[i]; - if (dev->di.id == device_id) { + if (dev->di.id == device_id || (device_id < 0 && i == 0)) { + ret = i; if (dev->aunit >= 0) { struct priv_devstruct *pdev = &pdevst[dev->aunit]; devinfo (pdev->mode, dev->unitnum, &dev->di); @@ -288,7 +354,9 @@ void scsi_do_disk_change (int device_id, int insert) uae_Cause (dev->changeint); } } +end: uae_sem_post (&change_sem); + return ret; } static int add_async_request (struct devstruct *dev, uaecptr request, int type, uae_u32 data) @@ -764,7 +832,6 @@ static void dev_reset (void) struct device_info *discsi, discsi2; int unitnum = 0; - device_func_init (DEVICE_TYPE_SCSI); for (i = 0; i < MAX_TOTAL_DEVICES; i++) { dev = &devst[i]; if (dev->opencnt > 0) { @@ -774,8 +841,10 @@ static void dev_reset (void) abort_async (dev, request, 0, 0); } dev->opencnt = 1; - sys_command_close (DF_SCSI, dev->unitnum); - sys_command_close (DF_IOCTL, dev->unitnum); + if (dev->allow_scsi) + sys_command_close (DF_SCSI, dev->unitnum); + if (dev->allow_ioctl) + sys_command_close (DF_IOCTL, dev->unitnum); } memset (dev, 0, sizeof (struct devstruct)); dev->unitnum = dev->aunit = -1; @@ -783,24 +852,29 @@ static void dev_reset (void) for (i = 0; i < MAX_OPEN_DEVICES; i++) memset (&pdevst[i], 0, sizeof (struct priv_devstruct)); - i = j = 0; - while (i < MAX_TOTAL_DEVICES) { - dev = &devst[i]; - discsi = 0; - if (sys_command_open (DF_SCSI, j)) { - discsi = sys_command_info (DF_SCSI, j, &discsi2); - sys_command_close (DF_SCSI, j); - } - if (discsi) { - dev->unitnum = j; - dev->allow_scsi = 1; - dev->drivetype = discsi->type; - memcpy (&dev->di, discsi, sizeof (struct device_info)); - if (discsi->type == INQ_ROMD) - dev->iscd = 1; + if (currprefs.cdimagefile[0]) { + scsiemul_switchscsi (currprefs.cdimagefile); + } else { + device_func_init (DEVICE_TYPE_SCSI); + i = j = 0; + while (i < MAX_TOTAL_DEVICES) { + dev = &devst[i]; + discsi = 0; + if (sys_command_open (DF_SCSI, j)) { + discsi = sys_command_info (DF_SCSI, j, &discsi2); + sys_command_close (DF_SCSI, j); + } + if (discsi) { + dev->unitnum = j; + dev->allow_scsi = 1; + dev->drivetype = discsi->type; + memcpy (&dev->di, discsi, sizeof (struct device_info)); + if (discsi->type == INQ_ROMD) + dev->iscd = 1; + } + i++; + j++; } - i++; - j++; } unitnum = 0; for (i = 0; i < MAX_TOTAL_DEVICES; i++) { diff --git a/zfile.cpp b/zfile.cpp index 094e0a52..09bd70d8 100644 --- a/zfile.cpp +++ b/zfile.cpp @@ -1171,7 +1171,7 @@ int iszip (struct zfile *z) zfile_fseek (z, 0, SEEK_SET); if (mask & ZFD_ARCHIVE) { - if (!strcasecmp (ext, L".zip")) { + if (!strcasecmp (ext, L".zip") || !strcasecmp (ext, L".rp9")) { if (header[0] == 'P' && header[1] == 'K') return ArchiveFormatZIP; return 0;