twoapple-reboot/src/twoapple.d

101 lines
2.7 KiB
D
Raw Normal View History

2012-03-14 00:43:29 +00:00
//@ //////////////////////////////////////////////////////////////////////////
//@ Copyright: 2007 Gerald Stocker
//@
2012-03-15 06:21:12 +00:00
//@ This file is part of twoapple-reboot.
2012-03-14 00:43:29 +00:00
//@
2012-03-15 06:21:12 +00:00
//@ twoapple-reboot is free software; you can redistribute it and/or modify
2012-03-14 00:43:29 +00:00
//@ it under the terms of the GNU General Public License as published by
//@ the Free Software Foundation; either version 2 of the License, or
//@ (at your option) any later version.
//@
2012-03-15 06:21:12 +00:00
//@ twoapple-reboot is distributed in the hope that it will be useful,
2012-03-14 00:43:29 +00:00
//@ but WITHOUT ANY WARRANTY; without even the implied warranty of
//@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//@ GNU General Public License for more details.
//@
//@ You should have received a copy of the GNU General Public License
2012-03-15 06:21:12 +00:00
//@ along with twoapple-reboot; if not, write to the Free Software
2012-03-14 00:43:29 +00:00
//@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//@ //////////////////////////////////////////////////////////////////////////
import std.stdio;
2012-04-14 11:28:11 +00:00
import cpu.d6502;
2012-03-14 00:43:29 +00:00
import timer;
import memory;
import system.base;
import ui.monitor;
import ui.sound;
import ui.inputevents;
import gthread.Thread;
2012-03-14 12:24:35 +00:00
import gtk.Main;
2012-03-14 00:43:29 +00:00
import glgdk.GLdInit;
import gtkc.gdktypes;
import gtkc.gtktypes;
import peripheral.base;
import peripheral.diskii;
import peripheral.langcard;
import peripheral.saturn128;
import std.file;
import std.string;
import device.speaker;
import ui.mainwindow;
import video.laz_engine;
// XXX Only needed for initializing peripheralStatus
import gtk.VBox;
import peripheral.base;
void main(string[] args)
{
// Init GTK
Thread.init(null);
2012-03-15 06:45:30 +00:00
Main.init(args);
GLdInit.init(args);
2012-03-14 00:43:29 +00:00
// open config
input = new Input();
monitor = new Monitor();
auto screen = new LazEngine();
monitor.installScreen(screen);
// XXX should make it so this can happen after system?
peripheralStatus = new VBox(false, 3);
appWindow = new TwoappleMainWindow();
// Get ROM file
TwoappleFile romFile = TwoappleFilePicker.open("ROM file", &checkRomFile);
if (romFile is null) return;
2012-04-14 11:28:11 +00:00
SystemBase sys;
2012-03-14 00:43:29 +00:00
if ((args.length > 1) && (args[1] == "--iie"))
2012-04-14 11:28:11 +00:00
sys = new System!"65C02"(cast(ubyte[])std.file.read(romFile.fileName));
2012-03-14 00:43:29 +00:00
else
2012-04-14 11:28:11 +00:00
sys = new System!"6502"(cast(ubyte[])std.file.read(romFile.fileName));
2012-03-14 00:43:29 +00:00
appWindow.initSystem(sys);
// XXX hack
appWindow.configChanged = true;
debug(disassemble)
{
input.pauseButton.setActive(true);
}
appWindow.mainLoop();
// save config
}
string checkRomFile(TwoappleFile checkFile)
{
ulong fsize = checkFile.fileSize();
// XXX allow 12288 for II/II+ ?
if (fsize >= 20480 && fsize <= 32768)
return null;
else
return "Invalid ROM file";
}