ifndef Z80
  @NAME = "Вектор-06Ц"
else
  @NAME = "Вектор-06Ц Z80"
endif

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

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

# Основное ПЗУ
@ROM = "vector/loader.rom"
@ROM_SIZE = 0x8000

# EDD for wx/SDL (NONE, EDD (default), EDDx2, ERAM)
#@CFG_EDD = EDD


ifndef CFG_EDD
  @CFG_EDD = EDD
endif

if CFG_EDD == EDD
  define EDD
endif

if CFG_EDD == EDDx2
  define EDD
  define EDD2
endif

if CFG_EDD == ERAM
  define EDD
  define ERAM
endif

if CFG_TS == ON
  define TS
endif


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

EmuWindow window
window.caption = @NAME

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

# 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.frameScale = bestFit

# 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 = 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 = rk

Ram ram = 0x10000

Rom rom = @ROM, @ROM_SIZE

ifndef ERAM
  @RAMDISK_SIZE = 0x40000
else
  @RAMDISK_SIZE = 0x200000
endif

ifdef EDD
  Ram ramDiskMem = @RAMDISK_SIZE
endif

ifdef EDD2
  Ram ramDiskMem2 = @RAMDISK_SIZE
endif

ifndef Z80
  Cpu8080 cpu
else
  CpuZ80 cpu
endif

cpu.frequency = @FREQUENCY
cpu.startAddr = 0x0000

VectorRenderer crtRenderer
crtRenderer.memory = &ram
crtRenderer.visibleArea = yes

VectorAddrSpace addrSpace
addrSpace.ram = &ram
addrSpace.rom = &rom
addrSpace.ramDisk = &ramDiskMem, 0
addrSpace.ramDisk = &ramDiskMem2, 1
addrSpace.cpu = &cpu
addrSpace.crtRenderer = &crtRenderer

ifdef ERAM
  addrSpace.eram = "yes"
endif

VectorCore core
core.window = &window
core.crtRenderer = &crtRenderer
cpu.core = &core

VectorKeyboard keyboard

AddrSpace ioAddrSpace


VectorPpi8255Circuit ppiCircuit
ppiCircuit.crtRenderer = &crtRenderer

GeneralSoundSource tapeSoundSource
#tapeSoundSource.muted = yes
ppiCircuit.tapeSoundSource = &tapeSoundSource

Ppi8255 ppi
ppi.noReset = yes
ppi.circuit = &ppiCircuit
ppiCircuit.keyboard = &keyboard

AddrSpaceInverter invertedPpi = &ppi

ioAddrSpace.range = &invertedPpi, 0x00, 0x03


Ppi8255 ppi2
AddrSpaceInverter invertedPpi2 = &ppi2
ioAddrSpace.range = &invertedPpi2, 0x04, 0x07

Covox covox = 7
covox.polarity = negative

VectorPpi8255Circuit2 covoxCircuit
covoxCircuit.covox = &covox
ppi2.circuit = &covoxCircuit


VectorColorRegister colorReg
colorReg.crtRenderer = &crtRenderer
ioAddrSpace.range = &colorReg, 0x0C, 0x0F


Pit8253 pit
pit.frequency = 1500000

Pit8253SoundSource sndSource
sndSource.pit = &pit
sndSource.polarity = negative

AddrSpaceInverter invertedPit = &pit
ioAddrSpace.range = &invertedPit, 0x08, 0x0B


Psg3910 ay
ay.frequency = 1750000
Psg3910SoundSource psgSoundSource
psgSoundSource.psg = &ay

ifdef TS
  Psg3910 ay2
  ay2.frequency = 1750000
  Psg3910SoundSource psgSoundSource2
  psgSoundSource2.psg = &ay2
  psgSoundSource2.polarity = negative

  TurboSound ts
  ts.psg1 = &ay
  ts.psg2 = &ay2

  ioAddrSpace.range = &ts, 0x14, 0x15
else
  ioAddrSpace.range = &ay, 0x14, 0x15
endif


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


ifdef EDD
  VectorRamDiskSelector ramDiskSelector
  ramDiskSelector.addrSpace = &addrSpace
  ramDiskSelector.diskNum = 0
  ioAddrSpace.range = &ramDiskSelector, 0x10, 0x10
endif

ifdef EDD2
  VectorRamDiskSelector ramDiskSelector2
  ramDiskSelector2.addrSpace = &addrSpace
  ramDiskSelector2.diskNum = 1
  ioAddrSpace.range = &ramDiskSelector2, 0x11, 0x11
endif

ifdef ERAM
  VectorEramSelector eramSelector
  eramSelector.addrSpace = &addrSpace
  ioAddrSpace.range = &eramSelector, 0x20, 0x20
endif


Fdc1793 fdc
AddrSpaceInverter invertedFdc = &fdc
ioAddrSpace.range = &invertedFdc, 0x18, 0x1B


VectorFddControlRegister fddReg
fddReg.fdc = &fdc
ioAddrSpace.range = &fddReg, 0x1C, 0x1C


AtaDrive ataDrive
ataDrive.geometry = vector
#ataDrive.geometry = 200, 5, 18

