memory refactoring (mostly for cd) + ARM mem asm update
[picodrive.git] / pico / memory.c
index 11de641..13fc67e 100644 (file)
@@ -21,7 +21,7 @@ unsigned long m68k_write8_map [0x1000000 >> M68K_MEM_SHIFT];
 unsigned long m68k_write16_map[0x1000000 >> M68K_MEM_SHIFT];\r
 \r
 static void xmap_set(unsigned long *map, int shift, int start_addr, int end_addr,\r
-    void *func_or_mh, int is_func)\r
+    const void *func_or_mh, int is_func)\r
 {\r
   unsigned long addr = (unsigned long)func_or_mh;\r
   int mask = (1 << shift) - 1;\r
@@ -49,13 +49,13 @@ static void xmap_set(unsigned long *map, int shift, int start_addr, int end_addr
 }\r
 \r
 void z80_map_set(unsigned long *map, int start_addr, int end_addr,\r
-    void *func_or_mh, int is_func)\r
+    const void *func_or_mh, int is_func)\r
 {\r
   xmap_set(map, Z80_MEM_SHIFT, start_addr, end_addr, func_or_mh, is_func);\r
 }\r
 \r
 void cpu68k_map_set(unsigned long *map, int start_addr, int end_addr,\r
-    void *func_or_mh, int is_func)\r
+    const void *func_or_mh, int is_func)\r
 {\r
   xmap_set(map, M68K_MEM_SHIFT, start_addr, end_addr, func_or_mh, is_func);\r
 }\r
@@ -144,6 +144,10 @@ static u32 ym2612_read_local_68k(void);
 static int ym2612_write_local(u32 a, u32 d, int is_from_z80);\r
 static void z80_mem_setup(void);\r
 \r
+#ifdef _ASM_MEMORY_C\r
+u32 PicoRead8_sram(u32 a);\r
+u32 PicoRead16_sram(u32 a);\r
+#endif\r
 \r
 #ifdef EMU_CORE_DEBUG\r
 u32 lastread_a, lastread_d[16]={0,}, lastwrite_cyc_d[16]={0,}, lastwrite_mus_d[16]={0,};\r
@@ -172,7 +176,10 @@ void cyclone_crashed(u32 pc, struct Cyclone *context)
 // -----------------------------------------------------------------\r
 // memmap helpers\r
 \r
-static int PadRead(int i)\r
+#ifndef _ASM_MEMORY_C\r
+static\r
+#endif\r
+int PadRead(int i)\r
 {\r
   int pad,value,data_reg;\r
   pad=~PicoPadInt[i]; // Get inverse of pad MXYZ SACB RLDU\r
@@ -204,6 +211,8 @@ static int PadRead(int i)
   return value; // will mirror later\r
 }\r
 \r
+#ifndef _ASM_MEMORY_C\r
+\r
 static u32 io_ports_read(u32 a)\r
 {\r
   u32 d;\r
@@ -233,7 +242,9 @@ static void NOINLINE io_ports_write(u32 a, u32 d)
   Pico.ioports[a] = d;\r
 }\r
 \r
-static void NOINLINE ctl_write_z80busreq(u32 d)\r
+#endif // _ASM_MEMORY_C\r
+\r
+void NOINLINE ctl_write_z80busreq(u32 d)\r
 {\r
   d&=1; d^=1;\r
   elprintf(EL_BUSREQ, "set_zrun: %i->%i [%i] @%06x", Pico.m.z80Run, d, SekCyclesDone(), SekPc);\r
@@ -253,7 +264,7 @@ static void NOINLINE ctl_write_z80busreq(u32 d)
   }\r
 }\r
 \r
-static void NOINLINE ctl_write_z80reset(u32 d)\r
+void NOINLINE ctl_write_z80reset(u32 d)\r
 {\r
   d&=1; d^=1;\r
   elprintf(EL_BUSREQ, "set_zreset: %i->%i [%i] @%06x", Pico.m.z80_reset, d, SekCyclesDone(), SekPc);\r
@@ -277,6 +288,8 @@ static void NOINLINE ctl_write_z80reset(u32 d)
 \r
 // -----------------------------------------------------------------\r
 \r
+#ifndef _ASM_MEMORY_C\r
+\r
 // cart (save) RAM area (usually 0x200000 - ...)\r
 static u32 PicoRead8_sram(u32 a)\r
 {\r
@@ -322,6 +335,8 @@ static u32 PicoRead16_sram(u32 a)
   return m68k_unmapped_read16(a);\r
 }\r
 \r
+#endif // _ASM_MEMORY_C\r
+\r
 static void PicoWrite8_sram(u32 a, u32 d)\r
 {\r
   if (a > SRam.end || a < SRam.start || !(Pico.m.sram_reg & SRR_MAPPED)) {\r
@@ -415,7 +430,6 @@ static void PicoWrite8_z80(u32 a, u32 d)
       SN76496Write(d);\r
     return;\r
   }\r
-#if !defined(_ASM_MEMORY_C) || defined(_ASM_MEMORY_C_AMIPS)\r
   if ((a & 0x7f00) == 0x6000) // Z80 BANK register\r
   {\r
     Pico.m.z80_bank68k >>= 1;\r
@@ -424,7 +438,6 @@ static void PicoWrite8_z80(u32 a, u32 d)
     elprintf(EL_Z80BNK, "z80 bank=%06x", Pico.m.z80_bank68k << 15);\r
     return;\r
   }\r
-#endif\r
   elprintf(EL_UIO|EL_ANOMALY, "68k bad write [%06x] %02x @ %06x", a, d&0xff, SekPc);\r
 }\r
 \r
@@ -435,6 +448,8 @@ static void PicoWrite16_z80(u32 a, u32 d)
   PicoWrite8_z80(a, d >> 8);\r
 }\r
 \r
+#ifndef _ASM_MEMORY_C\r
+\r
 // IO/control area (0xa10000 - 0xa1ffff)\r
 u32 PicoRead8_io(u32 a)\r
 {\r
@@ -561,6 +576,8 @@ void PicoWrite16_io(u32 a, u32 d)
   m68k_unmapped_write16(a, d);\r
 }\r
 \r
+#endif // _ASM_MEMORY_C\r
+\r
 // VDP area (0xc00000 - 0xdfffff)\r
 // TODO: verify if lower byte goes to PSG on word writes\r
 static u32 PicoRead8_vdp(u32 a)\r