main.CPUClock=3500KHz
main.Caption="ZX Spectrum 128"
main.ff.speed=20
main.ff.keymask[9]=1

cpu : z80 {
  debug=cas
  mem=mm
  int[FF]=vid.irq
  port[FD]=portFD
  port[FE]=sys.data[0]
}

portFD : MemMap2 {
  offset=cpu.port.msb
  map[7E-7F]=sys.data[1]
  map[BE-BF].wo=AY.data
  map[FE-FF].ro=AY.data
  map[FE-FF].wo=AY.regno
}

bios : Memory {
  rom="ZX\ZXSpectrum128.rom"
  frame[0].size=4000
  frame[0].page=sys.portB[4]
}

mem1 : Memory {
  size=20000
  frame[0].size=4000
  frame[0].page=sys.portB[0-2]
}

mm : MemMap {
  map[0][0000-3FFF]=bios.frame[0]
  map[0][4000-7FFF]=mem1[14000]
  map[0][8000-BFFF]=mem1[08000]
  map[0][C000-FFFF]=mem1.frame[0]
}

sys : K580ww55 {
}

kbd : Keyboard {
  layout="ZX\layout.kbd"
  ~mask=cpu.port.msb
  ~data=sys.portA
  irqkey=49
  irq=cpu.nmi
}

vid : zxspec-video {
  mem[0]=mem1[14000]
  mem[1]=mem1[1C000]
  border=sys.portA[0-2]
  page=sys.portB[3]
}

cas : tape-recorder {
  playback=sys.portA[6]
  record=sys.portA[3]
  filter="ZX Spectrum files (*.tzx;*.tap)|*.tzx;*.tap"
  ext="tzx"
  iproc[0562-05E0]=zx
  oproc[04C2-053E]=zx
}

AY : AY-3-8910 {
  freq=1773400
  input=sys.portA[4]
}
