From f09b1efb56e04edb4152515db1c657f38404afa1 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 26 Oct 2013 16:06:20 +0300 Subject: [PATCH] 2700b10 --- blitter.cpp | 6 +- cfgfile.cpp | 1 + custom.cpp | 62 +++-- disk.cpp | 51 +++- drawing.cpp | 9 +- fpp.cpp | 56 ++-- gencpu.cpp | 90 +++++-- include/cpu_prefetch.h | 8 +- include/disk.h | 2 + include/inputdevice.h | 3 + include/newcpu.h | 6 +- inputdevice.cpp | 205 +++++++++++++-- main.cpp | 6 +- newcpu.cpp | 87 ++++--- od-win32/mman.cpp | 15 +- od-win32/resources/resource.h | 8 +- od-win32/resources/winuae.rc | 21 +- od-win32/srcrelease.cmd | 1 + od-win32/sysconfig.h | 6 +- od-win32/win32.h | 4 +- od-win32/win32gui.cpp | 242 +++++++++--------- od-win32/winuae_msvc10/winuae_msvc.vcxproj | 2 +- .../winuae_msvc10/winuae_msvc.vcxproj.filters | 6 +- od-win32/winuae_msvc11/winuae_msvc.vcxproj | 4 +- .../winuae_msvc11/winuae_msvc.vcxproj.filters | 6 +- 25 files changed, 633 insertions(+), 274 deletions(-) diff --git a/blitter.cpp b/blitter.cpp index c6a84299..c17cb4f4 100644 --- a/blitter.cpp +++ b/blitter.cpp @@ -69,7 +69,7 @@ static int blit_cyclecounter, blit_waitcyclecounter; static int blit_maxcyclecounter, blit_slowdown, blit_totalcyclecounter; static int blit_startcycles, blit_misscyclecounter; -#ifdef CPUEMU_12 +#ifdef CPUEMU_13 extern uae_u8 cycle_line[256]; #endif @@ -683,7 +683,7 @@ STATIC_INLINE void blitter_nxline (void) bltstate = BLT_read; } -#ifdef CPUEMU_12 +#ifdef CPUEMU_13 static int blitter_cyclecounter; static int blitter_hcounter1, blitter_hcounter2; @@ -831,7 +831,7 @@ void blitter_handler (uae_u32 data) blitter_doit (); } -#ifdef CPUEMU_12 +#ifdef CPUEMU_13 static uae_u32 preva, prevb; STATIC_INLINE uae_u16 blitter_doblit (void) diff --git a/cfgfile.cpp b/cfgfile.cpp index 3cfd9d20..f18539d9 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -3832,6 +3832,7 @@ static int cfgfile_load_2 (struct uae_prefs *p, const TCHAR *filename, bool real if (real) { p->config_version = 0; config_newfilesystem = 0; + store_inputdevice_config (p); //reset_inputdevice_config (p); } diff --git a/custom.cpp b/custom.cpp index 000feda2..3dfc420f 100644 --- a/custom.cpp +++ b/custom.cpp @@ -253,7 +253,7 @@ static int last_sprite_point, nr_armed; static int sprite_width, sprres; int sprite_buffer_res; -#ifdef CPUEMU_12 +#ifdef CPUEMU_13 uae_u8 cycle_line[256]; #endif @@ -264,6 +264,8 @@ static uae_s16 bpl1mod, bpl2mod, dbpl1mod, dbpl2mod; static int dbpl1mod_on, dbpl2mod_on; static uaecptr prevbpl[2][MAXVPOS][8]; static uaecptr bplpt[8], bplptx[8]; +static uaecptr dbplpt[8]; +static int dbplpt_on[8], dbplpt_on2; /*static int blitcount[256]; blitter debug */ @@ -458,7 +460,7 @@ STATIC_INLINE void setclr (uae_u16 *p, uae_u16 val) STATIC_INLINE void alloc_cycle (int hpos, int type) { -#ifdef CPUEMU_12 +#ifdef CPUEMU_13 #if 0 if (cycle_line[hpos]) write_log (_T("hpos=%d, old=%d, new=%d\n"), hpos, cycle_line[hpos], type); @@ -659,7 +661,7 @@ STATIC_INLINE int GET_PLANES_LIMIT (uae_u16 bc0) /* Programmed rates or superhires (!) disable normal DMA limits */ #define HARD_DDF_START (HARD_DDF_LIMITS_DISABLED ? 0x04 : 0x18) -static void reset_bplmod (void) +static void reset_bpldelays (void) { if (dbpl1mod_on > 0) { bpl1mod = dbpl1mod; @@ -669,6 +671,15 @@ static void reset_bplmod (void) bpl2mod = dbpl2mod; dbpl2mod_on = 0; } + if (dbplpt_on2) { + for (int i = 0; i < MAX_PLANES; i++) { + if (dbplpt_on[i] > 0) { + bplpt[i] = (bplpt[i] & 0xffff0000) | (dbplpt[i] & 0x0000fffe); + dbplpt_on[i] = 0; + } + } + dbplpt_on2 = 0; + } } static void add_modulo (int hpos, int nr) @@ -694,14 +705,14 @@ static void add_modulo (int hpos, int nr) mod = bpl1mod; bplpt[nr] += mod; bplptx[nr] += mod; - reset_bplmod (); + reset_bpldelays (); } static void add_modulos (void) { int m1, m2; - reset_bplmod (); + reset_bpldelays (); if (fmode & 0x4000) { if (((diwstrt >> 8) ^ vpos) & 1) m1 = m2 = bpl2mod; @@ -1042,7 +1053,7 @@ static void setup_fmodes (int hpos) fetch_modulo_cycle = fetchunit - fetchstart; // wacky pixels / raf megademo hires unaligned scroller feature - if (thisline_decision.plfleft < 0) { + if ((thisline_decision.plfleft < 0) && bplcon0_res >= RES_HIRES) { if (fetch_cycle & (fetchunit >> 1)) { fetch_cycle &= ~(fetchunit_mask >> 1); fetch_cycle += fetchunit; @@ -2157,8 +2168,11 @@ STATIC_INLINE void decide_line (int hpos) { /* Take care of the vertical DIW. */ if (vpos == plffirstline) { - diwstate = DIW_waiting_stop; - ddf_change = vpos; + // A1000 Agnus won't start bitplane DMA if vertical diw is zero. + if (vpos > 0 || (vpos == 0 && !currprefs.cs_dipagnus)) { + diwstate = DIW_waiting_stop; + ddf_change = vpos; + } } if (vpos == plflastline) { diwstate = DIW_waiting_start; @@ -2986,7 +3000,7 @@ static void reset_decisions (void) bpldmasetupphase = 0; ddfstrt_old_hpos = -1; bpldmawasactive = false; - reset_bplmod (); + reset_bpldelays (); if (plf_state > plf_active) plf_state = plf_idle; @@ -4144,6 +4158,10 @@ static void BPLxPTH (int hpos, uae_u16 v, int num) { decide_line (hpos); decide_fetch (hpos); + if (dbplpt_on[num]) { + bplpt[num] = (bplpt[num] & 0xffff0000) | (dbplpt[num] & 0x0000fffe); + dbplpt_on[num] = 0; + } bplpt[num] = (bplpt[num] & 0x0000ffff) | ((uae_u32)v << 16); bplptx[num] = (bplptx[num] & 0x0000ffff) | ((uae_u32)v << 16); //write_log (_T("%d:%d:BPL%dPTH %08X COP=%08x\n"), hpos, vpos, num, bplpt[num], cop_state.ip); @@ -4155,10 +4173,20 @@ static void BPLxPTL (int hpos, uae_u16 v, int num) /* chipset feature: BPLxPTL write and next cycle doing DMA fetch using same pointer register -> * this write goes nowhere (same happens with all DMA channels, not just BPL) * (intro MoreNewStuffy by PlasmaForce) + * + * NEW: last fetch block does not have this side-effect, probably due to modulo adds. + * Also it seems only plane 0 fetches have this feature */ /* only detect copper accesses to prevent too fast CPU mode glitches */ - if (copper_access && is_bitplane_dma (hpos + 1) == num + 1) + if (copper_access && num == 0 && is_bitplane_dma (hpos + 1) == num + 1) { + if (plf_state < plf_wait_stop) + return; + /* modulo adds use old value! Argh! */ + dbplpt[num] = (bplpt[num] & 0xffff0000) | (v & 0x0000fffe); + dbplpt_on[num] = hpos + 1; + dbplpt_on2 = 1; return; + } bplpt[num] = (bplpt[num] & 0xffff0000) | (v & 0x0000fffe); bplptx[num] = (bplptx[num] & 0xffff0000) | (v & 0x0000fffe); //write_log (_T("%d:%d:BPL%dPTL %08X COP=%08x\n"), hpos, vpos, num, bplpt[num], cop_state.ip); @@ -4301,7 +4329,7 @@ static void BPL1MOD (int hpos, uae_u16 v) // write to BPLxMOD one cycle before // BPL fetch that also adds modulo: // Old BPLxMOD value is added. - if (is_bitplane_dma (hpos + 1) & 1) { + if (1 && (is_bitplane_dma (hpos + 1) & 1)) { dbpl1mod = v; dbpl1mod_on = hpos + 1; } else { @@ -4317,7 +4345,7 @@ static void BPL2MOD (int hpos, uae_u16 v) decide_line (hpos); decide_fetch (hpos); } - if (is_bitplane_dma (hpos + 1) & 2) { + if (1 && (is_bitplane_dma (hpos + 1) & 2)) { dbpl2mod = v; dbpl2mod_on = hpos + 1; } else { @@ -6605,7 +6633,7 @@ STATIC_INLINE bool is_last_line (void) static void hsync_handler_post (bool onvsync) { last_copper_hpos = 0; -#ifdef CPUEMU_12 +#ifdef CPUEMU_13 if (currprefs.cpu_cycle_exact || currprefs.blitter_cycle_exact) { memset (cycle_line, 0, sizeof cycle_line); } @@ -6678,7 +6706,7 @@ static void hsync_handler_post (bool onvsync) vsync_handler_post (); vpos_count = 0; } - // DIP Agnus (8361): vblank interrupt is triggered on line 1! + // A1000 DIP Agnus (8361): vblank interrupt is triggered on line 1! if (currprefs.cs_dipagnus) { if (vpos == 1) send_interrupt (5, 1 * CYCLE_UNIT); @@ -6691,7 +6719,7 @@ static void hsync_handler_post (bool onvsync) lof_lastline = lof_store != 0; } -#ifdef CPUEMU_12 +#ifdef CPUEMU_13 if (currprefs.cpu_cycle_exact || currprefs.blitter_cycle_exact) { int hp = maxhpos - 1, i; for (i = 0; i < 4; i++) { @@ -8333,6 +8361,8 @@ void check_prefs_changed_custom (void) currprefs.cs_mbdmac = changed_prefs.cs_mbdmac; currprefs.cs_df0idhw = changed_prefs.cs_df0idhw; currprefs.cs_slowmemisfast = changed_prefs.cs_slowmemisfast; + currprefs.cs_dipagnus = changed_prefs.cs_dipagnus; + currprefs.cs_denisenoehb = changed_prefs.cs_denisenoehb; if (currprefs.chipset_mask != changed_prefs.chipset_mask || currprefs.picasso96_nocustom != changed_prefs.picasso96_nocustom || @@ -8354,7 +8384,7 @@ void check_prefs_changed_custom (void) #endif } -#ifdef CPUEMU_12 +#ifdef CPUEMU_13 STATIC_INLINE void sync_copper (int hpos) { diff --git a/disk.cpp b/disk.cpp index b2bd64df..c3a0039c 100644 --- a/disk.cpp +++ b/disk.cpp @@ -237,14 +237,17 @@ static void writeimageblock (struct zfile *dst, uae_u8 *sector, int offset) zfile_fwrite (sector, FS_FLOPPY_BLOCKSIZE, 1, dst); } -static void disk_checksum (uae_u8 *p, uae_u8 *c) +static uae_u32 disk_checksum (uae_u8 *p, uae_u8 *c) { uae_u32 cs = 0; int i; for (i = 0; i < FS_FLOPPY_BLOCKSIZE; i+= 4) cs += (p[i] << 24) | (p[i+1] << 16) | (p[i+2] << 8) | (p[i+3] << 0); cs = -cs; - c[0] = cs >> 24; c[1] = cs >> 16; c[2] = cs >> 8; c[3] = cs >> 0; + if (c) { + c[0] = cs >> 24; c[1] = cs >> 16; c[2] = cs >> 8; c[3] = cs >> 0; + } + return cs; } static int dirhash (const uae_char *name) @@ -3655,6 +3658,24 @@ void DISK_reset (void) setamax (); } +static void load_track (int num, int cyl, int side, int *sectable) +{ + int oldcyl, oldside, drvsec; + + drive *drv = &floppy[num]; + + oldcyl = drv->cyl; + oldside = side; + drv->cyl = cyl; + side = 0; + drv->buffered_cyl = -1; + drive_fill_bigbuf (drv, 1); + decode_buffer (drv->bigmfmbuf, drv->cyl, 11, drv->ddhd, drv->filetype, &drvsec, sectable, 1); + drv->cyl = oldcyl; + side = oldside; + drv->buffered_cyl = -1; +} + int DISK_examine_image (struct uae_prefs *p, int num, struct diskinfo *di) { int drvsec; @@ -3666,7 +3687,7 @@ int DISK_examine_image (struct uae_prefs *p, int num, struct diskinfo *di) int oldcyl, oldside; ret = 0; - memset (di, 0, sizeof di); + memset (di, 0, sizeof (struct diskinfo)); di->unreadable = true; oldcyl = drv->cyl; oldside = side; @@ -3685,7 +3706,7 @@ int DISK_examine_image (struct uae_prefs *p, int num, struct diskinfo *di) side = oldside; if (sectable[0] == 0 || sectable[1] == 0) { ret = 2; - goto end; + goto end2; } crc = crc2 = 0; for (i = 0; i < 1024; i += 4) { @@ -3714,6 +3735,10 @@ int DISK_examine_image (struct uae_prefs *p, int num, struct diskinfo *di) goto end; } di->bb_crc_valid = true; + writebuffer[4] = writebuffer[5] = writebuffer[6] = writebuffer[7] = 0; + if (get_crc32 (writebuffer, 0x31) == 0xae5e282c) { + di->bootblocktype = 1; + } if (dos == 0x444f5300) ret = 10; else if (dos == 0x444f5301 || dos == 0x444f5302 || dos == 0x444f5303) @@ -3722,7 +3747,25 @@ int DISK_examine_image (struct uae_prefs *p, int num, struct diskinfo *di) ret = 12; else ret = 4; + uae_u32 v = get_crc32 (writebuffer + 8, 0x5c - 8); + if (ret >= 10 && v == 0xe158ca4b) { + di->bootblocktype = 2; + } end: + load_track (num, 40, 0, sectable); + if (sectable[0]) { + if (!disk_checksum (writebuffer, NULL) && + writebuffer[0] == 0 && writebuffer[1] == 0 && writebuffer[2] == 0 && writebuffer[3] == 2 && + writebuffer[508] == 0 && writebuffer[509] == 0 && writebuffer[510] == 0 && writebuffer[511] == 1) { + writebuffer[512 - 20 * 4 + 1 + writebuffer[512 - 20 * 4]] = 0; + TCHAR *n = au ((const char*)(writebuffer + 512 - 20 * 4 + 1)); + if (_tcslen (n) >= sizeof (di->diskname)) + n[sizeof (di->diskname) - 1] = 0; + _tcscpy (di->diskname, n); + xfree (n); + } + } +end2: drive_image_free (drv); if (wasdelayed > 1) { drive_eject (drv); diff --git a/drawing.cpp b/drawing.cpp index a90a691f..2938d0a6 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -733,16 +733,17 @@ static void pfield_init_linetoscr (void) int ddf_left = dp_for_drawing->plfleft * 2 + DIW_DDF_OFFSET; int ddf_right = dp_for_drawing->plfright * 2 + DIW_DDF_OFFSET; int leftborderhidden; + int native_ddf_left2; /* Compute datafetch start/stop in pixels; native display coordinates. */ native_ddf_left = coord_hw_to_window_x (ddf_left); native_ddf_right = coord_hw_to_window_x (ddf_right); -#if 0 - // this breaks Blerkenwiegel/Scoopex + // Blerkenwiegel/Scoopex workaround + native_ddf_left2 = native_ddf_left; if (native_ddf_left < 0) native_ddf_left = 0; -#endif + if (native_ddf_right < native_ddf_left) native_ddf_right = native_ddf_left; @@ -837,7 +838,7 @@ static void pfield_init_linetoscr (void) pixels_offset = MAX_PIXELS_PER_LINE - (ddf_left << bplres); ddf_left <<= bplres; - leftborderhidden = playfield_start - native_ddf_left; + leftborderhidden = playfield_start - native_ddf_left2; if (hblank_left_start > playfield_start) leftborderhidden += hblank_left_start - playfield_start; src_pixel = MAX_PIXELS_PER_LINE + res_shift_from_window (leftborderhidden); diff --git a/fpp.cpp b/fpp.cpp index 45da4737..a8e6c392 100644 --- a/fpp.cpp +++ b/fpp.cpp @@ -641,6 +641,8 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src, uaec uae_u32 ad = 0; static const int sz1[8] = { 4, 4, 12, 12, 2, 8, 1, 0 }; static const int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 }; + int exts[3]; + int doext = 0; if (!(extra & 0x4000)) { if (fault_if_no_fpu (opcode, extra, 0, oldpc)) @@ -708,10 +710,30 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src, uaec ad = x_cp_get_disp_ea_020 (m68k_getpc (), 0); break; case 4: - ad = m68k_getpc (); - m68k_setpc (ad + sz2[size]); - if (size == 6) - ad++; + doext = 1; + switch (size) + { + case 0: + case 1: + exts[0] = x_next_ilong (); + break; + case 2: + case 3: + exts[0] = x_next_ilong (); + exts[1] = x_next_ilong (); + exts[2] = x_next_ilong (); + break; + case 4: + exts[0] = x_next_iword (); + break; + case 5: + exts[0] = x_next_ilong (); + exts[1] = x_next_ilong (); + break; + case 6: + exts[0] = x_next_iword (); + break; + } break; default: return 0; @@ -724,21 +746,21 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src, uaec switch (size) { case 0: - *src = (fptype) (uae_s32) x_cp_get_long (ad); + *src = (fptype) (uae_s32) (doext ? exts[0] : x_cp_get_long (ad)); break; case 1: - *src = to_single (x_cp_get_long (ad)); + *src = to_single ((doext ? exts[0] : x_cp_get_long (ad))); break; case 2: { if (fault_if_4060 (opcode, extra, ad, oldpc, FPU_EXP_UNIMP_DATATYPE)) return -1; uae_u32 wrd1, wrd2, wrd3; - wrd1 = x_cp_get_long (ad); + wrd1 = (doext ? exts[0] : x_cp_get_long (ad)); ad += 4; - wrd2 = x_cp_get_long (ad); + wrd2 = (doext ? exts[1] : x_cp_get_long (ad)); ad += 4; - wrd3 = x_cp_get_long (ad); + wrd3 = (doext ? exts[2] : x_cp_get_long (ad)); *src = to_exten (wrd1, wrd2, wrd3); } break; @@ -747,28 +769,28 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src, uaec if (fault_if_4060 (opcode, extra, ad, oldpc, FPU_EXP_UNIMP_DATATYPE)) return -1; uae_u32 wrd1, wrd2, wrd3; - wrd1 = x_cp_get_long (ad); + wrd1 = (doext ? exts[0] : x_cp_get_long (ad)); ad += 4; - wrd2 = x_cp_get_long (ad); + wrd2 = (doext ? exts[1] : x_cp_get_long (ad)); ad += 4; - wrd3 = x_cp_get_long (ad); + wrd3 = (doext ? exts[2] : x_cp_get_long (ad)); *src = to_pack (wrd1, wrd2, wrd3); } break; case 4: - *src = (fptype) (uae_s16) x_cp_get_word (ad); + *src = (fptype) (uae_s16) (doext ? exts[0] : x_cp_get_word (ad)); break; case 5: { uae_u32 wrd1, wrd2; - wrd1 = x_cp_get_long (ad); + wrd1 = (doext ? exts[0] : x_cp_get_long (ad)); ad += 4; - wrd2 = x_cp_get_long (ad); + wrd2 = (doext ? exts[1] : x_cp_get_long (ad)); *src = to_double (wrd1, wrd2); } break; case 6: - *src = (fptype) (uae_s8) x_cp_get_byte (ad); + *src = (fptype) (uae_s8) (doext ? exts[0] : x_cp_get_byte (ad)); break; default: return 0; @@ -855,10 +877,12 @@ STATIC_INLINE int put_fp_value (fptype value, uae_u32 opcode, uae_u16 extra, uae case 3: ad = x_cp_get_disp_ea_020 (m68k_getpc (), 0); break; +#if 0 case 4: ad = m68k_getpc (); m68k_setpc (ad + sz2[size]); break; +#endif default: return 0; } diff --git a/gencpu.cpp b/gencpu.cpp index b6d0c5cc..afe669e9 100644 --- a/gencpu.cpp +++ b/gencpu.cpp @@ -194,24 +194,32 @@ static void addcycles_ce020 (int cycles) addcycles_ce020 (cycles, NULL); } -static void get_prefetch_ce020 (void) +static void get_prefetch_020 (void) { - if (!using_ce020) + if (!using_prefetch_020) return; printf ("\tregs.irc = %s (%d);\n", prefetch_word, m68k_pc_offset); } -static void get_prefetch_ce020_0 (void) +static void get_prefetch_020_0 (void) { - if (!using_ce020) + if (!using_prefetch_020) return; printf ("\tregs.irc = %s (0);\n", prefetch_word); } - static void returntail (bool iswrite) { - if (!using_ce020) + if (!using_ce020) { + if (using_prefetch_020) { + if (!tail_ce020_done) { + if (!did_prefetch) + get_prefetch_020 (); + did_prefetch = 1; + tail_ce020_done = true; + } + } return; + } if (!tail_ce020_done) { total_ce020 -= 2; if (iswrite) { @@ -225,7 +233,7 @@ static void returntail (bool iswrite) total_ce020 = 1; } if (!did_prefetch) - get_prefetch_ce020 (); + get_prefetch_020 (); if (total_ce020 > 0) addcycles_ce020 (total_ce020); @@ -1932,7 +1940,7 @@ static void genmovemel (uae_u16 opcode) } count_ncycles++; fill_prefetch_next (); - get_prefetch_ce020 (); + get_prefetch_020 (); } static void genmovemel_ce (uae_u16 opcode) @@ -2019,7 +2027,7 @@ static void genmovemle (uae_u16 opcode) } count_ncycles++; fill_prefetch_next (); - get_prefetch_ce020 (); + get_prefetch_020 (); } static void genmovemle_ce (uae_u16 opcode) @@ -2376,7 +2384,6 @@ static int islongimm (struct instr *curi) static void resetvars (void) { - memory_cycle_cnt = 4; insn_n_cycles = using_prefetch ? 0 : 4; insn_n_cycles020 = 0; ir2irc = 0; @@ -2442,7 +2449,6 @@ static void resetvars (void) do_cycles = "do_cycles_ce020"; nextw = "next_iword_020ce"; nextl = "next_ilong_020ce"; - memory_cycle_cnt = 3; } else if (using_ce020 == 2) { // 68030 CE disp020 = "x_get_disp_ea_ce030"; @@ -2460,7 +2466,6 @@ static void resetvars (void) do_cycles = "do_cycles_ce020"; nextw = "next_iword_030ce"; nextl = "next_ilong_030ce"; - memory_cycle_cnt = 3; } else if (using_prefetch_020) { disp020 = "x_get_disp_ea_020"; prefetch_word = "get_word_020_prefetch"; @@ -2476,7 +2481,6 @@ static void resetvars (void) dstb = "x_put_byte"; nextw = "next_iword_020_prefetch"; nextl = "next_ilong_020_prefetch"; - memory_cycle_cnt = 2; } #if 0 } else if (using_ce020) { @@ -3337,6 +3341,32 @@ static void gen_opcode (unsigned long int opcode) printf ("\tregs.sr = sr;\n"); setpc ("pc"); printf ("\tMakeFromSR ();\n"); + } else if (cpu_level == 1 && using_prefetch) { + int old_brace_level = n_braces; + if (next_cpu_level < 0) + next_cpu_level = 0; + printf ("\tuae_u16 newsr; uae_u32 newpc;\n"); + printf ("\tfor (;;) {\n"); + printf ("\t\tuaecptr a = m68k_areg (regs, 7);\n"); + printf ("\t\tuae_u16 sr = %s (a);\n", srcw); + printf ("\t\tuae_u32 pc = %s (a + 2);\n", srcl); + printf ("\t\tuae_u16 format = %s (a + 2 + 4);\n", srcw); + printf ("\t\tint frame = format >> 12;\n"); + printf ("\t\tint offset = 8;\n"); + printf ("\t\tnewsr = sr; newpc = pc;\n"); + printf ("\t\tif (frame == 0x0) { m68k_areg (regs, 7) += offset; break; }\n"); + printf ("\t\telse if (frame == 0x8) { m68k_areg (regs, 7) += offset + 50; break; }\n"); + printf ("\t\telse { m68k_areg (regs, 7) += offset; Exception (14); goto %s; }\n", endlabelstr); + printf ("\t\tregs.sr = newsr; MakeFromSR ();\n}\n"); + pop_braces (old_brace_level); + printf ("\tregs.sr = newsr; MakeFromSR ();\n"); + printf ("\tif (newpc & 1) {\n"); + printf ("\t\texception3i (0x%04X, newpc);\n", opcode); + printf ("\t\tgoto %s;\n", endlabelstr); + printf ("\t}\n"); + setpc ("newpc"); + printf ("\tipl_fetch ();\n"); + need_endlabel = 1; } else { int old_brace_level = n_braces; if (next_cpu_level < 0) @@ -3639,7 +3669,7 @@ static void gen_opcode (unsigned long int opcode) printf ("didnt_jump:;\n"); need_endlabel = 1; sync_m68k_pc (); - get_prefetch_ce020_0 (); + get_prefetch_020_0 (); if (curi->size == sz_byte) { addcycles000 (2); irc2ir (); @@ -3721,7 +3751,7 @@ static void gen_opcode (unsigned long int opcode) printf ("\t}\n"); setpc ("oldpc + %d", m68k_pc_offset); m68k_pc_offset = 0; - get_prefetch_ce020_0 (); + get_prefetch_020_0 (); fill_prefetch_full_000 (); insn_n_cycles = 12; need_endlabel = 1; @@ -5152,7 +5182,7 @@ static void generate_cpu (int id, int mode) } postfix = id; - if (id == 0 || id == 11 || id == 12 || id == 20 || id == 21 || id == 22 || id == 31 || id == 32 || id == 33) { + if (id == 0 || id == 11 || id == 13 || id == 20 || id == 21 || id == 22 || id == 31 || id == 32 || id == 33) { if (generate_stbl) fprintf (stblfile, "#ifdef CPUEMU_%d%s\n", postfix, extraup); postfix2 = postfix; @@ -5167,16 +5197,28 @@ static void generate_cpu (int id, int mode) using_ce020 = 0; using_mmu = 0; using_waitstates = 0; + memory_cycle_cnt = 4; mmu_postfix = ""; - if (id == 11 || id == 12) { // 11 = 68000 prefetch, 12 = 68000 cycle-exact - cpu_level = 0; + if (id == 11 || id == 12) { // 11 = 68010 prefetch, 12 = 68000 prefetch + cpu_level = id == 11 ? 1 : 0; using_prefetch = 1; using_exception_3 = 1; - if (id == 12) - using_ce = 1; - for (rp = 0; rp < nr_cpuop_funcs; rp++) - opcode_next_clev[rp] = 0; + if (id == 11) { + read_counts (); + for (rp = 0; rp < nr_cpuop_funcs; rp++) + opcode_next_clev[rp] = cpu_level; + } + } else if (id == 13 || id == 14) { // 13 = 68010 cycle-exact, 14 = 68000 cycle-exact + cpu_level = id == 13 ? 1 : 0; + using_prefetch = 1; + using_exception_3 = 1; + using_ce = 1; + if (id == 13) { + read_counts (); + for (rp = 0; rp < nr_cpuop_funcs; rp++) + opcode_next_clev[rp] = cpu_level; + } } else if (id == 20) { // 68020 prefetch cpu_level = 2; using_prefetch_020 = 2; @@ -5191,6 +5233,7 @@ static void generate_cpu (int id, int mode) // clock memory accesses, 68020 has 3 clock // memory accesses using_waitstates = 1; + memory_cycle_cnt = 3; read_counts (); for (rp = 0; rp < nr_cpuop_funcs; rp++) opcode_next_clev[rp] = cpu_level; @@ -5198,6 +5241,7 @@ static void generate_cpu (int id, int mode) cpu_level = 3 + (24 - id); using_ce020 = 2; using_prefetch_020 = 2; + memory_cycle_cnt = 2; if (id == 22) { read_counts (); for (rp = 0; rp < nr_cpuop_funcs; rp++) @@ -5272,7 +5316,7 @@ int main (int argc, char **argv) using_ce = 0; for (i = 0; i <= 33; i++) { - if ((i >= 6 && i < 11) || (i > 12 && i < 20) || (i > 24 && i < 31)) + if ((i >= 6 && i < 11) || (i > 14 && i < 20) || (i > 24 && i < 31)) continue; generate_stbl = 1; generate_cpu (i, 0); diff --git a/include/cpu_prefetch.h b/include/cpu_prefetch.h index caeb8cc0..07c7bea1 100644 --- a/include/cpu_prefetch.h +++ b/include/cpu_prefetch.h @@ -67,12 +67,6 @@ STATIC_INLINE void do_cycles_ce020_mem (int clocks, uae_u32 val) x_do_cycles_post (clocks * cpucycleunit, val); } -STATIC_INLINE void resetcycles_ce020 (void) -{ - regs.ce020memcycles = 0; - regs.ce020memcycle_data = true; -} - #if 0 STATIC_INLINE void do_head_cycles_ce020 (int h) { @@ -232,7 +226,7 @@ extern uae_u32 get_word_ce040_prefetch (int); #endif -#ifdef CPUEMU_12 +#ifdef CPUEMU_13 STATIC_INLINE void do_cycles_ce000 (int clocks) { diff --git a/include/disk.h b/include/disk.h index bcef9993..3e65ad43 100644 --- a/include/disk.h +++ b/include/disk.h @@ -18,6 +18,8 @@ struct diskinfo uae_u32 crc32; bool hd; bool unreadable; + int bootblocktype; + TCHAR diskname[110]; }; extern void DISK_init (void); diff --git a/include/inputdevice.h b/include/inputdevice.h index 6db86e0e..85c73067 100644 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -238,8 +238,11 @@ extern void inputdevice_reset (void); extern void write_inputdevice_config (struct uae_prefs *p, struct zfile *f); extern void read_inputdevice_config (struct uae_prefs *p, const TCHAR *option, TCHAR *value); extern void reset_inputdevice_config (struct uae_prefs *pr); +extern void store_inputdevice_config (struct uae_prefs *pr); +extern void restore_inputdevice_config (struct uae_prefs *p, int portnum); extern int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value, int portnum, int mode, int type); extern int inputdevice_getjoyportdevice (int port, int val); +extern void inputdevice_validate_jports (struct uae_prefs *p, int changedport); extern void inputdevice_init (void); extern void inputdevice_close (void); diff --git a/include/newcpu.h b/include/newcpu.h index 2c849ea3..e61cd329 100644 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -468,10 +468,12 @@ extern const struct cputbl op_smalltbl_20_ff[]; // prefetch extern const struct cputbl op_smalltbl_21_ff[]; // CE /* 68010 */ extern const struct cputbl op_smalltbl_4_ff[]; +extern const struct cputbl op_smalltbl_11_ff[]; // prefetch +extern const struct cputbl op_smalltbl_13_ff[]; // CE /* 68000 */ extern const struct cputbl op_smalltbl_5_ff[]; -extern const struct cputbl op_smalltbl_11_ff[]; // prefetch -extern const struct cputbl op_smalltbl_12_ff[]; // CE +extern const struct cputbl op_smalltbl_12_ff[]; // prefetch +extern const struct cputbl op_smalltbl_14_ff[]; // CE extern cpuop_func *cpufunctbl[65536] ASM_SYM_FOR_FUNC ("cpufunctbl"); diff --git a/inputdevice.cpp b/inputdevice.cpp index b941343a..2df82d76 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -166,7 +166,7 @@ int inputdevice_uaelib (const TCHAR *s, const TCHAR *parm) for (i = 1; events[i].name; i++) { if (!_tcscmp (s, events[i].confname)) { - handle_input_event (i, _tstol (parm), 1, 0, false, false); + handle_input_event (i, parm ? _tstol (parm) : 0, 1, 0, false, false); return 1; } } @@ -1436,7 +1436,7 @@ static void inputdevice_mh_abs (int x, int y, uae_u32 buttonbits) x -= mouseoffset_x + 1; y -= mouseoffset_y + 2; - write_log (_T("%04dx%04d %08x\n"), x, y, buttonbits); + //write_log (_T("%04dx%04d %08x\n"), x, y, buttonbits); p[MH_ABSX] = x >> 8; p[MH_ABSX + 1] = x; @@ -2413,6 +2413,12 @@ static int handle_custom_event (const TCHAR *custom) debug_parser (p + 4, NULL, -1); } else if (!_tcsnicmp (p, _T("kbr "), 4)) { inject_events (p + 4); + } else if (!_tcsnicmp (p, _T("evt "), 4)) { + TCHAR *pp = _tcschr (p + 4, ' '); + p += 4; + if (pp) + *pp++ = 0; + inputdevice_uaelib (p, pp); } else { cfgfile_parse_line (&changed_prefs, p, 0); } @@ -2608,7 +2614,8 @@ static void queue_input_event (int evt, const TCHAR *custom, int state, int max, } static uae_u8 keybuf[256]; -static int inputcode_pending, inputcode_pending_state; +#define MAX_PENDING_EVENTS 20 +static int inputcode_pending[MAX_PENDING_EVENTS], inputcode_pending_state[MAX_PENDING_EVENTS]; void inputdevice_release_all_keys (void) { @@ -2625,8 +2632,17 @@ void inputdevice_release_all_keys (void) void inputdevice_add_inputcode (int code, int state) { - inputcode_pending = code; - inputcode_pending_state = state; + for (int i = 0; i < MAX_PENDING_EVENTS; i++) { + if (inputcode_pending[i] == code && inputcode_pending_state[i] == state) + return; + } + for (int i = 0; i < MAX_PENDING_EVENTS; i++) { + if (inputcode_pending[i] == 0) { + inputcode_pending[i] = code; + inputcode_pending_state[i] = state; + return; + } + } } void inputdevice_do_keyboard (int code, int state) @@ -2688,11 +2704,9 @@ static bool needcputrace (int code) return false; } -void inputdevice_handle_inputcode (void) +static bool inputdevice_handle_inputcode2 (int code, int state) { static int swapperslot; - int code = inputcode_pending; - int state = inputcode_pending_state; static int tracer_enable; if (code == 0) @@ -2700,12 +2714,10 @@ void inputdevice_handle_inputcode (void) if (needcputrace (code) && can_cpu_tracer () == true && is_cpu_tracer () == false && !input_play && !input_record && !debugging) { if (set_cpu_tracer (true)) { tracer_enable = 1; - return; // wait for next frame + return true; // wait for next frame } } - inputcode_pending = 0; - if (vpos != 0) write_log (_T("inputcode=%d but vpos = %d"), code, vpos); @@ -2736,7 +2748,7 @@ void inputdevice_handle_inputcode (void) #endif if (!state) - return; + return false; switch (code) { case AKS_ENTERGUI: @@ -2954,8 +2966,26 @@ end: set_cpu_tracer (false); tracer_enable = 0; } + return false; +} + +void inputdevice_handle_inputcode (void) +{ + bool got = false; + for (int i = 0; i < MAX_PENDING_EVENTS; i++) { + int code = inputcode_pending[i]; + int state = inputcode_pending_state[i]; + if (code) { + if (!inputdevice_handle_inputcode2 (code, state)) + inputcode_pending[i] = 0; + got = true; + } + } + if (!got) + inputdevice_handle_inputcode2 (0, 0); } + static int getqualid (int evt) { if (evt > INPUTEVENT_SPC_QUALIFIER_START && evt < INPUTEVENT_SPC_QUALIFIER_END) @@ -3407,6 +3437,8 @@ static int switchdevice (struct uae_input_device *id, int num, bool buttonmode) TCHAR *name = NULL; int otherbuttonpressed = 0; + //write_log (_T("switchdevice '%s' %d %d\n"), id->name, num, buttonmode); + if (num >= 4) return 0; #ifdef RETROPLATFORM @@ -3441,25 +3473,50 @@ static int switchdevice (struct uae_input_device *id, int num, bool buttonmode) } else { newport = num ? 1 : 0; } + //write_log (_T("newport = %d\n"), newport); /* "GamePorts" switch if in GamePorts mode or Input mode and GamePorts port was not NONE */ if (currprefs.input_selected_setting == GAMEPORT_INPUT_SETTINGS || currprefs.jports[newport].id != JPORT_NONE) { + //write_log (_T("GAMEPORTS MODE\n")); if ((num == 0 || num == 1) && currprefs.jports[newport].id != JPORT_CUSTOM) { + //write_log (_T("Port supported\n")); int om = jsem_ismouse (num, &currprefs); int om1 = jsem_ismouse (0, &currprefs); int om2 = jsem_ismouse (1, &currprefs); - if ((om1 >= 0 || om2 >= 0) && ismouse) + if ((om1 >= 0 || om2 >= 0) && ismouse) { + //write_log (_T("END3\n")); return 0; - if (flags) + } + if (flags) { + //write_log (_T("END2\n")); return 0; + } if (name) { +#if 1 + if (ismouse) { + int nummouse = 0; // count number of non-supermouse mice + int supermouse = -1; + for (i = 0; i < idev[IDTYPE_MOUSE].get_num (); i++) { + if (!idev[IDTYPE_MOUSE].get_flags (i)) + nummouse++; + else + supermouse = i; + } + if (supermouse >= 0 && nummouse == 1) { + name = idev[IDTYPE_MOUSE].get_uniquename (supermouse); + } + } +#endif write_log (_T("inputdevice change '%s':%d->%d\n"), name, num, newport); inputdevice_joyport_config (&changed_prefs, name, newport, -1, 2); + inputdevice_validate_jports (&changed_prefs, -1); inputdevice_copyconfig (&changed_prefs, &currprefs); return 1; } } + //write_log (_T("END1\n")); return 0; } else { + //write_log (_T("INPUTPANEL MODE\n")); int oldport = getoldport (id); int k, evt; struct inputevent *ie, *ie2; @@ -3514,6 +3571,7 @@ static int switchdevice (struct uae_input_device *id, int num, bool buttonmode) } write_log (_T("inputdevice change '%s':%d->%d\n"), name, num, newport); inputdevice_copyconfig (&currprefs, &changed_prefs); + inputdevice_validate_jports (&changed_prefs, -1); inputdevice_copyconfig (&changed_prefs, &currprefs); return 1; } @@ -6627,7 +6685,7 @@ void setjoystickstate (int joy, int axis, int state, int max) return; if (!joysticks[joy].enabled) { if (v1 && v1 != v2) - switchdevice (&joysticks[joy], axis * 2 + (v1 < 0 ? 0 : 1), false); + switchdevice (&joysticks[joy], v1 < 0 ? 0 : 1, false); return; } for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) { @@ -6804,6 +6862,105 @@ int jsem_iskbdjoy (int port, const struct uae_prefs *p) return v; } +static struct jport stored_ports[MAX_JPORTS]; + +static void fixjport (struct jport *port, int add) +{ + int vv = port->id; + if (vv == JPORT_CUSTOM || vv == JPORT_NONE) + return; + if (vv >= JSEM_JOYS && vv < JSEM_MICE) { + vv -= JSEM_JOYS; + vv += add; + if (vv >= inputdevice_get_device_total (IDTYPE_JOYSTICK)) + vv = 0; + vv += JSEM_JOYS; + } else if (vv >= JSEM_MICE && vv < JSEM_END) { + vv -= JSEM_MICE; + vv += add; + if (vv >= inputdevice_get_device_total (IDTYPE_MOUSE)) + vv = 0; + vv += JSEM_MICE; + } else if (vv >= JSEM_KBDLAYOUT && vv < JSEM_LASTKBD) { + vv -= JSEM_KBDLAYOUT; + vv += add; + if (vv >= JSEM_LASTKBD) + vv = 0; + vv += JSEM_KBDLAYOUT; + } + port->id = vv; +} + +void inputdevice_validate_jports (struct uae_prefs *p, int changedport) +{ + int i, j; + for (i = 0; i < MAX_JPORTS; i++) + fixjport (&p->jports[i], 0); + for (i = 0; i < MAX_JPORTS; i++) { + if (p->jports[i].id < 0) + continue; + for (j = 0; j < MAX_JPORTS; j++) { + if (p->jports[j].id < 0) + continue; + if (j == i) + continue; + if (p->jports[i].id == p->jports[j].id) { + if (i == changedport) { + restore_inputdevice_config (p, j); + } else if (j == changedport) { + restore_inputdevice_config (p, i); + } + int cnt = 0; + while (p->jports[i].id == p->jports[j].id) { + int k; + if (i == changedport) { + k = j; + } else { + k = i; + } + fixjport (&p->jports[k], 1); + cnt++; + if (cnt > 10) + p->jports[k].id = JSEM_KBDLAYOUT; + if (cnt > 20) + break; + } + } + } + } +} + +static bool inputdevice_inserted (struct uae_prefs *p, int portnum, int id, int mode, int type) +{ + for (int k = 0; k < MAX_JPORTS; k++) { + if (p->jports[k].id == id && k != portnum) { + if (type == IDTYPE_JOYSTICK) { + // if this joystick is already in port 0, reset port 0 back to original + // and insert joystick in port 1. Probably what user wanted. + if (k == 0 && portnum == 1) { + memcpy (&p->jports[0], &stored_ports[0], sizeof (struct jport)); + return false; + } + } else if (type == IDTYPE_MOUSE) { + return true; + } + return true; + } + } + return false; +} + +void store_inputdevice_config (struct uae_prefs *p) +{ + for (int i = 0; i < MAX_JPORTS; i++) { + memcpy (&stored_ports[i], &p->jports[i], sizeof (struct jport)); + } +} +void restore_inputdevice_config (struct uae_prefs *p, int portnum) +{ + memcpy (&p->jports[portnum], &stored_ports[portnum], sizeof (struct jport)); +} + int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value, int portnum, int mode, int type) { switch (type) @@ -6825,11 +6982,14 @@ int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value, int por TCHAR *name1 = idf->get_friendlyname (i); TCHAR *name2 = idf->get_uniquename (i); if ((name1 && !_tcscmp (name1, value)) || (name2 && !_tcscmp (name2, value))) { - p->jports[portnum].id = idnum + i; - if (mode >= 0) - p->jports[portnum].mode = mode; - set_config_changed (); - return 1; + if (!inputdevice_inserted (p, portnum, idnum + 1, mode, type)) { + p->jports[portnum].id = idnum + i; + if (mode >= 0) + p->jports[portnum].mode = mode; + set_config_changed (); + return 1; + } + return 0; } } } @@ -6838,6 +6998,7 @@ int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value, int por case 0: { int start = JPORT_NONE, got = 0, max = -1; + int type = -1; const TCHAR *pp = 0; if (_tcsncmp (value, _T("kbd"), 3) == 0) { start = JSEM_KBDLAYOUT; @@ -6845,11 +7006,13 @@ int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value, int por got = 1; max = JSEM_LASTKBD; } else if (_tcsncmp (value, _T("joy"), 3) == 0) { + type = IDTYPE_JOYSTICK; start = JSEM_JOYS; pp = value + 3; got = 1; max = idev[IDTYPE_JOYSTICK].get_num (); } else if (_tcsncmp (value, _T("mouse"), 5) == 0) { + type = IDTYPE_MOUSE; start = JSEM_MICE; pp = value + 5; got = 1; @@ -6875,6 +7038,8 @@ int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value, int por } } if (got == 2) { + if (inputdevice_inserted (p, portnum, start, mode, type)) + return 0; p->jports[portnum].id = start; if (mode >= 0) p->jports[portnum].mode = mode; diff --git a/main.cpp b/main.cpp index 478e40f2..6e3df6fa 100644 --- a/main.cpp +++ b/main.cpp @@ -523,11 +523,11 @@ void fixup_prefs (struct uae_prefs *p) p->cpu_compatible = 1; p->address_space_24 = 1; #endif -#if !defined (CPUEMU_11) && !defined (CPUEMU_12) +#if !defined (CPUEMU_11) && !defined (CPUEMU_13) p->cpu_compatible = 0; p->address_space_24 = 0; #endif -#if !defined (CPUEMU_12) +#if !defined (CPUEMU_13) p->cpu_cycle_exact = p->blitter_cycle_exact = 0; #endif #ifndef AGA @@ -553,7 +553,7 @@ void fixup_prefs (struct uae_prefs *p) #if !defined (UAESERIAL) p->uaeserial = 0; #endif -#if defined (CPUEMU_12) +#if defined (CPUEMU_13) if (p->cpu_cycle_exact) { if (p->gfx_framerate > 1) { error_log (_T("Cycle-exact requires disabled frameskip.")); diff --git a/newcpu.cpp b/newcpu.cpp index 9a769325..029b90dd 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -793,7 +793,7 @@ static void set_x_funcs (void) } else if (!currprefs.cpu_cycle_exact) { // 68020+ no ce if (currprefs.cpu_compatible) { - if (currprefs.cpu_model == 68020) { + if (currprefs.cpu_model == 68020 && !currprefs.cachesize) { x_prefetch = get_word_prefetch; x_prefetch_long = get_long_prefetch; x_get_ilong = get_long_020_prefetch; @@ -811,7 +811,7 @@ static void set_x_funcs (void) x_do_cycles_pre = do_cycles; x_do_cycles_post = do_cycles_post; } else { - // 68030+ does not have real prefetch only emulation + // JIT or 68030+ does not have real prefetch only emulation x_prefetch = NULL; x_prefetch_long = NULL; x_get_ilong = get_ilong; @@ -1137,6 +1137,14 @@ static void build_cpufunctbl (void) case 68010: lvl = 1; tbl = op_smalltbl_4_ff; +#ifdef CPUEMU_11 + if (currprefs.cpu_compatible) + tbl = op_smalltbl_11_ff; /* prefetch */ +#endif +#ifdef CPUEMU_13 + if (currprefs.cpu_cycle_exact) + tbl = op_smalltbl_13_ff; /* prefetch and cycle-exact */ +#endif break; #endif #endif @@ -1147,11 +1155,11 @@ static void build_cpufunctbl (void) tbl = op_smalltbl_5_ff; #ifdef CPUEMU_11 if (currprefs.cpu_compatible) - tbl = op_smalltbl_11_ff; /* prefetch */ + tbl = op_smalltbl_12_ff; /* prefetch */ #endif -#ifdef CPUEMU_12 +#ifdef CPUEMU_13 if (currprefs.cpu_cycle_exact) - tbl = op_smalltbl_12_ff; /* prefetch and cycle-exact */ + tbl = op_smalltbl_14_ff; /* prefetch and cycle-exact */ #endif break; } @@ -1305,9 +1313,9 @@ void check_prefs_changed_cpu (void) || currprefs.fpu_no_unimplemented != changed_prefs.fpu_no_unimplemented || currprefs.cpu_compatible != changed_prefs.cpu_compatible || currprefs.cpu_cycle_exact != changed_prefs.cpu_cycle_exact) { - + bool doprefetch = !currprefs.cpu_compatible && changed_prefs.cpu_compatible; prefs_changed_cpu (); - if (!currprefs.cpu_compatible && changed_prefs.cpu_compatible) + if (doprefetch) fill_prefetch (); build_cpufunctbl (); changed = true; @@ -2210,7 +2218,7 @@ static void exception_debug (int nr) #endif } -#ifdef CPUEMU_12 +#ifdef CPUEMU_13 /* cycle-exact exception handler, 68000 only */ @@ -2350,18 +2358,32 @@ static void Exception_ce000 (int nr) write_log (_T("Exception %d (%x) at %x -> %x!\n"), nr, last_addr_for_exception_3, currpc, get_long (4 * nr)); goto kludge_me_do; } - m68k_areg (regs, 7) -= 6; - x_put_word (m68k_areg (regs, 7) + 4, currpc); // write low address - if (interrupt) { - // fetch interrupt vector number - nr = x_get_byte (0x00fffff1 | ((nr - 24) << 1)); - x_do_cycles (4 * cpucycleunit); + if (currprefs.cpu_model == 68010) { + // 68010 creates only format 0 and 8 stack frames + m68k_areg (regs, 7) -= 8; + x_put_word (m68k_areg (regs, 7) + 4, currpc); // write low address + if (interrupt) { + // fetch interrupt vector number + nr = x_get_byte (0x00fffff1 | ((nr - 24) << 1)); + x_do_cycles (4 * cpucycleunit); + } + x_put_word (m68k_areg (regs, 7) + 0, regs.sr); // write SR + x_put_word (m68k_areg (regs, 7) + 2, currpc >> 16); // write high address + x_put_word (m68k_areg (regs, 7) + 6, nr * 4); + } else { + m68k_areg (regs, 7) -= 6; + x_put_word (m68k_areg (regs, 7) + 4, currpc); // write low address + if (interrupt) { + // fetch interrupt vector number + nr = x_get_byte (0x00fffff1 | ((nr - 24) << 1)); + x_do_cycles (4 * cpucycleunit); + } + x_put_word (m68k_areg (regs, 7) + 0, regs.sr); // write SR + x_put_word (m68k_areg (regs, 7) + 2, currpc >> 16); // write high address } - x_put_word (m68k_areg (regs, 7) + 0, regs.sr); // write SR - x_put_word (m68k_areg (regs, 7) + 2, currpc >> 16); // write high address kludge_me_do: - newpc = x_get_word (4 * nr) << 16; // read high address - newpc |= x_get_word (4 * nr + 2); // read low address + newpc = x_get_word (regs.vbr + 4 * nr) << 16; // read high address + newpc |= x_get_word (regs.vbr + 4 * nr + 2); // read low address if (newpc & 1) { if (nr == 2 || nr == 3) cpu_halt (2); @@ -2856,8 +2878,8 @@ static void ExceptionX (int nr, uaecptr address) if (currprefs.cachesize) regs.instruction_pc = address == -1 ? m68k_getpc () : address; #endif -#ifdef CPUEMU_12 - if (currprefs.cpu_cycle_exact && currprefs.cpu_model == 68000) +#ifdef CPUEMU_13 + if (currprefs.cpu_cycle_exact && currprefs.cpu_model <= 68010) Exception_ce000 (nr); else #endif @@ -4109,6 +4131,7 @@ static void m68k_run_1 (void) } #endif do_cycles (cpu_cycles); + r->instruction_pc = m68k_getpc (); cpu_cycles = (*cpufunctbl[opcode])(opcode); cpu_cycles = adjust_cycles (cpu_cycles); if (r->spcflags) { @@ -4125,7 +4148,7 @@ static void m68k_run_1 (void) #endif /* CPUEMU_11 */ -#ifndef CPUEMU_12 +#ifndef CPUEMU_13 static void m68k_run_1_ce (void) { @@ -4200,6 +4223,7 @@ static void m68k_run_1_ce (void) inprec_playdebug_cpu (1); } + r->instruction_pc = m68k_getpc (); (*cpufunctbl[opcode])(opcode); if (cpu_tracer) { cputrace.state = 0; @@ -4802,7 +4826,7 @@ static void m68k_run_2p (void) x_do_cycles (cpu_cycles); - opcode = get_word_020_prefetch (0); + opcode = regs.irc; count_instr (opcode); cpu_cycles = (*cpufunctbl[opcode])(opcode); @@ -5028,8 +5052,8 @@ void m68k_go (int may_quit) run_func = m68k_run_mmu; } else { #endif - run_func = currprefs.cpu_cycle_exact && currprefs.cpu_model == 68000 ? m68k_run_1_ce : - currprefs.cpu_compatible && currprefs.cpu_model == 68000 ? m68k_run_1 : + run_func = currprefs.cpu_cycle_exact && currprefs.cpu_model <= 68010 ? m68k_run_1_ce : + currprefs.cpu_compatible && currprefs.cpu_model <= 68010 ? m68k_run_1 : #ifdef JIT currprefs.cpu_model >= 68020 && currprefs.cachesize ? m68k_run_jit : #endif @@ -6414,7 +6438,8 @@ uae_u32 get_word_020_prefetch (int o) // these are also used by 68030. #define RESET_CE020_CYCLES \ - resetcycles_ce020 () + regs.ce020memcycles = 0; \ + regs.ce020memcycle_data = true; #define STORE_CE020_CYCLES \ unsigned long cycs = get_cycles () #define ADD_CE020_CYCLES \ @@ -6890,10 +6915,12 @@ void fill_prefetch_030 (void) uaecptr pc = m68k_getpc (); pc &= ~3; fill_icache030 (pc); - do_cycles_ce020 (2); + if (currprefs.cpu_cycle_exact) + do_cycles_ce020 (2); regs.prefetch020[0] = regs.cacheholdingdata020; fill_icache030 (pc + 4); - do_cycles_ce020 (2); + if (currprefs.cpu_cycle_exact) + do_cycles_ce020 (2); regs.prefetch020[1] = regs.cacheholdingdata020; regs.irc = get_word_ce030_prefetch (0); } @@ -6904,10 +6931,12 @@ void fill_prefetch_020 (void) uae_u32 (*fetch)(uaecptr) = currprefs.cpu_cycle_exact ? mem_access_delay_longi_read_ce020 : get_longi; pc &= ~3; fill_icache020 (pc, fetch); - do_cycles_ce020 (2); + if (currprefs.cpu_cycle_exact) + do_cycles_ce020 (2); regs.prefetch020[0] = regs.cacheholdingdata020; fill_icache020 (pc + 4, fetch); - do_cycles_ce020 (2); + if (currprefs.cpu_cycle_exact) + do_cycles_ce020 (2); regs.prefetch020[1] = regs.cacheholdingdata020; regs.irc = get_word_020_prefetch (0); } diff --git a/od-win32/mman.cpp b/od-win32/mman.cpp index 67685adc..77522532 100644 --- a/od-win32/mman.cpp +++ b/od-win32/mman.cpp @@ -167,18 +167,21 @@ bool preinit_shm (void) if (size64 > MAXZ3MEM32) size64 = MAXZ3MEM32; } - if (maxmem < 0) + if (maxmem < 0) { size64 = MAXZ3MEM64; - else if (maxmem > 0) + if (!os_64bit) { + if (totalphys64 < 1536 * 1024 * 1024) + max_allowed_mman = 256; + if (max_allowed_mman < 256) + max_allowed_mman = 256; + } + } else if (maxmem > 0) { size64 = maxmem * 1024 * 1024; + } if (size64 < 8 * 1024 * 1024) size64 = 8 * 1024 * 1024; if (max_allowed_mman * 1024 * 1024 > size64) max_allowed_mman = size64 / (1024 * 1024); - if (!os_64bit) { - if (max_allowed_mman * 1024 * 1024 > (totalphys64 / 2)) - max_allowed_mman = (totalphys64 / 2) / (1024 * 1024); - } natmem_size = (max_allowed_mman + 1) * 1024 * 1024; if (natmem_size < 17 * 1024 * 1024) diff --git a/od-win32/resources/resource.h b/od-win32/resources/resource.h index bc2cded6..17548220 100644 --- a/od-win32/resources/resource.h +++ b/od-win32/resources/resource.h @@ -377,6 +377,7 @@ #define IDS_JOYMODE_WHEELMOUSE 389 #define IDD_ERRORLOG 389 #define IDS_NUMSG_KS68030PLUS 390 +#define IDD_DISKINFO 390 #define IDS_SELECTTAPE 391 #define IDS_TAPE 392 #define IDS_QS_MODELS 1000 @@ -1100,6 +1101,7 @@ #define IDC_DD_SURFACETYPE 1791 #define IDC_RTG_SCALE_ALLOW 1791 #define IDC_CPU_FREQUENCY 1791 +#define IDC_LOGENABLE2 1791 #define IDC_RTG_SCALE_ASPECTRATIO 1792 #define IDC_ASSOCIATE_ON 1792 #define IDC_DD_SURFACETYPE2 1792 @@ -1158,6 +1160,8 @@ #define IDC_TAPE_RW 1834 #define IDC_ERRORLOGMESSAGE 1835 #define IDC_ERRORLOGCLEAR 1836 +#define IDC_DISKINFOBOX 1837 +#define IDC_SAVEBOOTBLOCK 1838 #define ID__FLOPPYDRIVES 40004 #define ID_FLOPPYDRIVES_DF0 40005 #define ID_ST_CONFIGURATION 40010 @@ -1206,9 +1210,9 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 390 +#define _APS_NEXT_RESOURCE_VALUE 391 #define _APS_NEXT_COMMAND_VALUE 40050 -#define _APS_NEXT_CONTROL_VALUE 1837 +#define _APS_NEXT_CONTROL_VALUE 1839 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index e5b29904..b04dd885 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -1,7 +1,7 @@ // Microsoft Visual C++ generated resource script. // -#include "winres.h" #include "resource.h" +#include "winres.h" ///////////////////////////////////////////////////////////////////////////// // English resources @@ -922,10 +922,11 @@ BEGIN CONTROL "Use relative paths",IDC_PATHS_RELATIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,199,231,189,11 EDITTEXT IDC_LOGPATH,7,281,324,13,ES_READONLY PUSHBUTTON "Open [] Open selected file.",IDC_LOGOPEN,337,280,51,14 - COMBOBOX IDC_LOGSELECT,7,263,169,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - CONTROL "Enable full logging (temporary)",IDC_LOGENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,186,264,140,12 + COMBOBOX IDC_LOGSELECT,7,263,137,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP + CONTROL "Enable full logging",IDC_LOGENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,151,264,93,12 PUSHBUTTON "Save All [] Save and open both logs and config file.",IDC_LOGSAVE,337,264,51,14 GROUPBOX "Debug logging",IDC_STATIC,1,248,393,53 + CONTROL "Log window",IDC_LOGENABLE2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,254,264,68,12 END IDD_QUICKSTART DIALOGEX 0, 0, 396, 262 @@ -1156,6 +1157,16 @@ BEGIN CONTROL "Read/write",IDC_TAPE_RW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,313,39,67,10 END +IDD_DISKINFO DIALOGEX 0, 0, 491, 323 +STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Disk image information" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + DEFPUSHBUTTON "OK",IDOK,220,303,50,14 + EDITTEXT IDC_DISKINFOBOX,5,4,481,292,ES_MULTILINE | ES_READONLY | WS_VSCROLL + PUSHBUTTON "Save bootblock",IDC_SAVEBOOTBLOCK,397,303,89,14,NOT WS_VISIBLE +END + ///////////////////////////////////////////////////////////////////////////// // @@ -1466,6 +1477,10 @@ BEGIN IDD_TAPEDRIVE, DIALOG BEGIN END + + IDD_DISKINFO, DIALOG + BEGIN + END END #endif // APSTUDIO_INVOKED diff --git a/od-win32/srcrelease.cmd b/od-win32/srcrelease.cmd index 093b98aa..f3a27172 100644 --- a/od-win32/srcrelease.cmd +++ b/od-win32/srcrelease.cmd @@ -33,6 +33,7 @@ del compstbl.cpp del cpuemu_0.cpp del cpuemu_11.cpp del cpuemu_12.cpp +del cpuemu_13.cpp del cpuemu_20.cpp del cpuemu_21.cpp del cpuemu_22.cpp diff --git a/od-win32/sysconfig.h b/od-win32/sysconfig.h index fcfa7746..72f1fbbd 100644 --- a/od-win32/sysconfig.h +++ b/od-win32/sysconfig.h @@ -48,8 +48,8 @@ #define MMUEMU /* Aranym 68040 MMU */ #define FULLMMU /* Aranym 68040 MMU */ #define CPUEMU_0 /* generic 680x0 emulation */ -#define CPUEMU_11 /* 68000 prefetch emulation */ -#define CPUEMU_12 /* 68000 cycle-exact cpu&blitter */ +#define CPUEMU_11 /* 68000/68010 prefetch emulation */ +#define CPUEMU_13 /* 68000/68010 cycle-exact cpu&blitter */ #define CPUEMU_20 /* 68020 prefetch */ #define CPUEMU_21 /* 68020 "cycle-exact" + blitter */ #define CPUEMU_22 /* 68030 (040/060) "cycle-exact" + blitter */ @@ -90,7 +90,7 @@ #define OPENGL #endif #define CAPS -#define CPUEMU_12 +#define CPUEMU_13 #define CPUEMU_11 diff --git a/od-win32/win32.h b/od-win32/win32.h index 88d095bd..91cd0c65 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -19,11 +19,11 @@ #define LANG_DLL 1 #if WINUAEPUBLICBETA -#define WINUAEBETA _T("9") +#define WINUAEBETA _T("10") #else #define WINUAEBETA _T("") #endif -#define WINUAEDATE MAKEBD(2013, 10, 20) +#define WINUAEDATE MAKEBD(2013, 10, 26) #define WINUAEEXTRA _T("") //#define WINUAEEXTRA _T("AmiKit Preview") //#define WINUAEEXTRA _T("Amiga Forever Edition") diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index c3f4a6a6..881810a8 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -267,6 +267,36 @@ static void hide (HWND hDlg, DWORD id, int hide) ShowWindow (w, hide ? SW_HIDE : SW_SHOW); } +static int stringboxdialogactive; +static INT_PTR CALLBACK StringBoxDialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_DESTROY: + PostQuitMessage (0); + return TRUE; + case WM_CLOSE: + stringboxdialogactive = 0; + DestroyWindow (hDlg); + return TRUE; + case WM_INITDIALOG: + return TRUE; + case WM_COMMAND: + switch (LOWORD (wParam)) + { + case IDOK: + stringboxdialogactive = -1; + DestroyWindow (hDlg); + return TRUE; + case IDCANCEL: + stringboxdialogactive = 0; + DestroyWindow (hDlg); + return TRUE; + } + break; + } + return FALSE; +} static int CALLBACK BrowseForFolderCallback (HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) { @@ -2018,45 +2048,71 @@ static void eject_cd (void) } } -static void infofloppy (int n) +static void infofloppy (HWND hDlg, int n) { struct diskinfo di; - FILE *f; - TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH]; + TCHAR tmp2[MAX_DPATH]; + TCHAR text[20000]; DISK_examine_image (&workprefs, n, &di); - tmp[0] = 0; - if (GetTempPath (MAX_DPATH, tmp) <= 0) - return; - _tcscat (tmp, _T("floppy_info.txt")); - f = _tfopen (tmp, _T("wt, ccs=UTF-8")); - if (f) { + _stprintf (tmp2, + _T("'%s'\r\nDisk readable: %s\r\nCRC32: %08X\r\nBoot block checksum valid: %s\r\nBoot block type: %s\r\n"), + workprefs.floppyslots[n].df, + di.unreadable ? _T("No") : _T("Yes"), + di.crc32, + di.bb_crc_valid ? _T("Yes") : _T("No"), + di.bootblocktype == 0 ? _T("Custom") : (di.bootblocktype == 1 ? _T("Standard 1.x") : _T("Standard 2.x+")) + ); + _tcscpy (text, tmp2); + if (di.diskname[0]) { _stprintf (tmp2, - _T("\nDisk readable: %s\nCRC32: %08X\nBoot block checksum valid: %s\n\n"), - di.unreadable ? _T("No") : _T("Yes"), - di.crc32, - di.bb_crc_valid ? _T("Yes") : _T("No") - ); - fputws (tmp2, f); - int w = 32; - for (int i = 0; i < 1024; i += w) { - for (int j = 0; j < w; j++) { - uae_u8 b = di.bootblock[i + j]; - _stprintf (tmp2 + j * 2, _T("%02X"), b); - if (b >= 32 && b < 127) - tmp2[w * 2 + 1 + j] = (TCHAR)b; - else - tmp2[w * 2 + 1 + j] = '.'; + _T("Label: '%s'\r\n"), di.diskname); + _tcscat (text, tmp2); + } + _tcscat (text, _T("\r\n")); + + int w = 32; + for (int i = 0; i < 1024; i += w) { + for (int j = 0; j < w; j++) { + uae_u8 b = di.bootblock[i + j]; + _stprintf (tmp2 + j * 2, _T("%02X"), b); + if (b >= 32 && b < 127) + tmp2[w * 2 + 1 + j] = (TCHAR)b; + else + tmp2[w * 2 + 1 + j] = '.'; + } + tmp2[w * 2] = ' '; + tmp2[w * 2 + 1 + w] = 0; + _tcscat (text, tmp2); + _tcscat (text, _T("\r\n")); + } + + stringboxdialogactive = 1; + HWND hwnd = CustomCreateDialog (IDD_DISKINFO, hDlg, StringBoxDialogProc); + if (hwnd == NULL) + return; + + HFONT font = CreateFont (12, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console")); + if (font) + SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETFONT, WPARAM(font), FALSE); + SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETTEXT, 0, (LPARAM)text); + while (stringboxdialogactive == 1) { + MSG msg; + int ret; + WaitMessage (); + while ((ret = GetMessage (&msg, NULL, 0, 0))) { + if (ret == -1) + break; + if (!IsWindow (hwnd) || !IsDialogMessage (hwnd, &msg)) { + TranslateMessage (&msg); + DispatchMessage (&msg); } - tmp2[w * 2] = ' '; - tmp2[w * 2 + 1 + w] = 0; - fputws (tmp2, f); - fputws (_T("\n"), f); } - fclose (f); - ShellExecute (NULL, _T("open"), tmp, NULL, NULL, SW_SHOWNORMAL); + if (stringboxdialogactive == -1) + break; } + DeleteObject (font); } static void ejectfloppy (int n) @@ -5137,6 +5193,11 @@ static INT_PTR CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM SendDlgItemMessage (hDlg, IDC_LOGSELECT, CB_SETCURSEL, 0, 0); CheckDlgButton (hDlg, IDC_LOGENABLE, winuaelog_temporary_enable || (full_property_sheet == 0 && currprefs.win32_logfile)); ew (hDlg, IDC_LOGENABLE, winuaelog_temporary_enable == false && full_property_sheet); + extern int consoleopen; + if (consoleopen || !full_property_sheet) { + CheckDlgButton (hDlg, IDC_LOGENABLE2, consoleopen ? TRUE : FALSE); + ew (hDlg, IDC_LOGENABLE2, FALSE); + } values_to_pathsdialog (hDlg); recursive--; return TRUE; @@ -5172,6 +5233,10 @@ static INT_PTR CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM case IDC_LOGENABLE: winuaelog_temporary_enable = ischecked (hDlg, IDC_LOGENABLE); break; + case IDC_LOGENABLE2: + extern int console_logging; + console_logging = 1; + break; case IDC_LOGOPEN: flush_log (); val = SendDlgItemMessage (hDlg, IDC_LOGSELECT, CB_GETCURSEL, 0, 0L); @@ -5873,7 +5938,7 @@ static void enable_for_chipsetdlg (HWND hDlg) { int enable = workprefs.cpu_cycle_exact ? FALSE : TRUE; -#if !defined (CPUEMU_12) +#if !defined (CPUEMU_13) ew (hDlg, IDC_CYCLEEXACT, FALSE); #endif ew (hDlg, IDC_GENLOCK, full_property_sheet); @@ -8822,10 +8887,8 @@ static void values_from_cpudlg (HWND hDlg) #ifdef JIT oldcache = workprefs.cachesize; - jitena = ischecked (hDlg, IDC_JITENABLE) ? 1 : 0; + jitena = (ischecked (hDlg, IDC_JITENABLE) ? 1 : 0) && !workprefs.address_space_24 && workprefs.cpu_model >= 68020; workprefs.cachesize = SendMessage (GetDlgItem (hDlg, IDC_CACHE), TBM_GETPOS, 0, 0) * 1024; - if (!workprefs.cachesize) - setchecked (hDlg, IDC_JITENABLE, false); if (!jitena) { cachesize_prev = workprefs.cachesize; trust_prev = workprefs.comptrustbyte; @@ -8843,6 +8906,8 @@ static void values_from_cpudlg (HWND hDlg) workprefs.comptrustlong = trust_prev; workprefs.comptrustnaddr = trust_prev; } + if (!workprefs.cachesize) + setchecked (hDlg, IDC_JITENABLE, false); if (oldcache == 0 && candirect && workprefs.cachesize > 0) canbang = 1; #endif @@ -11331,17 +11396,17 @@ static INT_PTR CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA break; case IDC_INFO0: case IDC_INFO0Q: - infofloppy (0); + infofloppy (hDlg, 0); break; case IDC_INFO1: case IDC_INFO1Q: - infofloppy (1); + infofloppy (hDlg, 1); break; case IDC_INFO2: - infofloppy (2); + infofloppy (hDlg, 2); break; case IDC_INFO3: - infofloppy (3); + infofloppy (hDlg, 3); break; case IDC_EJECT0: case IDC_EJECT0Q: @@ -11786,7 +11851,7 @@ static int joys[] = { IDC_PORT0_JOYS, IDC_PORT1_JOYS, IDC_PORT2_JOYS, IDC_PORT3_ static int joysm[] = { IDC_PORT0_JOYSMODE, IDC_PORT1_JOYSMODE, -1, -1 }; static int joysaf[] = { IDC_PORT0_AF, IDC_PORT1_AF, -1, -1 }; -static void updatejoyport (HWND hDlg) +static void updatejoyport (HWND hDlg, int changedport) { int i, j; TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH]; @@ -11856,40 +11921,9 @@ static void updatejoyport (HWND hDlg) } } -static void fixjport (struct jport *port, int v) +static void values_from_gameportsdlg (HWND hDlg, int d, int changedport) { - int vv = port->id; - if (vv == JPORT_CUSTOM || vv == JPORT_NONE) - return; - if (vv != v) - return; - if (vv >= JSEM_JOYS && vv < JSEM_MICE) { - vv -= JSEM_JOYS; - vv++; - if (vv >= inputdevice_get_device_total (IDTYPE_JOYSTICK)) - vv = 0; - vv += JSEM_JOYS; - } - if (vv >= JSEM_MICE && vv < JSEM_END) { - vv -= JSEM_MICE; - vv++; - if (vv >= inputdevice_get_device_total (IDTYPE_MOUSE)) - vv = 0; - vv += JSEM_MICE; - } - if (vv >= JSEM_KBDLAYOUT && vv < JSEM_LASTKBD) { - vv -= JSEM_KBDLAYOUT; - vv++; - if (vv >= JSEM_LASTKBD) - vv = 0; - vv += JSEM_KBDLAYOUT; - } - port->id = vv; -} - -static void values_from_gameportsdlg (HWND hDlg, int d) -{ - int i, j, success; + int i, success; int changed = 0; if (d) { @@ -11948,15 +11982,8 @@ static void values_from_gameportsdlg (HWND hDlg, int d) if (*port != prevport) changed = 1; } - if (changed) { - for (i = 0; i < MAX_JPORTS; i++) { - for (j = 0; j < MAX_JPORTS; j++) { - if (j != i) - fixjport (&workprefs.jports[i], workprefs.jports[j].id); - } - } - } - + if (changed) + inputdevice_validate_jports (&workprefs, changedport); } static int midi2dev (struct midiportinfo **mid, int idx, int def) @@ -12278,11 +12305,12 @@ static void processport (HWND hDlg, bool reset, int port) { if (reset) inputdevice_compa_clear (&workprefs, port); - values_from_gameportsdlg (hDlg, 0); + values_from_gameportsdlg (hDlg, 0, port); enable_for_gameportsdlg (hDlg); - updatejoyport (hDlg); + updatejoyport (hDlg, port); inputdevice_updateconfig (NULL, &workprefs); inputdevice_config_change (); + reset_inputdevice_config (&workprefs); } /* Handle messages for the Joystick Settings page of our property-sheet */ @@ -12354,13 +12382,13 @@ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP inputdevice_updateconfig (NULL, &workprefs); enable_for_gameportsdlg (hDlg); - updatejoyport (hDlg); + updatejoyport (hDlg, -1); recursive--; break; case WM_USER: recursive++; enable_for_gameportsdlg (hDlg); - updatejoyport (hDlg); + updatejoyport (hDlg, -1); recursive--; return TRUE; @@ -12374,23 +12402,23 @@ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP joyxprevious[0] = joyxprevious[1]; joyxprevious[1] = temp; enable_for_gameportsdlg (hDlg); - updatejoyport (hDlg); + updatejoyport (hDlg, -1); } else if (LOWORD (wParam) == IDC_PORT0_REMAP) { ports_remap (hDlg, 0); enable_for_gameportsdlg (hDlg); - updatejoyport (hDlg); + updatejoyport (hDlg, -1); } else if (LOWORD (wParam) == IDC_PORT1_REMAP) { ports_remap (hDlg, 1); enable_for_gameportsdlg (hDlg); - updatejoyport (hDlg); + updatejoyport (hDlg, -1); } else if (LOWORD (wParam) == IDC_PORT2_REMAP) { ports_remap (hDlg, 2); enable_for_gameportsdlg (hDlg); - updatejoyport (hDlg); + updatejoyport (hDlg, -1); } else if (LOWORD (wParam) == IDC_PORT3_REMAP) { ports_remap (hDlg, 3); enable_for_gameportsdlg (hDlg); - updatejoyport (hDlg); + updatejoyport (hDlg, -1); } else if (HIWORD (wParam) == CBN_SELCHANGE) { switch (LOWORD (wParam)) { @@ -12422,7 +12450,7 @@ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP } } } else { - values_from_gameportsdlg (hDlg, 1); + values_from_gameportsdlg (hDlg, 1, -1); enable_for_gameportsdlg (hDlg); } recursive--; @@ -12444,6 +12472,7 @@ static INT_PTR CALLBACK IOPortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR currentpage = IOPORTS_ID; init_portsdlg (hDlg); inputdevice_updateconfig (NULL, &workprefs); + reset_inputdevice_config (&workprefs); enable_for_portsdlg (hDlg); values_to_portsdlg (hDlg); recursive--; @@ -12526,37 +12555,6 @@ static void values_to_inputdlg (HWND hDlg) CheckDlgButton (hDlg, IDC_INPUTDEVICEDISABLE, (!input_total_devices || inputdevice_get_device_status (input_selected_device)) ? BST_CHECKED : BST_UNCHECKED); } -static int stringboxdialogactive; -static INT_PTR CALLBACK StringBoxDialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_DESTROY: - PostQuitMessage (0); - return TRUE; - case WM_CLOSE: - stringboxdialogactive = 0; - DestroyWindow (hDlg); - return TRUE; - case WM_INITDIALOG: - return TRUE; - case WM_COMMAND: - switch (LOWORD (wParam)) - { - case IDOK: - stringboxdialogactive = -1; - DestroyWindow (hDlg); - return TRUE; - case IDCANCEL: - stringboxdialogactive = 0; - DestroyWindow (hDlg); - return TRUE; - } - break; - } - return FALSE; -} - static int askinputcustom (HWND hDlg, TCHAR *custom, int maxlen, DWORD titleid) { HWND hwnd; diff --git a/od-win32/winuae_msvc10/winuae_msvc.vcxproj b/od-win32/winuae_msvc10/winuae_msvc.vcxproj index 433d2254..d51bfe4e 100644 --- a/od-win32/winuae_msvc10/winuae_msvc.vcxproj +++ b/od-win32/winuae_msvc10/winuae_msvc.vcxproj @@ -590,6 +590,7 @@ + @@ -693,7 +694,6 @@ - diff --git a/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters b/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters index d274109b..4184b353 100644 --- a/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters +++ b/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters @@ -244,9 +244,6 @@ common - - common - common @@ -628,6 +625,9 @@ common + + common + diff --git a/od-win32/winuae_msvc11/winuae_msvc.vcxproj b/od-win32/winuae_msvc11/winuae_msvc.vcxproj index 935362d8..dbf1ade2 100644 --- a/od-win32/winuae_msvc11/winuae_msvc.vcxproj +++ b/od-win32/winuae_msvc11/winuae_msvc.vcxproj @@ -63,7 +63,7 @@ Application false Unicode - v110 + v120 Application @@ -785,6 +785,7 @@ + @@ -888,7 +889,6 @@ - diff --git a/od-win32/winuae_msvc11/winuae_msvc.vcxproj.filters b/od-win32/winuae_msvc11/winuae_msvc.vcxproj.filters index c51d5962..1cf15a3b 100644 --- a/od-win32/winuae_msvc11/winuae_msvc.vcxproj.filters +++ b/od-win32/winuae_msvc11/winuae_msvc.vcxproj.filters @@ -244,9 +244,6 @@ common - - common - common @@ -628,6 +625,9 @@ common + + common + -- 2.47.3