X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fmemory.c;h=2fff489b6cec31b7cca905a4706d4009de35e19d;hb=f3a57b2d6c6a32dc09a6efd4fbef31eb876263b2;hp=d36ac62418013c2cdcd0297378850f179ae2d9ec;hpb=db1d3564e69b422518701926bffdeae05379c400;p=picodrive.git diff --git a/pico/memory.c b/pico/memory.c index d36ac62..2fff489 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, +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; @@ -44,17 +44,17 @@ static void xmap_set(unsigned long *map, int shift, int start_addr, int end_addr for (i = start_addr >> shift; i <= end_addr >> shift; i++) { map[i] = addr >> 1; if (is_func) - map[i] |= 1 << (sizeof(addr) * 8 - 1); + map[i] |= (uptr)1 << (sizeof(addr) * 8 - 1); } } -void z80_map_set(unsigned long *map, int start_addr, int end_addr, +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 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); } @@ -257,8 +257,11 @@ void NOINLINE ctl_write_z80busreq(u32 d) else { z80stopCycle = SekCyclesDone(); - if ((PicoOpt&POPT_EN_Z80) && !Pico.m.z80_reset) + if ((PicoOpt&POPT_EN_Z80) && !Pico.m.z80_reset) { + pprof_start(m68k); PicoSyncZ80(z80stopCycle); + pprof_end_sub(m68k); + } } Pico.m.z80Run = d; } @@ -272,8 +275,11 @@ void NOINLINE ctl_write_z80reset(u32 d) { if (d) { - if ((PicoOpt&POPT_EN_Z80) && Pico.m.z80Run) + if ((PicoOpt&POPT_EN_Z80) && Pico.m.z80Run) { + pprof_start(m68k); PicoSyncZ80(SekCyclesDone()); + pprof_end_sub(m68k); + } YM2612ResetChip(); timers_reset(); } @@ -316,7 +322,7 @@ static u32 PicoRead8_sram(u32 a) static u32 PicoRead16_sram(u32 a) { u32 d; - if (SRam.end >= a && a >= SRam.start && (Pico.m.sram_reg & SRR_MAPPED)) + if (SRam.start <= a && a <= SRam.end && (Pico.m.sram_reg & SRR_MAPPED)) { if (SRam.flags & SRF_EEPROM) d = EEPROM_read(); @@ -957,7 +963,7 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80) if (xcycles >= timer_b_next_oflow) \ ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 2 -static u32 MEMH_FUNC ym2612_read_local_z80(void) +static u32 ym2612_read_local_z80(void) { int xcycles = z80_cyclesDone() << 8; @@ -1052,17 +1058,25 @@ void ym2612_unpack_state(void) elprintf(EL_YMTIMER, "load: %i/%i, timer_b_next_oflow %i", tbt>>16, tbc>>16, timer_b_next_oflow >> 8); } +#if defined(NO_32X) && defined(_ASM_MEMORY_C) +// referenced by asm code +u32 PicoRead8_32x(u32 a) { return 0; } +u32 PicoRead16_32x(u32 a) { return 0; } +void PicoWrite8_32x(u32 a, u32 d) {} +void PicoWrite16_32x(u32 a, u32 d) {} +#endif + // ----------------------------------------------------------------- // z80 memhandlers -static unsigned char MEMH_FUNC z80_md_vdp_read(unsigned short a) +static unsigned char z80_md_vdp_read(unsigned short a) { // TODO? elprintf(EL_ANOMALY, "z80 invalid r8 [%06x] %02x", a, 0xff); return 0xff; } -static unsigned char MEMH_FUNC z80_md_bank_read(unsigned short a) +static unsigned char z80_md_bank_read(unsigned short a) { unsigned int addr68k; unsigned char ret; @@ -1076,13 +1090,13 @@ static unsigned char MEMH_FUNC z80_md_bank_read(unsigned short a) return ret; } -static void MEMH_FUNC z80_md_ym2612_write(unsigned int a, unsigned char data) +static void z80_md_ym2612_write(unsigned int a, unsigned char data) { if (PicoOpt & POPT_EN_FM) emustatus |= ym2612_write_local(a, data, 1) & 1; } -static void MEMH_FUNC z80_md_vdp_br_write(unsigned int a, unsigned char data) +static void z80_md_vdp_br_write(unsigned int a, unsigned char data) { // TODO: allow full VDP access if ((a&0xfff9) == 0x7f11) // 7f11 7f13 7f15 7f17 @@ -1103,7 +1117,7 @@ static void MEMH_FUNC z80_md_vdp_br_write(unsigned int a, unsigned char data) elprintf(EL_ANOMALY, "z80 invalid w8 [%06x] %02x", a, data); } -static void MEMH_FUNC z80_md_bank_write(unsigned int a, unsigned char data) +static void z80_md_bank_write(unsigned int a, unsigned char data) { unsigned int addr68k; @@ -1146,8 +1160,8 @@ static void z80_mem_setup(void) drZ80.z80_out = z80_md_out; #endif #ifdef _USE_CZ80 - Cz80_Set_Fetch(&CZ80, 0x0000, 0x1fff, (UINT32)Pico.zram); // main RAM - Cz80_Set_Fetch(&CZ80, 0x2000, 0x3fff, (UINT32)Pico.zram); // mirror + Cz80_Set_Fetch(&CZ80, 0x0000, 0x1fff, (FPTR)Pico.zram); // main RAM + Cz80_Set_Fetch(&CZ80, 0x2000, 0x3fff, (FPTR)Pico.zram); // mirror Cz80_Set_INPort(&CZ80, z80_md_in); Cz80_Set_OUTPort(&CZ80, z80_md_out); #endif