
;////////////////////////////////////////////////////////////////
;////////////////////////////////////////////////////////////////
[vdmgrfileinfo]
name    = "SEGA MARKIII/SEGA MASTER SYSTEM"
version = 0.01
lang    = sc-3000


;////////////////////////////////////////////////////////////////
;////////////////////////////////////////////////////////////////
[module]
window           = window("SEGA MARKIII/SEGA MASTER SYSTEM", 16,  16, 256, 192, 1)
viewwindow       = window("NAME/SPR/PTN/COL",               -16,  16, 512, 256, 0)
fftwindow        = window("FFT/Wave",                       -16, 312, 440, 240, 0)
drecwindow       = window("Data Recorder",                   16,  64, 352,  80, 0)
clockgen         = clockgen(10738635)
cpu              = z80(3)
board            = sc-3000(1)
segagraphicboard = segagraphicboard()
rom              = sega.rom
vdp              = 315-5124()
sn76489          = sn76489(3579545)
ym2413           = ym2413(3579545)
sk-1100          = sk-1100()
sk-1100.i8255    = i8255()
datarecorder     = datarecorder()
fftwave          = fftwave()
bitmap           = bitmap("resource/fftwave.bmp")
menu_open        = menu("ROM(&R)", $16425, $54, -, $55, "SEGA Mapper(&S)", "Codemasters Mapper(&C)", ?, $51, -, "NO RAM(&N)","RAM 2KB(&1)", "RAM 8KB(&2)", "RAM 16KB(&3)", "RAM 32KB(&4)", "RAM 64KB(&5)")
menu_datarec     = menu($36, $37, $38, $39)
menu_disp        = menu($30, $31, $40, $32)
menu_machine     = menu($56, ?, ?, ?, ?, "SEGA MARKIII(&1)", "MASTER SYSTEM(&2)")
menu_ext         = menu($33, $34, $35, "SEGA GRAPHIC BOARD(&G)", $45)
filereader       = filereader(1)
assembler        = assembler(0)
filesel_open     = filesel(open|reset|history, $10, "sc;sg;omv;sms;zip", filereader.bin, rom.download, 0x00000, 0x400200)
filesel_asm      = filesel(open|reset|history, $19, "asm;s",             assembler.asm,  rom.download, 0x00000, 0x400000)
filesel_openwav  = filesel(open|history,       $11, "wav;zip")
filesel_savewav  = filesel(save,               $11, "wav")
filesel_instape  = filesel(open|save,          $11, "wav;zip")


;////////////////////////////////////////////////////////////////
;////////////////////////////////////////////////////////////////
[init]
datarecorder.file = "resource/datarecorder.bmp"
fftwave.ch2.level = 300


;////////////////////////////////////////////////////////////////
;////////////////////////////////////////////////////////////////
[assign]
menu_open(1)                          = filesel_open
menu_open(1)                          = filesel_asm
menu_datarec(1)                       = filesel_openwav
menu_datarec(2)                       = filesel_savewav

sk-1100.load                          = datarecorder.output
sk-1100.datarecorder                  = datarecorder
sk-1100.i8255.PA                      = sk-1100.PA
sk-1100.i8255.PB                      = sk-1100.PB
sk-1100.i8255.PC                      = sk-1100.PC
sk-1100.input                         = window.input

datarecorder.filesel                  = filesel_instape
datarecorder.window                   = drecwindow.window
datarecorder.menu                     = menu_datarec.menu
datarecorder.input                    = sk-1100.save

segagraphicboard.window               = window.window
segagraphicboard.input                = window.input

cpu.memory                            = board.memory
cpu.io                                = board.io
cpu./NMI                              = board./NMI
cpu./INT                              = vdp./INT

rom.menu                              = menu_open.menu
rom.window                            = window.window

board.prop.machine                    = rom.prop.machine
board.menu.machine                    = menu_machine.menu
board.menu.extslot                    = menu_ext.menu
board.input                           = window.input
board.module.SK-1100                  = sk-1100
board.memory                          = rom.memory
board.io                              = rom.io
board.vdp                             = vdp.addressbus
board.SN76489                         = sn76489.addressbus
board.YM2413                          = ym2413.addressbus
board./PAUSE                          = window.input.b12
board./MREQ                           = rom./MREQ
board./DSRAM                          = rom./DSRAM
board./JOYSEL                         = sk-1100./JOYSEL
board.SK-1100                         = sk-1100.i8255.addressbus
board.segagraphicboard                = segagraphicboard.port

fftwindow.image                       = bitmap.imagegen
fftwave.window                        = fftwindow.window
fftwave.ch1.soundgen                  = sn76489.soundgen
fftwave.ch2.soundgen                  = ym2413.soundgen

