]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc1430b10.zip
authorToni Wilen <twilen@winuae.net>
Thu, 19 Jul 2007 16:04:09 +0000 (19:04 +0300)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:34:50 +0000 (21:34 +0200)
35 files changed:
akiko.c
ar.c
archivers/lha/header.c
blkdev.c
cfgfile.c
compemu_raw_x86.c
compemu_support.c
custom.c
disk.c
drawing.c
filesys.c
gencomp.c
gencpu.c
hardfile.c
include/autoconf.h
include/blkdev.h
include/compemu.h
include/custom.h
include/flags_x86.h [new file with mode: 0755]
include/memory.h
include/newcpu.h
include/savestate.h
include/zarchive.h
inputdevice.c
main.c
memory.c
newcpu.c
od-win32/win32.c
od-win32/win32.h
od-win32/win32gui.c
od-win32/winuae_msvc/winuae_msvc.8.vcproj
od-win32/winuaechangelog.txt
savestate.c
zfile.c
zfile_archive.c

diff --git a/akiko.c b/akiko.c
index 3de30afd93262151811890b2683708a1e5dfb4f2..ed796537a07a7a62ed259acf549dd088ed837cbd 100755 (executable)
--- a/akiko.c
+++ b/akiko.c
 #include "crc32.h"
 #include "uae.h"
 #include "custom.h"
+#include "newcpu.h"
 
 #define AKIKO_DEBUG_NVRAM 0
 #define AKIKO_DEBUG_IO 0
 #define AKIKO_DEBUG_IO_CMD 0
 
-
 static void irq(void)
 {
     if (!(intreq & 8)) {
@@ -39,8 +39,6 @@ static void irq(void)
     }
 }
 
-static int m68k_getpc(void) { return 0;        }
-
 /*
  * CD32 1Kb NVRAM (EEPROM) emulation
  *
@@ -144,7 +142,7 @@ static void i2c_do (void)
            if (scl_out && !oscl) {
                if (bitcounter == 8) {
 #if AKIKO_DEBUG_NVRAM
-                   write_log ("RB %02.2X ", nvram_byte, m68k_getpc());
+                   write_log ("RB %02.2X ", nvram_byte, M68K_GETPC);
 #endif
                    sda_in = 0; /* ACK */
                    if (direction > 0) {
@@ -173,7 +171,7 @@ static void i2c_do (void)
                bitcounter++;
                if (bitcounter == 8) {
 #if AKIKO_DEBUG_NVRAM
-                   write_log ("NVRAM sent byte %02.2X address %04.4X PC=%08.8X\n", cd32_nvram[nvram_address], nvram_address, m68k_getpc());
+                   write_log ("NVRAM sent byte %02.2X address %04.4X PC=%08.8X\n", cd32_nvram[nvram_address], nvram_address, M68K_GETPC);
 #endif
                    nvram_address++;
                    nvram_address &= NVRAM_SIZE - 1;
@@ -207,14 +205,14 @@ static void i2c_do (void)
        }
        bitcounter = 0;
 #if AKIKO_DEBUG_NVRAM
-       write_log ("I2C_DEVICEADDR: rw %d, address %02.2Xxx PC=%08.8X\n", nvram_rw, nvram_address >> 8, m68k_getpc());
+       write_log ("I2C_DEVICEADDR: rw %d, address %02.2Xxx PC=%08.8X\n", nvram_rw, nvram_address >> 8, M68K_GETPC);
 #endif
        break;
        case I2C_WORDADDR:
        nvram_address &= 0x300;
        nvram_address |= nvram_byte;
 #if AKIKO_DEBUG_NVRAM
-       write_log ("I2C_WORDADDR: address %04.4X PC=%08.8X\n", nvram_address, m68k_getpc());
+       write_log ("I2C_WORDADDR: address %04.4X PC=%08.8X\n", nvram_address, M68K_GETPC);
 #endif
        if (direction < 0) {
            memcpy (nvram_writetmp, cd32_nvram + (nvram_address & ~(NVRAM_PAGE_SIZE - 1)), NVRAM_PAGE_SIZE);
@@ -1205,7 +1203,7 @@ static uae_u32 akiko_bget2 (uaecptr addr, int msg)
     akiko_internal ();
     uae_sem_post (&akiko_sem);
     if (msg && addr < 0x30 && AKIKO_DEBUG_IO)
-       write_log ("akiko_bget %08.8X: %08.8X %02.2X\n", m68k_getpc(), addr, v & 0xff);
+       write_log ("akiko_bget %08.8X: %08.8X %02.2X\n", M68K_GETPC, addr, v & 0xff);
     return v;
 }
 
@@ -1227,7 +1225,7 @@ static uae_u32 REGPARAM2 akiko_wget (uaecptr addr)
     v = akiko_bget2 (addr + 1, 0);
     v |= akiko_bget2 (addr + 0, 0) << 8;
     if (addr < 0x30 && AKIKO_DEBUG_IO)
-       write_log ("akiko_wget %08.8X: %08.8X %04.4X\n", m68k_getpc(), addr, v & 0xffff);
+       write_log ("akiko_wget %08.8X: %08.8X %04.4X\n", M68K_GETPC, addr, v & 0xffff);
     return v;
 }
 
@@ -1244,10 +1242,24 @@ static uae_u32 REGPARAM2 akiko_lget (uaecptr addr)
     v |= akiko_bget2 (addr + 1, 0) << 16;
     v |= akiko_bget2 (addr + 0, 0) << 24;
     if (addr < 0x30 && (addr != 4 && addr != 8) && AKIKO_DEBUG_IO)
-       write_log ("akiko_lget %08.8X: %08.8X %08.8X\n", m68k_getpc(), addr, v);
+       write_log ("akiko_lget %08.8X: %08.8X %08.8X\n", M68K_GETPC, addr, v);
     return v;
 }
 
+static void write_readmask(uae_u16 v)
+{
+    int i, cnt;
+
+    cnt = 0;
+    for (i = 0; i < 16; i++) {
+       if (v & (1 << i))
+           cnt++;
+    }
+    cdrom_readmask_w |= v;
+    cdrom_readmask_r = 0;
+}
+
+
 static void akiko_bput2 (uaecptr addr, uae_u32 v, int msg)
 {
     uae_u32 tmp;
@@ -1255,7 +1267,7 @@ static void akiko_bput2 (uaecptr addr, uae_u32 v, int msg)
     addr &= 0xffff;
     v &= 0xff;
     if(msg && addr < 0x30 && AKIKO_DEBUG_IO)
-       write_log ("akiko_bput %08.8X: %08.8X=%02.2X\n", m68k_getpc(), addr, v & 0xff);
+       write_log ("akiko_bput %08.8X: %08.8X=%02.2X\n", M68K_GETPC, addr, v & 0xff);
     uae_sem_wait (&akiko_sem);
     switch (addr)
     {
@@ -1302,12 +1314,10 @@ static void akiko_bput2 (uaecptr addr, uae_u32 v, int msg)
            cdrom_result_last_pos = v;
            break;
            case 0x20:
-           cdrom_readmask_w |= (v << 8);
-           cdrom_readmask_r &= 0x00ff;
+           write_readmask(v <<8);
            break;
            case 0x21:
-           cdrom_readmask_w |= (v << 0);
-           cdrom_readmask_r &= 0xff00;
+           write_readmask(v);
            break;
            case 0x24:
            case 0x25:
@@ -1361,7 +1371,7 @@ static void REGPARAM2 akiko_wput (uaecptr addr, uae_u32 v)
 #endif
     addr &= 0xfff;
     if((addr < 0x30 && AKIKO_DEBUG_IO))
-       write_log("akiko_wput %08.8X: %08.8X=%04.4X\n", m68k_getpc(), addr, v & 0xffff);
+       write_log("akiko_wput %08.8X: %08.8X=%04.4X\n", M68K_GETPC, addr, v & 0xffff);
     akiko_bput2 (addr + 1, v & 0xff, 0);
     akiko_bput2 (addr + 0, v >> 8, 0);
 }
@@ -1373,7 +1383,7 @@ static void REGPARAM2 akiko_lput (uaecptr addr, uae_u32 v)
 #endif
     addr &= 0xffff;
     if(addr < 0x30 && AKIKO_DEBUG_IO)
-       write_log("akiko_lput %08.8X: %08.8X=%08.8X\n", m68k_getpc(), addr, v);
+       write_log("akiko_lput %08.8X: %08.8X=%08.8X\n", M68K_GETPC, addr, v);
     akiko_bput2 (addr + 3, (v >> 0) & 0xff, 0);
     akiko_bput2 (addr + 2, (v >> 8) & 0xff, 0);
     akiko_bput2 (addr + 1, (v >> 16) & 0xff, 0);
diff --git a/ar.c b/ar.c
index e8f7ff9a0c471304678bf2b6206a1700eafb16d4..eb37f674ff62dc05dd3d8cdc65b3fe903f5afb60 100755 (executable)
--- a/ar.c
+++ b/ar.c
@@ -912,7 +912,7 @@ static void action_replay_go (void)
     set_special (&regs, SPCFLAG_ACTION_REPLAY);
     copyfromamiga (artemp, regs.vbr + 0x7c, 4);
     copytoamiga (regs.vbr+0x7c, armemory_rom + 0x7c, 4);
-    Interrupt (7);
+    NMI ();
 }
 
 static void action_replay_go1 (int irq)
@@ -921,7 +921,7 @@ static void action_replay_go1 (int irq)
     hide_cart (0);
     action_replay_flag = ACTION_REPLAY_ACTIVE;
     memcpy (armemory_ram + 0xf000, ar_custom, 2 * 256);
-    Interrupt (7);
+    NMI ();
 }
 
 typedef struct {
@@ -985,13 +985,13 @@ static void hrtmon_go (void)
        if (v) {
            old = get_long((uaecptr)(regs.vbr + 0x7c));
            put_long ((uaecptr)(regs.vbr + 0x7c), v);
-           Interrupt (7);
+           NMI ();
            put_long ((uaecptr)(regs.vbr + 0x7c), old);
        }
     } else {
         old = get_long((uaecptr)(regs.vbr + 0x7c));
        put_long ((uaecptr)(regs.vbr + 0x7c), hrtmem_start + 12 + 2 + get_word (hrtmem_start + 14));
-       Interrupt (7);
+       NMI ();
        //put_long ((uaecptr)(regs.vbr + 0x7c), old);
     }
 }
index 420a47a23aff378e2f1113c4a7fae17769a1454e..2e908319cd9fca175881c1b0e7b6f13235584842 100755 (executable)
@@ -348,8 +348,8 @@ generic_to_unix_stamp(t)
        if (t == 0)
                return (time_t) 0;
 
-       year = ((int) (t >> 16 + 9) & 0x7f) + 1980;
-       month = (int) (t >> 16 + 5) & 0x0f;     /* 1..12 means Jan..Dec */
+       year = ((int) ((t >> 16) + 9) & 0x7f) + 1980;
+       month = (int) ((t >> 16) + 5) & 0x0f;   /* 1..12 means Jan..Dec */
        day = (int) (t >> 16) & 0x1f;   /* 1..31 means 1st,...31st */
 
        hour = ((int) t >> 11) & 0x1f;
index 7385730f267a3a908a124400d9c24a2ba706b8b3..1a86c5546fce02cd3af94200f3b6af8b6072e4c8 100755 (executable)
--- a/blkdev.c
+++ b/blkdev.c
@@ -18,6 +18,8 @@ static int have_ioctl;
 
 #ifdef _WIN32
 
+static int initialized;
+
 #include "od-win32/win32.h"
 
 extern struct device_functions devicefunc_win32_aspi;
@@ -62,9 +64,14 @@ void sys_command_close (int mode, int unitnum)
        device_func[DF_IOCTL]->closedev (unitnum);
 }
 
