main.CPUClock=2MHz
main.Caption="Партнер-01.01"

CPU : K580wm80a {
  debug=cas
  mem=mm
  rst[6]=crt.irq
  port.maptomem=1
}

mem1 : Memory {
  size=8000
}

mem2 : Memory {
  size=8000
}

font : Memory {
  rom="symgen.bin"
}

bios : Memory {
  rom="partner\bios.rom"
}

basic : Memory {
  rom="partner\basic.rom"
}

fddbios : Memory {
  rom="partner\fdd.rom"
}

fdd : KR1818wg93 {
  image[0].file="Partner\disk2.cpm"
  drive[0].tooltip="A:"
  drive[1].tooltip="B:"
  dma=dma[0]
  vdpb="2800040F01C2007F00C00020000200"
  vdgm="80C5S"
}

fddsel : K580ww55 {
  portA[3]=fdd.drive[1]
  portA[6]=fdd.drive[0]
  portA[7]=fdd.side
}

sys : K580ww55 {
  portA=kbd.~mask
  portB=kbd.~data
  portC[4-6]=kbd.~data2
}

sys2 : K580ww55 {
  portA[4-7]=mm.page
}

fontmap : MemMap {
  map[0][0-3FF]=font[0000]
  map[2][0-3FF]=font[0400]
  map[4][0-3FF]=font[0800]
  map[6][0-3FF]=font[0C00]
  map[1][0-3FF]=font[1000]
  map[3][0-3FF]=font[1400]
  map[5][0-3FF]=font[1800]
  map[7][0-3FF]=font[1C00]
  page=crt.ggh
}

crt : K580wg75 {
  mode=0
  dma=dma[2]
  font=fontmap
  mcpg=mcpgfont[0000]
}

dma : K580wt57 {
  mem=mm
}

mcpgbios : Memory {
  rom="partner\mcpg.rom"
}

mcpgfont : Memory {
  size=1000
}

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

win1 : MemMap {
  ~pagemask=wpage.portA
  map[0][0000-1FFF]=bios[0000]
  map[1][0000-1FFF]=bios[0000]
  map[2][0000-1FFF]=fddbios[0000]
  map[3][0000-1FFF]=mcpgbios[0000]
}

win2 : MemMap {
  ~pagemask=wpage.portA
  map[0][0000]=bios[0000]
  map[1][0000]=bios[0000]
  map[2][0000]=bios[0000]
  map[3][0000-1FFF]=mcpgfont[0000]
}

mtm : MemMap2 {
  map[0-3]=mtim.data
  adrshift=2
}

iomap : MemMap {
  ~pagemask=wpage.portA
  map[0][0000]=bios[0000]
  map[1][0000]=bios[0000]
  map[2][0000-00FF]=fdd.data
  map[2][0100-01FF]=fddsel.data
  map[3][0100-01FF]=mtm
}

wpage : K580ww55 {
}

