X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FMemory.c;h=1e6630da76ba0bb0f743723150418337c0414788;hb=b542be4686241c9e0722ff8e452980f9ac2b4d7c;hp=2b869246ac574511b103f6bc158e3b6264c24e26;hpb=03e4f2a349247334666c87abe3a908df72d23051;p=picodrive.git diff --git a/Pico/Memory.c b/Pico/Memory.c index 2b86924..1e6630d 100644 --- a/Pico/Memory.c +++ b/Pico/Memory.c @@ -7,7 +7,7 @@ // For commercial use, separate licencing terms must be obtained. -#define __debug_io +//#define __debug_io #include "PicoInt.h" @@ -28,7 +28,6 @@ u32 PicoRead8(u32 a); u32 PicoRead16(u32 a); void PicoWrite8(u32 a,u8 d); void PicoWriteRomHW_SSF2(u32 a,u32 d); -void PicoWriteRomHW_in1 (u32 a,u32 d); #endif @@ -324,7 +323,7 @@ PICO_INTERNAL_ASM u32 PicoRead8(u32 a) #ifndef EMU_CORE_DEBUG // sram - if(a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) { + if (a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) { d = SRAMRead(a); elprintf(EL_SRAMIO, "sram r8 [%06x] %02x @ %06x", a, d, SekPc); goto end; @@ -335,14 +334,17 @@ PICO_INTERNAL_ASM u32 PicoRead8(u32 a) log_io(a, 8, 0); if ((a&0xff4000)==0xa00000) { d=z80Read8(a); goto end; } // Z80 Ram - d=OtherRead16(a&~1, 8); if ((a&1)==0) d>>=8; + if ((a&0xe700e0)==0xc00000) // VDP + d=PicoVideoRead(a); + else d=OtherRead16(a&~1, 8); + if ((a&1)==0) d>>=8; + -end: #ifdef __debug_io dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc); #endif #ifdef EMU_CORE_DEBUG - if(a>=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) { + if (a>=Pico.romsize) { lastread_a = a; lastread_d[lrp_cyc++&15] = (u8)d; } @@ -360,7 +362,7 @@ PICO_INTERNAL_ASM u32 PicoRead16(u32 a) #ifndef EMU_CORE_DEBUG // sram - if(a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) { + if (a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) { d = SRAMRead(a); d |= d<<8; elprintf(EL_SRAMIO, "sram r16 [%06x] %04x @ %06x", a, d, SekPc); @@ -371,14 +373,16 @@ PICO_INTERNAL_ASM u32 PicoRead16(u32 a) if (a=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) { + if (a>=Pico.romsize) { lastread_a = a; lastread_d[lrp_cyc++&15] = d; } @@ -405,14 +409,16 @@ PICO_INTERNAL_ASM u32 PicoRead32(u32 a) if (a=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) { + if (a>=Pico.romsize) { lastread_a = a; lastread_d[lrp_cyc++&15] = d; } @@ -424,7 +430,7 @@ end: // ----------------------------------------------------------------- // Write Ram -#ifndef _ASM_MEMORY_C +#if !defined(_ASM_MEMORY_C) || defined(_ASM_MEMORY_C_AMIPS) PICO_INTERNAL_ASM void PicoWrite8(u32 a,u8 d) { #ifdef __debug_io @@ -455,6 +461,7 @@ void PicoWrite16(u32 a,u16 d) log_io(a, 16, 1); a&=0xfffffe; + if ((a&0xe700e0)==0xc00000) { PicoVideoWrite(a,(u16)d); return; } // VDP OtherWrite16(a,d); } @@ -477,6 +484,14 @@ static void PicoWrite32(u32 a,u32 d) log_io(a, 32, 1); a&=0xfffffe; + if ((a&0xe700e0)==0xc00000) + { + // VDP: + PicoVideoWrite(a, (u16)(d>>16)); + PicoVideoWrite(a+2,(u16)d); + return; + } + OtherWrite16(a, (u16)(d>>16)); OtherWrite16(a+2,(u16)d); } @@ -526,33 +541,36 @@ unsigned int m68k_read_pcrelative_CD16(unsigned int a); unsigned int m68k_read_pcrelative_CD32(unsigned int a); // these are allowed to access RAM -static unsigned int m68k_read_8 (unsigned int a, int do_fake) { +static unsigned int m68k_read_8 (unsigned int a, int do_fake) +{ a&=0xffffff; - if(PicoMCD&1) return m68k_read_pcrelative_CD8(a); - if(a>13)==2) // 0x4000-0x5fff (Charles MacDonald) { if (PicoOpt&1) ret = (u8) YM2612Read(); @@ -675,10 +693,8 @@ PICO_INTERNAL unsigned char z80_read(unsigned short a) return ret; } -#ifdef _USE_DRZ80 - // should not be needed || dprintf("z80_read RAM"); + // should not be needed, cores should be able to access RAM themselves if (a<0x4000) return Pico.zram[a&0x1fff]; -#endif elprintf(EL_ANOMALY, "z80 invalid r8 [%06x] %02x", a, ret); return ret; @@ -690,10 +706,6 @@ PICO_INTERNAL_ASM void z80_write(unsigned char data, unsigned short a) PICO_INTERNAL_ASM void z80_write(unsigned int a, unsigned char data) #endif { -#ifndef _USE_DRZ80 - if (a<0x4000) { Pico.zram[a&0x1fff]=data; return; } -#endif - if ((a>>13)==2) // 0x4000-0x5fff (Charles MacDonald) { if(PicoOpt&1) emustatus|=YM2612Write(a, data) & 1; @@ -724,10 +736,8 @@ PICO_INTERNAL_ASM void z80_write(unsigned int a, unsigned char data) return; } -#ifdef _USE_DRZ80 - // should not be needed, drZ80 knows how to access RAM itself || dprintf("z80_write RAM @ %08x", lr); + // should not be needed if (a<0x4000) { Pico.zram[a&0x1fff]=data; return; } -#endif elprintf(EL_ANOMALY, "z80 invalid w8 [%06x] %02x", a, data); }