]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc1500b21.zip
authorToni Wilen <twilen@winuae.net>
Wed, 28 May 2008 13:56:28 +0000 (16:56 +0300)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:40:32 +0000 (21:40 +0200)
36 files changed:
autoconf.c
blitter.c
cfgfile.c
custom.c
drawing.c
driveclick.c
expansion.c
gfxutil.c
include/audio.h
include/autoconf.h
include/memory.h
include/traps.h
inputdevice.c
memory.c
newcpu.c
od-win32/ahidsound.c
od-win32/cloanto/RetroPlatformIPC.h
od-win32/cloanto/RetroPlatformIPC_doc_draft.txt
od-win32/dinput.c
od-win32/direct3d.c
od-win32/parser.c
od-win32/picasso96_win.c
od-win32/rp.c
od-win32/rp.h
od-win32/sounddep/sound.c
od-win32/win32.c
od-win32/win32.h
od-win32/win32gfx.c
od-win32/win32gui.c
od-win32/winuaechangelog.txt
savestate.c
traps.c
uaeexe.c
uaelib.c
uaeresource.c
zfile.c

index 316e84494bd4d11ada6596b22637f0cf93710553..76b288a9219edbfe943c854d2dc81c4bf35debae 100755 (executable)
@@ -234,10 +234,10 @@ void rtarea_init (void)
     calltrap (deftrap2 (nullfunc, TRAPFLAG_NO_RETVAL, ""));
 
     org (rtarea_base + 0xFF80);
-    calltrap (deftrap2 (getchipmemsize, TRAPFLAG_DORET, ""));
+    calltrap (deftrapres (getchipmemsize, TRAPFLAG_DORET, "getchipmemsize"));
 
     org (rtarea_base + 0xFF10);
-    calltrap (deftrap2 (uae_puts, TRAPFLAG_NO_RETVAL, ""));
+    calltrap (deftrapres (uae_puts, TRAPFLAG_NO_RETVAL, "uae_puts"));
     dw (RTS);
 
     org (a);
index 979a330c097a3cf985d522911ed2dda65d4d9bec..3318fe3b7edcd637bc2e79ab2498a28441b80c22 100755 (executable)
--- a/blitter.c
+++ b/blitter.c
@@ -256,8 +256,8 @@ static void blitter_done (void)
     ddat1use = ddat2use = 0;
     bltstate = BLT_done;
     blitter_done_notify ();
-    INTREQ(0x8040);
-    event2_remevent(ev2_blitter);
+    INTREQ (0x8040);
+    event2_remevent (ev2_blitter);
     unset_special (&regs, SPCFLAG_BLTNASTY);
 #ifdef BLITTER_DEBUG
     write_log ("vpos=%d, cycles %d, missed %d, total %d\n",
index 97a01a1ddfb653319d28a6cb6c9ae91e48b46f68..24dfe68ce76a730d071b55b023ce72eb8d927a44 100755 (executable)
--- a/cfgfile.c
+++ b/cfgfile.c
@@ -322,7 +322,7 @@ static void write_filesys_config (struct uae_prefs *p, const char *unexpanded,
     }
 }
 
