X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FMemory.c;h=847d1bd098afda1fc2cef9eb84f7457ca9db8481;hb=dca310c413517d278898b967cfe610574310acd8;hp=ecc34c2549cac42940d419be596e9a046d33977b;hpb=9dc09829192f73f5d0502c8b312a39863bca60d3;p=picodrive.git diff --git a/Pico/Memory.c b/Pico/Memory.c index ecc34c2..847d1bd 100644 --- a/Pico/Memory.c +++ b/Pico/Memory.c @@ -1,14 +1,12 @@ // This is part of Pico Library // (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006 notaz, All rights reserved. +// (c) Copyright 2006,2007 notaz, All rights reserved. // Free for non-commercial use. // For commercial use, separate licencing terms must be obtained. -//#define __debug_io - #include "PicoInt.h" #include "sound/ym2612.h" @@ -39,6 +37,8 @@ extern unsigned int ppop; #ifdef IO_STATS void log_io(unsigned int addr, int bits, int rw); +#elif defined(_MSC_VER) +#define log_io #else #define log_io(...) #endif @@ -205,10 +205,7 @@ static void SRAMWrite(u32 a, u32 d) } // for nonstandard reads -#ifndef _ASM_MEMORY_C -static -#endif -u32 OtherRead16End(u32 a, int realsize) +static u32 OtherRead16End(u32 a, int realsize) { u32 d=0; @@ -322,7 +319,6 @@ static void OtherWrite8End(u32 a,u32 d,int realsize) Pico.m.prot_bytes[(a>>2)&1] = (u8)d; } - #include "MemoryCmn.c" @@ -357,9 +353,7 @@ PICO_INTERNAL_ASM u32 PicoRead8(u32 a) if ((a&1)==0) d>>=8; end: -#ifdef __debug_io - dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc); -#endif + elprintf(EL_IO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc); #ifdef EMU_CORE_DEBUG if (a>=Pico.romsize) { lastread_a = a; @@ -394,9 +388,7 @@ PICO_INTERNAL_ASM u32 PicoRead16(u32 a) else d = OtherRead16(a, 16); end: -#ifdef __debug_io - dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc); -#endif + elprintf(EL_IO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc); #ifdef EMU_CORE_DEBUG if (a>=Pico.romsize) { lastread_a = a; @@ -429,9 +421,7 @@ PICO_INTERNAL_ASM u32 PicoRead32(u32 a) else d = (OtherRead16(a, 32)<<16)|OtherRead16(a+2, 32); end: -#ifdef __debug_io - dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc); -#endif + elprintf(EL_IO, "r32: %06x, %08x @%06x", a&0xffffff, d, SekPc); #ifdef EMU_CORE_DEBUG if (a>=Pico.romsize) { lastread_a = a; @@ -448,9 +438,7 @@ end: #if !defined(_ASM_MEMORY_C) || defined(_ASM_MEMORY_C_AMIPS) PICO_INTERNAL_ASM void PicoWrite8(u32 a,u8 d) { -#ifdef __debug_io - dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc); -#endif + elprintf(EL_IO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc); #ifdef EMU_CORE_DEBUG lastwrite_cyc_d[lwp_cyc++&15] = d; #endif @@ -465,9 +453,7 @@ PICO_INTERNAL_ASM void PicoWrite8(u32 a,u8 d) void PicoWrite16(u32 a,u16 d) { -#ifdef __debug_io - dprintf("w16: %06x, %04x", a&0xffffff, d); -#endif + elprintf(EL_IO, "w16: %06x, %04x", a&0xffffff, d); #ifdef EMU_CORE_DEBUG lastwrite_cyc_d[lwp_cyc++&15] = d; #endif @@ -482,9 +468,7 @@ void PicoWrite16(u32 a,u16 d) static void PicoWrite32(u32 a,u32 d) { -#ifdef __debug_io - dprintf("w32: %06x, %08x", a&0xffffff, d); -#endif + elprintf(EL_IO, "w32: %06x, %08x", a&0xffffff, d); #ifdef EMU_CORE_DEBUG lastwrite_cyc_d[lwp_cyc++&15] = d; #endif @@ -513,6 +497,26 @@ static void PicoWrite32(u32 a,u32 d) // ----------------------------------------------------------------- + +// TODO: asm code +static void OtherWrite16End(u32 a,u32 d,int realsize) +{ + PicoWrite8Hook(a, d>>8, realsize); + PicoWrite8Hook(a+1,d&0xff, realsize); +} + +u32 (*PicoRead16Hook) (u32 a, int realsize) = OtherRead16End; +void (*PicoWrite8Hook) (u32 a, u32 d, int realsize) = OtherWrite8End; +void (*PicoWrite16Hook)(u32 a, u32 d, int realsize) = OtherWrite16End; + +PICO_INTERNAL void PicoMemResetHooks(void) +{ + // default unmapped/cart specific handlers + PicoRead16Hook = OtherRead16End; + PicoWrite8Hook = OtherWrite8End; + PicoWrite16Hook = OtherWrite16End; +} + PICO_INTERNAL void PicoMemSetup(void) { // Setup memory callbacks: @@ -607,9 +611,7 @@ unsigned int m68k_read_memory_8(unsigned int a) if (a