main.CPUClock=3500KHz
main.Caption="Àðãî"
main.ff.speed=10
main.ff.keymask[B]=1
main.scale.x=100%
main.scale.y=150%

CPU : Z80 {
  debug=cas
  mem=amm
  pc=F800
  port[00-FF]=portmap
  rst[7]=crt.irq
  nmi=amm.nmi
}

portmap : MemMap2 {
  map[80]=sysctl
  map[81].ro=amm.nmi.code
  map[81].wo=casctl
  map[A1].ro=kbd.~idata
  map[A1].wo=memcfg
  map[A9].wo=memcfg
  map[B1].wo=memcfg
  map[B9].wo=memcfg
  map[A9].offset=1
  map[B1].offset=2
  map[B9].offset=3
  map[A0]=timdata
  map[A2]=timdata
  map[A4]=timdata
  map[A6]=timdata
  map[A2].offset=1
  map[A4].offset=2
  map[A6].offset=3
  map[C0]=crt.data
  map[C4]=crt.data
  map[C4].offset=1
  map[C1]=comdata
  map[C3]=comdata
  map[C3].offset=1
  map[E0-EF]=dma.data
  map[FE]=sysctl
}

mem1 : Memory {
  size=20000
}

bios : Memory {
  rom="Argo\argo.bin"
}

sysctl : Register {
  write[0-3]=crt.border
  write[4]=beep.input
  read[0-5]=3F
  read[6]=cas.playback
  read[7]=amm.nmi.trap
}

fontmem : MemMap {
  map[0][0000-07FF]=mem1[1F800]
  map[1][0000-FFFF]=mem1[10000]
}

fontdc : Decoder {
  mem=fontmem
  adrxlat="FEDCB98765A43210"
}

crt : K580wg75 {
  mode=0
  dma=dma[2]
  font=fontdc
  fontwidth=8
  fontmode=128
  palette="Unior\palette.rom"
  pindex=crt.ggh
}

dma : K580wt57 {
  mem[0]=amm.dma0
  mem[1]=amm.dma1
  mem[2]=mem1
  autocopy=1
  hrq=CPU.hold
  tc=crt.stopdrq
}

timdata : MemMap {
  map[0][0000-FFFF]=tim.data
  map[1][0000-FFFF]=amm.nmi.disable
}

tim : K580wi53 {
  clock[0].rate=3/4
  clock[1].rate=1/1
  clock[2].rate=1/8e
  gate[0].value=1
  gate[1].value=1
  gate[2].value=1
}

comdata : Decoder {
  addr=amm.nmi.end
  mem=com.data
}

com : K580ww51 {
  io=cas.ioctl
}

mm : MemMap {
  map[0][0000-FFFF]=mem1[00000]
  map[1][0000-F7FF]=mem1[00000]
  map[1][F800-FFFF]=mem1[1F800]
  map[2][0000-FFFF]=mem1[00000]
  map[3][0000-FFFF]=mem1[10000]
  map[4][0000-3FFF]=mem1[0000]
  map[4][4000-77FF]=mem1[14000]
  map[4][7800-FFFF]=mem1[7800]
  map[5][0000-3FFF]=mem1[4000]
  map[5][4000-77FF]=mem1[14000]
  map[5][7800-FFFF]=mem1[7800]
  map[6][0000-3FFF]=mem1[0000]
  map[6][4000-77FF]=mem1[14000]
  map[6][7800-FFFF]=mem1[7800]
  map[7][0000-3FFF]=mem1[4000]
  map[7][4000-77FF]=mem1[14000]
  map[7][7800-FFFF]=mem1[7800]
}

reg1 : Register {
  write[7]=crt.zxmode
  write[7]=fontmem.page
  write[7]=timdata.page
}

memcfg : Decoder {
  data=reg1
  mem.wo=amm.memcfg
}

amm : argo-memmap {
  bios=bios
  mem=mem1
  memmap=mm.map[0]
}

kbd : Keyboard {
  mask=CPU.port.msb
  layout="Argo\layout.kbd"
  irqkey=1
  irq=amm.nmi.enable
}

beep : beep {
}

casctl : Register {
 write[1]=cas.ioctl.rec
 write[2]=cas.ioctl.play
 write[3]=cas.ioctl.back
 write[4]=cas.ioctl.ff
 write[5]=cas.ioctl.stop
}

cas : tape-recorder {
  iproc[0562-05E0]=zx
  iproc[0562-05E0].check="DBFE1FE620F6024F"
  oproc[04C2-053E]=zx
  oproc[04C2-053E].check="213F05E521801FCB"
}
