@NAME = "Северная Пальмира"


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

# Тактовые частоты
@CPU_FREQUENCY = 1777777   # ВМ80, ВТ57
@CRT_FREQUENCY = 3000000   # ВГ75
@PIT_FREQUENCY = 1500000   # ВИ53

# Основное ПЗУ и адреса перехвата
@ROM = "palmira/palmbios.bin"
@F806_ADDR = 0xfb98
@F80C_ADDR = 0xfc46
@F803_ADDR = 0xfe63

# Знакогенератор
@SYM_GEN  = "palmira/sgplm.bin"       

# Файл настроек
@OPT_FILE = "palmira/palmira.opt"

# Директория SD-карты (vinxru)
ifndef CFG_SD_DIR
  @CFG_SD_DIR = "palmira/sdcard"
endif


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

EmuWindow window
window.caption = @NAME

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

# 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 = 1x
#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 ram11 = 0x8000
Ram ram12 = 0x8000

Ram ram2 = 0x4000
Ram ram3 = 0x0800
Ram fontRam = 0x0800

Rom rom = @ROM, 0x2000

AddrSpaceMapper lowerMem = 2
lowerMem.page = 0, &ram11
lowerMem.page = 1, &ram12

Ppi8255 ppi1
Ppi8255 ppi2

Dma8257 dma
dma.frequency = @CPU_FREQUENCY

Crt8275 crt
crt.frequency = @CRT_FREQUENCY
crt.dma = &dma, 2

Pit8253 pit
pit.frequency = @PIT_FREQUENCY
Pit8253SoundSource sndSource
Pit8253SoundSource polarity = negative
sndSource.pit = &pit

PalmiraRenderer crtRenderer
crtRenderer.font = @SYM_GEN
crtRenderer.visibleArea = no
crtRenderer.crt = &crt
crtRenderer.fontRam = &fontRam

PalmiraCore core
core.window = &window
core.crtRenderer = &crtRenderer

crt.core = &core

Cpu8080 cpu
cpu.frequency = @CPU_FREQUENCY
cpu.startAddr = 0xE000
cpu.core = &core

Cpu8080StatusWordSpace null = &cpu

PalmiraConfigRegister cfgReg
cfgReg.crtRenderer = &crtRenderer

AddrSpace upperMemDev
upperMemDev.range = &ppi1, 0x0000, 0x1FFF
upperMemDev.range = &ppi2, 0x2000, 0x3FFF

AddrSpaceMapper upperMem = 2
upperMem.page = 0, &ram2
upperMem.page = 1, &upperMemDev

AddrSpaceMapper fontMem = 2
fontMem.page = 0, &fontRam
fontMem.page = 1, &null

cfgReg.lowerMemMapper = &lowerMem
cfgReg.upperMemMapper = &upperMem
cfgReg.fontMemMapper = &fontMem

AddrSpace addrSpace
addrSpace.range = &lowerMem, 0x0000, 0x7FFF
addrSpace.range = &upperMem, 0x8000, 0xBFFF
addrSpace.range = &crt, 0xC000, 0xC1FF
addrSpace.range = &ppi1, 0xC200, 0xC3FF
addrSpace.range = &ppi2, 0xC400, 0xC5FF
addrSpace.range = &pit, 0xCC00, 0xCDFF
addrSpace.range = &ram3, 0xD000, 0xD7FF
addrSpace.range = &fontMem, 0xD800, 0xDFFF
addrSpace.writeRange = &cfgReg, 0xCE00, 0xCFFF
addrSpace.readRange = &null, 0xCE00, 0xCFFF
addrSpace.writeRange = &dma, 0xE000, 0xFFFF
addrSpace.readRange = &rom, 0xE000, 0xFFFF

cpu.addrSpace = &addrSpace

dma.addrSpace = &addrSpace
dma.cpu = &cpu

GeneralSoundSource tapeSoundSource
#tapeSoundSource.muted = yes

RkKbdLayout kbdLayout
kbdLayout.layout = smart

RkKeyboard keyboard

RkPpi8255Circuit ppiCircuit
ppiCircuit.rkKeyboard = &keyboard
ppiCircuit.tapeSoundSource = &tapeSoundSource
ppi1.circuit = &ppiCircuit

RkSdController sdCard = @CFG_SD_DIR
ppi2.circuit = &sdCard

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


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

RkFileLoader loader
loader.addrSpace = &addrSpace
loader.filter = "Файлы Пальмиры (*.rkl)|*.rkl;*.RKL|Файлы RK-совместимых ПК (*.rk?)|*.rk;*.rk?;*.RK;*.RK?|Все файлы (*.*)|*"

TapeRedirector tapeInFile
tapeInFile.mode = "r"
tapeInFile.filter = "Файлы Пальмиры (*.rkl)|*.rkl;*.RKL|Файлы RK-совместимых ПК (*.rk?)|*.rk;*.rk?;*.RK;*.RK?|Файлы BSM (*.bsm)|*.bsm;*.BSM|Файлы EDM (*.edm)|*.edm;*.EDM|Все файлы (*.*)|*"

TapeRedirector tapeOutFile
tapeOutFile.mode = "w"
tapeOutFile.filter = "Файлы Пальмиры (*.rkl)|*.rkl|Файлы RK-совместимых ПК (*.rk)|*.rk|Файлы BSM (*.bsm)|*.bsm|Файлы EDM (*.edm)|*.edm|Все файлы (*.*)|*"

RkTapeInHook tapeInHook = @F806_ADDR
tapeInHook.tapeRedirector = &tapeInFile
cpu.addHook = &tapeInHook

RkTapeOutHook tapeOutHook = @F80C_ADDR
tapeOutHook.tapeRedirector = &tapeOutFile
cpu.addHook = &tapeOutHook

CloseFileHook closeFileHook = @F803_ADDR
closeFileHook.addTapeRedirector = &tapeInFile
closeFileHook.addTapeRedirector = &tapeOutFile
cpu.addHook = &closeFileHook

EmuObjectGroup tapeGrp
tapeGrp.addItem = &tapeOutHook
tapeGrp.addItem = &tapeInHook
tapeGrp.addItem = &closeFileHook
#tapeGrp.enabled = no


ifdef WX
  include "palmira/palmira_wx.inc"
endif