window.image                          = vdp.imagegen
window.sound                          = fftwave.soundgen

viewwindow.image                      = vdp.view.imagegen
drecwindow.image                      = datarecorder.imagegen

vdp.menu                              = menu_disp.menu
vdp.window                            = window.window
vdp.view.window                       = viewwindow.window


;////////////////////////////////////////////////////////////////
;////////////////////////////////////////////////////////////////
[reset]
cpu.SP = 0xfffc


;////////////////////////////////////////////////////////////////
;////////////////////////////////////////////////////////////////
[setup]
vdmgr = clockgen(clockgen.clk)
vdmgr = menu(file,  menu_open)
vdmgr = menu(file , menu_datarec)
vdmgr = menu(setup, menu_disp)
vdmgr = menu(setup, menu_machine)
vdmgr = menu(setup, menu_ext)
vdmgr = cpuctrl("Z80", cpu.cpuctrl)
vdmgr = registerctrl("Z80", cpu.registerctrl)
vdmgr = registerctrl("VDP", vdp.registerctrl)
vdmgr = registerctrl("SN76489", sn76489.registerctrl)
vdmgr = memoryctrl("Z80", cpu.memoryctrl)
vdmgr = memoryctrl("VDP", vdp.memoryctrl)


;////////////////////////////////////////////////////////////////
;////////////////////////////////////////////////////////////////
[selectfile]
board.file.MK-2000 = "MASTER SYSTEM IPL", "bios/sms.rom"
rom.file.database  = "ROM Database",      "resource/db/sc-3000.csv"


;////////////////////////////////////////////////////////////////
;////////////////////////////////////////////////////////////////
[save]
state = board.state
state = rom.state
state = vdp.state
state = viewwindow.state
state = fftwindow.state
state = drecwindow.state
image = rom.image


;////////////////////////////////////////////////////////////////
;////////////////////////////////////////////////////////////////
[keyconfig]
key0  = 0xc8, $100
key1  = 0xd0, $101
key2  = 0xcb, $102
key3  = 0xcd, $103
key4  = 0x2c, $104
key5  = 0x2d, $105
key6  = 0x00, $106
key7  = 0x00, $107
key8  = 0x00, $108
key9  = 0x00, $109
key10 = 0x00, $110
key11 = 0x00, $111
key12 = 0x0f, "PAUSE"
key13 = 0xc5, "BREAK"
key14 = 0x01, "FUNC"
key15 = 0x1d, "CTRL"
key16 = 0x1c, "CR"
key17 = 0x2a, "L SHIFT"
key18 = 0x36, "R SHIFT"
key19 = 0x38, "GRAPH"
key20 = 0x7b, $112
key21 = 0x39, "SPACE"
key22 = 0xc7, "HOME CLR"
key23 = 0x0e, "INS DEL"
key24 = 0xcb, "LEFT"
key25 = 0xcd, "RIGHT"
key26 = 0xc8, "UP"
key27 = 0xd0, "DOWN"
key28 = 0x02, "1"
key29 = 0x03, "2"
key30 = 0x04, "3"
key31 = 0x05, "4"
key32 = 0x06, "5"
key33 = 0x07, "6"
key34 = 0x08, "7"
key35 = 0x09, "8"
key36 = 0x0a, "9/#"
key37 = 0x0b, "0/*"
key38 = 0x0c, "-"
key39 = 0x90, "^"
key40 = 0x7d, "\"
key41 = 0x10, "Q"
key42 = 0x11, "W"
key43 = 0x12, "E"
key44 = 0x13, "R"
key45 = 0x14, "T"
key46 = 0x15, "Y"
key47 = 0x16, "U"
key48 = 0x17, "I"
key49 = 0x18, "O"
key50 = 0x19, "P"
key51 = 0x91, "@"
key52 = 0x1a, "["
key53 = 0x1e, "A"
key54 = 0x1f, "S"
key55 = 0x20, "D"
key56 = 0x21, "F"
key57 = 0x22, "G"
key58 = 0x23, "H"
key59 = 0x24, "J"
key60 = 0x25, "K"
key61 = 0x26, "L"
key62 = 0x27, ";"
key63 = 0x92, ":"
key64 = 0x1b, "]"
key65 = 0x2c, "Z"
key66 = 0x2d, "X"
key67 = 0x2e, "C"
key68 = 0x2f, "V"
key69 = 0x30, "B"
key70 = 0x31, "N"
key71 = 0x32, "M"
key72 = 0x33, "<"
key73 = 0x34, ">"
key74 = 0x35, "/"
key75 = 0x2b, "PI"
