main.CPUClock=2222222
main.Caption="Искра-1080 Тарту"
main.ff.speed=20
main.ff.keymask[A]=1

CPU : K580wm80a {
  debug=codesel
  debug=cas
  mem=mm
  haltmode=1
  port[80-87]=comport.data
  port[90-97]=vid.palette
  port[98]=port98
  port[99]=port99
  port[9A]=port98
  port[9B]=port99
  port[9C]=port98
  port[9D]=port99
  port[9E]=port98
  port[9F]=port99
  port[A8-AF]=portA8
  port[B0-B7]=cas.touchflip
  port[B0-B7]=beep.touchflip
  port[B8-BF]=cfg.clrbit
  port[C0-C7]=kbdreg
  port[F8-FF]=cfg.setbit
}

mem1 : Memory {
  size=10000
}

bios : Memory {
  rom="Iskra1080\i1080.rom"
  frame[0].size=4000
}

comport : K580ww51 {
}

port98 : Register {
}

port99 : Register {
  read[0]=cas.playback
}

beep : beep {
}

portA8 : Register {
  write[7]=mm00xx.page
}

cfg : Register {
  write[2]=bios.frame[0].page
}

kbdreg : Register {
  write[0-3]=kbd.mask
  read=kbd.idata
}

kbd : Keyboard {
  layout="Iskra1080\layout.kbd"
}

mm00xx : MemMap {
  map[0][0000-FFFF].ro=bios[0000]
  map[0][0000-FFFF].wo=mem1[0000]
  map[1][0000-FFFF]=mem1[0000]
}

mm : MemMap {
  cpustate=CPU.state
  map[0][0000-00FF]=mm00xx
  map[0][0100-FFFF]=mem1[0100]
  map[1][0000-00FF]=mm00xx
  map[1][0100-FFFF]=mem1[0100]
  map[2][0000-00FF]=mm00xx
  map[2][0100-BFFF]=mem1[0100]
  map[2][C000-CFFF].ro=bios.frame[0]
  map[2][C000-CFFF].wo=mem1[C000]
  map[2][D000-FFFF]=mem1[D000]
  map[3][0000-00FF]=mm00xx
  map[3][0100-FFFF]=mem1[0100]
  map[4][0000-00FF]=mm00xx
  map[4][0100-BFFF]=mem1[0100]
  map[4][C000-C7FF].ro=bios.frame[0]
  map[4][C000-C7FF].wo=mem1[C000]
  map[4][C800-CFFF]=mem1[C800]
  map[4][D000-FFFF].ro=bios[1000]
  map[4][D000-FFFF].wo=mem1[D000]
  map[5][0000-00FF]=mm00xx
  map[5][0100-FFFF]=mem1[0100]
}

codesel : exec-sensor {
  range[0000-C7FF]=0
  range[C800-CFFF]=1
  range[D000-FFFF]=2
  output=mm.page[1-2]
}

vid : Iskra1080-video {
  plane[0][0]=mem1[9000]
  plane[0][1]=mem1[D000]
}

cas : tape-recorder {
  filehdr="LVOV/2.0/$"
  tapehdr="$$$$$$$$$$"
  filter="Lvov/Iskra1080 files (*.lvt;*.l??)|*.lvt;*.l??"
  ext="lvt"
  tproc[FEF1-FF42]=sp
  biproc[FF43-FF41]=sp
}