+void device_func_reset (void)
+{
+    initialized = 0;
+    have_ioctl = 0;
+}
+
 int device_func_init (int flags)
 {
-    static int initialized;
     int support_scsi = 0, support_ioctl = 0;
     int oflags = (flags & DEVICE_TYPE_SCSI) ? 0 : (1 << INQ_ROMD);
 
index 9e1dabf1e7db2c8b7c92ed687fee9201800fb0c3..ea0ce6345950ba0aa6dad87b01424d9834fe03be 100755 (executable)
--- a/cfgfile.c
+++ b/cfgfile.c
@@ -160,6 +160,7 @@ static const char *obsolete[] = {
     "sound_pri_cutoff", "sound_pri_time", "sound_min_buff",
     "gfx_test_speed", "gfxlib_replacement", "enforcer", "catweasel_io",
     "kickstart_key_file", "fast_copper", "sound_adjust",
+    "serial_hardware_dtrdsr",
     0
 };
 
@@ -2558,6 +2559,45 @@ uae_u32 cfgfile_uaelib (int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen)
     return 0;
 }
 
+uae_u8 *restore_configuration (uae_u8 *src)
+{
+    write_log(src);
+    src += strlen(src) + 1;
+    return src;
+}
+
+uae_u8 *save_configuration(int *len)
+{
+    int tmpsize = 30000;
+    uae_u8 *dstbak, *dst;
+    char *p;
+    int index = -1;
+
+    dstbak = dst = (uae_u8*)malloc (tmpsize);
+    p = dst;
+    for (;;) {
+       char tmpout[256];
+        int ret;
+        tmpout[0] = 0;
+        ret = cfgfile_modify (index, "*", 1, tmpout, sizeof (tmpout));
+       index++;
+       if (strlen(tmpout) > 0) {
+           if (!memcmp(tmpout, "input.", 6))
+               continue;
+           strcpy (p, tmpout);
+           strcat (p, "\n");
+           p += strlen(p);
+           if (p - dstbak >= tmpsize - sizeof(tmpout))
+               break;
+       }
+       if (ret >= 0)
+           break;
+    }
+    *len = p - dstbak + 1;
+    return dstbak;
+}
+
+
 static int configure_rom (struct uae_prefs *p, int *rom, int msg)
 {
     struct romdata *rd;
index f82d09e9d91e981453183b1f6914629cfae1b157..4a8ecba569efb98f3de9964f53c29296327b72f5 100755 (executable)
@@ -512,6 +512,36 @@ LOWFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc))
 }
 LENDFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc))
 
+LOWFUNC(READ,NONE,3,raw_cmov_b_rr,(RW1 d, R1 s, IMM cc))
+{
+       /* replacement using branch and mov */
+       int uncc=(cc^1);
+       emit_byte(0x70+uncc); 
+       emit_byte(3);  /* skip next 2 bytes if not cc=true */
+    emit_byte(0x88);
+    emit_byte(0xc0+8*s+d);
+}
+LENDFUNC(READ,NONE,3,raw_cmov_b_rr,(RW1 d, R1 s, IMM cc))
+
+LOWFUNC(READ,NONE,3,raw_cmov_w_rr,(RW2 d, R2 s, IMM cc))
+{
+    if (have_cmov) {
+       emit_byte(0x66);
+       emit_byte(0x0f);
+       emit_byte(0x40+cc);
+       emit_byte(0xc0+8*d+s);
+    }
+    else { /* replacement using branch and mov */
+       int uncc=(cc^1);
+       emit_byte(0x70+uncc); 
+       emit_byte(3);  /* skip next 3 bytes if not cc=true */
+       emit_byte(0x66);
+       emit_byte(0x89);
+       emit_byte(0xc0+8*s+d);
+    }
+}
+LENDFUNC(READ,NONE,3,raw_cmov_w_rr,(RW2 d, R2 s, IMM cc))
+
 LOWFUNC(READ,NONE,3,raw_cmov_l_rr,(RW4 d, R4 s, IMM cc))
 {
     if (have_cmov) {
index 36a3a60e081e20eff5338edcbd2b23ee40a19f39..cdba4b2dd63baa8eb4198d88859fd3ba88bca5f3 100755 (executable)
@@ -457,6 +457,8 @@ int check_prefs_changed_comp (void)
        alloc_cache();
        changed = 1;
     }
+    if (!candirect)
+       canbang = 0;
 
     // Turn off illegal-mem logging when using JIT...
     if(currprefs.cachesize)
@@ -469,7 +471,7 @@ int check_prefs_changed_comp (void)
        currprefs.comptrustbyte != 1)
     {
        // Set all of these to indirect when canbang == 0
-       // Basically, set the  compforcesettings option...
+       // Basically, set the compforcesettings option...
        currprefs.comptrustbyte = 1;
        currprefs.comptrustword = 1;
        currprefs.comptrustlong = 1;
@@ -2416,6 +2418,32 @@ MIDFUNC(2,setcc_m,(IMM d, IMM cc))
 }
 MENDFUNC(2,setcc_m,(IMM d, IMM cc))
 
+MIDFUNC(3,cmov_b_rr,(RW1 d, R1 s, IMM cc))
+{
+    if (d==s)
+       return;
+    CLOBBER_CMOV;
+    s=readreg(s,1);
+    d=rmw(d,1,1);
+    raw_cmov_b_rr(d,s,cc);
+    unlock(s);
+    unlock(d);
+}
+MENDFUNC(3,cmov_b_rr,(RW1 d, R1 s, IMM cc))
+
+MIDFUNC(3,cmov_w_rr,(RW2 d, R2 s, IMM cc))
+{
+    if (d==s)
+       return;
+    CLOBBER_CMOV;
+    s=readreg(s,2);
+    d=rmw(d,2,2);
+    raw_cmov_w_rr(d,s,cc);
+    unlock(s);
+    unlock(d);
+}
+MENDFUNC(3,cmov_w_rr,(RW2 d, R2 s, IMM cc))
+
 MIDFUNC(3,cmov_l_rr,(RW4 d, R4 s, IMM cc))
 {
     if (d==s)
index f6819ea30b15053a8f7bd38bc51b61c124e0b0a4..80880caf2cbd2a6a6e68634e54a8bf5df2c55640 100755 (executable)
--- a/custom.c
+++ b/custom.c
@@ -2789,7 +2789,7 @@ static void BPLCON0 (int hpos, uae_u16 v)
        hpos_previous = hpos;
     }
 
-    if ((v & 4) && !interlace_seen)
+    if (((v & 4) && !interlace_seen) || (!(v & 4) && interlace_seen))
        interlace_started = 2;
 
     ddf_change = vpos;
@@ -4584,13 +4584,14 @@ void init_eventtab (void)
     events_schedule ();
 }
 
-void customreset (void)
+void customreset (int hardreset)
 {
     int i;
     int zero = 0;
 
     write_log ("Reset at %08.8X\n", m68k_getpc(&regs));
     memory_map_dump();
+
     hsync_counter = 0;
     vsync_counter = 0;
     ciavsync_counter = 0;
@@ -4635,6 +4636,7 @@ void customreset (void)
        CLXCON (0);
     }
 
+    gayle_reset (hardreset);
 #ifdef AUTOCONFIG
     expamem_reset ();
 #endif
@@ -4648,6 +4650,9 @@ void customreset (void)
 #ifdef NCR
     ncr_reset ();
 #endif
+#ifdef FILESYS
+    filesys_free_handles();
+#endif
 #ifdef JIT
     compemu_reset ();
 #endif
@@ -4752,6 +4757,9 @@ void customreset (void)
     #if defined(ENFORCER)
     enforcer_disable();
     #endif
+
+    if (hardreset)
+       rtc_hardreset();
 }
 
 void dumpcustom (void)
diff --git a/disk.c b/disk.c
index f9789f4754a2c504df617d151457e7649bf43747..7fd4c0c31ba391bcd327d4ce36cf3b612dcec4c5 100755 (executable)
--- a/disk.c
+++ b/disk.c
@@ -553,19 +553,24 @@ static void drive_image_free (drive *drv)
 
 static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char *fname);
 
+static void reset_drive_gui(int i)
+{
+    gui_data.drive_disabled[i] = 0;
+    gui_data.df[i][0] = 0;
+    gui_data.crc32[i] = 0;
+    if (currprefs.dfxtype[i] < 0)
+       gui_data.drive_disabled[i] = 1;
+}
+
 static void reset_drive(int i)
 {
     drive *drv = &floppy[i];
     drive_image_free (drv);
     drv->motoroff = 1;
     disabled &= ~(1 << i);
-    gui_data.drive_disabled[i] = 0;
-    gui_data.df[i][0] = 0;
-    gui_data.crc32[i] = 0;
-    if (currprefs.dfxtype[i] < 0) {
+    if (currprefs.dfxtype[i] < 0)
        disabled |= 1 << i;
-       gui_data.drive_disabled[i] = 1;
-    }
+    reset_drive_gui(i);
     /* most internal Amiga floppy drives won't enable
      * diskready until motor is running at full speed
      * and next indexsync has been passed
@@ -3111,6 +3116,11 @@ uae_u8 *restore_disk(int num,uae_u8 *src)
        }
        changed_prefs.dfxtype[num] = dfxtype;
     }
+    drv->indexhackmode = 0;
+    if (num == 0 && currprefs.dfxtype[num] == 0)
+       drv->indexhackmode = 1;
+    drv->buffered_cyl = -1;
+    drv->buffered_side = -1;
     drv->cyl = restore_u8 ();
     drv->dskready = restore_u8 ();
     drv->drive_id_scnt = restore_u8 ();
@@ -3122,15 +3132,22 @@ uae_u8 *restore_disk(int num,uae_u8 *src)
     strncpy(changed_prefs.df[num],src,255);
     newis = changed_prefs.df[num][0] ? 1 : 0;
     src+=strlen(src)+1;
-    drive_insert (floppy + num, &currprefs, num, changed_prefs.df[num]);
-    if (drive_empty (floppy + num)) {
-       if (newis && old[0]) {
-           strcpy (changed_prefs.df[num], old);
+    if (!(disabled & (1 << num))) {
+       if (!newis) {
+           drv->dskchange = 1;
+       } else {
            drive_insert (floppy + num, &currprefs, num, changed_prefs.df[num]);
-           if (drive_empty (floppy + num))
-               drv->dskchange = 1;
-        }
+           if (drive_empty (floppy + num)) {
+               if (newis && old[0]) {
+                   strcpy (changed_prefs.df[num], old);
+                   drive_insert (floppy + num, &currprefs, num, changed_prefs.df[num]);
+                   if (drive_empty (floppy + num))
+                       drv->dskchange = 1;
+               }
+           }
+       }
     }
+    reset_drive_gui(num);
     return src;
 }
 
@@ -3165,7 +3182,7 @@ uae_u8 *save_disk(int num, int *len, uae_u8 *dstptr)
     else
        dstbak = dst = (uae_u8*)malloc (2+1+1+1+1+4+4+256);
     save_u32 (drv->drive_id);      /* drive type ID */
-    save_u8 ((drv->motoroff ? 0:1) | ((disabled & (1 << num)) ? 2 : 0) | (drv->idbit ? 4 : 0));
+    save_u8 ((drv->motoroff ? 0:1) | ((disabled & (1 << num)) ? 2 : 0) | (drv->idbit ? 4 : 0) | (drv->dskchange ? 8 : 0));
     save_u8 (drv->cyl);                    /* cylinder */
     save_u8 (drv->dskready);       /* dskready */
     save_u8 (drv->drive_id_scnt);   /* id mode position */
index cf9bbc56017c208cfbf9b753b98557bd841f5414..b5db58543b2e7103f55d20d78e2bb2deae82accd 100755 (executable)
--- a/drawing.c
+++ b/drawing.c
@@ -1693,7 +1693,7 @@ static void center_image (void)
     /* @@@ interlace_seen used to be (bplcon0 & 4), but this is probably
      * better.  */
     if (prev_x_adjust != visible_left_border || prev_y_adjust != thisframe_y_adjust)
-       frame_redraw_necessary |= interlace_seen && currprefs.gfx_linedbl ? 2 : 1;
+       frame_redraw_necessary |= (interlace_seen && currprefs.gfx_linedbl) ? 2 : 1;
 
     max_diwstop = 0;
     min_diwstart = 10000;
@@ -2235,9 +2235,6 @@ void vsync_handle_redraw (int long_frame, int lof_changed)
            quit_program = -quit_program;
            set_inhibit_frame (IHF_QUIT_PROGRAM);
            set_special (&regs, SPCFLAG_BRK);
-#ifdef FILESYS
-           filesys_prepare_reset ();
-#endif
            return;
        }
 
