Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nnarain committed Dec 13, 2018
2 parents f3fd679 + 87f8fd9 commit 64d9fc2
Show file tree
Hide file tree
Showing 90 changed files with 8,457 additions and 7,978 deletions.
21 changes: 9 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
language: cpp
dist: trusty
dist: xenial
sudo: required

os:
- linux
compiler:
- g++
- clang

addons:
apt:
sources:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
packages:
- lcov

before_install:
- git clone --depth=1 https://github.com/nnarain/travis-ci-scripts.git ~/scripts
- cd ~/scripts/ && ./bootstrap && cd -
- preinstall_general

install:
- install_general
- chmod +x ./scripts/travis_deploy_docs
- bash scripts/ci_install
- sudo apt-get --allow-unauthenticated install -y doxygen graphviz

script:
- mkdir build && cd build
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DWITH_COVERAGE=ON -DBUILD_DOCS="ON"
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DWITH_COVERAGE=ON -DBUILD_DOCS=ON
- cd .. && cppcheck -q --enable=all --inconclusive --force --suppressions-list=./config/cppcheck-suppress.txt src/gameboycore/ && cd -
- make
- make check
- make run_test_roms
- make check && make run_test_roms
- cd ..

after_success:
- "./scripts/travis_deploy_docs $TRAVIS_BRANCH $GITHUB_API_TOKEN"
- bash ./scripts/travis_deploy_docs $TRAVIS_BRANCH $GITHUB_API_TOKEN
- cd build
- make package
- export ARTIFACTS=$(ls -d1 $PWD/*.tar.gz)
Expand Down
2 changes: 2 additions & 0 deletions config/cppcheck-suppress.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
unusedFunction
*:*tests/*
16 changes: 16 additions & 0 deletions scripts/ci_install
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Install google-test
pushd .
git clone --branch=release-1.8.1 --depth=1 https://github.com/google/googletest ~/gtest
mkdir ~/gtest/build && cd ~/gtest/build
cmake ..
make && sudo make install
popd

# Install cppcheck
pushd .
git clone --branch=1.86 --depth=1 https://github.com/danmar/cppcheck ~/cppcheck
mkdir ~/cppcheck/build && cd ~/cppcheck/build
cmake .. && make && sudo make install
popd
4 changes: 2 additions & 2 deletions scripts/travis_deploy_docs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export BRANCH=$1
export API_TOKEN=$2

# only deploy on master branch commit
if [[ "$BRANCH" != "develop" ]]; then
exit 0
if [[ "$BRANCH" != "master" ]]; then
exit 0
fi

# clone into what is going to be the docs output directory
Expand Down
76 changes: 44 additions & 32 deletions src/gameboycore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
option(BUILD_TESTS "Build tests" ON)
option(WITH_COVERAGE "Build with coverage info" OFF)

########################################################################################################################
### CMake Policy ###
########################################################################################################################
cmake_policy(SET CMP0054 OLD)


########################################################################################################################
### GameboyCore ###
Expand Down Expand Up @@ -54,32 +59,32 @@ set(GAMEBOYCORE_HEADERS
include/gameboycore/cartinfo.h
include/gameboycore/opcodeinfo.h
include/gameboycore/opcode_cycles.h
src/core/bitutil.h
src/core/shiftrotate.h
src/bitutil.h
src/shiftrotate.h
)

set(GAMEBOYCORE
src/core/gameboycore.cpp
src/core/cpu.cpp
src/core/mmu.cpp
src/core/gpu.cpp
src/core/apu.cpp
src/core/joypad.cpp
src/core/link.cpp
src/core/link_cable.cpp
src/core/mbc.cpp
src/core/mbc1.cpp
src/core/mbc2.cpp
src/core/mbc3.cpp
src/core/mbc5.cpp
src/core/alu.cpp
src/core/cartinfo.cpp
src/core/shiftrotate.cpp
src/core/opcodeinfo.cpp
src/core/tileram.cpp
src/core/tilemap.cpp
src/core/oam.cpp
src/core/timer.cpp
src/gameboycore.cpp
src/cpu.cpp
src/mmu.cpp
src/gpu.cpp
src/apu.cpp
src/joypad.cpp
src/link.cpp
src/link_cable.cpp
src/mbc.cpp
src/mbc1.cpp
src/mbc2.cpp
src/mbc3.cpp
src/mbc5.cpp
src/alu.cpp
src/cartinfo.cpp
src/shiftrotate.cpp
src/opcodeinfo.cpp
src/tileram.cpp
src/tilemap.cpp
src/oam.cpp
src/timer.cpp
)

# Gameboy Core Library
Expand All @@ -91,15 +96,18 @@ add_library(gameboycore::gameboycore ALIAS gameboycore)

target_compile_features(gameboycore PUBLIC cxx_std_11)

# TODO: Move detail headers elsewhere?
target_include_directories(gameboycore PUBLIC
include/
target_include_directories(gameboycore
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(gameboycore PRIVATE -Wall -Wno-format-security)
elseif(MSVC)
target_compile_options(gameboycore PRIVATE /W3)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(gameboycore PRIVATE -Wall -Wextra)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(gameboycore PRIVATE /W4)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(gameboycore PRIVATE -Wall -Wextra)
endif()

target_compile_definitions(gameboycore PRIVATE GAMEBOYCORE_STATIC=1 ${ENDIAN}=1 _CRT_SECURE_NO_WARNINGS=1)
Expand All @@ -111,8 +119,12 @@ target_compile_definitions(gameboycore PRIVATE GAMEBOYCORE_STATIC=1 ${ENDIAN}=1
if (BUILD_TESTS)
# Setup coverage reporting
if (WITH_COVERAGE)
target_link_libraries(gameboycore gcov)
target_compile_options(gameboycore PRIVATE -fprofile-arcs -ftest-coverage)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(gameboycore PRIVATE -fprofile-arcs -ftest-coverage)
target_link_libraries(gameboycore gcov)
else()
message(WARNING "Code coverage is not supported for ${CMAKE_CXX_COMPILER_ID}")
endif()
endif()

add_subdirectory(tests)
Expand Down
118 changes: 59 additions & 59 deletions src/gameboycore/include/gameboycore/alu.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
\file alu.h
\author Natesh Narain <nnaraindev@gmail.com>
\file alu.h
\author Natesh Narain <nnaraindev@gmail.com>
*/

#ifndef GAMEBOYCORE_ALU_H
Expand All @@ -9,77 +9,77 @@
#include <cstdint>

/**
Contains Math and Logical operation
Contains Math and Logical operation
*/
namespace gb
{
/*!
\class ALU
\brief Arithmetic and logic unit
*/
class ALU
{
public:
enum Flags
{
Z = 1 << 7,
N = 1 << 6,
H = 1 << 5,
C = 1 << 4
};
/*!
\class ALU
\brief Arithmetic and logic unit
*/
class ALU
{
public:
enum Flags
{
Z = 1 << 7,
N = 1 << 6,
H = 1 << 5,
C = 1 << 4
};

public:
ALU(uint8_t& flags);
~ALU();
public:
ALU(uint8_t& flags);
~ALU();

/**
ADD
*/
void add(uint8_t& a, uint8_t n);
void add(uint16_t& hl, uint16_t n);
void addr(uint16_t& sp, int8_t n);
/**
ADD
*/
void add(uint8_t& a, uint8_t n);
void add(uint16_t& hl, uint16_t n);
void addr(uint16_t& sp, int8_t n);

/**
ADC
*/
void addc(uint8_t& a, uint8_t n);
/**
ADC
*/
void addc(uint8_t& a, uint8_t n);

/**
SUB
*/
void sub(uint8_t& a, uint8_t n);
/**
SUB
*/
void sub(uint8_t& a, uint8_t n);

/**
SUBC
*/
void subc(uint8_t& a, uint8_t n);
/**
SUBC
*/
void subc(uint8_t& a, uint8_t n);

/**
AND
*/
void anda(uint8_t& a, uint8_t n);
/**
AND
*/
void anda(uint8_t& a, uint8_t n);

/**
OR
*/
void ora(uint8_t& a, uint8_t n);
/**
OR
*/
void ora(uint8_t& a, uint8_t n);

/**
XOR
*/
void xora(uint8_t& a, uint8_t n);
/**
XOR
*/
void xora(uint8_t& a, uint8_t n);

/**
Compare
*/
void compare(uint8_t& a, uint8_t n);
/**
Compare
*/
void compare(uint8_t& a, uint8_t n);

private:
void setFlag(uint8_t mask, bool set);
private:
void setFlag(uint8_t mask, bool set);

private:
uint8_t& flags_;
};
private:
uint8_t& flags_;
};

}
#endif // GAMEBOYCORE_ALU_H

0 comments on commit 64d9fc2

Please sign in to comment.