public void WriteWord(int address, short value) { address &= 0x00FFFFFF; if (address >= 0xE00000) // Work RAM { //Console.WriteLine("MEM[{0:X4}] change to {1:X4}", address & 0xFFFF, value); Ram[(address & 0xFFFF) + 0] = (byte)(value >> 8); Ram[(address & 0xFFFF) + 1] = (byte)value; return; } if (address >= 0xC00000) { switch (address & 0x1F) { case 0x00: case 0x02: VDP.WriteVdpData((ushort)value); return; case 0x04: case 0x06: VDP.WriteVdpControl((ushort)value); return; } } if (address == 0xA11100) // Z80 BUSREQ { M68000HasZ80Bus = (value & 0x100) != 0; //Console.WriteLine("68000 has the z80 bus: " + M68000HasZ80Bus); return; } if (address == 0xA11200) // Z80 RESET { Z80Reset = (value & 0x100) == 0; if (Z80Reset) { SoundCPU.SoftReset(); } //Console.WriteLine("z80 reset: " + Z80Reset); return; } Console.WriteLine("UNHANDLED WRITEW {0:X6}:{1:X4}", address, value); }
public void WriteByte(int address, sbyte value) { address &= 0x00FFFFFF; if (address >= 0xE00000) // Work RAM { //Console.WriteLine("MEM[{0:X4}] change from {1:X2} to {2:X2}", address & 0xFFFF, Ram[address & 0xFFFF], value); Ram[address & 0xFFFF] = (byte)value; return; } if ((address & 0xFF0000) == 0xA00000) { WriteMemoryZ80((ushort)(address & 0x7FFF), (byte)value); return; } if (address >= 0xA10000 && address <= 0xA1001F) { WriteIO(address, value); return; } if (address == 0xA11100) { M68000HasZ80Bus = (value & 1) != 0; //Console.WriteLine("68000 has the z80 bus: " + M68000HasZ80Bus); return; } if (address == 0xA11200) // Z80 RESET { Z80Reset = (value & 1) == 0; if (Z80Reset) { SoundCPU.SoftReset(); } //Console.WriteLine("z80 reset: " + Z80Reset); return; } if (address >= 0xC00000 && address < 0xC00010) { // when writing to VDP in byte mode, the LSB is duplicated into the MSB VDP.WriteVdp(address & 0x1E, (ushort)((ushort)value | ((ushort)value << 8))); return; } if (address >= 0xC00011 && address <= 0xC00017 && (address & 1) != 0) { PSG.WritePsgData((byte)value, SoundCPU.TotalExecutedCycles); return; } if (SaveRamEnabled && address >= SaveRamStartOffset && address < SaveRamEndOffset) { if (SaveRamEveryOtherByte) { SaveRAM[(address - SaveRamStartOffset) >> 1] = (byte)value; } else { SaveRAM[address - SaveRamStartOffset] = (byte)value; } SaveRamModified = true; return; } if (EepromEnabled && (address == SclAddr || address == SdaInAddr)) { WriteByteEeprom(address, (byte)value); return; } Console.WriteLine("UNHANDLED WRITEB {0:X6}:{1:X2}", address, value); }