index 347cf7b58bf1f7a3d5098584dd20462b0cfa804d..26e48899d8c8c1180cdaf6846571508198644d98 100755 (executable)
--- a/filesys.c
+++ b/filesys.c
@@ -3779,9 +3779,26 @@ void filesys_start_threads (void)
 
 void filesys_cleanup (void)
 {
+    filesys_free_handles();
     free_mountinfo ();
 }
 
+void filesys_free_handles(void)
+{
+    Unit *u, *u1;
+    for (u = units; u; u = u1) {
+       Key *k1, *knext;
+       u1 = u->next;
+       for (k1 = u->keys; k1; k1 = knext) {
+           knext = k1->next;
+           if (k1->fd)
+               fs_close (u, k1->fd);
+           xfree(k1);
+       }
+       u->keys = NULL;
+    }
+}
+
 void filesys_reset (void)
 {
     Unit *u, *u1;
@@ -3791,6 +3808,7 @@ void filesys_reset (void)
     if (savestate_state == STATE_RESTORE)
        return;
 
+    filesys_free_handles();
     for (u = units; u; u = u1) {
        u1 = u->next;
        xfree (u);
@@ -3838,6 +3856,7 @@ void filesys_prepare_reset (void)
        }
     }
 #endif
+    filesys_free_handles();
     u = units;
     while (u != 0) {
        free_all_ainos (u, &u->rootnode);
@@ -4414,7 +4433,7 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context)
     put_long (parmpacket + 44, 0); /* unused */
     put_long (parmpacket + 48, 0); /* interleave */
     put_long (parmpacket + 52, 0); /* lowCyl */
-    put_long (parmpacket + 56, uip[unit_no].hf.nrcyls - 1); /* hiCyl */
+    put_long (parmpacket + 56, uip[unit_no].hf.nrcyls <= 0 ? 0 : uip[unit_no].hf.nrcyls - 1); /* hiCyl */
     put_long (parmpacket + 60, 50); /* Number of buffers */
     put_long (parmpacket + 64, 0); /* Buffer mem type */
     put_long (parmpacket + 68, 0x7FFFFFFF); /* largest transfer */
index ccc19db06dcbd214e6f6f81bc57bc33f2ca0d8bd..c2a9de2ab29d5b214eb474367e3bc594dd1e6d21 100755 (executable)
--- a/gencomp.c
+++ b/gencomp.c
@@ -2023,13 +2023,13 @@ gen_opcode (unsigned long int opcode)
        break;
 
      case i_ASR:
-       mayfail;
+    mayfail;
        if (curi->smode==Dreg) {
-           comprintf("if ((uae_u32)srcreg==(uae_u32)dstreg) {\n"
-               "  FAIL(1);\n"
-               "  return 0;\n"
-               "} \n");
-           start_brace();
+         comprintf("if ((uae_u32)srcreg==(uae_u32)dstreg) {\n"
+                               "  FAIL(1);\n"
+                               "  return 0;\n"
+                               "} \n");
+         start_brace();
        }
        comprintf("\tdont_care_flags();\n");
 
@@ -2042,51 +2042,45 @@ gen_opcode (unsigned long int opcode)
                comprintf("\tint highmask;\n"
                          "\tint width;\n"
                          "\tint cdata=scratchie++;\n"
-                         "\tint tmpcnt=scratchie++;\n"
-                         "\tint highshift=scratchie++;\n");
-               comprintf("\tmov_l_rr(tmpcnt,cnt);\n"
-                         "\tand_l_ri(tmpcnt,63);\n"
-                         "\tmov_l_ri(cdata,0);\n"
-                         "\tcmov_l_rr(cdata,data,5);\n");
-               /* cdata is now either data (for shift count!=0) or
-                  0 (for shift count==0) */
-               switch(curi->size) {
-                case sz_byte: comprintf("\tshra_b_rr(data,cnt);\n"
-                                        "\thighmask=0x38;\n"
-                                        "\twidth=8;\n");
-                break;
-                case sz_word: comprintf("\tshra_w_rr(data,cnt);\n"
-                                        "\thighmask=0x30;\n"
-                                        "\twidth=16;\n");
-                break;
-                case sz_long: comprintf("\tshra_l_rr(data,cnt);\n"
-                                        "\thighmask=0x20;\n"
-                                        "\twidth=32;\n");
-                break;
-                default: abort();
+                         "\tint sdata=scratchie++;\n"
+                         "\tint tmpcnt=scratchie++;\n");
+               comprintf("\tmov_l_rr(sdata,data);\n"
+                         "\tmov_l_rr(cdata,data);\n"
+                         "\tmov_l_rr(tmpcnt,cnt);\n");
+               switch (curi->size) {
+               case sz_byte: comprintf("\tshra_b_ri(sdata,7);\n"); break;
+               case sz_word: comprintf("\tshra_w_ri(sdata,15);\n"); break;
+               case sz_long: comprintf("\tshra_l_ri(sdata,31);\n"); break;
+               default: abort();
                }
-               comprintf("test_l_ri(cnt,highmask);\n"
-                         "mov_l_ri(highshift,0);\n"
-                         "mov_l_ri(scratchie,width/2);\n"
-                         "cmov_l_rr(highshift,scratchie,5);\n");
-               /* The x86 masks out bits, so we now make sure that things
-                  really get shifted as much as planned */
+               /* sdata is now the MSB propagated to all bits for the
+                  register of specified size */
+               comprintf("\tand_l_ri(tmpcnt,63);\n");
                switch(curi->size) {
-                case sz_byte: comprintf("\tshra_b_rr(data,highshift);\n");break;
-                case sz_word: comprintf("\tshra_w_rr(data,highshift);\n");break;
-                case sz_long: comprintf("\tshra_l_rr(data,highshift);\n");break;
-                default: abort();
+               case sz_byte: comprintf("\tshra_b_rr(data,tmpcnt);\n"
+                                       "\thighmask=0x38;\n");
+                   break;
+               case sz_word: comprintf("\tshra_w_rr(data,tmpcnt);\n"
+                                       "\thighmask=0x30;\n");
+                   break;
+               case sz_long: comprintf("\tshra_l_rr(data,tmpcnt);\n"
+                                       "\thighmask=0x20;\n");
+                   break;
                }
-               /* And again */
-               switch(curi->size) {
-                case sz_byte: comprintf("\tshra_b_rr(data,highshift);\n");break;
-                case sz_word: comprintf("\tshra_w_rr(data,highshift);\n");break;
-                case sz_long: comprintf("\tshra_l_rr(data,highshift);\n");break;
-                default: abort();
+               comprintf("\ttest_l_ri(tmpcnt,highmask);\n");
+               switch (curi->size) {
+               case sz_byte: comprintf("\tcmov_b_rr(data,sdata,NATIVE_CC_NE);\n"); break;
+               case sz_word: comprintf("\tcmov_w_rr(data,sdata,NATIVE_CC_NE);\n"); break;
+               case sz_long: comprintf("\tcmov_l_rr(data,sdata,NATIVE_CC_NE);\n"); break;
                }
-
+               
                /* Result of shift is now in data. Now we need to determine
                   the carry by shifting cdata one less */
+               /* NOTE: carry bit is cleared if shift count is zero */
+               comprintf("\tmov_l_ri(scratchie,0);\n"
+                         "\ttest_l_rr(tmpcnt,tmpcnt);\n"
+                         "\tcmov_l_rr(sdata,scratchie,NATIVE_CC_EQ);\n"
+                         "\tforget_about(scratchie);\n");
                comprintf("\tsub_l_ri(tmpcnt,1);\n");
                switch(curi->size) {
                 case sz_byte: comprintf("\tshra_b_rr(cdata,tmpcnt);\n");break;
@@ -2095,10 +2089,16 @@ gen_opcode (unsigned long int opcode)
                 default: abort();
                }
                /* If the shift count was higher than the width, we need
-                  to pick up the sign from data */
-               comprintf("test_l_ri(tmpcnt,highmask);\n"
-                         "cmov_l_rr(cdata,data,5);\n");
-               /* And create the flags */
+                  to pick up the sign from original data (sdata) */
+               /* NOTE: for shift count of zero, the following holds
+                  true and cdata contains 0 so that carry bit is cleared */
+               comprintf("\ttest_l_ri(tmpcnt,highmask);\n"
+                         "\tforget_about(tmpcnt);\n"
+                         "\tcmov_l_rr(cdata,sdata,NATIVE_CC_NE);\n");
+
+               /* And create the flags (preserve X flag if shift count is zero) */
+               comprintf("\ttest_l_ri(cnt,63);\n"
+                         "\tcmov_l_rr(FLAGX,cdata,NATIVE_CC_NE);\n");
                comprintf("\tstart_needflags();\n");
                comprintf("\tif (needed_flags & FLAG_ZNV)\n");
                switch(curi->size) {
@@ -2109,7 +2109,6 @@ gen_opcode (unsigned long int opcode)
                comprintf("\t bt_l_ri(cdata,0);\n"); /* Set C */
                comprintf("\t live_flags();\n");
                comprintf("\t end_needflags();\n");
-               comprintf("\t duplicate_carry();\n");
                comprintf("if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n");
                genastore ("data", curi->dmode, "dstreg", curi->size, "data");
            }
@@ -2122,15 +2121,15 @@ gen_opcode (unsigned long int opcode)
                switch(curi->size) {
                 case sz_byte: comprintf("\tshra_b_rr(data,cnt);\n"
                                         "\thighmask=0x38;\n"
-                                        "\twidth=8;\n");
+                                        "\twidth=8;\n"); 
                 break;
                 case sz_word: comprintf("\tshra_w_rr(data,cnt);\n"
                                         "\thighmask=0x30;\n"
-                                        "\twidth=16;\n");
+                                        "\twidth=16;\n"); 
                 break;
                 case sz_long: comprintf("\tshra_l_rr(data,cnt);\n"
                                         "\thighmask=0x20;\n"
-                                        "\twidth=32;\n");
+                                        "\twidth=32;\n"); 
                 break;
                 default: abort();
                }
@@ -2336,13 +2335,13 @@ gen_opcode (unsigned long int opcode)
        break;
 
      case i_LSR:
-       mayfail;
+    mayfail;
        if (curi->smode==Dreg) {
-           comprintf("if ((uae_u32)srcreg==(uae_u32)dstreg) {\n"
-               "  FAIL(1);\n"
-               "  return 0;\n"
-               "} \n");
-           start_brace();
+         comprintf("if ((uae_u32)srcreg==(uae_u32)dstreg) {\n"
+                               "  FAIL(1);\n"
+                               "  return 0;\n"
+                               "} \n");
+         start_brace();
        }
        comprintf("\tdont_care_flags();\n");
 
@@ -2358,43 +2357,46 @@ gen_opcode (unsigned long int opcode)
                comprintf("\tmov_l_rr(tmpcnt,cnt);\n"
                          "\tand_l_ri(tmpcnt,63);\n"
                          "\tmov_l_ri(cdata,0);\n"
-                         "\tcmov_l_rr(cdata,data,5);\n");
+                         "\tcmov_l_rr(cdata,data,NATIVE_CC_NE);\n");
                /* cdata is now either data (for shift count!=0) or
                   0 (for shift count==0) */
                switch(curi->size) {
-                case sz_byte: comprintf("\tshrl_b_rr(data,cnt);\n"
-                                        "\thighmask=0x38;\n");
+                case sz_byte: comprintf("\tshrl_b_rr(data,tmpcnt);\n"
+                                        "\thighmask=0x38;\n"); 
                 break;
-                case sz_word: comprintf("\tshrl_w_rr(data,cnt);\n"
-                                        "\thighmask=0x30;\n");
+                case sz_word: comprintf("\tshrl_w_rr(data,tmpcnt);\n"
+                                        "\thighmask=0x30;\n"); 
                 break;
-                case sz_long: comprintf("\tshrl_l_rr(data,cnt);\n"
-                                        "\thighmask=0x20;\n");
+                case sz_long: comprintf("\tshrl_l_rr(data,tmpcnt);\n"
+                                        "\thighmask=0x20;\n"); 
                 break;
                 default: abort();
                }