mm : MemMap {
  map[0][0000-07FF]=bios[0000]
  map[0][0800-7FFF]=mem1[0800]
  map[0][8000-D7FF]=mem2[0000]
  map[0][D800-D8FF]=crt.data
  map[0][D900-D9FF]=sys.data
  map[0][DA00-DAFF]=sys2.data
  map[0][DB00-DBFF]=dma.data
  map[0][DC00-DDFF]=iomap
  map[0][DE00-DEFF]=wpage.data[0]
  map[0][E000-E7FF]=win1
  map[0][E800-FFFF]=bios[0800]

  map[1][0000-7FFF]=mem1[0000]
  map[1][8000-D7FF]=mem2[0000]
  map[1][D800-D8FF]=crt.data
  map[1][D900-D9FF]=sys.data
  map[1][DA00-DAFF]=sys2.data
  map[1][DB00-DBFF]=dma.data
  map[1][DC00-DDFF]=iomap
  map[1][DE00-DEFF]=wpage.data[0]
  map[1][E000-FFFF]=bios[0000]

  map[2][0000-7FFF]=mem1[0000]
  map[2][8000-D7FF]=mem2[0000]
  map[2][D800-D8FF]=crt.data
  map[2][D900-D9FF]=sys.data
  map[2][DA00-DAFF]=sys2.data
  map[2][DB00-DBFF]=dma.data
  map[2][DC00-DDFF]=iomap
  map[2][DE00-DEFF]=wpage.data[0]
  map[2][E000-E7FF]=win1
  map[2][E800-FFFF]=bios[0800]

  map[3][0000-7FFF]=mem1[0000]
  map[3][8000-D7FF]=mem2[0000]
  map[3][D800-D8FF]=crt.data
  map[3][D900-D9FF]=sys.data
  map[3][DA00-DAFF]=sys2.data
  map[3][DB00-DBFF]=dma.data
  map[3][DC00-DDFF]=iomap
  map[3][DE00-DEFF]=wpage.data[0]
  map[3][E000-FFFF]=win1

  map[4][0000-7FFF]=mem1[0000]
  map[4][8000-97FF]=mem2[0000]
  map[4][C000-D7FF]=mem2[4000]
  map[4][D800-D8FF]=crt.data
  map[4][D900-D9FF]=sys.data
  map[4][DA00-DAFF]=sys2.data
  map[4][DB00-DBFF]=dma.data
  map[4][DC00-DDFF]=iomap
  map[4][DE00-DEFF]=wpage.data[0]
  map[4][E000-FFFF]=win1

  map[5][0000-7FFF]=mem1[0000]
  map[5][C000-D7FF]=mem2[4000]
  map[5][D800-D8FF]=crt.data
  map[5][D900-D9FF]=sys.data
  map[5][DA00-DAFF]=sys2.data
  map[5][DB00-DBFF]=dma.data
  map[5][DC00-DDFF]=iomap
  map[5][DE00-DEFF]=wpage.data[0]
  map[5][E000-FFFF]=win1

  map[6][0000-7FFF]=mem1[0000]
  map[6][8000-9FFF]=mem2[0000]
  map[6][A000-BFFF]=basic[0000]
  map[6][C000-D7FF]=mem2[4000]
  map[6][D800-D8FF]=crt.data
  map[6][D900-D9FF]=sys.data
  map[6][DA00-DAFF]=sys2.data
  map[6][DB00-DBFF]=dma.data
  map[6][DC00-DDFF]=iomap
  map[6][DE00-DEFF]=wpage.data[0]
  map[6][E000-E7FF]=win1
  map[6][E800-FFFF]=bios[0800]

  map[7][0000-7FFF]=mem2[0000]
  map[7][8000-D7FF]=mem1[0000]
  map[7][D800-D8FF]=crt.data
  map[7][D900-D9FF]=sys.data
  map[7][DA00-DAFF]=sys2.data
  map[7][DB00-DBFF]=dma.data
  map[7][DC00-DDFF]=iomap
  map[7][DE00-DEFF]=wpage.data[0]
  map[7][E000-E7FF]=win1
  map[7][E800-FFFF]=bios[0800]

  map[8][0000-7FFF]=mem1[0000]
  map[8][8000-9FFF]=win1
  map[8][A000-BFFF]=basic[0000]
  map[8][C000-C7FF]=bios[0000]
  map[8][C800-D7FF]=win2
  map[8][D800-D8FF]=crt.data
  map[8][D900-D9FF]=sys.data
  map[8][DA00-DAFF]=sys2.data
  map[8][DB00-DBFF]=dma.data
  map[8][DC00-DDFF]=iomap
  map[8][DE00-DEFF]=wpage.data[0]
  map[8][E000-E7FF]=win1
  map[8][E800-FFFF]=bios[0800]

  map[9][0000-7FFF]=mem1[0000]
  map[9][8000-9FFF]=win1
  map[9][A000-C7FF]=mem2[2000]
  map[9][C800-D7FF]=win2
  map[9][D800-D8FF]=crt.data
  map[9][D900-D9FF]=sys.data
  map[9][DA00-DAFF]=sys2.data
  map[9][DB00-DBFF]=dma.data
  map[9][DC00-DDFF]=iomap
  map[9][DE00-DEFF]=wpage.data[0]
  map[9][E000-E7FF]=win1
  map[9][E800-FFFF]=bios[0800]

  map[A][0000-7FFF]=mem1[2000]
  map[A][8000-BFFF]=win2
  map[A][C000-CFFF]=bios[0000]
  map[A][D000-D7FF]=mem2[3000]
  map[A][D800-D8FF]=crt.data
  map[A][D900-D9FF]=sys.data
  map[A][DA00-DAFF]=sys2.data
  map[A][DB00-DBFF]=dma.data
  map[A][DC00-DDFF]=iomap
  map[A][DE00-DEFF]=wpage.data[0]
  map[A][E000-E7FF]=win1
  map[A][E800-FFFF]=bios[0800]
}

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

beep : beep {
  input=sys.portC[0]
  wave=sys.portC[9]
  freq=1/500
  input[0]=mtim.out[0]
  input[1]=mtim.out[1]
  input[2]=mtim.out[2]
}

cas : tape-recorder {
  iproc[FF24-FF6F]=rk
  oproc[FC1B-FF6F]=rk
  record=sys.portC[0]
  playback=sys.portC[7]
}
