From 617bad3e519c9dd71023e65b39eb4d4c83c02046 Mon Sep 17 00:00:00 2001 From: "Christopher A. Mosher" Date: Thu, 3 Nov 2022 01:07:39 -0400 Subject: [PATCH] add USE_EMU as build option; slight refactor build --- CMakeLists.txt | 6 +++++- src/CMakeLists.txt | 25 ++++++++++++++++--------- src/apple2.cpp | 2 +- src/apple2.h | 13 +++++-------- src/configep2.cpp | 6 ++++++ 5 files changed, 33 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e409db3..a467817 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.22.1) -set(CMAKE_VERBOSE_MAKEFILE ON) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +set(CMAKE_FIND_DEBUG_MODE TRUE) + project(epple2) + include(GNUInstallDirs) + add_subdirectory(src) add_subdirectory(conf) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8fb027f..0831653 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,3 @@ -set(CMAKE_FIND_DEBUG_MODE 1) - -find_package(SDL2 CONFIG) -include_directories(${SDL2_INCLUDE_DIRS}) -message("SDL2_INCLUDE_DIRS: ${SDL2_INCLUDE_DIRS}") -message("SDL2_LIBRARIES: ${SDL2_LIBRARIES}") - set(sources a2colorsobserved.cpp addressbus.cpp @@ -76,6 +69,20 @@ wozfile.cpp ) add_executable(epple2 ${sources}) -target_compile_features(epple2 PUBLIC cxx_std_17) -target_compile_definitions(epple2 PUBLIC ETCDIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}") + +find_package(SDL2 CONFIG) +message(STATUS "SDL2_INCLUDE_DIRS: ${SDL2_INCLUDE_DIRS}") +message(STATUS "SDL2_LIBRARIES: ${SDL2_LIBRARIES}") +target_include_directories(epple2 PRIVATE ${SDL2_INCLUDE_DIRS}) target_link_libraries(epple2 ${SDL2_LIBRARIES}) + +target_compile_features(epple2 PRIVATE cxx_std_17) +target_compile_definitions(epple2 PRIVATE ETCDIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}") + +option(USE_EMU "Use http://www.visual6502.org/ CPU (will run slowly)") +if (USE_EMU) + message(STATUS "USE_EMU") + target_compile_definitions(epple2 PRIVATE USE_EMU) + # target_compile_definitions(epple2 PRIVATE TRACESEG) + target_compile_definitions(epple2 PRIVATE TRACEREG) +endif() diff --git a/src/apple2.cpp b/src/apple2.cpp index 5cb34f6..12ca666 100644 --- a/src/apple2.cpp +++ b/src/apple2.cpp @@ -52,7 +52,7 @@ Apple2::Apple2(KeypressQueue& keypresses, PaddleButtonStates& paddleButtonStates transistors("transistors"), cpu(transistors,addressBus), #else - cpu(addressBus), + cpu(addressBus), #endif powerUpReset(*this), revision(1) diff --git a/src/apple2.h b/src/apple2.h index 33b2596..69e721f 100644 --- a/src/apple2.h +++ b/src/apple2.h @@ -41,9 +41,6 @@ class Emulator; class ScreenImage; -//#define USE_EMU 1 -#undef USE_EMU - class Apple2 : public Timable { Slots slts; @@ -52,10 +49,10 @@ class Apple2 : public Timable Paddles paddles; SpeakerClicker speaker; Memory rom; - MemoryRandomAccess ram; - CassetteIn cassetteIn; - CassetteOut cassetteOut; - AddressBus addressBus; + MemoryRandomAccess ram; + CassetteIn cassetteIn; + CassetteOut cassetteOut; + AddressBus addressBus; PictureGenerator picgen; TextCharacters textRows; Video video; @@ -63,7 +60,7 @@ class Apple2 : public Timable std::ifstream transistors; Emu6502 cpu; #else - CPU cpu; + CPU cpu; #endif PowerUpReset powerUpReset; int revision; diff --git a/src/configep2.cpp b/src/configep2.cpp index 8093333..b2f2d84 100644 --- a/src/configep2.cpp +++ b/src/configep2.cpp @@ -95,6 +95,12 @@ static void trim(std::string& str) void Config::parse(MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revision, ScreenImage& gui, CassetteIn& cassetteIn, CassetteOut& cassetteOut) { +#ifdef USE_EMU + std::cout << "Running with http://www.visual6502.org/ CPU emulation (which will be slow)." << std::endl; +#endif + + + std::ifstream* pConfig; std::string path(this->file_path);