Skip to content

Commit c0d015a

Browse files
committed
Merge branch 'develop'
2 parents afb8ff2 + 2725506 commit c0d015a

32 files changed

+801
-41
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ install:
2727

2828
script:
2929
- mkdir build && cd build
30-
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DWITH_COVERAGE=ON -DBUILD_DOCS=ON
30+
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DWITH_COVERAGE=ON -DBUILD_EXAMPLES=ON
3131
- cd .. && cppcheck -q --enable=all --inconclusive --force --suppressions-list=./config/cppcheck-suppress.txt src/gameboycore/ && cd -
3232
- make
3333
- make check && make run_test_roms

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ cmake_minimum_required(VERSION 3.0)
88

99
project(gameboycore)
1010

11-
option(BUILD_DOCS "Build documentation" OFF)
12-
1311
set(CMAKE_MODULE_PATH ${CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
1412
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
1513

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![Build status](https://ci.appveyor.com/api/projects/status/jkrjhds3i67o5k76/branch/develop?svg=true)](https://ci.appveyor.com/project/nnarain/gameboycore/branch/develop)
55
[![codecov](https://codecov.io/gh/nnarain/gameboycore/branch/master/graph/badge.svg)](https://codecov.io/gh/nnarain/gameboycore)
66
[![GitHub release](https://img.shields.io/github/release/nnarain/gameboycore.svg)](https://github.com/nnarain/gameboycore/releases)
7+
[![Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://nnarain.github.io/gameboycore)
78

89
GameboyCore is a Gameboy/Gameboy Color emulator library written in C++.
910

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ install:
2121
before_build:
2222
- cd c:\projects\gameboycore
2323
- mkdir build && cd build
24-
- cmake .. -DBUILD_TESTS="ON" -DBUILD_EXAMPLE="OFF" -DBUILD_DOCS="OFF" -DCMAKE_TOOLCHAIN_FILE=%VCPKG_TOOLCHAIN%
24+
- cmake .. -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DCMAKE_TOOLCHAIN_FILE=%VCPKG_TOOLCHAIN%
2525

2626
build:
2727
project: c:\projects\gameboycore\build\gameboycore.sln

src/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
option(BUILD_TOOLS "Build debug tooling" OFF)
2+
option(BUILD_EXAMPLES "Build example programs" OFF)
23

34
add_subdirectory(gameboycore)
45

56
if (BUILD_TOOLS)
67
add_subdirectory(tools)
78
endif(BUILD_TOOLS)
9+
10+
if (BUILD_EXAMPLES)
11+
add_subdirectory(examples)
12+
endif(BUILD_EXAMPLES)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
add_executable(minimal_example
2+
src/main.cpp
3+
)
4+
5+
target_link_libraries(minimal_example
6+
gameboycore
7+
)
8+
9+
target_compile_definitions(minimal_example PRIVATE GAMEBOYCORE_STATIC=1)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <gameboycore/gameboycore.h>
2+
3+
#include <iostream>
4+
#include <string>
5+
#include <functional>
6+
7+
using namespace gb;
8+
9+
int main(int argc, char * argv[])
10+
{
11+
if (argc < 2)
12+
{
13+
std::cerr << "Must provide path to a ROM file\n";
14+
return 1;
15+
}
16+
17+
std::string filepath{argv[1]};
18+
19+
// Create an instance of the gameboy emulator core
20+
GameboyCore core;
21+
22+
// Set callbacks for video and audio
23+
core.setScanlineCallback([](const GPU::Scanline& scanline, int line){
24+
std::cout << "Line " << line << "\n";
25+
});
26+
core.setAudioSampleCallback([](int16_t l, int16_t r){
27+
std::cout << "L: " << l << " " << "R: " << r << "\n";
28+
});
29+
30+
// Open the ROM specified ROM file
31+
try
32+
{
33+
core.open(filepath);
34+
}
35+
catch(const std::runtime_error& e)
36+
{
37+
std::cerr << "Error loading ROM file: " << e.what() << "\n";
38+
return 1;
39+
}
40+
41+
// Run the emulator
42+
core.emulateFrame();
43+
44+
return 0;
45+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
add_executable(batteryram_example
2+
src/main.cpp
3+
)
4+
5+
target_link_libraries(batteryram_example
6+
gameboycore
7+
)
8+
9+
target_compile_definitions(batteryram_example PRIVATE GAMEBOYCORE_STATIC=1)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <gameboycore/gameboycore.h>
2+
3+
#include <iostream>
4+
#include <string>
5+
6+
using namespace gb;
7+
8+
int main(int argc, char * argv[])
9+
{
10+
if (argc < 2)
11+
{
12+
std::cerr << "Must provide path to a ROM file\n";
13+
return 1;
14+
}
15+
16+
std::string filepath{argv[1]};
17+
18+
// Create an instance of the gameboy emulator core
19+
GameboyCore core;
20+
21+
// Open the ROM specified ROM file
22+
try
23+
{
24+
core.open(filepath);
25+
}
26+
catch(const std::runtime_error& e)
27+
{
28+
std::cerr << "Error loading ROM file: " << e.what() << "\n";
29+
return 1;
30+
}
31+
32+
// Get battery RAM from the emulator
33+
// Battery RAM is persistent storage for the Gameboy (RAM at this location is always on because of a battery in the cartridge)
34+
// Battery RAM starts at address $A000
35+
auto batteryram = core.getBatteryRam();
36+
batteryram[0] = 0xFF;
37+
core.setBatteryRam(batteryram);
38+
39+
std::cout << "$A000: " << std::hex << (int)core.readMemory(0xA000) << "\n";
40+
41+
return 0;
42+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
add_executable(linkport_example
2+
src/main.cpp
3+
)
4+
5+
target_link_libraries(linkport_example
6+
gameboycore
7+
)
8+
9+
target_compile_definitions(linkport_example PRIVATE GAMEBOYCORE_STATIC=1)

0 commit comments

Comments
 (0)