add USE_EMU as build option; slight refactor build

This commit is contained in:
Christopher A. Mosher 2022-11-03 01:07:39 -04:00
parent 7059628f52
commit 617bad3e51
5 changed files with 33 additions and 19 deletions

View File

@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.22.1) 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) project(epple2)
include(GNUInstallDirs) include(GNUInstallDirs)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(conf) add_subdirectory(conf)

View File

@ -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 set(sources
a2colorsobserved.cpp a2colorsobserved.cpp
addressbus.cpp addressbus.cpp
@ -76,6 +69,20 @@ wozfile.cpp
) )
add_executable(epple2 ${sources}) 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_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()

View File

@ -52,7 +52,7 @@ Apple2::Apple2(KeypressQueue& keypresses, PaddleButtonStates& paddleButtonStates
transistors("transistors"), transistors("transistors"),
cpu(transistors,addressBus), cpu(transistors,addressBus),
#else #else
cpu(addressBus), cpu(addressBus),
#endif #endif
powerUpReset(*this), powerUpReset(*this),
revision(1) revision(1)

View File

@ -41,9 +41,6 @@
class Emulator; class Emulator;
class ScreenImage; class ScreenImage;
//#define USE_EMU 1
#undef USE_EMU
class Apple2 : public Timable class Apple2 : public Timable
{ {
Slots slts; Slots slts;
@ -52,10 +49,10 @@ class Apple2 : public Timable
Paddles paddles; Paddles paddles;
SpeakerClicker speaker; SpeakerClicker speaker;
Memory rom; Memory rom;
MemoryRandomAccess ram; MemoryRandomAccess ram;
CassetteIn cassetteIn; CassetteIn cassetteIn;
CassetteOut cassetteOut; CassetteOut cassetteOut;
AddressBus addressBus; AddressBus addressBus;
PictureGenerator picgen; PictureGenerator picgen;
TextCharacters textRows; TextCharacters textRows;
Video video; Video video;
@ -63,7 +60,7 @@ class Apple2 : public Timable
std::ifstream transistors; std::ifstream transistors;
Emu6502 cpu; Emu6502 cpu;
#else #else
CPU cpu; CPU cpu;
#endif #endif
PowerUpReset powerUpReset; PowerUpReset powerUpReset;
int revision; int revision;

View File

@ -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) 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::ifstream* pConfig;
std::string path(this->file_path); std::string path(this->file_path);