main.CPUClock=2MHz
main.Caption="Специалист-МХ2"

CPU : K580wm80a {
  debug=cas
  mem=mm
  port.maptomem=1
}

bios : Memory {
  rom="Specialist\specsvga.bin"
}

mem1 : Memory {
  size=10000
}

ramdisk : Memory {
  size=80000
  frame[0].size=10000
}

sys : K580ww55 {
  portA=kbd.row
  portB[1]=kbd.shift
  portB[2-7]=kbd.col
  portC[0-3]=kbd.row2
  portC[4-7]=vid.pindex
}

fdisk : Memory {
  rom="Specialist\001.rom"
  romselect="Change Flash-Disk ROM"
  romfiles="ROM files (*.rom)|*.rom"
}

mab : Register {
  write=fdisk.msb
}

app : K580ww55 {
  portA=fdisk.data
  portB=fdisk.lsb
  portB=mab.d
  portC[0-4]=fdisk.hsb
  portC[5]=mab.c
}

tim : K580wi53 {
  clock[0].rate=1/1
  clock[1].rate=1/1
  clock[2]=tim.out[1]
  ~gate[0]=tim.out[2]
  gate[1].value=1
  gate[2].value=1
}

dsk : KR1818wg93 {
  ext="odi"
}

mmport : MemMap2 {
  map[00-03]=sys.data
  map[04-07]=app.data
  map[08-0B]=dsk.data
  map[0C-0F]=tim.data
  map[12]=dsk.side
  map[13]=dsk.drive
  map[14]=sdcard.data8
  map[15]=40
  map[16]=sdcard.data8
  map[17]=40
  map[18-1B]=vidcolor
  map[1C-1F]=mode
}

mm2 : MemMap2 {
  map[00-1F]=mmport
  map[20-3F]=mmport
  map[40-7F]=mm2
  map[80-FF]=mm2
}

mmport1 : MemMap2 {
  map[00-DF]=mem1[FF00]
  map[E0-FF]=mmport
}

mmport2 : MemMap2 {
  map[00-BF]=ramdisk.frame[0][FF00]
  map[C0-DF]=mem1[FFC0]
  map[E0-FF]=mmport
}

mode : Decoder {
  adrxlat="10"
  addr.wo=mm.page[0-1]
  data.wo=ramdisk.frame[0].page
  mem.wo=vidmode
}

mm : MemMap {
  map[0][0000-8FFF]=mem1[0000]
  map[0][9000-BFFF]=vid.mem
  map[0][C000-FEFF]=mem1[C000]
  map[0][FF00-FFFF]=mmport1
  map[1][0000-FEFF]=ramdisk.frame[0]
  map[1][FF00-FFFF]=mmport2
  map[2][0000-7FFF]=bios[8000]
  map[2][8000-8FFF]=mem1[8000]
  map[2][9000-BFFF]=vid.mem
  map[2][C000-FEFF]=mem1[C000]
  map[2][FF00-FFFF]=mmport1
  map[3][0000-7FFF]=bios[0000]
  map[3][8000-8FFF]=mem1[8000]
  map[3][9000-BFFF]=vid.mem
  map[3][C000-EFFF]=mem1[C000]
  map[3][F000-F7FF]=mm2
  map[3][F800-FFFF]=sys.data
  map[4][0000-8FFF]=mem1[0000]
  map[4][9000-BFFF]=vid.mem
  map[4][C000-FEFF]=mem1[C000]
  map[4][FF00-FFFF]=mmport1
  map[5][0000-FEFF]=ramdisk.frame[0]
  map[5][FF00-FFFF]=mmport2
  map[6][0000-7FFF]=bios[8000]
  map[6][8000-8FFF]=mem1[8000]
  map[6][9000-BFFF]=vid.mem
  map[6][C000-FEFF]=mem1[C000]
  map[6][FF00-FFFF]=mmport1
  map[7][0000-8FFF]=mem1[0000]
  map[7][9000-BFFF]=vid.mem
  map[7][C000-EFFF]=mem1[C000]
  map[7][F000-F7FF]=mm2
  map[7][F800-FFFF]=sys.data
  initpage=3
}

kbd : Specialist-Keyboard {
  layout="Specialist\layoutmx.kbd"
}

vidcolor : Register {
  write=vid.color
  write[0]=mm.page[2]
  write[1]=vid.pselect
}

vidmode : MemMap2 {
  map[0]=wtf
  map[1]=wtf
  map[2-3]=wtf
}

wtf : Decoder {
  addr=vid.penable
}

vid : Specialist-Video {
  palette="70707070404040402020202010101010 70607060504050403020302010001000"
}

beep : beep {
  input=sys.portC[5]
  input[0]=tim.out[0]
}

sdcard : sd-mmc {
  image="Specialist\sd.img"
}

cas : tape-recorder {
  biproc[C377-C3C8]=rk
  biproc[C377-C3C8].check="C5D50E00573A01FF"
  boproc[C3D0-C3F4]=sp
  boproc[C3D0-C3F4].check="C5D5F5570E087A07"
}
