X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FMemoryCmn.c;h=ee75abcabc143b498760a4a3144612e261c1bf90;hb=29a951879b9e2d2f93f9aa3a34c2872e6cbf4e39;hp=43433af4887229c9e7e808ccc817e58b5334a8e3;hpb=66fdc0f0d590809fb0040d08fd57607bf80b1abc;p=picodrive.git diff --git a/Pico/MemoryCmn.c b/Pico/MemoryCmn.c index 43433af..ee75abc 100644 --- a/Pico/MemoryCmn.c +++ b/Pico/MemoryCmn.c @@ -1,4 +1,5 @@ -/* common code for Memory.c and cd/Memory.c */ +// common code for Memory.c and cd/Memory.c +// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas static int PadRead(int i) { @@ -98,14 +99,15 @@ u32 OtherRead16(u32 a, int realsize) // |=0x80 for Shadow of the Beast & Super Offroad; rotate fakes next fetched instruction for Time Killers if (a==0xa11100) { // z80 busreq d=Pico.m.z80Run&1; +#if 1 if (!d) { // needed by buggy Terminator (Sega CD) - extern int z80stopCycle; int stop_before = SekCyclesDone() - z80stopCycle; dprintf("stop before: %i", stop_before); if (stop_before > 0 && stop_before <= 32) // Gens uses 16 here d = 1; // bus not yet available } +#endif d=(d<<8)|0x8000|Pico.m.rotate++; dprintf("get_zrun: %04x [%i|%i] @%06x", d, Pico.m.scanline, SekCyclesDone(), SekPc); goto end; @@ -124,7 +126,10 @@ end: //extern UINT32 mz80GetRegisterValue(void *, UINT32); -static void OtherWrite8(u32 a,u32 d,int realsize) +#ifndef _ASM_CD_MEMORY_C +static +#endif +void OtherWrite8(u32 a,u32 d,int realsize) { if ((a&0xe700f9)==0xc00011||(a&0xff7ff9)==0xa07f11) { if(PicoOpt&2) SN76496Write(d); return; } // PSG Sound if ((a&0xff4000)==0xa00000) { if(!(Pico.m.z80Run&1)) Pico.zram[a&0x1fff]=(u8)d; return; } // Z80 ram @@ -146,16 +151,21 @@ static void OtherWrite8(u32 a,u32 d,int realsize) return; } if (a==0xa11100) { - extern int z80startCycle, z80stopCycle; //int lineCycles=(488-SekCyclesLeft)&0x1ff; d&=1; d^=1; if(!d) { // this is for a nasty situation where Z80 was enabled and disabled in the same 68k timeslice (Golden Axe III) if (Pico.m.z80Run) { - int lineCycles=(488-SekCyclesLeft)&0x1ff; + int lineCycles; z80stopCycle = SekCyclesDone(); - lineCycles=(lineCycles>>1)-(lineCycles>>5); - z80_run(lineCycles); + if (Pico.m.z80Run&2) + lineCycles=(488-SekCyclesLeft)&0x1ff; + else lineCycles=z80stopCycle-z80startCycle; // z80 was started at current line + if (lineCycles > 0 && lineCycles <= 488) { + dprintf("zrun: %i/%i cycles", lineCycles, (lineCycles>>1)-(lineCycles>>5)); + lineCycles=(lineCycles>>1)-(lineCycles>>5); + z80_run(lineCycles); + } } } else { z80startCycle = SekCyclesDone(); @@ -187,7 +197,10 @@ static void OtherWrite8(u32 a,u32 d,int realsize) } -static void OtherWrite16(u32 a,u32 d) +#ifndef _ASM_CD_MEMORY_C +static +#endif +void OtherWrite16(u32 a,u32 d) { if ((a&0xe700e0)==0xc00000) { PicoVideoWrite(a,(u16)d); return; } if ((a&0xff4000)==0xa00000) { if(!(Pico.m.z80Run&1)) Pico.zram[a&0x1fff]=(u8)(d>>8); return; } // Z80 ram (MSB only)