Skip to content

Commit 64d9fc2

Browse files
committed
Merge branch 'develop'
2 parents f3fd679 + 87f8fd9 commit 64d9fc2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+8457
-7978
lines changed

.travis.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
language: cpp
2-
dist: trusty
2+
dist: xenial
33
sudo: required
44

55
os:
66
- linux
77
compiler:
88
- g++
9+
- clang
910

1011
addons:
1112
apt:
13+
sources:
14+
- sourceline: 'ppa:ubuntu-toolchain-r/test'
1215
packages:
1316
- lcov
1417

15-
before_install:
16-
- git clone --depth=1 https://github.com/nnarain/travis-ci-scripts.git ~/scripts
17-
- cd ~/scripts/ && ./bootstrap && cd -
18-
- preinstall_general
19-
2018
install:
21-
- install_general
22-
- chmod +x ./scripts/travis_deploy_docs
19+
- bash scripts/ci_install
2320
- sudo apt-get --allow-unauthenticated install -y doxygen graphviz
2421

2522
script:
2623
- mkdir build && cd build
27-
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DWITH_COVERAGE=ON -DBUILD_DOCS="ON"
24+
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DWITH_COVERAGE=ON -DBUILD_DOCS=ON
25+
- cd .. && cppcheck -q --enable=all --inconclusive --force --suppressions-list=./config/cppcheck-suppress.txt src/gameboycore/ && cd -
2826
- make
29-
- make check
30-
- make run_test_roms
27+
- make check && make run_test_roms
3128
- cd ..
3229

