ifdef HDD
  @NAME = "ПК8000 (HDD)"
else
ifdef FDC
  @NAME = "ПК8000 (НГМД)"
else
  @NAME = "ПК8000"
endif
endif

# Файл справки
@HELP_FILE = pk8000/pk8000.html

# Тактовая частота
@FREQUENCY = 2500000

# Основное ПЗУ
@ROM = "pk8000/pk8000_v12.rom"

# ПЗУ КНГМД
@FDC_ROM = "pk8000/pk8000_fdc.rom"

# ПЗУ КНГМД
@HDD_ROM = "pk8000/pk8000_hdd.rom"

# Кардридж с ROM-диском
#@ROM_DISK = "pk8000/multigame_cartrige_v1_2.bin"


######## Window ########

EmuWindow window
window.caption = @NAME

# Default window size for window.windowStyle = fixed (default = 800, 600)
#window.defaultWindowSize = 768, 512
window.defaultWindowSize = 800, 400

# Window style: autosize, resizable, fixed, fullscreen (default = autosise)
window.windowStyle = autosize
#window.windowStyle = resizable

# Window scaling option: 1x, 2x, 3x, 4x, 5x, fit, bestFit (default = bestFit)
window.frameScale = 2x

# Window fields mixing: none, mix, average, interlace, scanline (default = none)
#window.fieldsMixing = mix

# Image smoothing / post-processing: nearest, bilinear, sharp, custom (default = sharp)
window.smoothing = sharp

# Custom image shader: "shader name" or none (default = none)
#window.shader = crt-hyllian

# Convert image to grayscale
#window.desaturate = yes

# Aspect correction (default = no)
#window.aspectCorrection = yes

# Wide screen (16:9): yes, no, custom (default = no)
window.wideScreen = no

# Gray window background (default: no)
#window.grayBackground = yes

# Screen format for window.wideScreen = custom
window.customScreenFormat = 1.111



######## Platform ########

platform.helpFile = @HELP_FILE

# Code page: rk, koi8 (default = rk)
platform.codePage = koi8

Ram ram0 = 0x4000
Ram ram1 = 0x4000
Ram ram2 = 0x4000
Ram ram3 = 0x4000

@RAM_TAG = 1

ram0.tag = @RAM_TAG
ram1.tag = @RAM_TAG
ram2.tag = @RAM_TAG
ram3.tag = @RAM_TAG

Rom rom = @ROM, 0x4000

AddrSpace romRam0
romRam0.readRange  = &rom,  0x0000, 0x3FFF
romRam0.writeRange = &ram0, 0x0000, 0x3FFF

AddrSpace romRam1
romRam1.readRange  = &rom,  0x0000, 0x3FFF
romRam1.writeRange = &ram1, 0x0000, 0x3FFF

AddrSpace romRam2
romRam2.readRange  = &rom,  0x0000, 0x3FFF
romRam2.writeRange = &ram2, 0x0000, 0x3FFF

AddrSpace romRam3
romRam3.readRange  = &rom,  0x0000, 0x3FFF
romRam3.writeRange = &ram3, 0x0000, 0x3FFF

AddrSpace ext10r
AddrSpace ext11r
AddrSpace ext12r
AddrSpace ext13r

ifdef FDC
  Rom fdcRom = @FDC_ROM, 0x2000

  Fdc1793 fdc
  
  Pk8000FddControlRegister fddControlRegister
  fddControlRegister.fdc = &fdc

  Pk8000FdcStatusRegisters fdcStatusRegisters
  fdcStatusRegisters.fdc = &fdc

  AddrSpace fddRegSpace
  fddRegSpace.range = &fddControlRegister, 0, 0
  fddRegSpace.range = &fdc, 1, 4
  fddRegSpace.range = &fdcStatusRegisters, 5, 8

  ext10r.readRange = &fdcRom,  0x0000, 0x1FFF
  ext10r.range = &fddRegSpace, 0x3FF7, 0x3FFF

  ext11r.readRange = &fdcRom,  0x0000, 0x1FFF
  ext11r.range = &fddRegSpace, 0x3FF7, 0x3FFF

  ext12r.readRange = &fdcRom,  0x0000, 0x1FFF
  ext12r.range = &fddRegSpace, 0x3FF7, 0x3FFF

  ext13r.readRange = &fdcRom,  0x0000, 0x1FFF
  ext13r.range = &fddRegSpace, 0x3FF7, 0x3FFF
