]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
2100b21
authorToni Wilen <twilen@winuae.net>
Sat, 10 Apr 2010 13:21:32 +0000 (16:21 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 10 Apr 2010 13:21:32 +0000 (16:21 +0300)
16 files changed:
akiko.cpp
blkdev_cdimage.cpp
cdtv.cpp
epsonprinter.cpp
include/scsidev.h
inputdevice.cpp
od-win32/blkdev_win32_ioctl.cpp
od-win32/blkdev_win32_spti.cpp
od-win32/rp.cpp
od-win32/sounddep/sound.cpp
od-win32/win32.cpp
od-win32/win32.h
od-win32/win32gui.cpp
sampler.cpp
scsiemul.cpp
zfile.cpp

index 0c4a252f0c64ed8b109fd871ef8fad3d2f3e8936..8d71471378ee50ae993f5cf53fa5353cc1f0729d 100644 (file)
--- 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);
index 51e980d4636c311677b2e6f50d3044fc2f97a1b9..090d32d7d24df2bd113cd22c53f149d594c6569e 100644 (file)
@@ -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 (&sector);
+       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 (&sector);
@@ -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"<EMPTY>");
+       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;
 }
index b76886c6d925060ff5706635b4ab5310c3a988e8..d85f8894fbb18c98402ffb1b28ff0801334c50b0 100644 (file)
--- 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);
index 9b4f2c37cfe2a73f44758fb4c596ca95cd5ec108..790bc5c540c4e23df8b4d2cd90319aa470a84784 100644 (file)
@@ -36,8 +36,8 @@
 
 #include <math.h>
 
-//#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 <png.h>
@@ -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<Tpage_w; x++)
                        {
-                               Bit8u pixel = 255 - *((Bit8u*)Tpage + x + (y*Tpage_pitch));
-                               if (pixel != 255) {
-                                       Bit32u color = 0;
-                                       color |= pixel;
-                                       color |= pixel << 8;
-                                       color |= pixel << 16;
-                                       SetPixel (TmemHDC, x, y, color);
-                               }
+                               Bit8u r, g, b;
+                               getcolor (Tpage, Tcpage, x, y, Tpage_pitch, &r, &g, &b);
+                               if (r != 255 || g != 255 || b != 255)
+                                       SetPixel (TmemHDC, x, y, (r << 16) | (g << 8) | b);
                        }
                }
 
                BitBlt (TprinterDC, leftmargin, topmargin, Tpage_w, Tpage_h, TmemHDC, 0, 0, SRCCOPY);
 
                EndPage (TprinterDC);
-               DeleteObject (bitmap);
                EndDoc (TprinterDC);
 
+               DeleteObject (bitmap);
+               if (dc)
+                       ReleaseDC (NULL, dc);
+
        }
 #ifdef C_LIBPNG
        else
@@ -751,6 +786,7 @@ static void *prt_thread (void *p)
                Bitu i;
                TCHAR fname[MAX_DPATH];
                FILE *fp;
+               Bit8u *bm = NULL;
 
                getfname (fname);
                /* Open the actual file */
@@ -782,22 +818,39 @@ static void *prt_thread (void *p)
                png_set_compression_method(png_ptr, 8);
                png_set_compression_buffer_size(png_ptr, 8192);
 
-
-               png_set_IHDR(png_ptr, info_ptr, Tpage_w, Tpage_h,
-                       8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
-                       PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
-               for (i=0;i<256;i++) 
-               {
-                       palette[i].red = 255 - i;
-                       palette[i].green = 255 - i;
-                       palette[i].blue = 255 - i;
-               }
-               png_set_PLTE(png_ptr, info_ptr, palette,256);
-
                // Allocate an array of scanline pointers
                row_pointers = (png_bytep*)malloc(Tpage_h*sizeof(png_bytep));
-               for (i=0; i<Tpage_h; i++) 
-                       row_pointers[i] = ((Bit8u*)Tpage+(i*Tpage_pitch));
+
+               if (colorPrinted) {
+                       png_set_IHDR(png_ptr, info_ptr, Tpage_w, Tpage_h,
+                               8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
+                               PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+                       bm = xcalloc (Bit8u, Tpage_w * Tpage_h * 3);
+                       for (i=0; i<Tpage_h; i++) 
+                               row_pointers[i] = bm + i * Tpage_w * 3;
+                       for (int y = 0; y < Tpage_h; y++) {
+                               for (int x = 0; x < Tpage_w; x++) {
+                                       Bit8u r, g, b;
+                                       getcolor (Tpage, Tcpage, x, y, Tpage_pitch, &r, &g, &b);
+                                       bm[y * Tpage_w * 3 + x * 3 + 0] = r;
+                                       bm[y * Tpage_w * 3 + x * 3 + 1] = g;
+                                       bm[y * Tpage_w * 3 + x * 3 + 2] = b;
+                               }
+                       }
+               } else {
+                       png_set_IHDR(png_ptr, info_ptr, Tpage_w, Tpage_h,
+                               8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
+                               PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+                       for (i=0;i<256;i++) 
+                       {
+                               palette[i].red = 255 - i;
+                               palette[i].green = 255 - i;
+                               palette[i].blue = 255 - i;
+                       }
+                       png_set_PLTE(png_ptr, info_ptr, palette,256);
+                       for (i=0; i<Tpage_h; i++) 
+                               row_pointers[i] = ((Bit8u*)Tpage+(i*Tpage_pitch));
+               }
 
                // tell the png library what to encode.
                png_set_rows(png_ptr, info_ptr, row_pointers);
@@ -812,12 +865,14 @@ static void *prt_thread (void *p)
                png_destroy_write_struct(&png_ptr, &info_ptr);
 
                /*clean up dynamically allocated RAM.*/
-               free(row_pointers);
+               xfree (row_pointers);
+               xfree (bm);
                ShellExecute (NULL, L"open", fname, NULL, NULL, SW_SHOWNORMAL);
        }
 #endif
 end:
        xfree (Tpage);
+       xfree (Tcpage);
        if (TprinterDC)
                DeleteObject (TprinterDC);
        DeleteObject (TmemHDC);
@@ -834,6 +889,7 @@ static void outputPage(void)
                memHDC = NULL;
                printerDC = NULL;
                page = NULL;
+               cpage = NULL;
        }
 }
 
