+#if defined(ICACHE_EMULATION)
+ /* Stores in PS1 code during cache isolation invalidate cachelines.
+ * It is assumed that cache-flush routines write to the lowest 4KB of
+ * address space for Icache, or 1KB for Dcache/scratchpad.
+ * Originally, stores had to check 'writeok' in psxRegs struct before
+ * writing to RAM. To eliminate this necessity, we could simply patch the
+ * BIOS 0x44 FlushCache() A0 jumptable entry. Unfortunately, this won't
+ * work for some games that use less-buggy non-BIOS cache-flush routines
+ * like '007 Tomorrow Never Dies', often provided by SN-systems, the PS1
+ * toolchain provider.
+ * Instead, we backup the lowest 64KB PS1 RAM when the cache is isolated.
+ * All stores write to RAM regardless of cache state. Thus, cache-flush
+ * routines temporarily trash the lowest 4KB of PS1 RAM. Fortunately, they
+ * ran in a 'critical section' with interrupts disabled, so there's little
+ * worry of PS1 code ever reading the trashed contents.
+ * We point the relevant portions of psxMemRLUT[] to the 64KB backup while
+ * cache is isolated. This is in case the dynarec needs to recompile some
+ * code during isolation. As long as it reads code using psxMemRLUT[] ptrs,
+ * it should never see trashed RAM contents.
+ *
+ * -senquack, mips dynarec team, 2017
+ */
+ static u32 mem_bak[0x10000/4];
+#endif