main.CPUClock=2MHz
main.Caption="Башкирия-2М"

CPU : K580wm80a {
  mem=mm
  port[00-03]=tim.data
  port[04-07]=ext.data
  port[08-0B]=sys.data
  port[0C]=comport.netid
  port[10-13]=vid.palette
  port[14-15]=intctl.data
  port[18-19]=comport.data
  port[1C-1F]=dsk.data
  portmask=1F
  int=intctl.int
}

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

sys : K580ww55 {
  portA=prn.~data
  portB=vid.scroll
  portC[0-2]=mm.page
  portC[4]=prn.strobe
  portC[E]=cas.record
  portC[7]=vid.page
}

ext : K580ww55 {
  portC[1]=dsk.side[0]
  portC[2]=dsk.drive[1].on
  portC[3]=dsk.drive[0].on
}

comport : K580ww51 {
  connect="tcp:15015"
}

intctl : K580wn59 {
  irq[0]=vid.irq
  irq[1]=tim.out[0]
  irq[2]=prn.~busy
  irq[3]=comport.irq
  irq[4]=cas.playback
}

dsk : KR1818wg93 {
  image[0].file="B2M\disk2.cpm"
  image[1].file="B2M\disk1.cpm"
  drive[0].tooltip="A:/B:"
  drive[1].tooltip="C:/D:"
  vdpb="2800040F01C2007F00C00020000200"
  vdgm="80C5S"
}

mem1 : Memory {
  size=10000
}

mem2 : Memory {
  size=10000
}

bios : Memory {
  rom="B2M\bios1.rom"
}

mm : MemMap {
  map[0][0000-DFFF]=mem1[0000]
  map[0][E000-FFFF]=bios[0000]

  map[1][0000-DFFF]=mem1[0000]
  map[1][E000-FFFF]=bios[0000]

  map[2][0000-27FF]=mem1[0000]
  map[2][2800-2FFF]=kbd.mem
  map[2][3000-6FFF]=mem2[0000]
  map[2][7000-DFFF]=mem1[7000]
  map[2][E000-FFFF]=bios[0000]

  map[3][0000-27FF]=mem1[0000]
  map[3][2800-2FFF]=kbd.mem
  map[3][3000-6FFF]=mem2[4000]
  map[3][7000-DFFF]=mem1[7000]
  map[3][E000-FFFF]=bios[0000]

  map[4][0000-27FF]=mem1[0000]
  map[4][2800-2FFF]=kbd.mem
  map[4][3000-6FFF]=mem2[8000]
  map[4][7000-DFFF]=mem1[7000]
  map[4][E000-FFFF]=bios[0000]

  map[5][0000-27FF]=mem1[0000]
  map[5][2800-2FFF]=kbd.mem
  map[5][3000-6FFF]=mem2[C000]
  map[5][7000-DFFF]=mem1[7000]
  map[5][E000-FFFF]=bios[0000]

  map[6][0000-FFFF]=mem1[0000]

  map[7][0000-1FFF]=bios[0000]
  map[7][2000-3FFF]=bios[0000]
  map[7][4000-5FFF]=bios[0000]
  map[7][6000-7FFF]=bios[0000]
  map[7][8000-9FFF]=bios[0000]
  map[7][A000-BFFF]=bios[0000]
  map[7][C000-DFFF]=bios[0000]
  map[7][E000-FFFF]=bios[0000]

  initpage="7"
}

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

vid : B2M-video {
  plane[0][0]=mem2[1000]
  plane[0][1]=mem2[5000]
  plane[1][0]=mem2[9000]
  plane[1][1]=mem2[D000]
}

beep : beep {
  input=tim.out[1]
}

cas : tape-recorder {
}

prn : printer {
}
