X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fmemory.c;h=6281501039750c76443bd7a78200495cba0432cd;hb=274f95a9a9e5a889ee137a7cbd764a384a7ac2dd;hp=11de6417fe27765322ea2ff9e11a31e41ce5faf9;hpb=5e89f0f5aebedc086888415e063b9883fc4a9e92;p=picodrive.git diff --git a/pico/memory.c b/pico/memory.c index 11de641..6281501 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -15,15 +15,15 @@ extern unsigned int lastSSRamWrite; // used by serial eeprom code -unsigned long m68k_read8_map [0x1000000 >> M68K_MEM_SHIFT]; -unsigned long m68k_read16_map [0x1000000 >> M68K_MEM_SHIFT]; -unsigned long m68k_write8_map [0x1000000 >> M68K_MEM_SHIFT]; -unsigned long m68k_write16_map[0x1000000 >> M68K_MEM_SHIFT]; +uptr m68k_read8_map [0x1000000 >> M68K_MEM_SHIFT]; +uptr m68k_read16_map [0x1000000 >> M68K_MEM_SHIFT]; +uptr m68k_write8_map [0x1000000 >> M68K_MEM_SHIFT]; +uptr m68k_write16_map[0x1000000 >> M68K_MEM_SHIFT]; -static void xmap_set(unsigned long *map, int shift, int start_addr, int end_addr, - void *func_or_mh, int is_func) +static void xmap_set(uptr *map, int shift, int start_addr, int end_addr, + const void *func_or_mh, int is_func) { - unsigned long addr = (unsigned long)func_or_mh; + uptr addr = (uptr)func_or_mh; int mask = (1 << shift) - 1; int i; @@ -48,14 +48,14 @@ static void xmap_set(unsigned long *map, int shift, int start_addr, int end_addr } } -void z80_map_set(unsigned long *map, int start_addr, int end_addr, - void *func_or_mh, int is_func) +void z80_map_set(uptr *map, int start_addr, int end_addr, + const void *func_or_mh, int is_func) { xmap_set(map, Z80_MEM_SHIFT, start_addr, end_addr, func_or_mh, is_func); } -void cpu68k_map_set(unsigned long *map, int start_addr, int end_addr, - void *func_or_mh, int is_func) +void cpu68k_map_set(uptr *map, int start_addr, int end_addr, + const void *func_or_mh, int is_func) { xmap_set(map, M68K_MEM_SHIFT, start_addr, end_addr, func_or_mh, is_func); } @@ -63,8 +63,8 @@ void cpu68k_map_set(unsigned long *map, int start_addr, int end_addr, // more specialized/optimized function (does same as above) void cpu68k_map_all_ram(int start_addr, int end_addr, void *ptr, int is_sub) { - unsigned long *r8map, *r16map, *w8map, *w16map; - unsigned long addr = (unsigned long)ptr; + uptr *r8map, *r16map, *w8map, *w16map; + uptr addr = (uptr)ptr; int shift = M68K_MEM_SHIFT; int i; @@ -110,23 +110,23 @@ static void m68k_unmapped_write16(u32 a, u32 d) void m68k_map_unmap(int start_addr, int end_addr) { - unsigned long addr; + uptr addr; int shift = M68K_MEM_SHIFT; int i; - addr = (unsigned long)m68k_unmapped_read8; + addr = (uptr)m68k_unmapped_read8; for (i = start_addr >> shift; i <= end_addr >> shift; i++) m68k_read8_map[i] = (addr >> 1) | (1 << 31); - addr = (unsigned long)m68k_unmapped_read16; + addr = (uptr)m68k_unmapped_read16; for (i = start_addr >> shift; i <= end_addr >> shift; i++) m68k_read16_map[i] = (addr >> 1) | (1 << 31); - addr = (unsigned long)m68k_unmapped_write8; + addr = (uptr)m68k_unmapped_write8; for (i = start_addr >> shift; i <= end_addr >> shift; i++) m68k_write8_map[i] = (addr >> 1) | (1 << 31); - addr = (unsigned long)m68k_unmapped_write16; + addr = (uptr)m68k_unmapped_write16; for (i = start_addr >> shift; i <= end_addr >> shift; i++) m68k_write16_map[i] = (addr >> 1) | (1 << 31); } @@ -144,6 +144,10 @@ static u32 ym2612_read_local_68k(void); static int ym2612_write_local(u32 a, u32 d, int is_from_z80); static void z80_mem_setup(void); +#ifdef _ASM_MEMORY_C +u32 PicoRead8_sram(u32 a); +u32 PicoRead16_sram(u32 a); +#endif #ifdef EMU_CORE_DEBUG u32 lastread_a, lastread_d[16]={0,}, lastwrite_cyc_d[16]={0,}, lastwrite_mus_d[16]={0,}; @@ -172,7 +176,10 @@ void cyclone_crashed(u32 pc, struct Cyclone *context) // ----------------------------------------------------------------- // memmap helpers -static int PadRead(int i) +#ifndef _ASM_MEMORY_C +static +#endif +int PadRead(int i) { int pad,value,data_reg; pad=~PicoPadInt[i]; // Get inverse of pad MXYZ SACB RLDU @@ -204,6 +211,8 @@ static int PadRead(int i) return value; // will mirror later } +#ifndef _ASM_MEMORY_C + static u32 io_ports_read(u32 a) { u32 d; @@ -233,7 +242,9 @@ static void NOINLINE io_ports_write(u32 a, u32 d) Pico.ioports[a] = d; } -static void NOINLINE ctl_write_z80busreq(u32 d) +#endif // _ASM_MEMORY_C + +void NOINLINE ctl_write_z80busreq(u32 d) { d&=1; d^=1; elprintf(EL_BUSREQ, "set_zrun: %i->%i [%i] @%06x", Pico.m.z80Run, d, SekCyclesDone(), SekPc); @@ -253,7 +264,7 @@ static void NOINLINE ctl_write_z80busreq(u32 d) } } -static void NOINLINE ctl_write_z80reset(u32 d) +void NOINLINE ctl_write_z80reset(u32 d) { d&=1; d^=1; elprintf(EL_BUSREQ, "set_zreset: %i->%i [%i] @%06x", Pico.m.z80_reset, d, SekCyclesDone(), SekPc); @@ -277,6 +288,8 @@ static void NOINLINE ctl_write_z80reset(u32 d) // ----------------------------------------------------------------- +#ifndef _ASM_MEMORY_C + // cart (save) RAM area (usually 0x200000 - ...) static u32 PicoRead8_sram(u32 a) { @@ -322,6 +335,8 @@ static u32 PicoRead16_sram(u32 a) return m68k_unmapped_read16(a); } +#endif // _ASM_MEMORY_C + static void PicoWrite8_sram(u32 a, u32 d) { if (a > SRam.end || a < SRam.start || !(Pico.m.sram_reg & SRR_MAPPED)) { @@ -415,7 +430,6 @@ static void PicoWrite8_z80(u32 a, u32 d) SN76496Write(d); return; } -#if !defined(_ASM_MEMORY_C) || defined(_ASM_MEMORY_C_AMIPS) if ((a & 0x7f00) == 0x6000) // Z80 BANK register { Pico.m.z80_bank68k >>= 1; @@ -424,7 +438,6 @@ static void PicoWrite8_z80(u32 a, u32 d) elprintf(EL_Z80BNK, "z80 bank=%06x", Pico.m.z80_bank68k << 15); return; } -#endif elprintf(EL_UIO|EL_ANOMALY, "68k bad write [%06x] %02x @ %06x", a, d&0xff, SekPc); } @@ -435,6 +448,8 @@ static void PicoWrite16_z80(u32 a, u32 d) PicoWrite8_z80(a, d >> 8); } +#ifndef _ASM_MEMORY_C + // IO/control area (0xa10000 - 0xa1ffff) u32 PicoRead8_io(u32 a) { @@ -461,7 +476,7 @@ u32 PicoRead8_io(u32 a) goto end; } - if (!(PicoOpt & POPT_DIS_32X)) { + if (PicoOpt & POPT_EN_32X) { d = PicoRead8_32x(a); goto end; } @@ -496,7 +511,7 @@ u32 PicoRead16_io(u32 a) goto end; } - if (!(PicoOpt & POPT_DIS_32X)) { + if (PicoOpt & POPT_EN_32X) { d = PicoRead16_32x(a); goto end; } @@ -526,7 +541,7 @@ void PicoWrite8_io(u32 a, u32 d) Pico.m.sram_reg |= (u8)(d & 3); return; } - if (!(PicoOpt & POPT_DIS_32X)) { + if (PicoOpt & POPT_EN_32X) { PicoWrite8_32x(a, d); return; } @@ -554,13 +569,15 @@ void PicoWrite16_io(u32 a, u32 d) Pico.m.sram_reg |= (u8)(d & 3); return; } - if (!(PicoOpt & POPT_DIS_32X)) { + if (PicoOpt & POPT_EN_32X) { PicoWrite16_32x(a, d); return; } m68k_unmapped_write16(a, d); } +#endif // _ASM_MEMORY_C + // VDP area (0xc00000 - 0xdfffff) // TODO: verify if lower byte goes to PSG on word writes static u32 PicoRead8_vdp(u32 a)