@NAME = "Специалист SP580"


#define USE_COPIER

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

# Основное ПЗУ и адреса перехвата
@ROM1 = "sp580/sp580.bin"
@ROM2 = "sp580/sp580a.bin"

#@F806_ADDR = 0xFDEB
#@F80C_ADDR = 0xFD9A
@F803_ADDR = 0xC337

# Тактовая частота
@CPU_FREQUENCY = 2000000

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



######## 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 = 0x9000
SpecVideoRam videoRam = 0x3000

Rom rom1 = @ROM1, 0x0800
Rom rom2 = @ROM2, 0x0800

Ppi8255 ppi1
Ppi8255 ppi2

Pit8253 pit
pit.frequency = @CPU_FREQUENCY

RkPit8253SoundSource sndSource
sndSource.pit = &pit

AddrSpace addrSpace
addrSpace.range = &ram,      0x0000, 0x8FFF
addrSpace.range = &videoRam, 0x9000, 0xBFFF
addrSpace.range = &rom1,     0xC000, 0xDFFF
addrSpace.range = &pit,      0xE000, 0xE7FF
addrSpace.range = &ppi1,     0xE800, 0xEFFF
addrSpace.range = &ppi2,     0xF000, 0xF7FF
addrSpace.range = &rom2,     0xF800, 0xFFFF

SpecRenderer crtRenderer
crtRenderer.screenMemory = &videoRam
crtRenderer.colorMode = mono

SpecCore core
core.window = &window
core.crtRenderer = &crtRenderer

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

GeneralSoundSource tapeSoundSource
#tapeSoundSource.muted = yes
GeneralSoundSource beepSoundSource

SpecKbdLayout kbdLayout
kbdLayout.layout = smart

SpecKeyboard keyboard
keyboard.matrix = "sp580"

SpecPpi8255Circuit ppiCircuit
ppiCircuit.specKeyboard = &keyboard
ppiCircuit.videoRam = &videoRam
ppiCircuit.tapeSoundSource = &tapeSoundSource
ppiCircuit.beepSoundSource = &beepSoundSource

ppi2.circuit = &ppiCircuit



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

# Internal Loader

Sp580FileLoader loader
loader.addrSpace = &addrSpace
loader.filter = "Файлы SP-580 (*.tsx, *.cas)|*.tsx;*.TSX;*.cas;*.CAS|Файлы Специалиста (*.rks)|*.rks;*.RKS|Все файлы (*.*)|*"
loader.allowMultiblock = yes


# MSX tape hooks

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

TapeRedirector tapeInFile
tapeInFile.mode = "r"
tapeInFile.filter = "Cas-файлы MSX (*.cas)|*.cas;*.CAS|TSX-файлы MSX (*.tsx)|*.tsx;*.TSX|Все файлы (*.*)|*"
tapeInFile.timeout = 15000
loader.tapeRedirector = &tapeInFile

MsxTapeOutHook tapeOutHook = 0xFE56
tapeOutHook.outReg = C
tapeOutHook.tapeRedirector = &tapeOutFile
cpu.addHook = &tapeOutHook

MsxTapeOutHeaderHook tapeOutHeaderHook = 0xFE40
tapeOutHeaderHook.tapeRedirector = &tapeOutFile
cpu.addHook = &tapeOutHeaderHook

MsxTapeInHook tapeInHook = 0xC4D9
tapeInHook.tapeRedirector = &tapeInFile
cpu.addHook = &tapeInHook

MsxTapeInHeaderHook tapeInHeaderHook = 0xC463
tapeInHeaderHook.tapeRedirector = &tapeInFile
cpu.addHook = &tapeInHeaderHook


# RKS tape hooks

TapeRedirector rksTapeInFile
rksTapeInFile.mode = "r"
rksTapeInFile.filter = "Файлы Специалиста (*.rks)|*.rks;*.RKS|Файлы RK-совместимых ПК (*.rk?)|*.rk;*.rk?;*.RK;*.RK?|Все файлы (*.*)|*"

RkTapeInHook rkTapeInHook = 0xC377
rkTapeInHook.tapeRedirector = &rksTapeInFile
cpu.addHook = &rkTapeInHook



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


EmuObjectGroup tapeGrp
tapeGrp.addItem = &tapeOutHook
tapeGrp.addItem = &tapeOutHeaderHook
tapeGrp.addItem = &tapeInHook
tapeGrp.addItem = &tapeInHeaderHook
tapeGrp.addItem = &rkTapeInHook
tapeGrp.addItem = &closeFileHook
tapeGrp.enabled = yes


ifdef USE_COPIER
  MsxTapeInHook copierTapeInHook = 0xBCAF
  copierTapeInHook.signature = 3AFCBF57DB
  copierTapeInHook.tapeRedirector = &tapeInFile
  cpu.addHook = &copierTapeInHook

  MsxTapeInHeaderHook copierTapeInHeaderHook = 0xBC60
  copierTapeInHeaderHook.signature = 21E80351CD
  copierTapeInHeaderHook.tapeRedirector = &tapeInFile
  cpu.addHook = &copierTapeInHeaderHook

  MsxTapeOutHook copierTapeOutHook = 0xBBDA
  copierTapeOutHook.leaveAddr = 0xBBFA
  copierTapeOutHook.tapeRedirector = &tapeOutFile
  cpu.addHook = &copierTapeOutHook

  MsxTapeOutHeaderHook copierTapeOutHeaderHook = 0xBD45
  copierTapeOutHeaderHook.tapeRedirector = &tapeOutFile
  cpu.addHook = &copierTapeOutHeaderHook

  CloseFileHook copierCloseFileHook = 0xBA00
  copierCloseFileHook.addTapeRedirector = &tapeInFile
  copierCloseFileHook.addTapeRedirector = &tapeOutFile
  cpu.addHook = &copierCloseFileHook
endif #USE_COPIER



######## 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.fieldsMixing
ConfigRadioSelector mixSelector = &window, fieldsMixing, "Смешивание полукадров"
mixSelector.addItem = none, "Выкл."
mixSelector.addItem = scanline, "Имитация линий растра"
configTab.addControl = 1, &mixSelector

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

#crtRenderer.colorMode
ConfigRadioSelector colorSelector = &crtRenderer, colorMode, "Цветовой режим"
colorSelector.addItem = mono, "Монохромный"
colorSelector.addItem = 4color, "4-цветный"
colorSelector.addItem = 8color, "8-цветный"
configTab.addControl = 2, &colorSelector

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

#kayboard.matrix
ConfigRadioSelector kbdSelector = &keyboard, matrix, "Тип клавиатуры"
kbdSelector.addItem = original, "Оригинальная"
kbdSelector.addItem = ramfos, "RAMFOS"
kbdSelector.addItem = eureka, "Eureka"
kbdSelector.addItem = lik, "Lik"
configTab.addControl = 3, &kbdSelector

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
