ifdef SDCARD
  @NAME = "Апогей БК-01 (SD card)"
else
  @NAME = "Апогей БК-01"
endif


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

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

# Монитор
@ROM = "apogey/apogey.rom"

# ROM-диск
ifndef CFG_ROMDISK_FILE
  @CFG_ROMDISK_FILE = "apogey/romdisk512.bin"
endif

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

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

# Шрифты 8x8, 8x12, 8x16
@FONT     = "apogey/fonta.bin"

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



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

EmuWindow window
window.caption = @NAME

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

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

# Window fullscreen mode: yes, no (default = no)
window.fullscreen = no

# 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 = 0xEC00

Rom rom = @ROM, 0x1000

Ppi8255 ppi1

Ppi8255 ppi2

Dma8257 dma
dma.frequency = @CPU_FREQUENCY

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

ApogeyRenderer crtRenderer
crtRenderer.font = @SYM_GEN
crtRenderer.altFont = @FONT
crtRenderer.altRenderer = no
crtRenderer.visibleArea = no
crtRenderer.crt = &crt

ApogeyCore core
core.window = &window
core.crtRenderer = &crtRenderer
crt.core = &core

Pit8253 pit
pit.frequency = @CPU_FREQUENCY

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

AddrSpace addrSpace
addrSpace.range = &ram, 0, 0xebFF
addrSpace.range = &pit, 0xec00, 0xecff
addrSpace.range = &ppi1, 0xed00, 0xedff
addrSpace.range = &ppi2, 0xee00, 0xeeff
addrSpace.range = &crt, 0xef00, 0xefff
addrSpace.writeRange = &dma, 0xf000, 0xffff
addrSpace.readRange = &rom, 0xf000, 0xffff

Cpu8080 cpu
cpu.frequency = @CPU_FREQUENCY
cpu.startAddr = 0xF800
cpu.addrSpace = &addrSpace
cpu.core = &core

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


ifdef SDCARD
  RkSdController sdCard = @CFG_SD_DIR
  ppi2.circuit = &sdCard
else
  ApogeyRomDisk romDisk = @CFG_ROMDISK_FILE
  ppi2.circuit = &romDisk
endif


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



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

RkFileLoader loader
loader.addrSpace = &addrSpace
loader.filter = "Файлы Апогея (*.rka)|*.rka;*.RKA|Файлы RK-совместимых ПК (*.rk?)|*.rk;*.rk?;*.RK;*.RK?|Все файлы (*.*)|*"

TapeRedirector tapeInFile
tapeInFile.mode = "r"
tapeInFile.filter = "Файлы Апогея (*.rka)|*.rka;*.RKA|Файлы RK-совместимых ПК (*.rk?)|*.rk;*.rk?;*.RK;*.RK?|Файлы BSM (*.bsm)|*.bsm;*.BSM|Файлы EDM (*.edm)|*.edm;*.EDM|Все файлы (*.*)|*"
#tapeInFile.fileName = "example.rka"

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

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

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

RkTapeOutHook tapeOutHook = 0xFC46
tapeOutHook.tapeRedirector = &tapeOutFile
cpu.addHook = &tapeOutHook

RkTapeInHook tapeInHook = 0xFB98
tapeInHook.tapeRedirector = &tapeInFile
cpu.addHook = &tapeInHook

MsxTapeOutHook msxTapeOutHook = 0xF66F
msxTapeOutHook.outReg = C
msxTapeOutHook.tapeRedirector = &msxTapeOutFile
cpu.addHook = &msxTapeOutHook

MsxTapeOutHeaderHook msxTapeOutShortHeaderHook = 0xF6D3
msxTapeOutShortHeaderHook.tapeRedirector = &msxTapeOutFile
cpu.addHook = &msxTapeOutShortHeaderHook

MsxTapeOutHeaderHook msxTapeOutLongHeaderHook = 0xF6DC
msxTapeOutLongHeaderHook.tapeRedirector = &msxTapeOutFile
cpu.addHook = &msxTapeOutLongHeaderHook

MsxTapeInHook msxTapeInHook = 0xF536
msxTapeInHook.tapeRedirector = &msxTapeInFile
#msxTapeInHook.ignoreHeaders = yes
msxTapeInHook.apogeyFix = yes
cpu.addHook = &msxTapeInHook

MsxTapeInHeaderHook msxTapeInLongHeaderHook = 0xF5C6
msxTapeInLongHeaderHook.tapeRedirector = &msxTapeInFile
cpu.addHook = &msxTapeInLongHeaderHook

CloseFileHook closeFileHook = 0xFE61
closeFileHook.addTapeRedirector = &tapeInFile
closeFileHook.addTapeRedirector = &tapeOutFile
closeFileHook.addTapeRedirector = &msxTapeInFile
closeFileHook.addTapeRedirector = &msxTapeOutFile
cpu.addHook = &closeFileHook

