X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fmemory.c;h=0e4a624e28f377677fcc879fe987818c3750dbad;hb=9aee8770d2504ed14980dc47f4683bdf080310c9;hp=9967f5c2877f58e7a326011fbef6f106046dce35;hpb=553c3eaa3a4bda6ba99d925ecab518fe82530cd6;p=picodrive.git diff --git a/pico/memory.c b/pico/memory.c index 9967f5c..0e4a624 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -1,11 +1,11 @@ -// This is part of Pico Library - -// (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006-2009 notaz, All rights reserved. -// Free for non-commercial use. - -// For commercial use, separate licencing terms must be obtained. - +/* + * memory handling + * (c) Copyright Dave, 2004 + * (C) notaz, 2006-2010 + * + * This work is licensed under the terms of MAME license. + * See COPYING file in the top-level directory. + */ #include "pico_int.h" #include "memory.h" @@ -44,7 +44,7 @@ static void xmap_set(uptr *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); } } @@ -166,7 +166,7 @@ void log_io(unsigned int addr, int bits, int rw); #if defined(EMU_C68K) void cyclone_crashed(u32 pc, struct Cyclone *context) { - elprintf(EL_STATUS|EL_ANOMALY, "%c68k crash detected @ %06x\n", + elprintf(EL_STATUS|EL_ANOMALY, "%c68k crash detected @ %06x", context == &PicoCpuCM68k ? 'm' : 's', pc); context->membase = (u32)Pico.rom; context->pc = (u32)Pico.rom + Pico.romsize; @@ -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(); @@ -720,13 +726,13 @@ PICO_INTERNAL void PicoMemSetup(void) int i; // by default, point everything to first 64k of ROM for (i = 0; i < M68K_FETCHBANK1; i++) - PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.rom - (i<<(24-FAMEC_FETCHBITS)); + PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom - (i<<(24-FAMEC_FETCHBITS)); // now real ROM for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < Pico.romsize; i++) - PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.rom; + PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom; // .. and RAM for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++) - PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.ram - (i<<(24-FAMEC_FETCHBITS)); + PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.ram - (i<<(24-FAMEC_FETCHBITS)); } #endif #ifdef EMU_M68K @@ -1052,6 +1058,14 @@ 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 @@ -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