-static void write_compatibility_cpu(struct zfile *f, struct uae_prefs *p)
+static void write_compatibility_cpu (struct zfile *f, struct uae_prefs *p)
 {
     char tmp[100];
     int model;
index f7055ef489e7d85dc2cdfdf4031abd13d2720189..1e79b616ca9cf91d36214228629af0abf2fe0667 100755 (executable)
--- a/custom.c
+++ b/custom.c
@@ -2693,7 +2693,7 @@ static void COPJMP (int num)
     copper_enabled_thisline = 0;
     cop_state.strobe = num;
 
-    if (nocustom()) {
+    if (nocustom ()) {
        immediate_copper (num);
        return;
     }
@@ -3630,7 +3630,7 @@ STATIC_INLINE int dangerous_reg (int reg)
     return 1;
 }
 
-static int custom_wput_copper(int hpos, uaecptr addr, uae_u32 value, int noget)
+static int custom_wput_copper (int hpos, uaecptr addr, uae_u32 value, int noget)
 {
     debug_wputpeek (0xdff000 + (cop_state.saved_i1 & 0x1fe), cop_state.saved_i2);
     return custom_wput_1 (hpos, addr, value, noget);
@@ -3658,7 +3658,7 @@ static void perform_copper_write (int old_hpos)
        cop_state.last_write = cop_state.saved_i1;
        cop_state.last_write_hpos = old_hpos;
        old_hpos++;
-       if (!nocustom() && cop_state.saved_i1 >= 0x140 && cop_state.saved_i1 < 0x180 && old_hpos >= SPR0_HPOS && old_hpos < SPR0_HPOS + 4 * MAX_SPRITES) {
+       if (!nocustom () && cop_state.saved_i1 >= 0x140 && cop_state.saved_i1 < 0x180 && old_hpos >= SPR0_HPOS && old_hpos < SPR0_HPOS + 4 * MAX_SPRITES) {
            //write_log ("%d:%d %04.4X:%04.4X\n", vpos, old_hpos, cop_state.saved_i1, cop_state.saved_i2);
            do_sprites (old_hpos);
        }
@@ -3700,7 +3700,7 @@ static void update_copper (int until_hpos)
     int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80);
     int c_hpos = cop_state.hpos;
 
-    if (nocustom())
+    if (nocustom ())
        return;
 
     if (cop_state.state == COP_wait && vp < cop_state.vcmp) {
@@ -3799,7 +3799,7 @@ static void update_copper (int until_hpos)
            if (copper_cant_read (old_hpos))
                continue;
            cop_state.i2 = chipmem_agnus_wget (cop_state.ip);
-           alloc_cycle(old_hpos, CYCLE_COPPER);
+           alloc_cycle (old_hpos, CYCLE_COPPER);
            cop_state.ip += 2;
            if (cop_state.ignore_next) {
                cop_state.ignore_next = 0;
@@ -3914,7 +3914,7 @@ static void update_copper (int until_hpos)
                /* another undocumented copper feature:
                   copper stops if skipped instruction is MOVE to dangerous register...
                */
-               test_copper_dangerous (chipmem_agnus_wget(cop_state.ip));
+               test_copper_dangerous (chipmem_agnus_wget (cop_state.ip));
            }
 
 #ifdef DEBUGGER
@@ -3937,7 +3937,7 @@ static void compute_spcflag_copper (void)
 {
     copper_enabled_thisline = 0;
     unset_special (&regs, SPCFLAG_COPPER);
-    if (!dmaen (DMA_COPPER) || cop_state.state == COP_stop || cop_state.state == COP_bltwait || nocustom())
+    if (!dmaen (DMA_COPPER) || cop_state.state == COP_stop || cop_state.state == COP_bltwait || nocustom ())
        return;
 
     if (cop_state.state == COP_wait) {
@@ -3957,8 +3957,7 @@ void blitter_done_notify (void)
 
     cop_state.hpos = current_hpos () & ~1;
     cop_state.vpos = vpos;
-    /* apparently there is small delay until copper wakes up.. */
-    cop_state.state = COP_wait_in2;
+    cop_state.state = COP_read1;
     compute_spcflag_copper ();
 }
 
@@ -4440,6 +4439,7 @@ static void vsync_handler (void)
     filesys_vsync ();
 
     init_hardware_frame ();
+
 }
 
 #ifdef JIT
@@ -4663,12 +4663,10 @@ static void hsync_handler (void)
     }
 
     {
-       //extern void uaenet_fake_int_handler (void);
        extern int volatile uaenet_int_requested;
        extern int volatile uaenet_vsync_requested;
        if (uaenet_int_requested || (uaenet_vsync_requested && vpos == 10)) {
            INTREQ (0x8000 | 0x2000);
-           //uaenet_fake_int_handler ();
        }
     }
 
index f5f5c4411c1f74713979803ee47efe7395abcfa9..d49083257909dc24f8e40d7249b89d5fafc88169 100755 (executable)
--- a/drawing.c
+++ b/drawing.c
@@ -853,7 +853,7 @@ static void init_ham_decoding (void)
     ham_decode_pixel = src_pixel;
     ham_lastcolor = color_reg_get (&colors_for_drawing, 0);
 
-    if (! bplham || (bplplanecnt != 6 && ((currprefs.chipset_mask & CSMASK_AGA) == 0 || bplplanecnt != 8))) {
+    if (!bplham) {
        if (unpainted_amiga > 0) {
            int pv = pixdata.apixels[ham_decode_pixel + unpainted_amiga - 1];
 #ifdef AGA
@@ -865,38 +865,40 @@ static void init_ham_decoding (void)
        }
 #ifdef AGA
     } else if (currprefs.chipset_mask & CSMASK_AGA) {
-       if (bplplanecnt == 8) { /* AGA mode HAM8 */
+       if (bplplanecnt >= 7) { /* AGA mode HAM8 */
            while (unpainted_amiga-- > 0) {
                int pv = pixdata.apixels[ham_decode_pixel++];
-               switch (pv & 0x3) {
-               case 0x0: ham_lastcolor = colors_for_drawing.color_regs_aga[pv >> 2]; break;
-               case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break;
-               case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break;
-               case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break;
+               switch (pv & 0x3)
+               {
+                   case 0x0: ham_lastcolor = colors_for_drawing.color_regs_aga[pv >> 2]; break;
+                   case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break;
+                   case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break;
+                   case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break;
                }
            }
-       } else if (bplplanecnt == 6) { /* AGA mode HAM6 */
+       } else { /* AGA mode HAM6 */
            while (unpainted_amiga-- > 0) {
                int pv = pixdata.apixels[ham_decode_pixel++];
-               switch (pv & 0x30) {
-               case 0x00: ham_lastcolor = colors_for_drawing.color_regs_aga[pv]; break;
-               case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pv & 0xF) << 4; break;
-               case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break;
-               case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break;
+               switch (pv & 0x30)
+               {
+                   case 0x00: ham_lastcolor = colors_for_drawing.color_regs_aga[pv]; break;
+                   case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pv & 0xF) << 4; break;
+                   case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break;
+                   case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break;
                }
            }
        }
 #endif
     } else {
-       if (bplplanecnt == 6) { /* OCS/ECS mode HAM6 */
-           while (unpainted_amiga-- > 0) {
-               int pv = pixdata.apixels[ham_decode_pixel++];
-               switch (pv & 0x30) {
-               case 0x00: ham_lastcolor = colors_for_drawing.color_regs_ecs[pv]; break;
-               case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break;
-               case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break;
-               case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break;
-               }
+       /* OCS/ECS mode HAM6 */
+       while (unpainted_amiga-- > 0) {
+           int pv = pixdata.apixels[ham_decode_pixel++];
+           switch (pv & 0x30)
+           {
+               case 0x00: ham_lastcolor = colors_for_drawing.color_regs_ecs[pv]; break;
+               case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break;
+               case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break;
+               case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break;
            }
        }
     }
@@ -906,7 +908,7 @@ static void decode_ham (int pix, int stoppos)
 {
     int todraw_amiga = res_shift_from_window (stoppos - pix);
 
-    if (! bplham || (bplplanecnt != 6 && ((currprefs.chipset_mask & CSMASK_AGA) == 0 || bplplanecnt != 8))) {
+    if (!bplham) {
        while (todraw_amiga-- > 0) {
            int pv = pixdata.apixels[ham_decode_pixel];
 #ifdef AGA
@@ -920,42 +922,44 @@ static void decode_ham (int pix, int stoppos)
        }
 #ifdef AGA
     } else if (currprefs.chipset_mask & CSMASK_AGA) {
-       if (bplplanecnt == 8) { /* AGA mode HAM8 */
+       if (bplplanecnt >= 7) { /* AGA mode HAM8 */
            while (todraw_amiga-- > 0) {
                int pv = pixdata.apixels[ham_decode_pixel];
-               switch (pv & 0x3) {
-               case 0x0: ham_lastcolor = colors_for_drawing.color_regs_aga[pv >> 2]; break;
-               case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break;
-               case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break;
-               case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break;
+               switch (pv & 0x3)
+               {
+                   case 0x0: ham_lastcolor = colors_for_drawing.color_regs_aga[pv >> 2]; break;
+                   case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break;
+                   case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break;
+                   case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break;
                }
                ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
            }
-       } else if (bplplanecnt == 6) { /* AGA mode HAM6 */
+       } else { /* AGA mode HAM6 */
            while (todraw_amiga-- > 0) {
                int pv = pixdata.apixels[ham_decode_pixel];
-               switch (pv & 0x30) {
-               case 0x00: ham_lastcolor = colors_for_drawing.color_regs_aga[pv]; break;
-               case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pv & 0xF) << 4; break;
-               case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break;
-               case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break;
+               switch (pv & 0x30)
+               {
+                   case 0x00: ham_lastcolor = colors_for_drawing.color_regs_aga[pv]; break;
+                   case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pv & 0xF) << 4; break;
+                   case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break;
+                   case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break;
                }
                ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
            }
        }
 #endif
     } else {
-       if (bplplanecnt == 6) { /* OCS/ECS mode HAM6 */
-           while (todraw_amiga-- > 0) {
-               int pv = pixdata.apixels[ham_decode_pixel];
-               switch (pv & 0x30) {
-               case 0x00: ham_lastcolor = colors_for_drawing.color_regs_ecs[pv]; break;
-               case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break;
-               case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break;
-               case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break;
-               }
-               ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
+       /* OCS/ECS mode HAM6 */
+       while (todraw_amiga-- > 0) {
+           int pv = pixdata.apixels[ham_decode_pixel];
+           switch (pv & 0x30)
+           {
+               case 0x00: ham_lastcolor = colors_for_drawing.color_regs_ecs[pv]; break;
+               case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break;
+               case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break;
+               case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break;
            }
+           ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
        }
     }
 }
index 5383d03df37b8d4a3ef4e0dc903defb3dbdf9717..d53420d0b0592c4e5c5fabe0e1de9c9f51b99793 100755 (executable)
@@ -300,15 +300,15 @@ static int clickcnt;
 
 static void mix (void)
 {
-    int total = ((uae_u8*)sndbufpt - (uae_u8*)sndbuffer) / (get_audio_nativechannels() * 2);
+    int total = ((uae_u8*)sndbufpt - (uae_u8*)sndbuffer) / (get_audio_nativechannels () * 2);
 
     if (currprefs.dfxclickvolume > 0) {
        while (clickcnt < total) {
-           clickbuffer[clickcnt++] = getsample() * (100 - currprefs.dfxclickvolume) / 100;
+           clickbuffer[clickcnt++] = getsample () * (100 - currprefs.dfxclickvolume) / 100;
        }
     } else {
        while (clickcnt < total) {
-           clickbuffer[clickcnt++] = getsample();
+           clickbuffer[clickcnt++] = getsample ();
        }
     }
 }
@@ -328,26 +328,52 @@ void driveclick_mix (uae_s16 *sndbuffer, int size)
 
     if (!wave_initialized)
        return;
-    mix();
+    mix ();
     clickcnt = 0;
-    if (!get_audio_ismono ()) {
-       for (i = 0; i < size / 2; i++) {
-           uae_s16 s = clickbuffer[i];
-           sndbuffer[0] = limit(((sndbuffer[0] + s) * 2) / 3);
-           sndbuffer[1] = limit(((sndbuffer[1] + s) * 2) / 3);
-           sndbuffer += 2;
-       }
-    } else {
-       for (i = 0; i < size; i++) {
-           sndbuffer[0] = limit(((sndbuffer[0] + clickbuffer[i]) * 2) / 3);
-           sndbuffer++;
-       }
+    switch (get_audio_nativechannels ())
+    {
+       case 6:
+           for (i = 0; i < size / 6; i++) {
+               uae_s16 s = clickbuffer[i];
+               sndbuffer[0] = limit (((sndbuffer[0] + s) * 2) / 3);
+               sndbuffer[1] = limit (((sndbuffer[1] + s) * 2) / 3);
+               sndbuffer[2] = limit (((sndbuffer[2] + s) * 2) / 3);
+               sndbuffer[3] = limit (((sndbuffer[3] + s) * 2) / 3);
+               sndbuffer[4] = limit (((sndbuffer[4] + s) * 2) / 3);
+               sndbuffer[5] = limit (((sndbuffer[5] + s) * 2) / 3);
+               sndbuffer += 6;
+           }
+       break;
+       case 4:
+           for (i = 0; i < size / 4; i++) {
+               uae_s16 s = clickbuffer[i];
+               sndbuffer[0] = limit (((sndbuffer[0] + s) * 2) / 3);
+               sndbuffer[1] = limit (((sndbuffer[1] + s) * 2) / 3);
+               sndbuffer[2] = limit (((sndbuffer[2] + s) * 2) / 3);
+               sndbuffer[3] = limit (((sndbuffer[3] + s) * 2) / 3);
+               sndbuffer += 4;
+           }
+       break;
+       case 2:
+           for (i = 0; i < size / 2; i++) {
+               uae_s16 s = clickbuffer[i];
+               sndbuffer[0] = limit (((sndbuffer[0] + s) * 2) / 3);
+               sndbuffer[1] = limit (((sndbuffer[1] + s) * 2) / 3);
+               sndbuffer += 2;
+           }
+       break;
+       case 1:
+           for (i = 0; i < size; i++) {
+               sndbuffer[0] = limit (((sndbuffer[0] + clickbuffer[i]) * 2) / 3);
+               sndbuffer++;
+           }
+       break;
     }
 }
 
 static void dr_audio_activate(void)
 {
-    if (audio_activate())
+    if (audio_activate ())
        clickcnt = 0;
 }
 
@@ -361,13 +387,13 @@ void driveclick_click (int drive, int cyl)
        return;
     if (prevcyl[drive] == 0 && cyl == 0) // "noclick" check
        return;
-    dr_audio_activate();
+    dr_audio_activate ();
     prevcyl[drive] = cyl;
     if (!wave_initialized) {
        driveclick_fdrawcmd_seek (currprefs.dfxclick[drive] - 2, cyl);
        return;
     }
-    mix();
+    mix ();
     drvs[drive][DS_CLICK].pos = drvs[drive][DS_CLICK].indexes[cyl] << DS_SHIFT;
     drvs[drive][DS_CLICK].len = (drvs[drive][DS_CLICK].indexes[cyl] + (drvs[drive][DS_CLICK].lengths[cyl] / 2)) << DS_SHIFT;
 }
@@ -382,7 +408,7 @@ void driveclick_motor (int drive, int running)
        driveclick_fdrawcmd_motor (currprefs.dfxclick[drive] - 2, running);
        return;
     }
-    mix();
+    mix ();
     if (running == 0) {
        drv_starting[drive] = 0;
        drv_spinning[drive] = 0;
@@ -419,9 +445,9 @@ void driveclick_check_prefs (void)
 {
     int i;
 
-    driveclick_fdrawcmd_vsync();
-    if (driveclick_active())
-       dr_audio_activate();
+    driveclick_fdrawcmd_vsync ();
+    if (driveclick_active ())
+       dr_audio_activate ();
     if (currprefs.dfxclickvolume != changed_prefs.dfxclickvolume ||
        currprefs.dfxclick[0] != changed_prefs.dfxclick[0] ||
        currprefs.dfxclick[1] != changed_prefs.dfxclick[1] ||
index b51b33f23838f6ce5a13c2449ffdd47f9b2320ce..1b45de64158d1f33022b63fb4b11cda833460baf 100755 (executable)
@@ -1195,6 +1195,8 @@ static uaecptr check_boot_rom (void)
 
     if (currprefs.cs_cdtvcd || currprefs.cs_cdtvscsi || currprefs.uae_hide > 1)
        b = RTAREA_BACKUP;
+    if (currprefs.cs_mbdmac == 1)
+       b = RTAREA_BACKUP;
     ab = &get_mem_bank (RTAREA_DEFAULT);
     if (ab) {
        if (valid_address (RTAREA_DEFAULT, 65536))
index 357748f9a0494de62f7ad8ca4989613c216db510..3cbaf5de2731227be6b76e6177ab6120c8d74729 100755 (executable)
--- a/gfxutil.c
+++ b/gfxutil.c
@@ -251,6 +251,14 @@ void alloc_colors_picasso (int rw, int gw, int bw, int rs, int gs, int bs, int r
        green_shift = 5;
        blue_shift = 10;
        break;
+       default:
+       red_bits = rw;
+       green_bits = gw;
+       blue_bits = bw;
+       red_shift = rs;
+       green_shift = gs;
+       blue_shift = bs;
+       break;
     }
 
     memset (p96_rgbx16, 0, sizeof p96_rgbx16);
index 0d7723269ba2f3c79d8c676cdd1de4bb45462a08..ad5ccd36cfce79810faa05b9cf97a898bbd6822e 100755 (executable)
@@ -40,17 +40,17 @@ extern void write_wavheader (struct zfile *wavfile, uae_u32 size, uae_u32 freq);
 
 enum {
     SND_MONO, SND_STEREO, SND_4CH_CLONEDSTEREO, SND_4CH, SND_6CH_CLONEDSTEREO, SND_6CH, SND_NONE };
-STATIC_INLINE int get_audio_nativechannels(void)
+STATIC_INLINE int get_audio_nativechannels (void)
 {
     int ch[] = { 1, 2, 4, 4, 6, 6, 0 };
     return ch[currprefs.sound_stereo];
 }
-STATIC_INLINE int get_audio_amigachannels(void)
+STATIC_INLINE int get_audio_amigachannels (void)
 {
     int ch[] = { 1, 2, 2, 4, 2, 4, 0 };
     return ch[currprefs.sound_stereo];
 }
-STATIC_INLINE int get_audio_ismono(void)
+STATIC_INLINE int get_audio_ismono (void)
 {
     if (currprefs.sound_stereo == 0)
        return 1;
index 3d03b4f58e6c9f44a74fd85236ea8557eaa1a6c2..564f7e4401876f2d5eeaa88ada596accf57c2db3 100755 (executable)
@@ -21,6 +21,7 @@ extern uaecptr makedatatable (uaecptr resid, uaecptr resname, uae_u8 type, uae_s
 
 #define deftrap(f) define_trap((f), 0, "")
 #define deftrap2(f, mode, str) define_trap((f), (mode), (str))
+#define deftrapres(f, mode, str) define_trap((f), (mode | TRAPFLAG_UAERES), (str))
 
 extern void align (int);
 
@@ -86,9 +87,3 @@ extern void expansion_cleanup (void);
 extern void expansion_clear (void);
 
 extern void uaegfx_install_code (void);
-
-#define TRAPFLAG_NO_REGSAVE 1
-#define TRAPFLAG_NO_RETVAL 2
-#define TRAPFLAG_EXTRA_STACK 4
-#define TRAPFLAG_DORET 8
-
index 6571203277338b9916d15c71b47c2e59782154fb..de6c9943893f2535eb9228376d40e17dbb7c99ad 100755 (executable)
@@ -407,7 +407,7 @@ extern void free_keyring (void);
 extern int get_keyring (void);
 
 uaecptr strcpyha_safe (uaecptr dst, const char *src);
-extern char *strcpyah_safe (char *dst, uaecptr src);
+extern char *strcpyah_safe (char *dst, uaecptr src, int maxsize);
 void memcpyha_safe (uaecptr dst, const uae_u8 *src, int size);
 void memcpyha (uaecptr dst, const uae_u8 *src, int size);
 void memcpyah_safe (uae_u8 *dst, uaecptr src, int size);
index 05262653006bb54b05b32c10d404ab1bc6630fa2..d9923648368fe1efb981aa6fa7134dba4fdfe695 100755 (executable)
@@ -26,6 +26,7 @@ typedef struct TrapContext
 #define TRAPFLAG_NO_RETVAL   2
 #define TRAPFLAG_EXTRA_STACK 4
 #define TRAPFLAG_DORET       8
+#define TRAPFLAG_UAERES     16
 
 /*
  * A function which handles a 68k trap
@@ -39,6 +40,7 @@ typedef uae_u32 (REGPARAM3 *TrapHandler) (TrapContext *) REGPARAM;
 extern void REGPARAM3 m68k_handle_trap (unsigned int trap_num, struct regstruct *) REGPARAM;
 
 unsigned int define_trap (TrapHandler handler_func, int flags, const char *name);
+uaecptr find_trap (const char *name);
 
 /*
  * Call a 68k Library function from an extended trap
index 5245014fc9b3caa028a003c85c9d6cb1e9f68a5c..ee7cc2a8d3810f3a383732fd8c68d0959c33d114 100755 (executable)
@@ -3311,9 +3311,6 @@ void pausemode (int mode)
        pause_emulation = pause_emulation ? 0 : 1;
     else
        pause_emulation = mode;
-#ifdef RETROPLATFORM
-    rp_pause (pause_emulation);
-#endif
 }
 
 int jsem_isjoy (int port, const struct uae_prefs *p)
index 3e041f931f92833a7d9df5d5cee9b4dfdcbbe682..3dea73d3d8b3cc04dff4d68e095744d45864e4e8 100755 (executable)
--- a/memory.c
+++ b/memory.c
@@ -44,13 +44,11 @@ static int isdirectjit (void)
 
 static int canjit (void)
 {
-    return 1;
-#if 0
-    if (canbang || currprefs.cpu_model >= 68020)
+    if (currprefs.cpu_model >= 68020)
        return 1;
     return 0;
-#endif
 }
+
 static void nocanbang (void)
 {
     canbang = 0;
@@ -122,7 +120,7 @@ void romlist_add (char *path, struct romdata *rd)
        return;
     }
     romlist_cnt++;
-    rl = (struct romlist*)realloc (rl, sizeof (struct romlist) * romlist_cnt);
+    rl = realloc (rl, sizeof (struct romlist) * romlist_cnt);
     rl2 = rl + romlist_cnt - 1;
     rl2->path = my_strdup (path);
     rl2->rd = rd;
@@ -444,7 +442,7 @@ struct romlist **getromlistbyident(int ver, int rev, int subver, int subrev, cha
        max = i;
     else
        max = romlist_cnt;
-    buf = xmalloc((sizeof (struct romlist*) + sizeof (struct romlist)) * (i + 1));
+    buf = xmalloc ((sizeof (struct romlist*) + sizeof (struct romlist)) * (i + 1));
     rdout = (struct romlist**)buf;
     rltmp = (struct romlist*)((uae_u8*)buf + (i + 1) * sizeof (struct romlist*));
     out = 0;
@@ -539,7 +537,7 @@ struct romlist **getarcadiaroms(void)
        if (roms[i].group == 0 && (roms[i].type == ROMTYPE_ARCADIABIOS || roms[i].type == ROMTYPE_ARCADIAGAME))
            max++;
     }
-    buf = xmalloc((sizeof (struct romlist*) + sizeof (struct romlist)) * (max + 1));
+    buf = xmalloc ((sizeof (struct romlist*) + sizeof (struct romlist)) * (max + 1));
     rdout = (struct romlist**)buf;
     rltmp = (struct romlist*)((uae_u8*)buf + (max + 1) * sizeof (struct romlist*));
     out = 0;
@@ -1462,6 +1460,7 @@ static uae_u8 *REGPARAM2 chipmem_xlate (uaecptr addr)
 /* Slow memory */
 
 static uae_u8 *bogomemory;
+static int bogomemory_allocated;
 
 static uae_u32 REGPARAM3 bogomem_lget (uaecptr) REGPARAM;
 static uae_u32 REGPARAM3 bogomem_wget (uaecptr) REGPARAM;
@@ -2330,28 +2329,24 @@ addrbank custmem2_bank = {
 static int a3000_f0;
 void a3000_fakekick (int map)
 {
-    static uae_u8 *blop;
+    static uae_u8 *kickstore;
 
     if (map) {
        uae_u8 *fkickmemory = a3000lmemory + allocated_a3000lmem - fkickmem_size;
        if (fkickmemory[2] == 0x4e && fkickmemory[3] == 0xf9 && fkickmemory[4] == 0x00) {
-           if (!blop)
-               blop = xmalloc (fkickmem_size);
-           memcpy (blop, kickmemory, fkickmem_size);
+           if (!kickstore)
+               kickstore = xmalloc (fkickmem_size);
+           memcpy (kickstore, kickmemory, fkickmem_size);
            if (fkickmemory[5] == 0xfc) {
                memcpy (kickmemory, fkickmemory, fkickmem_size / 2);
                memcpy (kickmemory + fkickmem_size / 2, fkickmemory, fkickmem_size / 2);
-               if (need_uae_boot_rom () != 0xf00000) {
-                   extendedkickmem_size = 65536;
-                   extendedkickmem_mask = extendedkickmem_size - 1;
-                   extendedkickmemory = mapped_malloc (extendedkickmem_size, "rom_f0");
-                   extendedkickmem_bank.baseaddr = extendedkickmemory;
-                   memcpy (extendedkickmemory, fkickmemory + fkickmem_size / 2, 65536);
-                   map_banks (&extendedkickmem_bank, 0xf0, 1, 1);
-                   a3000_f0 = 1;
-               } else {
-                   write_log ("A3000 Bonus hack: can't map bonus when uae boot rom is enabled\n");
-               }
+               extendedkickmem_size = 65536;
+               extendedkickmem_mask = extendedkickmem_size - 1;
+               extendedkickmemory = mapped_malloc (extendedkickmem_size, "rom_f0");
+               extendedkickmem_bank.baseaddr = extendedkickmemory;
+               memcpy (extendedkickmemory, fkickmemory + fkickmem_size / 2, 65536);
+               map_banks (&extendedkickmem_bank, 0xf0, 1, 1);
+               a3000_f0 = 1;
            } else {
                memcpy (kickmemory, fkickmemory, fkickmem_size);
            }
@@ -2359,14 +2354,14 @@ void a3000_fakekick (int map)
     } else {
        if (a3000_f0) {
            map_banks (&dummy_bank, 0xf0, 1, 1);
-           mapped_free(extendedkickmemory);
+           mapped_free (extendedkickmemory);
            extendedkickmemory = NULL;
            a3000_f0 = 0;
        }
-       if (blop)
-           memcpy (kickmemory, blop, fkickmem_size);
-       xfree(blop);
-       blop = NULL;
+       if (kickstore)
+           memcpy (kickmemory, kickstore, fkickmem_size);
+       xfree (kickstore);
+       kickstore = NULL;
     }
 }
 
@@ -3049,6 +3044,33 @@ static void init_mem_banks (void)
 
 static void allocate_memory (void)
 {
+    /* emulate 0.5M+0.5M with 1M Agnus chip ram aliasing */
+    if ((allocated_chipmem != currprefs.chipmem_size || allocated_bogomem != currprefs.bogomem_size) &&
+       currprefs.chipmem_size == 0x80000 && currprefs.bogomem_size >= 0x80000 &&
+       (currprefs.chipset_mask & CSMASK_ECS_AGNUS) && !(currprefs.chipset_mask & CSMASK_AGA) && !canjit ()) {
+       int memsize1, memsize2;
+       if (chipmemory)
+           mapped_free (chipmemory);
+       chipmemory = 0;
+       if (bogomemory_allocated)
+           mapped_free (bogomemory);
+       bogomemory = 0;
+       bogomemory_allocated = 0;
+       memsize1 = allocated_chipmem = currprefs.chipmem_size;
+       memsize2 = allocated_bogomem = currprefs.bogomem_size;
+       chipmem_mask = allocated_chipmem - 1;
+       chipmem_full_mask = allocated_chipmem * 2 - 1;
+       chipmemory = mapped_malloc (memsize1 + memsize2, "chip");
+       bogomemory = chipmemory + memsize1;
+       bogomem_mask = allocated_bogomem - 1;
+       if (chipmemory == 0) {
+           write_log ("Fatal error: out of memory for chipmem.\n");
+           allocated_chipmem = 0;
+       } else {
+           need_hardreset = 1;
+       }
+    }
+
     if (allocated_chipmem != currprefs.chipmem_size) {
        int memsize;
        if (chipmemory)
@@ -3072,21 +3094,21 @@ static void allocate_memory (void)
            if (memsize != allocated_chipmem)
                memset (chipmemory + allocated_chipmem, 0xff, memsize - allocated_chipmem);
        }
-    }
-
-    currprefs.chipset_mask = changed_prefs.chipset_mask;
-    chipmem_full_mask = allocated_chipmem - 1;
-    if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
-       if (allocated_chipmem < 0x100000)
-           chipmem_full_mask = 0x100000 - 1;
-       if (allocated_chipmem > 0x100000 && allocated_chipmem < 0x200000)
-           chipmem_full_mask = chipmem_mask = 0x200000 - 1;
+       currprefs.chipset_mask = changed_prefs.chipset_mask;
+       chipmem_full_mask = allocated_chipmem - 1;
+       if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
+           if (allocated_chipmem < 0x100000)
+               chipmem_full_mask = 0x100000 - 1;
+           if (allocated_chipmem > 0x100000 && allocated_chipmem < 0x200000)
+               chipmem_full_mask = chipmem_mask = 0x200000 - 1;
+       }
     }
 
     if (allocated_bogomem != currprefs.bogomem_size) {
-       if (bogomemory)
+       if (bogomemory_allocated)
            mapped_free (bogomemory);
        bogomemory = 0;
+       bogomemory_allocated = 0;
 
        allocated_bogomem = currprefs.bogomem_size;
        bogomem_mask = allocated_bogomem - 1;
@@ -3217,7 +3239,7 @@ void map_overlay (int chip)
        map_banks (&dummy_bank, 0, 32, 0);
        if (!isdirectjit ()) {
            map_banks (cb, 0, size, allocated_chipmem);
-           if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
+           if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) && allocated_bogomem == 0) {
                int start = allocated_chipmem >> 16;
                if (allocated_chipmem < 0x100000) {
                    int dummy = (0x100000 - allocated_chipmem) >> 16;
@@ -3419,11 +3441,13 @@ void memory_reset (void)
 
     if (a1000_bootrom)
        a1000_handle_kickstart (1);
+
 #ifdef AUTOCONFIG
     map_banks (&expamem_bank, 0xE8, 1, 0);
 #endif
+
     if (a3000_f0)
-       a3000_fakekick (1);
+       map_banks (&extendedkickmem_bank, 0xf0, 1, 0);
 
     /* Map the chipmem into all of the lower 8MB */
     map_overlay (1);
@@ -3581,7 +3605,7 @@ void memory_cleanup (void)
     #endif
 }
 
-void memory_hardreset(void)
+void memory_hardreset (void)
 {
     if (savestate_state == STATE_RESTORE)
        return;
@@ -3593,7 +3617,7 @@ void memory_hardreset(void)
        memset (a3000lmemory, 0, allocated_a3000lmem);
     if (a3000hmemory)
        memset (a3000hmemory, 0, allocated_a3000hmem);
-    expansion_clear();
+    expansion_clear ();
 }
 
 void map_banks (addrbank *bank, int start, int size, int realsize)
@@ -3603,6 +3627,8 @@ void map_banks (addrbank *bank, int start, int size, int realsize)
     addrbank *orgbank = bank;
     uae_u32 realstart = start;
 
+    //write_log ("MAP_BANK %04X0000 %d %s\n", start, size, bank->name);
+
     flush_icache (1); /* Sure don't want to keep any old mappings around! */
 #ifdef NATMEM_OFFSET
     delete_shmmaps (start << 16, size << 16);
@@ -3612,7 +3638,7 @@ void map_banks (addrbank *bank, int start, int size, int realsize)
        realsize = size << 16;
 
     if ((size << 16) < realsize) {
-       gui_message ("Broken mapping, size=%x, realsize=%x\nStart is %x\n",
+       write_log ("Broken mapping, size=%x, realsize=%x\nStart is %x\n",
            size, realsize, start);
     }
 
@@ -3658,7 +3684,7 @@ void map_banks (addrbank *bank, int start, int size, int realsize)
 
 /* memory save/restore code */
 
-uae_u8 *save_bootrom(int *len)
+uae_u8 *save_bootrom (int *len)
 {
     if (!uae_boot_rom)
        return 0;
@@ -3814,7 +3840,7 @@ uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr)
     if (dstptr)
        dstbak = dst = dstptr;
     else
-       dstbak = dst = (uae_u8*)xmalloc (4 + 4 + 4 + 4 + 4 + 256 + 256 + mem_size);
+       dstbak = dst = xmalloc (4 + 4 + 4 + 4 + 4 + 256 + 256 + mem_size);
     save_u32 (mem_start);
     save_u32 (mem_size);
     save_u32 (mem_type);
@@ -3823,7 +3849,7 @@ uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr)
     strcpy (dst, tmpname);
     dst += strlen (dst) + 1;
     strcpy (dst, path);/* rom image name */
-    dst += strlen(dst) + 1;
+    dst += strlen (dst) + 1;
     if (saverom) {
        for (i = 0; i < mem_size; i++)
            *dst++ = byteget (mem_start + i);
@@ -3838,7 +3864,7 @@ uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr)
 
 void memcpyha_safe (uaecptr dst, const uae_u8 *src, int size)
 {
-    if (!addr_valid("memcpyha", dst, size))
+    if (!addr_valid ("memcpyha", dst, size))
        return;
     while (size--)
        put_byte (dst++, *src++);
@@ -3850,7 +3876,7 @@ void memcpyha (uaecptr dst, const uae_u8 *src, int size)
 }
 void memcpyah_safe (uae_u8 *dst, uaecptr src, int size)
 {
-    if (!addr_valid("memcpyah", src, size))
+    if (!addr_valid ("memcpyah", src, size))
        return;
     while (size--)
        *dst++ = get_byte (src++);
@@ -3860,15 +3886,20 @@ void memcpyah (uae_u8 *dst, uaecptr src, int size)
     while (size--)
        *dst++ = get_byte (src++);
 }
-char *strcpyah_safe (char *dst, uaecptr src)
+char *strcpyah_safe (char *dst, uaecptr src, int maxsize)
 {
     char *res = dst;
     uae_u8 b;
     do {
-       if (!addr_valid("strcpyah", src, 1))
+       if (!addr_valid ("strcpyah", src, 1))
            return res;
        b = get_byte (src++);
        *dst++ = b;
+       maxsize--;
+       if (maxsize <= 1) {
+           *dst++= 0;
+           break;
+       }
     } while (b);
     return res;
 }
@@ -3877,7 +3908,7 @@ uaecptr strcpyha_safe (uaecptr dst, const char *src)
     uaecptr res = dst;
     uae_u8 b;
     do {
-       if (!addr_valid("strcpyha", dst, 1))
+       if (!addr_valid ("strcpyha", dst, 1))
            return res;
        b = *src++;
        put_byte (dst++, b);
index 5a0f6101f09b2bc05f5d69dcca68a8558b42725e..dbed1ec8e0ea3256111e16d9c7cdb2b7eb9e5548 100755 (executable)
--- a/newcpu.c
+++ b/newcpu.c
@@ -1133,6 +1133,7 @@ void REGPARAM2 Exception (int nr, struct regstruct *regs, uaecptr oldpc)
 
 STATIC_INLINE void do_interrupt (int nr, struct regstruct *regs)
 {
+    int vector;
 #if 0
     if (nr == 2)
        write_log (".");
@@ -1141,7 +1142,15 @@ STATIC_INLINE void do_interrupt (int nr, struct regstruct *regs)
     regs->stopped = 0;
     unset_special (regs, SPCFLAG_STOP);
     assert (nr < 8 && nr >= 0);
-    Exception (nr + 24, regs, 0);
+
+    if (currprefs.cpu_cycle_exact)
+       vector = get_byte_ce (0x00fffff1 | (nr << 1));
+    else if (currprefs.cpu_model <= 68010)
+       vector = get_byte (0x00fffff1 | (nr << 1));
+    else
+       vector = nr + 24;
+
+    Exception (vector, regs, 0);
 
     regs->intmask = nr;
     doint ();
index b4bf6018eeca356a4636937284ba5884239dea4b..e6917f4759eb56bb31f5c5689bb1038e4fa85073 100755 (executable)
@@ -48,13 +48,13 @@ static char *sndptrmax, soundneutral, sndptr;
 static LPSTR lpData,sndptrout;
 extern uae_u32 chipmem_mask;
 unsigned int *sndbufrecpt;
-static char *ahisndbuffer,*sndrecbuffer;
-static int ahisndbufsize,*ahisndbufpt,ahitweak;;
+static char *ahisndbuffer, *sndrecbuffer;
+static int ahisndbufsize, *ahisndbufpt, ahitweak;;
 int ahi_pollrate = 40;
 
 int sound_freq_ahi, sound_channels_ahi, sound_bits_ahi;
 
-static int vin,devicenum;
+static int vin, devicenum;
 static int amigablksize;
 
 static DWORD sound_flushes2 = 0;
@@ -83,10 +83,10 @@ static struct winuae *a6;
 
 #if defined(X86_MSVC_ASSEMBLY)
 
-#define CREATE_NATIVE_FUNC_PTR2 uae_u32 (* native_func)( uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, \
+#define CREATE_NATIVE_FUNC_PTR2 uae_u32 (*native_func)(uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32,\
        uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32,uae_u32,uae_u32)
 #define SET_NATIVE_FUNC2(x) native_func = (uae_u32 (*)(uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32,uae_u32,uae_u32))(x)
-#define CALL_NATIVE_FUNC2( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6,a7) if(native_func) return native_func( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6,a7,regs_ )
+#define CALL_NATIVE_FUNC2(d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6,a7) if(native_func) return native_func(d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6,a7,regs_)
 
 static uae_u32 REGPARAM2 emulib_ExecuteNativeCode2 (TrapContext *context)
 {
@@ -110,8 +110,8 @@ static uae_u32 REGPARAM2 emulib_ExecuteNativeCode2 (TrapContext *context)
     uaevar.z3offset = (uae_u32)(get_real_address (0x10000000) - 0x10000000);
     uaevar.amigawnd = hAmigaWnd;
     a6 = &uaevar;
-    if(object_UAM)  {
-       SET_NATIVE_FUNC2(object_UAM);
+    if (object_UAM)  {
+       SET_NATIVE_FUNC2 (object_UAM);
     __asm
        {   mov espstore,esp
            push regs_
@@ -148,14 +148,14 @@ void ahi_close_sound (void)
        return;
     ahi_on = 0;
     record_enabled = 0;
-    ahisndbufpt = (int*) ahisndbuffer;
+    ahisndbufpt = (int*)ahisndbuffer;
 
     if (lpDSB2) {
        hr = IDirectSoundBuffer_Stop (lpDSB2);
-       if(FAILED(hr))
-           write_log ( "AHI: SoundStop() failure: %s\n", DXError(hr));
+       if(FAILED (hr))
+           write_log ("AHI: SoundStop() failure: %s\n", DXError (hr));
     } else {
-       write_log ( "AHI: Sound Stopped...\n" );
+       write_log ("AHI: Sound Stopped...\n");
     }
 
     if (lpDSB2)
@@ -175,7 +175,7 @@ void ahi_close_sound (void)
        IDirectSound_Release (lpDS2r);
     lpDS2r = NULL;
     if (ahisndbuffer)
-       free(ahisndbuffer);
+       free (ahisndbuffer);
     ahisndbuffer = NULL;
 }
 
@@ -187,19 +187,19 @@ void ahi_updatesound(int force)
     LPVOID dwData1, dwData2;
     static int oldpos;
 
-    if(sound_flushes2 == 1) {
+    if (sound_flushes2 == 1) {
        oldpos = 0;
        intcount = 1;
        INTREQ_f (0x8000 | 0x2000);
-       hr = IDirectSoundBuffer_Play(lpDSB2, 0, 0, DSBPLAY_LOOPING);
+       hr = IDirectSoundBuffer_Play (lpDSB2, 0, 0, DSBPLAY_LOOPING);
        if(hr == DSERR_BUFFERLOST) {
-           IDirectSoundBuffer_Restore(lpDSB2);
-           hr = IDirectSoundBuffer_Play(lpDSB2, 0, 0, DSBPLAY_LOOPING);
+           IDirectSoundBuffer_Restore (lpDSB2);
+           hr = IDirectSoundBuffer_Play (lpDSB2, 0, 0, DSBPLAY_LOOPING);
        }
     }
 
-    hr = IDirectSoundBuffer_GetCurrentPosition(lpDSB2, &pos, 0);
-    if(hr != DSERR_BUFFERLOST) {
+    hr = IDirectSoundBuffer_GetCurrentPosition (lpDSB2, &pos, 0);
+    if (hr != DSERR_BUFFERLOST) {
        pos -= ahitweak;
        if (pos < 0)
            pos += ahisndbufsize;
@@ -217,11 +217,11 @@ void ahi_updatesound(int force)
        }
     }
 
-    hr = IDirectSoundBuffer_Lock(lpDSB2, oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0);
+    hr = IDirectSoundBuffer_Lock (lpDSB2, oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0);
     if(hr == DSERR_BUFFERLOST) {
        write_log ("AHI: lostbuf %d %x\n", pos, amigablksize);
-       IDirectSoundBuffer_Restore(lpDSB2);
-       hr = IDirectSoundBuffer_Lock(lpDSB2, oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0);
+       IDirectSoundBuffer_Restore (lpDSB2);
+       hr = IDirectSoundBuffer_Lock (lpDSB2, oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0);
     }
     if(FAILED(hr))
        return;
@@ -237,14 +237,14 @@ void ahi_updatesound(int force)
        }
     }
 
-    memcpy(dwData1, ahisndbuffer, dwBytes1);
+    memcpy (dwData1, ahisndbuffer, dwBytes1);
     if (dwData2)
-       memcpy(dwData2, (uae_u8*)ahisndbuffer + dwBytes1, dwBytes2);
+       memcpy (dwData2, (uae_u8*)ahisndbuffer + dwBytes1, dwBytes2);
 
     sndptrmax = ahisndbuffer + ahisndbufsize;
     ahisndbufpt = (int*)ahisndbuffer;
 
-    IDirectSoundBuffer_Unlock(lpDSB2, dwData1, dwBytes1, dwData2, dwBytes2);
+    IDirectSoundBuffer_Unlock (lpDSB2, dwData1, dwBytes1, dwData2, dwBytes2);
 
     oldpos += amigablksize * 4;
     if (oldpos >= ahisndbufsize)
@@ -256,7 +256,7 @@ void ahi_updatesound(int force)
 }
 
 
-void ahi_finish_sound_buffer( void )
+void ahi_finish_sound_buffer (void)
 {
     sound_flushes2++;
     ahi_updatesound(2);
@@ -271,28 +271,28 @@ static int ahi_init_record_win32 (void)
     HRESULT hr;
     DSCBUFFERDESC sound_buffer_rec;
     // Record begin
-    hr = DirectSoundCaptureCreate(NULL, &lpDS2r, NULL);
-    if (FAILED(hr)) {
-       write_log ( "AHI: DirectSoundCaptureCreate() failure: %s\n", DXError(hr));
+    hr = DirectSoundCaptureCreate (NULL, &lpDS2r, NULL);
+    if (FAILED (hr)) {
+       write_log ( "AHI: DirectSoundCaptureCreate() failure: %s\n", DXError (hr));
        record_enabled = -1;
        return 0;
     }
-    memset (&sound_buffer_rec, 0, sizeof(DSCBUFFERDESC));
-    sound_buffer_rec.dwSize = sizeof(DSCBUFFERDESC);
+    memset (&sound_buffer_rec, 0, sizeof (DSCBUFFERDESC));
+    sound_buffer_rec.dwSize = sizeof (DSCBUFFERDESC);
     sound_buffer_rec.dwBufferBytes = amigablksize * 4 * RECORDBUFFER;
     sound_buffer_rec.lpwfxFormat = &wavfmt;
     sound_buffer_rec.dwFlags = 0 ;
 
-    hr = IDirectSoundCapture_CreateCaptureBuffer(lpDS2r, &sound_buffer_rec, &lpDSB2r, NULL);
-    if (FAILED(hr)) {
+    hr = IDirectSoundCapture_CreateCaptureBuffer (lpDS2r, &sound_buffer_rec, &lpDSB2r, NULL);
+    if (FAILED (hr)) {
        write_log ("AHI: CreateCaptureSoundBuffer() failure: %s\n", DXError(hr));
        record_enabled = -1;
        return 0;
     }
 
-    hr = IDirectSoundCaptureBuffer_Start(lpDSB2r, DSCBSTART_LOOPING);
-    if (FAILED(hr)) {
-       write_log ("AHI: DirectSoundCaptureBuffer_Start failed: %s\n", DXError(hr));
+    hr = IDirectSoundCaptureBuffer_Start (lpDSB2r, DSCBSTART_LOOPING);
+    if (FAILED (hr)) {
+       write_log ("AHI: DirectSoundCaptureBuffer_Start failed: %s\n", DXError (hr));
        record_enabled = -1;
        return 0;
     }
@@ -307,7 +307,7 @@ void setvolume_ahi (LONG vol)
     if (!lpDS2)
        return;
     hr = IDirectSoundBuffer_SetVolume (lpDSB2, vol);
-    if (FAILED(hr))
+    if (FAILED (hr))
        write_log ("AHI: SetVolume(%d) failed: %s\n", vol, DXError (hr));
 }
 
@@ -336,12 +336,12 @@ static int ahi_init_sound_win32 (void)
        return 0;
     soundneutral = 0;
     ahisndbufsize = (amigablksize * 4) * NATIVBUFFNUM;  // use 4 native buffer
-    ahisndbuffer = malloc(ahisndbufsize + 32);
+    ahisndbuffer = malloc (ahisndbufsize + 32);
     if (!ahisndbuffer)
        return 0;
     hr = DirectSoundCreate (&sound_device_guid[currprefs.win32_soundcard], &lpDS2, NULL);
     if (FAILED (hr)) {
-       write_log ( "AHI: DirectSoundCreate() failure: %s\n", DXError (hr));
+       write_log ("AHI: DirectSoundCreate() failure: %s\n", DXError (hr));
        return 0;
     }
     memset (&sound_buffer, 0, sizeof (DSBUFFERDESC));
@@ -351,8 +351,8 @@ static int ahi_init_sound_win32 (void)
     sound_buffer.lpwfxFormat = NULL;
 
     DSCaps.dwSize = sizeof(DSCAPS);
-    hr = IDirectSound_GetCaps(lpDS2, &DSCaps);
-    if (SUCCEEDED(hr)) {
+    hr = IDirectSound_GetCaps (lpDS2, &DSCaps);
+    if (SUCCEEDED (hr)) {
        if (DSCaps.dwFlags & DSCAPS_EMULDRIVER)
            write_log ( "AHI: Your DirectSound Driver is emulated via WaveOut - yuck!\n");
     }
@@ -365,7 +365,7 @@ static int ahi_init_sound_win32 (void)
     }
     hr = IDirectSoundBuffer_SetFormat (lpDSBprimary2, &wavfmt);
     if (FAILED (hr)) {
-       write_log ( "AHI: SetFormat() failure: %s\n", DXError (hr));
+       write_log ("AHI: SetFormat() failure: %s\n", DXError (hr));
        return 0;
     }
     sound_buffer.dwBufferBytes = ahisndbufsize;
@@ -373,7 +373,7 @@ static int ahi_init_sound_win32 (void)
     sound_buffer.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLVOLUME
        | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS | DSBCAPS_LOCSOFTWARE;
     sound_buffer.guid3DAlgorithm = GUID_NULL;
-    hr = IDirectSound_CreateSoundBuffer(lpDS2, &sound_buffer, &lpDSB2, NULL);
+    hr = IDirectSound_CreateSoundBuffer (lpDS2, &sound_buffer, &lpDSB2, NULL);
     if (FAILED (hr)) {
        write_log ("AHI: CreateSoundBuffer() failure: %s\n", DXError (hr));
        return 0;
@@ -381,15 +381,15 @@ static int ahi_init_sound_win32 (void)
 
     setvolume_ahi (0);
 
-    hr = IDirectSoundBuffer_GetFormat(lpDSBprimary2,&wavfmt,500,0);
-    if(FAILED(hr)) {
-       write_log ("AHI: GetFormat() failure: %s\n", DXError(hr));
+    hr = IDirectSoundBuffer_GetFormat (lpDSBprimary2,&wavfmt,500,0);
+    if (FAILED (hr)) {
+       write_log ("AHI: GetFormat() failure: %s\n", DXError (hr));
        return 0;
     }
 
     ahisndbufpt =(int*)ahisndbuffer;
     sndptrmax = ahisndbuffer + ahisndbufsize;
-    memset(ahisndbuffer,  soundneutral, amigablksize * 8);
+    memset (ahisndbuffer,  soundneutral, amigablksize * 8);
     ahi_on = 1;
     return sound_freq_ahi;
 }
@@ -402,7 +402,7 @@ int ahi_open_sound (void)
     if (!sound_freq_ahi)
        return 0;
     if (ahi_on)
-       ahi_close_sound();
+       ahi_close_sound ();
     sound_flushes2 = 1;
     if ((rate = ahi_init_sound_win32 ()))
        return rate;
index 6985b2256124c550948d2fa8d871e66a987972c6..df3bbe7dc749ab1c9a68a0a0ee48e08dd061cd6a 100755 (executable)
@@ -7,7 +7,7 @@
          : License version 2 as published by the Free Software Foundation.
  Authors : os, mcb
  Created : 2007-08-27 13:55:49
- Updated : 2008-05-20 10:37:00
+ Updated : 2008-05-27 10:37:00
  Comment : RP Player interprocess communication include file
  *****************************************************************************/
 
@@ -49,6 +49,7 @@
 #define RPIPCGM_ESCAPED         (WM_APP + 20)
 #define RPIPCGM_PARENT          (WM_APP + 21)
 #define RPIPCGM_DEVICESEEK      (WM_APP + 22)
+#define RPIPCGM_CLOSE           (WM_APP + 23)
 
 
 // ****************************************************************************
@@ -86,7 +87,7 @@
 #define RP_FEATURE_PAUSE         0x00000080 // pause functionality is available (see RPIPCHM_PAUSE message)
 #define RP_FEATURE_TURBO         0x00000100 // turbo mode functionality is available (see RPIPCHM_TURBO message)
 #define RP_FEATURE_VOLUME        0x00000200 // volume adjustment is possible (see RPIPCHM_VOLUME message)
-#define RP_FEATURE_STATE         0x00000400 // loading and saving of emulation state is supported (see RPIPCHM_SAVESTATE message)
+#define RP_FEATURE_STATE         0x00000400 // loading and saving of emulation state is supported (see RPIPCHM_SAVESTATE/RPIPCHM_LOADSTATE message)
 
 // Screen Modes
 #define RP_SCREENMODE_1X            0x00000000 // 1x window or full-screen mode ("CGA mode")
index afab61a1d23375665a9eb7f9f8e962ce75cdb742..773ce86e04b4af621620a5d4aed635bee481e4e7 100755 (executable)
@@ -100,14 +100,15 @@ Message:
 Description:
    the guest sends a RPIPCGM_SCREENMODE message to notify the host
    about a change in its "screen mode"
-   (1x/2x/3x/4x, full screen, clipping coordinates, etc.);
+   (1x/2x/3x/4x, full screen, clipping coordinates, etc.),
+   or to keep the host updated about the guest window handle
+   (just before destroying its window, the guest sends this message
+   with the hGuestWindow field of the RPSCREENMODE structure set to NULL);
    screen mode changes requested by the host
    (see the RPIPCHM_SCREENMODE message) must not be notified,
    unless this is an asynchronous screen mode change
    (i.e. the guest returned the INVALID_HANDLE_VALUE
    response to a RPIPCHM_SCREENMODE host request);
-   this message can also be sent when the guest has to close
-   and reopen its window for other reasons;
    at startup-time, the guest must create
    a borderless and hidden window and send its handle
    using this message; the host will then take care
@@ -209,8 +210,10 @@ Description:
    the guest sends this message to the host
    when it enters or exits pause mode;
    pause mode changes requested by the host
-   (see the RPIPCHM_PAUSE message) must not be notified;
-   note: when paused, the guest should release the mouse (if captured)
+   (see the RPIPCHM_PAUSE message) must not be notified,
+   unless the guest returned the value 2 as RPIPCHM_PAUSE response;
+   note: when paused, the guest should release the mouse (if captured);
+   during pause moude, the mouse should never be captured
 Data sent:
    WPARAM = non-zero when the guest enters pause mode
             or zero when the guest exits from pause mode
@@ -228,8 +231,8 @@ Description:
    this notification must not be sent when the event
    has been requested by the host (see the RPIPCHM_DEVICECONTENT message)
 Data sent:
-   pData = a RPDEVICECONTENT structure (see below);
-           the szImageFile field of the structure
+   pData = a RPDEVICECONTENT structure (see RetroPlatformIPC.h);
+           the szContent field of the structure
            contains an empty string when the guest
            is ejecting something from the device
 Response:
@@ -315,6 +318,22 @@ Response:
    none
 
 
+Message:
+   RPIPCGM_CLOSE
+Description:
+   when the user presses ALT+F4 in the guest window
+   the guest should intercept such an event
+   (WM_SYSCOMMAND with wParam set to SC_CLOSE),
+   send this notification message to the host
+   and not close its window (i.e. not call the DefWindowProc() of its window);
+   the host will then open its Close Options dialog
+   and will send a RPIPCHM_CLOSE command to the guest
+   if the user confirms the close request
+Data sent:
+   none
+Response:
+   none
+
 
 
 
@@ -331,7 +350,7 @@ Description:
 Data sent:
    none
 Response:
-   LRESULT = non-zero if the guest can safely terminate or 0 otherwise
+   LRESULT = 1 if the guest can safely terminate or 0 otherwise
 
 
 Message:
@@ -370,7 +389,7 @@ Data sent:
    pData = (Unicode) full path and name of the file to save
            (note: the file may exist and can be overwritten)
 Response:
-   LRESULT = non-zero if the guest saved its screen to the file
+   LRESULT = 1 if the guest successfully saved its screen to the file or 0 otherwise
 
 
 Message:
@@ -378,12 +397,16 @@ Message:
 Description:
    the RPIPCHM_PAUSE message sets the guest into pause mode
    or resumes the guest from pause mode;
-   note: when paused, the guest should release the mouse (if captured)
+   note: when paused, the guest should release the mouse (if captured);
+   during pause moude, the mouse should never be captured
 Data sent:
    WPARAM = non-zero to set the guest into pause mode
             or zero to resume the guest from pause mode
 Response:
-   LRESULT = non-zero if the guest executed the command
+   LRESULT = 0 (error), 1 (command successfully executed)
+             or 2 (the command will be asynchronously executed
+             and a RPIPCGM_PAUSE will be later sent from the guest
+             to confirm execution)
 
 
 Message:
@@ -395,12 +418,16 @@ Description:
    or a physical or keyboard-emulated joystick into an input port)
    or to unload the currently loaded content from the device
 Data sent:
-   pData = a RPDEVICECONTENT structure (see below);
-           if the szImageFile field of the structure
+   pData = a RPDEVICECONTENT structure (see RetroPlatformIPC.h);
+           if the szContent field of the structure
            contains an empty string, the guest should
-           unload the current content from the device
+           unload the current content from the device;
+           for joysticks, szContent may contain multiple identifiers
+           using the "Joystick1\ProductGUID\ProductName" format
+           (ProductName is last and may contain unescaped backslash
+           characters itself)
 Response:
-   LRESULT = non-zero if the guest executed the command
+   LRESULT = 1 if the guest successfully executed the command or 0 otherwise
 
 
 Message:
@@ -410,7 +437,7 @@ Description:
 Data sent:
    WPARAM = a RP_RESET_* value
 Response:
-   LRESULT = non-zero if the guest executed the command
+   LRESULT = 1 if the guest successfully executed the command or 0 otherwise
 
 
 Message:
@@ -424,7 +451,7 @@ Data sent:
             (1 = speedup the guest functionality
              0 = revert to normal speed emulation)
 Response:
-   LRESULT = non-zero if the guest executed the command
+   LRESULT = 1 if the guest successfully executed the command or 0 otherwise
 
 
 Message:
@@ -446,7 +473,7 @@ Description:
 Data sent:
    WPARAM = volume level (min 0, max 100)
 Response:
-   LRESULT = non-zero if the guest set the volume as requested
+   LRESULT = 1 if the guest successfully set the volume as requested or 0 otherwise
 
 
 Message:
@@ -460,7 +487,7 @@ Data sent:
    LPARAM = milliseconds value
             (amount of time the user has to hold the above key to trigger the escape functionality)
 Response:
-   LRESULT = non-zero if the guest accepted the new settings
+   LRESULT = 1 if the guest successfully accepted the new settings or 0 otherwise
 
 
 Message:
@@ -472,7 +499,7 @@ Description:
 Data sent:
    pData = (Unicode) event string (guest-specific)
 Response:
-   LRESULT = non-zero if the guest simulated the specified event
+   LRESULT = 1 if the guest successfully simulated the specified event or 0 otherwise
 
 
 Message:
@@ -483,4 +510,26 @@ Description:
 Data sent:
    WPARAM = mouse capture state being requested (RP_MOUSECAPTURE_* flags)
 Response:
-   LRESULT = non-zero if the guest executed the command
+   LRESULT = 1 if the guest successfully executed the command or 0 otherwise
+
+
+Message:
+   RPIPCHM_SAVESTATE
+Description:
+   with this message the host asks the guest to save
+   the emulation status to the the specified file
+Data sent:
+   pData = (Unicode) full path and name of the file to save
+Response:
+   LRESULT = 1 if the guest successfully saved the status file or 0 otherwise
+
+
+Message:
+   RPIPCHM_LOADSTATE
+Description:
+   with this message the host asks the guest to load
+   the emulation status from the the specified file
+Data sent:
+   pData = (Unicode) full path and name of the file to load
+Response:
+   LRESULT = 1 if the guest successfully loaded the status file or 0 otherwise
index 132f0bbaa9022cc3a302d1031b9bb6edbc9fcab8..c4b520dd03b34ccae5435f904a6603ecd1509376 100755 (executable)
@@ -1525,6 +1525,10 @@ static int keyhack (int scancode,int pressed, int num)
 
      //check ALT-F4
     if (pressed && !di_keycodes[num][DIK_F4] && scancode == DIK_F4 && di_keycodes[num][DIK_LALT] && !currprefs.win32_ctrl_F11_is_quit) {
+#ifdef RETROPLATFORM
+       if (rp_close ())
+           return -1;
+#endif
        uae_quit ();
        return -1;
     }
index 58ea8ddfca4c87be9f877d908699c68baf323572..2c8c3c0162ac3eee39d19cc3b330dcd9794ac52f 100755 (executable)
@@ -510,6 +510,7 @@ static void calc (float *xp, float *yp, float *sxp, float *syp)
 void D3D_unlocktexture (void)
 {
     float x, y, sx, sy;
+
     IDirect3DTexture9_UnlockRect (texture, 0);
     calc (&x, &y, &sx, &sy);
     BlitRect (d3ddev, texture, x, y, sx, sy, 0xffffff, 0.1f);
index 1d015d9e292e0115d8e6214c0b5d78ea28fc8239..f7631d369c63cb5b89d42f68141787dc9de2983d 100755 (executable)
@@ -148,7 +148,7 @@ static int openprinter_ps (void)
            return 0;
        }
        ptr_gsapi_run_string_begin (gsinstance, 0, &gs_exitcode);
-    } __except(ExceptionFilter(GetExceptionInformation(), GetExceptionCode())) {
+    } __except (ExceptionFilter (GetExceptionInformation (), GetExceptionCode ())) {
        write_log ("GS crashed\n");
        return 0;
     }
@@ -419,16 +419,16 @@ void openprinter( void )
        return;
     } else if (hPrt == INVALID_HANDLE_VALUE) {
        flushprtbuf ();
-       if (OpenPrinter(currprefs.prtname, &hPrt, NULL)) {
+       if (OpenPrinter (currprefs.prtname, &hPrt, NULL)) {
            // Fill in the structure with info about this "document."
            DocInfo.pDocName = "My Document";
            DocInfo.pOutputFile = NULL;
            DocInfo.pDatatype = "RAW";
            // Inform the spooler the document is beginning.
-           if(dwJob = StartDocPrinter(hPrt, 1, (LPSTR)&DocInfo)) == 0) {
+           if ((dwJob = StartDocPrinter(hPrt, 1, (LPSTR)&DocInfo)) == 0) {
                ClosePrinter(hPrt );
                hPrt = INVALID_HANDLE_VALUE;
-           } else if(StartPagePrinter(hPrt)) {
+           } else if(StartPagePrinter (hPrt)) {
                prtopen = 1;
            }
        } else {
@@ -444,7 +444,7 @@ void openprinter( void )
 
 void flushprinter (void)
 {
-    closeprinter();
+    closeprinter ();
 }
 
 void closeprinter( void        )
@@ -475,7 +475,7 @@ void closeprinter( void     )
 
 static void putprinter (char val)
 {
-    DoSomeWeirdPrintingStuff( val );
+    DoSomeWeirdPrintingStuff (val);
 }
 
 int doprinter (uae_u8 val)
@@ -859,7 +859,7 @@ void closeser (void)
     }
     if (midi_ready) {
        extern uae_u16 serper;
-       Midi_Close();
+       Midi_Close ();
        //need for camd Midi Stuff(it close midi and reopen it but serial.c think the baudrate
        //is the same and do not open midi), so setting serper to different value helps
        serper = 0x30;
@@ -1062,7 +1062,7 @@ void initparallel (void)
     if (uae_boot_rom) {
        uaecptr a = here (); //this install the ahisound
        org (rtarea_base + 0xFFC0);
-       calltrap (deftrap (ahi_demux));
+       calltrap (deftrapres (ahi_demux, 0, "ahi_winuae"));
        dw (0x4e75);// rts
        org (a);
     }
index bdaecd1f5af49208a647344c582450fee819b953..00741e819aa6849fca599f6974e32ffff480b19b 100755 (executable)
@@ -771,23 +771,38 @@ static void setconvert (void)
        case RGBFB_R5G6B5:
        if (d == 4)
            v = RGBFB_R5G6B5_32;
+       else
+           v = RGBFB_R5G6B5_16;
        break;
        case RGBFB_R5G5B5:
        if (d == 4)
            v = RGBFB_R5G5B5_32;
+       else
+           v = RGBFB_R5G5B5_16;
        break;
        case RGBFB_B5G5R5PC:
        if (d == 4)
            v = RGBFB_B5G5R5PC_32;
+       else
+           v = RGBFB_B5G5R5PC_16;
        break;
 
-
+       case RGBFB_A8R8G8B8:
+       if (d == 2)
+           v = RGBFB_A8R8G8B8_16;
+       else if (d == 4)
+           v = RGBFB_A8R8G8B8_32;
+       break;
        case RGBFB_R8G8B8:
-       if (d == 4)
+       if (d == 2)
+           v = RGBFB_R8G8B8_16;
+       else if (d == 4)
            v = RGBFB_R8G8B8_32;
        break;
        case RGBFB_B8G8R8:
-       if (d == 4)
+       if (d == 2)
+           v = RGBFB_B8G8R8_16;
+       else if (d == 4)
            v = RGBFB_B8G8R8_32;
        break;
        case RGBFB_A8B8G8R8:
@@ -802,6 +817,12 @@ static void setconvert (void)
        else if (d == 4)
            v = RGBFB_B8G8R8A8_32;
        break;
+       case RGBFB_R8G8B8A8:
+       if (d == 2)
+           v = RGBFB_R8G8B8A8_16;
+       else if (d == 4)
+           v = RGBFB_R8G8B8A8_32;
+       break;
     }
     picasso_convert = v;
     host_mode = DirectDraw_GetSurfacePixelFormat (NULL);
@@ -3487,13 +3508,14 @@ STATIC_INLINE void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width)
 
     switch (picasso_convert)
     {
+       /* Picasso96mode == Nativemode */
        case RGBFB_B8G8R8A8_32:
-       case RGBFB_B5G6R5PC_16:
        case RGBFB_R5G6B5PC_16:
        case RGBFB_CLUT_8:
            memcpy (dst2 + x * dstpix, src2 + x * srcpix, width * dstpix);
        break;
 
+       /* 24bit->32bit */
        case RGBFB_R8G8B8_32:
            while (x < endx) {
                ((uae_u32*)dst2)[x] = (src2[x * 3 + 0] << 16) | (src2[x * 3 + 1] << 8) | (src2[x * 3 + 2] << 0);
@@ -3506,6 +3528,8 @@ STATIC_INLINE void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width)
                x++;
            }
        break;
+
+       /* 32bit->32bit */
        case RGBFB_R8G8B8A8_32:
            while (x < endx) {
                ((uae_u32*)dst2)[x] = (src2[x * 4 + 0] << 16) | (src2[x * 4 + 1] << 8) | (src2[x * 4 + 2] << 0);
@@ -3520,11 +3544,12 @@ STATIC_INLINE void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width)
        break;
        case RGBFB_A8B8G8R8_32:
            while (x < endx) {
-               ((uae_u32*)dst2)[x] = ((uae_u32*)src2)[0] << 8;
+               ((uae_u32*)dst2)[x] = ((uae_u32*)src2)[x] >> 8;
                x++;
            }
        break;
 
+       /* 15/16bit->32bit */
        case RGBFB_R5G6B5PC_32:
        case RGBFB_R5G5B5PC_32:
        case RGBFB_R5G6B5_32:
@@ -3543,10 +3568,12 @@ STATIC_INLINE void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width)
            }
        break;
 
+       /* 16/15bit->16bit */
        case RGBFB_R5G5B5PC_16:
        case RGBFB_R5G6B5_16:
        case RGBFB_R5G5B5_16:
        case RGBFB_B5G5R5PC_16:
+       case RGBFB_B5G6R5PC_16:
            while (x < endx) {
                ((uae_u16*)dst2)[x] = (uae_u16)p96_rgbx16[((uae_u16*)src2)[x]];
                x++;
@@ -3559,17 +3586,51 @@ STATIC_INLINE void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width)
            }
        break;
 
+       /* 24bit->16bit */
        case RGBFB_R8G8B8_16:
+           while (x < endx) {
+               uae_u8 r, g, b;
+               r = src2[x * 3 + 0];
+               g = src2[x * 3 + 1];
+               b = src2[x * 3 + 2];
+               ((uae_u16*)dst2)[x] = p96_rgbx16[(((r >> 3) & 0x1f) << 11) | (((g >> 2) & 0x3f) << 5) | (((b >> 3) & 0x1f) << 0)];
+               x++;
+           }
        break;
        case RGBFB_B8G8R8_16:
+           while (x < endx) {
+               uae_u32 v;
+               v = ((uae_u32*)(&src2[x * 3]))[0] >> 8;
+               ((uae_u16*)dst2)[x] = p96_rgbx16[(((v >> (8 + 3)) & 0x1f) << 11) | (((v >> (0 + 2)) & 0x3f) << 5) | (((v >> (16 + 3)) & 0x1f) << 0)];
+               x++;
+           }
        break;
+
+       /* 32bit->16bit */
        case RGBFB_R8G8B8A8_16:
+           while (x < endx) {
+               uae_u32 v;
+               v = ((uae_u32*)src2)[x];
+               ((uae_u16*)dst2)[x] = p96_rgbx16[(((v >> (0 + 3)) & 0x1f) << 11) | (((v >> (8 + 2)) & 0x3f) << 5) | (((v >> (16 + 3)) & 0x1f) << 0)];
+               x++;
+           }
        break;
        case RGBFB_A8R8G8B8_16:
+           while (x < endx) {
+               uae_u32 v;
+               v = ((uae_u32*)src2)[x];
+               ((uae_u16*)dst2)[x] = p96_rgbx16[(((v >> (8 + 3)) & 0x1f) << 11) | (((v >> (16 + 2)) & 0x3f) << 5) | (((v >> (24 + 3)) & 0x1f) << 0)];
+               x++;
+           }
        break;
        case RGBFB_A8B8G8R8_16:
+           while (x < endx) {
+               uae_u32 v;
+               v = ((uae_u32*)src2)[x];
+               ((uae_u16*)dst2)[x] = p96_rgbx16[(((v >> (24 + 3)) & 0x1f) << 11) | (((v >> (16 + 2)) & 0x3f) << 5) | (((v >> (8 + 3)) & 0x1f) << 0)];
+               x++;
+           }
        break;
-
        case RGBFB_B8G8R8A8_16:
            while (x < endx) {
                uae_u32 v;
@@ -3579,6 +3640,7 @@ STATIC_INLINE void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width)
            }
        break;
 
+       /* 8bit->32bit */
        case RGBFB_CLUT_RGBFB_32:
            while (x < endx) {
                ((uae_u32*)dst2)[x] = picasso_vidinfo.clut[src2[x]];
@@ -3591,6 +3653,8 @@ STATIC_INLINE void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width)
                x++;
            }
        break;
+
+       /* 8bit->16bit */
        case RGBFB_CLUT_RGBFB_16:
            while (x < endx) {
                ((uae_u16*)dst2)[x] = picasso_vidinfo.clut[src2[x]];
index 55792ecec42b7515062f30fd6bff570b6f1f1005..8e7f135c262b9d216684a944456951d15e373329 100755 (executable)
@@ -36,7 +36,7 @@ int rp_rpescapekey = 0x01;
 int rp_rpescapeholdtime = 600;
 int rp_screenmode = 0;
 int rp_inputmode = 0;
-int log_rp = 1;
+int log_rp = 0;
 static int max_horiz_dbl = RES_HIRES;
 static int max_vert_dbl = 1;
 
@@ -46,8 +46,8 @@ static int minimized;
 static DWORD hd_mask, cd_mask, floppy_mask;
 static int mousecapture, mousemagic;
 static int rp_filter, rp_filter_default;
-
 static int recursive_device, recursive;
+static int currentpausemode;
 
 static int cando (void)
 {
@@ -74,7 +74,11 @@ static void outhex (const uae_u8 *s)
 static char *ua (const WCHAR *s)
 {
     char *d;
-    int len = WideCharToMultiByte (CP_ACP, 0, s, -1, NULL, 0, 0, FALSE);
+    int len;
+
+    if (s == NULL)
+       return NULL;
+    len = WideCharToMultiByte (CP_ACP, 0, s, -1, NULL, 0, 0, FALSE);
     if (!len)
        return my_strdup ("");
     d = xmalloc (len + 1);
@@ -99,6 +103,7 @@ static const char *getmsg (int msg)
        case RPIPCGM_REGISTER: return "RPIPCGM_REGISTER";
        case RPIPCGM_FEATURES: return "RPIPCGM_FEATURES";
        case RPIPCGM_CLOSED: return "RPIPCGM_CLOSED";
+       case RPIPCGM_CLOSE: return "RPIPCGM_CLOSE";
        case RPIPCGM_ACTIVATED: return "RPIPCGM_ACTIVATED";
        case RPIPCGM_DEACTIVATED: return "RPIPCGM_DEACTIVATED";
        case RPIPCGM_PARENT: return "RPIPCGM_PARENT";
@@ -508,8 +513,15 @@ static LRESULT CALLBACK RPHostMsgFunction2 (UINT uMessage, WPARAM wParam, LPARAM
        }
        return TRUE;
        case RPIPCHM_PAUSE:
-           pausemode (wParam ? 1 : 0);
-       return TRUE;
+           currentpausemode = pause_emulation;
+           if (wParam ? 1 : 0 != pause_emulation ? 1 : 0) {
+               pausemode (wParam ? 1 : 0);
+               if (wParam) {
+                   currentpausemode = -1;
+                   return 2;
+               }
+           }
+           return 1;
        case RPIPCHM_VOLUME:
            currprefs.sound_volume = changed_prefs.sound_volume = 100 - wParam;
            set_volume (currprefs.sound_volume, 0);
@@ -584,12 +596,16 @@ static LRESULT CALLBACK RPHostMsgFunction2 (UINT uMessage, WPARAM wParam, LPARAM
        {
            char *s = ua ((WCHAR*)pData);
            DWORD ret = FALSE;
+           if (s == NULL) {
+               savestate_initsave (NULL, 0, 0);
+               return 1;
+           }
            if (vpos == 0) {
-               save_state (s, "AF");
+               save_state (s, "AF2008");
                ret = 1;
            } else {
-               savestate_initsave (s, 1, TRUE);
-               ret = -1;
+               //savestate_initsave (s, 1, TRUE);
+               //ret = -1;
            }
            xfree (s);
            return ret;
@@ -649,6 +665,14 @@ void rp_free (void)
     RPUninitializeGuest (&guestinfo);
 }
 
+int rp_close (void)
+{
+    if (!cando ())
+       return 0;
+    RPSendMessagex (RPIPCGM_CLOSE, 0, 0, NULL, 0, &guestinfo, NULL);
+    return 1;
+}
+
 HWND rp_getparent (void)
 {
     LRESULT lr;
@@ -904,7 +928,9 @@ void rp_pause (int paused)
        return;
     if (isrecursive ())
        return;
-    RPSendMessagex (RPIPCGM_PAUSE, (WPARAM)paused, 0, NULL, 0, &guestinfo, NULL);
+    if (currentpausemode != paused)
+       RPSendMessagex (RPIPCGM_PAUSE, (WPARAM)paused, 0, NULL, 0, &guestinfo, NULL);
+    currentpausemode = paused;
 }
 
 static void rp_mouse (void)
index 0c954ad08ab8c319c5111ec8273856ed5cbbe73a..2405c81ae55e48618e79d13c6ec9cf346d2e08f4 100755 (executable)
@@ -1,6 +1,7 @@
 
 extern HRESULT rp_init (void);
 extern void rp_free (void);
+extern int rp_close (void);
 extern void rp_fixup_options (struct uae_prefs*);
 extern void rp_update_volume (struct uae_prefs*);
 extern void rp_pause (int paused);
@@ -28,6 +29,7 @@ extern int rp_rpescapekey;
 extern int rp_rpescapeholdtime;
 extern int rp_screenmode;
 extern int rp_inputmode;
+extern int log_rp;
 
 extern void rp_input_change (int num);
 extern void rp_disk_image_change (int num, const char *name);
index 9b091bf1c9df42c0ea77959d348013ccc26f275b..d76c5e82e316a1b3f12fb1b1190470dacbae2efb 100755 (executable)
@@ -787,7 +787,8 @@ static void channelswap (uae_s16 *sndbuffer, int len)
 {
     int i;
     for (i = 0; i < len; i += 2) {
-       uae_s16 t = sndbuffer[i];
+       uae_s16 t;
+       t = sndbuffer[i];
        sndbuffer[i] = sndbuffer[i + 1];
        sndbuffer[i + 1] = t;
     }
@@ -796,7 +797,8 @@ static void channelswap6 (uae_s16 *sndbuffer, int len)
 {
     int i;
     for (i = 0; i < len; i += 6) {
-       uae_s16 t = sndbuffer[i + 0];
+       uae_s16 t;
+       t = sndbuffer[i + 0];
        sndbuffer[i + 0] = sndbuffer[i + 1];
        sndbuffer[i + 1] = t;
        t = sndbuffer[i + 4];
index d46d7ce410a8d97979af853e26efa66e92c2a3c5..5c79829191076c84925e00b8a55c602df179a600 100755 (executable)
@@ -91,7 +91,7 @@ static int userdtsc = 0;
 HINSTANCE hInst = NULL;
 HMODULE hUIDLL = NULL;
 HWND (WINAPI *pHtmlHelp)(HWND, LPCSTR, UINT, LPDWORD) = NULL;
-HWND hAmigaWnd, hMainWnd, hHiddenWnd;
+HWND hAmigaWnd, hMainWnd, hHiddenWnd, hGUIWnd;
 RECT amigawin_rect;
 static int mouseposx, mouseposy;
 static UINT TaskbarRestart;
@@ -332,6 +332,9 @@ void resumepaused (void)
        setmouseactive (-1);
     pausemouseactive = 0;
     pause_emulation = FALSE;
+#ifdef RETROPLATFORM
+    rp_pause (pause_emulation);
+#endif
 }
 
 void setpaused (void)
@@ -352,6 +355,9 @@ void setpaused (void)
        pausemouseactive = mouseactive;
        setmouseactive (0);
     }
+#ifdef RETROPLATFORM
+    rp_pause (pause_emulation);
+#endif
 }
 
 static void checkpause (void)
@@ -982,7 +988,15 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
                break;
                default:
                {
-                   LRESULT lr = DefWindowProc (hWnd, message, wParam, lParam);
+                   LRESULT lr;
+                   
+#ifdef RETROPLATFORM
+                   if ((wParam & 0xfff0) == SC_CLOSE) {
+                       if (rp_close ())
+                           return 0;
+                   }
+#endif
+                   lr = DefWindowProc (hWnd, message, wParam, lParam);
                    switch (wParam & 0xfff0)
                    {
                        case SC_MINIMIZE:
@@ -990,7 +1004,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
                        case SC_RESTORE:
                        break;
                        case SC_CLOSE:
-                       PostQuitMessage (0);
+                           PostQuitMessage (0);
                        break;
                    }
                    return lr;
@@ -1041,70 +1055,8 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
     }
     break;
 
-    case WM_USER + 1: /* Systray icon */
-        switch (lParam)
-        {
-           case WM_LBUTTONDOWN:
-           SetForegroundWindow (hWnd);
-           break;
-           case WM_LBUTTONDBLCLK:
-           gui_display (-1);
-           break;
-           case WM_RBUTTONDOWN:
-           if (!gui_active)
-               systraymenu (hWnd);
-           else
-               SetForegroundWindow (hWnd);
-           break;
-        }
-       break;
-
-     case WM_COMMAND:
-       switch (wParam & 0xffff)
-       {
-           case ID_ST_CONFIGURATION:
-               gui_display (-1);
-           break;
-           case ID_ST_HELP:
-               if (pHtmlHelp)
-                   pHtmlHelp (NULL, help_file, 0, NULL);
-           break;
-           case ID_ST_QUIT:
-               uae_quit ();
-           break;
-           case ID_ST_RESET:
-               uae_reset (0);
-           break;
-           case ID_ST_EJECTALL:
-               disk_eject (0);
-               disk_eject (1);
-               disk_eject (2);
-               disk_eject (3);
-           break;
-           case ID_ST_DF0:
-               DiskSelection (isfullscreen() > 0 ? NULL : hWnd, IDC_DF0, 0, &changed_prefs, 0);
-               disk_insert (0, changed_prefs.df[0]);
-           break;
-           case ID_ST_DF1:
-               DiskSelection (isfullscreen() > 0 ? NULL : hWnd, IDC_DF1, 0, &changed_prefs, 0);
-               disk_insert (1, changed_prefs.df[0]);
-           break;
-           case ID_ST_DF2:
-               DiskSelection (isfullscreen() > 0 ? NULL : hWnd, IDC_DF2, 0, &changed_prefs, 0);
-               disk_insert (2, changed_prefs.df[0]);
-           break;
-           case ID_ST_DF3:
-               DiskSelection (isfullscreen() > 0 ? NULL : hWnd, IDC_DF3, 0, &changed_prefs, 0);
-               disk_insert (3, changed_prefs.df[0]);
-           break;
-       }
-       break;
 
      default:
-        if (TaskbarRestart != 0 && TaskbarRestartHWND == hWnd && message == TaskbarRestart) {
-            //write_log ("notif: taskbarrestart\n");
-            systray (TaskbarRestartHWND, FALSE);
-        }
     break;
     }
 
@@ -1222,8 +1174,6 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam,
 
 
     default:
-       if (TaskbarRestart != 0 && TaskbarRestartHWND == hWnd && message == TaskbarRestart)
-           return AmigaWindowProc (hWnd, message, wParam, lParam);
        break;
 
     }
@@ -1233,6 +1183,71 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam,
 
 static LRESULT CALLBACK HiddenWindowProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
+    switch (message)
+    {
+       case WM_USER + 1: /* Systray icon */
+           switch (lParam)
+           {
+               case WM_LBUTTONDOWN:
+                   SetForegroundWindow (hGUIWnd ? hGUIWnd : hMainWnd);
+               break;
+               case WM_LBUTTONDBLCLK:
+                   if (!gui_active)
+                       inputdevice_add_inputcode (AKS_ENTERGUI, 1);
+               break;
+               case WM_RBUTTONDOWN:
+                   if (!gui_active)
+                       systraymenu (hWnd);
+                   else
+                       SetForegroundWindow (hGUIWnd ? hGUIWnd : hMainWnd);
+               break;
+           }
+       break;
+       case WM_COMMAND:
+           switch (wParam & 0xffff)
+           {
+               case ID_ST_CONFIGURATION:
+                   inputdevice_add_inputcode (AKS_ENTERGUI, 1);
+               break;
+               case ID_ST_HELP:
+                   if (pHtmlHelp)
+                       pHtmlHelp (NULL, help_file, 0, NULL);
+               break;
+               case ID_ST_QUIT:
+                   uae_quit ();
+               break;
+               case ID_ST_RESET:
+                   uae_reset (0);
+               break;
+               case ID_ST_EJECTALL:
+                   disk_eject (0);
+                   disk_eject (1);
+                   disk_eject (2);
+                   disk_eject (3);
+               break;
+               case ID_ST_DF0:
+                   DiskSelection (isfullscreen() > 0 ? NULL : hWnd, IDC_DF0, 0, &changed_prefs, 0);
+                   disk_insert (0, changed_prefs.df[0]);
+               break;
+               case ID_ST_DF1:
+                   DiskSelection (isfullscreen() > 0 ? NULL : hWnd, IDC_DF1, 0, &changed_prefs, 0);
+                   disk_insert (1, changed_prefs.df[0]);
+               break;
+               case ID_ST_DF2:
+                   DiskSelection (isfullscreen() > 0 ? NULL : hWnd, IDC_DF2, 0, &changed_prefs, 0);
+                   disk_insert (2, changed_prefs.df[0]);
+               break;
+               case ID_ST_DF3:
+                   DiskSelection (isfullscreen() > 0 ? NULL : hWnd, IDC_DF3, 0, &changed_prefs, 0);
+                   disk_insert (3, changed_prefs.df[0]);
+               break;
+           }
+           break;
+    }
+    if (TaskbarRestart != 0 && TaskbarRestartHWND == hWnd && message == TaskbarRestart) {
+         //write_log ("notif: taskbarrestart\n");
+         systray (TaskbarRestartHWND, FALSE);
+    }
     return DefWindowProc (hWnd, message, wParam, lParam);
 }
 
@@ -1293,7 +1308,13 @@ void remove_brkhandler (void)
 {
 }
 
-int WIN32_RegisterClasses (void)
+static void WIN32_UnregisterClasses (void)
+{
+    systray (hHiddenWnd, TRUE);
+    DestroyWindow (hHiddenWnd);
+}
+
+static int WIN32_RegisterClasses (void)
 {
     WNDCLASS wc;
     HDC hDC;
@@ -1353,6 +1374,8 @@ int WIN32_RegisterClasses (void)
     if (!hHiddenWnd)
        return 0;
 
+    systray (hHiddenWnd, FALSE);
+
     return 1;
 }
 
@@ -2872,6 +2895,10 @@ static int process_arg(char **xargv)
            log_uaeserial = 1;
            continue;
        }
+       if (!strcmp (arg, "-rplog")) {
+           log_rp = 1;
+           continue;
+       }
        if (!strcmp (arg, "-nomultidisplay")) {
            multi_display = 0;
            continue;
@@ -3080,6 +3107,7 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
        }
     }
 
+    WIN32_UnregisterClasses ();
 #ifdef RETROPLATFORM
     rp_free ();
 #endif
@@ -3370,7 +3398,7 @@ void addnotifications (HWND hwnd, int remove)
     }
 }
 
-void systray (HWND hwnd, int remove)
+static void systray (HWND hwnd, int remove)
 {
     NOTIFYICONDATA nid;
     BOOL v;
@@ -3407,7 +3435,7 @@ void systray (HWND hwnd, int remove)
     }
 }
 
-void systraymenu (HWND hwnd)
+static void systraymenu (HWND hwnd)
 {
     POINT pt;
     HMENU menu, menu2, drvmenu;
@@ -3415,7 +3443,6 @@ void systraymenu (HWND hwnd)
     int i;
     char text[100];
 
-    winuae_inactive (hwnd, FALSE);
     WIN32GUI_LoadUIString (IDS_STMENUNOFLOPPY, text, sizeof (text));
     GetCursorPos (&pt);
     menu = LoadMenu (hUIDLL ? hUIDLL : hInst, MAKEINTRESOURCE (IDM_SYSTRAY));
@@ -3441,7 +3468,6 @@ void systraymenu (HWND hwnd)
        pt.x, pt.y, 0, hwnd, NULL);
     PostMessage (hwnd, WM_NULL, 0, 0);
     DestroyMenu (menu);
-    winuae_active (hwnd, FALSE);
 }
 
 static void LLError(const char *s)
index 748c6ff4c85a5dcef50b9caa0fc2b43cc06f4f9f..0682e396a8f077e1b7f3a987dd22238216ef667d 100755 (executable)
@@ -15,9 +15,9 @@
 #define GETBDM(x) (((x) - ((x / 10000) * 10000)) / 100)
 #define GETBDD(x) ((x) % 100)
 
-#define WINUAEBETA 20
+#define WINUAEBETA 21
 #define WINUAEPUBLICBETA 1
-#define WINUAEDATE MAKEBD(2008, 5, 24)
+#define WINUAEDATE MAKEBD(2008, 5, 28)
 #define WINUAEEXTRA ""
 #define WINUAEREV ""
 
@@ -25,7 +25,7 @@
 #define NORMAL_WINDOW_STYLE (WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU)
 
 extern HMODULE hUIDLL;
-extern HWND hAmigaWnd, hMainWnd, hHiddenWnd;
+extern HWND hAmigaWnd, hMainWnd, hHiddenWnd, hGUIWnd;
 extern RECT amigawin_rect;
 extern int in_sizemove;
 extern int manual_painting_needed;
index 014adb51710e126fe5448c0771ff617580199712..f178aabfe3f3959c889c2a43cf1c6b1fa0b104af 100755 (executable)
@@ -739,8 +739,6 @@ static void close_hwnds (void)
     }
     if (hAmigaWnd) {
        addnotifications (hAmigaWnd, TRUE);
-       //write_log ("notif: close_hwnds\n");
-       systray (NULL, TRUE);
 #ifdef OPENGL
        OGL_free ();
 #endif
@@ -1434,7 +1432,6 @@ uae_u32 OSDEP_minimize_uae (void)
 
 void close_windows (void)
 {
-    systray (NULL, TRUE);
     reset_sound();
 #if defined (GFXFILTER)
     S2X_free ();
@@ -1692,8 +1689,6 @@ static int create_windows_2 (void)
        close_hwnds();
        return 0;
     }
-    systray (NULL, TRUE);
-    systray (hAmigaWnd, FALSE);
     addnotifications (hAmigaWnd, FALSE);
     if (hMainWnd != hAmigaWnd) {
        ShowWindow (hMainWnd, SW_SHOWNORMAL);
index dfca0c5e1aae41a6f5514a5f3b8343dc1f3687ae..5b9f231cadde2587b11e0b6eb2a50bcfad0fd3fd 100755 (executable)
@@ -1025,6 +1025,7 @@ struct ConfigStruct {
     struct ConfigStruct *Parent, *Child;
     int host, hardware;
     HTREEITEM item;
+    FILETIME t;
 };
 
 static char *configreg[] = { "ConfigFile", "ConfigFileHardware", "ConfigFileHost" };
@@ -1152,8 +1153,8 @@ void gui_display (int shortcut)
     manual_painting_needed++; /* So that WM_PAINT will refresh the display */
 
     if (isfullscreen () > 0) {
-       hr = DirectDraw_FlipToGDISurface();
-       if (FAILED(hr))
+       hr = DirectDraw_FlipToGDISurface ();
+       if (FAILED (hr))
            write_log ("FlipToGDISurface failed, %s\n", DXError (hr));
     }
 
@@ -1889,7 +1890,9 @@ static void getconfigcache (char *dst, const char *path)
 
 static char *fgetsx (char *dst, FILE *f)
 {
-    char *s = fgets (dst, MAX_DPATH, f);
+    char *s;
+    dst[0] = 0;
+    s = fgets (dst, MAX_DPATH, f);
     if (!s)
        return s;
     if (strlen (dst) == 0)
@@ -1901,7 +1904,30 @@ static char *fgetsx (char *dst, FILE *f)
     return s;
 }
 
-static char configcachever[] = "0.1";
+static char configcachever[] = "WinUAE Configuration.Cache";
+
+static void setconfighosthard (struct ConfigStruct *config)
+{
+    if (!config->Directory)
+       return;
+    if (!stricmp (config->Name, CONFIG_HOST))
+       config->host = 1;
+    if (!stricmp (config->Name, CONFIG_HARDWARE))
+       config->hardware = 1;
+}
+
+static void flushconfigcache (const char *cachepath)
+{
+    FILE *zcache;
+    zcache = fopen (cachepath, "r");
+    if (zcache == NULL)
+       return;
+    fclose (zcache);
+    zcache = fopen (cachepath, "w+");
+    if (zcache)
+        fclose (zcache);
+    write_log ("'%s' flushed\n", cachepath);
+}
 
 static struct ConfigStruct *readconfigcache (const char *path)
 {
@@ -1909,9 +1935,16 @@ static struct ConfigStruct *readconfigcache (const char *path)
     char cachepath[MAX_DPATH];
     char buf[MAX_DPATH];
     char rootpath[MAX_DPATH];
-    char path2[MAX_DPATH];
+    char path2[MAX_DPATH], tmp[MAX_DPATH];
     struct ConfigStruct *cs, *first;
-    int err, i;
+    int err;
+    int filelines, dirlines, headlines, dirmode, lines;
+    char dirsep = '\\';
+    FILETIME t;
+    SYSTEMTIME st;
+    ULARGE_INTEGER t1, stt, dirtt;
+    HANDLE h;
+    WIN32_FIND_DATA ffd;
 
     err = 0;
     first = NULL;
@@ -1920,65 +1953,219 @@ static struct ConfigStruct *readconfigcache (const char *path)
     if (!zcache)
        return NULL;
     fgetsx (buf, zcache);
-    if (!feof (zcache) && !strcmp (buf, configcachever)) {
-       GetFullPathName (path, sizeof path2, path2, NULL);
-       strcpy (rootpath, path2);
+    if (feof (zcache))
+       goto end;
+    if (strcmp (buf, configcachever))
+       goto end;
+    GetFullPathName (path, sizeof path2, path2, NULL);
+    strcpy (rootpath, path2);
+    if (path2[strlen (path2) - 1] == '\\' || path2[strlen (path2) -1] == '/')
+       path2[strlen (path2) - 1] = 0;
+    h = FindFirstFile (path2, &ffd);
+    if (h == INVALID_HANDLE_VALUE)
+       goto end;
+    FindClose (h);
+    memcpy (&dirtt, &ffd.ftLastWriteTime, sizeof (ULARGE_INTEGER));
+
+    fgetsx (buf, zcache);
+    headlines = atol (buf);
+    fgetsx (buf, zcache);
+    headlines--;
+    dirlines = atol (buf);
+    fgetsx (buf, zcache);
+    headlines--;
+    filelines = atol (buf);
+    fgetsx (buf, zcache);
+    t1.QuadPart = _atoi64 (buf);
+    headlines--;
+    GetSystemTime (&st);
+    SystemTimeToFileTime (&st, &t);
+    memcpy (&stt, &t, sizeof (ULARGE_INTEGER));
+
+    if (headlines < 0 || dirlines < 3 || filelines < 3 ||
+       t1.QuadPart == 0 || t1.QuadPart > stt.QuadPart || dirtt.QuadPart > t1.QuadPart)
+        goto end;
+
+    while (headlines-- > 0)
        fgetsx (buf, zcache);
-       if (!strcmp (buf, rootpath)) {
-           fgetsx (buf, zcache);
-           if (!feof (zcache) && strlen (buf) == 0) {
-               while (fgetsx (buf, zcache)) {
-                   cs = AllocConfigStruct ();
-                   if (configstore == NULL || configstoreallocated == configstoresize) {
-                       configstoreallocated += 100;
-                       configstore = realloc (configstore, sizeof (struct ConfigStruct*) * configstoreallocated);
-                   }
-                   configstore[configstoresize++] = cs;
-                   if (!first)
-                        first = cs;
-                   if (buf[0] == '1')
-                       cs->Directory = 1;
-
-                   fgetsx (buf, zcache);
-                   if (strlen (buf) > strlen (rootpath)) {
-                       for (i = 0; i < configstoresize; i++) {
-                           GetFullPathName (configstore[i]->Fullpath, sizeof path2, path2, NULL);
-                           if (!strcmp (path2, buf) && strcmp (path2, rootpath)) {
-                               cs->Parent = configstore[i];
-                               break;
-                           }
-                       }
-                   }
+    fgetsx (buf, zcache);
+    if (buf[0] != ';')
+       goto end;
 
-                   fgetsx (cs->Name, zcache);
-                   fgetsx (cs->Path, zcache);
-                   fgetsx (cs->Fullpath, zcache);
-                   fgetsx (cs->Description, zcache);
-                   fgetsx (cs->HardwareLink, zcache);
-                   fgetsx (cs->HostLink, zcache);
-                   fgetsx (buf, zcache);
-                   cs->Type = 3;
-
-                   fgetsx (buf, zcache);
-                   if (strlen (buf) > 0)
-                       break;
+    while (fgetsx (buf, zcache)) {
+       char c;
+       char dirpath[MAX_DPATH];
+
+       dirmode = 0;
+       if (strlen (buf) > 0) {
+           c = buf[strlen (buf) - 1];
+           if (c == '/' || c == '\\') {
+               dirmode = 1;
+               dirsep = c;
+           }
+       }
+
+       strcpy (dirpath, buf);
+       if (dirmode) {
+           lines = dirlines;
+       } else {
+           char *p;
+           lines = filelines;
+           p = strrchr (dirpath, dirsep);
+           if (p)
+               *p = 0;
+           else
+               dirpath[0] = 0;
+       }
+
+       lines--;
+        cs = AllocConfigStruct ();
+        if (configstore == NULL || configstoreallocated == configstoresize) {
+           configstoreallocated += 100;
+           configstore = realloc (configstore, sizeof (struct ConfigStruct*) * configstoreallocated);
+       }
+        configstore[configstoresize++] = cs;
+       if (!first)
+           first = cs;
+
+       cs->Directory = dirmode;
+       strcpy (tmp, path);
+       strcat (tmp, dirpath);
+       strcpy (cs->Fullpath, tmp);
+       strcpy (cs->Path, dirpath);
+
+       fgetsx (tmp, zcache);
+       lines--;
+       t1.QuadPart = _atoi64 (tmp);
+       if (t1.QuadPart > stt.QuadPart)
+           goto end;
+
+       fgetsx (cs->Name, zcache);
+       lines--;
+        fgetsx (cs->Description, zcache);
+       lines--;
+
+       strcpy (tmp, cs->Path);
+       if (strlen (tmp) > 0) {
+           char *p = tmp;
+           if (tmp[strlen (tmp) - 1] == dirsep) {
+               tmp[strlen (tmp) - 1] = 0;
+               p = strrchr (tmp, dirsep);
+               if (p)
+                   p[1] = 0;
+           } else {
+               tmp[strlen (tmp) + 1] = 0;
+               tmp[strlen (tmp)] = dirsep;
+           }
+           if (p) {
+               int i;
+               for (i = 0; i < configstoresize; i++) {
+                   struct ConfigStruct *cs2 = configstore[i];
+                   if (cs2 != cs && !strcmp (cs2->Path, tmp)) {
+                       cs->Parent = cs2;
+                       if (!cs2->Child)
+                           cs2->Child = cs;
+                       cs->host = cs2->host;
+                       cs->hardware = cs2->hardware;
+                   }
                }
            }
        }
+
+       if (!dirmode) {
+           fgetsx (cs->HardwareLink, zcache);
+           lines--;
+           fgetsx (cs->HostLink, zcache);
+           lines--;
+           fgetsx (buf, zcache);
+           lines--;
+           cs->Type = atol (buf);
+       }
+
+       setconfighosthard (cs);
+
+       if (lines < 0)
+           goto end;
+       while (lines-- > 0)
+           fgetsx (tmp, zcache);
+
+       fgetsx (tmp, zcache);
+       if (tmp[0] != ';')
+           goto end;
+
     }
+
+end:
     if (!feof (zcache))
        err = 1;
     fclose (zcache);
     if (err || first == NULL) {
-       zcache = fopen (cachepath, "w+");
-       if (zcache)
-           fclose (zcache);
+       write_log ("'%s' load failed\n", cachepath);
+       flushconfigcache (cachepath);
        FreeConfigStore ();
        return NULL;
+    } else {
+       write_log ("'%s' loaded successfully\n", cachepath);
     }
     return first;
 }
 
+static void writeconfigcacheentry (FILE *zcache, const char *relpath, struct ConfigStruct *cs)
+{
+    char path2[MAX_DPATH];
+    char lf = 10;
+    char el[] = ";\n";
+    char *p;
+    ULARGE_INTEGER li;
+
+    GetFullPathName (cs->Fullpath, sizeof path2, path2, NULL);
+    if (strlen (path2) < strlen (relpath))
+       return;
+    if (memcmp (path2, relpath, strlen (relpath)))
+       return;
+    p = path2 + strlen (relpath);
+    if (!cs->Directory)
+       strcat (p, cs->Name);
+    fwrite (p, strlen (p), 1, zcache);
+    fwrite (&lf, 1, 1, zcache);
+
+    memcpy (&li, &cs->t, sizeof (ULARGE_INTEGER));
+    sprintf (path2, "%I64u", li.QuadPart);
+    fwrite (path2, strlen (path2), 1, zcache);
+    fwrite (&lf, 1, 1, zcache);
+
+    fwrite (cs->Name, strlen (cs->Name), 1, zcache);
+    fwrite (&lf, 1, 1, zcache);
+    fwrite (cs->Description, strlen (cs->Description), 1, zcache);
+    fwrite (&lf, 1, 1, zcache);
+
+    if (!cs->Directory) {
+       fwrite (cs->HardwareLink, strlen (cs->HardwareLink), 1, zcache);
+       fwrite (&lf, 1, 1, zcache);
+       fwrite (cs->HostLink, strlen (cs->HostLink), 1, zcache);
+       fwrite (&lf, 1, 1, zcache);
+       sprintf (path2, "%d", cs->Type);
+       fwrite (path2, strlen (path2), 1, zcache);
+       fwrite (&lf, 1, 1, zcache);
+    }
+
+    fwrite (el, strlen (el), 1, zcache);
+}
+
+static void writeconfigcacherec (FILE *zcache, const char *relpath, struct ConfigStruct *cs)
+{
+    int i;
+    
+    if (!cs->Directory)
+       return;
+    writeconfigcacheentry (zcache, relpath, cs);
+    for (i = 0; i < configstoresize; i++) {
+       struct ConfigStruct *cs2 = configstore[i];
+       if (cs2->Parent == cs)
+           writeconfigcacherec (zcache, relpath, cs2);
+    }
+}
+
 static void writeconfigcache (const char *path)
 {
     int i;
@@ -1986,51 +2173,42 @@ static void writeconfigcache (const char *path)
     FILE *zcache;
     char cachepath[MAX_DPATH];
     char path2[MAX_DPATH];
+    FILETIME t;
+    SYSTEMTIME st;
 
     getconfigcache (cachepath, path);
+#if CONFIGCACHE == 0
     zcache = fopen (cachepath, "r");
     if (!zcache)
        return;
     fclose (zcache);
+#endif
     zcache = fopen (cachepath, "w");
     if (!zcache)
        return;
-    GetFullPathName (path, sizeof path2, path2, NULL);
+    t.dwHighDateTime = t.dwLowDateTime = 0;
+    GetSystemTime (&st);
+    SystemTimeToFileTime (&st, &t);
     fwrite (configcachever, strlen (configcachever), 1, zcache);
     fwrite (&lf, 1, 1, zcache);
+    sprintf (path2, "3\n4\n7\n%I64u\n;\n", t);
     fwrite (path2, strlen (path2), 1, zcache);
-    fwrite (&lf, 1, 1, zcache);
-    fwrite (&lf, 1, 1, zcache);
-    for (i = configstoresize - 1; i >= 0; i--) {
+    GetFullPathName (path, sizeof path2, path2, NULL);
+    for (i = 0; i < configstoresize; i++) {
        struct ConfigStruct *cs = configstore[i];
-        sprintf (path2, "%d", cs->Directory);
-        fwrite (path2, strlen (path2), 1, zcache);
-        fwrite (&lf, 1, 1, zcache);
-        GetFullPathName (cs->Fullpath, sizeof path2, path2, NULL);
-        fwrite (path2, strlen (path2), 1, zcache);
-        fwrite (&lf, 1, 1, zcache);
-        fwrite (cs->Name, strlen (cs->Name), 1, zcache);
-        fwrite (&lf, 1, 1, zcache);
-        fwrite (cs->Fullpath, strlen (cs->Fullpath), 1, zcache);
-        fwrite (&lf, 1, 1, zcache);
-        fwrite (cs->Path, strlen (cs->Path), 1, zcache);
-        fwrite (&lf, 1, 1, zcache);
-        fwrite (cs->Description, strlen (cs->Description), 1, zcache);
-        fwrite (&lf, 1, 1, zcache);
-        fwrite (cs->HardwareLink, strlen (cs->HardwareLink), 1, zcache);
-        fwrite (&lf, 1, 1, zcache);
-        fwrite (cs->HostLink, strlen (cs->HostLink), 1, zcache);
-        fwrite (&lf, 1, 1, zcache);
-        sprintf (path2, "%d", cs->Type);
-        fwrite (path2, strlen (path2), 1, zcache);
-        fwrite (&lf, 1, 1, zcache);
-
-        fwrite (&lf, 1, 1, zcache);
+       if (cs->Directory && cs->Parent == NULL)
+           writeconfigcacherec (zcache, path2, cs);
+    }
+    for (i = 0; i < configstoresize; i++) {
+       struct ConfigStruct *cs = configstore[i];
+       if (!cs->Directory)
+           writeconfigcacheentry (zcache, path2, cs);
     }
     fclose (zcache);
+    write_log ("'%s' created\n", cachepath);
 }
 
-static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int usedirs, int *level)
+static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int usedirs, int *level, int flushcache)
 {
     DWORD num_bytes = 0;
     char path[MAX_DPATH];
@@ -2049,6 +2227,11 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
     strncat (path2, "*.*", MAX_DPATH);
 
     if (*level == 0) {
+       if (flushcache) {
+           char cachepath[MAX_DPATH];
+           getconfigcache (cachepath, path);
+           flushconfigcache (cachepath);
+       }
        first = readconfigcache (path);
        if (first)
            return first; 
@@ -2074,6 +2257,7 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
            config = AllocConfigStruct ();
            strcpy (config->Path, shortpath);
            strcpy (config->Fullpath, path);
+           memcpy (&config->t, &find_data.ftLastWriteTime, sizeof (FILETIME));
            if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && usedirs) {
                if ((*level) < 2) {
                    struct ConfigStruct *child;
@@ -2087,11 +2271,8 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
                    config->Directory = 1;
                    (*level)++;
                    config->Parent = configparent;
-                   if (!stricmp (config->Name, CONFIG_HOST))
-                       config->host = 1;
-                   if (!stricmp (config->Name, CONFIG_HARDWARE))
-                       config->hardware = 1;
-                   child = GetConfigs (config, usedirs, level);
+                   setconfighosthard (config);
+                   child = GetConfigs (config, usedirs, level, FALSE);
                    (*level)--;
                    if (child)
                        config->Child = child;
@@ -2132,12 +2313,12 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
            break;
        }
     }
-    if (*level == 0 && CONFIGCACHE)
+    if (*level == 0)
        writeconfigcache (path);
     return first;
 }
 
-static struct ConfigStruct *CreateConfigStore (struct ConfigStruct *oldconfig)
+static struct ConfigStruct *CreateConfigStore (struct ConfigStruct *oldconfig, int flushcache)
 {
     int level = 0, i;
     char path[MAX_DPATH], name[MAX_DPATH];
@@ -2147,7 +2328,7 @@ static struct ConfigStruct *CreateConfigStore (struct ConfigStruct *oldconfig)
        strcpy (path, oldconfig->Path);
        strcpy (name, oldconfig->Name);
     }
-    GetConfigs (NULL, 1, &level);
+    GetConfigs (NULL, 1, &level, flushcache);
     if (oldconfig) {
        for (i = 0; i < configstoresize; i++) {
            cs = configstore[i];
@@ -2203,7 +2384,7 @@ static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *conf
                strcpy (workprefs.description, desc);
                cfgfile_save (&workprefs, path, configtypepanel);
            }
-           break;
+       break;
 
        case CONFIG_LOAD:
            if (strlen (name) == 0) {
@@ -2219,29 +2400,30 @@ static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *conf
                } else {
                    ew (hDlg, IDC_VIEWINFO, workprefs.info[0]);
                }
-           break;
+           }
+       break;
 
-           case CONFIG_DELETE:
-               if (strlen (name) == 0) {
-                   char szMessage[MAX_DPATH];
-                   WIN32GUI_LoadUIString(IDS_MUSTSELECTCONFIGFORDELETE, szMessage, MAX_DPATH);
-                   pre_gui_message (szMessage);
-               } else {
-                   char szMessage[MAX_DPATH];
-                   char szTitle[MAX_DPATH];
-                   WIN32GUI_LoadUIString (IDS_DELETECONFIGCONFIRMATION, szMessage, MAX_DPATH);
-                   WIN32GUI_LoadUIString (IDS_DELETECONFIGTITLE, szTitle, MAX_DPATH );
-                   if (MessageBox (hDlg, szMessage, szTitle,
-                       MB_YESNO | MB_ICONWARNING | MB_APPLMODAL | MB_SETFOREGROUND) == IDYES) {
-                       cfgfile_backup (path);
-                       DeleteFile (path);
-                       write_log ("deleted config '%s'\n", path);
-                       config_filename[0] = 0;
-                   }
+       case CONFIG_DELETE:
+           if (strlen (name) == 0) {
+               char szMessage[MAX_DPATH];
+               WIN32GUI_LoadUIString (IDS_MUSTSELECTCONFIGFORDELETE, szMessage, MAX_DPATH);
+               pre_gui_message (szMessage);
+           } else {
+               char szMessage[MAX_DPATH];
+               char szTitle[MAX_DPATH];
+               WIN32GUI_LoadUIString (IDS_DELETECONFIGCONFIRMATION, szMessage, MAX_DPATH);
+               WIN32GUI_LoadUIString (IDS_DELETECONFIGTITLE, szTitle, MAX_DPATH );
+               if (MessageBox (hDlg, szMessage, szTitle,
+                   MB_YESNO | MB_ICONWARNING | MB_APPLMODAL | MB_SETFOREGROUND) == IDYES) {
+                   cfgfile_backup (path);
+                   DeleteFile (path);
+                   write_log ("deleted config '%s'\n", path);
+                   config_filename[0] = 0;
                }
-           break;
-       }
+           }
+       break;
     }
+
     setguititle (NULL);
     return full_path;
 }
@@ -2789,7 +2971,7 @@ static int LoadConfigTreeView (HWND hDlg, int idx, HTREEITEM parent)
                    if (configstore[idx2] == config->Child) {
                        config->item = par;
                        if (LoadConfigTreeView (hDlg, idx2, par) == 0) {
-                           if (!config->hardware && !config->host)
+                           if (!config->hardware && !config->host && !config->Directory)
                                TreeView_DeleteItem (GetDlgItem(hDlg, IDC_CONFIGTREE), par);
                        }
                        break;
@@ -2955,7 +3137,7 @@ static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct *con
     {
         case IDC_SAVE:
            HandleConfiguration (hDlg, CONFIG_SAVE_FULL, config, newpath);
-           config = CreateConfigStore (config);
+           config = CreateConfigStore (config, TRUE);
            config = fixloadconfig (hDlg, config);
            ConfigToRegistry (config, configtypepanel);
            InitializeConfigTreeView (hDlg);
@@ -2963,7 +3145,7 @@ static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct *con
         break;
        case IDC_QUICKSAVE:
            HandleConfiguration (hDlg, CONFIG_SAVE, config, NULL);
-           config = CreateConfigStore (config);
+           config = CreateConfigStore (config, TRUE);
            config = fixloadconfig (hDlg, config);
            ConfigToRegistry (config, configtypepanel);
            InitializeConfigTreeView (hDlg);
@@ -2993,7 +3175,7 @@ static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct *con
         break;
         case IDC_DELETE:
            HandleConfiguration (hDlg, CONFIG_DELETE, config, NULL);
-           config = CreateConfigStore (config);
+           config = CreateConfigStore (config, TRUE);
            config = fixloadconfig (hDlg, config);
            InitializeConfigTreeView (hDlg);
         break;
@@ -3050,7 +3232,7 @@ static INT_PTR CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
     case WM_INITDIALOG:
        recursive++;
        if (!configstore) {
-           CreateConfigStore (NULL);
+           CreateConfigStore (NULL, FALSE);
            config = NULL;
        }
        pages[LOADSAVE_ID] = hDlg;
@@ -11048,7 +11230,7 @@ static int GetSettings (int all_options, HWND hwnd)
     }
 
     if (all_options || !configstore)
-       CreateConfigStore (NULL);
+       CreateConfigStore (NULL, FALSE);
 
     dialogreturn = -1;
     hAccelTable = NULL;
@@ -11071,13 +11253,14 @@ static int GetSettings (int all_options, HWND hwnd)
        setguititle (dhwnd);
        ShowWindow (dhwnd, SW_SHOW);
        MapDialogRect (dhwnd, &dialog_rect);
+       hGUIWnd = dhwnd;
 
        for (;;) {
            HANDLE IPChandle;
            IPChandle = geteventhandleIPC ();
            if (IPChandle != INVALID_HANDLE_VALUE) {
                MsgWaitForMultipleObjects (1, &IPChandle, FALSE, INFINITE, QS_ALLINPUT);
-               while (checkIPC&workprefs));
+               while (checkIPC (&workprefs));
            } else {
                WaitMessage();
            }
@@ -11104,6 +11287,7 @@ static int GetSettings (int all_options, HWND hwnd)
        psresult = dialogreturn;
     }
 
+    hGUIWnd = NULL;
     if (quit_program)
        psresult = -2;
     else if (qs_request_reset && quickstart)
index 0586d796847a70ed005642f9acc0c2cd2432e7db..c85e072479843e835c75dd78792117dedd01e408 100755 (executable)
@@ -1,4 +1,31 @@
 
+Beta 21:
+
+- A3000 1.3 SuperKickstart fakeMMU bonus remapping fixed
+- A3000 mode (=A3000 SCSI enabled) forces UAE boot rom to backup
+  location (no more conflicts with 1.3 SuperKickstart bonus area)
+- notification area icon is now created only once at startup
+- added function to uae.resource that can be used to query function
+  pointers using string labels (more portable and safe)
+- 32->16bit Picasso96 color space conversion fixed
+- all missing Picasso96 color space conversion routines added
+- HAM6 with less than 6 planes emulated properly
+- 0.5M chip + 0.5M slow + ECS Agnus chip ram aliasing implemented
+  (DMA addresses 0x80000-0xfffff are aliased to 0xc00000-0xc7ffff)
+  Previous chip mapping fixes were not 100% correct, there is no "bus
+  noise" when slow ram is enabled.
+  Fixes demo "Move Any Mountain" by "Lazy Bones"
+- floppy drive sounds fixed in 4+ sound channel modes
+- fixed rare bug in configuration list, missing directory entries
+  possible if it only contained other directories (no files)
+- implemented configuration cache that caches all data needed to
+  populate Configuration-panel quickly without directory/file scanning.
+  Currently always enabled (this way I surely get enough testing..)
+  Cache is stored in file called "configuration.cache" in configuration
+  root directory. Cache file is only re-created when configuration is
+  saved, deleted or cache file is missing or corrupted.
+  Enable/disable in future, first some testing :)
+
 Beta 20:
 
 - only reset sound when changing configuration if sound mode, sound card,
@@ -14,7 +41,7 @@ Beta 20:
 - added Amiga-side uae.resource, safe method to find "uae rom" base and
   other information. Version of resource is UAEVERSION.UAEREVISION
   NOTE: in compatible modes resource may not be available.
-  Check source for more information.
+  Check sources for more information.
   
 Beta 19:
 
index b7912c7ca35ee13add9d047747322f668ff824d6..014cacb68552e23c6d57a5bee8c58650ea31a53f 100755 (executable)
@@ -584,6 +584,13 @@ void savestate_restore_finish (void)
 /* 1=compressed,2=not compressed,3=ram dump,4=audio dump */
 void savestate_initsave (const char *filename, int mode, int nodialogs)
 {
+    if (filename == NULL) {
+       savestate_fname[0] = 0;
+       savestate_docompress = 0;
+       savestate_specialdump = 0;
+       savestate_nodialogs = 0;
+       return;
+    }
     strcpy (savestate_fname, filename);
     savestate_docompress = (mode == 1) ? 1 : 0;
     savestate_specialdump = (mode == 3) ? 1 : (mode == 4) ? 2 : 0;
diff --git a/traps.c b/traps.c
index 73674e4c13c9fd610f79e789e5f152c0a31b62f5..70d0035206f4ec1fc98ccbb4aa35197b9dc42dd2 100755 (executable)
--- a/traps.c
+++ b/traps.c
@@ -66,6 +66,7 @@ struct Trap
     TrapHandler handler;       /* Handler function to be invoked for this trap. */
     int         flags;         /* Trap attributes. */
     const char *name;          /* For debugging purposes. */
+    uaecptr addr;
 };
 
 #define MAX_TRAPS 4096
@@ -79,6 +80,19 @@ static const int trace_traps = 0;
 
 static void trap_HandleExtendedTrap (TrapHandler, int has_retval);
 
+uaecptr find_trap (const char *name)
+{
+    int i;
+
+    for (i = 0; i < trap_count; i++) {
+       struct Trap *trap = &traps[i];
+       if ((trap->flags & TRAPFLAG_UAERES) && trap->name && !strcmp (trap->name, name))
+           return trap->addr;
+    }
+    return 0;
+}
+
+
 /*
  * Define an emulator trap
  *
@@ -101,6 +115,7 @@ unsigned int define_trap (TrapHandler handler_func, int flags, const char *name)
        trap->handler = handler_func;
        trap->flags   = flags;
        trap->name    = name;
+       trap->addr    = here ();
 
        return trap_num;
     }
index 26e6d2fc4473295c9840f24ac52371aec0422a9c..f884dbaf1afd89ff31c7a0c3bd3ec4751ae1375a 100755 (executable)
--- a/uaeexe.c
+++ b/uaeexe.c
@@ -30,7 +30,7 @@ void uaeexe_install (void)
 
     loop = here ();
     org (UAEEXE_ORG);
-    calltrap (deftrap (uaeexe_server));
+    calltrap (deftrapres (uaeexe_server, 0, "uaeexe_server"));
     dw (RTS);
     org (loop);
 }
index d1f3065fc2214b10ceb1ab9143de7c6fe0ae2493..b915e36eb1c753291c19426798028d2ed7e57727 100755 (executable)
--- a/uaelib.c
+++ b/uaelib.c
@@ -474,7 +474,7 @@ void emulib_install (void)
     dw ((rtarea_base >> 16) | get_word (rtarea_base + 36));
     dw (get_word (rtarea_base + 38) + 12);
 #endif
-    calltrap (define_trap (uaelib_demux, 0, ""));
+    calltrap (deftrapres (uaelib_demux, 0, "uaelib_demux"));
     dw (RTS);
     org (a);
 }
index 349995ddf60e68534383c3dc4eea09c424647b79..132698978a89634a0ec9b4405d12779f5755aa05 100755 (executable)
 #include "uaeresource.h"
 
 #if 0
-  struct uaebase
-  {
-    struct Library lib;
-    UWORD uae_version;
-    UWORD uae_revision;
-    UWORD uae_subrevision;
-    UWORD zero;
-    APTR uae_rombase;
-  };
+
+    #define UAERESNAME "uae.resource"
+
+    #define UAERES_GETFUNC (LIB_BASE - 0*LIB_VECTSIZE)
+
+    APTR GetFunc (const char *name);
+
+    struct uaebase
+    {
+       struct Library uae_lib;
+       UWORD uae_version;
+       UWORD uae_revision;
+       UWORD uae_subrevision;
+       UWORD zero;
+       APTR uae_rombase;
+    };
+
 #endif
 
 static uaecptr res_init, res_name, res_id;
 
-static uae_u32 REGPARAM2 res_close (TrapContext *context)
+static uae_u32 REGPARAM2 res_getfunc (TrapContext *context)
 {
-    uaecptr base = m68k_areg (&context->regs, 6);
-    put_word (base + 32, get_word (base + 32) - 1);
-    return 0;
-}
-static uae_u32 REGPARAM2 res_open (TrapContext *context)
-{
-    uaecptr base = m68k_areg (&context->regs, 6);
-    put_word (base + 32, get_word (base + 32) + 1);
-    return 0;
-}
-static uae_u32 REGPARAM2 res_expunge (TrapContext *context)
-{
-    return 0;
+    uaecptr funcname = m68k_areg (&context->regs, 0);
+    char tmp[256];
+    if (funcname == 0)
+       return 0;
+    strcpyah_safe (tmp, funcname, sizeof tmp);
+    return find_trap (tmp);
 }
+
 static uae_u32 REGPARAM2 res_initcode (TrapContext *context)
 {
     uaecptr base = m68k_dreg (&context->regs, 0);
@@ -76,7 +78,7 @@ uaecptr uaeres_startup (uaecptr resaddr)
 void uaeres_install (void)
 {
     uae_u32 functable, datatable;
-    uae_u32 initcode, openfunc, closefunc, expungefunc;
+    uae_u32 initcode, getfunc;
     char tmp[100];
 
     sprintf (tmp, "UAE resource %d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV);
@@ -86,22 +88,13 @@ void uaeres_install (void)
     /* initcode */
     initcode = here ();
     calltrap (deftrap (res_initcode)); dw (RTS);
-    /* Open */
-    openfunc = here ();
-    calltrap (deftrap (res_open)); dw (RTS);
-    /* Close */
-    closefunc = here ();
-    calltrap (deftrap (res_close)); dw (RTS);
-    /* Expunge */
-    expungefunc = here ();
-    calltrap (deftrap (res_expunge)); dw (RTS);
+    /* getfunc */
+    getfunc = here ();
+    calltrap (deftrap (res_getfunc)); dw (RTS);
 
     /* FuncTable */
     functable = here ();
-    dl (openfunc); /* Open */
-    dl (closefunc); /* Close */
-    dl (expungefunc); /* Expunge */
-    dl (EXPANSION_nullfunc); /* Null */
+    dl (getfunc); /* getfunc */
     dl (0xFFFFFFFF); /* end of table */
 
     /* DataTable */
diff --git a/zfile.c b/zfile.c
index e87af8e17c2214358b2e3c521b5bf77291cab66e..b66c04323f47877f6f0b329c58e676fe687d849a 100755 (executable)
--- a/zfile.c
+++ b/zfile.c
@@ -34,7 +34,7 @@ static struct zfile *zfile_create (void)
 {
     struct zfile *z;
 
-    z = (struct zfile*)malloc (sizeof *z);
+    z = xmalloc (sizeof *z);
     if (!z)
        return 0;
     memset (z, 0, sizeof *z);
@@ -282,7 +282,7 @@ const char *uae_ignoreextensions[] =
 const char *uae_diskimageextensions[] =
     { ".adf", ".adz", ".ipf", ".fdi", ".exe", ".dms", ".wrp", ".dsq", 0 };
 
-int zfile_is_ignore_ext(const char *name)
+int zfile_is_ignore_ext (const char *name)
 {
     int i;
 
@@ -480,7 +480,7 @@ static struct zfile *openzip (const char *pname)
                if (name[i - len - 1] == '.' && !strcasecmp (name + i - len, plugins_7z[j])) {
                    struct zfile *f = zfile_fopen_nozip (name, "rb");
                    if (f) {
-                       f->zipname = my_strdup(name + i + 1);
+                       f->zipname = my_strdup (name + i + 1);
                        return f;
                    }
                    break;
@@ -531,11 +531,11 @@ static struct zfile *zfile_fopen_2 (const char *name, const char *mode)
 static void manglefilename(char *out, const char *in)
 {
     out[0] = 0;
-    if (!strncasecmp(in, AF, strlen(AF)))
+    if (!strncasecmp (in, AF, strlen(AF)))
        strcpy (out, start_path_data);
     if ((in[0] == '/' || in[0] == '\\') || (strlen(in) > 3 && in[1] == ':' && in[2] == '\\'))
        out[0] = 0;
-    strcat(out, in);
+    strcat (out, in);
 }
 #else
 static void manglefilename(char *out, const char *in)
@@ -550,8 +550,8 @@ int zfile_zopen (const char *name, zfile_callback zc, void *user)
     int ztype;
     char path[MAX_DPATH];
 
-    manglefilename(path, name);
-    l = zfile_fopen_2(path, "rb");
+    manglefilename (path, name);
+    l = zfile_fopen_2 (path, "rb");
     if (!l)
        return 0;
     ztype = iszip (l);
@@ -572,7 +572,7 @@ struct zfile *zfile_fopen (const char *name, const char *mode)
     struct zfile *l, *l2;
     char path[MAX_DPATH];
 
-    manglefilename(path, name);
+    manglefilename (path, name);
     l = zfile_fopen_2 (path, mode);
     if (!l)
        return 0;
@@ -594,8 +594,8 @@ struct zfile *zfile_dup (struct zfile *zf)
     struct zfile *nzf;
     if (!zf || !zf->data)
        return NULL;
-    nzf = zfile_create();
-    nzf->data = (uae_u8*)malloc (zf->size);
+    nzf = zfile_create ();
+    nzf->data = xmalloc (zf->size);
     memcpy (nzf->data, zf->data, zf->size);
     nzf->size = zf->size;
     return nzf;
@@ -608,17 +608,17 @@ int zfile_exists (const char *name)
 
     if (strlen (name) == 0)
        return 0;
-    manglefilename(fname, name);
+    manglefilename (fname, name);
     f = openzip (fname);
     if (!f) {
        FILE *f2;
-       manglefilename(fname, name);
-       if (!my_existsfile(fname))
+       manglefilename (fname, name);
+       if (!my_existsfile (fname))
            return 0;
-       f2 = fopen(fname, "rb");
+       f2 = fopen (fname, "rb");
        if (!f2)
            return 0;
-       fclose(f2);
+       fclose (f2);
     }
     zfile_fclose (f);
     return 1;
@@ -635,11 +635,11 @@ struct zfile *zfile_fopen_empty (const char *name, int size)
     l = zfile_create ();
     l->name = name ? strdup (name) : "";
     if (size) {
-       l->data = (uae_u8*)malloc (size);
+       l->data = xmalloc (size);
        l->size = size;
        memset (l->data, 0, size);
     } else {
-       l->data = (uae_u8*)calloc (1, 1);
+       l->data = xcalloc (1, 1);
        l->size = 0;
     }
     return l;
@@ -650,7 +650,7 @@ struct zfile *zfile_fopen_data (const char *name, int size, uae_u8 *data)
     struct zfile *l;
     l = zfile_create ();
     l->name = name ? strdup (name) : "";
-    l->data = (uae_u8*)malloc (size);
+    l->data = xmalloc (size);
     l->size = size;
     memcpy (l->data, data, size);
     return l;
@@ -710,7 +710,7 @@ size_t zfile_fread  (void *b, size_t l1, size_t l2,struct zfile *z)
     return fread (b, l1, l2, z->f);
 }
 
-size_t zfile_fwrite  (void *b, size_t l1, size_t l2, struct zfile *z)
+size_t zfile_fwrite (void *b, size_t l1, size_t l2, struct zfile *z)
 {
     if (z->data) {
        if (z->seek + l1 * l2 > z->size) {
@@ -754,7 +754,7 @@ char *zfile_fgets(char *s, int size, struct zfile *z)
        *s = 0;
        return os;
     } else {
-       return fgets(s, size, z->f);
+       return fgets (s, size, z->f);
     }
 }
 
@@ -836,7 +836,7 @@ int zfile_zcompress (struct zfile *f, void *src, int size)
     uae_u8 outbuf[4096];
 
     memset (&zs, 0, sizeof (zs));
-    if (deflateInit_ (&zs, Z_DEFAULT_COMPRESSION, ZLIB_VERSION, sizeof(z_stream)) != Z_OK)
+    if (deflateInit_ (&zs, Z_DEFAULT_COMPRESSION, ZLIB_VERSION, sizeof (z_stream)) != Z_OK)
        return 0;
     zs.next_in = (Bytef*)src;
     zs.avail_in = size;
@@ -844,11 +844,11 @@ int zfile_zcompress (struct zfile *f, void *src, int size)
     while (v == Z_OK) {
        zs.next_out = outbuf;
        zs.avail_out = sizeof (outbuf);
-       v = deflate(&zs, Z_NO_FLUSH | Z_FINISH);
-       if (sizeof(outbuf) - zs.avail_out > 0)
+       v = deflate (&zs, Z_NO_FLUSH | Z_FINISH);
+       if (sizeof (outbuf) - zs.avail_out > 0)
            zfile_fwrite (outbuf, 1, sizeof (outbuf) - zs.avail_out, f);
     }
-    deflateEnd(&zs);
+    deflateEnd (&zs);
     return zs.total_out;
 }
 
@@ -870,7 +870,7 @@ uae_u32 zfile_crc32 (struct zfile *f)
     pos = zfile_ftell (f);
     zfile_fseek (f, 0, SEEK_END);
     size = zfile_ftell (f);
-    p = (uae_u8*)xmalloc (size);
+    p = xmalloc (size);
     if (!p)
        return 0;
     memset (p, 0, size);
@@ -884,14 +884,14 @@ uae_u32 zfile_crc32 (struct zfile *f)
 
 static struct zvolume *zvolume_list;
 
-static struct znode *znode_alloc(struct znode *parent, const char *name)
+static struct znode *znode_alloc (struct znode *parent, const char *name)
 {
     char fullpath[MAX_DPATH];
-    struct znode *zn = xcalloc(sizeof(struct znode), 1);
+    struct znode *zn = xcalloc (sizeof (struct znode), 1);
 
-    sprintf(fullpath,"%s%c%s", parent->fullname, FSDB_DIR_SEPARATOR, name);
-    zn->fullname = my_strdup(fullpath);
-    zn->name = my_strdup(name);
+    sprintf (fullpath,"%s%c%s", parent->fullname, FSDB_DIR_SEPARATOR, name);
+    zn->fullname = my_strdup (fullpath);
+    zn->name = my_strdup (name);
     zn->volume = parent->volume;
     zn->volume->last->next = zn;
     zn->prev = zn->volume->last;
@@ -899,9 +899,9 @@ static struct znode *znode_alloc(struct znode *parent, const char *name)
     return zn;
 }
 
-static struct znode *znode_alloc_child(struct znode *parent, const char *name)
+static struct znode *znode_alloc_child (struct znode *parent, const char *name)
 {
-    struct znode *zn = znode_alloc(parent, name);
+    struct znode *zn = znode_alloc (parent, name);
 
     if (!parent->child) {
        parent->child = zn;
@@ -914,9 +914,9 @@ static struct znode *znode_alloc_child(struct znode *parent, const char *name)
     zn->parent = parent;
     return zn;
 }
-static struct znode *znode_alloc_sibling(struct znode *sibling, const char *name)
+static struct znode *znode_alloc_sibling (struct znode *sibling, const char *name)
 {
-    struct znode *zn = znode_alloc(sibling->parent, name);
+    struct znode *zn = znode_alloc (sibling->parent, name);
 
     if (!sibling->sibling) {
        sibling->sibling = zn;
@@ -930,7 +930,7 @@ static struct znode *znode_alloc_sibling(struct znode *sibling, const char *name
     return zn;
 }
 
-static void zvolume_addtolist(struct zvolume *zv)
+static void zvolume_addtolist (struct zvolume *zv)
 {
     if (!zv)
        return;
@@ -944,9 +944,9 @@ static void zvolume_addtolist(struct zvolume *zv)
     }
 }
 
-static struct zvolume *zvolume_alloc_2(const char *name, struct zfile *z, unsigned int id, void *handle)
+static struct zvolume *zvolume_alloc_2 (const char *name, struct zfile *z, unsigned int id, void *handle)
 {
-    struct zvolume *zv = xcalloc(sizeof (struct zvolume), 1);
+    struct zvolume *zv = xcalloc (sizeof (struct zvolume), 1);
     struct znode *root;
     size_t pos;
 
@@ -957,38 +957,38 @@ static struct zvolume *zvolume_alloc_2(const char *name, struct zfile *z, unsign
     zv->id = id;
     zv->blocks = 4;
     root->volume = zv;
-    root->name = my_strdup(name);
-    root->fullname = my_strdup(name);
+    root->name = my_strdup (name);
+    root->fullname = my_strdup (name);
     if (z) {
-       pos = zfile_ftell(z);
-       zfile_fseek(z, 0, SEEK_END);
-       zv->archivesize = zfile_ftell(z);
-       zfile_fseek(z, pos, SEEK_SET);
+       pos = zfile_ftell (z);
+       zfile_fseek (z, 0, SEEK_END);
+       zv->archivesize = zfile_ftell (z);
+       zfile_fseek (z, pos, SEEK_SET);
     }
     return zv;
 }
-struct zvolume *zvolume_alloc(struct zfile *z, unsigned int id, void *handle)
+struct zvolume *zvolume_alloc (struct zfile *z, unsigned int id, void *handle)
 {
-    return zvolume_alloc_2(zfile_getname(z), z, id, handle);
+    return zvolume_alloc_2 (zfile_getname (z), z, id, handle);
 }
-struct zvolume *zvolume_alloc_empty(const char *name)
+struct zvolume *zvolume_alloc_empty (const char *name)
 {
     return zvolume_alloc_2(name, 0, 0, 0);
 }
 
-static struct zvolume *get_zvolume(const char *path)
+static struct zvolume *get_zvolume (const char *path)
 {
     struct zvolume *zv = zvolume_list;
     while (zv) {
-       char *s = zfile_getname(zv->archive);
-       if (strlen(path) >= strlen(s) && !memcmp (path, s, strlen(s)))
+       char *s = zfile_getname (zv->archive);
+       if (strlen (path) >= strlen(s) && !memcmp (path, s, strlen(s)))
            return zv;
        zv = zv->next;
     }
     return NULL;
 }
 
-static struct zvolume *zfile_fopen_archive_ext(struct zfile *zf)
+static struct zvolume *zfile_fopen_archive_ext (struct zfile *zf)
 {
     struct zvolume *zv = NULL;
     char *ext = strrchr (zfile_getname(zf), '.');
@@ -1010,7 +1010,7 @@ static struct zvolume *zfile_fopen_archive_ext(struct zfile *zf)
 }
 
 
-struct zvolume *zfile_fopen_archive_data(struct zfile *zf)
+struct zvolume *zfile_fopen_archive_data (struct zfile *zf)
 {
     struct zvolume *zv = NULL;
     uae_u8 header[7];
@@ -1029,9 +1029,9 @@ struct zvolume *zfile_fopen_archive_data(struct zfile *zf)
     return zv;
 }
 
-static struct znode *get_znode(struct zvolume *zv, const char *ppath);
+static struct znode *get_znode (struct zvolume *zv, const char *ppath);
 
-static int zfile_fopen_archive_recurse(struct zvolume *zv)
+static int zfile_fopen_archive_recurse (struct zvolume *zv)
 {
     struct znode *zn;
     int i, added;
@@ -1042,19 +1042,19 @@ static int zfile_fopen_archive_recurse(struct zvolume *zv)
        char *ext = strrchr (zn->name, '.');
        if (ext && !zn->vchild && zn->isfile) {
            for (i = 0; plugins_7z[i]; i++) {
-               if (!strcasecmp(ext + 1, plugins_7z[i])) {
+               if (!strcasecmp (ext + 1, plugins_7z[i])) {
                    struct zvolume *zvnew;
                    struct znode *zndir;
                    char tmp[MAX_DPATH];
 
-                   sprintf(tmp, "%s.DIR", zn->fullname + strlen(zv->root.name) + 1);
-                   zndir = get_znode(zv, tmp);
+                   sprintf (tmp, "%s.DIR", zn->fullname + strlen (zv->root.name) + 1);
+                   zndir = get_znode (zv, tmp);
                    if (!zndir) {
                        struct zarchive_info zai = { 0 };
                        zvnew = zvolume_alloc_empty (tmp);
                        zai.name = tmp;
                        zai.t = zn->mtime;
-                       zndir = zvolume_adddir_abs(zv, &zai);
+                       zndir = zvolume_adddir_abs (zv, &zai);
                        zndir->vfile = zn;
                        zndir->vchild = zvnew;
                        zvnew->parent = zv;
@@ -1067,40 +1067,40 @@ static int zfile_fopen_archive_recurse(struct zvolume *zv)
     return 0;
 }
 
-static void recursivepath(char *path, struct zvolume *zv)
+static void recursivepath (char *path, struct zvolume *zv)
 {
     char tmp[2] = { FSDB_DIR_SEPARATOR, 0 };
     if (!zv)
        return;
-    recursivepath(path, zv->parent);
-    strcat(path, zv->root.fullname);
-    strcat(path, tmp);
+    recursivepath (path, zv->parent);
+    strcat (path, zv->root.fullname);
+    strcat (path, tmp);
 }
 
-static struct zvolume *prepare_recursive_volume(struct zvolume *zv, const char *path)
+static struct zvolume *prepare_recursive_volume (struct zvolume *zv, const char *path)
 {
     struct zfile *zf = NULL;
     struct zvolume *zvnew = NULL;
 
     write_log ("unpacking '%s'\n", path);
-    zf = zfile_open_archive(path, 0);
+    zf = zfile_open_archive (path, 0);
     if (!zf)
        goto end;
-    zvnew = zfile_fopen_archive_ext(zf);
+    zvnew = zfile_fopen_archive_ext (zf);
     if (!zvnew)
        goto end;
     zvnew->parent = zv->parent;
-    zfile_fopen_archive_recurse(zvnew);
-    zfile_fclose_archive(zv);
+    zfile_fopen_archive_recurse (zvnew);
+    zfile_fclose_archive (zv);
     return zvnew;
 end:
     write_log ("unpack failed\n");
     zfile_fclose_archive (zvnew);
-    zfile_fclose(zf);
+    zfile_fclose (zf);
     return NULL;
 }
 
-static struct znode *get_znode(struct zvolume *zv, const char *ppath)
+static struct znode *get_znode (struct zvolume *zv, const char *ppath)
 {
     struct znode *zn;
     int prevlen = 0;
@@ -1112,11 +1112,11 @@ static struct znode *get_znode(struct zvolume *zv, const char *ppath)
     zn = &zv->root;
     while (zn) {
        if (zn->isfile) {
-           if (!stricmp(zn->fullname, path))
+           if (!stricmp (zn->fullname, path))
                return zn;
        } else {
-           int len = strlen(zn->fullname);
-           if (strlen(path) >= len && (path[len] == 0 || path[len] == FSDB_DIR_SEPARATOR) && !strnicmp(zn->fullname, path, len)) {
+           int len = strlen (zn->fullname);
+           if (strlen (path) >= len && (path[len] == 0 || path[len] == FSDB_DIR_SEPARATOR) && !strnicmp (zn->fullname, path, len)) {
                if (path[len] == 0)
                    return zn;
                if (zn->vchild) {
@@ -1124,7 +1124,7 @@ static struct znode *get_znode(struct zvolume *zv, const char *ppath)
                    struct zvolume *zvdeep = zn->vchild;
                    char *p = path + prevlen + 1;
                    if (zvdeep->archive == NULL) {
-                       zvdeep = prepare_recursive_volume(zvdeep, zn->fullname);
+                       zvdeep = prepare_recursive_volume (zvdeep, zn->fullname);
                        if (!zvdeep) {
                            write_log ("failed to unpack '%s'\n", zn->fullname);
                            return NULL;
@@ -1139,7 +1139,7 @@ static struct znode *get_znode(struct zvolume *zv, const char *ppath)
                        return NULL;
                    p++;
                    strcpy (path, zn->volume->root.name);
-                   memmove(path + strlen(path) + 1, p, strlen (p) + 1);
+                   memmove (path + strlen (path) + 1, p, strlen (p) + 1);
                    path[strlen(path)] = FSDB_DIR_SEPARATOR;
                } else {
                    zn = zn->child;
@@ -1154,7 +1154,7 @@ static struct znode *get_znode(struct zvolume *zv, const char *ppath)
 }
 
 
-static void addvolumesize(struct zvolume *zv, int size)
+static void addvolumesize (struct zvolume *zv, int size)
 {
     int blocks = (size + 511) / 512;
 
@@ -1167,25 +1167,25 @@ static void addvolumesize(struct zvolume *zv, int size)
     }
 }
 
-struct znode *znode_adddir(struct znode *parent, const char *name, struct zarchive_info *zai)
+struct znode *znode_adddir (struct znode *parent, const char *name, struct zarchive_info *zai)
 {
     struct znode *zn;
     char path[MAX_DPATH];
 
     sprintf(path, "%s%c%s", parent->fullname, FSDB_DIR_SEPARATOR, name);
-    zn = get_znode(parent->volume, path);
+    zn = get_znode (parent->volume, path);
     if (zn)
        return zn;
-    zn = znode_alloc_child(parent, name);
+    zn = znode_alloc_child (parent, name);
     zn->mtime = zai->t;
-    addvolumesize(parent->volume, 0);
+    addvolumesize (parent->volume, 0);
     return zn;
 }
 
-struct znode *zvolume_adddir_abs(struct zvolume *zv, struct zarchive_info *zai)
+struct znode *zvolume_adddir_abs (struct zvolume *zv, struct zarchive_info *zai)
 {
     struct znode *zn2;
-    char *path = my_strdup(zai->name);
+    char *path = my_strdup (zai->name);
     char *p, *p2;
     int i;
 
@@ -1201,19 +1201,19 @@ struct znode *zvolume_adddir_abs(struct zvolume *zv, struct zarchive_info *zai)
     for (i = 0; path[i]; i++) {
        if (path[i] == '/' || path[i] == '\\') {
            path[i] = 0;
-           zn2 = znode_adddir(zn2, p, zai);
+           zn2 = znode_adddir (zn2, p, zai);
            path[i] = FSDB_DIR_SEPARATOR;
            p = p2 = &path[i + 1];
        }
     }
-    return znode_adddir(zn2, p, zai);
+    return znode_adddir (zn2, p, zai);
 }
 
-struct znode *zvolume_addfile_abs(struct zvolume *zv, struct zarchive_info *zai)
+struct znode *zvolume_addfile_abs (struct zvolume *zv, struct zarchive_info *zai)
 {
     struct znode *zn, *zn2;
     int i;
-    char *path = my_strdup(zai->name);
+    char *path = my_strdup (zai->name);
     char *p, *p2;
 
     zn2 = &zv->root;
@@ -1221,35 +1221,35 @@ struct znode *zvolume_addfile_abs(struct zvolume *zv, struct zarchive_info *zai)
     for (i = 0; path[i]; i++) {
        if (path[i] == '/' || path[i] == '\\') {
            path[i] = 0;
-           zn2 = znode_adddir(zn2, p, zai);
+           zn2 = znode_adddir (zn2, p, zai);
            path[i] = FSDB_DIR_SEPARATOR;
            p = p2 = &path[i + 1];
        }
     }
     if (p2) {
-       zn = znode_alloc_child(zn2, p2);
+       zn = znode_alloc_child (zn2, p2);
        zn->size = zai->size;
        zn->isfile = 1;
        zn->mtime = zai->t;
        if (zai->comment)
-           zn->comment = my_strdup(zai->comment);
+           zn->comment = my_strdup (zai->comment);
        zn->flags = zai->flags;
-       addvolumesize(zn->volume, zai->size);
+       addvolumesize (zn->volume, zai->size);
     }
-    xfree(path);
+    xfree (path);
     return zn;
 }
 
-struct zvolume *zfile_fopen_archive(const char *filename)
+struct zvolume *zfile_fopen_archive (const char *filename)
 {
     struct zvolume *zv = NULL;
     struct zfile *zf = zfile_fopen_nozip (filename, "rb");
 
     if (!zf)
        return NULL;
-    zv = zfile_fopen_archive_ext(zf);
+    zv = zfile_fopen_archive_ext (zf);
     if (!zv)
-       zv = zfile_fopen_archive_data(zf);
+       zv = zfile_fopen_archive_data (zf);
 #if RECURSIVE_ARCHIVES
     if (zv)
        zfile_fopen_archive_recurse (zv);
@@ -1260,11 +1260,11 @@ struct zvolume *zfile_fopen_archive(const char *filename)
     if (zv)
        zvolume_addtolist (zv);
     else
-       zfile_fclose(zf);
+       zfile_fclose (zf);
     return zv;
 }
 
-void zfile_fclose_archive(struct zvolume *zv)
+void zfile_fclose_archive (struct zvolume *zv)
 {
     struct znode *zn;
     struct zvolume *v;
@@ -1275,13 +1275,13 @@ void zfile_fclose_archive(struct zvolume *zv)
     while (zn) {
        struct znode *zn2 = zn->next;
        if (zn->vchild)
-           zfile_fclose_archive(zn->vchild);
-       xfree(zn->comment);
-       xfree(zn->fullname);
-       xfree(zn->name);
-       zfile_fclose(zn->f);
+           zfile_fclose_archive (zn->vchild);
+       xfree (zn->comment);
+       xfree (zn->fullname);
+       xfree (zn->name);
+       zfile_fclose (zn->f);
        if (zn != &zv->root)
-           xfree(zn);
+           xfree (zn);
        zn = zn2;
     }
     archive_access_close (zv->handle, zv->id);
@@ -1297,18 +1297,18 @@ void zfile_fclose_archive(struct zvolume *zv)
            v = v->next;
        }
     }
-    xfree(zv);
+    xfree (zv);
 }
 
 struct zdirectory {
     struct znode *n;
 };
 
-void *zfile_opendir_archive(const char *path)
+void *zfile_opendir_archive (const char *path)
 {
-    struct zvolume *zv = get_zvolume(path);
-    struct znode *zn = get_znode(zv, path);
-    struct zdirectory *zd = xmalloc(sizeof (struct zdirectory));
+    struct zvolume *zv = get_zvolume (path);
+    struct znode *zn = get_znode (zv, path);
+    struct zdirectory *zd = xmalloc (sizeof (struct zdirectory));
 
     if (!zn || (!zn->child && !zn->vchild))
        return NULL;
@@ -1324,11 +1324,11 @@ void *zfile_opendir_archive(const char *path)
     }
     return zd;
 }
-void zfile_closedir_archive(struct zdirectory *zd)
+void zfile_closedir_archive (struct zdirectory *zd)
 {
-    xfree(zd);
+    xfree (zd);
 }
-int zfile_readdir_archive(struct zdirectory *zd, char *out)
+int zfile_readdir_archive (struct zdirectory *zd, char *out)
 {
     if (!zd->n)
        return 0;
@@ -1337,10 +1337,10 @@ int zfile_readdir_archive(struct zdirectory *zd, char *out)
     return 1;
 }
 
-int zfile_fill_file_attrs_archive(const char *path, int *isdir, int *flags, char **comment)
+int zfile_fill_file_attrs_archive (const char *path, int *isdir, int *flags, char **comment)
 {
-    struct zvolume *zv = get_zvolume(path);
-    struct znode *zn = get_znode(zv, path);
+    struct zvolume *zv = get_zvolume (path);
+    struct znode *zn = get_znode (zv, path);
 
     *isdir = 0;
     *flags = 0;
@@ -1350,13 +1350,13 @@ int zfile_fill_file_attrs_archive(const char *path, int *isdir, int *flags, char
     *isdir = zn->isfile ? 0 : 1;
     *flags = zn->flags;
     if (zn->comment)
-       *comment = my_strdup(zn->comment);
+       *comment = my_strdup (zn->comment);
     return 1;
 }
 
-int zfile_fs_usage_archive(const char *path, const char *disk, struct fs_usage *fsp)
+int zfile_fs_usage_archive (const char *path, const char *disk, struct fs_usage *fsp)
 {
-    struct zvolume *zv = get_zvolume(path);
+    struct zvolume *zv = get_zvolume (path);
 
     if (!zv)
        return -1;
@@ -1367,8 +1367,8 @@ int zfile_fs_usage_archive(const char *path, const char *disk, struct fs_usage *
 
 int zfile_stat_archive (const char *path, struct stat *s)
 {
-    struct zvolume *zv = get_zvolume(path);
-    struct znode *zn = get_znode(zv, path);
+    struct zvolume *zv = get_zvolume (path);
+    struct znode *zn = get_znode (zv, path);
 
     if (!zn)
        return 0;
@@ -1397,21 +1397,21 @@ void zfile_close_archive (void *d)
 
 void *zfile_open_archive (const char *path, int flags)
 {
-    struct zvolume *zv = get_zvolume(path);
-    struct znode *zn = get_znode(zv, path);
+    struct zvolume *zv = get_zvolume (path);
+    struct znode *zn = get_znode (zv, path);
     struct zfile *z;
 
     if (!zn)
        return 0;
     if (zn->f) {
-       zfile_fseek(zn->f, 0, SEEK_SET);
+       zfile_fseek (zn->f, 0, SEEK_SET);
        return zn->f;
     }
     if (zn->vfile)
        zn = zn->vfile;
     z = archive_getzfile (zn, zn->volume->id);
     if (z)
-       zfile_fseek(z, 0, SEEK_SET);
+       zfile_fseek (z, 0, SEEK_SET);
     zn->f = z;
     return zn->f;
 }
@@ -1422,9 +1422,9 @@ int zfile_exists_archive (const char *path, const char *rel)
     struct zvolume *zv;
     struct znode *zn;
 
-    sprintf(tmp, "%s%c%s", path, FSDB_DIR_SEPARATOR, rel);
-    zv = get_zvolume(tmp);
-    zn = get_znode(zv, tmp);
+    sprintf (tmp, "%s%c%s", path, FSDB_DIR_SEPARATOR, rel);
+    zv = get_zvolume (tmp);
+    zn = get_znode (zv, tmp);
     return zn ? 1 : 0;
 }