VectorHddRegisters hddRegisters
hddRegisters.ataDrive = &ataDrive
ioAddrSpace.range = &hddRegisters, 0x50, 0x5F

cpu.addrSpace = &addrSpace
cpu.ioAddrSpace = &ioAddrSpace

ifndef Z80
  VectorCpuWaits cpuWaits
else
  VectorZ80CpuWaits cpuWaits
endif

cpu.cpuWaits = &cpuWaits

VectorKbdLayout kbdLayout
kbdLayout.layout = smart

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



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

VectorFileLoader loader
loader.addrSpace = &ram
loader.filter = "Файлы Вектора (*.rom;*.r0m;*.vec;*.cas;*.bas;*.fdd;*.wav)|*.rom;*.ROM;*.rom;*.R0M;*.vec;*.VEC;*.cas;*.CAS;*.bas;*.BAS;*.fdd;*.FDD;*.wav;*.WAV|Все файлы (*.*)|*"

ifdef EDD
  RamDisk ramDisk = 1, @RAMDISK_SIZE
  ramDisk.filter = "Файлы RAM-диска Вектора (*.edd)|*.edd;*.EDD|Все файлы (*.*)|*"
  ramDisk.page = 0, &ramDiskMem
  #ramDisk.label = EDD
endif

ifdef EDD2
  RamDisk ramDisk2 = 1, @RAMDISK_SIZE
  ramDisk2.filter = "Файлы RAM-диска Вектора (*.edd)|*.edd;*.EDD|Все файлы (*.*)|*"
  ramDisk2.page = 0, &ramDiskMem2
  ramDisk2.label = EDD2
endif

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

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

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

DiskImage hdd
hdd.label = HDD
hdd.filter = "Образы HDD Вектора (*.hdd;*.img)|*.hdd;*.HDD;*.img;*.IMG|Все файлы (*.*)|*"
#hdd.fileName = vector/vector.hdd
ataDrive.diskImage = &hdd


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

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

RkTapeInHook tapeInHookBas = 0x2B05
tapeInHookBas.signature = C5D50E0057DB
tapeInHookBas.tapeRedirector = &tapeInFile
cpu.addHook = &tapeInHookBas

RkTapeOutHook tapeOutHookBas = 0x2B60
tapeOutHookBas.outReg = A
tapeOutHookBas.signature = C5D5F5570E08
tapeOutHookBas.tapeRedirector = &tapeOutFile
cpu.addHook = &tapeOutHookBas

CloseFileHook closeFileHookBas = 0x2B8E
closeFileHookBas.signature = C506003A203C
closeFileHookBas.addTapeRedirector = &tapeInFile
closeFileHookBas.addTapeRedirector = &tapeOutFile
cpu.addHook = &closeFileHookBas


RkTapeInHook tapeInHookMon = 0xF840
tapeInHookMon.signature = C5D50E0057DB
tapeInHookMon.tapeRedirector = &tapeInFile
cpu.addHook = &tapeInHookMon

RkTapeOutHook tapeOutHookMon = 0xF89B
tapeOutHookMon.outReg = A
tapeOutHookMon.signature = C5D5F5573E02
tapeOutHookMon.tapeRedirector = &tapeOutFile
cpu.addHook = &tapeOutHookMon

Ret8080Hook skipHookMon = 0xEDDC
skipHookMon.signature = CD1097FB76F3
cpu.addHook = &skipHookMon

CloseFileHook closeFileHookMon = 0xFEFF
closeFileHookMon.signature = 3AFDFFE604CD
closeFileHookMon.addTapeRedirector = &tapeInFile
closeFileHookMon.addTapeRedirector = &tapeOutFile
cpu.addHook = &closeFileHookMon


RkTapeInHook tapeInHookEmuRk = 0xFC31
tapeInHookEmuRk.signature = F3C5D50E0057
tapeInHookEmuRk.tapeRedirector = &tapeInFile
cpu.addHook = &tapeInHookEmuRk

RkTapeOutHook tapeOutHookEmuRk = 0xFC7D
tapeOutHookEmuRk.signature = F3C5D5F51608
tapeOutHookEmuRk.tapeRedirector = &tapeOutFile
cpu.addHook = &tapeOutHookEmuRk

CloseFileHook closeFileHookEmuRk = 0xFF18
closeFileHookEmuRk.signature = FB3A61F6E604
closeFileHookEmuRk.addTapeRedirector = &tapeInFile
closeFileHookEmuRk.addTapeRedirector = &tapeOutFile
cpu.addHook = &closeFileHookEmuRk


EmuObjectGroup tapeGrp
tapeGrp.addItem = &tapeOutHookBas
tapeGrp.addItem = &tapeInHookBas
tapeGrp.addItem = &closeFileHookBas
tapeGrp.addItem = &tapeOutHookMon
tapeGrp.addItem = &tapeInHookMon
tapeGrp.addItem = &closeFileHookMon
tapeGrp.addItem = &tapeOutHookEmuRk
tapeGrp.addItem = &tapeInHookEmuRk
tapeGrp.addItem = &closeFileHookEmuRk
tapeGrp.addItem = &skipHookMon



ifdef WX
  include "vector/vector_wx.inc"
endif