-               comprintf("test_l_ri(cnt,highmask);\n"
-                         "mov_l_ri(scratchie,0);\n"
-                         "cmov_l_rr(scratchie,data,4);\n");
-               switch(curi->size) {
-                case sz_byte: comprintf("\tmov_b_rr(data,scratchie);\n");break;
-                case sz_word: comprintf("\tmov_w_rr(data,scratchie);\n");break;
-                case sz_long: comprintf("\tmov_l_rr(data,scratchie);\n");break;
-                default: abort();
+               comprintf("\ttest_l_ri(tmpcnt,highmask);\n"
+                         "\rmov_l_ri(scratchie,0);\n");
+               if (curi->size == sz_long)
+                   comprintf("\tcmov_l_rr(data,scratchie,NATIVE_CC_NE);\n");
+               else {
+                   comprintf("\tcmov_l_rr(scratchie,data,NATIVE_CC_EQ);\n");
+                   switch(curi->size) {
+                   case sz_byte: comprintf("\tmov_b_rr(data,scratchie);\n");break;
+                   case sz_word: comprintf("\tmov_w_rr(data,scratchie);\n");break;
+                   default: abort();
+                   }
                }
                /* Result of shift is now in data. Now we need to determine
                   the carry by shifting cdata one less */
                comprintf("\tsub_l_ri(tmpcnt,1);\n");
-               switch(curi->size) {
-                case sz_byte: comprintf("\tshrl_b_rr(cdata,tmpcnt);\n");break;
-                case sz_word: comprintf("\tshrl_w_rr(cdata,tmpcnt);\n");break;
-                case sz_long: comprintf("\tshrl_l_rr(cdata,tmpcnt);\n");break;
-                default: abort();
-               }
-               comprintf("test_l_ri(tmpcnt,highmask);\n"
-                         "mov_l_ri(scratchie,0);\n"
-                         "cmov_l_rr(cdata,scratchie,5);\n");
-               /* And create the flags */
+               comprintf("\tshrl_l_rr(cdata,tmpcnt);\n");
+               comprintf("\ttest_l_ri(tmpcnt,highmask);\n");
+               comprintf("\tforget_about(tmpcnt);\n");
+               if (curi->size != sz_long) /* scratchie is still live for LSR.L */
+                   comprintf("\tmov_l_ri(scratchie,0);\n");
+               comprintf("\tcmov_l_rr(cdata,scratchie,NATIVE_CC_NE);\n");
+               comprintf("\tforget_about(scratchie);\n");
+               /* And create the flags (preserve X flag if shift count is zero) */
+               comprintf("\ttest_l_ri(cnt,63);\n"
+                         "\tcmov_l_rr(FLAGX,cdata,NATIVE_CC_NE);\n");
                comprintf("\tstart_needflags();\n");
                comprintf("\tif (needed_flags & FLAG_ZNV)\n");
                switch(curi->size) {
@@ -2405,7 +2407,6 @@ gen_opcode (unsigned long int opcode)
                comprintf("\t bt_l_ri(cdata,0);\n"); /* Set C */
                comprintf("\t live_flags();\n");
                comprintf("\t end_needflags();\n");
-               comprintf("\t duplicate_carry();\n");
                comprintf("if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n");
                genastore ("data", curi->dmode, "dstreg", curi->size, "data");
            }
@@ -2415,13 +2416,13 @@ gen_opcode (unsigned long int opcode)
                comprintf("\tint highmask;\n");
                switch(curi->size) {
                 case sz_byte: comprintf("\tshrl_b_rr(data,cnt);\n"
-                                        "\thighmask=0x38;\n");
+                                        "\thighmask=0x38;\n"); 
                    break;
                 case sz_word: comprintf("\tshrl_w_rr(data,cnt);\n"
-                                        "\thighmask=0x30;\n");
+                                        "\thighmask=0x30;\n"); 
                    break;
                 case sz_long: comprintf("\tshrl_l_rr(data,cnt);\n"
-                                        "\thighmask=0x20;\n");
+                                        "\thighmask=0x20;\n"); 
                    break;
                 default: abort();
                }
@@ -2471,6 +2472,14 @@ gen_opcode (unsigned long int opcode)
        break;
 
      case i_LSL:
+    mayfail;
+       if (curi->smode==Dreg) {
+         comprintf("if ((uae_u32)srcreg==(uae_u32)dstreg) {\n"
+                               "  FAIL(1);\n"
+                               "  return 0;\n"
+                               "} \n");
+         start_brace();
+       }
        comprintf("\tdont_care_flags();\n");
 
        genamode (curi->smode, "srcreg", curi->size, "cnt", 1, 0);
@@ -2485,56 +2494,61 @@ gen_opcode (unsigned long int opcode)
                comprintf("\tmov_l_rr(tmpcnt,cnt);\n"
                          "\tand_l_ri(tmpcnt,63);\n"
                          "\tmov_l_ri(cdata,0);\n"
-                         "\tcmov_l_rr(cdata,data,5);\n");
+                         "\tcmov_l_rr(cdata,data,NATIVE_CC_NE);\n");
                /* cdata is now either data (for shift count!=0) or
                   0 (for shift count==0) */
                switch(curi->size) {
-                case sz_byte: comprintf("\tshll_b_rr(data,cnt);\n"
-                                        "\thighmask=0x38;\n");
+                case sz_byte: comprintf("\tshll_b_rr(data,tmpcnt);\n"
+                                        "\thighmask=0x38;\n"); 
                 break;
-                case sz_word: comprintf("\tshll_w_rr(data,cnt);\n"
-                                        "\thighmask=0x30;\n");
+                case sz_word: comprintf("\tshll_w_rr(data,tmpcnt);\n"
+                                        "\thighmask=0x30;\n"); 
                 break;
-                case sz_long: comprintf("\tshll_l_rr(data,cnt);\n"
-                                        "\thighmask=0x20;\n");
+                case sz_long: comprintf("\tshll_l_rr(data,tmpcnt);\n"
+                                        "\thighmask=0x20;\n"); 
                 break;
                 default: abort();
                }
-               comprintf("test_l_ri(cnt,highmask);\n"
-                         "mov_l_ri(scratchie,0);\n"
-                         "cmov_l_rr(scratchie,data,4);\n");
-               switch(curi->size) {
-                case sz_byte: comprintf("\tmov_b_rr(data,scratchie);\n");break;
-                case sz_word: comprintf("\tmov_w_rr(data,scratchie);\n");break;
-                case sz_long: comprintf("\tmov_l_rr(data,scratchie);\n");break;
-                default: abort();
+               comprintf("\ttest_l_ri(tmpcnt,highmask);\n"
+                         "\tmov_l_ri(scratchie,0);\n");
+               if (curi->size == sz_long)
+                   comprintf("\tcmov_l_rr(data,scratchie,NATIVE_CC_NE);\n");
+               else {
+                   comprintf("\tcmov_l_rr(scratchie,data,NATIVE_CC_EQ);\n");
+                   switch(curi->size) {
+                   case sz_byte: comprintf("\tmov_b_rr(data,scratchie);\n");break;
+                   case sz_word: comprintf("\tmov_w_rr(data,scratchie);\n");break;
+                   default: abort();
+                   }
                }
                /* Result of shift is now in data. Now we need to determine
                   the carry by shifting cdata one less */
                comprintf("\tsub_l_ri(tmpcnt,1);\n");
-               switch(curi->size) {
-                case sz_byte: comprintf("\tshll_b_rr(cdata,tmpcnt);\n");break;
-                case sz_word: comprintf("\tshll_w_rr(cdata,tmpcnt);\n");break;
-                case sz_long: comprintf("\tshll_l_rr(cdata,tmpcnt);\n");break;
-                default: abort();
+               comprintf("\tshll_l_rr(cdata,tmpcnt);\n");
+               comprintf("\ttest_l_ri(tmpcnt,highmask);\n");
+               comprintf("\tforget_about(tmpcnt);\n");
+               if (curi->size != sz_long) /* scratchie is still live for LSL.L */
+                   comprintf("\tmov_l_ri(scratchie,0);\n");
+               comprintf("\tcmov_l_rr(cdata,scratchie,NATIVE_CC_NE);\n");
+               comprintf("\tforget_about(scratchie);\n");
+               /* And create the flags (preserve X flag if shift count is zero) */
+               switch (curi->size) {
+               case sz_byte: comprintf("\tshrl_l_ri(cdata,7);\n"); break;
+               case sz_word: comprintf("\tshrl_l_ri(cdata,15);\n"); break;
+               case sz_long: comprintf("\tshrl_l_ri(cdata,31);\n"); break;
                }
-               comprintf("test_l_ri(tmpcnt,highmask);\n"
-                         "mov_l_ri(scratchie,0);\n"
-                         "cmov_l_rr(cdata,scratchie,5);\n");
-               /* And create the flags */
+               comprintf("\ttest_l_ri(cnt,63);\n"
+                         "\tcmov_l_rr(FLAGX,cdata,NATIVE_CC_NE);\n");
                comprintf("\tstart_needflags();\n");
                comprintf("\tif (needed_flags & FLAG_ZNV)\n");
                switch(curi->size) {
-                case sz_byte: comprintf("\t  test_b_rr(data,data);\n");
-                   comprintf("\t bt_l_ri(cdata,7);\n"); break;
-                case sz_word: comprintf("\t  test_w_rr(data,data);\n");
-                   comprintf("\t bt_l_ri(cdata,15);\n"); break;
-                case sz_long: comprintf("\t  test_l_rr(data,data);\n");
-                   comprintf("\t bt_l_ri(cdata,31);\n"); break;
+               case sz_byte: comprintf("\t  test_b_rr(data,data);\n"); break;
+               case sz_word: comprintf("\t  test_w_rr(data,data);\n"); break;
+               case sz_long: comprintf("\t  test_l_rr(data,data);\n"); break;
                }
+               comprintf("\t bt_l_ri(cdata,0);\n");
                comprintf("\t live_flags();\n");
                comprintf("\t end_needflags();\n");
-               comprintf("\t duplicate_carry();\n");
                comprintf("if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n");
                genastore ("data", curi->dmode, "dstreg", curi->size, "data");
            }
@@ -2544,13 +2558,13 @@ gen_opcode (unsigned long int opcode)
                comprintf("\tint highmask;\n");
                switch(curi->size) {
                 case sz_byte: comprintf("\tshll_b_rr(data,cnt);\n"
-                                        "\thighmask=0x38;\n");
+                                        "\thighmask=0x38;\n"); 
                    break;
                 case sz_word: comprintf("\tshll_w_rr(data,cnt);\n"
-                                        "\thighmask=0x30;\n");
+                                        "\thighmask=0x30;\n"); 
                    break;
                 case sz_long: comprintf("\tshll_l_rr(data,cnt);\n"
-                                        "\thighmask=0x20;\n");
+                                        "\thighmask=0x20;\n"); 
                    break;
                 default: abort();
                }
@@ -2599,6 +2613,7 @@ gen_opcode (unsigned long int opcode)
        }
        break;
 