else
  ifdef HDD
    Rom hddRom = @HDD_ROM, 9322
    ext10r.readRange = &hddRom, 0x0000, 0x2FFF
    ext11r.readRange = &hddRom, 0x0000, 0x2FFF
    ext12r.readRange = &hddRom, 0x0000, 0x2FFF
    ext13r.readRange = &hddRom, 0x0000, 0x2FFF
  endif
endif

ifdef ROM_DISK
  Rom romDisk0 = @ROM_DISK, 0x4000
  Pk8000RomDisk romDisk = @ROM_DISK, 0x60000

  ext10r.readRange = &romDisk0, 0x0000, 0x3FFF
  ext11r.readRange = &romDisk0, 0x0000, 0x3FFF
  ext12r.readRange = &romDisk, 0x0000, 0x3FFF
  ext13r.readRange = &romDisk, 0x0000, 0x3FFF

  Pk8000RomDiskSelector romDiskSelector
  romDiskSelector.romDisk = &romDisk
endif

AddrSpaceWriteSplitter ext10 = &ext10r, &ram0
AddrSpaceWriteSplitter ext11 = &ext11r, &ram1
AddrSpaceWriteSplitter ext12 = &ext12r, &ram2
AddrSpaceWriteSplitter ext13 = &ext13r, &ram3

AddrSpace ext20
AddrSpace ext21
AddrSpace ext22
AddrSpace ext23

ext20.writeRange = &ram0, 0x0000, 0x3FFF
ext21.writeRange = &ram1, 0x0000, 0x3FFF
ext22.writeRange = &ram2, 0x0000, 0x3FFF
ext23.writeRange = &ram3, 0x0000, 0x3FFF

AddrSpaceMapper bank0 = 4
bank0.page = 0, &romRam0
bank0.page = 1, &ext10
bank0.page = 2, &ext20
bank0.page = 3, &ram0

AddrSpaceMapper bank1 = 4
bank1.page = 0, &romRam1
bank1.page = 1, &ext11
bank1.page = 2, &ext21
bank1.page = 3, &ram1

AddrSpaceMapper bank2 = 4
bank2.page = 0, &romRam2
bank2.page = 1, &ext12
bank2.page = 2, &ext22
bank2.page = 3, &ram2

AddrSpaceMapper bank3 = 4
bank3.page = 0, &romRam3
bank3.page = 1, &ext13
bank3.page = 2, &ext23
bank3.page = 3, &ram3

AddrSpace addrSpace
addrSpace.range = &bank0, 0x0000, 0x3FFF
addrSpace.range = &bank1, 0x4000, 0x7FFF
addrSpace.range = &bank2, 0x8000, 0xBFFF
addrSpace.range = &bank3, 0xC000, 0xFFFF

Pk8000Renderer crtRenderer
crtRenderer.screenMemoryBank = 0, &ram0
crtRenderer.screenMemoryBank = 1, &ram1
crtRenderer.screenMemoryBank = 2, &ram2
crtRenderer.screenMemoryBank = 3, &ram3

Pk8000Core core
core.window = &window
core.crtRenderer = &crtRenderer

Pk8000Keyboard keyboard

AddrSpace ioAddrSpace

GeneralSoundSource tapeSoundSource
#tapeSoundSource.muted = yes
GeneralSoundSource beepSoundSource

Pk8000Ppi8255Circuit1 ppiCircuit1
ppiCircuit1.bank = 0, &bank0
ppiCircuit1.bank = 1, &bank1
ppiCircuit1.bank = 2, &bank2
ppiCircuit1.bank = 3, &bank3
ppiCircuit1.keyboard = &keyboard
ppiCircuit1.tapeSoundSource = &tapeSoundSource
ppiCircuit1.beepSoundSource = &beepSoundSource

Ppi8255 ppi1
ppi1.circuit = &ppiCircuit1

ioAddrSpace.range = &ppi1, 0x80, 0x83

Pk8000Ppi8255Circuit2 ppiCircuit2
ppiCircuit2.crtRenderer = &crtRenderer

Ppi8255 ppi2
ppi2.circuit = &ppiCircuit2

ioAddrSpace.range = &ppi2, 0x84, 0x87

