main.CPUClock=5MHz
main.Caption="Poisk"

cpu : i8086 {
  mem=mm
  port=pm
  int=intctl20.int
  nmi=vid.trap.nmi
}

mem1 : Memory {
  size=A0000
}

bios : Memory {
  rom="Poisk\poisk.rom"
}

fddbios : Memory {
  rom="Poisk\b_ngmd_n.rf2"
}

hddbios : Memory {
  rom="Poisk\ide_xt.bin"
}

mm : MemMap {
  map[0][0000-FFFF]=mem1[00000]
  map[1][0000-FFFF]=mem1[10000]
  map[2][0000-FFFF]=mem1[20000]
  map[3][0000-FFFF]=mem1[30000]
  map[4][0000-FFFF]=mem1[40000]
  map[5][0000-FFFF]=mem1[50000]
  map[6][0000-FFFF]=mem1[60000]
  map[7][0000-FFFF]=mem1[70000]
  map[8][0000-FFFF]=mem1[80000]
  map[9][0000-FFFF]=mem1[90000]
  map[A][0000-FFFF]=dummy
  map[B][0000-7FFF]=dummy
  map[B][8000-FFFF]=vid.mem
  map[C][0000-FFFF]=dummy
  map[D][0000-07FF]=hdd.data8[0]
  map[D][0800-0BFF]=hdd.data8
  map[D][0C00-0FFF]=hddcfg
  map[D][1000-FFFF]=dummy
  map[E][0000-FFFF]=dummy
  map[F][0000-CFFF]=dummy
  map[F][D000-D7FF]=fddbios
  map[F][D800-DFFF]=hddbios
  map[F][E000-FFFF]=bios
  map[10][000-FFFF]=mem1[00000]
}

intctl20 : K580wn59 {
  irq[0]=tim40.out[0]
  irq[6]=tim40.out[1]
  irq[5]=hdd.irq
}

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

ppi60 : K580ww55 {
  portA=vid.mode
  portC[0]=vid.rtc
  portC[3]=vid.vrtc
}

ppi68 : K580ww55 {
  portA=kbd.mask
  portA=kbd.mask2
  portB=kbd.~data
  portC[0-3]=kbd.~data2
  portC[6-7]=vid.color
}

p00 : MemMap2 {
  map[20-21]=intctl20.data
  map[28-2A]=vid.trap
  map[40-43]=tim40.data
  map[60]=ppi68.data[0]
  map[61]=ppi60.data[1]
  map[62]=ppi60.data[2]
  map[63]=ppi60.data[3]
  map[68]=ppi60.data[0]
  map[69]=ppi68.data[1]
  map[6A]=ppi68.data[2]
  map[6B]=ppi68.data[3]
  map[C0-C3]=fdd.data
  map[C4]=fddsel
  map[C6]=motor
}

p03 : MemMap2 {
  map[D4-D5]=vid.trap.io[3D4]
  map[D8-D9]=vid.trap.io[3D8]
  map[DA].ro=ppi60.data[2]
}

pm : MemMap {
  map[0][0000-00FF]=p00
  map[0][0100-02FF]=dummy
  map[0][0300-03FF]=p03
  map[0][0100-FFFF]=dummy
}

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

vid : poisk-cga {
}

fdd : KR1818wg93 {
  ext="img;*.imd"
  image[0].geometry=80C2H9S512
  image[1].geometry=80C2H9S512
}

fddsel : Register {
  read[0]=fdd.drq
  read[7]=fdd.irq
  write[0]=fdd.drive[0]
  write[1]=fdd.drive[1]
  write[4]=fdd.side
  write[6]=fdd.reset
}

hdd : cf-ide {
  drive[0].image="Poisk\real_POISK_1024_17.12.2022_CF.img"
  drive[0].geometry=615C4H17S
}

hddcfg : Register {
  read[0-3]=0F
  read[7]=hdd.drq
}