EmuObjectGroup tapeGrp
tapeGrp.addItem = &tapeInHook
tapeGrp.addItem = &tapeOutHook
tapeGrp.addItem = &msxTapeInHook
tapeGrp.addItem = &msxTapeInLongHeaderHook
tapeGrp.addItem = &msxTapeOutHook
tapeGrp.addItem = &msxTapeOutShortHeaderHook
tapeGrp.addItem = &msxTapeOutLongHeaderHook
tapeGrp.addItem = &closeFileHook
#tapeGrp.enabled = no



######## Include Saved Options ########

include @OPT_FILE



######## Configuration Window ########

ConfigTab configTab = @NAME
configTab.optFileName = @OPT_FILE

#window.frameScale
ConfigRadioSelector scaleSelector = &window, frameScale, "Масштабирование"
scaleSelector.addItem = 1x, "1x"
scaleSelector.addItem = 2x, "2x"
scaleSelector.addItem = 3x, "3x"
scaleSelector.addItem = 4x, "4x"
scaleSelector.addItem = 5x, "5x"
scaleSelector.addItem = fit, "Растянуть во все окно"
scaleSelector.addItem = bestFit, "Растянуть с целым коэффициентом"
configTab.addControl = 1, &scaleSelector

#window.windowStyle
ConfigRadioSelector styleSelector = &window, windowStyle, "Размер окна"
styleSelector.addItem = autosize, "Автоматически подстраивать"
styleSelector.addItem = resizable, "Изменяемый пользователем"
styleSelector.addItem = fixed, "Фиксированный"
configTab.addControl = 1, &styleSelector

#window.smoothing
ConfigRadioSelector smSelector = &window, smoothing, "Сглаживание"
smSelector.addItem = nearest, "Выкл."
smSelector.addItem = bilinear, "Билинейное"
smSelector.addItem = sharp, "Границы пикселей (рекомендуется)"
configTab.addControl = 1, &smSelector

#window.aspectCorrection
ConfigRadioSelector arSelector = &window, aspectCorrection, "Учитывать Aspect Ratio"
arSelector.addItem = no, "Нет (1:1)"
arSelector.addItem = yes, "Оригинальный AR"
configTab.addControl = 2, &arSelector

#window.wideScreen
ConfigRadioSelector wsSelector = &window, wideScreen, "Формат экрана"
wsSelector.addItem = no, "4:3"
wsSelector.addItem = yes, "16:9"
wsSelector.addItem = custom, "Пользовательский"
configTab.addControl = 2, &wsSelector

#crtRenderer.visibleArea
ConfigRadioSelector cropSelector = &crtRenderer, visibleArea, "Отображать только видимую область"
cropSelector.addItem = no, "Нет"
cropSelector.addItem = yes, "Да"
configTab.addControl = 2, &cropSelector

#window.fieldsMixing
ConfigRadioSelector mixSelector = &window, fieldsMixing, "Смешивание полукадров"
mixSelector.addItem = none, "Выкл."
mixSelector.addItem = mix, "Вкл."
mixSelector.addItem = average, "Усреднять (старый метод)"
mixSelector.addItem = interlace, "Чередование"
mixSelector.addItem = scanline, "Имитация линий растра"
configTab.addControl = 1, &mixSelector

#crtRenderer.altRenderer
ConfigRadioSelector rendSelector = &crtRenderer, altRenderer, "Шрифт ВГ8275"
rendSelector.addItem = no, "Оригинальный шрифт"
rendSelector.addItem = yes, "8×16 / 8×12 / 8×8"
configTab.addControl = 2, &rendSelector

#crtRenderer.colorMode
ConfigRadioSelector colorSelector = &crtRenderer, colorMode, "Режим цвета"
colorSelector.addItem = color, "Цветной"
colorSelector.addItem = mono, "Ч/б"
colorSelector.addItem = grayscale, "Градации серого"
configTab.addControl = 2, &colorSelector

#kbdLayout.layout
ConfigRadioSelector laSelector = &kbdLayout, layout, "Раскладка клавиатуры"
laSelector.addItem = qwerty, "Qwerty"
laSelector.addItem = jcuken, "Йцукен"
laSelector.addItem = smart, "«Умная» раскладка"
configTab.addControl = 3, &laSelector

#tapeGrp.enabled
ConfigRadioSelector tapeSelector = &tapeGrp, enabled, "Перехват обращений к магнитофону"
tapeSelector.addItem = yes, "Вкл."
tapeSelector.addItem = no, "Выкл."
configTab.addControl = 3, &tapeSelector

#platform.codePage
ConfigRadioSelector codePageSelector = &platform, codePage, "Таблица символов отладчика"
codePageSelector.addItem = rk, "РК-86"
codePageSelector.addItem = koi8, "КОИ-8"
configTab.addControl = 3, &codePageSelector
