From 6034b9c5a4f262c7c0202faa7597bda1d5b38690 Mon Sep 17 00:00:00 2001 From: Taylor King Date: Sat, 5 Sep 2020 17:59:23 -0400 Subject: [PATCH 1/6] Fix cmakelists --- .gitignore | 1 + CMakeLists.txt | 7 +++++-- Makefile | 36 ------------------------------------ Sim.cpp | 9 +++++++++ 4 files changed, 15 insertions(+), 38 deletions(-) delete mode 100644 Makefile create mode 100644 Sim.cpp diff --git a/.gitignore b/.gitignore index bc5e0ba..389aa91 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ install_manifest.txt compile_commands.json CTestTestfile.cmake _deps +Makefile # Prerequisites *.d diff --git a/CMakeLists.txt b/CMakeLists.txt index ff51474..97bcc76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,11 @@ cmake_minimum_required(VERSION 3.10) - project(GBSim) -add_executable(GB gb.cpp) +file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/*.cpp) + + +add_executable(GB ${SRC_FILES}) +target_include_directories(GB PUBLIC ${PROJECT_SOURCE_DIR}) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) diff --git a/Makefile b/Makefile deleted file mode 100644 index c86d038..0000000 --- a/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -CC = g++ -CFLAGS = -g -c -Wall -std=c++17 -Og -INSTDIR = Instructions -OBJ = Tools.o Memory.o GBLoader.o Registers.o Pixel.o Decode.o gb.o -INST_OBJ = $(INSTDIR)/Misc.o $(INSTDIR)/Arithmetic.o $(INSTDIR)/BitOps.o - -.cpp.o: - $(CC) $(CFLAGS) $< -o $@ - -gb: $(OBJ) $(INST_OBJ) - -Decode.o: gb.h Sim.h - -Tools.o: Tools.h - -Memory.o: Memory.h Sim.h - -Registers.o: Registers.h Sim.h - -GBLoader.o: gb.h - -Pixel.o: Sim.h Pixel.h - -$(INSTDIR)/Misc.o: gb.h Sim.h - -$(INSTDIR)/BitOps.o: gb.h Sim.h - -$(INSTDIR)/Arithmetic.o: gb.h Sim.h - -gb.o: Tools.h Memory.h Registers.h Pixel.h - -clean: - rm $(OBJ) $(INST_OBJ) gb || true - -run: - make clean diff --git a/Sim.cpp b/Sim.cpp new file mode 100644 index 0000000..8afb630 --- /dev/null +++ b/Sim.cpp @@ -0,0 +1,9 @@ +#include +#include +#include +#include +#include "Sim.h" +#include "Memory.h" + +using namespace std; + From 9b83252d047bbad7efbc661916047d41af40173e Mon Sep 17 00:00:00 2001 From: Taylor King Date: Sat, 5 Sep 2020 18:11:23 -0400 Subject: [PATCH 2/6] add build.md --- BUILD.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 BUILD.md diff --git a/BUILD.md b/BUILD.md new file mode 100644 index 0000000..5f29455 --- /dev/null +++ b/BUILD.md @@ -0,0 +1,5 @@ +mkdir build +cd build +cmake .. +make +./GB From 1281bdfaee9e07e1d3e899e20ba58acbf996e671 Mon Sep 17 00:00:00 2001 From: Taylor King Date: Sat, 5 Sep 2020 18:14:40 -0400 Subject: [PATCH 3/6] Unix line endings --- BUILD.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/BUILD.md b/BUILD.md index 5f29455..a27f0ca 100644 --- a/BUILD.md +++ b/BUILD.md @@ -1,5 +1,7 @@ -mkdir build -cd build +``` +mkdir build +cd build cmake .. -make +make ./GB +``` From eac8e53575add625b21d2df59d9cc263aac3bb68 Mon Sep 17 00:00:00 2001 From: Taylor King Date: Sun, 6 Sep 2020 09:37:29 -0400 Subject: [PATCH 4/6] Add -g flag --- CMakeLists.txt | 1 + GB_build/Makefile | 178 ----------------------------------- GB_build/cmake_install.cmake | 49 ---------- 3 files changed, 1 insertion(+), 227 deletions(-) delete mode 100644 GB_build/Makefile delete mode 100644 GB_build/cmake_install.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 97bcc76..7fa4c48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/*.cpp) add_executable(GB ${SRC_FILES}) target_include_directories(GB PUBLIC ${PROJECT_SOURCE_DIR}) +add_definitions("-g") set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) diff --git a/GB_build/Makefile b/GB_build/Makefile deleted file mode 100644 index a49ddf6..0000000 --- a/GB_build/Makefile +++ /dev/null @@ -1,178 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.16 - -# Default target executed when no arguments are given to make. -default_target: all - -.PHONY : default_target - -# Allow only one "make -f Makefile2" at a time, but pass parallelism. -.NOTPARALLEL: - - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /mnt/c/Users/lefou/Desktop/cap/GBSim/Game-Boy-Sim - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /mnt/c/Users/lefou/Desktop/cap/GBSim/Game-Boy-Sim/GB_build - -#============================================================================= -# Targets provided globally by CMake. - -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/bin/cmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache - -.PHONY : rebuild_cache/fast - -# Special rule for the target edit_cache -edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..." - /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available. -.PHONY : edit_cache - -# Special rule for the target edit_cache -edit_cache/fast: edit_cache - -.PHONY : edit_cache/fast - -# The main all target -all: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /mnt/c/Users/lefou/Desktop/cap/GBSim/Game-Boy-Sim/GB_build/CMakeFiles /mnt/c/Users/lefou/Desktop/cap/GBSim/Game-Boy-Sim/GB_build/CMakeFiles/progress.marks - $(MAKE) -f CMakeFiles/Makefile2 all - $(CMAKE_COMMAND) -E cmake_progress_start /mnt/c/Users/lefou/Desktop/cap/GBSim/Game-Boy-Sim/GB_build/CMakeFiles 0 -.PHONY : all - -# The main clean target -clean: - $(MAKE) -f CMakeFiles/Makefile2 clean -.PHONY : clean - -# The main clean target -clean/fast: clean - -.PHONY : clean/fast - -# Prepare targets for installation. -preinstall: all - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall - -# Prepare targets for installation. -preinstall/fast: - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall/fast - -# clear depends -depend: - $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -.PHONY : depend - -#============================================================================= -# Target rules for targets named GB - -# Build rule for target. -GB: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 GB -.PHONY : GB - -# fast build rule for target. -GB/fast: - $(MAKE) -f CMakeFiles/GB.dir/build.make CMakeFiles/GB.dir/build -.PHONY : GB/fast - -gb.o: gb.cpp.o - -.PHONY : gb.o - -# target to build an object file -gb.cpp.o: - $(MAKE) -f CMakeFiles/GB.dir/build.make CMakeFiles/GB.dir/gb.cpp.o -.PHONY : gb.cpp.o - -gb.i: gb.cpp.i - -.PHONY : gb.i - -# target to preprocess a source file -gb.cpp.i: - $(MAKE) -f CMakeFiles/GB.dir/build.make CMakeFiles/GB.dir/gb.cpp.i -.PHONY : gb.cpp.i - -gb.s: gb.cpp.s - -.PHONY : gb.s - -# target to generate assembly for a file -gb.cpp.s: - $(MAKE) -f CMakeFiles/GB.dir/build.make CMakeFiles/GB.dir/gb.cpp.s -.PHONY : gb.cpp.s - -# Help Target -help: - @echo "The following are some of the valid targets for this Makefile:" - @echo "... all (the default if no target is provided)" - @echo "... clean" - @echo "... depend" - @echo "... rebuild_cache" - @echo "... edit_cache" - @echo "... GB" - @echo "... gb.o" - @echo "... gb.i" - @echo "... gb.s" -.PHONY : help - - - -#============================================================================= -# Special targets to cleanup operation of make. - -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system - diff --git a/GB_build/cmake_install.cmake b/GB_build/cmake_install.cmake deleted file mode 100644 index efeeba1..0000000 --- a/GB_build/cmake_install.cmake +++ /dev/null @@ -1,49 +0,0 @@ -# Install script for directory: /mnt/c/Users/lefou/Desktop/cap/GBSim/Game-Boy-Sim - -# Set the install prefix -if(NOT DEFINED CMAKE_INSTALL_PREFIX) - set(CMAKE_INSTALL_PREFIX "/usr/local") -endif() -string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") - -# Set the install configuration name. -if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) - if(BUILD_TYPE) - string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" - CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") - else() - set(CMAKE_INSTALL_CONFIG_NAME "") - endif() - message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") -endif() - -# Set the component getting installed. -if(NOT CMAKE_INSTALL_COMPONENT) - if(COMPONENT) - message(STATUS "Install component: \"${COMPONENT}\"") - set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") - else() - set(CMAKE_INSTALL_COMPONENT) - endif() -endif() - -# Install shared libraries without execute permission? -if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) - set(CMAKE_INSTALL_SO_NO_EXE "1") -endif() - -# Is this installation the result of a crosscompile? -if(NOT DEFINED CMAKE_CROSSCOMPILING) - set(CMAKE_CROSSCOMPILING "FALSE") -endif() - -if(CMAKE_INSTALL_COMPONENT) - set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") -else() - set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") -endif() - -string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT - "${CMAKE_INSTALL_MANIFEST_FILES}") -file(WRITE "/mnt/c/Users/lefou/Desktop/cap/GBSim/Game-Boy-Sim/GB_build/${CMAKE_INSTALL_MANIFEST}" - "${CMAKE_INSTALL_MANIFEST_CONTENT}") From 067326116dceec493117dec37a8bd3c78e2b41f7 Mon Sep 17 00:00:00 2001 From: Taylor King Date: Sun, 6 Sep 2020 21:15:27 -0400 Subject: [PATCH 5/6] add cmake changeS --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fa4c48..4b238ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,16 @@ cmake_minimum_required(VERSION 3.10) project(GBSim) +find_package(SDL2 REQUIRED) +include_directories(${SDL2_INCLUDE_DIRECTORIES}) + file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/*.cpp) add_executable(GB ${SRC_FILES}) target_include_directories(GB PUBLIC ${PROJECT_SOURCE_DIR}) + +target_link_libraries(GB "SDL2") add_definitions("-g") set(CMAKE_CXX_STANDARD 11) From 1225531b981c6d73c12b64e3b8396119906f8eab Mon Sep 17 00:00:00 2001 From: Taylor King Date: Sun, 27 Sep 2020 17:11:32 -0400 Subject: [PATCH 6/6] Fix CMakeLists --- CMakeLists.txt | 12 +++++++++--- SDL_Demo/CMakeLists.txt | 17 +++++++++++++++++ Sim.cpp | 9 --------- 3 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 SDL_Demo/CMakeLists.txt delete mode 100644 Sim.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b238ed..d9f5040 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,16 +2,22 @@ cmake_minimum_required(VERSION 3.10) project(GBSim) find_package(SDL2 REQUIRED) + include_directories(${SDL2_INCLUDE_DIRECTORIES}) -file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/*.cpp) +file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/*.cpp + ${PROJECT_SOURCE_DIR}/Instructions/*.cpp) add_executable(GB ${SRC_FILES}) target_include_directories(GB PUBLIC ${PROJECT_SOURCE_DIR}) -target_link_libraries(GB "SDL2") +target_link_libraries(GB "SDL2" "stdc++fs") add_definitions("-g") -set(CMAKE_CXX_STANDARD 11) +set_target_properties(GB PROPERTIES + CXX_STANDARD 17 + CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) +add_subdirectory("SDL_Demo") diff --git a/SDL_Demo/CMakeLists.txt b/SDL_Demo/CMakeLists.txt new file mode 100644 index 0000000..9aa159b --- /dev/null +++ b/SDL_Demo/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.10) + +find_package(SDL2 REQUIRED) + +include_directories(${SDL2_INCLUDE_DIRECTORIES}) + +add_executable(pixelmod "pixelmod.cpp") + +target_link_libraries(pixelmod "SDL2") + +add_executable(SDLdemo "SDLdemo.cpp") + +target_link_libraries(SDLdemo "SDL2") + +add_executable(SDL_keyInput "SDL_keyInput.cpp") + +target_link_libraries(SDL_keyInput "SDL2") diff --git a/Sim.cpp b/Sim.cpp deleted file mode 100644 index 8afb630..0000000 --- a/Sim.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include -#include -#include "Sim.h" -#include "Memory.h" - -using namespace std; -