diff --git a/CMakeLists.txt b/CMakeLists.txt index be00455..abc7978 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ project(vinace VERSION 0.1) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + find_package(PkgConfig REQUIRED) pkg_check_modules(GTKMM REQUIRED gtkmm-2.4) find_package(Threads REQUIRED) @@ -21,4 +23,3 @@ include_directories(${PULSEAUDIO_INCLUDE_DIRS}) add_subdirectory(src) - diff --git a/src/gui/resources/closed.jpg b/resources/closed.jpg similarity index 100% rename from src/gui/resources/closed.jpg rename to resources/closed.jpg diff --git a/src/gui/resources/colormon.jpg b/resources/colormon.jpg similarity index 100% rename from src/gui/resources/colormon.jpg rename to resources/colormon.jpg diff --git a/src/gui/resources/drive_1.jpg b/resources/drive_1.jpg similarity index 100% rename from src/gui/resources/drive_1.jpg rename to resources/drive_1.jpg diff --git a/src/gui/resources/drive_2.jpg b/resources/drive_2.jpg similarity index 100% rename from src/gui/resources/drive_2.jpg rename to resources/drive_2.jpg diff --git a/src/gui/resources/monitor.jpg b/resources/monitor.jpg similarity index 100% rename from src/gui/resources/monitor.jpg rename to resources/monitor.jpg diff --git a/src/gui/resources/on.jpg b/resources/on.jpg similarity index 100% rename from src/gui/resources/on.jpg rename to resources/on.jpg diff --git a/roms/put your ROM files here b/roms/put your ROM files here new file mode 100644 index 0000000..e69de29 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3b71cbc..46b0c2e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,6 +18,7 @@ set(SOURCE_FILES ${CORE_SOURCE_FILES} ${HARDWARE_SOURCE_FILES} ${GUI_SOURCE_FILES} + ${CMAKE_CURRENT_SOURCE_DIR}/main.cc ) add_executable(vinace ${SOURCE_FILES}) diff --git a/src/config.h.in b/src/config.h.in index 20cbf2a..01747eb 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -2,3 +2,6 @@ #define VINACE_VERSION_MINOR @vinace_VERSION_MINOR@ #define VINACE_FULL_NAME "Vinace v@vinace_VERSION_MAJOR@.@vinace_VERSION_MINOR@" + +#define RESOURCE_DIR "resources/" +#define ROM_DIR "roms/" diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 36fdb13..2893044 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -7,7 +7,6 @@ set(GUI_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/c-gui-numpad-joystick.cpp ${CMAKE_CURRENT_SOURCE_DIR}/c-pulse-audio-sound.cpp ${CMAKE_CURRENT_SOURCE_DIR}/c-sound.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/main.cc PARENT_SCOPE ) diff --git a/src/gui/main.cc b/src/gui/main.cc deleted file mode 100644 index 651d6ff..0000000 --- a/src/gui/main.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ -/* - * Vinace - * Copyright (C) P.Y. Rollo 2009 - * - * Vinace is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Vinace is distributed in the hope that it will be useful, 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 along - * with this program. If not, see . - */ - -#include -#include "hardware/models/c-apple2e-hardware.hpp" -#include "hardware/cards/c-disk-controler-card.hpp" -#include "hardware/c-disk-drive.hpp" -#include "c-gui-green-monitor.hpp" -#include "c-gui-color-monitor.hpp" -#include "c-gui-keyboard.hpp" -#include "c-gui-numpad-joystick.hpp" -#include "c-gui-disk-drive.hpp" -#include "c-pulse-audio-sound.hpp" -#include -#include -#include "config.h" - -void load_rom(CRomMemory *rom, const char *filename, int offset) { - std::ifstream file (filename, std::ios::in|std::ios::binary); - if (file.is_open()) - { - file.seekg(offset); - file.read((char *)rom->get_buffer(), rom->get_size()); - file.close(); - } - else - std::cout << "Unable to load ROM file \"" << filename << "\"." << std::endl; -} - -int main(int argc, char *argv[]) -{ - // Read rom file - CRomMemory *lcRom = new CRomMemory(0x3000); - CRomMemory *intRom = new CRomMemory(0x1000); - CRomMemory *diskRom = new CRomMemory(0x0100); - - load_rom(lcRom, "APPLE2E.ROM", 0x5000); - load_rom(intRom, "APPLE2E.ROM", 0x4000); - load_rom(diskRom, "APPLE2E.ROM", 0x0600); - - // Build an Apple //e - CApple2eHardware *apple = new CApple2eHardware(lcRom, intRom); - CDiskControlerCard *controler = new CDiskControlerCard(diskRom); - apple->insertCard(6, controler); - CDiskDrive *drive1 = new CDiskDrive(apple->get_clock(), controler->get_interface(0)); - CDiskDrive *drive2 = new CDiskDrive(apple->get_clock(), controler->get_interface(1)); - - // Build GUI - Gtk::Main main(argc, argv); - Gtk::Window window; - window.set_title(VINACE_FULL_NAME); - - Gtk::VBox box; - window.add(box); - - box.property_can_focus().set_value(true); - box.set_sensitive(); - box.grab_focus(); - - CGuiMonitor *monitor = new CGuiColorMonitor(apple->colorvideo); - box.add(*monitor); - - Gtk::HBox drivebox; - box.add(drivebox); - CGuiDiskDrive *gdrive1 = new CGuiDiskDrive(drive1, false); - drivebox.add(*gdrive1); - CGuiDiskDrive *gdrive2 = new CGuiDiskDrive(drive2, true); - drivebox.add(*gdrive2); - - CGuiKeyboard *keyboard = new CGuiKeyboard(&box, apple->keyboard); - CGuiNumpadJoystick *joystick = new CGuiNumpadJoystick(&box, apple->paddles); - - CPulseAudioSound *sound = new CPulseAudioSound(apple->speaker); - - window.show_all(); - - // Run ! - sound->start(); - apple->start(); - main.run(window); - - // Delete roms - delete lcRom; - delete intRom; - delete diskRom; - - return 0; -} diff --git a/src/main.cc b/src/main.cc index f981ca4..38a1fbc 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,33 +1,104 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* - * main.cc + * Vinace * Copyright (C) P.Y. Rollo 2009 - * - * main.cc is free software: you can redistribute it and/or modify it + * + * Vinace is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * - * main.cc is distributed in the hope that it will be useful, but + * + * Vinace is distributed in the hope that it will be useful, 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 along * with this program. If not, see . */ #include #include "hardware/models/c-apple2e-hardware.hpp" +#include "hardware/cards/c-disk-controler-card.hpp" +#include "hardware/c-disk-drive.hpp" +#include "gui/c-gui-green-monitor.hpp" +#include "gui/c-gui-color-monitor.hpp" +#include "gui/c-gui-keyboard.hpp" +#include "gui/c-gui-numpad-joystick.hpp" +#include "gui/c-gui-disk-drive.hpp" +#include "gui/c-pulse-audio-sound.hpp" +#include +#include +#include "config.h" + +void load_rom(CRomMemory *rom, const char *filename, int offset) { + std::ifstream file (filename, std::ios::in|std::ios::binary); + if (file.is_open()) + { + file.seekg(offset); + file.read((char *)rom->get_buffer(), rom->get_size()); + file.close(); + } + else + std::cout << "Unable to load ROM file \"" << filename << "\"." << std::endl; +} int main(int argc, char *argv[]) { - - CApple2eHardware *apple = new CApple2eHardware("APPLE2E.ROM"); - apple->start(); - + // Read rom file + CRomMemory *lcRom = new CRomMemory(0x3000); + CRomMemory *intRom = new CRomMemory(0x1000); + CRomMemory *diskRom = new CRomMemory(0x0100); + + load_rom(lcRom, ROM_DIR "APPLE2E.ROM", 0x5000); + load_rom(intRom, ROM_DIR "APPLE2E.ROM", 0x4000); + load_rom(diskRom, ROM_DIR "APPLE2E.ROM", 0x0600); + + // Build an Apple //e + CApple2eHardware *apple = new CApple2eHardware(lcRom, intRom); + CDiskControlerCard *controler = new CDiskControlerCard(diskRom); + apple->insertCard(6, controler); + CDiskDrive *drive1 = new CDiskDrive(apple->get_clock(), controler->get_interface(0)); + CDiskDrive *drive2 = new CDiskDrive(apple->get_clock(), controler->get_interface(1)); + + // Build GUI Gtk::Main main(argc, argv); Gtk::Window window; - main.run(window); + window.set_title(VINACE_FULL_NAME); + + Gtk::VBox box; + window.add(box); + + box.property_can_focus().set_value(true); + box.set_sensitive(); + box.grab_focus(); + + CGuiMonitor *monitor = new CGuiColorMonitor(apple->colorvideo); + box.add(*monitor); + + Gtk::HBox drivebox; + box.add(drivebox); + CGuiDiskDrive *gdrive1 = new CGuiDiskDrive(drive1, false); + drivebox.add(*gdrive1); + CGuiDiskDrive *gdrive2 = new CGuiDiskDrive(drive2, true); + drivebox.add(*gdrive2); + + CGuiKeyboard *keyboard = new CGuiKeyboard(&box, apple->keyboard); + CGuiNumpadJoystick *joystick = new CGuiNumpadJoystick(&box, apple->paddles); + + CPulseAudioSound *sound = new CPulseAudioSound(apple->speaker); + + window.show_all(); + + // Run ! + sound->start(); + apple->start(); + main.run(window); + + // Delete roms + delete lcRom; + delete intRom; + delete diskRom; + return 0; }