From 61290a355398cc8f17b183700f637dc65a8b8ab4 Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 11 Aug 2017 02:12:57 +0300 Subject: [PATCH] drz80: drop fast_sp for compatibility no measurable improvement in most cases anyway --- cpu/DrZ80/drz80.s | 4 +++- pico/z80if.c | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/cpu/DrZ80/drz80.s b/cpu/DrZ80/drz80.s index b92b2c2d..c2a64df3 100644 --- a/cpu/DrZ80/drz80.s +++ b/cpu/DrZ80/drz80.s @@ -12,7 +12,7 @@ .global DrZ80Ver .equiv INTERRUPT_MODE, 0 ;@0 = Use internal int handler, 1 = Use Mames int handler - .equiv FAST_Z80SP, 1 ;@0 = Use mem functions for stack pointer, 1 = Use direct mem pointer + .equiv FAST_Z80SP, 0 ;@0 = Use mem functions for stack pointer, 1 = Use direct mem pointer .equiv UPDATE_CONTEXT, 0 .equiv DRZ80_XMAP, 1 .equiv DRZ80_XMAP_MORE_INLINE, 1 @@ -212,6 +212,7 @@ z80_bad_jump: mov z80pc,r0 ldmfd sp!,{r3,r12,pc} +.if FAST_Z80SP z80_xmap_rebase_sp: ldr r1,[cpucontext,#z80_read8] sub r2,r0,#1 @@ -228,6 +229,7 @@ z80_xmap_rebase_sp: ldr pc,[cpucontext,#z80_rebaseSP] mov z80sp,r0 ldmfd sp!,{r3,r12,pc} +.endif @ FAST_Z80SP .endif @ DRZ80_XMAP diff --git a/pico/z80if.c b/pico/z80if.c index 8db4aa5c..90b3f7a9 100644 --- a/pico/z80if.c +++ b/pico/z80if.c @@ -14,9 +14,11 @@ uptr z80_read_map [0x10000 >> Z80_MEM_SHIFT]; uptr z80_write_map[0x10000 >> Z80_MEM_SHIFT]; #ifdef _USE_DRZ80 -struct DrZ80 drZ80; +// this causes trouble in some cases, like doukutsu putting sp in bank area +// no perf difference for most, upto 1-2% for some others +//#define FAST_Z80SP -static u32 drz80_sp_base; +struct DrZ80 drZ80; static void drz80_load_pcsp(u32 pc, u32 sp) { @@ -28,6 +30,8 @@ static void drz80_load_pcsp(u32 pc, u32 sp) drZ80.Z80PC_BASE <<= 1; drZ80.Z80PC = drZ80.Z80PC_BASE + pc; } + drZ80.Z80SP = sp; +#ifdef FAST_Z80SP drZ80.Z80SP_BASE = z80_read_map[sp >> Z80_MEM_SHIFT]; if (drZ80.Z80SP_BASE & (1<<31)) { elprintf(EL_STATUS|EL_ANOMALY, "load_pcsp: bad SP: %04x", sp); @@ -37,6 +41,7 @@ static void drz80_load_pcsp(u32 pc, u32 sp) drZ80.Z80SP_BASE <<= 1; drZ80.Z80SP = drZ80.Z80SP_BASE + sp; } +#endif } // called only if internal xmap rebase fails @@ -47,13 +52,19 @@ static unsigned int dz80_rebase_pc(unsigned short pc) return drZ80.Z80PC_BASE; } +#ifdef FAST_Z80SP +static u32 drz80_sp_base; + static unsigned int dz80_rebase_sp(unsigned short sp) { elprintf(EL_STATUS|EL_ANOMALY, "dz80_rebase_sp: fail on %04x", sp); drZ80.Z80SP_BASE = z80_read_map[drz80_sp_base >> Z80_MEM_SHIFT] << 1; return drZ80.Z80SP_BASE + (1 << Z80_MEM_SHIFT) - 0x100; } +#else +#define dz80_rebase_sp NULL #endif +#endif // _USE_DRZ80 void z80_init(void) @@ -91,9 +102,11 @@ void z80_reset(void) drZ80.Z80IX = 0xFFFF << 16; drZ80.Z80IY = 0xFFFF << 16; */ +#ifdef FAST_Z80SP // drZ80 is locked in single bank drz80_sp_base = (PicoAHW & PAHW_SMS) ? 0xc000 : 0x0000; drZ80.Z80SP_BASE = z80_read_map[drz80_sp_base >> Z80_MEM_SHIFT] << 1; +#endif if (PicoAHW & PAHW_SMS) drZ80.Z80SP = drZ80.Z80SP_BASE + 0xdff0; // simulate BIOS // XXX: since we use direct SP pointer, it might make sense to force it to RAM, @@ -286,3 +299,5 @@ void z80_debug(char *dstr) sprintf(dstr, "Z80 state: PC: %04x SP: %04x\n", (unsigned int)(CZ80.PC - CZ80.BasePC), CZ80.SP.W); #endif } + +// vim:ts=2:sw=2:expandtab -- 2.39.5