From: Toni Wilen Date: Sun, 13 Jun 2004 09:15:59 +0000 (+0300) Subject: imported winuaesrc0828b1.zip X-Git-Tag: 2100~346 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=a99189c294d6c3256340e802c92db9dab9b3e624;p=francis%2Fwinuae.git imported winuaesrc0828b1.zip --- diff --git a/ar.c b/ar.c index ddea11ce..d05503a2 100755 --- a/ar.c +++ b/ar.c @@ -1608,11 +1608,14 @@ uae_u8 *save_action_replay (int *len, uae_u8 *dstptr) strcpy (dst, currprefs.cartfile); dst += strlen(dst) + 1; memcpy (dst, armemory_ram, arram_size); + save_u32 (0); return dstbak; } uae_u8 *restore_action_replay (uae_u8 *src) { + uae_u32 crc32; + action_replay_unload (1); armodel = restore_u8 (); if (!armodel) @@ -1620,6 +1623,7 @@ uae_u8 *restore_action_replay (uae_u8 *src) strncpy (changed_prefs.cartfile, src, 255); strcpy (currprefs.cartfile, changed_prefs.cartfile); src += strlen(src) + 1; + crc32 = restore_u32 (); action_replay_load (); if (armemory_ram) { memcpy (armemory_ram, src, arram_size); diff --git a/blitter.c b/blitter.c index cfd3b592..6c7dc53f 100755 --- a/blitter.c +++ b/blitter.c @@ -10,6 +10,8 @@ //#define BLITTER_DEBUG //#define BLITTER_SLOWDOWNDEBUG 4 +#define SPEEDUP + #include "sysconfig.h" #include "sysdeps.h" @@ -207,9 +209,12 @@ static void blitter_dofast(void) bltdpt += (blt_info.hblitsize*2 + blt_info.bltdmod)*blt_info.vblitsize; } - if (blitfunc_dofast[mt] && !blitfill) +#ifdef SPEEDUP + if (blitfunc_dofast[mt] && !blitfill) { (*blitfunc_dofast[mt])(bltadatptr, bltbdatptr, bltcdatptr, bltddatptr, &blt_info); - else { + } else +#endif + { uae_u32 blitbhold = blt_info.bltbhold; uae_u32 preva = 0, prevb = 0; uaecptr dstp = 0; @@ -298,15 +303,17 @@ static void blitter_dofast_desc(void) bltddatptr = bltdpt; bltdpt -= (blt_info.hblitsize*2 + blt_info.bltdmod)*blt_info.vblitsize; } - if (blitfunc_dofast_desc[mt] && !blitfill) +#ifdef SPEEDUP + if (blitfunc_dofast_desc[mt] && !blitfill) { (*blitfunc_dofast_desc[mt])(bltadatptr, bltbdatptr, bltcdatptr, bltddatptr, &blt_info); - else { + } else +#endif + { uae_u32 blitbhold = blt_info.bltbhold; uae_u32 preva = 0, prevb = 0; uaecptr dstp = 0; int dodst = 0; -/* if (!blitfill) write_log ("minterm %x not present\n",mt);*/ for (j = 0; j < blt_info.vblitsize; j++) { blitfc = !!(bltcon1 & 0x4); for (i = 0; i < blt_info.hblitsize; i++) { diff --git a/build68k.c b/build68k.c index 13848b2d..7f1ae16b 100755 --- a/build68k.c +++ b/build68k.c @@ -213,6 +213,7 @@ int main(int argc, char **argv) int j; /* Remove superfluous spaces from the string */ char *opstrp = opcstr, *osendp; + char tmp[100], *p; int slen = 0; while (isspace(*opstrp)) @@ -229,17 +230,23 @@ int main(int argc, char **argv) if (no_insns > 0) printf(",\n"); no_insns++; - printf("{ %d, %d, {", bitpattern, n_variable); + strcpy (tmp, opstrp); + strcat (tmp, " "); + p = tmp; + while (!isspace(*p++)); + *p = 0; + printf("/* %s */\n", tmp); + printf("{0x%04.4X,%2d,{", bitpattern, n_variable); for (j = 0; j < 16; j++) { - printf("%d", bitpos[j]); + printf("%2d", bitpos[j]); if (j < 15) printf(","); } - printf ("}, %d, %d, %d, { ", bitmask, cpulevel, plevel); + printf ("},0x%04.4X,%d,%d,{", bitmask, cpulevel, plevel); for(i = 0; i < 5; i++) { - printf("{ %d, %d }%c ", flaguse[i], flagset[i], i == 4 ? ' ' : ','); + printf("{%d,%d}%s", flaguse[i], flagset[i], i == 4 ? "" : ","); } - printf("}, %d, \"%s\"}", sduse, opstrp); + printf("},%2d,\"%s\"}", sduse, opstrp); } } printf("};\nint n_defs68k = %d;\n", no_insns); diff --git a/cfgfile.c b/cfgfile.c index 0f4124f9..7d7c9bc1 100755 --- a/cfgfile.c +++ b/cfgfile.c @@ -143,9 +143,9 @@ static const char *filtermode2[] = { "0x", "1x", "2x", "3x", "4x", 0 }; #endif static const char *obsolete[] = { - "accuracy","gfx_opengl","gfx_32bit_blits","32bit_blits", - "gfx_immediate_blits","gfx_ntsc","win32", - "sound_pri_cutoff", "sound_pri_time", 0 }; + "accuracy", "gfx_opengl", "gfx_32bit_blits", "32bit_blits", + "gfx_immediate_blits", "gfx_ntsc", "win32", "gfx_filter_bits", + "sound_pri_cutoff", "sound_pri_time", "sound_min_buff", 0 }; #define UNEXPANDED "$(FILE_PATH)" @@ -1712,6 +1712,51 @@ uae_u32 cfgfile_uaelib(int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen) return 0; } +static int configure_rom (struct uae_prefs *p, int *rom, int msg) +{ + struct romdata *rd; + char tmp1[MAX_DPATH], tmp2[MAX_DPATH]; + char *path = 0; + int i; + + tmp2[0] = 0; + i = 0; + while (rom[i] >= 0) { + rd = getromdatabyid (rom[i]); + if (!rd) { + i++; + continue; + } + path = romlist_get (rd); + if (!path) { + getromname (rd, tmp1); + strcat (tmp2, "- "); + strcat (tmp2, tmp1); + strcat (tmp2, "\n"); + i++; + continue; + } + break; + } + if (!path) { + if (msg) + gui_message ("You need any of following ROM(s)\n\n%s", tmp2); + return 0; + } + switch (rd->type) + { + case ROMTYPE_KICK: + case ROMTYPE_KICKCD32: + strcpy (p->romfile, path); + break; + case ROMTYPE_EXTCD32: + case ROMTYPE_EXTCDTV: + strcpy (p->romextfile, path); + break; + } + return 1; +} + static void default_prefs_mini (struct uae_prefs *p, int type) { strcpy (p->description, "UAE default A500 configuration"); @@ -1729,6 +1774,8 @@ static void default_prefs_mini (struct uae_prefs *p, int type) void default_prefs (struct uae_prefs *p, int type) { + int roms[] = { 6, 7, 8, 9, 10, 14, 5, 4, 3, 2, 1 }; + memset (p, 0, sizeof (*p)); strcpy (p->description, "UAE default configuration"); @@ -1737,7 +1784,8 @@ void default_prefs (struct uae_prefs *p, int type) p->all_lines = 0; /* Note to porters: please don't change any of these options! UAE is supposed - * to behave identically on all platforms if possible. */ + * to behave identically on all platforms if possible. + * (TW says: maybe it is time to update default config..) */ p->illegal_mem = 0; p->no_xhair = 0; p->use_serial = 0; @@ -1790,13 +1838,13 @@ void default_prefs (struct uae_prefs *p, int type) p->gfx_width_win = p->gfx_width_fs = 800; p->gfx_height_win = p->gfx_height_fs = 600; p->gfx_lores = 0; - p->gfx_linedbl = 2; + p->gfx_linedbl = 1; p->gfx_afullscreen = 0; p->gfx_pfullscreen = 0; p->gfx_correct_aspect = 0; p->gfx_xcenter = 0; p->gfx_ycenter = 0; - p->color_mode = 0; + p->color_mode = 2; p->x11_use_low_bandwidth = 0; p->x11_use_mitshm = 0; @@ -1829,7 +1877,7 @@ void default_prefs (struct uae_prefs *p, int type) strcpy (p->df[2], "df2.adf"); strcpy (p->df[3], "df3.adf"); - strcpy (p->romfile, "kick.rom"); + configure_rom (p, roms, 0); strcpy (p->keyfile, ""); strcpy (p->romextfile, ""); strcpy (p->flashfile, ""); @@ -1842,20 +1890,10 @@ void default_prefs (struct uae_prefs *p, int type) strcpy (p->prtname, DEFPRTNAME); strcpy (p->sername, DEFSERNAME); -#ifdef CPUEMU_68000_ONLY p->cpu_level = 0; p->m68k_speed = 0; -#else - p->m68k_speed = -1; - p->cpu_level = 2; -#endif -#ifdef CPUEMU_0 - p->cpu_compatible = 0; - p->address_space_24 = 0; -#else p->cpu_compatible = 1; p->address_space_24 = 1; -#endif p->cpu_cycle_exact = 0; p->blitter_cycle_exact = 0; p->chipset_mask = CSMASK_ECS_AGNUS; @@ -1863,8 +1901,8 @@ void default_prefs (struct uae_prefs *p, int type) p->fastmem_size = 0x00000000; p->a3000mem_size = 0x00000000; p->z3fastmem_size = 0x00000000; - p->chipmem_size = 0x00200000; - p->bogomem_size = 0x00000000; + p->chipmem_size = 0x00080000; + p->bogomem_size = 0x00080000; p->gfxmem_size = 0x00000000; p->nr_floppies = 2; @@ -1889,3 +1927,227 @@ void default_prefs (struct uae_prefs *p, int type) inputdevice_default_prefs (p); } + +static void buildin_default_prefs_68020 (struct uae_prefs *p) +{ + p->cpu_level = 2; + p->cpu_compatible = 1; + p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE | CSMASK_AGA; + p->chipmem_size = 0x200000; + p->bogomem_size = 0; + p->m68k_speed = -1; +} + +static void buildin_default_prefs (struct uae_prefs *p) +{ + p->nr_floppies = 1; + p->dfxtype[0] = 0; + p->dfxtype[1] = -1; + p->dfxtype[2] = -1; + p->dfxtype[3] = -1; + + p->cpu_level = 0; + p->m68k_speed = 0; + p->cpu_compatible = 1; + p->address_space_24 = 1; + p->cpu_cycle_exact = 0; + p->blitter_cycle_exact = 0; + p->chipset_mask = CSMASK_ECS_AGNUS; + p->immediate_blits = 0; + p->collision_level = 2; + p->fast_copper = 1; + p->produce_sound = 3; + p->scsi = 0; + p->cpu_idle = 0; + p->catweasel_io = 0; + p->tod_hack = 0; + p->maprom = 0; + + p->chipmem_size = 0x00080000; + p->bogomem_size = 0x00080000; + p->fastmem_size = 0x00000000; + p->a3000mem_size = 0x00000000; + p->z3fastmem_size = 0x00000000; + p->gfxmem_size = 0x00000000; + + strcpy (p->romfile, ""); + strcpy (p->keyfile, ""); + strcpy (p->romextfile, ""); + strcpy (p->flashfile, ""); + strcpy (p->cartfile, ""); + strcpy (p->prtname, DEFPRTNAME); + strcpy (p->sername, DEFSERNAME); +} + +static void set_68020_compa (struct uae_prefs *p, int compa) +{ + if (compa == 0) + p->blitter_cycle_exact = 1; + if (compa > 0) { + p->cpu_compatible = 0; + p->address_space_24 = 0; + p->cachesize = 8192; + } + if (compa > 1) { + p->immediate_blits = 1; + p->produce_sound = 2; + } +} + +static void set_68000_compa (struct uae_prefs *p, int compa) +{ + if (compa == 0) { + p->cpu_cycle_exact = p->blitter_cycle_exact = 1; + p->fast_copper = 0; + } else if (compa == 2) { + p->immediate_blits = 1; + p->produce_sound = 2; + p->cpu_compatible = 0; + } +} + +static int bip_a1000 (struct uae_prefs *p, int config, int compa) +{ + int rom[4]; + + rom[0] = 23; + rom[1] = 24; + rom[2] = -1; + p->chipset_mask = 0; + p->bogomem_size = 0; + if (config == 1) + p->chipmem_size = 0x40000; + set_68000_compa (p, compa); + return configure_rom (p, rom, 1); +} + +static int bip_cdtv (struct uae_prefs *p, int config, int compa) +{ + int rom[4]; + + rom[0] = 6; + rom[1] = -1; + if (!configure_rom (p, rom, 1)) + return 0; + rom[0] = 22; + rom[1] = 21; + rom[2] = 20; + rom[3] = -1; + if (!configure_rom (p, rom, 1)) + return 0; + p->bogomem_size = 0; + p->chipmem_size = 0x100000; + p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE; + set_68000_compa (p, compa); + return 1; +} + + +static int bip_cd32 (struct uae_prefs *p, int config, int compa) +{ + int rom[2]; + + buildin_default_prefs_68020 (p); + rom[0] = 18; + rom[1] = -1; + if (!configure_rom (p, rom, 1)) + return 0; + rom[0] = 19; + if (!configure_rom (p, rom, 1)) + return 0; + p->nr_floppies = 0; + p->dfxtype[0] = -1; + set_68020_compa (p, compa); + return 1; +} + +static int bip_a1200 (struct uae_prefs *p, int config, int compa) +{ + int rom[3]; + + buildin_default_prefs_68020 (p); + rom[0] = 11; + rom[1] = 15; + rom[2] = -1; + if (config == 1) + p->fastmem_size = 0x400000; + set_68020_compa (p, compa); + return configure_rom (p, rom, 1); +} + +static int bip_a600 (struct uae_prefs *p, int config, int compa) +{ + int rom[5]; + + rom[0] = 10; + rom[1] = 9; + rom[2] = 8; + rom[3] = 7; + rom[4] = -1; + p->bogomem_size = 0; + p->chipmem_size = 0x100000; + p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE; + set_68000_compa (p, compa); + return configure_rom (p, rom, 1); +} + +static int bip_a500 (struct uae_prefs *p, int config, int compa) +{ + int rom[4]; + + rom[0] = rom[1] = rom[2] = rom[3] = -1; + switch (config) + { + case 0: // KS 1.3, ECS Agnus, 0.5M Chip + 0.5M Slow + rom[0] = 6; + break; + case 1: // KS 1.3, OCS Agnus, 0.5M Chip + rom[0] = 6; + p->bogomem_size = 0; + p->chipset_mask = 0; + break; + case 2: // KS 1.3, ECS Agnus, 1.0M Chip + rom[0] = 6; + p->bogomem_size = 0; + p->chipmem_size = 0x100000; + break; + case 3: // KS 1.2, OCS Agnus, 0.5M Chip + rom[0] = 5; + rom[1] = 4; + rom[2] = 3; + p->bogomem_size = 0; + p->chipset_mask = 0; + break; + case 4: // KS 1.2, OCS Agnus, 0.5M Chip + 0.5M Slow + rom[0] = 5; + rom[1] = 4; + rom[2] = 3; + p->chipset_mask = 0; + break; + } + set_68000_compa (p, compa); + return configure_rom (p, rom, 1); +} + +int build_in_prefs (struct uae_prefs *p, int model, int config, int compa) +{ + if (model > 5) + return 1; + buildin_default_prefs (p); + switch (model) + { + case 0: + return bip_a500 (p, config, compa); + case 1: + return bip_a600 (p, config, compa); + case 2: + return bip_a1000 (p, config, compa); + case 3: + return bip_a1200 (p, config, compa); + case 4: + return bip_cd32 (p, config, compa); + case 5: + return bip_cdtv (p, config, compa); + } + return 0; +} \ No newline at end of file diff --git a/cia.c b/cia.c index 94fce460..33986ffd 100755 --- a/cia.c +++ b/cia.c @@ -432,11 +432,6 @@ static void bfe001_change (void) } } -#ifdef PARALLEL_PORT -extern int isprinter (void); -extern int doprinter (uae_u8); -#endif - static uae_u8 ReadCIAA (unsigned int addr) { unsigned int tmp; diff --git a/crc32.c b/crc32.c new file mode 100755 index 00000000..18729a1c --- /dev/null +++ b/crc32.c @@ -0,0 +1,27 @@ + +#include "sysconfig.h" +#include "sysdeps.h" + +static unsigned long crc_table[256]; +static void make_crc_table() +{ + unsigned long c; + int n, k; + for (n = 0; n < 256; n++) + { + c = (unsigned long)n; + for (k = 0; k < 8; k++) c = (c >> 1) ^ (c & 1 ? 0xedb88320 : 0); + crc_table[n] = c; + } +} +uae_u32 get_crc32 (uae_u8 *buf, int len) +{ + uae_u32 crc; + if (!crc_table[1]) + make_crc_table(); + crc = 0xffffffff; + while (len-- > 0) { + crc = crc_table[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8); + } + return crc ^ 0xffffffff; +} diff --git a/custom.c b/custom.c index 059e69d5..e14849d6 100755 --- a/custom.c +++ b/custom.c @@ -2162,7 +2162,7 @@ void compute_vsynctime (void) { fake_vblank_hz = 0; if (currprefs.gfx_vsync && currprefs.gfx_afullscreen && currprefs.gfx_refreshrate) { - vblank_hz = currprefs.gfx_refreshrate; + vblank_hz = abs (currprefs.gfx_refreshrate); vblank_skip = 1; #if 0 if (vblank_hz == 75) { @@ -2362,9 +2362,8 @@ STATIC_INLINE uae_u16 VPOSR (void) int vp = (vpos >> 8) & 7; #ifdef AGA csbit |= (currprefs.chipset_mask & CSMASK_AGA) ? 0x2300 : 0; -#else - csbit |= (currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? 0x2000 : 0; #endif + csbit |= (currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? 0x2000 : 0; if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS)) vp &= 1; vp = vp | lof | csbit; diff --git a/disk.c b/disk.c index 511cba1e..be921d69 100755 --- a/disk.c +++ b/disk.c @@ -39,6 +39,7 @@ #ifdef CAPS #include "caps/caps_win32.h" #endif +#include "crc32.h" /* support HD floppies */ #define FLOPPY_DRIVE_HD @@ -76,7 +77,7 @@ static int side, direction, writing; static uae_u8 selected = 15, disabled; -static uae_u8 *writebuffer[544 * 11 * DDHDMULT]; +static uae_u8 writebuffer[544 * 11 * DDHDMULT]; #define DISK_INDEXSYNC 1 #define DISK_WORDSYNC 2 @@ -534,7 +535,7 @@ static void drive_image_free (drive *drv) drv->writediskfile = 0; } -static int drive_insert (drive * drv, int dnum, const char *fname); +static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char *fname); static void reset_drive(int i) { @@ -554,7 +555,7 @@ static void reset_drive(int i) drive_settype_id (drv); if (strlen (drv->newname) > 0) strcpy (currprefs.df[i], drv->newname); - if (!drive_insert (drv, i, currprefs.df[i])) + if (!drive_insert (drv, &currprefs, i, currprefs.df[i])) disk_eject (i); } @@ -650,8 +651,9 @@ static int read_header_ext2 (struct zfile *diskfile, trackid *trackdata, int *nu static char *getwritefilename (const char *name) { - static char name1[1024]; - char name2[1024]; + static char name1[MAX_DPATH]; + char name2[MAX_DPATH]; + char path[MAX_DPATH]; int i; strcpy (name2, name); @@ -670,7 +672,8 @@ static char *getwritefilename (const char *name) } i--; } - sprintf (name1, "%sSaveImages%c%s_save.adf", start_path, FSDB_DIR_SEPARATOR, name2 + i); + fetch_saveimagepath (path, sizeof (path), 1); + sprintf (name1, "%s%s_save.adf", path, name2 + i); return name1; } @@ -765,7 +768,7 @@ static int diskfile_iswriteprotect (const char *fname, int *needwritefile, drive return wrprot1; } -static int drive_insert (drive * drv, int dnum, const char *fname) +static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char *fname) { unsigned char buffer[2 + 2 + 4 + 4]; trackid *tid; @@ -775,7 +778,7 @@ static int drive_insert (drive * drv, int dnum, const char *fname) drv->diskfile = DISK_validate_filename (fname, 1, &drv->wrprot); drv->ddhd = 1; drv->num_secs = 0; - drv->hard_num_cyls = currprefs.dfxtype[dnum] == DRV_525_SD ? 40 : 80; + drv->hard_num_cyls = p->dfxtype[dnum] == DRV_525_SD ? 40 : 80; drv->tracktiming[0] = 0; drv->useturbo = 0; drv->indexoffset = 0; @@ -1283,83 +1286,93 @@ static void diskfile_update (struct zfile *diskfile, trackid *ti, int len, uae_u } #define MFMMASK 0x55555555 -static uae_u32 getmfmlong (uae_u16 * mbuf) +static uae_u16 getmfmword (uae_u16 *mbuf, int shift) { - return ((*mbuf << 16) | *(mbuf + 1)) & MFMMASK; + return (mbuf[0] << shift) | (mbuf[1] >> (16 - shift)); } -static int drive_write_adf_amigados (drive * drv) +static uae_u32 getmfmlong (uae_u16 *mbuf, int shift) +{ + return ((getmfmword (mbuf, shift) << 16) | getmfmword (mbuf + 1, shift)) & MFMMASK; +} + +static int decode_buffer (uae_u16 *mbuf, int cyl, int drvsec, int ddhd, int filetype, int *drvsecp) { int i, secwritten = 0; - int fwlen = FLOPPY_WRITE_LEN * drv->ddhd; + int fwlen = FLOPPY_WRITE_LEN * ddhd; int length = 2 * fwlen; - int drvsec = drv->num_secs; uae_u32 odd, even, chksum, id, dlong; uae_u8 *secdata; uae_u8 secbuf[544]; - uae_u16 *mbuf = drv->bigmfmbuf; uae_u16 *mend = mbuf + length; char sectable[22]; + int shift = 0; - if (!drvsec) - return 2; memset (sectable, 0, sizeof (sectable)); memcpy (mbuf + fwlen, mbuf, fwlen * sizeof (uae_u16)); mend -= (4 + 16 + 8 + 512); while (secwritten < drvsec) { int trackoffs; - do { - while (*mbuf++ != 0x4489) { - if (mbuf >= mend) - return 1; + while (getmfmword (mbuf, shift) != 0x4489) { + if (mbuf >= mend) + return 1; + shift++; + if (shift == 16) { + shift = 0; + mbuf++; } - } while (*mbuf++ != 0x4489); + } + while (getmfmword (mbuf, shift) == 0x4489) { + if (mbuf >= mend) + return 1; + mbuf++; + } - odd = getmfmlong (mbuf); - even = getmfmlong (mbuf + 2); + odd = getmfmlong (mbuf, shift); + even = getmfmlong (mbuf + 2, shift); mbuf += 4; id = (odd << 1) | even; trackoffs = (id & 0xff00) >> 8; if (trackoffs + 1 > drvsec) { write_log ("Disk write: weird sector number %d\n", trackoffs); - if (drv->filetype == ADF_EXT2) + if (filetype == ADF_EXT2) return 2; continue; } chksum = odd ^ even; for (i = 0; i < 4; i++) { - odd = getmfmlong (mbuf); - even = getmfmlong (mbuf + 8); + odd = getmfmlong (mbuf, shift); + even = getmfmlong (mbuf + 8, shift); mbuf += 2; dlong = (odd << 1) | even; if (dlong) { - if (drv->filetype == ADF_EXT2) + if (filetype == ADF_EXT2) return 6; secwritten = -200; } chksum ^= odd ^ even; } /* could check here if the label is nonstandard */ mbuf += 8; - odd = getmfmlong (mbuf); - even = getmfmlong (mbuf + 2); + odd = getmfmlong (mbuf, shift); + even = getmfmlong (mbuf + 2, shift); mbuf += 4; - if (((odd << 1) | even) != chksum || ((id & 0x00ff0000) >> 16) != drv->cyl * 2 + side) { + if (((odd << 1) | even) != chksum || ((id & 0x00ff0000) >> 16) != cyl * 2 + side) { write_log ("Disk write: checksum error on sector %d header\n", trackoffs); - if (drv->filetype == ADF_EXT2) + if (filetype == ADF_EXT2) return 3; continue; } - odd = getmfmlong (mbuf); - even = getmfmlong (mbuf + 2); + odd = getmfmlong (mbuf, shift); + even = getmfmlong (mbuf + 2, shift); mbuf += 4; chksum = (odd << 1) | even; secdata = secbuf + 32; for (i = 0; i < 128; i++) { - odd = getmfmlong (mbuf); - even = getmfmlong (mbuf + 256); + odd = getmfmlong (mbuf, shift); + even = getmfmlong (mbuf + 256, shift); mbuf += 2; dlong = (odd << 1) | even; *secdata++ = dlong >> 24; @@ -1371,7 +1384,7 @@ static int drive_write_adf_amigados (drive * drv) mbuf += 256; if (chksum) { write_log ("Disk write: sector %d, data checksum error\n", trackoffs); - if (drv->filetype == ADF_EXT2) + if (filetype == ADF_EXT2) return 4; continue; } @@ -1379,12 +1392,24 @@ static int drive_write_adf_amigados (drive * drv) secwritten++; memcpy (writebuffer + trackoffs * 512, secbuf + 32, 512); } - if (drv->filetype == ADF_EXT2 && (secwritten == 0 || secwritten < 0)) + if (filetype == ADF_EXT2 && (secwritten == 0 || secwritten < 0)) return 5; if (secwritten == 0) write_log ("Disk write in unsupported format\n"); if (secwritten < 0) write_log ("Disk write: sector labels ignored\n"); + *drvsecp = drvsec; + return 0; +} + +static int drive_write_adf_amigados (drive * drv) +{ + int drvsec, i; + + if (decode_buffer (drv->bigmfmbuf, drv->cyl, drv->num_secs, drv->ddhd, drv->filetype, &drvsec)) + return 2; + if (!drvsec) + return 2; if (drv->filetype == ADF_EXT2) diskfile_update (drv->diskfile, &drv->trackdata[drv->cyl * 2 + side], drvsec * 512 * 8, TRACK_AMIGADOS); @@ -1715,7 +1740,7 @@ void DISK_check_change (void) if (drv->dskchange_time) { drv->dskchange_time--; if (drv->dskchange_time == 0) { - drive_insert (drv, i, drv->newname); + drive_insert (drv, &currprefs, i, drv->newname); #ifdef DISK_DEBUG write_dlog ("delayed insert, drive %d, image '%s'\n", i, drv->newname); #endif @@ -2483,7 +2508,7 @@ void DISK_init (void) drive *drv = &floppy[dr]; /* reset all drive types to 3.5 DD */ drive_settype_id (drv); - if (!drive_insert (drv, dr, currprefs.df[dr])) + if (!drive_insert (drv, &currprefs, dr, currprefs.df[dr])) disk_eject (dr); } if (disk_empty (0)) @@ -2505,6 +2530,51 @@ void DISK_reset (void) reset_drive (i); } +int DISK_examine_image (struct uae_prefs *p, int num) +{ + int drvsec; + int ret, i; + drive *drv = &floppy[num]; + uae_u32 dos, crc; + + ret = 0; + drv->cyl = 0; + side = 0; + drive_insert (drv, p, num, p->df[num]); + if (!drv->diskfile) + return 1; + if (decode_buffer (drv->bigmfmbuf, drv->cyl, 11, drv->ddhd, drv->filetype, &drvsec)) { + ret = 2; + goto end; + } + crc = 0; + for (i = 0; i < 512; i += 4) { + uae_u32 v = (writebuffer[i] << 24) | (writebuffer[i + 1] << 16) | (writebuffer[i + 2] << 8) | writebuffer[i + 3]; + if (i == 0) + dos = v; + if (i == 4) + v = 0; + if (crc + v < crc) + crc++; + crc += v; + } + crc ^= 0xffffffff; +// if (crc != 0) +// return 3; + if (dos == 0x444f5300) + ret = 10; + else if (dos == 0x444f5301 || dos == 0x444f5302 || dos == 0x444f5303) + ret = 11; + else if (dos == 0x444f5304 || dos == 0x444f5305 || dos == 0x444f5306 || dos == 0x444f5307) + ret = 12; + else + ret = 4; +end: + drive_image_free (drv); + return ret; +} + + /* Disk save/restore code */ void DISK_save_custom (uae_u32 *pdskpt, uae_u16 *pdsklength, uae_u16 *pdsksync, uae_u16 *pdskbytr) @@ -2566,7 +2636,7 @@ uae_u8 *restore_disk(int num,uae_u8 *src) restore_u32 (); strncpy(changed_prefs.df[num],src,255); src+=strlen(src)+1; - drive_insert (floppy + num, num, changed_prefs.df[num]); + drive_insert (floppy + num, &currprefs, num, changed_prefs.df[num]); if (drive_empty (floppy + num)) drv->dskchange = 1; return src; @@ -2587,7 +2657,7 @@ static uae_u32 getadfcrc (drive *drv) return 0; zfile_fseek (drv->diskfile, 0, SEEK_SET); zfile_fread (b, 1, size, drv->diskfile); - crc32 = CRC32 (0, b, size); + crc32 = get_crc32 (b, size); free (b); return crc32; } diff --git a/drawing.c b/drawing.c index 854373ac..d1b9fddd 100755 --- a/drawing.c +++ b/drawing.c @@ -1009,8 +1009,10 @@ STATIC_INLINE void pfield_doline_1 (uae_u32 *pixels, int wordcount, int planes) b0 = 0, b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0, b7 = 0; switch (planes) { +#ifdef AGA case 8: b0 = GETLONG ((uae_u32 *)real_bplpt[7]); real_bplpt[7] += 4; case 7: b1 = GETLONG ((uae_u32 *)real_bplpt[6]); real_bplpt[6] += 4; +#endif case 6: b2 = GETLONG ((uae_u32 *)real_bplpt[5]); real_bplpt[5] += 4; case 5: b3 = GETLONG ((uae_u32 *)real_bplpt[4]); real_bplpt[4] += 4; case 4: b4 = GETLONG ((uae_u32 *)real_bplpt[3]); real_bplpt[3] += 4; diff --git a/include/crc32.h b/include/crc32.h new file mode 100755 index 00000000..0c3146a1 --- /dev/null +++ b/include/crc32.h @@ -0,0 +1 @@ +extern uae_u32 get_crc32 (uae_u8 *p, int size); diff --git a/include/custom.h b/include/custom.h index 38b6650d..924245d3 100755 --- a/include/custom.h +++ b/include/custom.h @@ -74,9 +74,14 @@ extern void INTREQ_0 (uae_u16); extern uae_u16 INTREQR (void); /* maximums for statically allocated tables */ - +#ifdef UAE_MINI +/* absolute minimums for basic A500/A1200-emulation */ +#define MAXHPOS 227 +#define MAXVPOS 312 +#else #define MAXHPOS 256 #define MAXVPOS 576 +#endif /* PAL/NTSC values */ diff --git a/include/debug.h b/include/debug.h index 6875898a..cc3218c4 100755 --- a/include/debug.h +++ b/include/debug.h @@ -7,6 +7,8 @@ * */ +#ifdef DEBUGGER + #define MAX_HIST 10000 extern int firsthist; @@ -24,3 +26,9 @@ extern void debug(void); extern void activate_debugger(void); extern int notinrom (void); extern const char *debuginfo(int); + +#else + +STATIC_INLINE void activate_debugger (void) { }; + +#endif diff --git a/include/disk.h b/include/disk.h index b1972efd..12578095 100755 --- a/include/disk.h +++ b/include/disk.h @@ -26,6 +26,7 @@ extern void disk_creatediskfile (char *name, int type, drive_type adftype); extern void dumpdisk (void); extern void DISK_history_add (const char *name, int idx); extern char *DISK_history_get (int idx); +extern int DISK_examine_image (struct uae_prefs *p, int drive); extern void DSKLEN (uae_u16 v, int hpos); extern uae_u16 DSKBYTR (int hpos); diff --git a/include/drawing.h b/include/drawing.h index b5e8a9f5..77f9fe9d 100755 --- a/include/drawing.h +++ b/include/drawing.h @@ -148,7 +148,7 @@ struct color_change { }; /* 440 rather than 880, since sprites are always lores. */ -#ifdef CUSTOM_SIMPLE +#ifdef UAE_MINI #define MAX_PIXELS_PER_LINE 880 #define MAX_VIDHEIGHT 800 #else diff --git a/include/memory.h b/include/memory.h index 9acb70af..60b58cd9 100755 --- a/include/memory.h +++ b/include/memory.h @@ -242,4 +242,35 @@ extern int canbang; extern uae_u8 *mapped_malloc (size_t, char *); extern void mapped_free (uae_u8 *); extern void clearexec (void); -extern void mapkick (void); \ No newline at end of file +extern void mapkick (void); +extern int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksum, int *cloanto_rom); +extern void decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size, uae_u8 *key, int keysize); + +#define ROMTYPE_KICK 1 +#define ROMTYPE_KICKCD32 2 +#define ROMTYPE_EXTCD32 4 +#define ROMTYPE_EXTCDTV 8 +#define ROMTYPE_AR 16 +#define ROMTYPE_KEY 32 + +struct romdata { + char *name; + int version, revision; + uae_u32 crc32; + uae_u32 size; + int id; + int cpu; + int type; +}; + +extern struct romdata *getromdatabycrc (uae_u32 crc32); +extern struct romdata *getromdatabydata (uae_u8 *rom, int size); +extern struct romdata *getromdatabyid (int id); +extern void getromname (struct romdata*, char*); +extern struct romdata *getromdatabyname (char*); +extern void romlist_add (char *path, struct romdata *rd); +extern char *romlist_get (struct romdata *rd); +extern void romlist_clear (void); + +extern uae_u8 *load_keyfile (struct uae_prefs *p, char *path, int *size); +extern void free_keyfile (uae_u8 *key); diff --git a/include/newcpu.h b/include/newcpu.h index 3450c30a..66b00703 100755 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -79,7 +79,7 @@ typedef double fptype; extern struct regstruct { uae_u32 regs[16]; - uaecptr usp,isp,msp; + uaecptr usp,isp,msp; uae_u16 sr; flagtype t1; flagtype t0; diff --git a/include/options.h b/include/options.h index 75f9c017..20d98e66 100755 --- a/include/options.h +++ b/include/options.h @@ -9,7 +9,7 @@ #define UAEMAJOR 0 #define UAEMINOR 8 -#define UAESUBREV 27 +#define UAESUBREV 28 typedef enum { KBD_LANG_US, KBD_LANG_DK, KBD_LANG_DE, KBD_LANG_SE, KBD_LANG_FR, KBD_LANG_IT, KBD_LANG_ES } KbdLang; @@ -136,6 +136,7 @@ struct uae_prefs { int keyboard_leds_in_use; int fast_copper; int scsi; + int uaeserial; int catweasel_io; int cpu_idle; int cpu_cycle_exact; @@ -256,6 +257,7 @@ extern int cfgfile_get_description (const char *filename, char *description, int extern void cfgfile_show_usage (void); extern uae_u32 cfgfile_uaelib(int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen); extern void cfgfile_addcfgparam (char *); +extern int build_in_prefs (struct uae_prefs *p, int model, int config, int compa); extern void fixup_prefs_dimensions (struct uae_prefs *prefs); diff --git a/include/parallel.h b/include/parallel.h new file mode 100755 index 00000000..f5bd4004 --- /dev/null +++ b/include/parallel.h @@ -0,0 +1,9 @@ + +extern int isprinter (void); +extern int doprinter (uae_u8); +extern void flushprinter (void); +extern void closeprinter (void); +extern void openprinter (void); +extern int isprinteropen (void); + + diff --git a/include/savestate.h b/include/savestate.h index 4a67e03a..9904bd16 100755 --- a/include/savestate.h +++ b/include/savestate.h @@ -112,8 +112,6 @@ extern int savestate_state; extern char savestate_fname[MAX_DPATH]; extern struct zfile *savestate_file; -extern uae_u32 CRC32(uae_u32 crc, const uae_u8 *buf, int len); - extern void savestate_quick (int slot, int save); extern void savestate_capture (int); diff --git a/include/uae.h b/include/uae.h index 10338b68..2638298e 100755 --- a/include/uae.h +++ b/include/uae.h @@ -41,3 +41,4 @@ struct bstring { }; extern char *colormodes[]; +extern void fetch_saveimagepath (char*, int, int); diff --git a/memory.c b/memory.c index 95480b8a..bb87c8b6 100755 --- a/memory.c +++ b/memory.c @@ -21,6 +21,7 @@ #include "autoconf.h" #include "savestate.h" #include "ar.h" +#include "crc32.h" #ifdef USE_MAPPED_MEMORY #include @@ -53,6 +54,152 @@ static long chip_filepos; static long bogo_filepos; static long rom_filepos; +struct romlist { + char *path; + struct romdata *rd; +}; + +static struct romlist *rl; +static int romlist_cnt; + +void romlist_add (char *path, struct romdata *rd) +{ + struct romlist *rl2; + + romlist_cnt++; + rl = realloc (rl, sizeof (struct romlist) * romlist_cnt); + rl2 = rl + romlist_cnt - 1; + rl2->path = my_strdup (path); + rl2->rd = rd; +} + +char *romlist_get (struct romdata *rd) +{ + int i; + + for (i = 0; i < romlist_cnt; i++) { + if (rl[i].rd == rd) + return rl[i].path; + } + return 0; +} + +void romlist_clear (void) +{ + free (rl); + rl = 0; + romlist_cnt = 0; +} + +static struct romdata roms[] = { + { "Cloanto Amiga Forever ROM key", 0, 0, 0x869ae1b1, 2069, 0, 68000, ROMTYPE_KEY }, + + { "Kickstart v1.0", 0, 0, 0x299790ff, 262144, 1, 68000, ROMTYPE_KICK }, + { "Kickstart v1.1", 31, 34, 0xd060572a, 262144, 2, 68000, ROMTYPE_KICK }, + { "Kickstart v1.2", 32, 34, 0xec86dae2, 262144, 3, 68000, ROMTYPE_KICK }, + { "Kickstart v1.2", 33, 166, 0x0ed783d0, 262144, 4, 68000, ROMTYPE_KICK }, + { "Kickstart v1.2", 33, 180, 0xa6ce1636, 262144, 5, 68000, ROMTYPE_KICK }, + { "Kickstart v1.3", 34, 5, 0xc4f0f55f, 262144, 6, 68000, ROMTYPE_KICK }, + + { "Kickstart v2.04", 37, 175, 0xc3bdb240, 524288, 7, 68000, ROMTYPE_KICK }, + { "Kickstart v2.05", 37, 299, 0x83028fb5, 524288, 8, 68000, ROMTYPE_KICK }, + { "Kickstart v2.05", 37, 300, 0x64466c2a, 524288, 9, 68000, ROMTYPE_KICK }, + { "Kickstart v2.05", 37, 350, 0x43b0df7b, 524288, 10, 68000, ROMTYPE_KICK }, + + { "Kickstart v3.0", 39, 106, 0x6c9b07d2, 524288, 11, 68020, ROMTYPE_KICK }, + { "Kickstart v3.0", 39, 106, 0x9e6ac152, 524288, 12, 68020, ROMTYPE_KICK }, + { "Kickstart v3.1", 40, 55, 0x14e93bcc, 524288, 13, 68020, ROMTYPE_KICK }, + { "Kickstart v3.1", 40, 63, 0xfc24ae0d, 524288, 14, 68000, ROMTYPE_KICK }, + { "Kickstart v3.1", 40, 68, 0x1483a091, 524288, 15, 68020, ROMTYPE_KICK }, + { "Kickstart v3.1", 40, 68, 0xd6bae334, 524288, 16, 68020, ROMTYPE_KICK }, + { "Kickstart v3.1", 40, 70, 0x917100a0, 524288, 17, 68020, ROMTYPE_KICK }, + + { "CD32 Kickstart v3.1", 40, 60, 0x1e62d4a5, 524288, 18, 68020, ROMTYPE_KICKCD32 }, + { "CD32 Extended", 40, 60, 0x87746be2, 524288, 19, 68020, ROMTYPE_EXTCD32 }, + + { "CDTV Extended v1.0", 0, 0, 0x42baa124, 262144, 20, 68000, ROMTYPE_EXTCDTV }, + { "CDTV Extended v2.3", 0, 0, 0x30b54232, 262144, 21, 68000, ROMTYPE_EXTCDTV }, + { "CDTV Extended v2.7", 0, 0, 0xceae68d2, 262144, 22, 68000, ROMTYPE_EXTCDTV }, + + { "A1000 Bootstrap", 0, 0, 0x62f11c04, 8192, 23, 68000, ROMTYPE_KICK }, + { "A1000 Bootstrap", 0, 0, 0x0b1ad2d0, 65536, 24, 68000, ROMTYPE_KICK }, + + { "Action Replay Mk I v1.50", 0, 0, 0xd4ce0675, 65536, 25, 68000, ROMTYPE_AR }, + { "Action Replay Mk II v2.05", 0, 0, 0x1287301f , 131072, 26, 68000, ROMTYPE_AR }, + { "Action Replay Mk II v2.12", 0, 0, 0x804d0361 , 131072, 27, 68000, ROMTYPE_AR }, + { "Action Replay Mk II v2.14", 0, 0, 0x49650e4f, 131072, 28, 68000, ROMTYPE_AR }, + { "Action Replay Mk III v3.09", 0, 0, 0x0ed9b5aa, 262144, 29, 68000, ROMTYPE_AR }, + { "Action Replay Mk III v3.17", 0, 0, 0xc8a16406, 262144, 30, 68000, ROMTYPE_AR }, + { 0 } +}; + +struct romdata *getromdatabyname (char *name) +{ + char tmp[MAX_PATH]; + int i = 0; + while (roms[i].name) { + getromname (&roms[i], tmp); + if (!strcmp (tmp, name) || !strcmp (roms[i].name, name)) + return &roms[i]; + i++; + } + return 0; +} + +struct romdata *getromdatabyid (int id) +{ + int i = 0; + while (roms[i].name) { + if (id == roms[i].id) + return &roms[i]; + i++; + } + return 0; +} + +struct romdata *getromdatabycrc (uae_u32 crc32) +{ + int i = 0; + while (roms[i].name) { + if (crc32 == roms[i].crc32) + return &roms[i]; + i++; + } + return 0; +} + +struct romdata *getromdatabydata (uae_u8 *rom, int size) +{ + int i; + uae_u32 crc32a, crc32b, crc32c; + uae_u8 tmp[4]; + + crc32a = get_crc32 (rom, size); + crc32b = get_crc32 (rom, size / 2); + /* ignore AR IO-port range until we have full dump */ + memcpy (tmp, rom, 4); + memset (rom, 0, 4); + crc32c = get_crc32 (rom, size); + memcpy (rom, tmp, 4); + i = 0; + while (roms[i].name) { + if (crc32a == roms[i].crc32 || crc32b == roms[i].crc32) + return &roms[i]; + if (crc32c == roms[i].crc32 && roms[i].type == ROMTYPE_AR) + return &roms[i]; + i++; + } + return 0; +} + +void getromname (struct romdata *rd, char *name) +{ + strcpy (name, rd->name); + if (rd->revision) + sprintf (name + strlen (name), " rev %d.%d", rd->version, rd->revision); + sprintf (name + strlen (name), " (%dk)", (rd->size + 1023) / 1024); +} + addrbank *mem_banks[MEMORY_BANKS]; /* This has two functions. It either holds a host address that, when added @@ -605,6 +752,8 @@ static int a1000_kickstart_mode; static uae_u8 *a1000_bootrom; static void a1000_handle_kickstart (int mode) { + if (!a1000_bootrom) + return; if (mode == 0) { a1000_kickstart_mode = 0; memcpy (kickmemory, kickmemory + 262144, 262144); @@ -620,8 +769,7 @@ static void a1000_handle_kickstart (int mode) void a1000_reset (void) { - if (a1000_bootrom) - a1000_handle_kickstart (1); + a1000_handle_kickstart (1); } static uae_u32 kickmem_lget (uaecptr) REGPARAM; @@ -962,40 +1110,76 @@ addrbank extendedkickmem_bank = { extendedkickmem_xlate, extendedkickmem_check, NULL }; +void decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size, uae_u8 *key, int keysize) +{ + long cnt, t; + for (t = cnt = 0; cnt < size; cnt++, t = (t + 1) % keysize) { + mem[cnt] ^= key[t]; + if (real_size == cnt + 1) + t = keysize - 1; + } +} + +uae_u8 *load_keyfile (struct uae_prefs *p, char *path, int *size) +{ + struct zfile *f; + uae_u8 *keybuf; + int keysize = 0; + char tmp[MAX_PATH]; + + tmp[0] = 0; + if (path) + strcpy (tmp, path); + strcat (tmp, "rom.key"); + f = zfile_fopen (tmp, "rb"); + if (!f) { + strcpy (tmp, p->path_rom); + strcat (tmp, "rom.key"); + f = zfile_fopen (tmp, "rb"); + if (!f) { + f = zfile_fopen ("roms\\rom.key", "rb"); + if (!f) { + strcpy (tmp, start_path); + strcat (tmp, "rom.key"); + f = zfile_fopen(tmp, "rb"); + if (!f) { + strcpy (tmp, start_path); + strcat (tmp, "..\\shared\\rom\\rom.key"); + f = zfile_fopen(tmp, "rb"); + } + } + } + } + if (f) { + zfile_fseek (f, 0, SEEK_END); + keysize = zfile_ftell (f); + zfile_fseek (f, 0, SEEK_SET); + keybuf = malloc (keysize); + zfile_fread (keybuf, 1, keysize, f); + zfile_fclose (f); + } + *size = keysize; + return keybuf; +} +void free_keyfile (uae_u8 *key) +{ + free (key); +} + static int decode_cloanto_rom (uae_u8 *mem, int size, int real_size) { - struct zfile *keyf; uae_u8 *p; - long cnt, t; int keysize; - if (strlen (currprefs.keyfile) == 0) { -#ifndef SINGLEFILE - gui_message ("No filename given for ROM key file and ROM image is an encrypted \"Amiga Forever\" ROM file.\n"); + p = load_keyfile (&currprefs, NULL, &keysize); + if (!p) { + #ifndef SINGLEFILE + gui_message ("Could not find ROM key file.\n"); #endif return 0; - } else { - keyf = zfile_fopen (currprefs.keyfile, "rb"); - if (keyf == 0) { - keyf = zfile_fopen( "..\\shared\\rom\\rom.key", "rb" ); - if( keyf == 0 ) - { -#ifndef SINGLEFILE - gui_message ("Could not find specified ROM key-file.\n"); -#endif - return 0; - } - } - p = (uae_u8 *)xmalloc (524288); - keysize = zfile_fread (p, 1, 524288, keyf); - for (t = cnt = 0; cnt < size; cnt++, t = (t + 1) % keysize) { - mem[cnt] ^= p[t]; - if (real_size == cnt + 1) - t = keysize - 1; - } - zfile_fclose (keyf); - free (p); } + decode_cloanto_rom_do (mem, size, real_size, p, keysize); + free_keyfile (p); return 1; } @@ -1017,20 +1201,25 @@ static int kickstart_checksum (uae_u8 *mem, int size) return 0; } -static int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksum, int *cloanto_rom) +int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksum, int *cloanto_rom) { unsigned char buffer[20]; int i, cr = 0; if (cloanto_rom) *cloanto_rom = 0; + if (size < 0) { + zfile_fseek (f, 0, SEEK_END); + size = zfile_ftell (f) & ~0x3ff; + zfile_fseek (f, 0, SEEK_SET); + } i = zfile_fread (buffer, 1, 11, f); if (strncmp ((char *)buffer, "AMIROMTYPE1", 11) != 0) { zfile_fseek (f, 0, SEEK_SET); } else { cr = 1; } - + i = zfile_fread (mem, 1, size, f); zfile_fclose (f); if ((i != 8192 && i != 65536) && i != 131072 && i != 262144 && i != 524288) { @@ -1045,6 +1234,7 @@ static int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksu if (i == 8192 || i == 65536) { a1000_bootrom = malloc (65536); memcpy (a1000_bootrom, kickmemory, 65536); + memset (kickmemory, 0, kickmem_size); a1000_handle_kickstart (1); i = 524288; dochecksum = 0; @@ -1453,10 +1643,16 @@ void memory_reset (void) allocate_memory (); if (strcmp (currprefs.romfile, changed_prefs.romfile) != 0 + || strcmp (currprefs.romextfile, changed_prefs.romextfile) != 0 || strcmp (currprefs.keyfile, changed_prefs.keyfile) != 0) { ersatzkickfile = 0; + a1000_handle_kickstart (0); + free (a1000_bootrom); + a1000_bootrom = 0; + a1000_kickstart_mode = 0; memcpy (currprefs.romfile, changed_prefs.romfile, sizeof currprefs.romfile); + memcpy (currprefs.romextfile, changed_prefs.romextfile, sizeof currprefs.romextfile); memcpy (currprefs.keyfile, changed_prefs.keyfile, sizeof currprefs.keyfile); if (savestate_state != STATE_RESTORE) clearexec (); @@ -1605,6 +1801,7 @@ void memory_cleanup (void) bogomemory = 0; kickmemory = 0; a1000_bootrom = 0; + a1000_kickstart_mode = 0; chipmemory = 0; #ifdef ACTION_REPLAY @@ -1702,17 +1899,21 @@ void restore_bram (int len, long filepos) uae_u8 *restore_rom (uae_u8 *src) { + uae_u32 crc32; + int i; + restore_u32 (); restore_u32 (); restore_u32 (); restore_u32 (); - restore_u32 (); - src += strlen (src) + 1; - if (src[0]) { - if (zfile_exists (src)) - strncpy (changed_prefs.romfile , src, 255); - src+=strlen(src)+1; + crc32 = restore_u32 (); + for (i = 0; i < romlist_cnt; i++) { + if (rl[i].rd->crc32 == crc32) { + strncpy (changed_prefs.romfile, rl[i].path, 255); + break; + } } + src += strlen (src) + 1; return src; } @@ -1759,7 +1960,7 @@ uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr) save_u32 (mem_size); save_u32 (mem_type); save_u32 (longget (mem_start + 12)); /* version+revision */ - save_u32 (CRC32 (0, kickmemory, mem_size)); + save_u32 (get_crc32 (kickmemory, mem_size)); sprintf (dst, "Kickstart %d.%d", wordget (mem_start + 12), wordget (mem_start + 14)); dst += strlen (dst) + 1; strcpy (dst, currprefs.romfile);/* rom image name */ diff --git a/newcpu.c b/newcpu.c index 297fab2e..48a0e9b9 100755 --- a/newcpu.c +++ b/newcpu.c @@ -819,9 +819,11 @@ static void exception_trace (int nr) static void exception_debug (int nr) { +#ifdef DEBUGGER if (!exception_debugging) return; console_out ("Exception %d, PC=%08.8X\n", nr, m68k_getpc()); +#endif } #ifdef CPUEMU_6 @@ -2188,8 +2190,10 @@ void m68k_go (int may_quit) m68k_setpc (regs.pc); } +#ifdef DEBUGGER if (debugging) debug (); +#endif if (regs.panic) { regs.panic = 0; /* program jumped to non-existing memory and cpu was >= 68020 */ diff --git a/od-win32/blkdev_win32_spti.c b/od-win32/blkdev_win32_spti.c index 85db9d18..34600cf4 100755 --- a/od-win32/blkdev_win32_spti.c +++ b/od-win32/blkdev_win32_spti.c @@ -48,7 +48,6 @@ static uae_u8 *scsibuf; static int doscsi (HANDLE *h, SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER *swb, int *err) { DWORD status, returned; - int i; *err = 0; if (log_scsi) { diff --git a/od-win32/fsdb_win32.c b/od-win32/fsdb_win32.c index edca5525..599c3ef9 100755 --- a/od-win32/fsdb_win32.c +++ b/od-win32/fsdb_win32.c @@ -90,10 +90,12 @@ int fsdb_fill_file_attrs (a_inode *aino) aino->dir = (mode & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0; aino->amigaos_mode = A_FIBF_EXECUTE | A_FIBF_READ; - if (FILE_ATTRIBUTE_ARCHIVE & mode) + if (!(FILE_ATTRIBUTE_ARCHIVE & mode)) aino->amigaos_mode |= A_FIBF_ARCHIVE; if (! (FILE_ATTRIBUTE_READONLY & mode)) aino->amigaos_mode |= A_FIBF_WRITE | A_FIBF_DELETE; + if (FILE_ATTRIBUTE_SYSTEM & mode) + aino->amigaos_mode |= A_FIBF_PURE; aino->amigaos_mode = filesys_parse_mask(aino->amigaos_mode); return 1; } @@ -113,11 +115,14 @@ int fsdb_set_file_attrs (a_inode *aino, int mask) if (! aino->dir) { if ((tmpmask & (A_FIBF_READ | A_FIBF_DELETE)) == 0) mode |= FILE_ATTRIBUTE_READONLY; - if (tmpmask & A_FIBF_ARCHIVE) + if (!(tmpmask & A_FIBF_ARCHIVE)) mode |= FILE_ATTRIBUTE_ARCHIVE; else mode &= ~FILE_ATTRIBUTE_ARCHIVE; - + if (tmpmask & A_FIBF_PURE) + mode |= FILE_ATTRIBUTE_SYSTEM; + else + mode &= ~FILE_ATTRIBUTE_SYSTEM; SetFileAttributes(aino->nname, mode); } @@ -136,8 +141,8 @@ int fsdb_mode_representable_p (const a_inode *aino) if (aino->dir) return aino->amigaos_mode == 0; - /* P or S set, or E or R clear, means we can't handle it. */ - if (mask & (A_FIBF_SCRIPT | A_FIBF_PURE | A_FIBF_EXECUTE | A_FIBF_READ)) + /* S set, or E or R clear, means we can't handle it. */ + if (mask & (A_FIBF_SCRIPT | A_FIBF_EXECUTE | A_FIBF_READ)) return 0; m1 = A_FIBF_DELETE | A_FIBF_WRITE; /* If it's rwed, we are OK... */ diff --git a/od-win32/parser.c b/od-win32/parser.c index 9f68aba1..adaf341d 100755 --- a/od-win32/parser.c +++ b/od-win32/parser.c @@ -40,6 +40,7 @@ #include "od-win32/ahidsound.h" #include "win32.h" #include "ioport.h" +#include "parallel.h" static UINT prttimer; static char prtbuf[PRTBUFSIZE]; @@ -106,7 +107,14 @@ int isprinter (void) return 1; } -static void openprinter( void ) +int isprinteropen (void) +{ + if (prtopen) + return 1; + return 0; +} + +void openprinter( void ) { DOC_INFO_1 DocInfo; diff --git a/od-win32/resources/bitmap1.bmp b/od-win32/resources/bitmap1.bmp new file mode 100755 index 00000000..df1851c7 Binary files /dev/null and b/od-win32/resources/bitmap1.bmp differ diff --git a/od-win32/resources/resource.h b/od-win32/resources/resource.h index 90e0ddbf..264b8040 100755 --- a/od-win32/resources/resource.h +++ b/od-win32/resources/resource.h @@ -18,6 +18,8 @@ #define IDS_INPUT 14 #define IDS_OPENGL 15 #define IDS_MISC2 16 +#define IDS_PATHS 17 +#define IDS_QUICKSTART 18 #define IDS_EXTTEXT 100 #define IDS_EXTACTUAL 101 #define IDS_SOUND 102 @@ -145,7 +147,9 @@ #define IDI_DISK 182 #define IDR_DRIVE_SPINND_A500_1 182 #define IDD_PANEL 183 +#define IDD_PATHS 184 #define IDI_CONFIGFILE 185 +#define IDD_QUICKSTART 185 #define IDM_SYSTRAY 186 #define IDI_FOLDER 188 #define IDI_DISPLAY 190 @@ -190,6 +194,7 @@ #define IDS_TREEVIEW_SETTINGS 235 #define IDS_WINUAETITLE_MMB 236 #define IDS_WINUAETITLE_NORMAL 237 +#define IDS_STARTEMULATION 238 #define IDC_RESOLUTION 1021 #define IDC_SERIAL 1022 #define IDC_REFRESHRATE 1022 @@ -399,6 +404,7 @@ #define IDC_SWAP 1509 #define IDC_CACHETEXT 1509 #define IDC_SELECTRESTEXT 1510 +#define IDC_FLUSHPRINTER 1510 #define IDC_SCREENRESTEXT 1511 #define IDC_WIDTHTEXT 1512 #define IDC_WINDOWEDTEXT 1512 @@ -408,11 +414,15 @@ #define IDC_SETTINGSTEXT2 1515 #define IDC_DISABLE1 1516 #define IDC_DF1WP 1516 +#define IDC_QUICKSTART_COMPA 1516 #define IDC_DISABLE2 1517 #define IDC_DF2WP 1517 +#define IDC_QUICKSTART_DF 1517 #define IDC_DISABLE3 1518 #define IDC_XCENTER 1518 #define IDC_DF3WP 1518 +#define IDC_DF1WP2 1518 +#define IDC_QUICKSTART_HOST 1518 #define IDC_YCENTER 1519 #define IDC_DISABLE0 1519 #define IDC_DF0WP 1519 @@ -626,6 +636,7 @@ #define IDC_DISKLISTREMOVE 1649 #define IDC_SOUNDCARD 1650 #define IDC_CS_SOUND0 1650 +#define IDC_UPBM 1650 #define IDC_SOUNDCARDLIST 1651 #define IDC_CS_SOUND1 1651 #define IDC_SOUNDFREQ 1652 @@ -638,10 +649,37 @@ #define IDC_SOUNDSTEREO 1655 #define IDC_CONFIGTYPE 1655 #define IDC_SOUNDDRIVETXT 1656 +#define IDC_PATHS_ROM 1656 #define IDC_SOUNDSTEREOTXT 1657 +#define IDC_PATHS_CONFIG 1657 #define IDC_SOUNDINTERPOLATIONTXT 1658 +#define IDC_PATHS_SCREENSHOT 1658 #define IDC_DISK 1659 #define IDC_DISKLIST 1659 +#define IDC_PATHS_SAVEIMAGE 1659 +#define IDC_PATHS_SAVESTATE 1660 +#define IDC_PATHS_ROMS 1661 +#define IDC_PATHS_CONFIGS 1662 +#define IDC_PATHS_SCREENSHOTS 1663 +#define IDC_PATHS_SAVESTATES 1664 +#define IDC_PATHS_SAVEIMAGES 1665 +#define IDC_PATHS_ROML 1666 +#define IDC_PATHS_CONFIGL 1667 +#define IDC_PATHS_SCREENSHOTL 1668 +#define IDC_PATHS_STATEFILEL 1669 +#define IDC_PATHS_SAVEIMAGEL 1670 +#define IDC_PATHS_DEFAULT 1671 +#define IDC_ROM_RESCAN 1672 +#define IDC_QUICKSTARTMODE 1673 +#define IDC_RESETREGISTRY 1673 +#define IDC_QUICKSTART_MODEL 1674 +#define IDC_QUICKSTART_CONFIGURATION 1675 +#define IDC_QUICKSTART_COMPATIBILITY 1676 +#define IDC_QUICKSTART_CONFIG 1677 +#define IDC_DF0Q 1678 +#define IDC_DF1Q 1679 +#define IDC_QUICKSTART_HOSTCONFIG 1679 +#define IDC_CONFIGAUTO 1682 #define ID__FLOPPYDRIVES 40004 #define ID_FLOPPYDRIVES_DF0 40005 #define ID_ST_CONFIGURATION 40010 @@ -660,9 +698,9 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 196 +#define _APS_NEXT_RESOURCE_VALUE 198 #define _APS_NEXT_COMMAND_VALUE 40020 -#define _APS_NEXT_CONTROL_VALUE 1656 +#define _APS_NEXT_CONTROL_VALUE 1683 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index b33d2034..f12651cb 100755 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -31,32 +31,36 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Dialog // -IDD_KICKSTART DIALOGEX 0, 0, 300, 175 +IDD_KICKSTART DIALOGEX 0, 0, 300, 176 STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD EXSTYLE WS_EX_CONTEXTHELP FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - GROUPBOX "Boot-ROM Settings:",-1,5,12,290,90 - RTEXT "ROM File:",IDC_ROMTEXT,10,27,75,10 - EDITTEXT IDC_ROMFILE,90,22,185,15,ES_AUTOHSCROLL + GROUPBOX "ROM Settings:",-1,5,12,290,96 + RTEXT "Boot ROM File:",IDC_ROMTEXT,10,27,75,10 + COMBOBOX IDC_ROMFILE,89,24,186,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | + CBS_SORT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "...",IDC_KICKCHOOSER,280,22,10,15 RTEXT "Key File:",IDC_KEYTEXT,10,48,75,10 - EDITTEXT IDC_KEYFILE,90,43,185,15,ES_AUTOHSCROLL + COMBOBOX IDC_KEYFILE,89,45,186,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | + CBS_SORT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "...",IDC_KEYCHOOSER,280,43,10,15 RTEXT "Extended ROM File:",IDC_ROMFILE2TEXT,10,68,75,10 - EDITTEXT IDC_ROMFILE2,90,63,185,15,ES_AUTOHSCROLL + COMBOBOX IDC_ROMFILE2,89,64,186,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | + CBS_SORT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "...",IDC_ROMCHOOSER2,280,63,10,15 + RTEXT "Cartridge ROM File:",IDC_FLASHTEXT2,8,86,75,10 + COMBOBOX IDC_CARTFILE,89,83,186,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | + CBS_SORT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "...",IDC_CARTCHOOSER,280,83,10,15 + GROUPBOX "Misc settings:",-1,5,112,290,57 + RTEXT "Flash RAM File:",IDC_FLASHTEXT,8,126,75,10 + EDITTEXT IDC_FLASHFILE,89,124,185,15,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_FLASHCHOOSER,280,124,10,15 CONTROL "MAPROM emulation",IDC_MAPROM,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,104,86,80,10 + WS_TABSTOP,104,150,80,10 CONTROL "ShapeShifter support",IDC_KICKSHIFTER,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,196,86,80,10 - GROUPBOX "Misc settings:",-1,5,105,290,59 - RTEXT "Flash RAM File:",IDC_FLASHTEXT,8,119,75,10 - EDITTEXT IDC_FLASHFILE,89,117,185,15,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_FLASHCHOOSER,279,117,10,15 - RTEXT "Cartridge ROM File:",IDC_FLASHTEXT2,8,140,75,10 - EDITTEXT IDC_CARTFILE,89,137,185,15,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_CARTCHOOSER,279,137,10,15 + BS_AUTOCHECKBOX | WS_TABSTOP,196,150,80,10 END IDD_DISPLAY DIALOGEX 0, 0, 300, 194 @@ -157,12 +161,12 @@ BEGIN WS_TABSTOP,10,33,34,10 CONTROL "68EC020",IDC_CPU2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,10,48,45,10 - CONTROL "68EC020+FPU",IDC_CPU3,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,10,63,63,10 + CONTROL "68EC020 + FPU",IDC_CPU3,"Button",BS_AUTORADIOBUTTON | + WS_TABSTOP,10,63,67,10 CONTROL "68020",IDC_CPU4,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,10,78,34,10 - CONTROL "68020+FPU",IDC_CPU5,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,10,93,54,10 + CONTROL "68020 + FPU",IDC_CPU5,"Button",BS_AUTORADIOBUTTON | + WS_TABSTOP,10,93,58,10 CONTROL "68040",IDC_CPU6,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,10,108,36,10 CONTROL "More compatible",IDC_COMPATIBLE,"Button", @@ -215,30 +219,30 @@ IDD_FLOPPY DIALOGEX 0, 0, 300, 230 STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - RTEXT "DF0:",IDC_STATIC,16,6,20,10,SS_CENTERIMAGE + RTEXT "DF0:",IDC_STATIC,16,7,20,10,SS_CENTERIMAGE COMBOBOX IDC_DF0TEXT,2,22,296,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_DF0TYPE,54,5,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_DF0TYPE,123,6,49,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP RTEXT "Write Protected",IDC_STATIC,174,8,59,10,SS_CENTERIMAGE CONTROL "",IDC_DF0WP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,238,4,10,15 PUSHBUTTON "Eject",IDC_EJECT0,253,4,30,15 PUSHBUTTON "...",IDC_DF0,287,4,10,15 - RTEXT "DF1:",IDC_STATIC,16,41,20,10,SS_CENTERIMAGE + RTEXT "DF1:",IDC_STATIC,16,42,20,10,SS_CENTERIMAGE COMBOBOX IDC_DF1TEXT,2,58,296,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_DF1TYPE,54,40,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_DF1TYPE,123,42,49,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "Write Protected",IDC_STATIC,174,42,59,10,SS_CENTERIMAGE + RTEXT "Write Protected",IDC_STATIC,174,43,59,10,SS_CENTERIMAGE CONTROL "",IDC_DF1WP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | - WS_TABSTOP,238,39,10,15 - PUSHBUTTON "Eject",IDC_EJECT1,253,39,30,15 - PUSHBUTTON "...",IDC_DF1,287,39,10,15 + WS_TABSTOP,238,40,10,15 + PUSHBUTTON "Eject",IDC_EJECT1,253,40,30,15 + PUSHBUTTON "...",IDC_DF1,287,40,10,15 RTEXT "DF2:",IDC_STATIC,16,77,20,10,SS_CENTERIMAGE COMBOBOX IDC_DF2TEXT,2,93,296,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_DF2TYPE,54,76,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_DF2TYPE,123,76,49,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP RTEXT "Write Protected",IDC_STATIC,174,77,59,10,SS_CENTERIMAGE CONTROL "",IDC_DF2WP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | @@ -248,7 +252,7 @@ BEGIN RTEXT "DF3:",IDC_STATIC,16,113,20,9,SS_CENTERIMAGE COMBOBOX IDC_DF3TEXT,2,130,296,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_DF3TYPE,54,112,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_DF3TYPE,123,110,49,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP RTEXT "Write Protected",IDC_STATIC,174,113,59,10, SS_CENTERIMAGE @@ -261,7 +265,7 @@ BEGIN WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Create Standard ""Floppy""",IDC_CREATE,76,165,97,15 PUSHBUTTON "Create Custom ""Floppy""",IDC_CREATE_RAW,183,165,101,15 - GROUPBOX "Floppy drive emulation speed",IDC_SETTINGSTEXT2,5,188, + GROUPBOX "Floppy drive emulation speed",IDC_SETTINGSTEXT2,5,190, 289,35 CONTROL "",IDC_FLOPPYSPD,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,32,198,116,20 @@ -343,36 +347,39 @@ BEGIN TBS_TOP | WS_TABSTOP,183,144,107,19 END -IDD_LOADSAVE DIALOGEX 0, 0, 302, 240 +IDD_LOADSAVE DIALOGEX 0, 0, 302, 241 STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN CONTROL "",IDC_CONFIGTREE,"SysTreeView32",TVS_HASLINES | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER | - WS_TABSTOP,6,4,289,155,WS_EX_CLIENTEDGE - RTEXT "Name:",IDC_STATIC,5,202,40,15,SS_CENTERIMAGE - EDITTEXT IDC_EDITNAME,50,202,155,15,ES_AUTOHSCROLL,0, - HIDC_EDITNAME - RTEXT "Path:",IDC_STATIC,5,184,39,15,SS_CENTERIMAGE - EDITTEXT IDC_EDITPATH,50,184,155,15,ES_AUTOHSCROLL | WS_DISABLED, - 0,HIDC_EDITPATH - RTEXT "Description:",IDC_STATIC,5,163,40,15,SS_CENTERIMAGE - EDITTEXT IDC_EDITDESCRIPTION,50,163,245,15,ES_AUTOHSCROLL,0, + WS_TABSTOP,6,3,289,159,WS_EX_CLIENTEDGE + RTEXT "Description:",IDC_STATIC,5,166,40,15,SS_CENTERIMAGE + EDITTEXT IDC_EDITDESCRIPTION,50,166,155,15,ES_AUTOHSCROLL,0, HIDC_EDITDESCRIPTION - GROUPBOX "Extra Info",IDC_STATIC,210,179,85,38 - PUSHBUTTON "View",IDC_VIEWINFO,215,195,35,15 - PUSHBUTTON "Set",IDC_SETINFO,255,194,35,15 - PUSHBUTTON "Load",IDC_QUICKLOAD,5,222,40,15 - PUSHBUTTON "Save",IDC_QUICKSAVE,50,222,40,15 - PUSHBUTTON "Load From...",IDC_LOAD,125,222,45,15 - PUSHBUTTON "Save As...",IDC_SAVE,175,222,40,15 - PUSHBUTTON "Delete",IDC_DELETE,255,222,40,15 + RTEXT "Path:",IDC_STATIC,5,187,39,15,SS_CENTERIMAGE + EDITTEXT IDC_EDITPATH,50,187,155,15,ES_AUTOHSCROLL | WS_DISABLED, + 0,HIDC_EDITPATH + RTEXT "Name:",IDC_STATIC,5,205,40,15,SS_CENTERIMAGE + EDITTEXT IDC_EDITNAME,50,205,155,15,ES_AUTOHSCROLL,0, + HIDC_EDITNAME + GROUPBOX "Extra Info",IDC_STATIC,210,182,85,38 + PUSHBUTTON "View",IDC_VIEWINFO,215,198,35,15 + PUSHBUTTON "Set",IDC_SETINFO,255,197,35,15 + PUSHBUTTON "Load",IDC_QUICKLOAD,5,225,40,15 + PUSHBUTTON "Save",IDC_QUICKSAVE,50,225,40,15 + PUSHBUTTON "Load From...",IDC_LOAD,125,225,45,15 + PUSHBUTTON "Save As...",IDC_SAVE,175,225,40,15 + PUSHBUTTON "Delete",IDC_DELETE,255,225,40,15 + CONTROL "Autoload",IDC_CONFIGAUTO,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,212,169,76,10 END IDD_PORTS DIALOGEX 0, 0, 300, 202 STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN + GROUPBOX "Serial and Parallel",IDC_SERPARFRAME,7,3,284,45 RTEXT "Serial:",IDC_STATIC,20,15,25,15,SS_CENTERIMAGE COMBOBOX IDC_SERIAL,50,15,95,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -385,6 +392,7 @@ BEGIN RTEXT "Printer:",IDC_STATIC,155,15,25,15,SS_CENTERIMAGE COMBOBOX IDC_PRINTERLIST,185,15,95,134,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "MIDI",IDC_MIDIFRAME,7,51,284,36 RTEXT "Out:",IDC_MIDI,10,64,34,15,SS_CENTERIMAGE COMBOBOX IDC_MIDIOUTLIST,50,64,95,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -418,8 +426,7 @@ BEGIN CONTROL "Keyboard Layout ""C""",IDC_PORT1_KBDC,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,190,177,90,10 PUSHBUTTON "<-swap->",IDC_SWAP,130,132,40,14 - GROUPBOX "MIDI",IDC_MIDIFRAME,7,51,284,36 - GROUPBOX "Serial and Parallel",IDC_SERPARFRAME,7,3,284,45 + PUSHBUTTON "Flush print job",IDC_FLUSHPRINTER,199,31,58,12 END IDD_CONTRIBUTORS DIALOGEX 0, 0, 411, 242 @@ -485,6 +492,8 @@ BEGIN WS_TABSTOP,29,45,115,10 CONTROL "UAEscsi.device",IDC_SCSIDEVICE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,60,117,10 + CONTROL "Disable UAEFSDB-support",IDC_NOUAEFSDB,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,29,76,115,10 CONTROL "BSDsocket.library emulation",IDC_SOCKETS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,159,15,120,10 CONTROL "Use CTRL-F11 to quit",IDC_CTRLF11,"Button", @@ -519,8 +528,6 @@ BEGIN 182,83,10,SS_CENTERIMAGE | WS_TABSTOP COMBOBOX IDC_STATE_BUFFERSIZE,248,180,38,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - CONTROL "Disable UAEFSDB-support",IDC_NOUAEFSDB,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,29,76,115,10 END IDD_HARDFILE DIALOGEX 0, 0, 229, 164 @@ -802,9 +809,9 @@ BEGIN CONTROL "",IDC_DISKLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,4,6,262,211 - PUSHBUTTON "Remove disk image",IDC_DISKLISTREMOVE,94,223,93,15 PUSHBUTTON "",IDC_UP,270,66,25,15,BS_ICON PUSHBUTTON "",IDC_DOWN,270,146,25,15,BS_ICON + PUSHBUTTON "Remove disk image",IDC_DISKLISTREMOVE,94,223,93,15 END IDD_PANEL DIALOGEX 0, 0, 420, 278 @@ -814,16 +821,80 @@ EXSTYLE WS_EX_ACCEPTFILES | WS_EX_CONTROLPARENT CAPTION "WinUAE Properties" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN + GROUPBOX "",IDC_PANEL_FRAME,112,4,303,247,NOT WS_VISIBLE CONTROL "",IDC_PANELTREE,"SysTreeView32",TVS_HASLINES | TVS_SHOWSELALWAYS | TVS_NOSCROLL | WS_BORDER | WS_TABSTOP,5,5,101,248,WS_EX_CLIENTEDGE GROUPBOX "",IDC_PANEL_FRAME_OUTER,110,2,307,251 + PUSHBUTTON "Reset",IDC_RESETAMIGA,6,259,47,14 + PUSHBUTTON "Quit",IDC_QUITEMU,57,259,47,14 DEFPUSHBUTTON "OK",IDOK,260,259,50,14 PUSHBUTTON "Cancel",IDCANCEL,313,259,50,14 PUSHBUTTON "Help",IDHELP,366,259,50,14,WS_DISABLED - PUSHBUTTON "Reset",IDC_RESETAMIGA,6,259,47,14 - PUSHBUTTON "Quit",IDC_QUITEMU,57,259,47,14 - GROUPBOX "",IDC_PANEL_FRAME,112,4,303,247,NOT WS_VISIBLE +END + +IDD_PATHS DIALOGEX 0, 0, 300, 223 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + LTEXT "ROM path:",IDC_PATHS_ROML,14,9,260,8,SS_CENTERIMAGE + EDITTEXT IDC_PATHS_ROM,14,22,261,15,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_PATHS_ROMS,281,22,11,15 + LTEXT "Configuration file path:",IDC_PATHS_CONFIGL,14,42,260,8, + SS_CENTERIMAGE + EDITTEXT IDC_PATHS_CONFIG,14,55,261,15,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_PATHS_CONFIGS,281,55,11,15 + LTEXT "Screenshot path:",IDC_PATHS_SCREENSHOTL,14,75,260,8, + SS_CENTERIMAGE + EDITTEXT IDC_PATHS_SCREENSHOT,14,89,261,15,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_PATHS_SCREENSHOTS,281,88,11,15 + LTEXT "State file path:",IDC_PATHS_STATEFILEL,14,109,260,8, + SS_CENTERIMAGE + EDITTEXT IDC_PATHS_SAVESTATE,14,123,261,15,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_PATHS_SAVESTATES,281,123,11,15 + LTEXT "Saveimage path:",IDC_PATHS_SAVEIMAGEL,14,143,260,8, + SS_CENTERIMAGE + EDITTEXT IDC_PATHS_SAVEIMAGE,14,156,261,15,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_PATHS_SAVEIMAGES,281,155,11,15 + PUSHBUTTON "Reset to defaults",IDC_PATHS_DEFAULT,13,182,73,14 + PUSHBUTTON "Rescan ROMs",IDC_ROM_RESCAN,97,182,73,14 + PUSHBUTTON "Clear registry",IDC_RESETREGISTRY,219,182,73,14 +END + +IDD_QUICKSTART DIALOGEX 0, 0, 300, 223 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + GROUPBOX "Hardware configuration",IDC_QUICKSTART_CONFIG,5,0,294, + 54 + RTEXT "Model:",IDC_STATIC,7,14,56,10,SS_CENTERIMAGE + COMBOBOX IDC_QUICKSTART_MODEL,67,12,225,50,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + RTEXT "Configuration:",IDC_STATIC,7,33,56,10,SS_CENTERIMAGE + COMBOBOX IDC_QUICKSTART_CONFIGURATION,67,31,225,50, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Compatibility Settings",IDC_QUICKSTART_COMPA,5,56,294, + 33 + RTEXT "Compatibility:",IDC_STATIC,8,70,55,10,SS_CENTERIMAGE + COMBOBOX IDC_QUICKSTART_COMPATIBILITY,67,68,225,50, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Disk Drive",IDC_QUICKSTART_DF,5,126,294,60 + LTEXT "Disk Drive DF0:",IDC_STATIC,12,141,56,10,SS_CENTERIMAGE + PUSHBUTTON "Select Disk Image",IDC_DF0Q,79,139,84,15 + RTEXT "Write Protected",IDC_STATIC,168,142,58,10, + SS_CENTERIMAGE + CONTROL "",IDC_DF0WP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | + WS_TABSTOP,233,139,10,15 + PUSHBUTTON "Eject",IDC_EJECT0,248,139,30,15 + PUSHBUTTON "...",IDC_DF0,282,139,10,15 + COMBOBOX IDC_DF0TEXT,11,157,282,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | + WS_VSCROLL | WS_TABSTOP + CONTROL "Start in Quickstart-mode",IDC_QUICKSTARTMODE,"Button", + BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,202,212,94,10 + COMBOBOX IDC_QUICKSTART_HOSTCONFIG,67,103,225,50,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + GROUPBOX "Host configuration",IDC_QUICKSTART_HOST,5,91,294,33 + RTEXT "Configuration:",IDC_STATIC,7,105,55,10,SS_CENTERIMAGE END @@ -887,8 +958,8 @@ IDI_MEMORY ICON "chip.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,8,27,0 - PRODUCTVERSION 0,8,27,0 + FILEVERSION 0,8,28,0 + PRODUCTVERSION 0,8,28,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -904,12 +975,12 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "WinUAE" - VALUE "FileVersion", "0.8.27" + VALUE "FileVersion", "0.8.28" VALUE "InternalName", "WinUAE" VALUE "LegalCopyright", "© 1996-2004 under the GNU Public License (GPL)" VALUE "OriginalFilename", "WinUAE.exe" VALUE "ProductName", "WinUAE" - VALUE "ProductVersion", "0.8.27" + VALUE "ProductVersion", "0.8.28" END END BLOCK "VarFileInfo" @@ -934,11 +1005,6 @@ IDC_MYHAND CURSOR "H_arrow.cur" #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN - IDD_FLOPPY, DIALOG - BEGIN - BOTTOMMARGIN, 175 - END - IDD_HARDDISK, DIALOG BEGIN BOTTOMMARGIN, 175 @@ -949,6 +1015,11 @@ BEGIN BOTTOMMARGIN, 206 END + IDD_LOADSAVE, DIALOG + BEGIN + BOTTOMMARGIN, 240 + END + IDD_CONTRIBUTORS, DIALOG BEGIN RIGHTMARGIN, 370 @@ -965,16 +1036,20 @@ BEGIN BOTTOMMARGIN, 187 END - IDD_OPENGL, DIALOG - BEGIN - BOTTOMMARGIN, 175 - END - IDD_PANEL, DIALOG BEGIN LEFTMARGIN, 7 TOPMARGIN, 7 - HORZGUIDE, 241 + END + + IDD_PATHS, DIALOG + BEGIN + BOTTOMMARGIN, 215 + END + + IDD_QUICKSTART, DIALOG + BEGIN + RIGHTMARGIN, 299 END END #endif // APSTUDIO_INVOKED @@ -1050,6 +1125,8 @@ END STRINGTABLE BEGIN IDS_MISC2 "Priority" + IDS_PATHS "Paths" + IDS_QUICKSTART "Quickstart" END STRINGTABLE @@ -1080,7 +1157,7 @@ BEGIN IDS_SELECTUAE "Select a UAE Config-File..." IDS_UAE "UAE Config Files" IDS_SELECTROM "Select an Amiga ROM file..." - IDS_ROM "Amiga Kickstart Files" + IDS_ROM "Amiga ROM Files" IDS_SELECTKEY "Select an Amiga Key-File..." IDS_KEY "Amiga Kickstart Key-Files" IDS_SELECTINFO "Select information for your config..." @@ -1209,6 +1286,7 @@ BEGIN IDS_TREEVIEW_SETTINGS "Settings" IDS_WINUAETITLE_MMB "[Mouse active - press Alt-Tab or middle-button to cancel]" IDS_WINUAETITLE_NORMAL "[Mouse active - press Alt-Tab to cancel]" + IDS_STARTEMULATION "Start" END #endif // English (U.S.) resources diff --git a/od-win32/screenshot.c b/od-win32/screenshot.c index 4df98ea7..63198e9a 100755 --- a/od-win32/screenshot.c +++ b/od-win32/screenshot.c @@ -118,15 +118,18 @@ void screenshot(int mode) char filename[MAX_DPATH]; char extension[] = "bmp"; char tmpstr[MAX_DPATH]; + char path[MAX_DPATH]; int number = 0; + fetch_path ("ScreenshotPath", path, sizeof (path)); + CreateDirectory (path, NULL); tmpstr[0] = 0; if(config_filename[0]) sprintf (tmpstr, "%s_", config_filename); while(++number < 1000) // limit 999 iterations / screenshots { - sprintf(filename, "%s%cScreenShots%c%s%03.3d.%s", start_path, FSDB_DIR_SEPARATOR, FSDB_DIR_SEPARATOR, tmpstr, number, extension); + sprintf(filename, "%s%s%03.3d.%s", path, tmpstr, number, extension); if((fp = fopen(filename, "r")) == NULL) // does file not exist? { diff --git a/od-win32/sysconfig.h b/od-win32/sysconfig.h index 49f1fea5..9adcd7d7 100755 --- a/od-win32/sysconfig.h +++ b/od-win32/sysconfig.h @@ -8,10 +8,10 @@ #define DRIVESOUND #define GFXFILTER -#define DEBUGGER #ifndef UAE_MINI +#define DEBUGGER #define FILESYS /* filesys emulation */ #define UAE_FILESYS_THREADS #define AUTOCONFIG /* autoconfig support, fast ram, harddrives etc.. */ @@ -61,6 +61,7 @@ #define CPUEMU_6 #define CPUEMU_5 + #endif #ifdef _DEBUG diff --git a/od-win32/win32.c b/od-win32/win32.c index e741b51f..a5d7515e 100755 --- a/od-win32/win32.c +++ b/od-win32/win32.c @@ -59,8 +59,6 @@ #include "scsidev.h" #include "disk.h" -extern void WIN32GFX_WindowMove ( void ); -extern void WIN32GFX_WindowSize ( void ); unsigned long *win32_stackbase; unsigned long *win32_freestack[42]; //EXTRA_STACK_SIZE @@ -90,7 +88,7 @@ int win_x_diff, win_y_diff; int toggle_sound; int paraport_mask; -HKEY hWinUAEKey = NULL; +HKEY hWinUAEKey = NULL; COLORREF g_dwBackgroundColor = RGB(10, 0, 10); static int emulation_paused; @@ -107,8 +105,10 @@ static HANDLE timehandle; char *start_path; char help_file[ MAX_DPATH ]; + extern int harddrive_dangerous, do_rdbdump, aspi_allow_all, dsound_hardware_mixing, no_rawinput; int log_scsi; +DWORD quickstart = 1; static int timeend (void) { @@ -1411,20 +1411,20 @@ void logging_cleanup( void ) void target_default_options (struct uae_prefs *p) { - p->win32_middle_mouse = 0; + p->win32_middle_mouse = 1; p->win32_logfile = 0; - p->win32_iconified_nosound = 0; - p->win32_iconified_pause = 0; + p->win32_iconified_nosound = 1; + p->win32_iconified_pause = 1; p->win32_inactive_nosound = 0; p->win32_inactive_pause = 0; p->win32_no_overlay = 0; p->win32_ctrl_F11_is_quit = 0; p->win32_soundcard = 0; - p->win32_active_priority = 1; + p->win32_active_priority = 0; p->win32_inactive_priority = 2; p->win32_iconified_priority = 3; - p->win32_midioutdev = 0; - p->win32_midiindev = -2; + p->win32_midioutdev = -2; + p->win32_midiindev = 0; } void target_save_options (FILE *f, struct uae_prefs *p) @@ -1527,11 +1527,105 @@ int target_parse_option (struct uae_prefs *p, char *option, char *value) return result; } +void fetch_saveimagepath (char *out, int size, int dir) +{ + fetch_path ("SaveimagePath", out, size); + if (dir) { + out[strlen (out) - 1] = 0; + CreateDirectory (out, NULL); + fetch_path ("SaveimagePath", out, size); + } +} +void fetch_path (char *name, char *out, int size) +{ + strcpy (out, start_path); + if (!strcmp (name, "FloppyPath")) + strcat (out, "..\\shared\\adf\\"); + if (!strcmp (name, "hdfPath")) + strcat (out, "..\\shared\\hdf\\"); + if (!strcmp (name, "KickstartPath")) + strcat (out, "..\\shared\\rom\\"); + if (hWinUAEKey) + RegQueryValueEx(hWinUAEKey, name, 0, NULL, out, &size); +} +void set_path (char *name, char *path) +{ + char tmp[MAX_DPATH]; + if (!path) { + strcpy (tmp, start_path); + if (!strcmp (name, "KickstartPath")) + strcat (tmp, "Roms"); + if (!strcmp (name, "ConfigurationPath")) + strcat (tmp, "Configurations"); + if (!strcmp (name, "ScreenshotPath")) + strcat (tmp, "Screenshots"); + if (!strcmp (name, "StatefilePath")) + strcat (tmp, "Savestates"); + if (!strcmp (name, "SaveimagePath")) + strcat (tmp, "SaveImages"); + } else { + strcpy (tmp, path); + } + if (tmp[strlen (tmp) - 1] != '\\' && tmp[strlen (tmp) - 1] != '/') + strcat (tmp, "\\"); + if (hWinUAEKey) + RegSetValueEx (hWinUAEKey, name, 0, REG_SZ, (CONST BYTE *)tmp, strlen (tmp) + 1); +} + +static void initpath (char *name, char *path) +{ + if (!hWinUAEKey) + return; + if (RegQueryValueEx(hWinUAEKey, name, 0, NULL, NULL, NULL) == ERROR_SUCCESS) + return; + set_path (name, NULL); +} + +extern int scan_roms (char*); +void read_rom_list (void) +{ + char tmp2[1000]; + DWORD size2; + int idx, idx2; + HKEY fkey; + char tmp[1000]; + DWORD size, disp; + + romlist_clear (); + if (!hWinUAEKey) + return; + RegCreateKeyEx(hWinUAEKey , "DetectedROMs", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, NULL, &fkey, &disp); + if (fkey == NULL) + return; + if (disp == REG_CREATED_NEW_KEY) + scan_roms (NULL); + idx = 0; + for (;;) { + int err; + size = sizeof (tmp); + size2 = sizeof (tmp2); + err = RegEnumValue(fkey, idx, tmp, &size, NULL, NULL, tmp2, &size2); + if (err != ERROR_SUCCESS) + break; + if (strlen (tmp) == 5) { + idx2 = atol (tmp + 3); + if (idx2 >= 0 && strlen (tmp2) > 0) { + struct romdata *rd = getromdatabyid (idx2); + if (rd) + romlist_add (tmp2, rd); + } + } + idx++; + } +} + static void WIN32_HandleRegistryStuff( void ) { - RGBFTYPE colortype = RGBFB_NONE; - DWORD dwType = REG_DWORD; + RGBFTYPE colortype = RGBFB_NONE; + DWORD dwType = REG_DWORD; DWORD dwDisplayInfoSize = sizeof( colortype ); + DWORD qssize; DWORD disposition; char path[MAX_DPATH] = ""; HKEY hWinUAEKeyLocal = NULL; @@ -1554,7 +1648,7 @@ static void WIN32_HandleRegistryStuff( void ) sprintf( path, "%sWinUAE.exe -f \"%%1\" -s use_gui=yes", start_path ); RegSetValueEx( hWinUAEKeyLocal, "", 0, REG_SZ, (CONST BYTE *)path, strlen( path ) + 1 ); } - RegCloseKey( hWinUAEKeyLocal ); + RegCloseKey( hWinUAEKeyLocal ); if( ( RegCreateKeyEx( HKEY_CLASSES_ROOT, "WinUAE\\shell\\Open\\command", 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hWinUAEKeyLocal, &disposition ) == ERROR_SUCCESS ) ) @@ -1566,11 +1660,19 @@ static void WIN32_HandleRegistryStuff( void ) RegCloseKey( hWinUAEKeyLocal ); } RegCloseKey( hWinUAEKey ); + hWinUAEKey = NULL; /* Create/Open the hWinUAEKey which points our config-info */ if( RegCreateKeyEx( HKEY_CURRENT_USER, "Software\\Arabuusimiehet\\WinUAE", 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hWinUAEKey, &disposition ) == ERROR_SUCCESS ) { + initpath ("FloppyPath", start_path); + initpath ("KickstartPath", start_path); + initpath ("hdfPath", start_path); + initpath ("ConfigurationPath", start_path); + initpath ("ScreenshotPath", start_path); + initpath ("StatefilePath", start_path); + initpath ("SaveimagePath", start_path); if( disposition == REG_CREATED_NEW_KEY ) { /* Create and initialize all our sub-keys to the default values */ @@ -1580,38 +1682,45 @@ static void WIN32_HandleRegistryStuff( void ) RegSetValueEx( hWinUAEKey, "yPos", 0, REG_DWORD, (CONST BYTE *)&colortype, sizeof( colortype ) ); RegSetValueEx( hWinUAEKey, "xPosGUI", 0, REG_DWORD, (CONST BYTE *)&colortype, sizeof( colortype ) ); RegSetValueEx( hWinUAEKey, "yPosGUI", 0, REG_DWORD, (CONST BYTE *)&colortype, sizeof( colortype ) ); - RegSetValueEx( hWinUAEKey, "FloppyPath", 0, REG_SZ, (CONST BYTE *)start_path, strlen( start_path ) + 1 ); - RegSetValueEx( hWinUAEKey, "KickstartPath", 0, REG_SZ, (CONST BYTE *)start_path, strlen( start_path ) + 1 ); - RegSetValueEx( hWinUAEKey, "hdfPath", 0, REG_SZ, (CONST BYTE *)start_path, strlen( start_path ) + 1 ); } // Set this even when we're opening an existing key, so that the version info is always up to date. RegSetValueEx( hWinUAEKey, "Version", 0, REG_SZ, (CONST BYTE *)VersionStr, strlen( VersionStr ) + 1 ); - RegQueryValueEx( hWinUAEKey, "DisplayInfo", 0, &dwType, (LPBYTE)&colortype, &dwDisplayInfoSize ); - if( colortype == 0 ) /* No color information stored in the registry yet */ - { - char szMessage[ 4096 ]; - char szTitle[ MAX_DPATH ]; - WIN32GUI_LoadUIString( IDS_GFXCARDCHECK, szMessage, 4096 ); - WIN32GUI_LoadUIString( IDS_GFXCARDTITLE, szTitle, MAX_DPATH ); + RegQueryValueEx( hWinUAEKey, "DisplayInfo", 0, &dwType, (LPBYTE)&colortype, &dwDisplayInfoSize ); + if( colortype == 0 ) /* No color information stored in the registry yet */ + { + char szMessage[ 4096 ]; + char szTitle[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_GFXCARDCHECK, szMessage, 4096 ); + WIN32GUI_LoadUIString( IDS_GFXCARDTITLE, szTitle, MAX_DPATH ); - if( MessageBox( NULL, szMessage, szTitle, - MB_YESNO | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND ) == IDYES ) - { - ignore_messages_all++; - colortype = WIN32GFX_FigurePixelFormats(0); - ignore_messages_all--; - RegSetValueEx( hWinUAEKey, "DisplayInfo", 0, REG_DWORD, (CONST BYTE *)&colortype, sizeof( colortype ) ); - } - } - if( colortype ) { - /* Set the 16-bit pixel format for the appropriate modes */ - WIN32GFX_FigurePixelFormats( colortype ); - } + if( MessageBox( NULL, szMessage, szTitle, MB_YESNO | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND ) == IDYES ) + { + ignore_messages_all++; + colortype = WIN32GFX_FigurePixelFormats(0); + ignore_messages_all--; + RegSetValueEx( hWinUAEKey, "DisplayInfo", 0, REG_DWORD, (CONST BYTE *)&colortype, sizeof( colortype ) ); + } + } + if( colortype ) { + /* Set the 16-bit pixel format for the appropriate modes */ + WIN32GFX_FigurePixelFormats( colortype ); } + qssize = sizeof (quickstart); + RegQueryValueEx( hWinUAEKey, "QuickStartMode", 0, &dwType, (LPBYTE)&quickstart, &qssize ); + } + fetch_path ("ConfigurationPath", path, sizeof (path)); + path[strlen (path) - 1] = 0; + CreateDirectory (path, NULL); + strcat (path, "\\Host"); + CreateDirectory (path, NULL); + fetch_path ("ConfigurationPath", path, sizeof (path)); + strcat (path, "Hardware"); + CreateDirectory (path, NULL); fkey = read_disk_history (); if (fkey) RegCloseKey (fkey); + read_rom_list (); } static void betamessage (void) @@ -1797,16 +1906,8 @@ __asm{ if((posn = strrchr (start_path, '\\'))) posn[1] = 0; sprintf (help_file, "%sWinUAE.chm", start_path ); -#ifndef SINGLEFILE - sprintf (tmp, "%sSaveStates", start_path); - CreateDirectory (tmp, NULL); strcat (tmp, "\\default.uss"); strcpy (savestate_fname, tmp); - sprintf (tmp, "%sSaveImages", start_path); - CreateDirectory (tmp, NULL); - sprintf (tmp, "%sScreenShots", start_path); - CreateDirectory (tmp, NULL); -#endif sprintf( VersionStr, "WinUAE %d.%d.%d%s", UAEMAJOR, UAEMINOR, UAESUBREV, WINUAEBETA ? WINUAEBETASTR : "" ); logging_init (); diff --git a/od-win32/win32.h b/od-win32/win32.h index 25e5d009..4aacb372 100755 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -20,8 +20,8 @@ extern int in_sizemove; extern int manual_painting_needed; extern int manual_palette_refresh_needed; extern int mouseactive, focus; -#define WINUAEBETA 0 -#define WINUAEBETASTR " " +#define WINUAEBETA 1 +#define WINUAEBETASTR " Beta 1" extern void my_kbd_handler (int, int, int); extern void clearallkeys(void); @@ -55,6 +55,7 @@ extern char VersionStr[256]; extern int os_winnt, os_winnt_admin; extern int paraport_mask; extern int gui_active; +extern DWORD quickstart; /* For StatusBar when running in a Window */ #define LED_NUM_PARTS 10 @@ -91,5 +92,8 @@ extern int dinput_winmouse (void); void systray (HWND hwnd, int remove); void systraymenu (HWND hwnd); void exit_gui (int); +void fetch_path (char *name, char *out, int size); +void set_path (char *name, char *path); +void read_rom_list (void); #endif \ No newline at end of file diff --git a/od-win32/win32gfx.c b/od-win32/win32gfx.c index 6d9a3811..aca67e18 100755 --- a/od-win32/win32gfx.c +++ b/od-win32/win32gfx.c @@ -945,7 +945,7 @@ static int open_windows (void) currentmode->current_width = picasso_vidinfo.width; currentmode->current_height = picasso_vidinfo.height; currentmode->current_depth = rgbformat_bits (picasso_vidinfo.selected_rgbformat); - currentmode->frequency = currprefs.gfx_refreshrate > default_freq ? currprefs.gfx_refreshrate : default_freq; + currentmode->frequency = abs (currprefs.gfx_refreshrate > default_freq ? currprefs.gfx_refreshrate : default_freq); } else { #endif currentmode->current_width = currprefs.gfx_width; @@ -955,7 +955,7 @@ static int open_windows (void) : currprefs.color_mode == 2 ? 16 : currprefs.color_mode == 3 ? 8 : currprefs.color_mode == 4 ? 8 : 32); - currentmode->frequency = currprefs.gfx_refreshrate; + currentmode->frequency = abs (currprefs.gfx_refreshrate); #ifdef PICASSO96 } #endif diff --git a/od-win32/win32gfx.h b/od-win32/win32gfx.h index 40fa7566..3b614394 100755 --- a/od-win32/win32gfx.h +++ b/od-win32/win32gfx.h @@ -18,6 +18,7 @@ void WIN32GFX_PaletteChange( void ); int WIN32GFX_ClearPalette( void ); int WIN32GFX_SetPalette( void ); void WIN32GFX_WindowMove ( void ); +void WIN32GFX_WindowSize ( void );; int DX_Blit( int srcx, int srcy, int dstx, int dsty, int width, int height, BLIT_OPCODE opcode ); diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index b79150c8..2cf4b5e8 100755 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "config.h" @@ -42,6 +43,7 @@ #include "xwin.h" #include "keyboard.h" #include "zfile.h" +#include "parallel.h" #include "dxwrap.h" #include "win32.h" @@ -67,12 +69,14 @@ #define ROM_FORMAT_STRING "(*.rom;*.zip;*.roz)\0*.rom;*.zip;*.roz\0" #define USS_FORMAT_STRING_RESTORE "(*.uss;*.gz;*.zip)\0*.uss;*.gz;*.zip\0" #define USS_FORMAT_STRING_SAVE "(*.uss)\0*.uss\0" +#define CONFIG_HOST "Host" +#define CONFIG_HARDWARE "Hardware" static int allow_quit; static int full_property_sheet = 1; static struct uae_prefs *pguiprefs; struct uae_prefs workprefs; -static int currentpage, currentpage_sub; +static int currentpage; int gui_active; extern HWND (WINAPI *pHtmlHelp)(HWND, LPCSTR, UINT, LPDWORD ); @@ -107,7 +111,7 @@ static int C_PAGES; static int LOADSAVE_ID = -1, MEMORY_ID = -1, KICKSTART_ID = -1, CPU_ID = -1, DISPLAY_ID = -1, HW3D_ID = -1, CHIPSET_ID = -1, SOUND_ID = -1, FLOPPY_ID = -1, DISK_ID = -1, HARDDISK_ID = -1, PORTS_ID = -1, INPUT_ID = -1, MISC1_ID = -1, MISC2_ID = -1, AVIOUTPUT_ID = -1, - ABOUT_ID = -1; + PATHS_ID = -1, QUICKSTART_ID = -1, ABOUT_ID = -1; static HWND pages[MAX_C_PAGES]; static HWND guiDlg; @@ -142,8 +146,210 @@ static HWND cachedlist = NULL; static char szNone[ MAX_DPATH ] = "None"; + +static struct romdata *scan_rom (char *path, uae_u8 *keybuf, int keysize) +{ + uae_u8 buffer[20] = { 0 }; + uae_u8 *rombuf; + int cl = 0, size; + struct romdata *rd = 0; + struct zfile *f; + + f = zfile_fopen (path, "rb"); + if (!f) + return 0; + + zfile_fseek (f, 0, SEEK_END); + size = zfile_ftell (f); + zfile_fseek (f, 0, SEEK_SET); + if (size > 600000) { + zfile_fclose (f); + return 0; + } + zfile_fread (buffer, 1, 11, f); + if (!memcmp (buffer, "AMIROMTYPE1", 11)) { + cl = 1; + if (keybuf == 0) + cl = -1; + size -= 11; + } else { + zfile_fseek (f, 0, SEEK_SET); + } + rombuf = xcalloc (size, 1); + if (!rombuf) + return 0; + zfile_fread (rombuf, 1, size, f); + if (cl > 0) { + decode_cloanto_rom_do (rombuf, size, size, keybuf, keysize); + cl = 0; + } + if (!cl) { + rd = getromdatabydata (rombuf, size); + } + free (rombuf); + zfile_fclose (f); + return rd; +} + +static int listrom (int *roms) +{ + int i; + + i = 0; + while (roms[i] >= 0) { + struct romdata *rd = getromdatabyid (roms[i]); + if (rd && romlist_get (rd)) + return 1; + i++; + } + return 0; +} + +static void show_rom_list (void) +{ + char *p; + int roms[6], ok; + + p = malloc (100000); + if (!p) + return; + strcpy (p, "ROM scan results:\n\n"); + + strcat (p, "Amiga 500 Kickstart 1.2: "); + roms[0] = 5; roms[1] = 4; roms[2] = -1; + if (listrom (roms)) strcat (p, "available"); else strcat (p, "unavailable"); + + strcat (p, "\nAmiga 500 Kickstart 1.3: "); + roms[0] = 6; roms[1] = -1; + if (listrom (roms)) strcat (p, "available"); else strcat (p, "unavailable"); + + strcat (p, "\nAmiga 500+/600: "); + roms[0] = 7; roms[1] = 8; roms[2] = 9; roms[3] = 10; roms[4] = -1; + if (listrom (roms)) strcat (p, "available"); else strcat (p, "unavailable"); + + strcat (p, "\nAmiga 1000: "); + roms[0] = 23; roms[1] = 24; roms[2] = -1; + if (listrom (roms)) strcat (p, "available"); else strcat (p, "unavailable"); + + strcat (p, "\nAmiga 1200: "); + roms[0] = 11; roms[1] = 15; roms[2] = -1; + if (listrom (roms)) strcat (p, "available"); else strcat (p, "unavailable"); + + ok = 0; + strcat (p, "\nCD32: "); + roms[0] = 18; roms[1] = -1; + if (listrom (roms)) { + roms[0] = 19; + if (listrom (roms)) + ok = 1; + } + if (ok) strcat (p, "available"); else strcat (p, "unavailable"); + + ok = 0; + strcat (p, "\nCDTV: "); + roms[0] = 20; roms[1] = 21; roms[2] = 22; roms[3] = -1; + if (listrom (roms)) { + roms[0] = 6; roms[1] = -1; + if (listrom (roms)) + ok = 1; + } + if (ok) strcat (p, "available"); else strcat (p, "unavailable"); + + pre_gui_message (p); + free (p); +} + +int scan_roms (char *pathp) +{ + HKEY fkey; + char buf[MAX_PATH], path[MAX_PATH], tmp[100]; + WIN32_FIND_DATA find_data; + HANDLE handle; + uae_u8 *keybuf; + int keysize; + int ret; + + if (!pathp) + fetch_path ("KickstartPath", path, sizeof (path)); + else + strcpy (path, pathp); + keybuf = load_keyfile (&workprefs, path, &keysize); + strcpy (buf, path); + strcat (buf, "*.*"); + if (!hWinUAEKey) + goto end; + SHDeleteKey (hWinUAEKey, "DetectedROMs"); + RegCreateKeyEx(hWinUAEKey , "DetectedROMs", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, NULL, &fkey, NULL); + if (fkey == NULL) + goto end; + ret = 0; + handle = FindFirstFile (buf, &find_data); + if (handle == INVALID_HANDLE_VALUE) + goto end; + for (;;) { + char tmppath[MAX_PATH]; + struct romdata *rd; + strcpy (tmppath, path); + strcat (tmppath, find_data.cFileName); + rd = scan_rom (tmppath, keybuf, keysize); + if (rd) { + sprintf (tmp, "ROM%02d", rd->id); + RegSetValueEx(fkey, tmp, 0, REG_SZ, (CONST BYTE *)tmppath, strlen(tmppath) + 1); + ret = 1; + } + if (FindNextFile (handle, &find_data) == 0) { + FindClose (handle); + break; + } + } +end: + free_keyfile (keybuf); + read_rom_list (); + show_rom_list (); + return ret; +} + +struct ConfigStruct { + char Name[MAX_DPATH]; + char Path[MAX_DPATH]; + char Fullpath[MAX_DPATH]; + char Description[CFG_DESCRIPTION_LENGTH]; + int Type, Directory; + struct ConfigStruct *Parent, *Child; + int host, hardware; + HTREEITEM item; +}; + +static char *configreg[] = { "ConfigFile", "ConfigFileHardware", "ConfigFileHost" }; +static char *configreg2[] = { "", "ConfigFileHardware_Auto", "ConfigFileHost_Auto" }; +static struct ConfigStruct **configstore; +static int configstoresize, configstoreallocated, configtype, configtypepanel; + +static struct ConfigStruct *getconfigstorefrompath (char *path, char *out, int type) +{ + int i; + for (i = 0; i < configstoresize; i++) { + if (((configstore[i]->Type == 0 || configstore[i]->Type == 3) && type == 0) || (configstore[i]->Type == type)) { + char path2[MAX_DPATH]; + strcpy (path2, configstore[i]->Path); + strncat (path2, configstore[i]->Name, MAX_DPATH); + if (!strcmp (path, path2)) { + strcpy (out, configstore[i]->Fullpath); + strncat (out, configstore[i]->Name, MAX_DPATH); + return configstore[i]; + } + } + } + return 0; +} + static int cfgfile_doload (struct uae_prefs *p, const char *filename, int type) { + int v, i; + DWORD ct, size; + char tmp1[MAX_DPATH], tmp2[MAX_DPATH]; + if (type == 0) { if (p->mountinfo == currprefs.mountinfo) currprefs.mountinfo = 0; @@ -154,7 +360,26 @@ static int cfgfile_doload (struct uae_prefs *p, const char *filename, int type) #endif } default_prefs (p, type); - return cfgfile_load (p, filename, 0); + v = cfgfile_load (p, filename, 0); + if (!v) + return v; + for (i = 1; i <= 2; i++) { + if (type != i) { + size = sizeof (ct); + ct = 0; + RegQueryValueEx (hWinUAEKey, configreg2[i], 0, NULL, (LPBYTE)&ct, &size); + if (ct) { + size = sizeof (tmp1); + RegQueryValueEx (hWinUAEKey, configreg[i], 0, NULL, (LPBYTE)tmp1, &size); + if (getconfigstorefrompath (tmp1, tmp2, i)) { + v = i; + cfgfile_load (p, tmp2, &v); + } + } + } + } + v = 1; + return v; } static int gui_width = 640, gui_height = 480; @@ -247,6 +472,7 @@ void gui_display( int shortcut ) static void prefs_to_gui (struct uae_prefs *p) { workprefs = *p; + strcpy (workprefs.path_rom, "roms\\"); updatewinfsmode (&workprefs); /* Could also duplicate unknown lines, but no need - we never modify those. */ @@ -268,6 +494,32 @@ static void gui_to_prefs (void) currprefs.mountinfo = mi; } +int DirectorySelection(HWND hDlg, int flag, char *path) +{ + BROWSEINFO bi; + LPITEMIDLIST pidlBrowse; + char buf[MAX_DPATH]; + + buf[0] = 0; + bi.hwndOwner = hDlg; + bi.pidlRoot = NULL; + bi.pszDisplayName = buf; + bi.lpszTitle = "Select folder"; + bi.ulFlags = 0; + bi.lpfn = NULL; + bi.lParam = 0; + + // Browse for a folder and return its PIDL. + pidlBrowse = SHBrowseForFolder(&bi); + if (pidlBrowse != NULL) { + if (SHGetPathFromIDList(pidlBrowse, buf)) { + strcpy (path, buf); + return 1; + } + } + return 0; +} + // Common routine for popping up a file-requester // flag - 0 for floppy loading, 1 for floppy creation, 2 for loading hdf, 3 for saving hdf // flag - 4 for loading .uae config-files, 5 for saving .uae config-files @@ -281,14 +533,6 @@ static void gui_to_prefs (void) int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, char *path_out) { OPENFILENAME openFileName; - char regfloppypath[MAX_DPATH] = ""; - char regrompath[MAX_DPATH] = ""; - char reghdfpath[MAX_DPATH] = ""; - DWORD dwType = REG_SZ; - DWORD dwRFPsize = MAX_DPATH; - DWORD dwRRPsize = MAX_DPATH; - DWORD dwRHPsize = MAX_DPATH; - char full_path[MAX_DPATH] = ""; char file_name[MAX_DPATH] = ""; char init_path[MAX_DPATH] = ""; @@ -303,46 +547,31 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, char szFilter[ MAX_DPATH ] = { 0 }; memset (&openFileName, 0, sizeof (OPENFILENAME)); - if( hWinUAEKey ) - { - RegQueryValueEx( hWinUAEKey, "FloppyPath", 0, &dwType, (LPBYTE)regfloppypath, &dwRFPsize ); - RegQueryValueEx( hWinUAEKey, "KickstartPath", 0, &dwType, (LPBYTE)regrompath, &dwRRPsize ); - RegQueryValueEx( hWinUAEKey, "hdfPath", 0, &dwType, (LPBYTE)reghdfpath, &dwRHPsize ); - } strncpy( init_path, start_path, MAX_DPATH ); switch( flag ) { case 0: case 1: - if( regfloppypath[0] ) - strncpy( init_path, regfloppypath, MAX_DPATH ); - else - strncat( init_path, "..\\shared\\adf\\", MAX_DPATH ); + fetch_path ("FloppyPath", init_path, sizeof (init_path)); break; case 2: case 3: - if( reghdfpath[0] ) - strncpy( init_path, reghdfpath, MAX_DPATH ); - else - strncat( init_path, "..\\shared\\hdf\\", MAX_DPATH ); + fetch_path ("hdfPath", init_path, sizeof (init_path)); break; case 6: case 7: case 11: - if( regrompath[0] ) - strncpy( init_path, regrompath, MAX_DPATH ); - else - strncat( init_path, "..\\shared\\rom\\", MAX_DPATH ); + fetch_path ("KickstartPath", init_path, sizeof (init_path)); break; case 4: case 5: case 8: - strncat( init_path, "Configurations\\", MAX_DPATH ); + fetch_path ("ConfigurationPath", init_path, sizeof (init_path)); break; case 9: case 10: - strncat( init_path, "SaveStates\\", MAX_DPATH ); + fetch_path ("StatefilePath", init_path, sizeof (init_path)); break; } @@ -460,6 +689,14 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, openFileName.lpstrFilter = NULL; openFileName.lpstrDefExt = NULL; break; + case 13: + WIN32GUI_LoadUIString( IDS_SELECTINFO, szTitle, MAX_DPATH ); + + openFileName.lpstrTitle = szTitle; + openFileName.lpstrFilter = NULL; + openFileName.lpstrDefExt = NULL; + openFileName.lpstrInitialDir = path_out; + break; } if (all) { p = szFilter; @@ -510,6 +747,7 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, SetDlgItemText (hDlg, wParam, full_path); break; case IDC_DF0: + case IDC_DF0Q: SetDlgItemText (hDlg, IDC_DF0TEXT, full_path); strcpy( prefs->df[0], full_path ); DISK_history_add (full_path, -1); @@ -544,7 +782,7 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, { char szMessage[MAX_DPATH]; WIN32GUI_LoadUIString (IDS_COULDNOTLOADCONFIG, szMessage, MAX_DPATH); - gui_message (szMessage); + pre_gui_message (szMessage); } else { @@ -559,23 +797,18 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, cfgfile_save (&workprefs, full_path, 0); break; case IDC_ROMFILE: - SetDlgItemText( hDlg, IDC_ROMFILE, full_path ); strcpy( workprefs.romfile, full_path ); break; case IDC_ROMFILE2: - SetDlgItemText( hDlg, IDC_ROMFILE2, full_path ); strcpy( workprefs.romextfile, full_path ); break; case IDC_KEYFILE: - SetDlgItemText( hDlg, IDC_KEYFILE, full_path ); strcpy( workprefs.keyfile, full_path ); break; case IDC_FLASHFILE: - SetDlgItemText( hDlg, IDC_FLASHFILE, full_path ); strcpy( workprefs.flashfile, full_path ); break; case IDC_CARTFILE: - SetDlgItemText( hDlg, IDC_CARTFILE, full_path ); strcpy( workprefs.cartfile, full_path ); break; } @@ -588,7 +821,7 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, { *amiga_path = 0; if( hWinUAEKey ) - RegSetValueEx( hWinUAEKey, "FloppyPath", 0, REG_SZ, (CONST BYTE *)openFileName.lpstrFile, strlen( openFileName.lpstrFile ) ); + RegSetValueEx( hWinUAEKey, "FloppyPath", 0, REG_SZ, (CONST BYTE *)openFileName.lpstrFile, strlen( openFileName.lpstrFile ) + 1 ); } } else if( flag == 2 || flag == 3 ) @@ -598,7 +831,7 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, { *amiga_path = 0; if( hWinUAEKey ) - RegSetValueEx( hWinUAEKey, "hdfPath", 0, REG_SZ, (CONST BYTE *)openFileName.lpstrFile, strlen( openFileName.lpstrFile ) ); + RegSetValueEx( hWinUAEKey, "hdfPath", 0, REG_SZ, (CONST BYTE *)openFileName.lpstrFile, strlen( openFileName.lpstrFile ) + 1 ); } } else if( flag == 6 || flag == 7 ) @@ -608,7 +841,7 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, { *amiga_path = 0; if( hWinUAEKey ) - RegSetValueEx( hWinUAEKey, "KickstartPath", 0, REG_SZ, (CONST BYTE *)openFileName.lpstrFile, strlen( openFileName.lpstrFile ) ); + RegSetValueEx( hWinUAEKey, "KickstartPath", 0, REG_SZ, (CONST BYTE *)openFileName.lpstrFile, strlen( openFileName.lpstrFile ) + 1 ); } } } @@ -709,24 +942,17 @@ static const char *nth[] = { "", "second ", "third ", "fourth ", "fifth ", "sixth ", "seventh ", "eighth ", "ninth ", "tenth " }; -struct ConfigStruct { - char Name[MAX_DPATH]; - char Path[MAX_DPATH]; - char Fullpath[MAX_DPATH]; - char Description[CFG_DESCRIPTION_LENGTH]; - int Type, Directory; - struct ConfigStruct *Parent, *Child; - HTREEITEM item; -}; - static void GetConfigPath (char *path, struct ConfigStruct *parent, int noroot) { if (parent == 0) { path[0] = 0; if (!noroot) { + fetch_path ("ConfigurationPath", path, MAX_DPATH); +#if 0 if (start_path) strcpy (path, start_path); strcat (path, "Configurations\\"); +#endif } return; } @@ -749,10 +975,7 @@ struct ConfigStruct *AllocConfigStruct (void) return config; } -static struct ConfigStruct **configstore; -static int configstoresize, configstoreallocated; - -static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int usedirs) +static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int usedirs, int *level) { DWORD num_bytes = 0; char path[MAX_DPATH]; @@ -783,17 +1006,27 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u for (;;) { config = NULL; if (strcmp (find_data.cFileName, ".") && strcmp (find_data.cFileName, "..")) { + int ok = 0; config = AllocConfigStruct (); if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && usedirs) { - struct ConfigStruct *child; - strcpy (config->Name, find_data.cFileName); - config->Directory = 1; - child = GetConfigs (config, usedirs); - if (child) - config->Child = child; + if ((*level) < 2) { + struct ConfigStruct *child; + strcpy (config->Name, find_data.cFileName); + config->Directory = 1; + (*level)++; + config->Parent = configparent; + if (!stricmp (config->Name, CONFIG_HOST)) + config->host = 1; + if (!stricmp (config->Name, CONFIG_HARDWARE)) + config->hardware = 1; + child = GetConfigs (config, usedirs, level); + (*level)--; + if (child) + config->Child = child; + ok = 1; + } } else if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { char path3[MAX_DPATH]; - int ok = 0; if (strlen (find_data.cFileName) > 4 && !strcasecmp (find_data.cFileName + strlen (find_data.cFileName) - 4, ".uae")) { strcpy (path3, path); strncat (path3, find_data.cFileName, MAX_DPATH); @@ -802,13 +1035,17 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u ok = 1; } } - if (!ok) { - FreeConfigStruct (config); - config = NULL; - } + } + if (!ok) { + FreeConfigStruct (config); + config = NULL; } } if (config) { + if (configparent) { + config->host = configparent->host; + config->hardware = configparent->hardware; + } strcpy (config->Path, shortpath); strcpy (config->Fullpath, path); config->Parent = configparent; @@ -837,10 +1074,26 @@ static void FreeConfigStore (void) configstore = 0; configstoresize = configstoreallocated = 0; } -static void CreateConfigStore (void) +static struct ConfigStruct *CreateConfigStore (struct ConfigStruct *oldconfig) { + int level = 0, i; + char path[MAX_DPATH], name[MAX_DPATH]; + struct ConfigStruct *cs; + + if (oldconfig) { + strcpy (path, oldconfig->Path); + strcpy (name, oldconfig->Name); + } FreeConfigStore (); - GetConfigs (NULL, 1); + GetConfigs (NULL, 1, &level); + if (oldconfig) { + for (i = 0; i < configstoresize; i++) { + cs = configstore[i]; + if (!cs->Directory && !strcmp (path, cs->Path) && !strcmp (name, cs->Name)) + return cs; + } + } + return 0; } static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *config) @@ -848,11 +1101,7 @@ static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *conf char name[MAX_DPATH], desc[MAX_DPATH]; char path[MAX_DPATH]; static char full_path[MAX_DPATH]; - int type; - type = SendDlgItemMessage (hDlg, IDC_CONFIGTYPE, CB_GETCURSEL, 0, 0); - if (type == CB_ERR) - type = 0; full_path[0] = 0; GetDlgItemText (hDlg, IDC_EDITNAME, name, MAX_DPATH); if (flag == CONFIG_SAVE_FULL || flag == CONFIG_SAVE) { @@ -885,10 +1134,10 @@ static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *conf if (strlen (name) == 0) { char szMessage[ MAX_DPATH ]; WIN32GUI_LoadUIString( IDS_MUSTENTERNAME, szMessage, MAX_DPATH ); - gui_message( szMessage ); + pre_gui_message (szMessage); } else { strcpy (workprefs.description, desc); - cfgfile_save (&workprefs, path, type); + cfgfile_save (&workprefs, path, configtypepanel); } break; @@ -896,12 +1145,12 @@ static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *conf if (strlen (name) == 0) { char szMessage[ MAX_DPATH ]; WIN32GUI_LoadUIString( IDS_MUSTSELECTCONFIG, szMessage, MAX_DPATH ); - gui_message( szMessage ); + pre_gui_message (szMessage); } else { - if (cfgfile_doload (&workprefs, path, type) == 0) { + if (cfgfile_doload (&workprefs, path, configtypepanel) == 0) { char szMessage[ MAX_DPATH ]; WIN32GUI_LoadUIString( IDS_COULDNOTLOADCONFIG, szMessage, MAX_DPATH ); - gui_message( szMessage ); + pre_gui_message (szMessage); } else { EnableWindow (GetDlgItem (hDlg, IDC_VIEWINFO), workprefs.info[0]); } @@ -911,7 +1160,7 @@ static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *conf if (strlen (name) == 0) { char szMessage[ MAX_DPATH ]; WIN32GUI_LoadUIString( IDS_MUSTSELECTCONFIGFORDELETE, szMessage, MAX_DPATH ); - gui_message( szMessage ); + pre_gui_message (szMessage); } else { char szMessage[ MAX_DPATH ]; char szTitle[ MAX_DPATH ]; @@ -1351,7 +1600,7 @@ static int CALLBACK InfoSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM return FALSE; } -static HTREEITEM AddConfigNode (HWND hDlg, struct ConfigStruct *config, char *name, char *desc, char *path, int isdir, HTREEITEM parent) +static HTREEITEM AddConfigNode (HWND hDlg, struct ConfigStruct *config, char *name, char *desc, char *path, int isdir, int expand, HTREEITEM parent) { TVINSERTSTRUCT is; HWND TVhDlg; @@ -1374,11 +1623,13 @@ static HTREEITEM AddConfigNode (HWND hDlg, struct ConfigStruct *config, char *na is.itemex.state |= TVIS_BOLD; is.itemex.stateMask |= TVIS_BOLD; } - if (isdir < 0) { + if (expand) { is.itemex.state |= TVIS_EXPANDED; is.itemex.stateMask |= TVIS_EXPANDED; } strcat (s, name); + if (strlen (s) > 4 && !stricmp (s + strlen (s) - 4, ".uae")) + s[strlen(s) - 4] = 0; if (desc && strlen(desc) > 0) { strcat (s, " ("); strcat (s, desc); @@ -1390,12 +1641,13 @@ static HTREEITEM AddConfigNode (HWND hDlg, struct ConfigStruct *config, char *na return TreeView_InsertItem (TVhDlg, &is); } -static void LoadConfigTreeView (HWND hDlg, int idx, HTREEITEM parent) +static int LoadConfigTreeView (HWND hDlg, int idx, HTREEITEM parent) { struct ConfigStruct *cparent, *config; + int cnt = 0; if (configstoresize == 0) - return; + return cnt; if (idx < 0) { idx = 0; for (;;) { @@ -1404,21 +1656,28 @@ static void LoadConfigTreeView (HWND hDlg, int idx, HTREEITEM parent) break; idx++; if (idx >= configstoresize) - return; + return cnt; } } cparent = configstore[idx]->Parent; idx = 0; - for (;;) { + while (idx < configstoresize) { config = configstore[idx]; + if ((configtypepanel == 1 && !config->hardware) || (configtypepanel == 2 && !config->host) || (configtypepanel == 0 && (config->host || config->hardware))) { + idx++; + continue; + } if (config->Parent == cparent) { - if (config->Directory && config->Child) { - HTREEITEM par = AddConfigNode (hDlg, config, config->Name, NULL, config->Path, 1, parent); + if (config->Directory) { + HTREEITEM par = AddConfigNode (hDlg, config, config->Name, NULL, config->Path, 1, config->hardware || config->host, parent); int idx2 = 0; for (;;) { if (configstore[idx2] == config->Child) { config->item = par; - LoadConfigTreeView (hDlg, idx2, par); + if (LoadConfigTreeView (hDlg, idx2, par) == 0) { + if (!config->hardware && !config->host) + TreeView_DeleteItem (GetDlgItem(hDlg, IDC_CONFIGTREE), par); + } break; } idx2++; @@ -1426,13 +1685,15 @@ static void LoadConfigTreeView (HWND hDlg, int idx, HTREEITEM parent) break; } } else if (!config->Directory) { - config->item = AddConfigNode (hDlg, config, config->Name, config->Description, config->Path, 0, parent); + if (((config->Type == 0 || config->Type == 3) && configtype == 0) || (config->Type == configtype)) { + config->item = AddConfigNode (hDlg, config, config->Name, config->Description, config->Path, 0, 0, parent); + cnt++; + } } } idx++; - if (idx >= configstoresize) - break; } + return cnt; } static HTREEITEM InitializeConfigTreeView (HWND hDlg) @@ -1457,21 +1718,43 @@ static HTREEITEM InitializeConfigTreeView (HWND hDlg) configstore[i]->item = NULL; TreeView_DeleteAllItems (TVhDlg); GetConfigPath (path, NULL, FALSE); - parent = AddConfigNode (hDlg, NULL, path, NULL, NULL, -1, NULL); + parent = AddConfigNode (hDlg, NULL, path, NULL, NULL, 0, 1, NULL); LoadConfigTreeView (hDlg, -1, parent); return parent; } -static void ConfigToRegistry (struct ConfigStruct *config) +static void ConfigToRegistry (struct ConfigStruct *config, int type) { if (hWinUAEKey && config) { char path[MAX_DPATH]; strcpy (path, config->Path); strncat (path, config->Name, MAX_DPATH); - RegSetValueEx (hWinUAEKey, "ConfigFile", 0, REG_SZ, (CONST BYTE *)path, strlen(path)); + RegSetValueEx (hWinUAEKey, configreg[type], 0, REG_SZ, (CONST BYTE *)path, strlen(path) + 1); + } +} +static void ConfigToRegistry2 (DWORD ct, int type) +{ + if (hWinUAEKey && type > 0) { + RegSetValueEx (hWinUAEKey, configreg2[type], 0, REG_DWORD, (CONST BYTE *)&ct, sizeof (ct)); } } +static void checkautoload (HWND hDlg, struct ConfigStruct *config) +{ + int ct = 0; + DWORD dwType = REG_DWORD; + DWORD dwRFPsize = sizeof (ct); + + if (configtypepanel > 0) + RegQueryValueEx (hWinUAEKey, configreg2[configtypepanel], 0, &dwType, (LPBYTE)&ct, &dwRFPsize); + if (!config || config->Directory) { + ct = 0; + ConfigToRegistry2 (ct, configtypepanel); + } + CheckDlgButton(hDlg, IDC_CONFIGAUTO, ct ? BST_CHECKED : BST_UNCHECKED); + EnableWindow (GetDlgItem (hDlg, IDC_CONFIGAUTO), configtypepanel > 0 && config && !config->Directory ? TRUE : FALSE); +} + static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { char name_buf[MAX_DPATH]; @@ -1479,12 +1762,15 @@ static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM static int recursive; HTREEITEM root; static struct ConfigStruct *config; - int i; switch (msg) { case WM_INITDIALOG: recursive++; + if (!configstore) { + CreateConfigStore (NULL); + config = NULL; + } pages[LOADSAVE_ID] = hDlg; currentpage = LOADSAVE_ID; EnableWindow (GetDlgItem( hDlg, IDC_VIEWINFO ), workprefs.info[0]); @@ -1496,28 +1782,18 @@ static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM DWORD dwType = REG_SZ; DWORD dwRFPsize = sizeof (name_buf); char path[MAX_DPATH]; - if (RegQueryValueEx (hWinUAEKey, "ConfigFile", 0, &dwType, (LPBYTE)name_buf, &dwRFPsize) == ERROR_SUCCESS) { - for (i = 0; i < configstoresize; i++) { - strcpy (path, configstore[i]->Path); - strncat (path, configstore[i]->Name, MAX_DPATH); - if (!strcmp (name_buf, path)) { - config = configstore[i]; - break; - } - } + if (RegQueryValueEx (hWinUAEKey, configreg[configtypepanel], 0, &dwType, (LPBYTE)name_buf, &dwRFPsize) == ERROR_SUCCESS) { + struct ConfigStruct *config2 = getconfigstorefrompath (name_buf, path, configtypepanel); + if (config2) + config = config2; } + checkautoload (hDlg, config); } if (config && config->item) TreeView_SelectItem (GetDlgItem(hDlg, IDC_CONFIGTREE), config->item); else TreeView_SelectItem (GetDlgItem(hDlg, IDC_CONFIGTREE), root); -/* - SendDlgItemMessage(hDlg, IDC_CONFIGTYPE, CB_RESETCONTENT, 0, 0); - SendDlgItemMessage(hDlg, IDC_CONFIGTYPE, CB_ADDSTRING, 0, (LPARAM)"Complete configuration file"); - SendDlgItemMessage(hDlg, IDC_CONFIGTYPE, CB_ADDSTRING, 0, (LPARAM)"Hardware only configuration file"); - SendDlgItemMessage(hDlg, IDC_CONFIGTYPE, CB_ADDSTRING, 0, (LPARAM)"Host only configuration file"); - SendDlgItemMessage(hDlg, IDC_CONFIGTYPE, CB_SETCURSEL, currentpage_sub, 0); -*/ + recursive--; return TRUE; @@ -1527,29 +1803,23 @@ static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM case WM_COMMAND: switch (LOWORD (wParam)) { - case IDC_CONFIGTYPE: - if (HIWORD (wParam) == CBN_SELCHANGE) { - currentpage_sub = SendDlgItemMessage (hDlg, IDC_CONFIGTYPE, CB_GETCURSEL, 0, 0); - InitializeConfigTreeView (hDlg); - } - break; case IDC_SAVE: HandleConfiguration (hDlg, CONFIG_SAVE_FULL, config); recursive++; - CreateConfigStore (); + config = CreateConfigStore (config); InitializeConfigTreeView (hDlg); recursive--; break; case IDC_QUICKSAVE: HandleConfiguration (hDlg, CONFIG_SAVE, config); recursive++; - CreateConfigStore (); + config = CreateConfigStore (config); InitializeConfigTreeView (hDlg); recursive--; break; case IDC_QUICKLOAD: cfgfile = HandleConfiguration (hDlg, CONFIG_LOAD, config); - ConfigToRegistry (config); + ConfigToRegistry (config, configtypepanel); if (full_property_sheet) { inputdevice_updateconfig (&workprefs); } else { @@ -1559,7 +1829,7 @@ static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM break; case IDC_LOAD: cfgfile = HandleConfiguration (hDlg, CONFIG_LOAD_FULL, config); - ConfigToRegistry (config); + ConfigToRegistry (config, configtypepanel); if (full_property_sheet) { inputdevice_updateconfig (&workprefs); } else { @@ -1570,7 +1840,7 @@ static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM case IDC_DELETE: HandleConfiguration (hDlg, CONFIG_DELETE, config); recursive++; - CreateConfigStore (); + config = CreateConfigStore (config); InitializeConfigTreeView (hDlg); recursive--; break; @@ -1588,6 +1858,12 @@ static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM if (DialogBox(hUIDLL ? hUIDLL : hInst, MAKEINTRESOURCE (IDD_SETINFO), hDlg, InfoSettingsProc)) EnableWindow( GetDlgItem( hDlg, IDC_VIEWINFO ), workprefs.info[0] ); break; + case IDC_CONFIGAUTO: + if (configtypepanel > 0) { + int ct = IsDlgButtonChecked (hDlg, IDC_CONFIGAUTO) == BST_CHECKED ? 1 : 0; + ConfigToRegistry2 (ct, configtypepanel); + } + break; } break; @@ -1609,7 +1885,7 @@ static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM struct ConfigStruct *config = (struct ConfigStruct*)pitem.lParam; if (config && !config->Directory) { cfgfile = HandleConfiguration (hDlg, CONFIG_LOAD, config); - ConfigToRegistry (config); + ConfigToRegistry (config, configtypepanel); if (!full_property_sheet) uae_restart (0, cfgfile); exit_gui (1); @@ -1632,6 +1908,11 @@ static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM } SetDlgItemText (hDlg, IDC_EDITPATH, config->Path); } + if (configtypepanel > 0) { + if (config && !config->Directory) + ConfigToRegistry (config, configtypepanel); + checkautoload (hDlg, config); + } return TRUE; } break; @@ -1784,6 +2065,445 @@ static void url_handler(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam ) } } +static void setpath (HWND hDlg, char *name, DWORD d, char *def) +{ + char tmp[MAX_DPATH]; + + strcpy (tmp, def); + fetch_path (name, tmp, sizeof (tmp)); + SetDlgItemText (hDlg, d, tmp); +} + +static void values_to_pathsdialog (HWND hDlg) +{ + setpath (hDlg, "KickstartPath", IDC_PATHS_ROM, "Roms"); + setpath (hDlg, "ConfigurationPath", IDC_PATHS_CONFIG, "Configurations"); + setpath (hDlg, "ScreenshotPath", IDC_PATHS_SCREENSHOT, "ScreenShots"); + setpath (hDlg, "StatefilePath", IDC_PATHS_SAVESTATE, "Savestates"); + setpath (hDlg, "SaveimagePath", IDC_PATHS_SAVEIMAGE, "SaveImages"); +} + +static void resetregistry (void) +{ + if (!hWinUAEKey) + return; + SHDeleteKey (hWinUAEKey, "DetectedROMs"); + SHDeleteKey (hWinUAEKey, "QuickStartMode"); + SHDeleteKey (hWinUAEKey, "ConfigFile"); + SHDeleteKey (hWinUAEKey, "ConfigurationPath"); + SHDeleteKey (hWinUAEKey, "SaveimagePath"); + SHDeleteKey (hWinUAEKey, "ScreenshotPath"); + SHDeleteKey (hWinUAEKey, "StatefilePath"); + SHDeleteKey (hWinUAEKey, "QuickStartModel"); + SHDeleteKey (hWinUAEKey, "QuickStartConfiguration"); + SHDeleteKey (hWinUAEKey, "QuickStartCompatibility"); +} + +static BOOL CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static int recursive; + char tmp[MAX_DPATH]; + + switch (msg) + { + case WM_INITDIALOG: + recursive++; + pages[PATHS_ID] = hDlg; + currentpage = PATHS_ID; + values_to_pathsdialog (hDlg); + recursive--; + return TRUE; + + case WM_COMMAND: + if (recursive > 0) + break; + recursive++; + switch (LOWORD (wParam)) + { + case IDC_PATHS_ROMS: + fetch_path ("KickstartPath", tmp, sizeof (tmp)); + if (DirectorySelection (hDlg, 0, tmp)) { + if (tmp[strlen (tmp) - 1] != '\\') + strcat (tmp, "\\"); + if (scan_roms (tmp)) + set_path ("KickstartPath", tmp); + else + pre_gui_message ("No ROMs found"); + values_to_pathsdialog (hDlg); + } + break; + case IDC_PATHS_CONFIGS: + fetch_path ("ConfigurationPath", tmp, sizeof (tmp)); + if (DirectorySelection (hDlg, 0, tmp)) { + set_path ("ConfigurationPath", tmp); + values_to_pathsdialog (hDlg); + FreeConfigStore (); + } + break; + case IDC_PATHS_SCREENSHOTS: + fetch_path ("ScreenshotPath", tmp, sizeof (tmp)); + if (DirectorySelection (hDlg, 0, tmp)) { + set_path ("ScreenshotPath", tmp); + values_to_pathsdialog (hDlg); + } + break; + case IDC_PATHS_SAVESTATES: + fetch_path ("StatefilePath", tmp, sizeof (tmp)); + if (DirectorySelection (hDlg, 0, tmp)) { + set_path ("StatefilePath", tmp); + values_to_pathsdialog (hDlg); + } + break; + case IDC_PATHS_SAVEIMAGES: + fetch_path ("SaveimagePath", tmp, sizeof (tmp)); + if (DirectorySelection (hDlg, 0, tmp)) { + set_path ("SaveimagePath", tmp); + values_to_pathsdialog (hDlg); + } + break; + case IDC_PATHS_DEFAULT: + set_path ("KickstartPath", NULL); + set_path ("ConfigurationPath", NULL); + set_path ("ScreenshotPath", NULL); + set_path ("StatefilePath", NULL); + set_path ("SaveimagePath", NULL); + values_to_pathsdialog (hDlg); + break; + case IDC_ROM_RESCAN: + scan_roms (NULL); + break; + case IDC_RESETREGISTRY: + resetregistry (); + break; + } + recursive--; + } + return FALSE; +} + +struct amigamodels { + char *name; + char *compatxt[3]; +}; +static struct amigamodels amodels[] = { + { "A500", + "High compatibility (>1.5GHz recommended)", + "Medium compatibility (recommended for most users)", + "Low compatiblity (for PCs with low CPU power)" + }, + { "A500+/A600", + "High compatibility (>1.5GHz recommended)", + "Medium compatibility (recommended for most users)", + "Low compatiblity (for PCs with low CPU power)" + }, + { "A1000", + "High compatibility (>1.5GHz recommended)", + "Medium compatibility (recommended for most users)", + "Low compatiblity (for PCs with low CPU power)" + }, + { "A1200", + "Good compatibility, slow CPU emulation", + "Medium compatibility, very fast CPU emulation", + "Low compatibility, very fast CPU emulation" + }, + { "CD32", + "Good compatibility, slow CPU emulation", + "Medium compatibility, very fast CPU emulation", + "Low compatibility, very fast CPU emulation" + }, + { "CDTV", + "High compatibility (incomplete)", + "Medium compatibility (incomplete)", + "Low compatiblity (incomplete)" + }, + { 0 } +}; + +struct amigaconfig { + int model; + char *config; + char *name; +}; +static struct amigaconfig aconf[] = { + { 0, "", "KS 1.3, ECS Agnus, 0.5M Chip + 0.5M Slow" }, + { 0, "", "KS 1.3, OCS Agnus, 0.5M Chip" }, + { 0, "", "KS 1.3, ECS Agnus, 1.0M Chip" }, + { 0, "", "KS 1.2, OCS Agnus, 0.5M Chip" }, + { 0, "", "KS 1.2, OCS Agnus, 0.5M Chip + 0.5M Slow" }, + + { 1, "", "1.0M Chip" }, + + { 2, "", "0.5M Chip" }, + { 2, "", "256K Chip" }, + + { 3, "", "2.0M Chip" }, + { 3, "", "2.0M Chip + 4.0M Fast" }, + + { 4, "", "CD32" }, + + { 5, "", "CDTV" }, + + { -1 } +}; + +static DWORD quickstart_model = 0, quickstart_conf = 0, quickstart_compa = 1; +static int quickstart_ok, quickstart_ok_floppy; +static void addfloppytype (HWND hDlg, int n); + +static void enable_for_quickstart (HWND hDlg) +{ + int v = quickstart_ok && quickstart_ok_floppy ? TRUE : FALSE; + EnableWindow (GetDlgItem (guiDlg, IDOK), v); + EnableWindow (GetDlgItem (guiDlg, IDC_RESETAMIGA), v); +} + +static void load_quickstart (HWND hDlg) +{ + EnableWindow (GetDlgItem (guiDlg, IDOK), FALSE); + EnableWindow (GetDlgItem (guiDlg, IDC_RESETAMIGA), FALSE); + quickstart_ok = build_in_prefs (&workprefs, quickstart_model, quickstart_conf, quickstart_compa); + enable_for_quickstart (hDlg); + addfloppytype (hDlg, 0); + addfloppytype (hDlg, 1); +} + +static void quickstarthost (HWND hDlg, char *name) +{ + int type = CONFIG_TYPE_HOST; + char tmp[MAX_DPATH]; + + if (getconfigstorefrompath (name, tmp, CONFIG_TYPE_HOST)) + cfgfile_load (&workprefs, tmp, &type); + else + cfgfile_load (&workprefs, "default.uae", &type); +} + +static void init_quickstartdlg (HWND hDlg) +{ + static int firsttime; + int i, j, cnt, idx; + DWORD dwType, qssize; + char tmp1[MAX_DPATH], tmp2[MAX_DPATH]; + + qssize = sizeof (tmp1); + RegQueryValueEx (hWinUAEKey, "QuickStartHostConfig", 0, &dwType, (LPBYTE)tmp1, &qssize); + if (firsttime == 0) { + quickstarthost (hDlg, tmp1); + load_quickstart (hDlg); + if (hWinUAEKey) { + qssize = sizeof (quickstart_model); + RegQueryValueEx (hWinUAEKey, "QuickStartModel", 0, &dwType, (LPBYTE)&quickstart_model, &qssize); + qssize = sizeof (quickstart_conf); + RegQueryValueEx (hWinUAEKey, "QuickStartConfiguration", 0, &dwType, (LPBYTE)&quickstart_conf, &qssize); + qssize = sizeof (quickstart_compa); + RegQueryValueEx (hWinUAEKey, "QuickStartCompatibility", 0, &dwType, (LPBYTE)&quickstart_compa, &qssize); + } + firsttime = 1; + } + + CheckDlgButton (hDlg, IDC_QUICKSTARTMODE, quickstart); + + SendDlgItemMessage (hDlg, IDC_QUICKSTART_MODEL, CB_RESETCONTENT, 0, 0L); + i = 0; + while (amodels[i].name) { + SendDlgItemMessage (hDlg, IDC_QUICKSTART_MODEL, CB_ADDSTRING, 0, (LPARAM)amodels[i].name); + i++; + } + SendDlgItemMessage (hDlg, IDC_QUICKSTART_MODEL, CB_SETCURSEL, quickstart_model, 0); + + SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_RESETCONTENT, 0, 0L); + i = 0; + cnt = 0; + while (aconf[i].model >= 0) { + if (aconf[i].model == quickstart_model) { + cnt++; + SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_ADDSTRING, 0, (LPARAM)aconf[i].name); + } + i++; + } + if (quickstart_conf >= cnt) + quickstart_conf = 0; + SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_SETCURSEL, quickstart_conf, 0); + + SendDlgItemMessage (hDlg, IDC_QUICKSTART_COMPATIBILITY, CB_RESETCONTENT, 0, 0L); + i = 0; + while (i < 3 && amodels[quickstart_model].compatxt[i]) { + SendDlgItemMessage (hDlg, IDC_QUICKSTART_COMPATIBILITY, CB_ADDSTRING, 0, (LPARAM)amodels[quickstart_model].compatxt[i]); + i++; + } + if (quickstart_compa >= i) + quickstart_compa = 0; + SendDlgItemMessage (hDlg, IDC_QUICKSTART_COMPATIBILITY, CB_SETCURSEL, quickstart_compa, 0); + + SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_RESETCONTENT, 0, 0L); + SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_ADDSTRING, 0, (LPARAM)"Default configuration"); + idx = 0; + j = 1; + for (i = 0; i < configstoresize; i++) { + if (configstore[i]->Type == CONFIG_TYPE_HOST) { + strcpy (tmp2, configstore[i]->Path); + strncat (tmp2, configstore[i]->Name, MAX_DPATH); + if (!strcmp (tmp2, tmp1)) + idx = j; + SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_ADDSTRING, 0, (LPARAM)tmp2); + j++; + } + } + SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_SETCURSEL, idx, 0); + + if (hWinUAEKey) { + RegSetValueEx (hWinUAEKey, "QuickStartModel", 0, REG_DWORD, (CONST BYTE *)&quickstart_model, sizeof(quickstart_model)); + RegSetValueEx (hWinUAEKey, "QuickStartConfiguration", 0, REG_DWORD, (CONST BYTE *)&quickstart_conf, sizeof(quickstart_conf)); + RegSetValueEx (hWinUAEKey, "QuickStartCompatibility", 0, REG_DWORD, (CONST BYTE *)&quickstart_compa, sizeof(quickstart_compa)); + } +} + +static void testimage (HWND hDlg) +{ + int ret; + int reload = 0; + + quickstart_ok_floppy = 0; + if (!workprefs.df[0][0]) + return; + ret = DISK_examine_image (&workprefs, 0); + if (!ret) + return; + switch (ret) + { + case 10: + quickstart_ok_floppy = 1; + break; + case 11: + quickstart_ok_floppy = 1; + if (quickstart_model < 1) { + quickstart_model = 1; + pre_gui_message ("Selected disk image requires Kickstart 2.04 or 3.0\nConfiguration updated"); + reload = 1; + } + break; + case 12: + quickstart_ok_floppy = 1; + if (quickstart_model < 2) { + quickstart_model = 2; + pre_gui_message ("Selected disk image requires Kickstart 3.0 or later\nConfiguration updated"); + reload = 1; + } + break; + case 4: + pre_gui_message ("Selected disk image is not bootable"); + break; + case 3: + pre_gui_message ("Selected disk image has incorrect bootblock checksum"); + break; + case 2: + pre_gui_message ("Selected disk image is unformatted"); + break; + } + if (reload) { + load_quickstart (hDlg); + init_quickstartdlg (hDlg); + } +} + +static BOOL CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +static BOOL CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static int recursive; + int val, ret = FALSE; + char tmp[MAX_DPATH]; + static char df0[MAX_DPATH]; + + switch( msg ) + { + case WM_INITDIALOG: + pages[QUICKSTART_ID] = hDlg; + currentpage = QUICKSTART_ID; + init_quickstartdlg (hDlg); + enable_for_quickstart (hDlg); + addfloppytype (hDlg, 0); + addfloppytype (hDlg, 1); + break; + case WM_COMMAND: + if (recursive > 0) + break; + recursive++; + if (HIWORD (wParam) == CBN_SELCHANGE || HIWORD (wParam) == CBN_KILLFOCUS) { + switch (LOWORD (wParam)) + { + case IDC_QUICKSTART_MODEL: + val = SendDlgItemMessage (hDlg, IDC_QUICKSTART_MODEL, CB_GETCURSEL, 0, 0L); + if (val != CB_ERR && val != quickstart_model) { + quickstart_model = val; + init_quickstartdlg (hDlg); + load_quickstart (hDlg); + if (quickstart && !full_property_sheet) + uae_reset (1); + } + break; + case IDC_QUICKSTART_CONFIGURATION: + val = SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_GETCURSEL, 0, 0L); + if (val != CB_ERR && val != quickstart_conf) { + quickstart_conf = val; + init_quickstartdlg (hDlg); + load_quickstart (hDlg); + if (quickstart && !full_property_sheet) + uae_reset (1); + } + break; + case IDC_QUICKSTART_COMPATIBILITY: + val = SendDlgItemMessage (hDlg, IDC_QUICKSTART_COMPATIBILITY, CB_GETCURSEL, 0, 0L); + if (val != CB_ERR) { + quickstart_compa = val; + load_quickstart (hDlg); + } + break; + case IDC_QUICKSTART_HOSTCONFIG: + val = SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_GETCURSEL, 0, 0); + if (val != CB_ERR) { + SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_GETLBTEXT, (WPARAM)val, (LPARAM)tmp); + if (hWinUAEKey) + RegSetValueEx (hWinUAEKey, "QuickStartHostConfig", 0, REG_SZ, (CONST BYTE *)&tmp, strlen (tmp) + 1); + quickstarthost (hDlg, tmp); + } + break; + } + } else { + switch (LOWORD (wParam)) + { + case IDC_QUICKSTARTMODE: + quickstart = IsDlgButtonChecked (hDlg, IDC_QUICKSTARTMODE); + if (hWinUAEKey) + RegSetValueEx( hWinUAEKey, "QuickStartMode", 0, REG_DWORD, (CONST BYTE *)&quickstart, sizeof(quickstart)); + break; + } + } + switch (LOWORD (wParam)) + { + case IDC_DF0TEXT: + case IDC_DF0WP: + case IDC_EJECT0: + case IDC_DF0: + case IDC_DF0Q: + case IDC_DF1TEXT: + case IDC_DF1WP: + case IDC_EJECT1: + case IDC_DF1: + case IDC_DF1Q: + ret = FloppyDlgProc (hDlg, msg, wParam, lParam); + break; + } + recursive--; + } + if (strcmp (workprefs.df[0], df0)) { + strcpy (df0, workprefs.df[0]); + testimage (hDlg); + enable_for_quickstart (hDlg); + } + return ret; +} + static void init_aboutdlg (HWND hDlg) { CHARFORMAT CharFormat; @@ -2665,65 +3385,185 @@ static BOOL CALLBACK MemoryDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l return FALSE; } +static void addromfiles (HKEY fkey, HWND hDlg, DWORD d, char *path, uae_u8 *keybuf, int keysize, int type) +{ + int idx, idx2; + char tmp[1000]; + char tmp2[1000]; + char seltmp[1000]; + struct romdata *rdx; + + rdx = scan_rom (path, keybuf, keysize); + SendDlgItemMessage(hDlg, d, CB_RESETCONTENT, 0, 0); + SendDlgItemMessage(hDlg, d, CB_ADDSTRING, 0, (LPARAM)""); + idx = 0; + seltmp[0] = 0; + for (;fkey;) { + DWORD size = sizeof (tmp); + DWORD size2 = sizeof (tmp2); + int err = RegEnumValue(fkey, idx, tmp, &size, NULL, NULL, tmp2, &size2); + if (err != ERROR_SUCCESS) + break; + if (strlen (tmp) == 5) { + idx2 = atol (tmp + 3); + if (idx2 >= 0) { + struct romdata *rd = getromdatabyid (idx2); + if (rd && (rd->type & type)) { + getromname (rd, tmp); + SendDlgItemMessage(hDlg, d, CB_ADDSTRING, 0, (LPARAM)tmp); + if (rd == rdx) + strcpy (seltmp, tmp); + } + } + } + idx++; + } + if (seltmp[0]) + SendDlgItemMessage (hDlg, d, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)seltmp); + else + SetDlgItemText( hDlg, d, path); +} + +static void getromfile (HWND hDlg, DWORD d, char *path, int size) +{ + DWORD val = SendDlgItemMessage (hDlg, d, CB_GETCURSEL, 0, 0L); + if (val == CB_ERR) { + SendDlgItemMessage (hDlg, d, WM_GETTEXT, (WPARAM)size, (LPARAM)path); + } else { + char tmp1[MAX_PATH], tmp2[MAX_PATH]; + struct romdata *rd; + SendDlgItemMessage (hDlg, d, CB_GETLBTEXT, (WPARAM)val, (LPARAM)tmp1); + path[0] = 0; + rd = getromdatabyname (tmp1); + if (rd && hWinUAEKey) { + HKEY fkey; + RegCreateKeyEx(hWinUAEKey , "DetectedROMs", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, NULL, &fkey, NULL); + if (fkey) { + DWORD outsize = size; + sprintf (tmp1, "ROM%02d", rd->id); + tmp2[0] = 0; + RegQueryValueEx (fkey, tmp1, NULL, NULL, tmp2, &outsize); + RegCloseKey (fkey); + if (tmp2[0]) + strncpy (path, tmp2, size); + } + } + } +} + +static void values_from_kickstartdlg (HWND hDlg) +{ + getromfile (hDlg, IDC_ROMFILE, workprefs.romfile, sizeof (workprefs.romfile)); + getromfile (hDlg, IDC_ROMFILE2, workprefs.romextfile, sizeof (workprefs.romextfile)); + getromfile (hDlg, IDC_KEYFILE, workprefs.keyfile, sizeof (workprefs.keyfile)); + getromfile (hDlg, IDC_CARTFILE, workprefs.cartfile, sizeof (workprefs.cartfile)); +} + static void values_to_kickstartdlg (HWND hDlg) { - SetDlgItemText( hDlg, IDC_ROMFILE, workprefs.romfile ); - SetDlgItemText( hDlg, IDC_ROMFILE2, workprefs.romextfile ); - SetDlgItemText( hDlg, IDC_KEYFILE, workprefs.keyfile ); + HKEY fkey; + uae_u8 *keybuf; + int keysize; + + if (hWinUAEKey) { + RegCreateKeyEx(hWinUAEKey , "DetectedROMs", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, NULL, &fkey, NULL); + keybuf = load_keyfile (&workprefs, NULL, &keysize); + addromfiles (fkey, hDlg, IDC_ROMFILE, workprefs.romfile, keybuf, keysize, ROMTYPE_KICK | ROMTYPE_KICKCD32); + addromfiles (fkey, hDlg, IDC_ROMFILE2, workprefs.romextfile, keybuf, keysize, ROMTYPE_EXTCD32 | ROMTYPE_EXTCDTV); + addromfiles (fkey, hDlg, IDC_KEYFILE, workprefs.keyfile, keybuf, keysize, ROMTYPE_KEY); + addromfiles (fkey, hDlg, IDC_CARTFILE, workprefs.cartfile, keybuf, keysize, ROMTYPE_AR); + free_keyfile (keybuf); + if (fkey) + RegCloseKey (fkey); + } + SetDlgItemText( hDlg, IDC_FLASHFILE, workprefs.flashfile ); - SetDlgItemText( hDlg, IDC_CARTFILE, workprefs.cartfile ); CheckDlgButton( hDlg, IDC_KICKSHIFTER, workprefs.kickshifter ); CheckDlgButton( hDlg, IDC_MAPROM, workprefs.maprom ); + } -static BOOL CALLBACK KickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +static void init_kickstart (HWND hDlg) { - switch( msg ) - { - case WM_INITDIALOG: - pages[KICKSTART_ID] = hDlg; - currentpage = KICKSTART_ID; + HKEY fkey; + #if !defined(AUTOCONFIG) - EnableWindow( GetDlgItem( hDlg, IDC_MAPROM), FALSE ); + EnableWindow( GetDlgItem( hDlg, IDC_MAPROM), FALSE ); #endif #if !defined (CDTV) && !defined (CD32) - EnableWindow( GetDlgItem( hDlg, IDC_FLASHFILE), FALSE ); - EnableWindow( GetDlgItem( hDlg, IDC_ROMFILE2), FALSE ); + EnableWindow( GetDlgItem( hDlg, IDC_FLASHFILE), FALSE ); + EnableWindow( GetDlgItem( hDlg, IDC_ROMFILE2), FALSE ); #endif #if !defined (ACTION_REPLAY) - EnableWindow( GetDlgItem( hDlg, IDC_CARTFILE), FALSE ); + EnableWindow( GetDlgItem( hDlg, IDC_CARTFILE), FALSE ); #endif #if defined (UAE_MINI) - EnableWindow( GetDlgItem( hDlg, IDC_KICKSHIFTER), FALSE ); - EnableWindow( GetDlgItem( hDlg, IDC_ROMCHOOSER2), FALSE ); - EnableWindow( GetDlgItem( hDlg, IDC_CARTCHOOSER), FALSE ); - EnableWindow( GetDlgItem( hDlg, IDC_FLASHCHOOSER), FALSE ); -#endif - case WM_USER: + EnableWindow( GetDlgItem( hDlg, IDC_KICKSHIFTER), FALSE ); + EnableWindow( GetDlgItem( hDlg, IDC_ROMCHOOSER2), FALSE ); + EnableWindow( GetDlgItem( hDlg, IDC_CARTCHOOSER), FALSE ); + EnableWindow( GetDlgItem( hDlg, IDC_FLASHCHOOSER), FALSE ); +#endif + if (RegOpenKeyEx (hWinUAEKey , "DetectedROMs", 0, KEY_READ, &fkey) != ERROR_SUCCESS) + scan_roms (workprefs.path_rom); + if (fkey) + RegCloseKey (fkey); +} + +static BOOL CALLBACK KickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static int recursive; + + switch( msg ) + { + case WM_INITDIALOG: + pages[KICKSTART_ID] = hDlg; + currentpage = KICKSTART_ID; + init_kickstart (hDlg); values_to_kickstartdlg (hDlg); return TRUE; case WM_COMMAND: - switch( wParam ) + if (recursive > 0) + break; + recursive++; + if (HIWORD (wParam) == CBN_SELCHANGE || HIWORD (wParam) == CBN_KILLFOCUS) { + switch (LOWORD (wParam)) + { + case IDC_ROMFILE: + case IDC_ROMFILE2: + case IDC_KEYFILE: + case IDC_CARTFILE: + values_from_kickstartdlg (hDlg); + break; + } + } + switch (LOWORD (wParam)) { case IDC_KICKCHOOSER: DiskSelection( hDlg, IDC_ROMFILE, 6, &workprefs, 0); + values_to_kickstartdlg (hDlg); break; case IDC_ROMCHOOSER2: DiskSelection( hDlg, IDC_ROMFILE2, 6, &workprefs, 0); + values_to_kickstartdlg (hDlg); break; case IDC_KEYCHOOSER: DiskSelection( hDlg, IDC_KEYFILE, 7, &workprefs, 0); + values_to_kickstartdlg (hDlg); break; case IDC_FLASHCHOOSER: DiskSelection( hDlg, IDC_FLASHFILE, 11, &workprefs, 0); + values_to_kickstartdlg (hDlg); break; case IDC_CARTCHOOSER: DiskSelection( hDlg, IDC_CARTFILE, 6, &workprefs, 0); + values_to_kickstartdlg (hDlg); break; case IDC_KICKSHIFTER: @@ -2733,35 +3573,9 @@ static BOOL CALLBACK KickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA case IDC_MAPROM: workprefs.maprom = IsDlgButtonChecked( hDlg, IDC_MAPROM ) ? 0xe00000 : 0; break; - - default: - if( SendMessage( GetDlgItem( hDlg, IDC_ROMFILE ), EM_GETMODIFY, 0, 0 ) ) - { - GetDlgItemText( hDlg, IDC_ROMFILE, workprefs.romfile, CFG_ROM_LENGTH); - SendMessage( GetDlgItem( hDlg, IDC_ROMFILE ), EM_SETMODIFY, 0, 0 ); - } - if( SendMessage( GetDlgItem( hDlg, IDC_ROMFILE2 ), EM_GETMODIFY, 0, 0 ) ) - { - GetDlgItemText( hDlg, IDC_ROMFILE2, workprefs.romextfile, CFG_ROM_LENGTH); - SendMessage( GetDlgItem( hDlg, IDC_ROMFILE2 ), EM_SETMODIFY, 0, 0 ); - } - if( SendMessage( GetDlgItem( hDlg, IDC_KEYFILE ), EM_GETMODIFY, 0, 0 ) ) - { - GetDlgItemText( hDlg, IDC_KEYFILE, workprefs.keyfile, CFG_KEY_LENGTH); - SendMessage( GetDlgItem( hDlg, IDC_KEYFILE ), EM_SETMODIFY, 0, 0 ); - } - if( SendMessage( GetDlgItem( hDlg, IDC_FLASHFILE ), EM_GETMODIFY, 0, 0 ) ) - { - GetDlgItemText( hDlg, IDC_FLASHFILE, workprefs.flashfile, CFG_ROM_LENGTH); - SendMessage( GetDlgItem( hDlg, IDC_FLASHFILE ), EM_SETMODIFY, 0, 0 ); - } - if( SendMessage( GetDlgItem( hDlg, IDC_CARTFILE ), EM_GETMODIFY, 0, 0 ) ) - { - GetDlgItemText( hDlg, IDC_CARTFILE, workprefs.cartfile, CFG_ROM_LENGTH); - SendMessage( GetDlgItem( hDlg, IDC_CARTFILE ), EM_SETMODIFY, 0, 0 ); - } - break; + } + recursive--; break; } return FALSE; @@ -4147,6 +4961,8 @@ HKEY read_disk_history (void) char tmp[1000]; DWORD size; + if (!hWinUAEKey) + return NULL; RegCreateKeyEx(hWinUAEKey , "DiskImageMRUList", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &fkey, NULL); if (fkey == NULL || regread) @@ -4181,12 +4997,12 @@ static void out_floppyspeed (HWND hDlg) SetDlgItemText (hDlg, IDC_FLOPPYSPDTEXT, txt); } -#define BUTTONSPERFLOPPY 5 +#define BUTTONSPERFLOPPY 6 static int floppybuttons[][BUTTONSPERFLOPPY] = { - { IDC_DF0TEXT,IDC_DF0,IDC_EJECT0,IDC_DF0TYPE,IDC_DF0WP }, - { IDC_DF1TEXT,IDC_DF1,IDC_EJECT1,IDC_DF1TYPE,IDC_DF1WP }, - { IDC_DF2TEXT,IDC_DF2,IDC_EJECT2,IDC_DF2TYPE,IDC_DF2WP }, - { IDC_DF3TEXT,IDC_DF3,IDC_EJECT3,IDC_DF3TYPE,IDC_DF3WP } + { IDC_DF0TEXT,IDC_DF0,IDC_EJECT0,IDC_DF0TYPE,IDC_DF0WP,IDC_DF0Q }, + { IDC_DF1TEXT,IDC_DF1,IDC_EJECT1,IDC_DF1TYPE,IDC_DF1WP,-1 }, + { IDC_DF2TEXT,IDC_DF2,IDC_EJECT2,IDC_DF2TYPE,IDC_DF2WP,-1 }, + { IDC_DF3TEXT,IDC_DF3,IDC_EJECT3,IDC_DF3TYPE,IDC_DF3WP,-1 } }; static void addfloppytype (HWND hDlg, int n) @@ -4196,6 +5012,7 @@ static void addfloppytype (HWND hDlg, int n) int f_eject = floppybuttons[n][2]; int f_type = floppybuttons[n][3]; int f_wp = floppybuttons[n][4]; + int f_driveq = floppybuttons[n][5]; int nn = workprefs.dfxtype[n] + 1; int state, i; char *s; @@ -4209,8 +5026,10 @@ static void addfloppytype (HWND hDlg, int n) SendDlgItemMessage (hDlg, f_type, CB_SETCURSEL, nn, 0); EnableWindow(GetDlgItem(hDlg, f_text), state); - EnableWindow(GetDlgItem(hDlg, f_eject), state); + EnableWindow(GetDlgItem(hDlg, f_eject), TRUE); EnableWindow(GetDlgItem(hDlg, f_drive), state); + if (f_driveq >= 0) + EnableWindow(GetDlgItem(hDlg, f_driveq), state); CheckDlgButton(hDlg, f_wp, disk_getwriteprotect (workprefs.df[n]) && state == TRUE ? BST_CHECKED : 0); EnableWindow(GetDlgItem(hDlg, f_wp), state && DISK_validate_filename (workprefs.df[n], 0, 0) ? TRUE : FALSE); @@ -4224,7 +5043,7 @@ static void addfloppytype (HWND hDlg, int n) SendDlgItemMessage(hDlg, f_text, CB_ADDSTRING, 0, (LPARAM)s); if (fkey) { sprintf (tmp, "Image%02d", i); - RegSetValueEx(fkey, tmp, 0, REG_SZ, (CONST BYTE *)s, strlen(s)); + RegSetValueEx(fkey, tmp, 0, REG_SZ, (CONST BYTE *)s, strlen(s) + 1); } if (!strcmp (workprefs.df[n], s)) SendDlgItemMessage (hDlg, f_text, CB_SETCURSEL, i - 1, 0); @@ -4383,6 +5202,7 @@ static BOOL CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l floppysetwriteprotect (hDlg, 3, IsDlgButtonChecked (hDlg, IDC_DF3WP)); break; case IDC_DF0: + case IDC_DF0Q: DiskSelection (hDlg, wParam, 0, &workprefs, 0); disk_insert (0, workprefs.df[0]); addfloppytype (hDlg, 0); @@ -4576,6 +5396,9 @@ static void enable_for_portsdlg( HWND hDlg ) #endif #if !defined (PARALLEL_PORT) EnableWindow( GetDlgItem( hDlg, IDC_PRINTERLIST), FALSE ); + EnableWindow( GetDlgItem( hDlg, IDC_FLUSHPRINTER), FALSE ); +#else + EnableWindow( GetDlgItem( hDlg, IDC_FLUSHPRINTER), isprinteropen () ? TRUE : FALSE ); #endif } @@ -4746,7 +5569,7 @@ static void values_to_portsdlg (HWND hDlg) // Warn the user that their printer-port selection is not valid on this machine char szMessage[ MAX_DPATH ]; WIN32GUI_LoadUIString( IDS_INVALIDPRTPORT, szMessage, MAX_DPATH ); - gui_message( szMessage ); + pre_gui_message (szMessage); // Disable the invalid parallel-port selection strcpy( workprefs.prtname, "none" ); @@ -4787,7 +5610,7 @@ static void values_to_portsdlg (HWND hDlg) // Warn the user that their COM-port selection is not valid on this machine char szMessage[ MAX_DPATH ]; WIN32GUI_LoadUIString( IDS_INVALIDCOMPORT, szMessage, MAX_DPATH ); - gui_message( szMessage ); + pre_gui_message (szMessage); // Select "none" as the COM-port SendDlgItemMessage( hDlg, IDC_SERIAL, CB_SETCURSEL, 0L, 0L ); @@ -4928,15 +5751,17 @@ static BOOL CALLBACK PortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP if (recursive > 0) break; recursive++; - if( wParam == IDC_SWAP ) - { + if( wParam == IDC_SWAP ) { temp = workprefs.jport0; workprefs.jport0 = workprefs.jport1; workprefs.jport1 = temp; UpdatePortRadioButtons( hDlg ); - } - else - { + } else if (wParam == IDC_FLUSHPRINTER) { + if (isprinter ()) { + flushprinter (); + openprinter (); + } + } else { values_from_portsdlg (hDlg); UpdatePortRadioButtons( hDlg ); } @@ -5396,20 +6221,20 @@ static void values_to_hw3ddlg (HWND hDlg) scanlineindexes[i] = sl; i++; } - SendDlgItemMessage( hDlg, IDC_OPENGLSLR, CB_SETCURSEL, j, 0 ); + SendDlgItemMessage (hDlg, IDC_OPENGLSLR, CB_SETCURSEL, j, 0); - SendDlgItemMessage( hDlg, IDC_OPENGLHZ, TBM_SETPOS, TRUE, workprefs.gfx_filter_horiz_zoom); - SendDlgItemMessage( hDlg, IDC_OPENGLVZ, TBM_SETPOS, TRUE, workprefs.gfx_filter_vert_zoom); - SendDlgItemMessage( hDlg, IDC_OPENGLHO, TBM_SETPOS, TRUE, workprefs.gfx_filter_horiz_offset); - SendDlgItemMessage( hDlg, IDC_OPENGLVO, TBM_SETPOS, TRUE, workprefs.gfx_filter_vert_offset); - SendDlgItemMessage( hDlg, IDC_OPENGLSL, TBM_SETPOS, TRUE, workprefs.gfx_filter_scanlines); - SendDlgItemMessage( hDlg, IDC_OPENGLSL2, TBM_SETPOS, TRUE, workprefs.gfx_filter_scanlinelevel); - SetDlgItemInt( hDlg, IDC_OPENGLHZV, workprefs.gfx_filter_horiz_zoom, TRUE ); - SetDlgItemInt( hDlg, IDC_OPENGLVZV, workprefs.gfx_filter_vert_zoom, TRUE ); - SetDlgItemInt( hDlg, IDC_OPENGLHOV, workprefs.gfx_filter_horiz_offset, TRUE ); - SetDlgItemInt( hDlg, IDC_OPENGLVOV, workprefs.gfx_filter_vert_offset, TRUE ); - SetDlgItemInt( hDlg, IDC_OPENGLSLV, workprefs.gfx_filter_scanlines, TRUE ); - SetDlgItemInt( hDlg, IDC_OPENGLSL2V, workprefs.gfx_filter_scanlinelevel, TRUE ); + SendDlgItemMessage (hDlg, IDC_OPENGLHZ, TBM_SETPOS, TRUE, workprefs.gfx_filter_horiz_zoom); + SendDlgItemMessage (hDlg, IDC_OPENGLVZ, TBM_SETPOS, TRUE, workprefs.gfx_filter_vert_zoom); + SendDlgItemMessage (hDlg, IDC_OPENGLHO, TBM_SETPOS, TRUE, workprefs.gfx_filter_horiz_offset); + SendDlgItemMessage (hDlg, IDC_OPENGLVO, TBM_SETPOS, TRUE, workprefs.gfx_filter_vert_offset); + SendDlgItemMessage (hDlg, IDC_OPENGLSL, TBM_SETPOS, TRUE, workprefs.gfx_filter_scanlines); + SendDlgItemMessage (hDlg, IDC_OPENGLSL2, TBM_SETPOS, TRUE, workprefs.gfx_filter_scanlinelevel); + SetDlgItemInt (hDlg, IDC_OPENGLHZV, workprefs.gfx_filter_horiz_zoom, TRUE); + SetDlgItemInt (hDlg, IDC_OPENGLVZV, workprefs.gfx_filter_vert_zoom, TRUE); + SetDlgItemInt (hDlg, IDC_OPENGLHOV, workprefs.gfx_filter_horiz_offset, TRUE); + SetDlgItemInt (hDlg, IDC_OPENGLVOV, workprefs.gfx_filter_vert_offset, TRUE); + SetDlgItemInt (hDlg, IDC_OPENGLSLV, workprefs.gfx_filter_scanlines, TRUE); + SetDlgItemInt (hDlg, IDC_OPENGLSL2V, workprefs.gfx_filter_scanlinelevel, TRUE); } static void values_from_hw3ddlg (HWND hDlg) @@ -5772,6 +6597,8 @@ static HWND updatePanel (HWND hDlg, int id) RECT r1c, r1w, r2c, r2w, r3c, r3w; int w, h, pw, ph, x , y; + EnableWindow( GetDlgItem (guiDlg, IDC_RESETAMIGA ), full_property_sheet ? FALSE : TRUE); + EnableWindow( GetDlgItem (guiDlg, IDOK ), TRUE); if (chwnd != NULL) { ShowWindow (chwnd, FALSE); DestroyWindow (chwnd); @@ -5783,8 +6610,10 @@ static HWND updatePanel (HWND hDlg, int id) GetWindowRect (hDlg, &r); left = r.left; top = r.top; - RegSetValueEx (hWinUAEKey, "xPosGUI", 0, REG_DWORD, (LPBYTE)&left, sizeof(LONG)); - RegSetValueEx (hWinUAEKey, "yPosGUI", 0, REG_DWORD, (LPBYTE)&top, sizeof(LONG)); + if (hWinUAEKey) { + RegSetValueEx (hWinUAEKey, "xPosGUI", 0, REG_DWORD, (LPBYTE)&left, sizeof(LONG)); + RegSetValueEx (hWinUAEKey, "yPosGUI", 0, REG_DWORD, (LPBYTE)&top, sizeof(LONG)); + } } EnableWindow (GetDlgItem (hDlg, IDHELP), FALSE); return NULL; @@ -5878,6 +6707,8 @@ static void createTreeView (HWND hDlg, int currentpage) p = root = CreateFolderNode (TVhDlg, IDS_TREEVIEW_SETTINGS, NULL, ABOUT_ID, 0); CN(ABOUT_ID); + CN(PATHS_ID); + CN(QUICKSTART_ID); CN(LOADSAVE_ID); p = CreateFolderNode (TVhDlg, IDS_TREEVIEW_HARDWARE, root, LOADSAVE_ID, CONFIG_TYPE_HARDWARE); @@ -5913,10 +6744,14 @@ static void centerWindow (HWND hDlg) if (!isfullscreen ()) { DWORD regkeytype; DWORD regkeysize = sizeof(LONG); - if (RegQueryValueEx (hWinUAEKey, "xPosGUI", 0, ®keytype, (LPBYTE)&x, ®keysize) != ERROR_SUCCESS) - x = 0; - if (RegQueryValueEx (hWinUAEKey, "yPosGUI", 0, ®keytype, (LPBYTE)&y, ®keysize) != ERROR_SUCCESS) - y = 0; + if (hWinUAEKey) { + if (RegQueryValueEx (hWinUAEKey, "xPosGUI", 0, ®keytype, (LPBYTE)&x, ®keysize) != ERROR_SUCCESS) + x = 0; + if (RegQueryValueEx (hWinUAEKey, "yPosGUI", 0, ®keytype, (LPBYTE)&y, ®keysize) != ERROR_SUCCESS) + y = 0; + } else { + x = y = 0; + } } else { GetWindowRect (owner, &rcOwner); GetWindowRect (hDlg, &rcDlg); @@ -6018,10 +6853,14 @@ static BOOL CALLBACK DialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara case WM_INITDIALOG: guiDlg = hDlg; SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon (GetModuleHandle (NULL), MAKEINTRESOURCE(IDI_APPICON))); + if (full_property_sheet) { + char tmp[100]; + WIN32GUI_LoadUIString (IDS_STARTEMULATION, tmp, sizeof (tmp)); + SetWindowText (GetDlgItem (guiDlg, IDOK), tmp); + } centerWindow (hDlg); createTreeView (hDlg, currentpage); updatePanel (hDlg, currentpage); - EnableWindow( GetDlgItem( hDlg, IDC_RESETAMIGA ), full_property_sheet ? FALSE : TRUE); return TRUE; case WM_DROPFILES: if (dragdrop (hDlg, (HDROP)wParam, (gui_active || full_property_sheet) ? &workprefs : &changed_prefs, currentpage)) @@ -6037,7 +6876,7 @@ static BOOL CALLBACK DialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara { LPNMTREEVIEW tv = (LPNMTREEVIEW)lParam; currentpage = tv->itemNew.lParam & 0xffff; - currentpage_sub = tv->itemNew.lParam >> 16; + configtypepanel = configtype = tv->itemNew.lParam >> 16; updatePanel (hDlg, currentpage); return TRUE; } @@ -6113,7 +6952,7 @@ static int GetSettings (int all_options, HWND hwnd) prefs_to_gui (&changed_prefs); - if( !init_called ) + if (!init_called) { LOADSAVE_ID = init_page (IDD_LOADSAVE, IDI_CONFIGFILE, IDS_LOADSAVE, LoadSaveDlgProc, "gui/configurations.htm"); MEMORY_ID = init_page (IDD_MEMORY, IDI_MEMORY, IDS_MEMORY, MemoryDlgProc, "gui/ram.htm"); @@ -6137,16 +6976,21 @@ static int GetSettings (int all_options, HWND hwnd) #ifdef AVIOUTPUT AVIOUTPUT_ID = init_page (IDD_AVIOUTPUT, IDI_AVIOUTPUT, IDS_AVIOUTPUT, AVIOutputDlgProc, "gui/output.htm"); #endif + PATHS_ID = init_page (IDD_PATHS, IDI_ABOUT, IDS_PATHS, PathsDlgProc, "gui/paths.htm"); + QUICKSTART_ID = init_page (IDD_QUICKSTART, IDI_ABOUT, IDS_QUICKSTART, QuickstartDlgProc, "gui/quickstart.htm"); ABOUT_ID = init_page (IDD_ABOUT, IDI_ABOUT, IDS_ABOUT, AboutDlgProc, NULL); C_PAGES = ABOUT_ID + 1; init_called = 1; - currentpage = LOADSAVE_ID; - hMoveUp = (HICON)LoadImage( hInst, MAKEINTRESOURCE( IDI_MOVE_UP ), IMAGE_ICON, 16, 16, LR_LOADMAP3DCOLORS ); - hMoveDown = (HICON)LoadImage( hInst, MAKEINTRESOURCE( IDI_MOVE_DOWN ), IMAGE_ICON, 16, 16, LR_LOADMAP3DCOLORS ); + if (quickstart) + currentpage = QUICKSTART_ID; + else + currentpage = LOADSAVE_ID; + hMoveUp = (HICON)LoadImage (hInst, MAKEINTRESOURCE( IDI_MOVE_UP ), IMAGE_ICON, 16, 16, LR_LOADMAP3DCOLORS); + hMoveDown = (HICON)LoadImage (hInst, MAKEINTRESOURCE( IDI_MOVE_DOWN ), IMAGE_ICON, 16, 16, LR_LOADMAP3DCOLORS); } if (all_options || !configstore) - CreateConfigStore (); + CreateConfigStore (NULL); psresult = DialogBox (hUIDLL ? hUIDLL : hInst, MAKEINTRESOURCE (IDD_PANEL), hwnd, DialogProc); if (quit_program) @@ -6278,11 +7122,20 @@ void gui_filename (int num, const char *name) } -static int fsdialog (HWND *hwnd) +static int fsdialog (HWND *hwnd, DWORD *flags) { - HRESULT hr; - if (gui_active || !isfullscreen ()) + if (gui_active) { + *hwnd = guiDlg; + *flags |= MB_SETFOREGROUND; + return 0; + } + *hwnd = hAmigaWnd; + if (!isfullscreen ()) return 0; + *flags &= ~MB_SETFOREGROUND; + return 0; +/* + HRESULT hr; hr = DirectDraw_FlipToGDISurface(); if (hr != DD_OK) { write_log ("FlipToGDISurface failed, %s\n", DXError (hr)); @@ -6290,6 +7143,7 @@ static int fsdialog (HWND *hwnd) } *hwnd = NULL; return 1; +*/ } int gui_message_multibutton (int flags, const char *format,...) @@ -6301,12 +7155,20 @@ int gui_message_multibutton (int flags, const char *format,...) int fullscreen = 0; int focuso = focus; int mbflags, ret; - HWND hwnd = guiDlg; + HWND hwnd; + + mbflags = MB_ICONWARNING | MB_TASKMODAL; + if (flags == 0) + mbflags |= MB_OK; + else if (flags == 1) + mbflags |= MB_YESNO; + else if (flags == 2) + mbflags |= MB_YESNOCANCEL; pause_sound (); - flipflop = fsdialog (&hwnd); - if( flipflop ) - ShowWindow( hAmigaWnd, SW_MINIMIZE ); + flipflop = fsdialog (&hwnd, &mbflags); + if (flipflop) + ShowWindow (hAmigaWnd, SW_MINIMIZE); va_start (parms, format); vsprintf( msg, format, parms ); @@ -6315,22 +7177,15 @@ int gui_message_multibutton (int flags, const char *format,...) if (msg[strlen(msg)-1]!='\n') write_log("\n"); - WIN32GUI_LoadUIString( IDS_ERRORTITLE, szTitle, MAX_DPATH ); + WIN32GUI_LoadUIString (IDS_ERRORTITLE, szTitle, MAX_DPATH); - mbflags = MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND; - if (flags == 0) - mbflags |= MB_OK; - else if (flags == 1) - mbflags |= MB_YESNO; - else if (flags == 2) - mbflags |= MB_YESNOCANCEL; ret = MessageBox (hwnd, msg, szTitle, mbflags); - if( flipflop ) - ShowWindow( hAmigaWnd, SW_RESTORE ); + if (flipflop) + ShowWindow (hAmigaWnd, SW_RESTORE); - resume_sound(); - setmouseactive( focuso ); + resume_sound (); + setmouseactive (focuso); if (ret == IDOK) return 0; if (ret == IDYES) @@ -6350,12 +7205,13 @@ void gui_message (const char *format,...) int flipflop = 0; int fullscreen = 0; int focuso = focus; - HWND hwnd = guiDlg; + DWORD flags = MB_OK | MB_ICONWARNING | MB_TASKMODAL; + HWND hwnd; pause_sound (); - flipflop = fsdialog (&hwnd); - if( flipflop ) - ShowWindow( hAmigaWnd, SW_MINIMIZE ); + flipflop = fsdialog (&hwnd, &flags); + if (flipflop) + ShowWindow (hAmigaWnd, SW_MINIMIZE); va_start (parms, format); vsprintf( msg, format, parms ); @@ -6364,14 +7220,14 @@ void gui_message (const char *format,...) if (msg[strlen(msg)-1]!='\n') write_log("\n"); - WIN32GUI_LoadUIString( IDS_ERRORTITLE, szTitle, MAX_DPATH ); + WIN32GUI_LoadUIString (IDS_ERRORTITLE, szTitle, MAX_DPATH); - MessageBox (hwnd, msg, szTitle, MB_OK | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND); + MessageBox (hwnd, msg, szTitle, flags); - if( flipflop ) - ShowWindow( hAmigaWnd, SW_RESTORE ); + if (flipflop) + ShowWindow (hAmigaWnd, SW_RESTORE); resume_sound(); - setmouseactive( focuso ); + setmouseactive (focuso); } void pre_gui_message (const char *format,...) @@ -6384,6 +7240,8 @@ void pre_gui_message (const char *format,...) vsprintf( msg, format, parms ); va_end (parms); write_log( msg ); + if (msg[strlen(msg)-1]!='\n') + write_log("\n"); WIN32GUI_LoadUIString( IDS_ERRORTITLE, szTitle, MAX_DPATH ); diff --git a/od-win32/winuae_msvc/winuae_msvc.vcproj b/od-win32/winuae_msvc/winuae_msvc.vcproj index e90bcf3c..4bc7835f 100755 --- a/od-win32/winuae_msvc/winuae_msvc.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.vcproj @@ -43,7 +43,7 @@ + + @@ -392,6 +395,9 @@ + + @@ -482,6 +488,9 @@ + + diff --git a/readcpu.c b/readcpu.c index 8c5ece17..c61115d3 100755 --- a/readcpu.c +++ b/readcpu.c @@ -141,9 +141,31 @@ struct mnemolookup lookuptab[] = { { i_ILLG, "" }, }; -struct instr *table68k; +struct instr *table68k = 0; -STATIC_INLINE amodes mode_from_str (const char *str) +static int specialcase (uae_u16 opcode, int cpu_lev) +{ + int mode = (opcode >> 3) & 7; + int reg = opcode & 7; + + if (cpu_lev >= 2) + return cpu_lev; + /* TST.W A0, TST.L A0, TST.x (d16,PC) and TST.x (d8,PC,Xn) are 68020+ only */ + if ((opcode & 0xff00) == 0x4a00) { + if (mode == 7 && (reg == 4 || reg == 2 || reg == 3)) + return 2; + if (mode == 1) /* Ax */ + return 2; + } + /* CMPI.W #x,(d16,PC) and CMPI.W #x,(d8,PC,Xn) are 68020+ only */ + if ((opcode & 0xff00) == 0x0c00) { + if (mode == 7 && (reg == 2 || reg == 3)) + return 2; + } + return cpu_lev; +} + +static amodes mode_from_str (const char *str) { if (strncmp (str, "Dreg", 4) == 0) return Dreg; if (strncmp (str, "Areg", 4) == 0) return Areg; @@ -161,7 +183,7 @@ STATIC_INLINE amodes mode_from_str (const char *str) return 0; } -STATIC_INLINE amodes mode_from_mr (int mode, int reg) +static amodes mode_from_mr (int mode, int reg) { switch (mode) { case 0: return Dreg; @@ -716,7 +738,8 @@ static void build_insn (int insn) table68k[opc].duse = usedst; table68k[opc].stype = srctype; table68k[opc].plev = id.plevel; - table68k[opc].clev = id.cpulevel; + table68k[opc].clev = specialcase(opc, id.cpulevel); + #if 0 for (i = 0; i < 5; i++) { table68k[opc].flaginfo[i].flagset = id.flaginfo[i].flagset; diff --git a/savestate.c b/savestate.c index c7db03a7..620ef06f 100755 --- a/savestate.c +++ b/savestate.c @@ -79,28 +79,6 @@ static int replaybuffersize; char savestate_fname[MAX_DPATH]; static struct staterecord staterecords[MAX_STATERECORDS]; -static unsigned long crc_table[256]; -static void make_crc_table() -{ - unsigned long c; - int n, k; - for (n = 0; n < 256; n++) - { - c = (unsigned long)n; - for (k = 0; k < 8; k++) c = (c >> 1) ^ (c & 1 ? 0xedb88320L : 0); - crc_table[n] = c; - } -} -uae_u32 CRC32(uae_u32 crc, const uae_u8 *buf, int len) -{ - if (!crc_table[1]) make_crc_table(); - crc = crc ^ 0xffffffffL; - while (len-- > 0) { - crc = crc_table[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8); - } - return crc ^ 0xffffffffL; -} - /* functions for reading/writing bytes, shorts and longs in big-endian * format independent of host machine's endianess */ @@ -523,14 +501,17 @@ void save_state (char *filename, char *description) int len,i; char name[5]; int comp = savestate_docompress; + static int warned; #ifdef FILESYS - if (nr_units (currprefs.mountinfo)) { + if (nr_units (currprefs.mountinfo) && !warned) { + warned = 1; gui_message("WARNING: State saves do not support harddrive emulation"); } #endif custom_prepare_savestate (); + f = zfile_fopen (filename, "wb"); if (!f) return; diff --git a/uaeserial.c b/uaeserial.c new file mode 100755 index 00000000..9a00ad65 --- /dev/null +++ b/uaeserial.c @@ -0,0 +1,572 @@ + /* + * UAE - The Un*x Amiga Emulator + * + * uaeserial.device + * + * Copyright 2004 Toni Wilen + * + */ + +#include "sysconfig.h" +#include "sysdeps.h" + +#include "config.h" +#include "uae.h" +#include "threaddep/thread.h" +#include "options.h" +#include "memory.h" +#include "custom.h" +#include "events.h" +#include "newcpu.h" +#include "autoconf.h" +#include "execlib.h" +#include "native2amiga.h" + +#define MAX_ASYNC_REQUESTS 20 +#define MAX_TOTAL_DEVICES 8 +#define MAX_OPEN_DEVICES 20 + +#define ASYNC_REQUEST_NONE 0 +#define ASYNC_REQUEST_TEMP 1 + +static int log_serial = 1; + +struct devstruct { + int unit; + char *name; + int opencnt; + volatile uaecptr d_request[MAX_ASYNC_REQUESTS]; + volatile int d_request_type[MAX_ASYNC_REQUESTS]; + volatile uae_u32 d_request_data[MAX_ASYNC_REQUESTS]; + + smp_comm_pipe requests; + uae_thread_id tid; + int thread_running; + uae_sem_t sync_sem; +}; + +struct priv_devstruct { + int inuse; + int unit; + int mode; + int scsi; + int ioctl; + int noscsi; + int type; + int flags; /* OpenDevice() */ +}; + +static struct devstruct devst[MAX_TOTAL_DEVICES]; +static struct priv_devstruct pdevst[MAX_OPEN_DEVICES]; + +static uae_sem_t change_sem; + +static char *getdevname (int type) +{ + return "uaeserial.device"; +} + +static void io_log (char *msg, uaecptr request) +{ + if (log_serial) + write_log ("%s: %08X %d %08.8X %d %d io_actual=%d io_error=%d\n", + msg, request,get_word(request + 28),get_long(request + 40),get_long(request + 36),get_long(request + 44), + get_long (request + 32), get_byte (request + 31)); +} + +static void memcpyha (uae_u32 dst, char *src, int size) +{ + while (size--) + put_byte (dst++, *src++); +} + +static struct devstruct *getdevstruct (int unit) +{ + int i; + for (i = 0; i < MAX_TOTAL_DEVICES; i++) { + if (unit >= 0 && devst[i].unit == unit) return &devst[i]; + } + return 0; +} + +static struct priv_devstruct *getpdevstruct (uaecptr request) +{ + int i = get_long (request + 24); + if (i < 0 || i >= MAX_OPEN_DEVICES || pdevst[i].inuse == 0) { + write_log ("serial.device: corrupt iorequest %08.8X %d\n", request, i); + return 0; + } + return &pdevst[i]; +} + +static void *dev_thread (void *devs); +static int start_thread (struct devstruct *dev) +{ + if (dev->thread_running) + return 1; + init_comm_pipe (&dev->requests, 100, 1); + uae_sem_init (&dev->sync_sem, 0, 0); + uae_start_thread (dev_thread, dev, &dev->tid); + uae_sem_wait (&dev->sync_sem); + return dev->thread_running; +} + +static void dev_close_3 (struct devstruct *dev, struct priv_devstruct *pdev) +{ + if (!dev->opencnt) return; + dev->opencnt--; + if (!dev->opencnt) { + pdev->inuse = 0; + write_comm_pipe_u32 (&dev->requests, 0, 1); + } +} + +static uae_u32 dev_close_2 (void) +{ + uae_u32 request = m68k_areg (regs, 1); + struct priv_devstruct *pdev = getpdevstruct (request); + struct devstruct *dev; + + if (!pdev) + return 0; + dev = getdevstruct (pdev->unit); + if (log_serial) + write_log ("%s:%d close, req=%08.8X\n", getdevname (pdev->type), pdev->unit, request); + if (!dev) + return 0; + dev_close_3 (dev, pdev); + put_long (request + 24, 0); + put_word (m68k_areg(regs, 6) + 32, get_word (m68k_areg(regs, 6) + 32) - 1); + return 0; +} + +static uae_u32 dev_close (void) +{ + return dev_close_2 (); +} +static uae_u32 diskdev_close (void) +{ + return dev_close_2 (); +} + +static int openfail (uaecptr ioreq, int error) +{ + put_long (ioreq + 20, -1); + put_byte (ioreq + 31, error); + return (uae_u32)-1; +} + +static uae_u32 dev_open_2 (int type) +{ + uaecptr ioreq = m68k_areg(regs, 1); + uae_u32 unit = m68k_dreg (regs, 0); + uae_u32 flags = m68k_dreg (regs, 1); + struct devstruct *dev = getdevstruct (unit); + struct priv_devstruct *pdev = 0; + int i; + + if (log_serial) + write_log ("opening %s:%d ioreq=%08.8X\n", getdevname (type), unit, ioreq); + if (!dev) + return openfail (ioreq, 32); /* badunitnum */ + if (!dev->opencnt) { + for (i = 0; i < MAX_OPEN_DEVICES; i++) { + pdev = &pdevst[i]; + if (pdev->inuse == 0) break; + } + pdev->type = type; + pdev->unit = unit; + pdev->flags = flags; + pdev->inuse = 1; + put_long (ioreq + 24, pdev - pdevst); + start_thread (dev); + } else { + for (i = 0; i < MAX_OPEN_DEVICES; i++) { + pdev = &pdevst[i]; + if (pdev->inuse && pdev->unit == unit) break; + } + if (i == MAX_OPEN_DEVICES) + return openfail (ioreq, -1); + put_long (ioreq + 24, pdev - pdevst); + } + dev->opencnt++; + + put_word (m68k_areg(regs, 6) + 32, get_word (m68k_areg(regs, 6) + 32) + 1); + put_byte (ioreq + 31, 0); + put_byte (ioreq + 8, 7); + return 0; +} + +static uae_u32 dev_open (void) +{ + return dev_open_2 (0); +} + +static uae_u32 dev_expunge (void) +{ + return 0; +} +static uae_u32 diskdev_expunge (void) +{ + return 0; +} + +static int is_async_request (struct devstruct *dev, uaecptr request) +{ + int i = 0; + while (i < MAX_ASYNC_REQUESTS) { + if (dev->d_request[i] == request) return 1; + i++; + } + return 0; +} + +static int add_async_request (struct devstruct *dev, uaecptr request, int type, uae_u32 data) +{ + int i; + + if (log_serial) + write_log ("async request %p (%d) added\n", request, type); + i = 0; + while (i < MAX_ASYNC_REQUESTS) { + if (dev->d_request[i] == request) { + dev->d_request_type[i] = type; + dev->d_request_data[i] = data; + return 0; + } + i++; + } + i = 0; + while (i < MAX_ASYNC_REQUESTS) { + if (dev->d_request[i] == 0) { + dev->d_request[i] = request; + dev->d_request_type[i] = type; + dev->d_request_data[i] = data; + return 0; + } + i++; + } + return -1; +} + +static int release_async_request (struct devstruct *dev, uaecptr request) +{ + int i = 0; + + if (log_serial) + write_log ("async request %p removed\n", request); + while (i < MAX_ASYNC_REQUESTS) { + if (dev->d_request[i] == request) { + int type = dev->d_request_type[i]; + dev->d_request[i] = 0; + dev->d_request_data[i] = 0; + dev->d_request_type[i] = 0; + return type; + } + i++; + } + return -1; +} + +static void abort_async (struct devstruct *dev, uaecptr request, int errcode, int type) +{ + int i; + i = 0; + while (i < MAX_ASYNC_REQUESTS) { + if (dev->d_request[i] == request && dev->d_request_type[i] == ASYNC_REQUEST_TEMP) { + /* ASYNC_REQUEST_TEMP = request is processing */ + sleep_millis (10); + i = 0; + continue; + } + i++; + } + i = release_async_request (dev, request); + if (i >= 0 && log_serial) + write_log ("asyncronous request=%08.8X aborted, error=%d\n", request, errcode); +} + +static int dev_do_io (struct devstruct *dev, uaecptr request) +{ + uae_u32 command; + uae_u32 io_data = get_long (request + 40); // 0x28 + uae_u32 io_length = get_long (request + 36); // 0x24 + uae_u32 io_actual = get_long (request + 32); // 0x20 + uae_u32 io_offset = get_long (request + 44); // 0x2c + uae_u32 io_error = 0; + int async = 0; + struct priv_devstruct *pdev = getpdevstruct (request); + + if (!pdev) + return 0; + command = get_word (request+28); + + switch (command) + { + default: + io_error = -3; + break; + } + put_long (request + 32, io_actual); + put_byte (request + 31, io_error); + io_log ("dev_io",request); + return async; +} + +static int dev_can_quick (uae_u32 command) +{ +/* + switch (command) + { + return 1; + } +*/ + return 0; +} + +static int dev_canquick (struct devstruct *dev, uaecptr request) +{ + uae_u32 command = get_word (request + 28); + return dev_can_quick (command); +} + +static uae_u32 dev_beginio (void) +{ + uae_u32 request = m68k_areg(regs, 1); + uae_u8 flags = get_byte (request + 30); + int command = get_word (request + 28); + struct priv_devstruct *pdev = getpdevstruct (request); + struct devstruct *dev = getdevstruct (pdev->unit); + + put_byte (request+8, NT_MESSAGE); + if (!dev || !pdev) { + put_byte (request + 31, 32); + return get_byte (request + 31); + } + put_byte (request+31, 0); + if ((flags & 1) && dev_canquick (dev, request)) { + if (dev_do_io (dev, request)) + write_log ("device %s command %d bug with IO_QUICK\n", getdevname (pdev->type), command); + return get_byte (request + 31); + } else { + add_async_request (dev, request, ASYNC_REQUEST_TEMP, 0); + put_byte (request+30, get_byte (request + 30) & ~1); + write_comm_pipe_u32 (&dev->requests, request, 1); + return 0; + } +} + +static void *dev_thread (void *devs) +{ + struct devstruct *dev = devs; + + set_thread_priority (2); + dev->thread_running = 1; + uae_sem_post (&dev->sync_sem); + for (;;) { + uaecptr request = (uaecptr)read_comm_pipe_u32_blocking (&dev->requests); + uae_sem_wait (&change_sem); + if (!request) { + dev->thread_running = 0; + uae_sem_post (&dev->sync_sem); + uae_sem_post (&change_sem); + return 0; + } else if (dev_do_io (dev, request) == 0) { + put_byte (request + 30, get_byte (request + 30) & ~1); + release_async_request (dev, request); + uae_ReplyMsg (request); + } else { + if (log_serial) + write_log ("async request %08.8X\n", request); + } + uae_sem_post (&change_sem); + } + return 0; +} + +static uae_u32 dev_init_2 (int type) +{ + uae_u32 base = m68k_dreg (regs,0); + if (log_serial) + write_log ("%s init\n", getdevname (type)); + return base; +} + +static uae_u32 dev_init (void) +{ + return dev_init_2 (0); +} + +static uae_u32 dev_abortio (void) +{ + uae_u32 request = m68k_areg(regs, 1); + struct priv_devstruct *pdev = getpdevstruct (request); + struct devstruct *dev; + + if (!pdev) { + put_byte (request + 31, 32); + return get_byte (request + 31); + } + dev = getdevstruct (pdev->unit); + if (!dev) { + put_byte (request + 31, 32); + return get_byte (request + 31); + } + put_byte (request + 31, -2); + if (log_serial) + write_log ("abortio %s unit=%d, request=%08.8X\n", getdevname (pdev->type), pdev->unit, request); + abort_async (dev, request, -2, 0); + return 0; +} + +struct uaeserial_info { + char *name; + int num; +}; + +static struct uaeserial_info devices[] = { + { "COM1", 1 }, + { "COM2", 2 }, + { "COM3", 3 }, + { "COM4", 4 }, + { NULL } +}; + +static void dev_reset (void) +{ + int i, j; + struct uaeserial_info *uaedev; + struct devstruct *dev; + + for (i = 0; i < MAX_TOTAL_DEVICES; i++) { + dev = &devst[i]; + if (dev->opencnt > 0) { + for (j = 0; j < MAX_ASYNC_REQUESTS; j++) { + uaecptr request; + if (request = dev->d_request[i]) + abort_async (dev, request, 0, 0); + } + } + free (dev->name); + memset (dev, 0, sizeof (struct devstruct)); + dev->unit = -1; + } + for (i = 0; i < MAX_TOTAL_DEVICES; i++) { + dev = &devst[i]; + uaedev = &devices[i]; + if (!dev->name) + break; + dev->unit = uaedev->num; + dev->name = strdup (uaedev->name); + } +} + +static uaecptr ROM_serialdev_resname = 0, + ROM_serialdev_resid = 0, + ROM_serialdev_init = 0; + +uaecptr serialdev_startup (uaecptr resaddr) +{ + if (!currprefs.uaeserial) + return resaddr; + /* Build a struct Resident. This will set up and initialize + * the serial.device */ + put_word(resaddr + 0x0, 0x4AFC); + put_long(resaddr + 0x2, resaddr); + put_long(resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ + put_word(resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ + put_word(resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ + put_long(resaddr + 0xE, ROM_serialdev_resname); + put_long(resaddr + 0x12, ROM_serialdev_resid); + put_long(resaddr + 0x16, ROM_serialdev_init); /* calls scsidev_init */ + resaddr += 0x1A; + return resaddr; +} + + +void serialdev_install (void) +{ + uae_u32 functable, datatable; + uae_u32 initcode, openfunc, closefunc, expungefunc; + uae_u32 beginiofunc, abortiofunc; + + if (!currprefs.uaeserial) + return; + + ROM_serialdev_resname = ds ("uaeserial.device"); + ROM_serialdev_resid = ds ("UAE serial.device 0.2"); + + /* initcode */ + initcode = here (); + calltrap (deftrap (dev_init)); dw (RTS); + + /* Open */ + openfunc = here (); + calltrap (deftrap (dev_open)); dw (RTS); + + /* Close */ + closefunc = here (); + calltrap (deftrap (dev_close)); dw (RTS); + + /* Expunge */ + expungefunc = here (); + calltrap (deftrap (dev_expunge)); dw (RTS); + + /* BeginIO */ + beginiofunc = here (); + calltrap (deftrap (dev_beginio)); + dw (RTS); + + /* AbortIO */ + abortiofunc = here (); + calltrap (deftrap (dev_abortio)); dw (RTS); + + /* FuncTable */ + functable = here (); + dl (openfunc); /* Open */ + dl (closefunc); /* Close */ + dl (expungefunc); /* Expunge */ + dl (EXPANSION_nullfunc); /* Null */ + dl (beginiofunc); /* BeginIO */ + dl (abortiofunc); /* AbortIO */ + dl (0xFFFFFFFFul); /* end of table */ + + /* DataTable */ + datatable = here (); + dw (0xE000); /* INITBYTE */ + dw (0x0008); /* LN_TYPE */ + dw (0x0300); /* NT_DEVICE */ + dw (0xC000); /* INITLONG */ + dw (0x000A); /* LN_NAME */ + dl (ROM_serialdev_resname); + dw (0xE000); /* INITBYTE */ + dw (0x000E); /* LIB_FLAGS */ + dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */ + dw (0xD000); /* INITWORD */ + dw (0x0014); /* LIB_VERSION */ + dw (0x0004); /* 0.4 */ + dw (0xD000); /* INITWORD */ + dw (0x0016); /* LIB_REVISION */ + dw (0x0000); /* end of table already ??? */ + dw (0xC000); /* INITLONG */ + dw (0x0018); /* LIB_IDSTRING */ + dl (ROM_serialdev_resid); + dw (0x0000); /* end of table */ + + ROM_serialdev_init = here (); + dl (0x00000100); /* size of device base */ + dl (functable); + dl (datatable); + dl (initcode); +} + +void serialdev_start_threads (void) +{ +} + +void serialdev_reset (void) +{ + if (!currprefs.uaeserial) + return; + dev_reset (); +} \ No newline at end of file