]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
2410b2
authorToni Wilen <twilen@winuae.net>
Sun, 1 Apr 2012 18:18:39 +0000 (21:18 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 1 Apr 2012 18:18:39 +0000 (21:18 +0300)
14 files changed:
calc.cpp
custom.cpp
drawing.cpp
include/custom.h
include/xwin.h
inputdevice.cpp
od-win32/direct3d.cpp
od-win32/direct3d.h
od-win32/win32.h
od-win32/win32_scaler.cpp
od-win32/win32gfx.cpp
od-win32/win32gui.cpp
od-win32/winuaechangelog.txt
specialmonitors.cpp

index ec774a04ef0cfe76257f292069f0bd2ae6f5b43d..258fc177d3a9916add82857f766c6645700281fe 100644 (file)
--- a/calc.cpp
+++ b/calc.cpp
@@ -12,7 +12,7 @@
 
 */
 
-#define CALC_DEBUG 1
+#define CALC_DEBUG 0
 
 #if CALC_DEBUG
 #define calc_log(x) do { write_log x; } while(0)
@@ -226,7 +226,7 @@ struct calcstack
        double val;
 };
 
-static double docalcx (TCHAR op, double v1, double v2)
+static double docalcx(TCHAR op, double v1, double v2)
 {
        switch (op)
        {
@@ -256,7 +256,7 @@ static double stacktoval(struct calcstack *st)
        }
 }
 
-static double docalc2 (TCHAR op, struct calcstack *sv1, struct calcstack *sv2)
+static double docalc2(TCHAR op, struct calcstack *sv1, struct calcstack *sv2)
 {
        double v1, v2;
 
@@ -264,7 +264,7 @@ static double docalc2 (TCHAR op, struct calcstack *sv1, struct calcstack *sv2)
        v2 = stacktoval(sv2);
        return docalcx (op, v1, v2);
 }
-static double docalc1 (TCHAR op, struct calcstack *sv1, double v2)
+static double docalc1(TCHAR op, struct calcstack *sv1, double v2)
 {
        double v1;
 
@@ -272,7 +272,7 @@ static double docalc1 (TCHAR op, struct calcstack *sv1, double v2)
        return docalcx (op, v1, v2);
 }
 
-static TCHAR *stacktostr (struct calcstack *st)
+static TCHAR *stacktostr(struct calcstack *st)
 {
        static TCHAR out[256];
        if (st->s)
@@ -281,7 +281,7 @@ static TCHAR *stacktostr (struct calcstack *st)
        return out;
 }
 