@@ -841,8 +897,10 @@ static void newPage(int save)
 {
        if (save)
                outputPage ();
-       if (page == NULL)
+       if (page == NULL) {
                page = xcalloc (uae_u8, pagesize);
+               cpage = xcalloc (uae_u8, pagesize);
+       }
        curY = topMargin;
        memset (page, 0, pagesize);
 }
@@ -881,6 +939,7 @@ static void initPrinter(void)
        LQtypeFace = roman;
        justification = JUST_LEFT;
        charcnt = 0;
+       printColor = 0;
 
        selectCodepage(charTables[curCharTable]);
 
@@ -961,6 +1020,7 @@ static int printer_init(Bit16u dpi2, Bit16u width, Bit16u height, const TCHAR *p
        pagesize =  page_w * page_h;
        page_pitch = page_w;
        page = xcalloc (uae_u8, pagesize);
+       cpage = xcalloc (uae_u8, pagesize);
        curFont = NULL;
        charRead = false;
        autoFeed = false;
@@ -981,6 +1041,8 @@ static void printer_close(void)
        if (page != NULL) {
                xfree (page);
                page = NULL;
+               xfree (cpage);
+               cpage = NULL;
 #ifndef WINFONT
                if (ft)
                        FT_Done_FreeType(FTlib);
@@ -1636,8 +1698,9 @@ static int processCommandChar(Bit8u ch)
                        updateFont();
                        break;
                case 0x72: // Select printing color (ESC r)
-                       if (params[0] != 0)
-                               write_log(L"EPSONPRINTER: Color printing not supported\n");
+                       printColor = params[0];
+                       if (printColor > 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<pixsizeX; xx++) {
                                        Bitu yy;
                                        for (yy=0; yy<pixsizeY; yy++)
-                                               if (((PIXX + xx) < page_w) && ((PIXY + yy) < page_h))
+                                               if (((PIXX + xx) < page_w) && ((PIXY + yy) < page_h)) {
                                                        *((Bit8u*)page + PIXX + xx + (PIXY+yy)*page_pitch) = 255;
+                                                       *((Bit8u*)cpage + PIXX + xx + (PIXY+yy)*page_pitch) |= 1 < printColor;
+                                               }
                                }
                        }
 
@@ -1956,6 +2021,7 @@ static void blitGlyph(uae_u8 *gbitmap, int width, int rows, int pitch, int destx
                        if (*source != 0 && (destx+x < page_w) && (desty+y < page_h) && (destx+x >= 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)
index fe5fc4505ef111bedbb8569f98d50823e8848e73..64c1a2f0f365e334c0c7e7447a622d9a057f65f1 100644 (file)
@@ -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;
 
index 51cd9942bfe48b75b001c8759c3c3f4e4f1235dd..4cedf82b32bddb7cac0230d830f42822559c0e3d 100644 (file)
@@ -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:
index 731d2c65f518db63c6f1f1619ef9652e7ce4defb..87706eeb2e5ec63b3185fd840d7e8a15a1089548 100644 (file)
@@ -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
                }
        }
index 0ac18c1fed767430666c667b5ff22f8227c4eda2..e0e2da61570bd8a3e5c4bf29d0e4c652aaa314c8 100644 (file)
@@ -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
index e9db9aad2aafdfb2bb4fb7daad38352b58da9e1f..f5caa750a4a1712b604ab84924b897a6d91dd9ef 100644 (file)
@@ -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) {
index 75784fe0c4aaab6afb582794502768db9cac7361..e09b1711dca7fc90fff0ed7e9c35d5da81738147 100644 (file)
@@ -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)
index 6c567009072cacca8524394d7a0d2841c9301894..8924ccd4eec0f4f5d5012780eb076703102ea9b1 100644 (file)
@@ -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;
index 3bb971cbd66d2912ac0d6ae5b05c3b09be42b3be..7e832b380aef40452ae8ff2f7c36cb747b3304d7 100644 (file)
@@ -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""
 
index 1bdb7d0bb36ec89ed23ede0266f5de1f4ce2d52c..b843d549930f4d52b1bbc208ee7ab94abf9088a3 100644 (file)
@@ -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;
 
-       ifbNoMidiIn) {
+       if (bNoMidiIn) {
                workprefs.win32_midiindev = -1;
        } else {
                workprefs.win32_midiindev = SendDlgItemMessage (hDlg, IDC_MIDIINLIST, CB_GETCURSEL, 0, 0);
index 7bbc44a30adadb526d3e04720db548ae3dd3b56f..69a4a6ce6e3bb07f2a31d9f620ef9cf8bd4405aa 100644 (file)
 
 #include <dsound.h>
 
+#include <math.h>
+
 #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;
index 097ae022473be8a1865ce2f1e5088b55e3c4fd5c..1de355c9003f24f69f62cc802471759d90c15134 100644 (file)
@@ -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++) {
index 094e0a520c4766f2c145804f6bf8000ec15de4d4..09bd70d8f555f038e57158d6f63833448f35bcf8 100644 (file)
--- 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;