ifdef HDD

  Ppi8255 hddPpi
  ioAddrSpace.range = &hddPpi, 0x50, 0x53

  DiskImage hdd
  hdd.label = HDD
  hdd.filter = "Образы HDD ПК8000 (*.hdd;*.img)|*.hdd;*.HDD;*.img;*.IMG|Все файлы (*.*)|*"
  hdd.fileName = @HDD_IMAGE

  AtaDrive ataDrive
  #ataDrive.geometry = 64, 8, 8
  ataDrive.geometry = lba
  ataDrive.diskImage = &hdd

  PpiAtaAdapter ataAdapter
  ataAdapter.ataDrive = &ataDrive
  hddPpi.circuit = &ataAdapter

endif

Pk8000ColorSelector colorSelector
colorSelector.crtRenderer = &crtRenderer
ioAddrSpace.range = &colorSelector, 0x88, 0x88

Pk8000TxtBufSelector txtBufSelector
txtBufSelector.crtRenderer = &crtRenderer
ioAddrSpace.range = &txtBufSelector, 0x90, 0x90

Pk8000SymGenBufSelector sgBufSelector
sgBufSelector.crtRenderer = &crtRenderer
ioAddrSpace.range = &sgBufSelector, 0x91, 0x91

Pk8000GrBufSelector grBufSelector
grBufSelector.crtRenderer = &crtRenderer
ioAddrSpace.range = &grBufSelector, 0x92, 0x92

Pk8000ColBufSelector colBufSelector
colBufSelector.crtRenderer = &crtRenderer
ioAddrSpace.range = &colBufSelector, 0x93, 0x93

Pk8000InputRegister inputReg
inputReg.keyboard = &keyboard
ioAddrSpace.range = &inputReg, 0x8D, 0x8D

NullSpace inputReg2 = 0x00
ioAddrSpace.range = &inputReg2, 0x8C, 0x8C

Pk8000Mode1ColorMem colormem
colormem.crtRenderer = &crtRenderer
ioAddrSpace.range = &colormem, 0xA0, 0xBF

ifdef ROM_DISK
  ioAddrSpace.range = &romDiskSelector, 0x77, 0x77
endif

Psg3910 ay
ay.frequency = 1750000
ioAddrSpace.range = &ay, 0x14, 0x15

Psg3910SoundSource psgSoundSource
psgSoundSource.psg = &ay

# stereo (def.) | mono
#psgSoundSource.mixing = stereo

Cpu8080 cpu
cpu.frequency = @FREQUENCY
cpu.startAddr = 0x0000
cpu.addrSpace = &addrSpace
cpu.ioAddrSpace = &ioAddrSpace
cpu.core = &core

Pk8000CpuWaits cpuWaits
crtRenderer.cpuWaits = &cpuWaits
cpu.cpuWaits = &cpuWaits

Pk8000KbdLayout kbdLayout
kbdLayout.layout = smart
#kbdLayout.numpadJoystick = yes

KbdTapper kbdTapper
kbdTapper.pressTime = 40
kbdTapper.releaseTime = 40
kbdTapper.crDelay = 100


######## File I/O ########

TapeRedirector msxTapeOutFile
msxTapeOutFile.mode = "w"
msxTapeOutFile.filter = "Cas-файлы MSX (*.cas)|*.cas|Все файлы (*.*)|*"
msxTapeOutFile.timeout = 6000

TapeRedirector msxTapeInFile
msxTapeInFile.mode = "r"
msxTapeInFile.filter = "Cas-файлы MSX (*.cas)|*.cas;*.CAS|Все файлы (*.*)|*"
msxTapeInFile.timeout = 3000

TapeRedirector tapeOutFile
tapeOutFile.mode = "w"
tapeOutFile.filter = "Файлы RK-совместимых ПК (*.rk)|*.rk|Все файлы (*.*)|*"
tapeOutFile.timeout = 6000

TapeRedirector tapeInFile
tapeInFile.mode = "r"
tapeInFile.filter = "Файлы RK-совместимых ПК (*.rk?)|*.rk;*.rk?;*.RK;*.RK?|Все файлы (*.*)|*"
tapeInFile.timeout = 3000

Pk8000FileLoader loader
loader.addrSpace = &addrSpace
loader.filter = "Двоичные и basic-файлы ПК-8000 (*.cas)|*.cas;*.CAS|Все файлы (*.*)|*"
loader.tapeRedirector = &msxTapeInFile
loader.allowMultiblock = yes

MsxTapeOutHook tapeOutHook = 0x365E
tapeOutHook.signature = F57DD60F
tapeOutHook.tapeRedirector = &msxTapeOutFile
cpu.addHook = &tapeOutHook

