From: Toni Wilen Date: Fri, 1 Feb 2013 17:54:28 +0000 (+0200) Subject: 2600b5 X-Git-Tag: 2600~16 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=7135be3789794949677fd9ad86ea9224ac610255;p=francis%2Fwinuae.git 2600b5 --- diff --git a/a2091.cpp b/a2091.cpp index be0108d4..f63c2711 100644 --- a/a2091.cpp +++ b/a2091.cpp @@ -199,7 +199,7 @@ static int scsidelay_irq[WD_STATUS_QUEUE]; static uae_u8 scsidelay_status[WD_STATUS_QUEUE]; static int queue_index; -static int wd33c93a = 1; +static int wd33c93_ver = 1; // A struct scsi_data *scsis[8]; static struct scsi_data *scsi; @@ -332,6 +332,15 @@ static bool decreasetc (void) return tc == 0; } +static bool canwddma (void) +{ + uae_u8 mode = wdregs[WD_CONTROL] >> 5; + if (mode != 0 && mode != 4 && mode != 1) { + write_log (_T("%s weird DMA mode %d!!\n"), WD33C93, mode); + } + return mode == 4 || mode == 1; +} + static TCHAR *scsitostring (void) { static TCHAR buf[200]; @@ -543,8 +552,8 @@ static void wd_cmd_sel_xfer (bool atn) wdregs[WD_COMMAND_PHASE] = 0x10; } #if WD33C93_DEBUG > 0 - write_log (_T("* %s select and transfer%s, ID=%d PHASE=%02X TC=%d\n"), - WD33C93, atn ? _T(" with atn") : _T(""), wdregs[WD_DESTINATION_ID] & 0x7, wdregs[WD_COMMAND_PHASE], tmp_tc); + write_log (_T("* %s select and transfer%s, ID=%d PHASE=%02X TC=%d wddma=%d dmac=%d\n"), + WD33C93, atn ? _T(" with atn") : _T(""), wdregs[WD_DESTINATION_ID] & 0x7, wdregs[WD_COMMAND_PHASE], tmp_tc, wdregs[WD_CONTROL] >> 5, dmac_dma); #endif if (wdregs[WD_COMMAND_PHASE] <= 0x30) { scsi->buffer[0] = 0; @@ -585,10 +594,10 @@ static void wd_cmd_sel_xfer (bool atn) wdregs[WD_COMMAND_PHASE] = 0x44; } - if (wdregs[WD_COMMAND_PHASE] == 0x44) { + // target replied or start/continue data phase (if data available) + if (wdregs[WD_COMMAND_PHASE] == 0x44 || wdregs[WD_COMMAND_PHASE] == 0x45) { settc (tmp_tc); wd_dataoffset = 0; - // target replied setphase (0x45); scsi_start_transfer (scsi); @@ -615,7 +624,7 @@ static void wd_cmd_sel_xfer (bool atn) if (scsi->direction) { scsi_start_transfer (scsi); - if ((wdregs[WD_CONTROL] >> 5) == 4) { + if (canwddma ()) { if (scsi->direction <= 0) { scsi_emulate_cmd (scsi); do_dma (); @@ -725,7 +734,7 @@ static void wd_cmd_trans_info (void) scsi->data_len = gettc (); } - if ((wdregs[WD_CONTROL] >> 5) == 4) { + if (canwddma ()) { wd_data_avail = -1; } else { wd_data_avail = 1; @@ -775,8 +784,6 @@ static void wd_cmd_reset (bool irq) for (i = 1; i < 0x16; i++) wdregs[i] = 0; wdregs[0x18] = 0; - if (!wd33c93a) - wdregs[0] &= ~(0x08 | 0x10); sasr = 0; wd_selected = false; scsi = NULL; @@ -829,14 +836,34 @@ static int writeonlyreg (int reg) return 0; } +static void writewdreg (int sasr, uae_u8 val) +{ + switch (sasr) + { + case WD_OWN_ID: + if (wd33c93_ver == 0) + val &= ~(0x20 | 0x08); + else if (wd33c93_ver == 1) + val &= ~0x20; + break; + } + if (sasr > WD_QUEUE_TAG && sasr < WD_AUXILIARY_STATUS) + return; + // queue tag is B revision only + if (sasr == WD_QUEUE_TAG && wd33c93_ver < 2) + return; + wdregs[sasr] = val; +} + void wdscsi_put (uae_u8 d) { #if WD33C93_DEBUG > 1 if (WD33C93_DEBUG > 3 || sasr != WD_DATA) write_log (_T("W %s REG %02X = %02X (%d) PC=%08X\n"), WD33C93, sasr, d, d, M68K_GETPC); #endif - if (!writeonlyreg (sasr)) - wdregs[sasr] = d; + if (!writeonlyreg (sasr)) { + writewdreg (sasr, d); + } if (!wd_used) { wd_used = 1; write_log (_T("%s in use\n"), WD33C93); diff --git a/akiko.cpp b/akiko.cpp index 8a227012..f404a0be 100644 --- a/akiko.cpp +++ b/akiko.cpp @@ -1825,7 +1825,7 @@ void akiko_reset (void) cdaudiostop (); akiko_thread_running = 0; while(akiko_thread_running == 0) - Sleep (10); + sleep_millis (10); akiko_thread_running = 0; } akiko_cdrom_free (); diff --git a/blitter.cpp b/blitter.cpp index 38ef1017..f50d4789 100644 --- a/blitter.cpp +++ b/blitter.cpp @@ -275,6 +275,7 @@ static void blitter_dump (void) write_log (_T("AFWM=%04X ALWM=%04X MOD A=%04X B=%04X C=%04X D=%04X\n"), blt_info.bltafwm, blt_info.bltalwm, blt_info.bltamod & 0xffff, blt_info.bltbmod & 0xffff, blt_info.bltcmod & 0xffff, blt_info.bltdmod & 0xffff); + write_log (_T("PC=%08X DMA=%d\n"), m68k_getpc (), dmaen (DMA_BLITTER)); } STATIC_INLINE const int *get_ch (void) @@ -319,6 +320,8 @@ int blitter_channel_state (void) extern int is_bitplane_dma (int hpos); STATIC_INLINE int canblit (int hpos) { + if (!dmaen (DMA_BLITTER)) + return 0; if (is_bitplane_dma (hpos)) return 0; if (cycle_line[hpos] & CYCLE_MASK) @@ -701,12 +704,6 @@ static void decide_blitter_line (int hsync, int hpos) break; } - if ((!dmaen (DMA_BLITTER) || v <= 0) && (c == 3 || c == 4)) { - blit_misscyclecounter++; - blitter_nasty++; - break; - } - blit_cyclecounter++; blit_totalcyclecounter++; @@ -1086,12 +1083,6 @@ void decide_blitter (int hpos) } blitter_nasty++; - - if (!dmaen (DMA_BLITTER) || v <= 0) { - blit_misscyclecounter++; - break; - } - blt_info.got_cycle = 1; if (c == 4) { blitter_doddma (last_blitter_hpos); @@ -1227,7 +1218,9 @@ static void blit_bltset (int con) blit_frozen = 1; write_log (_T("BLITTER: frozen! %d (%d) -> %d (%d) %08X\n"), original_ch, iseo, blit_ch, isen, M68K_GETPC); } else if (!iseo && isen) { - if (log_blitter & 2) + if (!dmaen (DMA_BLITTER)) // subtle shades / nuance bootblock bug + blit_frozen = 1; + if (log_blitter) write_log (_T("BLITTER: on the fly %d (%d) -> %d (%d) switch\n"), original_ch, iseo, blit_ch, isen); } } @@ -1431,7 +1424,8 @@ static void do_blitter2 (int hpos, int copper) } if (blt_info.vblitsize == 0 || (blitline && blt_info.hblitsize != 2)) { - blitter_done (hpos); + if (dmaen (DMA_BLITTER)) + blitter_done (hpos); return; } @@ -1439,10 +1433,8 @@ static void do_blitter2 (int hpos, int copper) blit_waitcyclecounter = 0; if (currprefs.immediate_blits) { - if (dmaen (DMA_BLITTER)) { + if (dmaen (DMA_BLITTER)) blitter_doit (); - return; - } return; } diff --git a/cpummu.cpp b/cpummu.cpp index 9ed001e3..6d0543d4 100644 --- a/cpummu.cpp +++ b/cpummu.cpp @@ -31,6 +31,7 @@ #include "memory.h" #include "newcpu.h" #include "cpummu.h" +#include "debug.h" #define DBG_MMU_VERBOSE 1 #define DBG_MMU_SANITY 1 @@ -267,7 +268,7 @@ static void mmu_bus_error(uaecptr addr, int fc, bool write, int size, bool rmw, ssw |= MMU_SSW_TT1; if ((fc2 & 3) != 3) fc2 &= ~2; -#if MMUDEBUG > 0 +#if MMUDEBUGMISC > 0 write_log (_T("040 MMU MOVES fc=%d -> %d\n"), fc, fc2); #endif fc = fc2; @@ -304,7 +305,7 @@ static void mmu_bus_error(uaecptr addr, int fc, bool write, int size, bool rmw, if (locked_rmw_cycle) { ssw |= MMU_SSW_LK | MMU_SSW_RW; locked_rmw_cycle = false; -#if MMUDEBUG > 0 +#if MMUDEBUGMISC > 0 write_log (_T("040 MMU_SSW_LK!\n")); #endif } @@ -319,14 +320,8 @@ static void mmu_bus_error(uaecptr addr, int fc, bool write, int size, bool rmw, uae_u32 fslw = 0; fslw |= write ? MMU_FSLW_W : MMU_FSLW_R; -#if 0 - // read-modify-write? - if (table68k[mmu060_opcode].rmw) { - fslw |= MMU_FSLW_W | MMU_FSLW_R; - } -#endif - fslw |= fc << 16; /* MMU_FSLW_TM */ + switch (size) { case sz_byte: fslw |= MMU_FSLW_SIZE_B; @@ -345,6 +340,9 @@ static void mmu_bus_error(uaecptr addr, int fc, bool write, int size, bool rmw, } if ((fc & 3) == 2) { // instruction faults always point to opcode address +#if MMUDEBUGMISC > 0 + write_log(_T("INS FAULT %08x %08x %d\n"), addr, regs.instruction_pc, mmu060_state); +#endif addr = regs.instruction_pc; if (mmu060_state == 0) { fslw |= MMU_FSLW_IO; // opword fetch @@ -364,7 +362,7 @@ static void mmu_bus_error(uaecptr addr, int fc, bool write, int size, bool rmw, regs.mmu_fslw = fslw; #if MMUDEBUG > 0 - write_log(_T("BF: fc=%d w=%d logical=%08x ssw=%08x rmw=%d PC=%08x INS=%04X\n"), fc, write, addr, fslw, rmw, m68k_getpc(), mmu_opcode); + write_log(_T("BF: fc=%d w=%d s=%d log=%08x ssw=%08x rmw=%d PC=%08x INS=%04X\n"), fc, write, 1 << size, addr, fslw, rmw, m68k_getpc(), mmu_opcode); #endif } @@ -468,7 +466,7 @@ fail: uaecptr REGPARAM2 mmu_translate(uaecptr addr, bool super, bool data, bool write) { struct mmu_atc_line *l; - uae_u32 status; + uae_u32 status = 0; // this should return a miss but choose a valid line mmu_user_lookup(addr, super, data, write, &l); @@ -478,7 +476,8 @@ uaecptr REGPARAM2 mmu_translate(uaecptr addr, bool super, bool data, bool write) #if MMUDEBUG > 2 write_log(_T("[MMU] mmu_translate error")); #endif - THROW(2); + mmu_bus_error(addr, mmu_get_fc(super, data), write, 0, false, status); + return 0; } return l->phys | (addr & mmu_pagemask); @@ -582,6 +581,26 @@ static uaecptr REGPARAM2 mmu_lookup_pagetable(uaecptr addr, bool super, bool wri return desc; } +static void misalignednotfirst(uaecptr addr) +{ +#if MMUDEBUGMISC > 0 + write_log (_T("misalignednotfirst %08x -> %08x %08X\n"), regs.mmu_fault_addr, addr, regs.instruction_pc); +#endif + regs.mmu_fault_addr = addr; + regs.mmu_fslw |= MMU_FSLW_MA; + regs.mmu_ssw |= MMU_SSW_MA; +} + +static void misalignednotfirstcheck(uaecptr addr) +{ +#if MMUDEBUGMISC > 0 + write_log (_T("misalignednotfirstcheck %08x -> %08x %08X\n"), regs.mmu_fault_addr, addr, regs.instruction_pc); +#endif + if (regs.mmu_fault_addr == addr) + return; + misalignednotfirst (addr); +} + uae_u16 REGPARAM2 mmu_get_word_unaligned(uaecptr addr, bool data, bool rmw) { uae_u16 res; @@ -594,9 +613,7 @@ uae_u16 REGPARAM2 mmu_get_word_unaligned(uaecptr addr, bool data, bool rmw) } CATCH(prb) { RESTORE_EXCEPTION; - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; + misalignednotfirst(addr); THROW_AGAIN(prb); } ENDTRY return res; @@ -615,9 +632,7 @@ uae_u32 REGPARAM2 mmu_get_long_unaligned(uaecptr addr, bool data, bool rmw) } CATCH(prb) { RESTORE_EXCEPTION; - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; + misalignednotfirst(addr); THROW_AGAIN(prb); } ENDTRY } else { @@ -631,9 +646,7 @@ uae_u32 REGPARAM2 mmu_get_long_unaligned(uaecptr addr, bool data, bool rmw) } CATCH(prb) { RESTORE_EXCEPTION; - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; + misalignednotfirst(addr); THROW_AGAIN(prb); } ENDTRY } @@ -644,17 +657,15 @@ uae_u16 REGPARAM2 mmu_get_lrmw_word_unaligned(uaecptr addr) { uae_u16 res; - res = (uae_u16)mmu_get_user_byte(addr, regs.s != 0, false, true, sz_word) << 8; + res = (uae_u16)mmu_get_user_byte(addr, regs.s != 0, true, true, sz_word) << 8; SAVE_EXCEPTION; TRY(prb) { - res |= mmu_get_user_byte(addr + 1, regs.s != 0, false, true, sz_word); + res |= mmu_get_user_byte(addr + 1, regs.s != 0, true, true, sz_word); RESTORE_EXCEPTION; } CATCH(prb) { RESTORE_EXCEPTION; - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; + misalignednotfirst(addr); THROW_AGAIN(prb); } ENDTRY return res; @@ -665,33 +676,29 @@ uae_u32 REGPARAM2 mmu_get_lrmw_long_unaligned(uaecptr addr) uae_u32 res; if (likely(!(addr & 1))) { - res = (uae_u32)mmu_get_user_word(addr, regs.s != 0, false, true, sz_long) << 16; + res = (uae_u32)mmu_get_user_word(addr, regs.s != 0, true, true, sz_long) << 16; SAVE_EXCEPTION; TRY(prb) { - res |= mmu_get_user_word(addr + 2, regs.s != 0, false, true, sz_long); + res |= mmu_get_user_word(addr + 2, regs.s != 0, true, true, sz_long); RESTORE_EXCEPTION; } CATCH(prb) { RESTORE_EXCEPTION; - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; + misalignednotfirst(addr); THROW_AGAIN(prb); } ENDTRY } else { - res = (uae_u32)mmu_get_user_byte(addr, regs.s != 0, false, true, sz_long) << 8; + res = (uae_u32)mmu_get_user_byte(addr, regs.s != 0, true, true, sz_long) << 8; SAVE_EXCEPTION; TRY(prb) { - res = (res | mmu_get_user_byte(addr + 1, regs.s != 0, false, true, sz_long)) << 8; - res = (res | mmu_get_user_byte(addr + 2, regs.s != 0, false, true, sz_long)) << 8; - res |= mmu_get_user_byte(addr + 3, regs.s != 0, false, true, sz_long); + res = (res | mmu_get_user_byte(addr + 1, regs.s != 0, true, true, sz_long)) << 8; + res = (res | mmu_get_user_byte(addr + 2, regs.s != 0, true, true, sz_long)) << 8; + res |= mmu_get_user_byte(addr + 3, regs.s != 0, true, true, sz_long); RESTORE_EXCEPTION; } CATCH(prb) { RESTORE_EXCEPTION; - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; + misalignednotfirst(addr); THROW_AGAIN(prb); } ENDTRY } @@ -748,11 +755,7 @@ void REGPARAM2 mmu_put_long_unaligned(uaecptr addr, uae_u32 val, bool data, bool CATCH(prb) { RESTORE_EXCEPTION; regs.wb3_data = val; - if (regs.mmu_fault_addr != addr) { - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; - } + misalignednotfirstcheck(addr); THROW_AGAIN(prb); } ENDTRY } @@ -768,11 +771,7 @@ void REGPARAM2 mmu_put_word_unaligned(uaecptr addr, uae_u16 val, bool data, bool CATCH(prb) { RESTORE_EXCEPTION; regs.wb3_data = val; - if (regs.mmu_fault_addr != addr) { - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; - } + misalignednotfirstcheck(addr); THROW_AGAIN(prb); } ENDTRY } @@ -832,9 +831,7 @@ uae_u32 REGPARAM2 sfc_get_long(uaecptr addr) } CATCH(prb) { RESTORE_EXCEPTION; - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; + misalignednotfirst(addr); THROW_AGAIN(prb); } ENDTRY } else { @@ -848,9 +845,7 @@ uae_u32 REGPARAM2 sfc_get_long(uaecptr addr) } CATCH(prb) { RESTORE_EXCEPTION; - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; + misalignednotfirst(addr); THROW_AGAIN(prb); } ENDTRY } @@ -878,9 +873,7 @@ uae_u16 REGPARAM2 sfc_get_word(uaecptr addr) } CATCH(prb) { RESTORE_EXCEPTION; - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; + misalignednotfirst(addr); THROW_AGAIN(prb); } ENDTRY } @@ -924,11 +917,7 @@ void REGPARAM2 dfc_put_long(uaecptr addr, uae_u32 val) CATCH(prb) { RESTORE_EXCEPTION; regs.wb3_data = val; - if (regs.mmu_fault_addr != addr) { - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; - } + misalignednotfirstcheck(addr); THROW_AGAIN(prb); } ENDTRY ismoves = false; @@ -953,11 +942,7 @@ void REGPARAM2 dfc_put_word(uaecptr addr, uae_u16 val) CATCH(prb) { RESTORE_EXCEPTION; regs.wb3_data = val; - if (regs.mmu_fault_addr != addr) { - regs.mmu_fault_addr = addr; - regs.mmu_fslw |= MMU_FSLW_MA; - regs.mmu_ssw |= MMU_SSW_MA; - } + misalignednotfirstcheck(addr); THROW_AGAIN(prb); } ENDTRY ismoves = false; @@ -1076,18 +1061,19 @@ void REGPARAM2 mmu_flush_atc(uaecptr addr, bool super, bool global) { int way,type,index; - uaecptr tag = (mmu_is_super | (addr >> 1)) & mmu_tagmask; + uaecptr tag = ((super ? 0x80000000 : 0) | (addr >> 1)) & mmu_tagmask; if (mmu_pagesize_8k) index=(addr & 0x0001E000)>>13; else index=(addr & 0x0000F000)>>12; - for (type=0;type> 3) { + case 1: + tmp1 = get_rmw_byte_mmu060 (src); + res = tmp1 << (24 + offset); + bdata[0] = tmp1 & ~(mask >> (24 + offset)); + break; + case 2: + tmp1 = get_rmw_word_mmu060 (src); + res = tmp1 << (16 + offset); + bdata[0] = tmp1 & ~(mask >> (16 + offset)); + break; + case 3: + tmp1 = get_rmw_word_mmu060 (src); + tmp2 = get_rmw_byte_mmu060 (src + 2); + res = tmp1 << (16 + offset); + bdata[0] = tmp1 & ~(mask >> (16 + offset)); + res |= tmp2 << (8 + offset); + bdata[1] = tmp2 & ~(mask >> (8 + offset)); + break; + case 4: + tmp1 = get_rmw_long_mmu060 (src); + res = tmp1 << offset; + bdata[0] = tmp1 & ~(mask >> offset); + break; + case 5: + tmp1 = get_rmw_long_mmu060 (src); + tmp2 = get_rmw_byte_mmu060 (src + 4); + res = tmp1 << offset; + bdata[0] = tmp1 & ~(mask >> offset); + res |= tmp2 >> (8 - offset); + bdata[1] = tmp2 & ~(mask << (8 - offset)); + break; + default: + /* Panic? */ + write_log (_T("x_get_bitfield() can't happen %d\n"), (offset + width + 7) >> 3); + res = 0; + break; + } + return res; +} + +void REGPARAM2 mmu060_put_rmw_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width) +{ + offset = (offset & 7) + width; + switch ((offset + 7) >> 3) { + case 1: + put_rmw_byte_mmu060 (dst, bdata[0] | (val << (8 - offset))); + break; + case 2: + put_rmw_word_mmu060 (dst, bdata[0] | (val << (16 - offset))); + break; + case 3: + put_rmw_word_mmu060 (dst, bdata[0] | (val >> (offset - 16))); + put_rmw_byte_mmu060 (dst + 2, bdata[1] | (val << (24 - offset))); + break; + case 4: + put_rmw_long_mmu060 (dst, bdata[0] | (val << (32 - offset))); + break; + case 5: + put_rmw_long_mmu060 (dst, bdata[0] | (val >> (offset - 32))); + put_rmw_byte_mmu060 (dst + 4, bdata[1] | (val << (40 - offset))); + break; + default: + write_log (_T("x_put_bitfield() can't happen %d\n"), (offset + 7) >> 3); + break; + } +} + + #ifndef __cplusplus jmp_buf __exbuf; int __exvalue; diff --git a/custom.cpp b/custom.cpp index e96186be..0a594e97 100644 --- a/custom.cpp +++ b/custom.cpp @@ -1597,10 +1597,15 @@ static void finish_last_fetch (int pos, int fm) return; if (plf_state == plf_end) return; - pos += flush_plane_data (fm); plf_state = plf_end; - ddfstate = DIW_waiting_start; - fetch_state = fetch_not_started; + if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS)) { + finish_final_fetch (fm); + } else { + bpl1dat_early = true; + pos += flush_plane_data (fm); + ddfstate = DIW_waiting_start; + fetch_state = fetch_not_started; + } } STATIC_INLINE int one_fetch_cycle_0 (int pos, int ddfstop_to_test, int dma, int fm) @@ -1920,6 +1925,7 @@ static void start_bpl_dma (int hpos, int hstart) cycle_diagram_shift = hstart; bpldmawasactive = true; + } last_fetch_hpos = hstart; @@ -3264,7 +3270,7 @@ static void calcdiw (void) plfstop = 0xff; plfstrt_start = HARD_DDF_START_REAL - 2; } else { - plfstrt_start = plfstrt - 4; + plfstrt_start = plfstrt; } } diw_change = 2; @@ -6400,9 +6406,9 @@ static void hsync_handler_post (bool onvsync) cnt++; if (cnt == 500) { int port_insert_custom (int inputmap_port, int devicetype, DWORD flags, const TCHAR *custom); - port_insert_custom (0, 2, 0, _T("Fire.autorepeat=0x38 Left=0x4B Right=0x4D Up=0x48 Down=0x50 Fire=0x4C Fire2=0x52'")); - port_insert_custom (1, 2, 0, _T("Left=0x48 Right=0x50 Up=0x4B Down=0x4D Fire=0x4C")); - } else if (cnt == 1000) { + //port_insert_custom (0, 2, 0, _T("Left=0xCB Right=0xCD Up=0xC8 Down=0xD0 Fire=0x39 Fire.autorepeat=0xD2")); + port_insert_custom (1, 2, 0, _T("Left=0x1E Right=0x20 Up=0x11 Down=0x1F Fire=0x38")); + } else if (0 && cnt == 1000) { TCHAR out[256]; bool port_get_custom (int inputmap_port, TCHAR *out); port_get_custom (0, out); diff --git a/debug.cpp b/debug.cpp index a04d75df..e34e55b8 100644 --- a/debug.cpp +++ b/debug.cpp @@ -4053,6 +4053,13 @@ const TCHAR *debuginfo (int mode) return txt; } +void mmu_disasm (uaecptr pc, int lines) +{ + debug_mmu_mode = regs.s ? 6 : 2; + m68k_dumpstate (0xffffffff, NULL); + m68k_disasm (pc, NULL, lines); +} + static int mmu_logging; #define MMU_PAGE_SHIFT 16 diff --git a/disk.cpp b/disk.cpp index 5cbb05ad..b9c2d9e1 100644 --- a/disk.cpp +++ b/disk.cpp @@ -201,7 +201,7 @@ typedef struct { #endif } drive; -#define MIN_STEPLIMIT_CYCLE (CYCLE_UNIT * 250) +#define MIN_STEPLIMIT_CYCLE (CYCLE_UNIT * 210) static uae_u16 bigmfmbufw[0x4000 * DDHDMULT]; static drive floppy[MAX_FLOPPY_DRIVES]; @@ -1195,7 +1195,7 @@ static void set_steplimit (drive *drv) // emulate step limit only if cycle-exact or approximate CPU speed if (currprefs.m68k_speed != 0) return; - drv->steplimit = 10; + drv->steplimit = 4; drv->steplimitcycle = get_cycles (); } diff --git a/filesys.cpp b/filesys.cpp index bd0fa131..d524bdb0 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -6816,7 +6816,7 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context) cdname_amiga = uip[unit_no].devname_amiga; uip[unit_no].devno = unit_no; type = FILESYS_VIRTUAL; - gui_flicker_led (LED_CD, cd_unit_no, -1); + gui_flicker_led (LED_CD, cd_unit_no, 0); write_log (_T("Mounting uaescsi.device %d: (%d)\n"), cd_unit_no, unit_no); put_long (parmpacket + 0, cdname_amiga); @@ -6847,7 +6847,7 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context) } else { - gui_flicker_led (LED_HD, unit_no, -1); + gui_flicker_led (LED_HD, unit_no, 0); type = is_hardfile (unit_no); if (type == FILESYS_HARDFILE_RDB || type == FILESYS_HARDDRIVE) { /* RDB hardfile */ diff --git a/fpp.cpp b/fpp.cpp index 8ec86cf2..c8c949ce 100644 --- a/fpp.cpp +++ b/fpp.cpp @@ -189,14 +189,13 @@ static void fpu_format_error (void) #endif } -static void fpu_op_illg (uae_u32 opcode, int pcoffset) +static void fpu_op_illg2 (uae_u16 opcode, uae_u32 ea, uaecptr oldpc) { if ((currprefs.cpu_model == 68060 && (currprefs.fpu_model == 0 || (regs.pcr & 2))) || (currprefs.cpu_model == 68040 && currprefs.fpu_model == 0)) { /* 68040 unimplemented/68060 FPU disabled exception. * Line F exception with different stack frame.. */ uaecptr newpc = m68k_getpc (); - uaecptr oldpc = newpc - pcoffset; regs.t0 = regs.t1 = 0; MakeSR (); if (!regs.s) { @@ -204,17 +203,25 @@ static void fpu_op_illg (uae_u32 opcode, int pcoffset) m68k_areg (regs, 7) = regs.isp; } regs.s = 1; - m68k_areg (regs, 7) -= 4; - x_put_long (m68k_areg (regs, 7), oldpc); - m68k_areg (regs, 7) -= 4; - x_put_long (m68k_areg (regs, 7), oldpc); - m68k_areg (regs, 7) -= 2; - x_put_long (m68k_areg (regs, 7), 0x4000 + 11 * 4); - m68k_areg (regs, 7) -= 4; + if (currprefs.cpu_model == 68060) { + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), oldpc); + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), ea); + m68k_areg (regs, 7) -= 2; + x_put_long (m68k_areg (regs, 7), 0x4000 + 11 * 4); + m68k_areg (regs, 7) -= 4; + } else { + m68k_areg (regs, 7) -= 4; + x_put_long (m68k_areg (regs, 7), ea); + m68k_areg (regs, 7) -= 2; + x_put_long (m68k_areg (regs, 7), 0x2000 + 11 * 4); + m68k_areg (regs, 7) -= 4; + } x_put_long (m68k_areg (regs, 7), newpc); m68k_areg (regs, 7) -= 2; x_put_long (m68k_areg (regs, 7), regs.sr); - write_log (_T("68040/060 FPU disabled exception PC=%x\n"), newpc); + write_log (_T("68040/060 FPU disabled exception OP=%04X EA=%08X PC=%08X\n"), opcode, ea, oldpc); newpc = x_get_long (regs.vbr + 11 * 4); m68k_setpc (newpc); #ifdef JIT @@ -225,15 +232,28 @@ static void fpu_op_illg (uae_u32 opcode, int pcoffset) op_illg (opcode); } -static bool fault_if_no_fpu (uae_u32 opcode, int pcoffset) +static void fpu_op_illg (uae_u16 opcode, uaecptr oldpc) +{ + fpu_op_illg2 (opcode, 0, oldpc); +} + +static bool fault_if_no_fpu (uae_u16 opcode, uaecptr ea, uaecptr oldpc) { if ((regs.pcr & 2) || currprefs.fpu_model <= 0) { - fpu_op_illg (opcode, pcoffset); + fpu_op_illg2 (opcode, ea, oldpc); return true; } return false; } +static void fpu_noinst (uae_u16 opcode, uaecptr pc) +{ + write_log (_T("Unknown FPU instruction %04X %08X\n"), opcode, pc); + m68k_setpc (pc); + op_illg (opcode); +} + + static int get_fpu_version (void) { int v = 0; @@ -446,7 +466,7 @@ STATIC_INLINE void from_pack (fptype src, uae_u32 * wrd1, uae_u32 * wrd2, uae_u3 } } -STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src) +STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src, uaecptr oldpc) { int size, mode, reg; uae_u32 ad = 0; @@ -454,6 +474,8 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src) static const int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 }; if (!(extra & 0x4000)) { + if (fault_if_no_fpu (opcode, 0, oldpc)) + return -1; *src = regs.fp[(extra >> 10) & 7]; return 1; } @@ -526,6 +548,10 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src) return 0; } } + + if (fault_if_no_fpu (opcode, ad, oldpc)) + return -1; + switch (size) { case 0: @@ -577,10 +603,10 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src) return 1; } -STATIC_INLINE int put_fp_value (fptype value, uae_u32 opcode, uae_u16 extra) +STATIC_INLINE int put_fp_value (fptype value, uae_u32 opcode, uae_u16 extra, uaecptr oldpc) { int size, mode, reg; - uae_u32 ad; + uae_u32 ad = 0; static int sz1[8] = { 4, 4, 12, 12, 2, 8, 1, 0 }; static int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 }; @@ -589,6 +615,8 @@ STATIC_INLINE int put_fp_value (fptype value, uae_u32 opcode, uae_u16 extra) write_log (_T("PUTFP: %f %04X %04X\n"), value, opcode, extra); #endif if (!(extra & 0x4000)) { + if (fault_if_no_fpu (opcode, 0, oldpc)) + return 1; regs.fp[(extra >> 10) & 7] = value; return 1; } @@ -662,6 +690,10 @@ STATIC_INLINE int put_fp_value (fptype value, uae_u32 opcode, uae_u16 extra) return 0; } } + + if (fault_if_no_fpu (opcode, ad, oldpc)) + return 1; + switch (size) { case 0: @@ -848,7 +880,7 @@ STATIC_INLINE int fpp_cond (int condition) void fpuop_dbcc (uae_u32 opcode, uae_u16 extra) { - uaecptr pc = (uae_u32) m68k_getpc (); + uaecptr pc = m68k_getpc (); uae_s32 disp; int cc; @@ -856,14 +888,14 @@ void fpuop_dbcc (uae_u32 opcode, uae_u16 extra) if (!isinrom ()) write_log (_T("fdbcc_opp at %08lx\n"), m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, 4)) - return; - regs.fpiar = m68k_getpc () - 4; disp = (uae_s32) (uae_s16) x_next_iword (); + if (fault_if_no_fpu (opcode, pc + disp, pc)) + return; + regs.fpiar = m68k_getpc () - 4; cc = fpp_cond (extra & 0x3f); if (cc == -1) { - fpu_op_illg (opcode, 4); + fpu_op_illg (opcode, regs.fpiar); } else if (!cc) { int reg = opcode & 0x7; @@ -883,21 +915,23 @@ void fpuop_scc (uae_u32 opcode, uae_u16 extra) if (!isinrom ()) write_log (_T("fscc_opp at %08lx\n"), m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, 4)) + if (fault_if_no_fpu (opcode, 0, 4)) return; regs.fpiar = m68k_getpc () - 4; cc = fpp_cond (extra & 0x3f); if (cc == -1) { - fpu_op_illg (opcode, 4); + fpu_op_illg (opcode, regs.fpiar); } else if ((opcode & 0x38) == 0) { + if (fault_if_no_fpu (opcode, 0, 4)) + return; m68k_dreg (regs, opcode & 7) = (m68k_dreg (regs, opcode & 7) & ~0xff) | (cc ? 0xff : 0x00); } else { if (get_fp_ad (opcode, &ad) == 0) { - m68k_setpc (m68k_getpc () - 4); - op_illg (opcode); - } else + fpu_noinst (opcode, regs.fpiar); + } else { x_cp_put_byte (ad, cc ? 0xff : 0x00); + } } } @@ -910,13 +944,13 @@ void fpuop_trapcc (uae_u32 opcode, uaecptr oldpc, uae_u16 extra) if (!isinrom ()) write_log (_T("ftrapcc_opp at %08lx\n"), m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, pc - oldpc)) + if (fault_if_no_fpu (opcode, 0, pc)) return; regs.fpiar = oldpc; cc = fpp_cond (extra & 0x3f); if (cc == -1) { - fpu_op_illg (opcode, pc - oldpc); + fpu_op_illg (opcode, oldpc); } if (cc) Exception (7); @@ -931,13 +965,13 @@ void fpuop_bcc (uae_u32 opcode, uaecptr oldpc, uae_u32 extra) if (!isinrom ()) write_log (_T("fbcc_opp at %08lx\n"), m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, pc - oldpc)) + if (fault_if_no_fpu (opcode, 0, pc)) return; regs.fpiar = oldpc; cc = fpp_cond (opcode & 0x3f); if (cc == -1) { - fpu_op_illg (opcode, pc - oldpc); + fpu_op_illg (opcode, oldpc); } else if (cc) { if ((opcode & 0x40) == 0) extra = (uae_s32) (uae_s16) extra; @@ -957,14 +991,14 @@ void fpuop_save (uae_u32 opcode) if (!isinrom ()) write_log (_T("fsave_opp at %08lx\n"), m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, 2)) - return; if (get_fp_ad (opcode, &ad) == 0) { - fpu_op_illg (opcode, 2); + fpu_op_illg (opcode, pc); return; } + if (fault_if_no_fpu (opcode, ad, pc)) + return; regs.fpiar = pc; if (currprefs.fpu_model == 68060) { @@ -1064,15 +1098,16 @@ void fpuop_restore (uae_u32 opcode) if (!isinrom ()) write_log (_T("frestore_opp at %08lx\n"), m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, 2)) - return; if (get_fp_ad (opcode, &ad) == 0) { - fpu_op_illg (opcode, 2); + fpu_op_illg (opcode, pc); return; } + if (fault_if_no_fpu (opcode, ad, pc)) + return; regs.fpiar = pc; + uae_u32 pad = ad; if (incr < 0) { ad -= 4; @@ -1293,29 +1328,28 @@ static uaecptr fmovem2fpp (uaecptr ad, uae_u32 list, int incr) static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) { - int reg; + int reg, v; fptype src; uaecptr pc = m68k_getpc () - 4; + uaecptr ad = 0; #if DEBUG_FPP if (!isinrom ()) write_log (_T("FPP %04lx %04x at %08lx\n"), opcode & 0xffff, extra, pc); #endif - if (fault_if_no_fpu (opcode, 4)) - return; switch ((extra >> 13) & 0x7) { case 3: - if (put_fp_value (regs.fp[(extra >> 7) & 7], opcode, extra) == 0) { - m68k_setpc (pc); - op_illg (opcode); - } + if (put_fp_value (regs.fp[(extra >> 7) & 7], opcode, extra, pc) == 0) + fpu_noinst (opcode, pc); return; case 4: case 5: if ((opcode & 0x38) == 0) { + if (fault_if_no_fpu (opcode, 0, pc)) + return; if (extra & 0x2000) { if (extra & 0x1000) m68k_dreg (regs, opcode & 7) = regs.fpcr & 0xffff; @@ -1334,6 +1368,8 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) regs.fpiar = m68k_dreg (regs, opcode & 7); } } else if ((opcode & 0x38) == 0x08) { + if (fault_if_no_fpu (opcode, 0, pc)) + return; if (extra & 0x2000) { if (extra & 0x1000) m68k_areg (regs, opcode & 7) = regs.fpcr & 0xffff; @@ -1352,6 +1388,8 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) regs.fpiar = m68k_areg (regs, opcode & 7); } } else if ((opcode & 0x3f) == 0x3c) { + if (fault_if_no_fpu (opcode, 0, pc)) + return; if ((extra & 0x2000) == 0) { if (extra & 0x1000) { regs.fpcr = x_next_ilong (); @@ -1368,10 +1406,12 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) int incr = 0; if (get_fp_ad (opcode, &ad) == 0) { - m68k_setpc (pc); - op_illg (opcode); + fpu_noinst (opcode, pc); return; } + if (fault_if_no_fpu (opcode, ad, pc)) + return; + if ((opcode & 0x38) == 0x20) { if (extra & 0x1000) incr += 4; @@ -1404,10 +1444,12 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) int incr = 0; if (get_fp_ad (opcode, &ad) == 0) { - m68k_setpc (pc); - op_illg (opcode); + fpu_noinst (opcode, pc); return; } + if (fault_if_no_fpu (opcode, ad, pc)) + return; + if((opcode & 0x38) == 0x20) { if (extra & 0x1000) incr += 4; @@ -1445,10 +1487,12 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) if (extra & 0x2000) { /* FMOVEM FPP->memory */ if (get_fp_ad (opcode, &ad) == 0) { - m68k_setpc (pc); - op_illg (opcode); + fpu_noinst (opcode, pc); return; } + if (fault_if_no_fpu (opcode, ad, pc)) + return; + switch ((extra >> 11) & 3) { case 0: /* static pred */ @@ -1476,10 +1520,11 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) } else { /* FMOVEM memory->FPP */ if (get_fp_ad (opcode, &ad) == 0) { - m68k_setpc (pc); - op_illg (opcode); + fpu_noinst (opcode, pc); return; } + if (fault_if_no_fpu (opcode, ad, pc)) + return; switch ((extra >> 11) & 3) { case 0: /* static pred */ @@ -1512,6 +1557,8 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) case 2: /* Extremely common */ reg = (extra >> 7) & 7; if ((extra & 0xfc00) == 0x5c00) { + if (fault_if_no_fpu (opcode, 0, pc)) + return; switch (extra & 0x7f) { case 0x00: @@ -1581,16 +1628,16 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) regs.fp[reg] = *fp_1e4096; break; default: - m68k_setpc (pc); - op_illg (opcode); + fpu_noinst (opcode, pc); return; } MAKE_FPSR (regs.fp[reg]); return; } - if (get_fp_value (opcode, extra, &src) == 0) { - m68k_setpc (pc); - op_illg (opcode); + v = get_fp_value (opcode, extra, &src, pc); + if (v <= 0) { + if (v == 0) + fpu_noinst (opcode, pc); return; } @@ -1822,8 +1869,7 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) MAKE_FPSR (src); return; default: - m68k_setpc (pc); - op_illg (opcode); + fpu_noinst (opcode, pc); return; } MAKE_FPSR (regs.fp[reg]); @@ -1831,8 +1877,7 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) default: break; } - m68k_setpc (pc); - op_illg (opcode); + fpu_noinst (opcode, pc); } void fpuop_arithmetic (uae_u32 opcode, uae_u16 extra) diff --git a/gayle.cpp b/gayle.cpp index 5e00956d..6e6adcba 100644 --- a/gayle.cpp +++ b/gayle.cpp @@ -28,6 +28,7 @@ #include "ncr_scsi.h" #include "blkdev.h" #include "scsi.h" +#include "threaddep/thread.h" #define PCMCIA_SRAM 1 #define PCMCIA_IDE 2 @@ -226,6 +227,9 @@ static int ide2, ide_splitter; static struct ide_hdf *ide; +static smp_comm_pipe requests; +static volatile int gayle_thread_running; + STATIC_INLINE void pw (int offset, uae_u16 w) { ide->secbuf[offset * 2 + 0] = (uae_u8)w; @@ -425,7 +429,6 @@ static uae_u8 read_gayle_cs (void) return v; } - static void ide_interrupt (void) { ide->irq_delay = 2; @@ -782,6 +785,7 @@ static void ide_write_sectors (int flags) ide->data_offset = 0; ide->regs.ide_status |= IDE_STATUS_DRQ; ide->data_size = nsec * ide->blocksize; + ide_interrupt (); } static void atapi_packet (void) @@ -1233,8 +1237,13 @@ static void ide_write_reg (int ide_reg, uae_u32 val) break; case IDE_STATUS: ide->irq = 0; - if (isdrive (ide)) + if (isdrive (ide)) { + ide->regs.ide_status |= IDE_STATUS_BSY; ide_do_command (val); + } +#if 0 + write_comm_pipe_u32 (&requests, (ide->num << 8) | val, 1); +#endif break; } } @@ -2537,10 +2546,28 @@ int gayle_modify_pcmcia_ide_unit (const TCHAR *path, int readonly, int insert) return freepcmcia (0); } +static void *ide_thread (void *null) +{ + for (;;) { + uae_u32 command = read_comm_pipe_u32_blocking (&requests); + if (gayle_thread_running == 0 || command == 0xfffffff) + break; + ide_do_command ((uae_u8)command); + } + gayle_thread_running = -1; + return 0; +} + static void initide (void) { int i; + if (!gayle_thread_running) { + gayle_thread_running = 1; + init_comm_pipe (&requests, 100, 1); + uae_start_thread (_T("ide"), ide_thread, 0, NULL); + } + alloc_ide_mem (idedrive, TOTAL_IDE * 2); if (isrestore ()) return; @@ -2567,6 +2594,17 @@ static void initide (void) gayle_irq = gayle_int = 0; } +void gayle_free (void) +{ + if (gayle_thread_running > 0) { + gayle_thread_running = 0; + write_comm_pipe_u32 (&requests, 0xffffffff, 1); + while(gayle_thread_running == 0) + sleep_millis (10); + gayle_thread_running = 0; + } +} + void gayle_reset (int hardreset) { static TCHAR bankname[100]; diff --git a/gencpu.cpp b/gencpu.cpp index e0e359d9..d422d3d4 100644 --- a/gencpu.cpp +++ b/gencpu.cpp @@ -2533,7 +2533,11 @@ static void gen_opcode (unsigned long int opcode) printf ("\t\tif (frame == 0x0) { m68k_areg (regs, 7) += offset; break; }\n"); printf ("\t\telse if (frame == 0x1) { m68k_areg (regs, 7) += offset; }\n"); printf ("\t\telse if (frame == 0x2) { m68k_areg (regs, 7) += offset + 4; break; }\n"); - printf ("\t\telse if (frame == 0x4) { m68k_areg (regs, 7) += offset + 8; break; }\n"); + if (using_mmu == 68060) { + printf ("\t\telse if (frame == 0x4) { m68k_do_rte_mmu060 (a); m68k_areg (regs, 7) += offset + 8; break; }\n"); + } else { + printf ("\t\telse if (frame == 0x4) { m68k_areg (regs, 7) += offset + 8; break; }\n"); + } printf ("\t\telse if (frame == 0x8) { m68k_areg (regs, 7) += offset + 50; break; }\n"); if (using_mmu == 68040) { printf ("\t\telse if (frame == 0x7) { m68k_do_rte_mmu040 (a); m68k_areg (regs, 7) += offset + 52; break; }\n"); @@ -3520,7 +3524,6 @@ static void gen_opcode (unsigned long int opcode) printf ("\tint ru = (src >> 6) & 7;\n"); printf ("\tint rc = src & 7;\n"); genflags (flag_cmp, curi->size, "newv", "m68k_dreg (regs, rc)", "dst"); - sync_m68k_pc (); gen_set_fault_pc (); printf ("\tif (GET_ZFLG ()) "); old_brace_level = n_braces; @@ -3532,6 +3535,11 @@ static void gen_opcode (unsigned long int opcode) printf ("else"); start_brace (); printf ("\n"); + if (cpu_level >= 4) { + // apparently 68040/060 needs to always write at the end of RMW cycle + printf ("\t"); + genastore_cas ("dst", curi->dmode, "dstreg", curi->size, "dst"); + } switch (curi->size) { case sz_byte: printf ("\t\tm68k_dreg(regs, rc) = (m68k_dreg(regs, rc) & ~0xff) | (dst & 0xff);\n"); @@ -3543,11 +3551,6 @@ static void gen_opcode (unsigned long int opcode) printf ("\t\tm68k_dreg(regs, rc) = dst;\n"); break; } - if (cpu_level >= 4) { - // apparently 68040/060 needs to always write at the end of RMW cycle - printf ("\t"); - genastore_cas ("dst", curi->dmode, "dstreg", curi->size, "dst"); - } pop_braces (old_brace_level); } break; @@ -3620,8 +3623,6 @@ static void gen_opcode (unsigned long int opcode) sync_m68k_pc (); pop_braces (old_brace_level); } - if (using_mmu != 68040) - sync_m68k_pc (); } break; case i_BKPT: /* only needed for hardware emulators */ @@ -3673,15 +3674,16 @@ static void gen_opcode (unsigned long int opcode) char *getb, *putb; int flags = 0; - if (using_mmu || using_ce020) { + if (using_mmu == 68060 && (curi->mnemo == i_BFCHG || curi->mnemo == i_BFCLR || curi->mnemo == i_BFSET || curi->mnemo == i_BFINS)) { + getb = "mmu060_get_rmw_bitfield"; + putb = "mmu060_put_rmw_bitfield"; + } else if (using_mmu || using_ce020) { getb = "x_get_bitfield"; putb = "x_put_bitfield"; } else { getb = "get_bitfield"; putb = "put_bitfield"; } - if (curi->mnemo == i_BFCHG || curi->mnemo == i_BFCLR || curi->mnemo == i_BFSET || curi->mnemo == i_BFINS) - flags = GF_RMW; genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); genamode (curi->dmode, "dstreg", sz_long, "dst", 2, 0, 0); diff --git a/include/cpummu.h b/include/cpummu.h index ea674289..71e7bcd6 100644 --- a/include/cpummu.h +++ b/include/cpummu.h @@ -307,6 +307,9 @@ STATIC_INLINE int mmu_match_ttr_write(uaecptr addr, bool super, bool data, uae_ extern void mmu_tt_modified (void); +extern uae_u32 REGPARAM3 mmu060_get_rmw_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) REGPARAM; +extern void REGPARAM3 mmu060_put_rmw_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width) REGPARAM; + extern uae_u16 REGPARAM3 mmu_get_word_unaligned(uaecptr addr, bool data, bool rmw) REGPARAM; extern uae_u32 REGPARAM3 mmu_get_long_unaligned(uaecptr addr, bool data, bool rmw) REGPARAM; diff --git a/include/debug.h b/include/debug.h index 28ae9959..accb739a 100644 --- a/include/debug.h +++ b/include/debug.h @@ -41,6 +41,7 @@ extern int instruction_breakpoint (TCHAR **c); extern int debug_bankchange (int); extern void log_dma_record (void); extern void debug_parser (const TCHAR *cmd, TCHAR *out, uae_u32 outsize); +extern void mmu_disasm (uaecptr pc, int lines); #define BREAKPOINT_TOTAL 20 struct breakpoint_node { diff --git a/include/gayle.h b/include/gayle.h index ef80b4c2..7512f0d9 100644 --- a/include/gayle.h +++ b/include/gayle.h @@ -1,6 +1,7 @@ extern void gayle_reset (int); extern void gayle_hsync (void); +extern void gayle_free (void); extern int gayle_add_ide_unit (int ch, struct uaedev_config_info *ci); extern int gayle_modify_pcmcia_sram_unit (const TCHAR *path, int readonly, int insert); extern int gayle_modify_pcmcia_ide_unit (const TCHAR *path, int readonly, int insert); diff --git a/include/mmu_common.h b/include/mmu_common.h index 37b63bd9..db1a7873 100644 --- a/include/mmu_common.h +++ b/include/mmu_common.h @@ -4,6 +4,7 @@ #define MMUDEBUG 1 #define MMUINSDEBUG 0 +#define MMUDEBUGMISC 0 #ifdef _MSC_VER #define unlikely(x) x @@ -108,10 +109,17 @@ typedef int m68k_exception; #define ALWAYS_INLINE __inline // take care of 2 kinds of alignement, bus size and page +#if 1 static inline bool is_unaligned(uaecptr addr, int size) { return unlikely((addr & (size - 1)) && (addr ^ (addr + size - 1)) & regs.mmu_page_size); } +#else +static inline bool is_unaligned(uaecptr addr, int size) +{ + return (addr & (size - 1)); +} +#endif static ALWAYS_INLINE void phys_put_long(uaecptr addr, uae_u32 l) { diff --git a/include/newcpu.h b/include/newcpu.h index c0f0a884..7d3d4129 100644 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -407,6 +407,7 @@ extern void init_m68k (void); extern void init_m68k_full (void); extern void m68k_go (int); extern void m68k_dumpstate (uaecptr *); +extern void m68k_dumpstate (uaecptr, uaecptr *); extern void m68k_reset (int); extern int getDivu68kCycles (uae_u32 dividend, uae_u16 divisor); extern int getDivs68kCycles (uae_s32 dividend, uae_s16 divisor); diff --git a/inputdevice.cpp b/inputdevice.cpp index 372de46f..a073cbd2 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -775,7 +775,7 @@ static void inputdevice_default_kb_all (struct uae_prefs *p) inputdevice_default_kb (p, i); } -static bool read_slot (TCHAR *parm, int num, int joystick, int button, struct uae_input_device *id, int keynum, int subnum, struct inputevent *ie, uae_u64 flags, int port, TCHAR *custom) +static bool read_slot (const TCHAR *parm, int num, int joystick, int button, struct uae_input_device *id, int keynum, int subnum, struct inputevent *ie, uae_u64 flags, int port, TCHAR *custom) { int mask; @@ -2277,28 +2277,124 @@ void inputdevice_read (void) } while (handle_msgpump ()); } +static void inject_events (const TCHAR *str) +{ + bool quot = false; + bool first = true; + uae_u8 keys[300]; + int keycnt = 0; + + for (;;) { + TCHAR ch = *str++; + if (!ch) + break; + + if (ch == '\'') { + first = false; + quot = !quot; + continue; + } + + if (!quot && (ch == ' ' || first)) { + const TCHAR *s = str; + if (first) + s--; + while (*s == ' ') + s++; + const TCHAR *s2 = s; + while (*s && *s != ' ') + s++; + int s2len = s - s2; + if (!s2len) + break; + for (int i = 1; events[i].name; i++) { + const TCHAR *cf = events[i].confname; + if (!_tcsnicmp (cf, _T("KEY_"), 4)) + cf += 4; + if (events[i].allow_mask == AM_K && !_tcsnicmp (cf, s2, _tcslen (cf)) && s2len == _tcslen (cf)) { + int j; + uae_u8 kc = events[i].data << 1; + TCHAR tch = _totupper (s2[0]); + if (tch != s2[0]) { + // release + for (j = 0; j < keycnt; j++) { + if (keys[j] == kc) + keys[j] = 0xff; + } + kc |= 0x01; + } else { + for (j = 0; j < keycnt; j++) { + if (keys[j] == kc) { + kc = 0xff; + } + } + if (kc != 0xff) { + for (j = 0; j < keycnt; j++) { + if (keys[j] == 0xff) { + keys[j] = kc; + break; + } + } + if (j == keycnt) { + if (keycnt < sizeof keys) + keys[keycnt++] = kc; + } + } + } + if (kc != 0xff) { + //write_log (_T("%s\n"), cf); + record_key (kc); + } + } + } + } else if (quot) { + ch = _totupper (ch); + if ((ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9')) { + for (int i = 1; events[i].name; i++) { + if (events[i].allow_mask == AM_K && events[i].name[1] == 0 && events[i].name[0] == ch) { + record_key (events[i].data << 1); + record_key ((events[i].data << 1) | 0x01); + //write_log (_T("%c\n"), ch); + } + } + } + } + first = false; + } + while (--keycnt >= 0) { + uae_u8 kc = keys[keycnt]; + if (kc != 0xff) + record_key (kc | 0x01); + } +} + static int handle_custom_event (const TCHAR *custom) { TCHAR *p, *buf, *nextp; + bool noquot = false; if (custom == NULL) return 0; config_changed = 1; write_log (_T("%s\n"), custom); - p = buf = my_strdup (custom); + p = buf = my_strdup_trim (custom); + if (p[0] != '\"') + noquot = true; while (p && *p) { TCHAR *p2; - if (*p != '\"') - break; - p++; - p2 = p; - while (*p2 != '\"' && *p2 != 0) - p2++; - if (*p2 == '\"') { - *p2++ = 0; - nextp = p2 + 1; - while (*nextp == ' ') - nextp++; + if (!noquot) { + if (*p != '\"') + break; + p++; + p2 = p; + while (*p2 != '\"' && *p2 != 0) + p2++; + if (*p2 == '\"') { + *p2++ = 0; + nextp = p2 + 1; + while (*nextp == ' ') + nextp++; + } } //write_log (L"-> '%s'\n", p); if (!_tcsicmp (p, _T("no_config_check"))) { @@ -2307,9 +2403,13 @@ static int handle_custom_event (const TCHAR *custom) config_changed = 1; } else if (!_tcsnicmp (p, _T("dbg "), 4)) { debug_parser (p + 4, NULL, -1); + } else if (!_tcsnicmp (p, _T("kbr "), 4)) { + inject_events (p + 4); } else { cfgfile_parse_line (&changed_prefs, p, 0); } + if (noquot) + break; p = nextp; } xfree (buf); @@ -4127,9 +4227,11 @@ static void checkcompakb (int *kb, int *srcmap) while (keyboard_default[k].scancode >= 0) { if (keyboard_default[k].scancode == kb[j]) { for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++) { - if (uid->extra[l] == id) { + if (uid->extra[l] == id && uid->port[l][0] == 0) { for (int m = 0; m < MAX_INPUT_SUB_EVENT && keyboard_default[k].node[m].evt; m++) { uid->eventid[l][m] = keyboard_default[k].node[m].evt; + uid->port[l][m] = 0; + uid->flags[l][m] = 0; } break; } @@ -4238,12 +4340,14 @@ static void setcompakb (int *kb, int *srcmap, int index, int af) int inputdevice_get_compatibility_input (struct uae_prefs *prefs, int index, int *typelist, int **inputlist, int **at) { if (index >= MAX_JPORTS || joymodes[index] < 0) - return 0; + return -1; *typelist = joymodes[index]; *inputlist = joyinputs[index]; *at = axistable; + //write_log (_T("%d %p %p\n"), *typelist, *inputlist, *at); int cnt = 0; for (int i = 0; joyinputs[index] && joyinputs[index][i] >= 0; i++, cnt++); + //write_log (_T("%d\n"), cnt); return cnt; } @@ -4306,7 +4410,7 @@ static void remove_compa_config (struct uae_prefs *prefs, int index) { int typelist, *inputlist, *atp; - if (!inputdevice_get_compatibility_input (prefs, index, &typelist, &inputlist, &atp)) + if (inputdevice_get_compatibility_input (prefs, index, &typelist, &inputlist, &atp) <= 0) return; for (int i = 0; inputlist[i] >= 0; i++) { int evtnum = inputlist[i]; @@ -4492,6 +4596,7 @@ static void setjoyinputs (struct uae_prefs *prefs, int port) joyinputs[port] = ip_mousecdtv; break; } + //write_log (_T("joyinput %d = %p\n"), port, joyinputs[port]); } static void setautofire (struct uae_input_device *uid, int port, int af) @@ -5983,6 +6088,21 @@ void inputdevice_copyconfig (const struct uae_prefs *src, struct uae_prefs *dst) inputdevice_updateconfig (src, dst); } +static void swapevent (struct uae_input_device *uid, int i, int j, int evt) +{ + uid->eventid[i][j] = evt; + int port = uid->port[i][j]; + if (port == 1) + port = 2; + else if (port == 2) + port = 1; + else if (port == 3) + port = 4; + else if (port == 4) + port = 3; + uid->port[i][j] = port; +} + static void swapjoydevice (struct uae_input_device *uid, int **swaps) { for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) { @@ -5992,7 +6112,7 @@ static void swapjoydevice (struct uae_input_device *uid, int **swaps) int evtnum; for (int kk = 0; (evtnum = swaps[k][kk]) >= 0 && !found; kk++) { if (uid->eventid[i][j] == evtnum) { - uid->eventid[i][j] = swaps[1 - k][kk]; + swapevent (uid, i, j, swaps[1 - k][kk]); found = true; } else { for (int jj = 0; axistable[jj] >= 0; jj += 3) { @@ -6002,7 +6122,7 @@ static void swapjoydevice (struct uae_input_device *uid, int **swaps) int evtnum2 = swaps[1 - k][kk]; for (int m = 0; axistable[m] >= 0; m += 3) { if (evtnum2 == axistable[m] || evtnum2 == axistable[m + 1] || evtnum2 == axistable[m + 2]) { - uid->eventid[i][j] = axistable[m + ii]; + swapevent (uid, i, j, axistable[m + ii]); found = true; } } diff --git a/keybuf.cpp b/keybuf.cpp index 72e13956..50754e7c 100644 --- a/keybuf.cpp +++ b/keybuf.cpp @@ -25,7 +25,8 @@ static int kpb_first, kpb_last; -static int keybuf[256]; +#define KEYBUF_SIZE 256 +static int keybuf[KEYBUF_SIZE]; int keys_available (void) { @@ -40,7 +41,7 @@ int get_next_key (void) assert (kpb_first != kpb_last); key = keybuf[kpb_last]; - if (++kpb_last == 256) + if (++kpb_last == KEYBUF_SIZE) kpb_last = 0; //write_log (_T("%02x:%d\n"), key >> 1, key & 1); return key; @@ -61,7 +62,7 @@ int record_key_direct (int kc) int b = !(kc & 1); //write_log (_T("got kc %02X\n"), ((kc << 7) | (kc >> 1)) & 0xff); - if (kpb_next == 256) + if (kpb_next == KEYBUF_SIZE) kpb_next = 0; if (kpb_next == kpb_last) { write_log (_T("Keyboard buffer overrun. Congratulations.\n")); diff --git a/main.cpp b/main.cpp index 5014f5ce..89465bcf 100644 --- a/main.cpp +++ b/main.cpp @@ -53,6 +53,7 @@ #include "dongle.h" #include "sampler.h" #include "consolehook.h" +#include "gayle.h" #ifdef RETROPLATFORM #include "rp.h" #endif @@ -863,6 +864,7 @@ void do_leave_program (void) #ifdef BSDSOCKET bsdlib_reset (); #endif + gayle_free (); device_func_reset (); savestate_free (); memory_cleanup (); @@ -978,6 +980,7 @@ static int real_main2 (int argc, TCHAR **argv) memset (&gui_data, 0, sizeof gui_data); gui_data.cd = -1; gui_data.hd = -1; + gui_data.md = -1; logging_init (); /* Yes, we call this twice - the first case handles when the user has loaded a config using the cmd-line. This case handles loads through the GUI. */ diff --git a/newcpu.cpp b/newcpu.cpp index 7e1285d7..38fddd64 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -898,7 +898,7 @@ static void set_x_funcs (void) x_cp_get_byte = x_get_byte; x_cp_next_iword = x_next_iword; x_cp_next_ilong = x_next_ilong; - x_cp_get_disp_ea_020 = get_disp_ea_020; + x_cp_get_disp_ea_020 = x_get_disp_ea_020; if (currprefs.mmu_model == 68030) { x_cp_put_long = put_long_mmu030_state; @@ -911,6 +911,7 @@ static void set_x_funcs (void) x_cp_next_ilong = next_ilong_mmu030_state; x_cp_get_disp_ea_020 = get_disp_ea_020_mmu030; } + } bool can_cpu_tracer (void) @@ -1768,41 +1769,41 @@ void REGPARAM2 put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 uae_u32 REGPARAM2 x_get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) { - uae_u32 tmp, res, mask; + uae_u32 tmp1, tmp2, res, mask; offset &= 7; mask = 0xffffffffu << (32 - width); switch ((offset + width + 7) >> 3) { case 1: - tmp = x_cp_get_byte (src); - res = tmp << (24 + offset); - bdata[0] = tmp & ~(mask >> (24 + offset)); + tmp1 = x_cp_get_byte (src); + res = tmp1 << (24 + offset); + bdata[0] = tmp1 & ~(mask >> (24 + offset)); break; case 2: - tmp = x_cp_get_word (src); - res = tmp << (16 + offset); - bdata[0] = tmp & ~(mask >> (16 + offset)); + tmp1 = x_cp_get_word (src); + res = tmp1 << (16 + offset); + bdata[0] = tmp1 & ~(mask >> (16 + offset)); break; case 3: - tmp = x_cp_get_word (src); - res = tmp << (16 + offset); - bdata[0] = tmp & ~(mask >> (16 + offset)); - tmp = x_cp_get_byte (src + 2); - res |= tmp << (8 + offset); - bdata[1] = tmp & ~(mask >> (8 + offset)); + tmp1 = x_cp_get_word (src); + tmp2 = x_cp_get_byte (src + 2); + res = tmp1 << (16 + offset); + bdata[0] = tmp1 & ~(mask >> (16 + offset)); + res |= tmp2 << (8 + offset); + bdata[1] = tmp2 & ~(mask >> (8 + offset)); break; case 4: - tmp = x_cp_get_long (src); - res = tmp << offset; - bdata[0] = tmp & ~(mask >> offset); + tmp1 = x_cp_get_long (src); + res = tmp1 << offset; + bdata[0] = tmp1 & ~(mask >> offset); break; case 5: - tmp = x_cp_get_long (src); - res = tmp << offset; - bdata[0] = tmp & ~(mask >> offset); - tmp = x_cp_get_byte (src + 4); - res |= tmp >> (8 - offset); - bdata[1] = tmp & ~(mask << (8 - offset)); + tmp1 = x_cp_get_long (src); + tmp2 = x_cp_get_byte (src + 4); + res = tmp1 << offset; + bdata[0] = tmp1 & ~(mask >> offset); + res |= tmp2 >> (8 - offset); + bdata[1] = tmp2 & ~(mask << (8 - offset)); break; default: /* Panic? */ @@ -2366,7 +2367,10 @@ static void Exception_build_stack_frame (uae_u32 oldpc, uae_u32 currpc, uae_u32 x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr); break; case 0xB: // long bus cycle fault stack frame (68020, 68030) - // store state information to internal register space + // We always use B frame because it is easier to emulate, + // our PC always points at start of instruction but A frame assumes + // it is + 2 and handling this properly is not easy. + // Store state information to internal register space for (i = 0; i < mmu030_idx + 1; i++) { m68k_areg (regs, 7) -= 4; x_put_long (m68k_areg (regs, 7), mmu030_ad[i].val); @@ -2436,11 +2440,11 @@ static void Exception_build_stack_frame (uae_u32 oldpc, uae_u32 currpc, uae_u32 // 68030 MMU static void Exception_mmu030 (int nr, uaecptr oldpc) { - uae_u32 currpc = m68k_getpc(), newpc; + uae_u32 currpc = m68k_getpc (), newpc; int sv = regs.s; - exception_debug(nr); - MakeSR(); + exception_debug (nr); + MakeSR (); if (!regs.s) { regs.usp = m68k_areg (regs, 7); @@ -2907,6 +2911,8 @@ int m68k_move2c (int regno, uae_u32 *regp) uae_u32 opcr = regs.pcr; regs.pcr &= ~(0x40 | 2 | 1); regs.pcr |= (*regp) & (0x40 | 2 | 1); + if (currprefs.fpu_model <= 0) + regs.pcr |= 2; if (((opcr ^ regs.pcr) & 2) == 2) { write_log (_T("68060 FPU state: %s\n"), regs.pcr & 2 ? _T("disabled") : _T("enabled")); /* flush possible already translated FPU instructions */ @@ -4325,7 +4331,6 @@ retry: mmufixup[1].reg = -1; } - //activate_debugger (); TRY (prb2) { Exception (prb); } CATCH (prb2) { @@ -4356,14 +4361,6 @@ retry: mmu_restart = true; pc = regs.instruction_pc = m68k_getpc (); - -#if 0 - if (pc == 0x0004B0A6) { - //write_log (_T("*")); - activate_debugger (); - } -#endif - mmu_opcode = -1; mmu_opcode = opcode = x_prefetch (0); count_instr (opcode); @@ -4390,7 +4387,6 @@ retry: mmufixup[0].reg = -1; } - //activate_debugger (); TRY (prb2) { Exception (prb); } CATCH (prb2) { @@ -4424,12 +4420,6 @@ insretry: f.x = regflags.x; mmu030_state[0] = mmu030_state[1] = mmu030_state[2] = 0; -#if 0 - if (pc == 0xC0075432) { - write_log (_T("*")); - //activate_debugger (); - } -#endif mmu030_opcode = -1; if (mmu030_opcode_stageb < 0) { opcode = get_iword_mmu030 (0); @@ -4452,8 +4442,10 @@ insretry: cnt--; // so that we don't get in infinite loop if things go horribly wrong if (!mmu030_retry) break; - if (cnt < 0) + if (cnt < 0) { + cpu_halt (9); break; + } if (mmu030_retry && mmu030_opcode == -1) goto insretry; // urgh } @@ -5322,7 +5314,7 @@ uae_u32 val_move2c (int regno) } } -void m68k_dumpstate (uaecptr *nextpc) +void m68k_dumpstate (uaecptr pc, uaecptr *nextpc) { int i, j; @@ -5386,9 +5378,15 @@ void m68k_dumpstate (uaecptr *nextpc) console_out_f (_T("Prefetch %04x (%s) %04x (%s)\n"), regs.irc, lookup1->name, regs.ir, lookup2->name); } - m68k_disasm (m68k_getpc (), nextpc, 1); - if (nextpc) - console_out_f (_T("Next PC: %08lx\n"), *nextpc); + if (pc != 0xffffffff) { + m68k_disasm (pc, nextpc, 1); + if (nextpc) + console_out_f (_T("Next PC: %08lx\n"), *nextpc); + } +} +void m68k_dumpstate (uaecptr *nextpc) +{ + m68k_dumpstate (m68k_getpc (), nextpc); } #ifdef SAVESTATE diff --git a/od-win32/rp.cpp b/od-win32/rp.cpp index 025f5ad3..efcc7b41 100644 --- a/od-win32/rp.cpp +++ b/od-win32/rp.cpp @@ -216,7 +216,7 @@ bool port_get_custom (int inputmap_port, TCHAR *out) const TCHAR **eventorder; max = inputdevice_get_compatibility_input (&currprefs, inputmap_port, &mode, &events, &axistable); - if (!max) + if (max <= 0) return false; int devicetype = -1; @@ -261,7 +261,7 @@ bool port_get_custom (int inputmap_port, TCHAR *out) } } } - write_log (_T("port_get_custom: %s\n"), out); + write_log (_T("port%d_get_custom: %s\n"), inputmap_port, out); return true; } @@ -273,18 +273,20 @@ int port_insert_custom (int inputmap_port, int devicetype, DWORD flags, const TC int kb; const TCHAR **eventorder; + max = inputdevice_get_compatibility_input (&changed_prefs, inputmap_port, &mode, &events, &axistable); + eventorder = getcustomeventorder (&devicetype); if (!eventorder) return FALSE; kb = inputdevice_get_device_total (IDTYPE_JOYSTICK) + inputdevice_get_device_total (IDTYPE_MOUSE); - inputdevice_updateconfig_internal (NULL, &changed_prefs); + inputdevice_copyconfig (&currprefs, &changed_prefs); inputdevice_compa_prepare_custom (&changed_prefs, inputmap_port, devicetype); - inputdevice_updateconfig_internal (NULL, &changed_prefs); + inputdevice_updateconfig (NULL, &changed_prefs); max = inputdevice_get_compatibility_input (&changed_prefs, inputmap_port, &mode, &events, &axistable); write_log (_T("custom='%s' max=%d port=%d dt=%d kb=%d kbnum=%d\n"), custom, max, inputmap_port, devicetype, kb, inputdevice_get_device_total (IDTYPE_KEYBOARD)); - if (!max) + if (max <= 0) return FALSE; while (p && p[0]) { @@ -347,17 +349,14 @@ int port_insert_custom (int inputmap_port, int devicetype, DWORD flags, const TC } } if (wdnum >= 0) { - //write_log (_T("kb=%d (%s) wdnum=%d\n"), j, inputdevicefunc_keyboard.get_friendlyname (j), wdnum); + write_log (_T("kb=%d (%s) wdnum=%d\n"), j, inputdevicefunc_keyboard.get_friendlyname (j), wdnum); inputdevice_set_gameports_mapping (&changed_prefs, kb + j, wdnum, evtnum, flags, inputmap_port); - inputdevice_set_gameports_mapping (&currprefs, kb + j, wdnum, evtnum, flags, inputmap_port); } else { write_log (_T("kb=%d (%): keycode %02x not found!\n"), j, inputdevicefunc_keyboard.get_friendlyname (j), kc); } } } - - inputdevice_updateconfig_internal (NULL, &changed_prefs); - inputdevice_updateconfig (NULL, &currprefs); + inputdevice_copyconfig (&changed_prefs, &currprefs); return TRUE; } @@ -1479,7 +1478,7 @@ void rp_update_leds (int led, int onoff, int write) switch (led) { case LED_POWER: - ledstate = onoff >= 250 ? 100 : onoff * 10 / 26; + ledstate = onoff >= 250 ? 100 : onoff * 5 / 26 + 49; if (ledstate == oldled[led]) return; oldled[led] = ledstate; diff --git a/od-win32/win32.h b/od-win32/win32.h index 77e5e9fd..105a1ec5 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -19,11 +19,11 @@ #define LANG_DLL 1 #if WINUAEPUBLICBETA -#define WINUAEBETA _T("4") +#define WINUAEBETA _T("5") #else #define WINUAEBETA _T("") #endif -#define WINUAEDATE MAKEBD(2013, 1, 26) +#define WINUAEDATE MAKEBD(2013, 2, 1) #define WINUAEEXTRA _T("") //#define WINUAEEXTRA _T("AmiKit Preview") #define WINUAEREV _T("") diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index ec5bad20..84d675cb 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -351,7 +351,8 @@ void centerdstrect (RECT *dr) } } -static int picasso_offset_x, picasso_offset_y, picasso_offset_mx, picasso_offset_my; +static int picasso_offset_x, picasso_offset_y; +static float picasso_offset_mx, picasso_offset_my; void getgfxoffset (float *dxp, float *dyp, float *mxp, float *myp) { @@ -1153,8 +1154,8 @@ static void DX_Blit96 (int x, int y, int w, int h) picasso_offset_x = 0; picasso_offset_y = 0; - picasso_offset_mx = 1000; - picasso_offset_my = 1000; + picasso_offset_mx = 1.0; + picasso_offset_my = 1.0; if (scalepicasso) { int srcratio, dstratio; int srcwidth, srcheight; @@ -1191,8 +1192,8 @@ static void DX_Blit96 (int x, int y, int w, int h) SetRect (&dr, xx / 2, 0,srcwidth - xx / 2, srcheight); picasso_offset_x = xx / 2; } - picasso_offset_mx = picasso96_state.Width * 1000 / (dr.right - dr.left); - picasso_offset_my = picasso96_state.Height * 1000 / (dr.bottom - dr.top); + picasso_offset_mx = (float)picasso96_state.Width / (dr.right - dr.left); + picasso_offset_my = (float)picasso96_state.Height / (dr.bottom - dr.top); DirectDraw_BlitToPrimaryScale (&dr, &sr); } else { SetRect (&sr, x, y, x + w, y + h); @@ -1265,8 +1266,8 @@ void getrtgfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_hei } OffsetRect (zr, picasso_offset_x, picasso_offset_y); - picasso_offset_mx = srcwidth * 1000 / (dr->right - dr->left); - picasso_offset_my = srcheight * 1000 / (dr->bottom - dr->top); + picasso_offset_mx = (float)srcwidth / (dr->right - dr->left); + picasso_offset_my = (float)srcheight / (dr->bottom - dr->top); } static bool rtg_locked; @@ -1627,7 +1628,7 @@ static int open_windows (bool mousecapture) if (startactive) { setpriority (&priorities[currprefs.win32_active_capture_priority]); for (i = 0; i < NUM_LEDS; i++) - gui_led (i, -1); + gui_flicker_led (i, -1, -1); gui_led (LED_POWER, gui_data.powerled); gui_fps (0, 0, 0); for (i = 0; i < 4; i++) { diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index f654266b..29e52dac 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -3457,7 +3457,7 @@ static int inputmap_handle (HWND list, int currentdevnum, int currentwidgetnum, portnum = inputmap_port; cntitem = 1; cntgroup = 1; - if (inputdevice_get_compatibility_input (&workprefs, portnum, &mode, &events, &axistable)) { + if (inputdevice_get_compatibility_input (&workprefs, portnum, &mode, &events, &axistable) > 0) { int evtnum; for (int i = 0; (evtnum = events[i]) >= 0; i++) { struct inputevent *evt = inputdevice_get_eventinfo (evtnum); @@ -9471,9 +9471,10 @@ static void updatehdfinfo (HWND hDlg, bool force, bool defaults) if (!memcmp (id, "RDSK", 4)) break; } - if (i == 16) + if (i == 16) { hdf_read (&hfd, id, 0, 512); - current_hfdlg.dostype = (id[0] << 24) | (id[1] << 16) | (id[2] << 8) | (id[3] << 0); + current_hfdlg.dostype = (id[0] << 24) | (id[1] << 16) | (id[2] << 8) | (id[3] << 0); + } } if (defaults) { if (hfd.flags & HFD_FLAGS_REALDRIVE) { @@ -10056,6 +10057,23 @@ static ACCEL HarddiskAccel[] = { { 0, 0, 0 } }; +static void hilitehd (HWND hDlg) +{ + int total = ListView_GetItemCount (cachedlist); + if (total <= 0) { + ew (hDlg, IDC_EDIT, FALSE); + ew (hDlg, IDC_REMOVE, FALSE); + return; + } + if (clicked_entry < 0) + clicked_entry = 0; + if (clicked_entry >= total) + clicked_entry = total; + ListView_SetItemState (cachedlist, clicked_entry, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + ew (hDlg, IDC_EDIT, TRUE); + ew (hDlg, IDC_REMOVE, TRUE); +} + static int harddiskdlg_button (HWND hDlg, WPARAM wParam) { int button = LOWORD (wParam); @@ -10065,11 +10083,15 @@ static int harddiskdlg_button (HWND hDlg, WPARAM wParam) quickstart_cdtype = 1; workprefs.cdslots[0].inuse = true; addcdtype (hDlg, IDC_CD_TYPE); + InitializeListView (hDlg); + hilitehd (hDlg); break; case IDC_CD_EJECT: eject_cd (); SetDlgItemText (hDlg, IDC_CD_TEXT, _T("")); addcdtype (hDlg, IDC_CD_TYPE); + InitializeListView (hDlg); + hilitehd (hDlg); break; case IDC_NEW_FS: default_fsvdlg (¤t_fsvdlg); @@ -10189,23 +10211,6 @@ static void harddiskdlg_volume_notify (HWND hDlg, NM_LISTVIEW *nmlistview) } } -static void hilitehd (HWND hDlg) -{ - int total = ListView_GetItemCount (cachedlist); - if (total <= 0) { - ew (hDlg, IDC_EDIT, FALSE); - ew (hDlg, IDC_REMOVE, FALSE); - return; - } - if (clicked_entry < 0) - clicked_entry = 0; - if (clicked_entry >= total) - clicked_entry = total; - ListView_SetItemState (cachedlist, clicked_entry, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); - ew (hDlg, IDC_EDIT, TRUE); - ew (hDlg, IDC_REMOVE, TRUE); -} - /* harddisk parent view */ static INT_PTR CALLBACK HarddiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -12830,7 +12835,7 @@ static void input_test (HWND hDlg, int port) for (int idx = 0; idx < MAX_JPORTS; idx++) { int mode, **events, *axistable; write_log (_T("Port: %d\n"), idx); - if (inputdevice_get_compatibility_input (&workprefs, idx, &mode, &events, &axistable)) { + if (inputdevice_get_compatibility_input (&workprefs, idx, &mode, &events, &axistable) > 0) { for (int k = 0; k < 2 && events[k]; k++) { int *p = events[k]; int evtnum; @@ -15321,6 +15326,7 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage) break; case ZFILE_HDFRDB: default_hfdlg (¤t_hfdlg, true); + _tcscpy (current_hfdlg.ci.rootdir, file); add_filesys_config (&workprefs, -1, ¤t_hfdlg.ci); break; case ZFILE_NVR: @@ -16052,13 +16058,16 @@ static void gui_flicker_led2 (int led, int unitnum, int status) old = *p; if (status < 0) { if (old < 0) { - *p = 0; + gui_led (led, -1); + } else { gui_led (led, 0); } return; } if (status == 0 && old < 0) { + *p = 0; resetcounter[led] = 0; + gui_led (led, 0); return; } if (status == 0) { @@ -16067,10 +16076,12 @@ static void gui_flicker_led2 (int led, int unitnum, int status) return; } #ifdef RETROPLATFORM - if (led == LED_HD) - rp_hd_activity (unitnum, status ? 1 : 0, status == 2 ? 1 : 0); - else if (led == LED_CD) - rp_cd_activity (unitnum, status); + if (unitnum >= 0) { + if (led == LED_HD) + rp_hd_activity (unitnum, status ? 1 : 0, status == 2 ? 1 : 0); + else if (led == LED_CD) + rp_cd_activity (unitnum, status); + } #endif *p = status; resetcounter[led] = 6; diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index 38c9042f..5e3c84f2 100644 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -1,6 +1,27 @@ - restore only single input target to default. +Beta 5: + +- RDB hardfile dragndrop to hardfiles panel added empty hardfile. +- Windowed mode bottom border "led" state didn't always match OSD led state. +- SCSI emulation improved, select and transfer starting from 0x45 can be used to receive data. +- SCSI emulation WD33C93 is now correctly detected as revision A, not B. (only B has Queue Tag register) +- 68060 MMU: BFCHG, BFCLR, BFSET and BFINS are read-modify-write instructions. +- GUI IDE/SCSI CD path was not updated in harddrive list when CD was changed using "Select image file" button. +- 68040/060 MMU emulation fix, PFLUSH/PFLUSHN only flushed supervisor space ATC. Hopefully this was the last major + 040/060 MMU bug. Weird NetBSD and Linux crashes are gone. +- Subtle Shades / Nuance remaining graphics glitches fixed. (NOTE: ECS only, OCS has corrupted graphics and it is correct behavior) +- GUI "Swap Ports" cleared custom mappings. +- 68040/060 no FPU/disabled FPU exceptions now include correctly calculated EA field. This should allow "compatible" 040/060 FPU + emulation with correctly handled missing instructions in the future (currently 040/060 FPU always supports all 68881/2 instructions) +- Added new keyboard custom event type, "kbr ". For example 'kbr "abc " SHIFT_LEFT "abc" shift_left RETURN' + generates "abc ABC". Input name in upper case = press, lower case = release. Quoted string automatically sends both press + and release key codes. Any unreleased keys are automatically released at the end. Non-quoted names are same as input event config + names without KEY-prefix. (inputevents.def in source archive) +- Adjusted drive step limit value slightly, Extemporized / Digital works again. +- Fixed virtual mouse driver mouse movement problem (b1) + Beta 4: - Fixed 68030 MMU MOVEM to memory wrong bus error data output buffer value. diff --git a/od-win32/writelog.cpp b/od-win32/writelog.cpp index 860cb679..d24e1322 100644 --- a/od-win32/writelog.cpp +++ b/od-win32/writelog.cpp @@ -89,8 +89,8 @@ static void getconsole (void) SetConsoleCP (65001); SetConsoleOutputCP (65001); if (GetConsoleScreenBufferInfo (stdoutput, &csbi)) { - if (csbi.dwMaximumWindowSize.Y < 900) { - csbi.dwMaximumWindowSize.Y = 900; + if (csbi.dwMaximumWindowSize.Y < 5000) { + csbi.dwMaximumWindowSize.Y = 5000; SetConsoleScreenBufferSize (stdoutput, csbi.dwMaximumWindowSize); } } diff --git a/statusline.cpp b/statusline.cpp index fa8e6eb1..f3f462b9 100644 --- a/statusline.cpp +++ b/statusline.cpp @@ -205,9 +205,11 @@ void draw_status_line_single (uae_u8 *buf, int bpp, int y, int totalwidth, uae_u } else if (led == LED_MD && gui_data.drive_disabled[3]) { // DF3 reused as internal non-volatile ram led (cd32/cdtv) pos = 6 + 3; - on = gui_data.md; - on_rgb = on == 2 ? 0xcc0000 : 0x00cc00; - off_rgb = 0x003300; + if (gui_data.md >= 0) { + on = gui_data.md; + on_rgb = on == 2 ? 0xcc0000 : 0x00cc00; + off_rgb = 0x003300; + } num1 = -1; num2 = -1; num3 = -1;