main.CPUClock=2500KHz
main.CPUClock[0]=8700KHz
main.CPUClock[1]=2500KHz
main.Caption="Орион-Про"

CPU : Z80 {
  mem=mm
  port[00-03]=sys1.data
  port[04-07]=pagectl.data
  port[08-0B]=sys2.data
  port[10-13]=dsk.data
  port[14]=regs1.data[0]
  port[18-1B]=app1.data
  port[28-2B]=app2.data
  port[3E]=AY.data
  port[3F]=AY.regno
  port[E0]=vid.palette.r
  port[E1]=vid.palette.g
  port[E2]=vid.palette.b
  port[F8]=vid.mode
  port[F9]=sys2.data[0]
  port[FA]=vid.page
  port[FB]=regs1.data[1]
  port[FC]=vid.color
  port[FE]=AY.covox[4-7]
  port[FF]=AY.flip
  int[0]=vid.irq
}

mem1 : Memory {
  size=80000
  frame[0].size=10000
  frame[1].size=4000
  frame[2].size=4000
  frame[3].size=4000
}

rom1 : Memory {
  rom="Orion\Pro\rom1-210.bin"
}

rom2 : Memory {
  rom="Orion\Pro\rom2-210.bin"
  frame[0].size=2000
}

romdisk : Memory {
  rom="Orion\Pro\romd1.bin"
  romselect="Change ROM-disk"
  romfiles="ROM files (*.bin)|*.bin"
}

dip : Memory {
  rom="Orion\Pro\DIP"
}

sys1 : K580ww55 {
  portA[7]=dip[0]
  portA[6]=dip[1]
  portA[5]=dip[2]
  portA[4]=dip[3]
  portA[3]=dip[4]
  portA[2]=dip[5]
  portA[1]=dip[6]
  portA[0]=dip[7]
}

pagectl : K580ww55 {
  portA=mem1.frame[1].page
  portB=mem1.frame[2].page
  portC=mem1.frame[3].page
  default=1
}

sys2 : K580ww55 {
  portA=mem1.frame[0].page
  portB=rom2.frame[0].page
  portC[0]=win1.page[0]
  portC[1]=win2.page
  portC[2]=win3.page
  portC[3]=win1.page[2]
  portC[4]=win1.page[1]
  portC[5]=main.CPUClock.index
  portC[6-7]=mm.page
  default=1
}

app1 : K580ww55 {
  portA=kbd.~mask
  portB=kbd.~data
  portC[0]=cas.record
  portC[4]=cas.playback
  portC[5-7]=kbd.~data2
  default=1
}

app2 : K580ww55 {
  portA=romdisk.data
  portB=romdisk.lsb
  portC=romdisk.msb
  default=1
}

win1 : MemMap {
  map[0][0000-3FFF]=mem1.frame[0]
  map[1][0000-3FFF]=mem1.frame[1]

  map[2][0000-1FFF]=rom1[0000]
  map[2][2000-3FFF]=mem1.frame[0][2000]
  map[3][0000-1FFF]=rom1[0000]
  map[3][2000-3FFF]=mem1.frame[1][2000]

  map[4][0000-1FFF]=mem1.frame[0]
  map[4][2000-3FFF]=rom2.frame[0]
  map[5][0000-1FFF]=mem1.frame[1]
  map[5][2000-3FFF]=rom2.frame[0]

  map[6][0000-1FFF]=rom1[0000]
  map[6][2000-3FFF]=rom2.frame[0]
  map[7][0000-1FFF]=rom1[0000]
  map[7][2000-3FFF]=rom2.frame[0]

  initpage="7"
}

win2 : MemMap {
  map[0][0000-3FFF]=mem1.frame[0][4000]
  map[1][0000-3FFF]=mem1.frame[2]
}

win3 : MemMap {
  map[0][0000-3FFF]=mem1.frame[0][8000]
  map[1][0000-3FFF]=mem1.frame[3]
}

mm : MemMap {
  map[0][0000-3FFF]=win1
  map[0][4000-7FFF]=win2
  map[0][8000-BFFF]=win3
  map[0][C000-FFFF]=mem1.frame[0][C000]

  map[1][0000-3FFF]=win1
  map[1][4000-7FFF]=win2
  map[1][8000-BFFF]=win3
  map[1][C000-EFFF]=mem1.frame[0][C000]
  map[1][F000-FFFF]=mem1[7F000]

  map[2][0000-3FFF]=win1
  map[2][4000-7FFF]=win2
  map[2][8000-BFFF]=win3
  map[2][C000-EFFF]=mem1.frame[0][C000]
  map[2][F000-F3FF]=mem1[7F000]
  map[2][F400-F4FF]=app1.data
  map[2][F500-F5FF]=app2.data
  map[2][F700-F7FF]=extmap
  map[2][F800-F8FF].wo=vid.mode
  map[2][F900-F9FF].wo=sys2.data[0]
  map[2][FA00-FAFF].wo=vid.page
  map[2][F800-FFFF].ro=mem1[7F800]

  map[3][0000-3FFF]=win1
  map[3][4000-7FFF]=win2
  map[3][8000-BFFF]=win3
  map[3][C000-EFFF]=mem1.frame[0][C000]
  map[3][F000-F3FF]=mem1[7F000]
  map[3][F400-F4FF]=app1.data
  map[3][F500-F5FF]=app2.data
  map[3][F700-F7FF]=extmap
  map[3][F800-F8FF].wo=vid.mode
  map[3][F900-F9FF].wo=sys2.data[0]
  map[3][FA00-FAFF].wo=vid.page
  map[3][F800-FFFF].ro=mem1[7F800]
}

dsk : KR1818wg93 {
  ext="odi"
  image[0].file="Orion\Pro\prodos20.odi"
  vdpb="2800040F0084017F00C00020000400"
  vdpb.boot="Orion\Pro\prodos20.odi"
}

regs1 : K580ww55 {
  portA[0-1]=dsk.drive
  portA[4]=dsk.side[0]
  portB[0-3]=pagectl.data[0]
  portB[6]=vid.irqenable
}

extmap : MemMap2 {
  map[00-03]=dsk.data
  map[04]=regs1.data[0]
  map[10-13]=dsk.data
  map[14]=regs1.data[0]
  map[20]=regs1.data[0]
}

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

vid : orion-video {
  plane[0][0]=mem1[0C000]
  plane[0][1]=mem1[1C000]
  plane[1][0]=mem1[08000]
  plane[1][1]=mem1[18000]
  plane[2][0]=mem1[04000]
  plane[2][1]=mem1[14000]
  plane[3][0]=mem1[00000]
  plane[3][1]=mem1[10000]
  width=40
}

cas : tape-recorder {
}

AY : AY-3-8910 {
  freq=1773400
}