MsxTapeOutHeaderHook tapeOutHeaderHook = 0x362B
tapeOutHeaderHook.signature = B7F5DB82
tapeOutHeaderHook.tapeRedirector = &msxTapeOutFile
cpu.addHook = &tapeOutHeaderHook

MsxTapeInHook tapeInHook = 0x370E
tapeInHook.signature = 3AA0FD47
tapeInHook.tapeRedirector = &msxTapeInFile
cpu.addHook = &tapeInHook

MsxTapeInHeaderHook tapeInHeaderHook = 0x36C1
tapeInHeaderHook.signature = F3DB82F6
tapeInHeaderHook.tapeRedirector = &msxTapeInFile
cpu.addHook = &tapeInHeaderHook


MsxTapeOutHook tapeOutHook2 = 0x1405
tapeOutHook2.signature = F521272A
tapeOutHook2.tapeRedirector = &msxTapeOutFile
cpu.addHook = &tapeOutHook2

MsxTapeOutHeaderHook tapeOutHeaderHook2 = 0x13E2
tapeOutHeaderHook2.signature = F5010000
tapeOutHeaderHook2.tapeRedirector = &msxTapeOutFile
cpu.addHook = &tapeOutHeaderHook2

MsxTapeInHeaderHook tapeInHeaderHook2 = 0x1468
tapeInHeaderHook2.signature = CD4B1421
tapeInHeaderHook2.tapeRedirector = &msxTapeInFile
cpu.addHook = &tapeInHeaderHook2

MsxTapeInHook tapeInHook2 = 0x14B8
tapeInHook2.signature = 3A5E7E57
tapeInHook2.tapeRedirector = &msxTapeInFile
cpu.addHook = &tapeInHook2


CloseFileHook closeFileHook = 0x2400
closeFileHook.signature = C5E5D521
closeFileHook.addTapeRedirector = &msxTapeInFile
closeFileHook.addTapeRedirector = &msxTapeOutFile
cpu.addHook = &closeFileHook

CloseFileHook closeFileHook2 = 0x0D0C
closeFileHook2.signature = E5D5C5CDB609
closeFileHook2.addTapeRedirector = &msxTapeInFile
closeFileHook2.addTapeRedirector = &msxTapeOutFile
cpu.addHook = &closeFileHook2


RkTapeOutHook tapeOutHook3 = 0xFB95
tapeOutHook3.signature = C5D5F5790F0F
tapeOutHook3.tapeRedirector = &tapeOutFile
cpu.addHook = &tapeOutHook3

RkTapeInHook tapeInHook3 = 0xFB45
tapeInHook3.signature = C5D50E0057DB
tapeInHook3.tapeRedirector = &tapeInFile
cpu.addHook = &tapeInHook3

CloseFileHook closeFileHook3 = 0xFBEB
closeFileHook3.signature = E5C5D5CDD4FD
closeFileHook3.addTapeRedirector = &tapeInFile
closeFileHook3.addTapeRedirector = &tapeOutFile
cpu.addHook = &closeFileHook3


EmuObjectGroup tapeGrp
tapeGrp.addItem = &tapeOutHook
tapeGrp.addItem = &tapeInHook
tapeGrp.addItem = &tapeOutHeaderHook
tapeGrp.addItem = &tapeInHeaderHook
tapeGrp.addItem = &tapeOutHook2
tapeGrp.addItem = &tapeInHook2
tapeGrp.addItem = &tapeOutHeaderHook2
tapeGrp.addItem = &tapeInHeaderHook2
tapeGrp.addItem = &closeFileHook
tapeGrp.addItem = &closeFileHook2
tapeGrp.addItem = &tapeInHook3
tapeGrp.addItem = &tapeOutHook3
tapeGrp.addItem = &closeFileHook3

ifdef FDC
  FdImage diskA = 80, 2, 5, 1024
  diskA.label = A
  diskA.filter = "Образы дисков ПК8000 (*.fdd)|*.fdd;*.FDD|Все файлы (*.*)|*"

  FdImage diskB = 80, 2, 5, 1024
  diskB.label = B
  diskB.filter = "Образы дисков ПК8000 (*.fdd)|*.fdd;*.FDD|Все файлы (*.*)|*"

  fdc.fdImage = 0, &diskA
  fdc.fdImage = 1, &diskB
endif


ifndef QT
  include "pk8000/pk8000_wx.inc"
endif
