- if ((a&0xff4000)==0xa00000) { if(!(Pico.m.z80Run&1)) Pico.zram[a&0x1fff]=(u8)d; return; } // Z80 ram
- if ((a&0xff6000)==0xa04000) { if(PicoOpt&1) emustatus|=YM2612Write(a&3, d); return; } // FM Sound
- if ((a&0xffffe0)==0xa10000) { // I/O ports
- a=(a>>1)&0xf;
- // 6 button gamepad: if TH went from 0 to 1, gamepad changes state
- if(PicoOpt&0x20) {
- if(a==1) {
- Pico.m.padDelay[0] = 0;
- if(!(Pico.ioports[1]&0x40) && (d&0x40)) Pico.m.padTHPhase[0]++;
- }
- else if(a==2) {
- Pico.m.padDelay[1] = 0;
- if(!(Pico.ioports[2]&0x40) && (d&0x40)) Pico.m.padTHPhase[1]++;
- }
- }
- Pico.ioports[a]=(u8)d; // IO ports can be used as RAM
- return;
- }
- if (a==0xa11100) {
- //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;
- z80stopCycle = SekCyclesDone();
- 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();
- //if(Pico.m.scanline != -1)
- }
- dprintf("set_zrun: %02x [%i|%i] @%06x", d, Pico.m.scanline, SekCyclesDone(), /*mz80GetRegisterValue(NULL, 0),*/ SekPc);
- Pico.m.z80Run=(u8)d; return;
- }
- if (a==0xa11200) {
- dprintf("write z80Reset: %02x", d);
- if(!(d&1)) z80_reset();
+ if ((a&0xff4000)==0xa00000) { // z80 RAM
+ SekCyclesBurn(2); // hack
+ if (!(Pico.m.z80Run&1) && !Pico.m.z80_reset) Pico.zram[a&0x1fff]=(u8)d;
+ else elprintf(EL_ANOMALY, "68k z80 write with no bus or reset! [%06x] %02x @ %06x", a, d&0xff, SekPc);