+
      case i_ROL:
        mayfail;
        if (curi->smode==Dreg) {
index 293630c1d08ecac1e17daafb3da863b504689f7a..1f85e07fae28ca4877279993e37adf6561e4af60 100755 (executable)
--- a/gencpu.c
+++ b/gencpu.c
@@ -25,6 +25,8 @@
 #include "readcpu.h"
 
 #define BOOL_TYPE "int"
+/* Define the minimal 680x0 where NV flags are not affected by xBCD instructions.  */
+#define xBCD_KEEPS_NV_FLAGS 4
 
 static FILE *headerfile;
 static FILE *stblfile;
@@ -479,8 +481,9 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g
            /* This would ordinarily be done in gen_nextiword, which we bypass.  */
            insn_n_cycles += 4;
            printf ("\t%sa = get_disp_ea_020(regs, m68k_areg(regs, %s), next_iword(regs));\n", name, reg);
-       } else
+       } else {
            printf ("\t%sa = get_disp_ea_000(regs, m68k_areg(regs, %s), %s);\n", name, reg, gen_nextiword (flags & GF_NOREFILL));
+       }
        if (!(flags & GF_AD8R)) {
            addcycles (2);
            insn_n_cycles += 2;
@@ -874,7 +877,7 @@ static void duplicate_carry (int n)
 
 typedef enum
 {
-  flag_logical_noclobber, flag_logical, flag_add, flag_sub, flag_cmp, flag_addx, flag_subx, flag_zn,
+  flag_logical_noclobber, flag_logical, flag_add, flag_sub, flag_cmp, flag_addx, flag_subx, flag_z, flag_zn,
   flag_av, flag_sv
 }
 flagtypes;
@@ -929,6 +932,7 @@ static void genflags_normal (flagtypes type, wordsizes size, char *value, char *
     switch (type) {
      case flag_logical_noclobber:
      case flag_logical:
+     case flag_z:
      case flag_zn:
      case flag_av:
      case flag_sv:
@@ -983,6 +987,9 @@ static void genflags_normal (flagtypes type, wordsizes size, char *value, char *
      case flag_sv:
        printf ("\tSET_VFLG (&regs->ccrflags, (flgs ^ flgo) & (flgn ^ flgo));\n");
        break;
+     case flag_z:
+       printf ("\tSET_ZFLG (&regs->ccrflags, GET_ZFLG (&(regs->ccrflags)) & (%s == 0));\n", vstr);
+       break;
      case flag_zn:
        printf ("\tSET_ZFLG (&regs->ccrflags, GET_ZFLG (&(regs->ccrflags)) & (%s == 0));\n", vstr);
        printf ("\tSET_NFLG (&regs->ccrflags, %s < 0);\n", vstr);
@@ -1261,8 +1268,15 @@ static void gen_opcode (unsigned long int opcode)
        printf ("\tif ((((dst & 0xFF) - (src & 0xFF) - (GET_XFLG (&regs->ccrflags) ? 1 : 0)) & 0x100) > 0xFF) { newv -= 0x60; }\n");
        printf ("\tSET_CFLG (&regs->ccrflags, (((dst & 0xFF) - (src & 0xFF) - bcd - (GET_XFLG (&regs->ccrflags) ? 1 : 0)) & 0x300) > 0xFF);\n");
        duplicate_carry (0);
-       genflags (flag_zn, curi->size, "newv", "", "");
-       printf ("\tSET_VFLG (&regs->ccrflags, (tmp_newv & 0x80) != 0 && (newv & 0x80) == 0);\n");
+       /* Manual says bits NV are undefined though a real 68040/060 don't change them */
+       if (cpu_level >= xBCD_KEEPS_NV_FLAGS) {
+           if (next_cpu_level < xBCD_KEEPS_NV_FLAGS)
+               next_cpu_level = xBCD_KEEPS_NV_FLAGS - 1;
+           genflags (flag_z, curi->size, "newv", "", "");
+       } else {
+           genflags (flag_zn, curi->size, "newv", "", "");
+           printf ("\tSET_VFLG (&regs->ccrflags, (tmp_newv & 0x80) != 0 && (newv & 0x80) == 0);\n");
+       }
        addcycles (2);
        genastore ("newv", curi->dmode, "dstreg", curi->size, "dst");
        break;
@@ -1319,8 +1333,16 @@ static void gen_opcode (unsigned long int opcode)
        printf ("\tif (cflg) newv += 0x60;\n");
        printf ("\tSET_CFLG (&regs->ccrflags, cflg);\n");
        duplicate_carry (0);
-       genflags (flag_zn, curi->size, "newv", "", "");
-       printf ("\tSET_VFLG (&regs->ccrflags, (tmp_newv & 0x80) == 0 && (newv & 0x80) != 0);\n");
+       /* Manual says bits NV are undefined though a real 68040 don't change them */
+       if (cpu_level >= xBCD_KEEPS_NV_FLAGS) {
+           if (next_cpu_level < xBCD_KEEPS_NV_FLAGS)
+               next_cpu_level = xBCD_KEEPS_NV_FLAGS - 1;
+           genflags (flag_z, curi->size, "newv", "", "");
+       }
+       else {
+           genflags (flag_zn, curi->size, "newv", "", "");
+           printf ("\tSET_VFLG (&regs->ccrflags, (tmp_newv & 0x80) == 0 && (newv & 0x80) != 0);\n");
+       }
        addcycles (2);
        genastore ("newv", curi->dmode, "dstreg", curi->size, "dst");
        break;
@@ -1360,7 +1382,15 @@ static void gen_opcode (unsigned long int opcode)
        printf ("\tif (cflg) newv -= 0x60;\n");
        printf ("\tSET_CFLG (&regs->ccrflags, cflg);\n");
        duplicate_carry(0);
-       genflags (flag_zn, curi->size, "newv", "", "");
+       /* Manual says bits NV are undefined though a real 68040 don't change them */
+       if (cpu_level >= xBCD_KEEPS_NV_FLAGS) {
+           if (next_cpu_level < xBCD_KEEPS_NV_FLAGS)
+               next_cpu_level = xBCD_KEEPS_NV_FLAGS - 1;
+           genflags (flag_z, curi->size, "newv", "", "");
+       }
+       else {
+           genflags (flag_zn, curi->size, "newv", "", "");
+       }
        genastore ("newv", curi->smode, "srcreg", curi->size, "src");
        break;
     case i_CLR:
index 3c3358bbc73d911fcb2a3b3fbafee26f0173c1dc..dd30abe355b9672a1e3b890e4719c9bae88ea1ac 100755 (executable)
@@ -118,6 +118,53 @@ static int rl (uae_u8 *p)
 }
 
 
+static void getchs2 (struct hardfiledata *hfd, int *cyl, int *cylsec, int *head, int *tracksec)
+{
+    unsigned int total = (unsigned int)(hfd->size / 1024);
+    int heads;
+    int sectors = 63;
+
+    /* do we have RDB values? */
+    if (hfd->cylinders) {
+       *cyl = hfd->cylinders;
+       *tracksec = hfd->sectors;
+       *head = hfd->heads;
+       *cylsec = hfd->sectors * hfd->heads;
+       return;
+    }
+    /* what about HDF settings? */
+    if (hfd->surfaces && hfd->secspertrack) {
+       *head = hfd->surfaces;
+       *tracksec = hfd->secspertrack;
+       *cylsec = (*head) * (*tracksec);
+       *cyl = (unsigned int)(hfd->size / hfd->blocksize) / ((*tracksec) * (*head));
+       return;
+    }
+    /* no, lets guess something.. */
+    if (total <= 504 * 1024)
+       heads = 16;
+    else if (total <= 1008 * 1024)
+       heads = 32;
+    else if (total <= 2016 * 1024)
+       heads = 64;
+    else if (total <= 4032 * 1024)
+       heads = 128;
+    else
+       heads = 255;
+    *cyl = (unsigned int)(hfd->size / hfd->blocksize) / (sectors * heads);
+    *cylsec = sectors * heads;
+    *tracksec = sectors;
+    *head = heads;
+}
+
+static void getchs (struct hardfiledata *hfd, int *cyl, int *cylsec, int *head, int *tracksec)
+{
+    getchs2 (hfd, cyl, cylsec, head, tracksec);
+    hf_log ("CHS: %08.8X-%08.8X %d %d %d %d %d\n",
+       (uae_u32)(hfd->size >> 32),(uae_u32)hfd->size,
+       *cyl, *cylsec, *head, *tracksec);
+}
+
 void getchshd (struct hardfiledata *hfd, int *pcyl, int *phead, int *psectorspertrack)
 {
     unsigned int total = (unsigned int)(hfd->size / 512);
@@ -436,6 +483,15 @@ int scsi_emulate(struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u8
            int pc = cmdbuf[2] >> 6;
            int pcode = cmdbuf[2] & 0x3f;
            int dbd = cmdbuf[1] & 8;
+           int cyl, cylsec, head, tracksec;
+           if (hdhfd) {
+               cyl = hdhfd->cyls;
+               head = hdhfd->heads;
+               tracksec = hdhfd->secspertrack;
+               cylsec = 0;
+           } else {
+               getchs (hfd, &cyl, &cylsec, &head, &tracksec);
+           }
            //write_log("MODE SENSE PC=%d CODE=%d DBD=%d\n", pc, pcode, dbd);
            p = r;
            p[0] = 4 - 1;
@@ -460,8 +516,8 @@ int scsi_emulate(struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u8
                p[0] = 3;
                p[1] = 24;
                p[3] = 1;
-               p[10] = hdhfd->secspertrack >> 8;
-               p[11] = hdhfd->secspertrack;
+               p[10] = tracksec >> 8;
+               p[11] = tracksec;
                p[12] = hfd->blocksize >> 8;
                p[13] = hfd->blocksize;
                p[15] = 1; // interleave
@@ -469,10 +525,10 @@ int scsi_emulate(struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u8
                r[0] += p[1];
            } else if (pcode == 4) {
                p[0] = 4;
-               wl(p + 1, hdhfd->cyls);
+               wl(p + 1, cyl);
                p[1] = 24;
-               p[5] = hdhfd->heads;
-               wl(p + 13, hdhfd->cyls);
+               p[5] = head;
+               wl(p + 13, cyl);
                ww(p + 20, 5400);
                r[0] += p[1];
            } else {
@@ -490,10 +546,19 @@ int scsi_emulate(struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u8
            int pmi = cmdbuf[8] & 1;
            uae_u32 lba = (cmdbuf[2] << 24) | (cmdbuf[3] << 16) | (cmdbuf[2] << 8) | cmdbuf[3];
            uae_u32 blocks = (uae_u32)(hfd->size / hfd->blocksize - 1);
+           int cyl, cylsec, head, tracksec;
+           if (hdhfd) {
+               cyl = hdhfd->cyls;
+               head = hdhfd->heads;
+               tracksec = hdhfd->secspertrack;
+               cylsec = 0;
+           } else {
+               getchs (hfd, &cyl, &cylsec, &head, &tracksec);
+           }
            if (pmi) {
-               lba += hdhfd->secspertrack * hdhfd->heads;
-               lba /= hdhfd->secspertrack * hdhfd->heads;
-               lba *= hdhfd->secspertrack * hdhfd->heads;
+               lba += tracksec * head;
+               lba /= tracksec * head;
+               lba *= tracksec * head;
                if (lba > blocks)
                    lba = blocks;
                blocks = lba;
@@ -768,53 +833,6 @@ static uae_u32 REGPARAM2 hardfile_expunge (TrapContext *context)
     return 0; /* Simply ignore this one... */
 }
 
-static void getchs2 (struct hardfiledata *hfd, int *cyl, int *cylsec, int *head, int *tracksec)
-{
-    unsigned int total = (unsigned int)(hfd->size / 1024);
-    int heads;
-    int sectors = 63;
-
-    /* do we have RDB values? */
-    if (hfd->cylinders) {
-       *cyl = hfd->cylinders;
-       *tracksec = hfd->sectors;
-       *head = hfd->heads;
-       *cylsec = hfd->sectors * hfd->heads;
-       return;
-    }
-    /* what about HDF settings? */
-    if (hfd->surfaces && hfd->secspertrack) {
-       *head = hfd->surfaces;
-       *tracksec = hfd->secspertrack;
-       *cylsec = (*head) * (*tracksec);
-       *cyl = (unsigned int)(hfd->size / hfd->blocksize) / ((*tracksec) * (*head));
-       return;
-    }
-    /* no, lets guess something.. */
-    if (total <= 504 * 1024)
-       heads = 16;
-    else if (total <= 1008 * 1024)
-       heads = 32;
-    else if (total <= 2016 * 1024)
-       heads = 64;
-    else if (total <= 4032 * 1024)
-       heads = 128;
-    else
-       heads = 255;
-    *cyl = (unsigned int)(hfd->size / hfd->blocksize) / (sectors * heads);
-    *cylsec = sectors * heads;
-    *tracksec = sectors;
-    *head = heads;
-}
-
-static void getchs (struct hardfiledata *hfd, int *cyl, int *cylsec, int *head, int *tracksec)
-{
-    getchs2 (hfd, cyl, cylsec, head, tracksec);
-    hf_log ("CHS: %08.8X-%08.8X %d %d %d %d %d\n",
-       (uae_u32)(hfd->size >> 32),(uae_u32)hfd->size,
-       *cyl, *cylsec, *head, *tracksec);
-}
-
 static void outofbounds (int cmd, uae_u64 offset, uae_u64 len, uae_u64 max)
 {
     write_log ("UAEHF: cmd %d: out of bounds, %08.8X-%08.8X + %08.8X-%08.8X > %08.8X-%08.8X\n", cmd,
index 47854cf095a31332c64cb49f2ed385b9aa6ac13e..61323e60108cbd87bd5e08f3e220301502f2f1e7 100755 (executable)
@@ -59,6 +59,7 @@ extern void filesys_cleanup (void);
 extern void filesys_prepare_reset (void);
 extern void filesys_start_threads (void);
 extern void filesys_flush_cache (void);
+extern void filesys_free_handles (void);
 
 extern void filesys_install (void);
 extern void filesys_install_code (void);
index 9cb218655260a3fd42ec3e8b8321e18c0ae09ae3..394e126c8f2fc983af138aab93b7722906fc8a6e 100755 (executable)
@@ -113,6 +113,7 @@ struct device_functions {
 extern struct device_functions *device_func[2];
 
 extern int device_func_init(int flags);
+extern void device_func_reset(void);
 extern int sys_command_open (int mode, int unitnum);
 extern void sys_command_close (int mode, int unitnum);
 extern struct device_info *sys_command_info (int mode, int unitnum, struct device_info *di);
index 8a9fe5e574d9e0ec3880b687615ab3cb76788fab..64da421b599e262e872223d79e01a10eb8c0b5f6 100755 (executable)
@@ -1,3 +1,6 @@
+
+#include "flags_x86.h"
+
 #ifdef CPU_64_BIT
 typedef uae_u64 uintptr;
 #else
@@ -290,6 +293,8 @@ DECLARE(shra_w_ri(RW2 r, IMM i));
 DECLARE(shra_b_ri(RW1 r, IMM i));
 DECLARE(setcc(W1 d, IMM cc));
 DECLARE(setcc_m(IMM d, IMM cc));
+DECLARE(cmov_b_rr(RW1 d, R1 s, IMM cc));
+DECLARE(cmov_w_rr(RW2 d, R2 s, IMM cc));
 DECLARE(cmov_l_rr(RW4 d, R4 s, IMM cc));
 DECLARE(cmov_l_rm(RW4 d, IMM s, IMM cc));
 DECLARE(bsf_l_rr(W4 d, R4 s));
index f85c03730df335ff1aa3da1e11b5bd018a1005a2..b3032bbb0a8d7e87017c07970e46d8a85105ee56 100755 (executable)
@@ -20,7 +20,7 @@
 uae_u32 get_copper_address(int copno);
 
 extern int custom_init (void);
-extern void customreset (void);
+extern void customreset (int hardreset);
 extern int intlev (void);
 extern void dumpcustom (void);
 
diff --git a/include/flags_x86.h b/include/flags_x86.h
new file mode 100755 (executable)
index 0000000..89503a2
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *  compiler/flags_x86.h - Native flags definitions for IA-32
+ *
+ *  Original 68040 JIT compiler for UAE, copyright 2000-2002 Bernd Meyer
+ *
+ *  Adaptation for Basilisk II and improvements, copyright 2000-2005
+ *    Gwenole Beauchesne
+ *
+ *  Basilisk II (C) 1997-2005 Christian Bauer
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef NATIVE_FLAGS_X86_H
+#define NATIVE_FLAGS_X86_H
+
+/* Native integer code conditions */
+enum {
+       NATIVE_CC_HI = 7,
+       NATIVE_CC_LS = 6,
+       NATIVE_CC_CC = 3,
+       NATIVE_CC_CS = 2,
+       NATIVE_CC_NE = 5,
+       NATIVE_CC_EQ = 4,
+       NATIVE_CC_VC = 11,
+       NATIVE_CC_VS = 10,
+       NATIVE_CC_PL = 9,
+       NATIVE_CC_MI = 8,
+       NATIVE_CC_GE = 13,
+       NATIVE_CC_LT = 12,
+       NATIVE_CC_GT = 15,
+       NATIVE_CC_LE = 14
+};
+
+#endif /* NATIVE_FLAGS_X86_H */
index 8f345e781e21034e377cb3f451935694da09d33b..737994f98e7899609fb9532d5e63142687ee6c17 100755 (executable)
@@ -17,7 +17,7 @@ extern int special_mem;
 extern void *cache_alloc (int);
 extern void cache_free (void*);
 
-extern int canbang;
+extern int canbang, candirect;
 void init_shm (void);
 #endif
 
index 8a7d5c2d8e4aa4570057375a739d449d3fb05023..b5b8223cfef8ababc1910d8aa41e6c0e66768c3b 100755 (executable)
@@ -305,7 +305,7 @@ extern int get_cpu_model(void);
 extern void REGPARAM3 MakeSR (struct regstruct *regs) REGPARAM;
 extern void REGPARAM3 MakeFromSR (struct regstruct *regs) REGPARAM;
 extern void REGPARAM3 Exception (int, struct regstruct *regs, uaecptr) REGPARAM;
-extern void Interrupt (int nr);
+extern void NMI (void);
 extern void doint (void);
 extern void dump_counts (void);
 extern int m68k_move2c (int, uae_u32 *);
index ed20b8f337b86c59f4ff16275b49dc20e9372224..f773369f049ef8c956a3457518521bfe55585f46 100755 (executable)
@@ -91,6 +91,11 @@ extern uae_u8 *save_gayle (int *len);
 extern uae_u8 *restore_ide (uae_u8 *src);
 extern uae_u8 *save_ide (int num, int *len);
 
+extern uae_u8 *save_configuration (int *len);
+extern uae_u8 *restore_configuration (uae_u8 *src);
+extern uae_u8 *save_log (int *len);
+extern uae_u8 *restore_log (uae_u8 *src);
+
 extern void restore_cram (int, size_t);
 extern void restore_bram (int, size_t);
 extern void restore_fram (int, size_t);
index 3509c4ff83367ebd820fb0a77974e44f261bb85c..8344e58ad4e72088f4a834ee4fd7656efe88d93f 100755 (executable)
@@ -90,7 +90,7 @@ extern struct zfile *archive_access_lzx (struct znode *zn);
 extern struct zvolume *archive_directory_arcacc (struct zfile *z, unsigned int id);
 extern struct zfile *archive_access_arcacc (struct znode *zn);
 
-extern struct zfile *archive_access_select (struct zfile *zf, unsigned int id);
+extern struct zfile *archive_access_select (struct zfile *zf, unsigned int id, int doselect);
 extern struct zfile *archive_access_arcacc_select (struct zfile *zf, unsigned int id);
 
 
index a7c41241388ae7ff495d682351e352ad541aba73..ea1ce0542256369362c9ab7ad9e2c40108e9573b 100755 (executable)
@@ -1550,7 +1550,7 @@ void inputdevice_handle_inputcode (void)
        disk_eject (3);
        break;
     case AKS_IRQ7:
-       Interrupt (7);
+       NMI ();
        break;
     case AKS_PAUSE:
        pausemode (-1);
diff --git a/main.c b/main.c
index fe545a871ca51e835ab77d97ccaa5b98e406e6ff..7632a3c13109155b8f5580eeb420f1acbc7672c9 100755 (executable)
--- a/main.c
+++ b/main.c
@@ -45,6 +45,7 @@
 #include "a2091.h"
 #include "ncr_scsi.h"
 #include "scsi.h"
+#include "blkdev.h"
 
 #ifdef USE_SDL
 #include "SDL.h"
@@ -545,6 +546,7 @@ void reset_all_systems (void)
 #endif
 
 #ifdef FILESYS
+    filesys_prepare_reset ();
     filesys_reset ();
 #endif
     memory_reset ();
@@ -578,6 +580,10 @@ void do_start_program (void)
 {
     if (quit_program == -1)
        return;
+    if (!canbang && candirect < 0)
+       candirect = 0;
+    if (canbang && candirect < 0)
+       candirect = 1;
     /* Do a reset on startup. Whether this is elegant is debatable. */
     inputdevice_updateconfig (&currprefs);
     if (quit_program >= 0)
@@ -618,6 +624,7 @@ void do_leave_program (void)
 #ifdef FILESYS
     filesys_cleanup ();
 #endif
+    device_func_reset();
     savestate_free ();
     memory_cleanup ();
     cfgfile_addcfgparam (0);
index 410b1f8ba0c654823bd95ab3f3e98c5dfe3e5f42..250f7cdb778973e4bd68bfb342dc2eaa61a71a54 100755 (executable)
--- a/memory.c
+++ b/memory.c
 #include "a2091.h"
 
 int canbang;
+int candirect = -1;
 #ifdef JIT
 /* Set by each memory handler that does not simply access real memory. */
 int special_mem;
 #endif
 
+static void nocanbang(void)
+{
+    canbang = 0;
+}
+
 int ersatzkickfile;
 
 uae_u32 allocated_chipmem;
@@ -199,18 +205,18 @@ static struct romdata roms[] = {
     { "Freezer: Action Replay 1200", 0, 0, 0, 0, "AR\0", 262144, 47, 0, 0, ROMTYPE_AR, 1,
        0x8d760101, 0x0F6AB834,0x2810094A,0xC0642F62,0xBA42F78B,0xC0B07E6A },
 
-    { "Freezer: Action Cartridge Super IV Pro (+ROM)", 4, 3, 4, 3, "SUPERIV\0", 170368, 60, 0, 0, ROMTYPE_SUPERIV, 1,
-       0xe668a0be, 0x633A6E65,0xA93580B8,0xDDB0BE9C,0x9A64D4A1,0x7D4B4801 },
-    { "Freezer: Action Cartridge Super IV Pro", 0, 0, 0, 0, "SUPERIV\0", 0, 62, 0, 0, ROMTYPE_SUPERIV, 1,
+    { "Freezer: Action Cartridge Super IV Professional", 0, 0, 0, 0, "SUPERIV\0", 0, 62, 0, 0, ROMTYPE_SUPERIV, 1,
        0xffffffff, 0, 0, 0, 0, 0, "SuperIV" },
-    { "Freezer: X-Power Professional 500", 1, 2, 1, 2, "XPOWER\0", 131072, 65, 0, 0, ROMTYPE_SUPERIV, 1,
+    { "Freezer: Action Cart. Super IV Pro (+ROM v4.3)", 4, 3, 4, 3, "SUPERIV\0", 170368, 60, 0, 0, ROMTYPE_SUPERIV, 1,
+       0xe668a0be, 0x633A6E65,0xA93580B8,0xDDB0BE9C,0x9A64D4A1,0x7D4B4801 },
+    { "Freezer: X-Power Professional 500 v1.2", 1, 2, 1, 2, "XPOWER\0", 131072, 65, 0, 0, ROMTYPE_SUPERIV, 1,
        0x9e70c231, 0xa2977a1c,0x41a8ca7d,0x4af4a168,0x726da542,0x179d5963 },
     /* only 2 bad dumps available */
     { "Freezer: Nordic Power v?", 0, 0, 0, 0, "NPOWER\0", 65536, 66, 0, 0, ROMTYPE_SUPERIV, 1, },
     { "Freezer: Nordic Power v?", 0, 0, 0, 0, "NPOWER\0", 65536, 67, 0, 0, ROMTYPE_SUPERIV, 1, },
        //0xdd16cdec, 0xfd882967,0x87e2da5f,0x4ef6be32,0x5f7c9324,0xb5bd8e64 },
 
-    { "Freezer: HRTMon (built-in)", 0, 0, 0, 0, "HRTMON\0", 0, 63, 0, 0, ROMTYPE_HRTMON, 1,
+    { "Freezer: HRTMon v2.30 (built-in)", 0, 0, 0, 0, "HRTMON\0", 0, 63, 0, 0, ROMTYPE_HRTMON, 1,
        0xffffffff, 0, 0, 0, 0, 0, "HRTMon" },
 
     { "A590/A2091 SCSI boot ROM", 0, 0, 6, 0, "A590\0A2091\0", 16384, 53, 0, 0, ROMTYPE_A2091BOOT, 0,
@@ -2207,7 +2213,7 @@ static shmpiece *find_shmpiece (uae_u8 *base)
     if (!x) {
        write_log ("NATMEM: Failure to find mapping at %p\n",base);
        dumplist ();
-       canbang = 0;
+       nocanbang();
        return 0;
     }
     return x;
@@ -2231,7 +2237,7 @@ static void delete_shmmaps (uae_u32 start, uae_u32 size)
            if (x->size > size) {
                write_log ("NATMEM: Failure to delete mapping at %08x(size %08x, delsize %08x)\n",start,x->size,size);
                dumplist ();
-               canbang = 0;
+               nocanbang();
                return;
            }
            shmdt (x->native_address);
@@ -2272,7 +2278,7 @@ static void add_shmmaps (uae_u32 start, addrbank *what)
     if (y->native_address == (void *) -1) {
        write_log ("NATMEM: Failure to map existing at %08x(%p)\n",start,base);
        dumplist ();
-       canbang = 0;
+       nocanbang();
        return;
     }
     y->next = shm_start;
@@ -2288,12 +2294,14 @@ uae_u8 *mapped_malloc (size_t s, char *file)
     void *answer;
     shmpiece *x;
 
-    if (!canbang)
+    if (!canbang) {
+       nocanbang();
        return xmalloc (s);
+    }
 
     id = shmget (IPC_PRIVATE, s, 0x1ff, file);
     if (id == -1) {
-       canbang = 0;
+       nocanbang();
        return mapped_malloc (s, file);
     }
     answer = shmat (id, 0, 0);
@@ -2308,10 +2316,9 @@ uae_u8 *mapped_malloc (size_t s, char *file)
        if (x->next)
            x->next->prev = x;
        shm_start = x;
-
        return answer;
     }
-    canbang = 0;
+    nocanbang();
     return mapped_malloc (s, file);
 }
 
index eceee1767f81a872359dc77ecc0042157047da5d..1809ad328b61b3b8df5cd5b570e2c5552e65688f 100755 (executable)
--- a/newcpu.c
+++ b/newcpu.c
@@ -232,10 +232,11 @@ static void build_cpufunctbl (void)
            opcnt++;
        }
     }
-    write_log ("Building CPU function table, %d opcodes (%d %d %d). CPU=%d, FPU=%d.\n",
+    write_log ("Building CPU, %d opcodes (%d %d %d). CPU=%d, FPU=%d, JIT=%d.\n",
        opcnt, currprefs.cpu_level,
        currprefs.cpu_cycle_exact ? -1 : currprefs.cpu_compatible ? 1 : 0,
-       currprefs.address_space_24, currprefs.cpu_model, currprefs.fpu_model);
+       currprefs.address_space_24, currprefs.cpu_model, currprefs.fpu_model,
+       currprefs.cachesize);
 #ifdef JIT
     build_comp ();
 #endif
@@ -1147,9 +1148,9 @@ STATIC_INLINE void do_interrupt(int nr, struct regstruct *regs)
     doint();
 }
 
-void Interrupt (int nr)
+void NMI(void)
 {
-    do_interrupt (nr, &regs);
+    do_interrupt (7, &regs);
 }
 
 #ifndef CPUEMU_68000_ONLY
@@ -2011,7 +2012,7 @@ STATIC_INLINE int do_specialties (int cycles, struct regstruct *regs)
            int intr = intlev ();
            unset_special (regs, SPCFLAG_INT | SPCFLAG_DOINT);
            if (intr != -1 && intr > regs->intmask)
-               Interrupt (intr);
+               do_interrupt (intr, regs);
        }
        if ((regs->spcflags & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE))) {
            unset_special (regs, SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
@@ -2439,14 +2440,8 @@ void m68k_go (int may_quit)
            else if (savestate_state == STATE_REWIND)
                savestate_rewind ();
 #endif
-           /* following three lines must not be reordered or
-            * fastram state restore breaks
-            */
            reset_all_systems ();
-           gayle_reset (hardreset);
-           customreset ();
-           if (hardreset)
-               rtc_hardreset();
+           customreset (hardreset);
            m68k_reset (hardreset);
            if (hardreset) {
                memory_hardreset();
@@ -3048,7 +3043,7 @@ void cpureset (void)
     uae_u16 ins;
 
     if (currprefs.cpu_compatible || currprefs.cpu_cycle_exact) {
-        customreset ();
+        customreset (0);
        return;
     }
     pc = m68k_getpc(&regs);
@@ -3056,11 +3051,11 @@ void cpureset (void)
        addrbank *b = &get_mem_bank(pc);
        if (b->check(pc, 2 + 2)) {
            /* We have memory, hope for the best.. */
-           customreset ();
+           customreset (0);
            return;
        }
        write_log("M68K RESET PC=%x, rebooting..\n", pc);
-       customreset ();
+       customreset (0);
        m68k_setpc (&regs, ksboot);
        return;
     }
@@ -3070,14 +3065,14 @@ void cpureset (void)
        int reg = ins & 7;
        uae_u32 addr = m68k_areg (&regs, reg);
        write_log ("reset/jmp (ax) combination emulated -> %x\n", addr);
-       customreset ();
+       customreset (0);
        if (addr < 0x80000)
            addr += 0xf80000;
        m68k_setpc (&regs, addr - 2);
        return;
     }
     write_log("M68K RESET PC=%x, rebooting..\n", pc);
-    customreset ();
+    customreset (0);
     m68k_setpc (&regs, ksboot);
 }
 
index f8d609415a187d27a1268c360d76071a5ee395b8..8ba63f3e97455bf69f5d02c50082988518f1b7e8 100755 (executable)
@@ -1686,6 +1686,26 @@ void logging_cleanup( void )
     debugfile = 0;
 }
 
+uae_u8 *save_log(int *len)
+{
+    FILE *f;
+    uae_u8 *dst;
+    int size;
+
+    f = fopen(LOG_BOOT, "rb");
+    if (!f)
+       return NULL;
+    fseek(f, 0, SEEK_END);
+    size = ftell(f);
+    fseek(f, 0, SEEK_SET);
+    dst = xcalloc(1, size + 1);
+    if (dst)
+       fread(dst, 1, size, f);
+    fclose(f);
+    *len = size + 1;
+    return dst;
+}
+
 typedef DWORD (STDAPICALLTYPE *PFN_GetKey)(LPVOID lpvBuffer, DWORD dwSize);
 uae_u8 *target_load_keyfile (struct uae_prefs *p, char *path, int *sizep, char *name)
 {
index 8d53f06f2628a27a7bd8f38cd03b81e910ea55fb..a81a8fd98d0dec23fa543d214082b783849374b2 100755 (executable)
@@ -15,9 +15,9 @@
 #define GETBDM(x) (((x) - ((x / 10000) * 10000)) / 100)
 #define GETBDD(x) ((x) % 100)
 
-#define WINUAEBETA 9
+#define WINUAEBETA 10
 #define WINUAEPUBLICBETA 1
-#define WINUAEDATE MAKEBD(2007, 7, 10)
+#define WINUAEDATE MAKEBD(2007, 7, 19)
 #define WINUAEEXTRA ""
 #define WINUAEREV ""
 
index 4fd99f3a1ed7e3bce163c9b59c0214730273e889..fc42bd49cc91a74050277e8735405b90e3cac7ab 100755 (executable)
@@ -574,7 +574,7 @@ static void show_rom_list (void)
        8, 9, 10, -1, -1, // A600
        23, 24, -1, -1, // A1000
        11, 31, 15, -1, -1, // A1200
-       61, 32, 59, -1, -1, // A3000
+       61, 59, -1, -1, // A3000
        16, 46, 31, 13, 12, -1, -1, // A4000
        18, -1, 19, -1, -1, // CD32
        20, 21, 22, -1, 6, 32, -1, -1, // CDTV
@@ -5197,7 +5197,7 @@ static void enable_for_cpudlg (HWND hDlg)
 #ifndef JIT
     enable = FALSE;
 #endif
-    enable2 = enable && workprefs.compforcesettings;
+    enable2 = enable && workprefs.compforcesettings && candirect;
 
     ew (hDlg, IDC_TRUST0, enable2);
     ew (hDlg, IDC_TRUST1, enable2);
@@ -5268,7 +5268,7 @@ static void values_to_cpudlg (HWND hDlg)
 
 #ifdef JIT
     if(enable) {
-       if (!canbang) {
+       if (!canbang || !candirect) {
            workprefs.compforcesettings = TRUE;
            workprefs.comptrustbyte = 1;
            workprefs.comptrustword = 1;
@@ -5390,6 +5390,9 @@ static void values_from_cpudlg (HWND hDlg)
     }
     if (oldcache == 0 && workprefs.cachesize > 0)
        canbang = 1;
+    if (!candirect)
+       canbang = 0;
+
 #endif
     workprefs.cpu_idle = SendMessage(GetDlgItem(hDlg, IDC_CPUIDLE), TBM_GETPOS, 0, 0);
     if (workprefs.cpu_idle > 0)
@@ -10185,7 +10188,8 @@ static int fsdialog (HWND *hwnd, DWORD *flags)
     hr = DirectDraw_FlipToGDISurface();
     if (FAILED(hr))
        write_log ("FlipToGDISurface failed, %s\n", DXError (hr));
-    *flags &= ~MB_SETFOREGROUND;
+    *flags |= MB_SETFOREGROUND;
+    *flags |= MB_TOPMOST;
     return 0;
 /*
     HRESULT hr;
index 5f0380814d7355c9df0f3bb575deb37a01514a08..78badfceab5e63ad7f743e9b2f2044f3c0670c28 100755 (executable)
                                RelativePath="..\..\savestate.c"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\scsi.c"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\scsiemul.c"
                                >
                                >
                        </File>
                        <File
-                               RelativePath="..\..\unzip.c"
+                               RelativePath="..\..\zfile.c"
                                >
                        </File>
                        <File
-                               RelativePath="..\..\zfile.c"
+                               RelativePath="..\..\zfile_archive.c"
                                >
                        </File>
                </Filter>
                                >
                        </File>
                </Filter>
-               <Filter
-                       Name="dms"
-                       >
-                       <File
-                               RelativePath="..\..\dms\cdata.h"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\dms\crc_csum.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\dms\getbits.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\dms\maketbl.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\dms\pfile.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\dms\tables.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\dms\u_deep.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\dms\u_heavy.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\dms\u_init.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\dms\u_medium.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\dms\u_quick.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\dms\u_rle.c"
-                               >
-                       </File>
-               </Filter>
                <Filter
                        Name="prowizard"
                        >
                        </Filter>
                </Filter>
                <Filter
-                       Name="7z"
+                       Name="decompressor"
                        >
-                       <File
-                               RelativePath="..\..\7z\7zAlloc.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\7z\7zBuffer.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\7z\7zCrc.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\7z\7zDecode.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\7z\7zExtract.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\7z\7zHeader.c"
+                       <Filter
+                               Name="7z"
                                >
-                       </File>
-                       <File
-                               RelativePath="..\..\7z\7zIn.c"
+                               <File
+                                       RelativePath="..\..\archivers\7z\7zAlloc.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\7z\7zBuffer.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\7z\7zCrc.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\7z\7zDecode.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\7z\7zExtract.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\7z\7zHeader.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\7z\7zIn.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\7z\7zItem.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\7z\7zMain.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\7z\7zMethodID.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\7z\LzmaDecode.c"
+                                       >
+                               </File>
+                       </Filter>
+                       <Filter
+                               Name="dms"
                                >
-                       </File>
-                       <File
-                               RelativePath="..\..\7z\7zItem.c"
+                               <File
+                                       RelativePath="..\..\archivers\dms\crc_csum.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\dms\getbits.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\dms\maketbl.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\dms\pfile.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\dms\tables.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\dms\u_deep.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\dms\u_heavy.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\dms\u_init.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\dms\u_medium.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\dms\u_quick.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\dms\u_rle.c"
+                                       >
+                               </File>
+                       </Filter>
+                       <Filter
+                               Name="lha"
                                >
-                       </File>
-                       <File
-                               RelativePath="..\..\7z\7zMethodID.c"
+                               <File
+                                       RelativePath="..\..\archivers\lha\crcio.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\lha\dhuf.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\lha\header.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\lha\huf.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\lha\larc.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\lha\lhamaketbl.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\lha\lharc.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\lha\shuf.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\lha\slide.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\lha\uae_lha.c"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\..\archivers\lha\util.c"
+                                       >
+                               </File>
+                       </Filter>
+                       <Filter
+                               Name="lzx"
                                >
-                       </File>
-                       <File
-                               RelativePath="..\..\7z\LzmaDecode.c"
+                               <File
+                                       RelativePath="..\..\archivers\lzx\unlzx.c"
+                                       >
+                               </File>
+                       </Filter>
+                       <Filter
+                               Name="zip"
                                >
-                       </File>
+                               <File
+                                       RelativePath="..\..\archivers\zip\unzip.c"
+                                       >
+                               </File>
+                       </Filter>
                </Filter>
                <File
                        RelativePath="..\resources\drive_click.wav"
                        RelativePath="..\resources\drive_startup.wav"
                        >
                </File>
-               <File
-                       RelativePath="..\resources\resource"
-                       >
-               </File>
                <File
                        RelativePath="..\resources\resource.h"
                        >
index ea0b6066f55b4a3afc33e3939466d76b1d9ab10b..5df4887fc0a1241a572654a1c32ce22c9c1194f6 100755 (executable)
@@ -1,4 +1,34 @@
 
+Beta 10:
+
+- Arcadia emulation crash fixed
+- SCSI emulator MODE SENSE code 3 and 4 crash fix (uaehf.device only)
+- A3000 KS 1.3 ROM removed from rom scan "available"-list (only
+  proper A3000 ROMs, 1.4b and 3.1 included)
+- added missing version numbers to cartridge roms
+- xBCD instruction 68040/060 undefined behaviour emulated, N and V
+  flags are not cleared. (from Basilisk II JIT)
+- JIT LSL, LSR, ASR X-flag was incorrectly modified when shift count
+  was zero (from Basilisk II JIT)
+- configuration and bootlog (text format) saved with statefile
+  (compressed, few kb size increase, only for debugging purposes)
+  NOTE: fake END-hunk inserted before CONF and LOG hunks, you can
+  simply delete all "useless" data after first END-hunk without
+  corrupting the statefile.
+- action replay/hrtmon statefile hunks are now compressed
+- drive GUI properly initialized when restoring state (disabled
+  drives are "blanked", no track number visible)
+- empty drive disk change status was incorrect in some cases when
+  restoring state (load state, OS detects disk in empty drive)
+- do not allow JIT direct mode if emulation was originally started
+  without JIT direct enabled (different memory allocation which is not
+  compatible with direct = crashes. Will be properly fixed in future)
+- uaescsi.device SCSI mode selection reset after loading new config
+- messagebox in fullscreen mode tweaks, perhaps fixes problem with
+  hidden "too old rtg.library" messagebox in fullscreen mode
+- close native-side open filehandles after software reset
+  (fixes locked startup-sequence after directory fs setpatch reset)
+
 Beta 9:
 
 - ROM scan dialog listed "available" even if configuration required
@@ -120,7 +150,6 @@ Beta 5:
 - included beta updated rtg.library, fully enables >1024 pixel wide
   bitmaps (including acceleration), obsoletes picasso96fix. (BR)
 
-
 Beta 4:
 
 - return SCSI-1 style inquiry response when using A590/A2091 SCSI
index 409e1f9c1d02eec2da647d1521b02d60c5d44576..258bd45a09f1acaf9cc4c45eeabf285a46269396 100755 (executable)
@@ -308,11 +308,17 @@ static uae_u8 *restore_chunk (struct zfile *f, char *name, size_t *len, size_t *
        && strcmp (name, "BRAM") != 0
        && strcmp (name, "FRAM") != 0
        && strcmp (name, "ZRAM") != 0
-       && strcmp (name, "PRAM") != 0)
+       && strcmp (name, "PRAM") != 0
+       && strcmp (name, "A3K1") != 0
+       && strcmp (name, "A3K2") != 0)
     {
        /* without zeros at the end old state files may not work */
-       mem = (uae_u8*)calloc (1, len2 + 32);
-       zfile_fread (mem, 1, len2, f);
+       mem = (uae_u8*)calloc (1, *totallen + 32);
+       if (flags & 1) {
+           zfile_zuncompress (mem, *totallen, f, len2);
+       } else {
+           zfile_fread (mem, 1, len2, f);
+       }
     } else {
        mem = 0;
        zfile_fseek (f, len2, SEEK_CUR);
@@ -505,8 +511,14 @@ void restore_state (char *filename)
            end = restore_gayle (chunk);
        else if (!strcmp (name, "IDE "))
            end = restore_ide (chunk);
-       else
+       else if (!strcmp (name, "CONF"))
+           end = restore_configuration (chunk);
+       else if (!strcmp (name, "LOG "))
+           end = chunk + len;
+       else {
+           end = chunk + len;
            write_log ("unknown chunk '%s' size %d bytes\n", name, len);
+       }
        if (len != end - chunk)
            write_log ("Chunk '%s' total size %d bytes but read %d bytes!\n",
                       name, len, end - chunk);
@@ -575,6 +587,7 @@ static void save_rams (struct zfile *f, int comp)
 
 int save_state (char *filename, char *description)
 {
+    uae_u8 endhunk[] = { 'E', 'N', 'D', ' ', 0, 0, 0, 8 };
     uae_u8 header[1000];
     char tmp[100];
     uae_u8 *dst;
@@ -704,9 +717,9 @@ int save_state (char *filename, char *description)
 
 #ifdef ACTION_REPLAY
     dst = save_action_replay (&len, 0);
-    save_chunk (f, dst, len, "ACTR", 0);
+    save_chunk (f, dst, len, "ACTR", 1);
     dst = save_hrtmon (&len, 0);
-    save_chunk (f, dst, len, "HRTM", 0);
+    save_chunk (f, dst, len, "HRTM", 1);
 #endif
 #ifdef FILESYS
     dst = save_filesys_common (&len);
@@ -734,8 +747,23 @@ int save_state (char *filename, char *description)
        }
     }
 
-    zfile_fwrite ("END ", 1, 4, f);
-    zfile_fwrite ("\0\0\0\08", 1, 4, f);
+    /* add fake END tag, makes it easy to strip CONF and LOG hunks */
+    /* move this if you want to use CONF or LOG hunks when restoring state */
+    zfile_fwrite (endhunk, 1, 8, f);
+
+    dst = save_configuration (&len);
+    if (dst) {
+       save_chunk (f, dst, len, "CONF", 1);
+       xfree(dst);
+    }
+    dst = save_log (&len);
+    if (dst) {
+       save_chunk (f, dst, len, "LOG ", 1);
+       xfree(dst);
+    }
+
+    zfile_fwrite (endhunk, 1, 8, f);
+
     write_log ("Save of '%s' complete\n", filename);
     zfile_fclose (f);
     savestate_state = 0;
@@ -1324,7 +1352,7 @@ INTERNAL FLOPPY   CONTROLLER STATUS
 
 RAM SPACE
 
-       "xRAM" (CRAM = chip, BRAM = bogo, FRAM = fast, ZFRAM = Z3)
+       "xRAM" (CRAM = chip, BRAM = bogo, FRAM = fast, ZRAM = Z3, P96 = RTG RAM, A3K1/A3K2 = MB RAM)
 
        start address           4 ("bank"=chip/slow/fast etc..)
        of RAM "bank"
diff --git a/zfile.c b/zfile.c
index 5d9672c4b86361d4e3fcb20c1f026046c5a82391..613f2e490b64a9cfd36a23227a745c000328de4c 100755 (executable)
--- a/zfile.c
+++ b/zfile.c
@@ -137,7 +137,7 @@ int zfile_gettype (struct zfile *z)
     return ZFILE_UNKNOWN;
 }
 
-static struct zfile *zuncompress (struct zfile *z);
+static struct zfile *zuncompress (struct zfile *z, int);
 
 struct zfile *zfile_gunzip (struct zfile *z)
 {
@@ -303,7 +303,7 @@ static int iszip (struct zfile *z)
     return 0;
 }
 
-static struct zfile *zuncompress (struct zfile *z)
+static struct zfile *zuncompress (struct zfile *z, int dodefault)
 {
     char *name = z->name;
     char *ext = strrchr (name, '.');
@@ -313,15 +313,15 @@ static struct zfile *zuncompress (struct zfile *z)
     if (ext != NULL) {
        ext++;
        if (strcasecmp (ext, "7z") == 0)
-            return archive_access_select (z, ArchiveFormat7Zip);
+            return archive_access_select (z, ArchiveFormat7Zip, dodefault);
        if (strcasecmp (ext, "zip") == 0)
-            return archive_access_select (z, ArchiveFormatZIP);
+            return archive_access_select (z, ArchiveFormatZIP, dodefault);
        if (strcasecmp (ext, "lha") == 0 || strcasecmp (ext, "lzh") == 0)
-            return archive_access_select (z, ArchiveFormatLHA);
+            return archive_access_select (z, ArchiveFormatLHA, dodefault);
        if (strcasecmp (ext, "lzx") == 0)
-            return archive_access_select (z, ArchiveFormatLZX);
+            return archive_access_select (z, ArchiveFormatLZX, dodefault);
        if (strcasecmp (ext, "rar") == 0)
-            return archive_access_select (z, ArchiveFormatRAR);
+            return archive_access_select (z, ArchiveFormatRAR, dodefault);
        if (strcasecmp (ext, "gz") == 0)
             return zfile_gunzip (z);
        if (strcasecmp (ext, "adz") == 0)
@@ -345,15 +345,15 @@ static struct zfile *zuncompress (struct zfile *z)
        if (header[0] == 0x1f && header[1] == 0x8b)
            return zfile_gunzip (z);
        if (header[0] == 'P' && header[1] == 'K')
-            return archive_access_select (z, ArchiveFormatZIP);
+            return archive_access_select (z, ArchiveFormatZIP, dodefault);
        if (header[0] == 'R' && header[1] == 'a' && header[2] == 'r' && header[3] == '!')
-            return archive_access_select (z, ArchiveFormatRAR);
+            return archive_access_select (z, ArchiveFormatRAR, dodefault);
        if (header[0] == 'D' && header[1] == 'M' && header[2] == 'S' && header[3] == '!')
            return dms (z);
        if (header[0] == 'L' && header[1] == 'Z' && header[2] == 'X')
-            return archive_access_select (z, ArchiveFormatLZX);
+            return archive_access_select (z, ArchiveFormatLZX, dodefault);
        if (header[2] == '-' && header[3] == 'l' && header[4] == 'h' && header[6] == '-')
-            return archive_access_select (z, ArchiveFormatLHA);
+            return archive_access_select (z, ArchiveFormatLHA, dodefault);
     }
     return z;
 }
@@ -494,6 +494,7 @@ static void manglefilename(char *out, const char *in)
 #else
 static void manglefilename(char *out, const char *in)
 {
+    strcpy(out, in);
 }
 #endif
 
@@ -528,7 +529,7 @@ struct zfile *zfile_fopen (const char *name, const char *mode)
     l = zfile_fopen_2 (path, mode);
     if (!l)
        return 0;
-    l = zuncompress (l);
+    l = zuncompress (l, 0);
     return l;
 }
 
index 5324bb5f61532a8571e1922b1b08249a0226aa12..9fb21f9d40da56dc47e571e9bdfdab2917acbdb6 100755 (executable)
@@ -100,7 +100,7 @@ struct zfile *archive_getzfile(struct znode *zn, unsigned int id)
     return zf;
 }
 
-struct zfile *archive_access_select (struct zfile *zf, unsigned int id)
+struct zfile *archive_access_select (struct zfile *zf, unsigned int id, int dodefault)
 {
     struct zvolume *zv;
     struct znode *zn;
@@ -166,6 +166,9 @@ struct zfile *archive_access_select (struct zfile *zf, unsigned int id)
     if (z) {
        zfile_fclose(zf);
        zf = z;
+    } else if (!dodefault && zf->zipname && zf->zipname[0]) {
+       zfile_fclose(zf);
+       zf = NULL;
     }
     return zf;
 }
@@ -830,8 +833,8 @@ struct zvolume *archive_directory_plain (struct zfile *z)
     zfile_fseek(z, 0, SEEK_SET);
     zn = zvolume_addfile_abs(zv, &zai);
     if (!memcmp (id, exeheader, sizeof id)) {
-       uae_u8 *data = xmalloc(strlen(filename) + 2);
-       sprintf(data,"%s\n", filename);
+       uae_u8 *data = xmalloc(1 + strlen(filename) + 1 + 2);
+       sprintf(data,"\"%s\"\n", filename);
        addfile(zv, "s/startup-sequence", data, strlen(data));
        xfree(data);
     }