main.CPUClock=2MHz
main.Caption="Juku E5104"

CPU : K580wm80a {
  mem=mm
  port[00-03]=intctl.data
  port[04-07]=sys.data
  port[08-0B]=comport.data
  port[0C-0F]=app.data
  port[10-13]=tim1.data
  port[14-17]=tim2.data
  port[18-1B]=tim3.data
  port[1C-1F]=dsk.data
  int=intctl.int
}

mem1 : Memory {
  size=10000
}

bios : Memory {
  rom="Juku\juku.rom"
}

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

intctl : K580wn59 {
  irq[5]=tim2.out[0]
}

sys : K580ww55 {
  portA[0-3]=kbd.mask
  portB[8]=kbd.iw1.p
  portB[9-B]=kbd.iw1.out
  portB[E]=kbd.shift
  portB[F]=kbd.ctrl
  portC[0-1]=mm.page
  portC[6]=dsk.side
}

comport : K580ww51 {
}

app : K580ww55 {
}

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

tim2 : K580wi53 {
  clock[0]=tim1.out[0]
  clock[1]=tim1.out[2]
  clock[2]=tim1.out[2]
  gate[0].value=1
  gate[1]=tim2.out[0]
  gate[2]=tim2.out[0]
}

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

mm : MemMap {
  map[0][0000-3FFF].ro=bios[0000]
  map[0][0000-3FFF].wo=mem1[0000]
  map[0][4000-FFFF]=mem1[4000]
  map[1][0000-D7FF]=mem1[0000]
  map[1][D800-FFFF].ro=bios[1800]
  map[1][D800-FFFF].wo=mem1[D800]
  map[2][0000-3FFF]=mem1[0000]
  map[2][4000-BFFF]=basic
  map[2][C000-D7FF]=mem1[C000]
  map[2][D800-FFFF].ro=bios[1800]
  map[2][D800-FFFF].wo=mem1[D800]
  map[3][0000-FFFF]=mem1[0000]
}

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

vid : Juku-Video {
  mem=mem1[D800]
}

dsk : KR1818wg93 {
  image[0].file="Juku\disk.juk"
  image[0].geometry=80C2H10S512
}
