From 7120512205c633ad3263c9df2ff7db0da87ba0af Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Thu, 13 Jun 2019 18:36:08 +0200 Subject: [PATCH] wince: use exceptions in dyna/decoder.cpp and catch them in driver.cpp --- core/hw/sh4/dyna/decoder.cpp | 14 ++------------ core/hw/sh4/dyna/driver.cpp | 12 +++++++++++- core/hw/sh4/modules/mmu.cpp | 17 ----------------- core/hw/sh4/modules/mmu.h | 2 -- 4 files changed, 13 insertions(+), 32 deletions(-) diff --git a/core/hw/sh4/dyna/decoder.cpp b/core/hw/sh4/dyna/decoder.cpp index bb0c1b441..c1763a2cb 100644 --- a/core/hw/sh4/dyna/decoder.cpp +++ b/core/hw/sh4/dyna/decoder.cpp @@ -1059,18 +1059,8 @@ bool dec_DecodeBlock(RuntimeBlockInfo* rbi,u32 max_cycles) } */ - u32 op; - if (!mmu_enabled()) - op = IReadMem16(state.cpu.rpc); -#ifndef NO_MMU - else - { - u32 exception_occurred; - op = mmu_IReadMem16NoEx(state.cpu.rpc, &exception_occurred); - if (exception_occurred) - return false; - } -#endif + u32 op = IReadMem16(state.cpu.rpc); + if (op==0 && state.cpu.is_delayslot) { printf("Delayslot 0 hack!\n"); diff --git a/core/hw/sh4/dyna/driver.cpp b/core/hw/sh4/dyna/driver.cpp index 77d75bce1..db0e3086b 100644 --- a/core/hw/sh4/dyna/driver.cpp +++ b/core/hw/sh4/dyna/driver.cpp @@ -261,8 +261,18 @@ bool RuntimeBlockInfo::Setup(u32 rpc,fpscr_t rfpu_cfg) oplist.clear(); - if (!dec_DecodeBlock(this, SH4_TIMESLICE / 2)) +#if !defined(NO_MMU) + try { +#endif + if (!dec_DecodeBlock(this, SH4_TIMESLICE / 2)) + return false; +#if !defined(NO_MMU) + } + catch (SH4ThrownException& ex) { + Do_Exception(rpc, ex.expEvn, ex.callVect); return false; + } +#endif AnalyseBlock(this); diff --git a/core/hw/sh4/modules/mmu.cpp b/core/hw/sh4/modules/mmu.cpp index 312ddcb3b..83981dde3 100644 --- a/core/hw/sh4/modules/mmu.cpp +++ b/core/hw/sh4/modules/mmu.cpp @@ -756,23 +756,6 @@ void DYNACALL mmu_WriteMem(u32 adr, T data) _vmem_writet(addr, data); } -u16 DYNACALL mmu_IReadMem16NoEx(u32 vaddr, u32 *exception_occurred) -{ - u32 addr; - u32 rv = mmu_instruction_translation(vaddr, addr); - if (rv != MMU_ERROR_NONE) - { - DoMMUException(vaddr, rv, MMU_TT_IREAD); - *exception_occurred = 1; - return 0; - } - else - { - *exception_occurred = 0; - return _vmem_ReadMem16(addr); - } -} - bool mmu_TranslateSQW(u32 adr, u32* out) { if (!settings.dreamcast.FullMMU) diff --git a/core/hw/sh4/modules/mmu.h b/core/hw/sh4/modules/mmu.h index a03195e6a..c9419321a 100644 --- a/core/hw/sh4/modules/mmu.h +++ b/core/hw/sh4/modules/mmu.h @@ -95,8 +95,6 @@ void DoMMUException(u32 addr, u32 error_code, u32 access_type); bool mmu_TranslateSQW(u32 addr, u32* mapped); - u16 DYNACALL mmu_IReadMem16NoEx(u32 adr, u32 *exception_occurred); - template T DYNACALL mmu_ReadMemNoEx(u32 adr, u32 *exception_occurred) {