3330
after_success:
34-
- "./scripts/travis_deploy_docs $TRAVIS_BRANCH $GITHUB_API_TOKEN"
31+
- bash ./scripts/travis_deploy_docs $TRAVIS_BRANCH $GITHUB_API_TOKEN
3532
- cd build
3633
- make package
3734
- export ARTIFACTS=$(ls -d1 $PWD/*.tar.gz)

config/cppcheck-suppress.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
unusedFunction
2+
*:*tests/*

scripts/ci_install

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# Install google-test
4+
pushd .
5+
git clone --branch=release-1.8.1 --depth=1 https://github.com/google/googletest ~/gtest
6+
mkdir ~/gtest/build && cd ~/gtest/build
7+
cmake ..
8+
make && sudo make install
9+
popd
10+
11+
# Install cppcheck
12+
pushd .
13+
git clone --branch=1.86 --depth=1 https://github.com/danmar/cppcheck ~/cppcheck
14+
mkdir ~/cppcheck/build && cd ~/cppcheck/build
15+
cmake .. && make && sudo make install
16+
popd

scripts/travis_deploy_docs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export BRANCH=$1
1111
export API_TOKEN=$2
1212

1313
# only deploy on master branch commit
14-
if [[ "$BRANCH" != "develop" ]]; then
15-
exit 0
14+
if [[ "$BRANCH" != "master" ]]; then
15+
exit 0
1616
fi
1717

1818
# clone into what is going to be the docs output directory

src/gameboycore/CMakeLists.txt

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
option(BUILD_TESTS "Build tests" ON)
22
option(WITH_COVERAGE "Build with coverage info" OFF)
33

4+
########################################################################################################################
5+
### CMake Policy ###
6+
########################################################################################################################
7+
cmake_policy(SET CMP0054 OLD)
8+
49

510
########################################################################################################################
611
### GameboyCore ###
@@ -54,32 +59,32 @@ set(GAMEBOYCORE_HEADERS
5459
include/gameboycore/cartinfo.h
5560
include/gameboycore/opcodeinfo.h
5661
include/gameboycore/opcode_cycles.h
57-
src/core/bitutil.h
58-
src/core/shiftrotate.h
62+
src/bitutil.h
63+
src/shiftrotate.h
5964
)
6065

6166
set(GAMEBOYCORE
62-
src/core/gameboycore.cpp
63-
src/core/cpu.cpp
64-
src/core/mmu.cpp
65-
src/core/gpu.cpp
66-
src/core/apu.cpp
67-
src/core/joypad.cpp
68-
src/core/link.cpp
69-
src/core/link_cable.cpp
70-
src/core/mbc.cpp
71-
src/core/mbc1.cpp
72-
src/core/mbc2.cpp
73-
src/core/mbc3.cpp
74-
src/core/mbc5.cpp
75-
src/core/alu.cpp
76-
src/core/cartinfo.cpp
77-
src/core/shiftrotate.cpp
78-
src/core/opcodeinfo.cpp
79-
src/core/tileram.cpp
80-
src/core/tilemap.cpp
81-
src/core/oam.cpp
82-
src/core/timer.cpp
67+
src/gameboycore.cpp
68+
src/cpu.cpp
69+
src/mmu.cpp
70+
src/gpu.cpp
71+
src/apu.cpp
72+
src/joypad.cpp
73+
src/link.cpp
74+
src/link_cable.cpp
75+
src/mbc.cpp
76+
src/mbc1.cpp
77+
src/mbc2.cpp
78+
src/mbc3.cpp
79+
src/mbc5.cpp
80+
src/alu.cpp
81+
src/cartinfo.cpp
82+
src/shiftrotate.cpp
83+
src/opcodeinfo.cpp
84+
src/tileram.cpp
85+
src/tilemap.cpp
86+
src/oam.cpp
87+
src/timer.cpp
8388
)
8489

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

9297
target_compile_features(gameboycore PUBLIC cxx_std_11)
9398

94-
# TODO: Move detail headers elsewhere?
95-
target_include_directories(gameboycore PUBLIC
96-
include/
99+
target_include_directories(gameboycore
100+
PUBLIC
101+
$<INSTALL_INTERFACE:include>
102+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
97103
)
98104

99-
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
100-
target_compile_options(gameboycore PRIVATE -Wall -Wno-format-security)
101-
elseif(MSVC)
102-
target_compile_options(gameboycore PRIVATE /W3)
105+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
106+
target_compile_options(gameboycore PRIVATE -Wall -Wextra)
107+
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
108+
target_compile_options(gameboycore PRIVATE /W4)
109+
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
110+
target_compile_options(gameboycore PRIVATE -Wall -Wextra)
103111
endif()
104112

105113
target_compile_definitions(gameboycore PRIVATE GAMEBOYCORE_STATIC=1 ${ENDIAN}=1 _CRT_SECURE_NO_WARNINGS=1)
@@ -111,8 +119,12 @@ target_compile_definitions(gameboycore PRIVATE GAMEBOYCORE_STATIC=1 ${ENDIAN}=1
111119
if (BUILD_TESTS)
112120
# Setup coverage reporting
113121
if (WITH_COVERAGE)
114-
target_link_libraries(gameboycore gcov)
115-
target_compile_options(gameboycore PRIVATE -fprofile-arcs -ftest-coverage)
122+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
123+
target_compile_options(gameboycore PRIVATE -fprofile-arcs -ftest-coverage)
124+
target_link_libraries(gameboycore gcov)
125+
else()
126+
message(WARNING "Code coverage is not supported for ${CMAKE_CXX_COMPILER_ID}")
127+
endif()
116128
endif()
117129

118130
add_subdirectory(tests)
Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
\file alu.h
3-
\author Natesh Narain <nnaraindev@gmail.com>
2+
\file alu.h
3+
\author Natesh Narain <nnaraindev@gmail.com>
44
*/
55

66
#ifndef GAMEBOYCORE_ALU_H
@@ -9,77 +9,77 @@
99
#include <cstdint>
1010

1111
/**
12-
Contains Math and Logical operation
12+
Contains Math and Logical operation
1313
*/
1414
namespace gb
1515
{
16-
/*!
17-
\class ALU
18-
\brief Arithmetic and logic unit
19-
*/
20-
class ALU
21-
{
22-
public:
23-
enum Flags
24-
{
25-
Z = 1 << 7,
26-
N = 1 << 6,
27-
H = 1 << 5,
28-
C = 1 << 4
29-
};
16+
/*!
17+
\class ALU
18+
\brief Arithmetic and logic unit
19+
*/
20+
class ALU
21+
{
22+
public:
23+
enum Flags
24+
{
25+
Z = 1 << 7,
26+
N = 1 << 6,
27+
H = 1 << 5,
28+
C = 1 << 4
29+
};
3030

31-
public:
32-
ALU(uint8_t& flags);
33-
~ALU();
31+
public:
32+
ALU(uint8_t& flags);
33+
~ALU();
3434

35-
/**
36-
ADD
37-
*/
38-
void add(uint8_t& a, uint8_t n);
39-
void add(uint16_t& hl, uint16_t n);
40-
void addr(uint16_t& sp, int8_t n);
35+
/**
36+
ADD
37+
*/
38+
void add(uint8_t& a, uint8_t n);
39+
void add(uint16_t& hl, uint16_t n);
40+
void addr(uint16_t& sp, int8_t n);
4141

42-
/**
43-
ADC
44-
*/
45-
void addc(uint8_t& a, uint8_t n);
42+
/**
43+
ADC
44+
*/
45+
void addc(uint8_t& a, uint8_t n);
4646

47-
/**
48-
SUB
49-
*/
50-
void sub(uint8_t& a, uint8_t n);
47+
/**
48+
SUB
49+
*/
50+
void sub(uint8_t& a, uint8_t n);
5151

52-
/**
53-
SUBC
54-
*/
55-
void subc(uint8_t& a, uint8_t n);
52+
/**
53+
SUBC
54+
*/
55+
void subc(uint8_t& a, uint8_t n);
5656

57-
/**
58-
AND
59-
*/
60-
void anda(uint8_t& a, uint8_t n);
57+
/**
58+
AND
59+
*/
60+
void anda(uint8_t& a, uint8_t n);
6161

62-
/**
63-
OR
64-
*/
65-
void ora(uint8_t& a, uint8_t n);
62+
/**
63+
OR
64+
*/
65+
void ora(uint8_t& a, uint8_t n);
6666

67-
/**
68-
XOR
69-
*/
70-
void xora(uint8_t& a, uint8_t n);
67+
/**
68+
XOR
69+
*/
70+
void xora(uint8_t& a, uint8_t n);
7171

72-
/**
73-
Compare
74-
*/
75-
void compare(uint8_t& a, uint8_t n);
72+
/**
73+
Compare
74+
*/
75+
void compare(uint8_t& a, uint8_t n);
7676

77-
private:
78-
void setFlag(uint8_t mask, bool set);
77+
private:
78+
void setFlag(uint8_t mask, bool set);
7979

80-
private:
81-
uint8_t& flags_;
82-
};
80+
private:
81+
uint8_t& flags_;
82+
};
8383

8484
}
8585
#endif // GAMEBOYCORE_ALU_H

0 commit comments

Comments
 (0)