-static TCHAR *chartostack (TCHAR c)
+static TCHAR *chartostack(TCHAR c)
 {
        TCHAR *s = xmalloc (TCHAR, 2);
        s[0] = c;
@@ -394,6 +394,9 @@ static bool parse_values(const TCHAR *ins, TCHAR *out)
        TCHAR *in = inbuf;
        TCHAR *p = out;
        op = 0;
+       if (in[0] == '-' || in[0] == '+') {
+               *p++ = '0';
+       }
        while (*in) {
                TCHAR *instart = in;
                if (_istdigit (*in)) {
index 6f858b489915c88ed0ec9cf07b01228347896a2d..bcb9aaadede621c367d0b5dca4bf90e89b5b6fe9 100644 (file)
@@ -2820,7 +2820,7 @@ static bool changed_chipset_refresh (void)
        return stored_chipset_refresh != get_chipset_refresh ();
 }
 
-static void compute_framesync (void)
+void compute_framesync (void)
 {
        int islace = interlace_seen ? 1 : 0;
        int isntsc = (beamcon0 & 0x20) ? 0 : 1;
@@ -2911,16 +2911,28 @@ static void compute_framesync (void)
 
        }
 
+       if (gfxvidinfo.drawbuffer.inwidth > gfxvidinfo.drawbuffer.width_allocated)
+               gfxvidinfo.drawbuffer.inwidth = gfxvidinfo.drawbuffer.width_allocated;
+       if (gfxvidinfo.drawbuffer.inwidth2 > gfxvidinfo.drawbuffer.width_allocated)
+               gfxvidinfo.drawbuffer.inwidth2 = gfxvidinfo.drawbuffer.width_allocated;
 
-       if (gfxvidinfo.drawbuffer.inwidth > gfxvidinfo.drawbuffer.width)
-               gfxvidinfo.drawbuffer.inwidth = gfxvidinfo.drawbuffer.width;
-       if (gfxvidinfo.drawbuffer.inwidth2 > gfxvidinfo.drawbuffer.width)
-               gfxvidinfo.drawbuffer.inwidth2 = gfxvidinfo.drawbuffer.width;
+       if (gfxvidinfo.drawbuffer.inheight > gfxvidinfo.drawbuffer.height_allocated)
+               gfxvidinfo.drawbuffer.inheight = gfxvidinfo.drawbuffer.height_allocated;
+       if (gfxvidinfo.drawbuffer.inheight2 > gfxvidinfo.drawbuffer.height_allocated)
+               gfxvidinfo.drawbuffer.inheight2 = gfxvidinfo.drawbuffer.height_allocated;
 
-       if (gfxvidinfo.drawbuffer.inheight > gfxvidinfo.drawbuffer.height)
-               gfxvidinfo.drawbuffer.inheight = gfxvidinfo.drawbuffer.height;
-       if (gfxvidinfo.drawbuffer.inheight2 > gfxvidinfo.drawbuffer.height)
-               gfxvidinfo.drawbuffer.inheight2 = gfxvidinfo.drawbuffer.height;
+       gfxvidinfo.drawbuffer.outwidth = gfxvidinfo.drawbuffer.inwidth;
+       gfxvidinfo.drawbuffer.outheight = gfxvidinfo.drawbuffer.inheight;
+
+       if (gfxvidinfo.drawbuffer.outwidth > gfxvidinfo.drawbuffer.width_allocated)
+               gfxvidinfo.drawbuffer.outwidth = gfxvidinfo.drawbuffer.width_allocated;
+
+       if (gfxvidinfo.drawbuffer.outheight > gfxvidinfo.drawbuffer.height_allocated)
+               gfxvidinfo.drawbuffer.outheight = gfxvidinfo.drawbuffer.height_allocated;
+
+       if (target_graphics_buffer_update ()) {
+               reset_drawing ();
+       }
 
        compute_vsynctime ();
 
index 7df667dd4454ec4c92b850c8ad9a366c92fdf320..618646d00447c158ef3636f5a73d25dc0cfb1ffd 100644 (file)
@@ -1721,22 +1721,24 @@ static void pfield_doline (int lineno)
 void init_row_map (void)
 {
        int i, j;
-       if (gfxvidinfo.drawbuffer.height > MAX_VIDHEIGHT) {
+       if (gfxvidinfo.drawbuffer.height_allocated > MAX_VIDHEIGHT) {
                write_log (_T("Resolution too high, aborting\n"));
                abort ();
        }
        j = 0;
-       for (i = gfxvidinfo.drawbuffer.height; i < MAX_VIDHEIGHT + 1; i++)
+       for (i = gfxvidinfo.drawbuffer.height_allocated; i < MAX_VIDHEIGHT + 1; i++)
                row_map[i] = row_tmp;
-       for (i = 0; i < gfxvidinfo.drawbuffer.height; i++, j += gfxvidinfo.drawbuffer.rowbytes)
+       for (i = 0; i < gfxvidinfo.drawbuffer.height_allocated; i++, j += gfxvidinfo.drawbuffer.rowbytes)
                row_map[i] = gfxvidinfo.drawbuffer.bufmem + j;
 }
 
-static void init_aspect_maps (void)
+void init_aspect_maps (void)
 {
-       int i, maxl;
+       int i, maxl, h;
 
-       if (gfxvidinfo.drawbuffer.height == 0)
+       h = gfxvidinfo.drawbuffer.height_allocated;
+
+       if (h == 0)
                /* Do nothing if the gfx driver hasn't initialized the screen yet */
                return;
 
@@ -1753,16 +1755,16 @@ static void init_aspect_maps (void)
 
        /* At least for this array the +1 is necessary. */
        amiga2aspect_line_map = xmalloc (int, (MAXVPOS + 1) * 2 + 1);
-       native2amiga_line_map = xmalloc (int, gfxvidinfo.drawbuffer.height);
+       native2amiga_line_map = xmalloc (int, h);
 
        maxl = (MAXVPOS + 1) << linedbld;
        min_ypos_for_screen = minfirstline << linedbl;
        max_drawn_amiga_line = -1;
        for (i = 0; i < maxl; i++) {
                int v = i - min_ypos_for_screen;
-               if (v >= gfxvidinfo.drawbuffer.height && max_drawn_amiga_line < 0)
+               if (v >= h && max_drawn_amiga_line < 0)
                        max_drawn_amiga_line = i - min_ypos_for_screen;
-               if (i < min_ypos_for_screen || v >= gfxvidinfo.drawbuffer.height)
+               if (i < min_ypos_for_screen || v >= h)
                        v = -1;
                amiga2aspect_line_map[i] = v;
        }
@@ -1772,19 +1774,19 @@ static void init_aspect_maps (void)
 
        if (currprefs.gfx_ycenter && !currprefs.gfx_filter_autoscale) {
                /* @@@ verify maxvpos vs. MAXVPOS */
-               extra_y_adjust = (gfxvidinfo.drawbuffer.height - (maxvpos_nom << linedbl)) >> 1;
+               extra_y_adjust = (h - (maxvpos_nom << linedbl)) >> 1;
                if (extra_y_adjust < 0)
                        extra_y_adjust = 0;
        }
 
-       for (i = 0; i < gfxvidinfo.drawbuffer.height; i++)
+       for (i = 0; i < h; i++)
                native2amiga_line_map[i] = -1;
 
        for (i = maxl - 1; i >= min_ypos_for_screen; i--) {
                int j;
                if (amiga2aspect_line_map[i] == -1)
                        continue;
-               for (j = amiga2aspect_line_map[i]; j < gfxvidinfo.drawbuffer.height && native2amiga_line_map[j] == -1; j++)
+               for (j = amiga2aspect_line_map[i]; j < h && native2amiga_line_map[j] == -1; j++)
                        native2amiga_line_map[j] = i >> linedbl;
        }
 
@@ -2515,7 +2517,7 @@ static void draw_lightpen_cursor (int x, int y, int line, int onscreen)
        p = lightpen_cursor + y * LIGHTPEN_WIDTH;
        for (i = 0; i < LIGHTPEN_WIDTH; i++) {
                int xx = x + i - LIGHTPEN_WIDTH / 2;
-               if (*p != '-' && xx >= 0 && xx < gfxvidinfo.drawbuffer.width)
+               if (*p != '-' && xx >= 0 && xx < gfxvidinfo.drawbuffer.outwidth)
                        putpixel (xlinebuffer, gfxvidinfo.drawbuffer.pixbytes, xx, *p == 'x' ? xcolors[color1] : xcolors[color2], 1);
                p++;
        }
@@ -2644,6 +2646,7 @@ void finish_drawing_frame (void)
                lightpen_update (vb);
 
        if (currprefs.monitoremu && gfxvidinfo.tempbuffer.bufmem_allocated) {
+               static bool specialon;
                if (emulate_specialmonitors (vb, &gfxvidinfo.tempbuffer)) {
                        vb = gfxvidinfo.outbuffer = &gfxvidinfo.tempbuffer;
                        if (vb->nativepositioning) {
@@ -2654,8 +2657,17 @@ void finish_drawing_frame (void)
                                vb->outwidth = gfxvidinfo.drawbuffer.outwidth;
                                vb->outheight = gfxvidinfo.drawbuffer.outheight;
                        }
+                       gfxvidinfo.drawbuffer.tempbufferinuse = true;
+                       if (!specialon)
+                               compute_framesync ();
+                       specialon = true;
                        do_flush_screen (vb, 0, vb->outheight);
                        didflush = true;
+               } else {
+                       gfxvidinfo.drawbuffer.tempbufferinuse = false;
+                       if (specialon)
+                               compute_framesync ();
+                       specialon = false;
                }
        }
 
@@ -2895,8 +2907,8 @@ static void clearbuffer (struct vidbuffer *dst)
        if (!dst->bufmem_allocated)
                return;
        uae_u8 *p = dst->bufmem_allocated;
-       for (int y = 0; y < dst->height; y++) {
-               memset (p, 0, dst->width * dst->pixbytes);
+       for (int y = 0; y < dst->height_allocated; y++) {
+               memset (p, 0, dst->width_allocated * dst->pixbytes);
                p += dst->rowbytes;
        }
 }
index 2ec96b44ab59970107e6e892da9c592e48f38310..2594764662d98b84c8fe59f1940f34aa59b154fc 100644 (file)
@@ -215,4 +215,5 @@ uae_u16 customhack_get (struct customhack *ch, int hpos);
 extern void alloc_cycle_ext (int, int);
 extern bool ispal (void);
 extern int current_maxvpos (void);
-struct chipset_refresh *get_chipset_refresh (void);
+extern struct chipset_refresh *get_chipset_refresh (void);
+extern void compute_framesync (void);
\ No newline at end of file
index ee095714c4d839d62fe1005a69eed27f2d0282d8..e470ecc26b3504525815b3028d40752c89138e65 100644 (file)
@@ -50,6 +50,7 @@ extern bool show_screen_maybe (bool);
 
 extern int lockscr (struct vidbuffer*, bool);
 extern void unlockscr (struct vidbuffer*);
+extern bool target_graphics_buffer_update (void);
 
 extern int debuggable (void);
 extern void LED (int);
@@ -104,8 +105,8 @@ struct vidbuffer
     int rowbytes; /* Bytes per row in the memory pointed at by bufmem. */
     int pixbytes; /* Bytes per pixel. */
        /* size of this buffer */
-       int width;
-       int height;
+       int width_allocated;
+       int height_allocated;
        /* size of max visible image */
        int outwidth;
        int outheight;
@@ -117,6 +118,8 @@ struct vidbuffer
        int inheight2;
        /* use drawbuffer instead */
        bool nativepositioning;
+       /* tempbuffer in use */
+       bool tempbufferinuse;
        /* extra width, chipset hpos extra in right border */
        int extrawidth;
 
index 2ae3308ccea26d63b62509ae2cf2f63b10c9522e..834c53a4a0afe95a3831b0172a76b683182a5b62 100644 (file)
@@ -2743,7 +2743,7 @@ static int handle_input_event (int nr, int state, int max, int autofire, bool ca
        int joy;
        bool isaks = false;
 
-       if (nr <= 0)
+       if (nr <= 0 || nr == INPUTEVENT_SPC_CUSTOM_EVENT)
                return 0;
        ie = &events[nr];
        if (isqual (nr))
@@ -3327,6 +3327,10 @@ static void process_custom_event (struct uae_input_device *id, int offset, int s
        int idx, slotoffset, flags, custompos;
        TCHAR *custom;
 
+       queue_input_event (-1, NULL, -1, 0, 0, 1);
+       if (!id)
+               return;
+
        slotoffset = 0;
        if (!checkqualifiers (id->eventid[offset][slotoffset], id->flags[offset][slotoffset], qualmask)) {
                slotoffset = 4;
@@ -3355,16 +3359,13 @@ static void process_custom_event (struct uae_input_device *id, int offset, int s
                        custom = id->custom[offset][idx - 2 + slotoffset];
        }
 
-       handle_custom_event (custom);
-
        if (autofire)
                queue_input_event (-1, custom, 1, 1, currprefs.input_autofire_linecnt, 1);
-       if (!state)
-               queue_input_event (-1, NULL, -1, 0, 0, 1);
-
-
-       id->flags[offset][slotoffset] &= ~ID_FLAG_CUSTOMEVENT_TOGGLED;
-       id->flags[offset][slotoffset] |= custompos ? ID_FLAG_CUSTOMEVENT_TOGGLED : 0;
+       if (state) {
+               handle_custom_event (custom);
+               id->flags[offset][slotoffset] &= ~ID_FLAG_CUSTOMEVENT_TOGGLED;
+               id->flags[offset][slotoffset] |= custompos ? ID_FLAG_CUSTOMEVENT_TOGGLED : 0;
+       }
 }
 
 static void setbuttonstateall (struct uae_input_device *id, struct uae_input_device2 *id2, int button, int state)
@@ -3406,6 +3407,11 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev
                int toggle = (flags & ID_FLAG_TOGGLE) ? 1 : 0;
                int inverttoggle = (flags & ID_FLAG_INVERTTOGGLE) ? 1 : 0;
 
+               if (!state) {
+                       if (i == 0)
+                               process_custom_event (id, ID_BUTTON_OFFSET + button, state, qualmask, autofire);
+               }
+
                setqualifiers (flags, state > 0);
                if (qualonly)
                        continue;
@@ -3440,10 +3446,11 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev
                                process_custom_event (id, ID_BUTTON_OFFSET + button, toggled, qualmask, autofire);
                } else {
                        if (!checkqualifiers (evt, flags, qualmask)) {
-                               if (!state && !(flags & ID_FLAG_CANRELEASE))
+                               if (!state && !(flags & ID_FLAG_CANRELEASE)) {
                                        continue;
-                               else if (state)
+                               } else if (state) {
                                        continue;
+                               }
                        }
                        if (!state)
                                *flagsp &= ~ID_FLAG_CANRELEASE;
@@ -3963,7 +3970,6 @@ static void setcompakb (int *kb, int *srcmap, int index, int af)
 
 int inputdevice_get_compatibility_input (struct uae_prefs *prefs, int index, int *typelist, int **inputlist, int **at)
 {
-       //write_log (L"index=%d joymodes=%d\n", index, joymodes[index]);
        if (index >= MAX_JPORTS || joymodes[index] < 0)
                return 0;
        *typelist = joymodes[index];
@@ -4922,6 +4928,9 @@ static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int state
        if (!keyboards || scancode < 0)
                return handled;
 
+       if (!state)
+               process_custom_event (NULL, 0, 0, 0, 0);
+
        j = 0;
        while (j < MAX_INPUT_DEVICE_EVENTS && na->extra[j] >= 0) {
                if (na->extra[j] == scancode) {
index dfe1846bda4e02d450c430b31ccb358f211aebd3..09ebdd107407cc1caf0f8ccae03ee5e5e66df040 100644 (file)
@@ -1080,14 +1080,50 @@ static LPDIRECT3DTEXTURE9 createtext (int w, int h, D3DFORMAT format)
        return t;
 }
 
-static int createtexture (int iw, int ih, int ow, int oh, int win_w, int win_h)
+static int worktex_width, worktex_height;
+
+static int createamigatexture (int w, int h)
 {
        HRESULT hr;
 
-       texture = createtext (iw, ih, tformat);
+       if (texture)
+               texture->Release ();
+       texture = NULL;
+       if (lpWorkTexture1)
+               lpWorkTexture1->Release ();
+       lpWorkTexture1 = NULL;
+       if (lpWorkTexture2)
+               lpWorkTexture2->Release ();
+       lpWorkTexture2 = NULL;
+
+       texture = createtext (w, h, tformat);
        if (!texture)
                return 0;
-       write_log (_T("%s: %d*%d texture allocated, bits per pixel %d\n"), D3DHEAD, iw, ih, t_depth);
+       write_log (_T("%s: %d*%d texture allocated, bits per pixel %d\n"), D3DHEAD, w, h, t_depth);
+       if (psActive) {
+               D3DLOCKED_BOX lockedBox;
+               if (FAILED (hr = d3ddev->CreateTexture (w, h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpWorkTexture1, NULL))) {
+                       write_log (_T("%s: Failed to create temp texture: %s\n"), D3DHEAD, D3D_ErrorString (hr));
+                       return 0;
+               }
+               if (FAILED (hr = d3ddev->CreateTexture (w, h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpWorkTexture2, NULL))) {
+                       write_log (_T("%s: Failed to create working texture2: %s\n"), D3DHEAD, D3D_ErrorString (hr));
+                       return 0;
+               }
+               if (FAILED (hr = lpHq2xLookupTexture->LockBox (0, &lockedBox, NULL, 0))) {
+                       write_log (_T("%s: Failed to lock box of volume texture: %s\n"), D3DHEAD, D3D_ErrorString (hr));
+                       return 0;
+               }
+               BuildHq2xLookupTexture (worktex_width, worktex_height, w, h,  (unsigned char*)lockedBox.pBits);
+               lpHq2xLookupTexture->UnlockBox (0);
+       }
+       return 1;
+}
+
+static int createtexture (int ow, int oh, int win_w, int win_h)
+{
+       HRESULT hr;
+
        int w, h;
        if (ow > win_w * multx && oh > win_h * multx) {
                w = ow;
@@ -1096,6 +1132,8 @@ static int createtexture (int iw, int ih, int ow, int oh, int win_w, int win_h)
                w = win_w * multx;
                h = win_h * multx;
        }
+       worktex_width = w;
+       worktex_height = h;
        if (FAILED (hr = d3ddev->CreateTexture (w, h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpTempTexture, NULL))) {
                write_log (_T("%s: Failed to create working texture1: %s\n"), D3DHEAD, D3D_ErrorString (hr));
                return 0;
@@ -1104,25 +1142,10 @@ static int createtexture (int iw, int ih, int ow, int oh, int win_w, int win_h)
        texelsize.x = 1.0f / w; texelsize.y = 1.0f / h; texelsize.z = 1; texelsize.w = 1; 
 
        if (psActive) {
-               D3DLOCKED_BOX lockedBox;
-               if (FAILED (hr = d3ddev->CreateTexture (iw, ih, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpWorkTexture1, NULL))) {
-                       write_log (_T("%s: Failed to create temp texture: %s\n"), D3DHEAD, D3D_ErrorString (hr));
-                       return 0;
-               }
-               if (FAILED (hr = d3ddev->CreateTexture (iw, ih, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpWorkTexture2, NULL))) {
-                       write_log (_T("%s: Failed to create working texture2: %s\n"), D3DHEAD, D3D_ErrorString (hr));
-                       return 0;
-               }
                if (FAILED (hr = d3ddev->CreateVolumeTexture (256, 16, 256, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpHq2xLookupTexture, NULL))) {
                        write_log (_T("%s: Failed to create volume texture: %s\n"), D3DHEAD, D3D_ErrorString (hr));
                        return 0;
                }
-               if (FAILED (hr = lpHq2xLookupTexture->LockBox (0, &lockedBox, NULL, 0))) {
-                       write_log (_T("%s: Failed to lock box of volume texture: %s\n"), D3DHEAD, D3D_ErrorString (hr));
-                       return 0;
-               }
-               BuildHq2xLookupTexture (w, h, iw, ih,  (unsigned char*)lockedBox.pBits);
-               lpHq2xLookupTexture->UnlockBox (0);
 
        }
        return 1;
@@ -1575,15 +1598,11 @@ static void setupscenecoords (void)
        RECT sr, dr, zr;
        float w, h;
        float dw, dh;
-       int resmult, vresmult;
        static RECT sr2, dr2, zr2;
 
        //write_log (_T("%dx%d %dx%d %dx%d\n"), tin_w, tin_h, tin_w, tin_h, window_w, window_h);
 
-       resmult = 1 << (gfxvidinfo.gfx_resolution_reserved - currprefs.gfx_resolution);
-       vresmult = 1 << (gfxvidinfo.gfx_vresolution_reserved - currprefs.gfx_vresolution);
-
-       getfilterrect2 (&dr, &sr, &zr, window_w, window_h, tin_w / (mult * resmult), tin_h / (mult * vresmult), mult, tin_w / resmult, tin_h / vresmult);
+       getfilterrect2 (&dr, &sr, &zr, window_w, window_h, tin_w / mult, tin_h / mult, mult, tin_w, tin_h);
 
        if (memcmp (&sr, &sr2, sizeof RECT) || memcmp (&dr, &dr2, sizeof RECT) || memcmp (&zr, &zr2, sizeof RECT)) {
                write_log (_T("POS (%d %d %d %d) - (%d %d %d %d)[%d,%d] (%d %d)\n"),
@@ -1878,7 +1897,7 @@ static int restoredeviceobjects (void)
 
        createmask2texture (currprefs.gfx_filteroverlay);
 
-       if (!createtexture (tin_w, tin_h, tout_w, tout_h, window_w, window_h))
+       if (!createtexture (tout_w, tout_h, window_w, window_h))
                return 0;
        createledtexture ();
 
@@ -1906,7 +1925,6 @@ static int restoredeviceobjects (void)
        hr = d3ddev->SetRenderState (D3DRS_CULLMODE, D3DCULL_NONE);
        hr = d3ddev->SetRenderState (D3DRS_LIGHTING, FALSE);
 
-       setupscenecoords ();
        settransform ();
 
        return 1;
@@ -2001,7 +2019,7 @@ static int getd3dadapter (IDirect3D9 *d3d)
        return D3DADAPTER_DEFAULT;
 }
 
-const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth, int mmult)
+const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int depth, int mmult)
 {
        HRESULT ret, hr;
        static TCHAR errmsg[100] = { 0 };
@@ -2169,7 +2187,7 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth
                        write_log (_T("%s\n"), errmsg);
                        write_log (_T("%s: Retrying fullscreen with DirectDraw\n"), D3DHEAD);
                        if (ddraw_fs_hack_init ()) {
-                               const TCHAR *err2 = D3D_init (ahwnd, w_w, w_h, t_w, t_h, depth, mult);
+                               const TCHAR *err2 = D3D_init (ahwnd, w_w, w_h, depth, mmult);
                                if (err2)
                                        ddraw_fs_hack_free ();
                                return err2;
@@ -2178,7 +2196,7 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth
                if (d3d_ex && D3DEX) {
                        write_log (_T("%s\n"), errmsg);
                        D3DEX = 0;
-                       return D3D_init (ahwnd, w_w, w_h, t_w, t_h, depth, mult);
+                       return D3D_init (ahwnd, w_w, w_h, depth, mmult);
                }
                D3D_free ();
                return errmsg;
@@ -2220,23 +2238,20 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth
        if ((d3dCaps.PixelShaderVersion < D3DPS_VERSION(2,0) || !psEnabled || max_texture_w < 2048 || max_texture_h < 2048 || !shaderon) && d3d_ex) {
                D3DEX = 0;
                write_log (_T("Disabling D3D9Ex\n"));
-               return D3D_init (ahwnd, w_w, w_h, t_w, t_h, depth, mult);
+               return D3D_init (ahwnd, w_w, w_h, depth, mmult);
        }
        if (!shaderon)
                write_log (_T("Using non-shader version\n"));
 
-       window_w = w_w;
-       window_h = w_h;
        multx = mmult;
        mult = S2X_getmult ();
-       tin_w = t_w * mult;
-       tin_h = t_h * mult;
-       tout_w = tin_w * multx;
-       tout_h = tin_h * multx;
+
+       window_w = w_w;
+       window_h = w_h;
 
        if (max_texture_w < w_w  || max_texture_h < w_h) {
                _stprintf (errmsg, _T("%s: %d * %d or bigger texture support required\nYour card's maximum texture size is only %d * %d"),
-                       D3DHEAD, t_w, t_h, max_texture_w, max_texture_h);
+                       D3DHEAD, w_w, w_h, max_texture_w, max_texture_h);
                return errmsg;
        }
        while (multx > 1 && (w_w * multx > max_texture_w || w_h * multx > max_texture_h))
@@ -2295,6 +2310,19 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth
        return 0;
 }
 
+bool D3D_alloctexture (int w, int h)
+{
+       tin_w = w * mult;
+       tin_h = h * mult;
+
+       tout_w = tin_w * multx;
+       tout_h = tin_h * multx;
+
+       if (!createamigatexture (tin_w, tin_h))
+               return false;
+       return true;
+}
+
 static HRESULT reset (void)
 {
        if (d3dex)
@@ -2706,7 +2734,7 @@ void D3D_unlocktexture (void)
 {
        HRESULT hr;
 
-       if (!isd3d ())
+       if (!isd3d () || !texture)
                return;
        if (currprefs.leds_on_screen & (STATUSLINE_CHIPSET | STATUSLINE_RTG))
                updateleds ();
@@ -2719,7 +2747,7 @@ void D3D_unlocktexture (void)
 
 void D3D_flushtexture (int miny, int maxy)
 {
-       if (fulllocked)
+       if (fulllocked || !texture)
                return;
        if (miny >= 0 && maxy >= 0) {
                RECT r;
@@ -2744,7 +2772,7 @@ uae_u8 *D3D_locktexture (int *pitch, bool fullupdate)
 
        if (D3D_needreset () > 0)
                return NULL;
-       if (!isd3d ())
+       if (!isd3d () || !texture)
                return NULL;
 
        lock.pBits = NULL;
@@ -2788,7 +2816,7 @@ bool D3D_renderframe (void)
 {
        static int vsync2_cnt;
 
-       if (!isd3d ())
+       if (!isd3d () || !texture)
                return false;
 
        if (filenotificationhandle != NULL) {
index 4af013fbefb691a7d74803bc30f7ec14e473d791..78fbecf762378c29af1cca98688676c7676d476b 100644 (file)
@@ -1,6 +1,7 @@
 extern void D3D_resize (int width, int height);
 extern void D3D_free (void);
-extern const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth, int mult);
+extern const TCHAR *D3D_init (HWND ahwnd, int w_w, int h_h, int depth, int mmult);
+extern bool D3D_alloctexture (int, int);
 extern void D3D_getpixelformat (int depth,int *rb, int *bb, int *gb, int *rs, int *bs, int *gs, int *ab, int *ar, int *a);
 extern void D3D_refresh (void);
 extern bool D3D_renderframe (void);
index 327e32fcc8f7a80efe625319fc921d2610188935..fb9ff96495d69a1dd5831e2072c76545896f85cd 100644 (file)
@@ -19,8 +19,8 @@
 #define LANG_DLL 1
 
 //#define WINUAEBETA _T("")
-#define WINUAEBETA _T("Beta 1")
-#define WINUAEDATE MAKEBD(2012, 3, 31)
+#define WINUAEBETA _T("Beta 2")
+#define WINUAEDATE MAKEBD(2012, 4, 1)
 #define WINUAEEXTRA _T("")
 //#define WINUAEEXTRA _T("AmiKit Preview")
 #define WINUAEREV _T("")
index 8c492f307b9ac37bf5b79f29b50e85de9f3b2d36..e59cd0c3146d2ee4acd9cd0b9d59b065aa134d3f 100644 (file)
@@ -645,8 +645,8 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height
        dr->left = (temp_width - aws) / 2;
        dr->top = (temp_height - ahs) / 2;
 
-       dr->left -= (dst_width - gfxvidinfo.outbuffer->inwidth2) / 2;
-       dr->top -= (dst_height - gfxvidinfo.outbuffer->inheight2) / 2;
+       dr->left -= (dst_width - aws) / 2;
+       dr->top -= (dst_height - ahs) / 2;
 
        dr->right = dr->left + dst_width;
        dr->bottom = dr->top + dst_height;
@@ -708,9 +708,9 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height
                                cy = 0;
                                cv = 1;
                                if (scalemode == AUTOSCALE_STATIC_NOMINAL || scalemode == AUTOSCALE_INTEGER) {
-                                       cw -= 40 << currprefs.gfx_resolution;
+                                       cw -= 50 << currprefs.gfx_resolution;
                                        ch -= 25 << currprefs.gfx_vresolution;
-                                       cx = 28 << currprefs.gfx_resolution;
+                                       cx = 18 << currprefs.gfx_resolution;
                                        cy = 10 << currprefs.gfx_vresolution;
                                }
                        }
@@ -998,8 +998,6 @@ end:
                OffsetRect (dr, mrsx, mrsy);
        }
 
-
-
        fpux_restore (&fpuv);
 
 }
@@ -1014,8 +1012,8 @@ uae_u8 *getfilterbuffer (int *widthp, int *heightp, int *pitch, int *depth)
        *depth = amiga_depth;
        if (usedfilter == NULL)
                return NULL;
-       *widthp = vb->width;
-       *heightp = vb->height;
+       *widthp = vb->outwidth;
+       *heightp = vb->outheight;
        if (pitch)
                *pitch = vb->rowbytes;
        *depth = vb->pixbytes * 8;
@@ -1108,8 +1106,8 @@ void S2X_init (int dw, int dh, int dd)
        dst_width2 = dw;
        dst_height2 = dh;
        dst_depth2 = dd;
-       amiga_width2 = vb->width;
-       amiga_height2 = vb->height;
+       amiga_width2 = vb->outwidth;
+       amiga_height2 = vb->outheight;
        amiga_depth2 = vb->pixbytes * 8;
 
 
@@ -1152,8 +1150,8 @@ void S2X_init (int dw, int dh, int dd)
        dst_width = dw;
        dst_height = dh;
        dst_depth = dd;
-       amiga_width = vb->width;
-       amiga_height = vb->height;
+       amiga_width = vb->outwidth;
+       amiga_height = vb->outheight;
        amiga_depth = vb->pixbytes * 8;
 
        if (d3d) {
index 944295e75eed7dafd4eb4cde9bbc5a9f35c43096..98df27f3cda0791efff9c8ada3e9749620d8df53 100644 (file)
@@ -1001,8 +1001,8 @@ void flush_clear_screen (struct vidbuffer *vb)
 {
        if (lockscr (vb, true)) {
                int y;
-               for (y = 0; y < vb->height; y++) {
-                       memset (vb->bufmem + y * vb->rowbytes, 0, vb->width * vb->pixbytes);
+               for (y = 0; y < vb->height_allocated; y++) {
+                       memset (vb->bufmem + y * vb->rowbytes, 0, vb->width_allocated * vb->pixbytes);
                }
                unlockscr (vb);
                flush_screen (vb, 0, 0);
@@ -3137,11 +3137,11 @@ static int set_ddraw (void)
        return 1;
 }
 
-static void allocsoftbuffer (struct vidbuffer *buf, int flags, int width, int height, int depth)
+static void allocsoftbuffer (const TCHAR *name, struct vidbuffer *buf, int flags, int width, int height, int depth)
 {
        buf->pixbytes = (depth + 7) / 8;
-       buf->width = (width + 7) & ~7;
-       buf->height = height;
+       buf->width_allocated = (width + 7) & ~7;
+       buf->height_allocated = height;
 
        if (!(flags & DM_SWSCALE)) {
 
@@ -3156,8 +3156,8 @@ static void allocsoftbuffer (struct vidbuffer *buf, int flags, int width, int he
 
        } else if (flags & DM_SWSCALE) {
 
-               int w = buf->width * 2;
-               int h = buf->height * 2;
+               int w = buf->width_allocated * 2;
+               int h = buf->height_allocated * 2;
                int size = (w * 2) * (h * 3) * buf->pixbytes;
                buf->realbufmem = xcalloc (uae_u8, size);
                buf->bufmem_allocated = buf->bufmem = buf->realbufmem + (w + (w * 2) * h) * buf->pixbytes;
@@ -3165,6 +3165,7 @@ static void allocsoftbuffer (struct vidbuffer *buf, int flags, int width, int he
                buf->bufmemend = buf->realbufmem + size - buf->rowbytes;
                buf->bufmem_lockable = true;
 
+               write_log (_T("Allocated %s temp buffer (%d*%d*%d)\n"), name, width, height, depth);
        }
 }
 
@@ -3173,8 +3174,6 @@ static int create_windows (void)
        if (!create_windows_2 ())
                return 0;
 
-
-
        return set_ddraw ();
 }
 
@@ -3248,7 +3247,7 @@ static BOOL doInit (void)
                        if (currprefs.gfx_resolution > gfxvidinfo.gfx_resolution_reserved)
                                gfxvidinfo.gfx_resolution_reserved = currprefs.gfx_resolution;
                        if (currprefs.gfx_vresolution > gfxvidinfo.gfx_vresolution_reserved)
-                               gfxvidinfo.gfx_vresolution_reserved = currprefs.gfx_resolution;
+                               gfxvidinfo.gfx_vresolution_reserved = currprefs.gfx_vresolution;
 
                        //gfxvidinfo.drawbuffer.gfx_resolution_reserved = RES_SUPERHIRES;
 
@@ -3263,17 +3262,12 @@ static BOOL doInit (void)
                                }
                                if (gfxvidinfo.gfx_resolution_reserved == RES_SUPERHIRES)
                                        currentmode->amiga_height *= 2;
-                               if (currentmode->amiga_height > 1024)
-                                       currentmode->amiga_height = 1024;
+                               if (currentmode->amiga_height > 1280)
+                                       currentmode->amiga_height = 1280;
 
                                gfxvidinfo.drawbuffer.inwidth = gfxvidinfo.drawbuffer.outwidth = currentmode->amiga_width;
                                gfxvidinfo.drawbuffer.inheight = gfxvidinfo.drawbuffer.outheight = currentmode->amiga_height;
-                               if (currprefs.monitoremu) {
-                                       if (currentmode->amiga_width < 1024)
-                                               currentmode->amiga_width = 1024;
-                                       if (currentmode->amiga_height < 1024)
-                                               currentmode->amiga_height = 1024;
-                               }
+
                                if (usedfilter) {
                                        if ((usedfilter->flags & (UAE_FILTER_MODE_16 | UAE_FILTER_MODE_32)) == (UAE_FILTER_MODE_16 | UAE_FILTER_MODE_32)) {
                                                currentmode->current_depth = currentmode->native_depth;
@@ -3323,39 +3317,22 @@ static BOOL doInit (void)
 
        if (!screen_is_picasso) {
 
-               allocsoftbuffer (&gfxvidinfo.drawbuffer, currentmode->flags,
-                       currentmode->current_width > currentmode->amiga_width ? currentmode->current_width : currentmode->amiga_width,
-                       currentmode->current_height > currentmode->amiga_height ? currentmode->current_height : currentmode->amiga_height,
-                       currentmode->current_depth);
-               if (currprefs.monitoremu)
-                       allocsoftbuffer (&gfxvidinfo.tempbuffer, currentmode->flags,
+               allocsoftbuffer (_T("draw"), &gfxvidinfo.drawbuffer, currentmode->flags,
+                       1600, 1280, currentmode->current_depth);
+               if (currprefs.monitoremu) {
+                       allocsoftbuffer (_T("monemu"), &gfxvidinfo.tempbuffer, currentmode->flags,
                                currentmode->amiga_width > 1024 ? currentmode->amiga_width : 1024,
                                currentmode->amiga_height > 1024 ? currentmode->amiga_height : 1024,
                                currentmode->current_depth);
-
-               if (currentmode->current_width > gfxvidinfo.drawbuffer.outwidth)
-                       gfxvidinfo.drawbuffer.outwidth = currentmode->current_width;
-               if (gfxvidinfo.drawbuffer.outwidth > gfxvidinfo.drawbuffer.width)
-                       gfxvidinfo.drawbuffer.outwidth = gfxvidinfo.drawbuffer.width;
-
-               if (currentmode->current_height > gfxvidinfo.drawbuffer.outheight)
-                       gfxvidinfo.drawbuffer.outheight = currentmode->current_height;
-               if (gfxvidinfo.drawbuffer.outheight > gfxvidinfo.drawbuffer.height)
-                       gfxvidinfo.drawbuffer.outheight = gfxvidinfo.drawbuffer.height;
+               }
 
                init_row_map ();
        }
        init_colors ();
 
-
-#if defined (GFXFILTER)
        S2X_free ();
-#ifdef D3D
        if (currentmode->flags & DM_D3D) {
-               const TCHAR *err = D3D_init (hAmigaWnd, currentmode->native_width, currentmode->native_height,
-                       screen_is_picasso ? picasso_vidinfo.width : gfxvidinfo.outbuffer->width,
-                       screen_is_picasso ? picasso_vidinfo.height : gfxvidinfo.outbuffer->height,
-                       currentmode->current_depth, screen_is_picasso ? 1 : currprefs.gfx_filter_filtermode + 1);
+               const TCHAR *err = D3D_init (hAmigaWnd, currentmode->native_width, currentmode->native_height, currentmode->current_depth, screen_is_picasso ? 1 : currprefs.gfx_filter_filtermode + 1);
                if (err) {
                        D3D_free ();
                        gui_message (err);
@@ -3368,11 +3345,7 @@ static BOOL doInit (void)
                        goto oops;
                }
        }
-#endif
-       if (currentmode->flags & DM_SWSCALE) {
-               S2X_init (currentmode->native_width, currentmode->native_height, currentmode->native_depth);
-       }
-#endif
+
        screen_is_initialized = 1;
        picasso_refresh ();
 
@@ -3386,6 +3359,32 @@ oops:
        return ret;
 }
 
+bool target_graphics_buffer_update (void)
+{
+       int w, h;
+       
+       if (screen_is_picasso) {
+               w = picasso_vidinfo.width;
+               h = picasso_vidinfo.height;
+       } else {
+               struct vidbuffer *vb = gfxvidinfo.drawbuffer.tempbufferinuse ? &gfxvidinfo.tempbuffer : &gfxvidinfo.drawbuffer;
+               gfxvidinfo.outbuffer = vb;
+               w = vb->outwidth;
+               h = vb->outheight;
+       }
+               
+       write_log (_T("Buffer size (%d*%d)\n"), w, h);
+
+       if (currentmode->flags & DM_D3D) {
+               D3D_alloctexture (w, h);
+       }
+       S2X_free ();
+       if (currentmode->flags & DM_SWSCALE) {
+               S2X_init (currentmode->native_width, currentmode->native_height, currentmode->native_depth);
+       }
+       return true;
+}
+
 void WIN32GFX_WindowMove (void)
 {
 }
index 7734cc1965e5e797ca50f40cb0357c50842e215c..1699edfa724174b26c1494eeae547e2c548f8379 100644 (file)
@@ -11684,21 +11684,27 @@ static void values_from_inputdlg (HWND hDlg, int inputchange)
        }
        item = SendDlgItemMessage (hDlg, IDC_INPUTAMIGA, CB_GETCURSEL, 0, 0L);
        if(item != CB_ERR) {
-               if (item == 1) {
-                       if (item != input_selected_event)
+               if (item != input_selected_event) {
+                       input_selected_event = (int)item;
+                       doselect = 1;
+                       if (item == 1) {
                                doinputcustom (hDlg, 1);
+                       }
                }
-               input_selected_event = (int)item;
-               doselect = 1;
        }
 
        if (inputchange && doselect && input_selected_device >= 0 && input_selected_event >= 0) {
                int flags;
+               bool iscustom = false;
                TCHAR custom[MAX_DPATH];
-               custom[0] = 0;
+
+               if (!_tcscmp (inputdevice_get_eventinfo (INPUTEVENT_SPC_CUSTOM_EVENT)->name, eventnames[input_selected_event])) {
+                       doinputcustom (hDlg, 1);
+                       iscustom = true;
+               }
                inputdevice_get_mapping (input_selected_device, input_selected_widget,
                        &flags, NULL, 0, custom, input_selected_sub_num);
-               if (input_selected_event != 1)
+               if (input_selected_event != 1 && !iscustom)
                        custom[0] = 0;
                inputdevice_set_mapping (input_selected_device, input_selected_widget,
                        eventnames[input_selected_event], _tcslen (custom) == 0 ? NULL : custom,
index 6fdda018ce5f03c280af2b4b971a5f0d83035e6c..eedccd485cf978f5196dd5db6351ec28f1e76125 100644 (file)
@@ -4,6 +4,14 @@
 - restore only single input target to default.
 - hdd from command line
 
+Beta 2:
+
+- Filter system partial rewrite again. Do not use static display buffer. Always dynamically reallocate internal buffer if
+  display mode changes (double scan modes, A2024 etc..). Fixes slowdown introduced in 2.4, also fixes shader filters
+  that expect texture size = output size. Very tall (>1024 line) programmed modes are also now fully visible.
+  Most likely some more updates needed..
+- Always cancel custom event autofire if any release event arrives.
+
 Beta 1:
 
 - Input custom event autofire support.
index cd66fa2579f72dd41bfb73ff23f96fa35ffbddad..807a1a17b3e3431c54fc890630272dbf15671e28 100644 (file)
@@ -62,8 +62,8 @@ STATIC_INLINE void PRGB(struct vidbuffer *dst, uae_u8 *dataline, uae_u8 r, uae_u
 static void clearmonitor(struct vidbuffer *dst)
 {
        uae_u8 *p = dst->bufmem;
-       for (int y = 0; y < dst->height; y++) {
-               memset(p, 0, dst->width * dst->pixbytes);
+       for (int y = 0; y < dst->height_allocated; y++) {
+               memset(p, 0, dst->width_allocated * dst->pixbytes);
                p += dst->rowbytes;
        }
 }