Skip to content

Commit 958980a

Browse files
committed
First checkin
0 parents  commit 958980a

File tree

437 files changed

+72212
-0
lines changed

Some content is hidden

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

437 files changed

+72212
-0
lines changed

.gitignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/build
2+
3+
# Prerequisites
4+
*.d
5+
6+
# Compiled Object files
7+
*.slo
8+
*.lo
9+
*.o
10+
*.obj
11+
12+
# Precompiled Headers
13+
*.gch
14+
*.pch
15+
16+
# Compiled Dynamic libraries
17+
*.so
18+
*.dylib
19+
*.dll
20+
21+
# Fortran module files
22+
*.mod
23+
*.smod
24+
25+
# Compiled Static libraries
26+
*.lai
27+
*.la
28+
*.a
29+
*.lib
30+
31+
# Executables
32+
*.exe
33+
*.out
34+
*.app

.vscode/launch.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "(Windows) Launch",
6+
"type": "cppvsdbg",
7+
"request": "launch",
8+
"program": "${command:cmake.launchTargetPath}",
9+
"args": ["Tetris.gb"],
10+
"stopAtEntry": false,
11+
"cwd": "${workspaceFolder}\\build",
12+
"environment": [],
13+
"externalConsole": false
14+
}
15+
]
16+
}

.vscode/settings.json

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"files.associations": {
3+
"iosfwd": "cpp",
4+
"algorithm": "cpp",
5+
"cctype": "cpp",
6+
"cmath": "cpp",
7+
"cstddef": "cpp",
8+
"cstdint": "cpp",
9+
"cstdio": "cpp",
10+
"cstdlib": "cpp",
11+
"cstring": "cpp",
12+
"ctime": "cpp",
13+
"cwchar": "cpp",
14+
"deque": "cpp",
15+
"exception": "cpp",
16+
"fstream": "cpp",
17+
"functional": "cpp",
18+
"initializer_list": "cpp",
19+
"iomanip": "cpp",
20+
"ios": "cpp",
21+
"iostream": "cpp",
22+
"istream": "cpp",
23+
"limits": "cpp",
24+
"list": "cpp",
25+
"map": "cpp",
26+
"memory": "cpp",
27+
"new": "cpp",
28+
"ostream": "cpp",
29+
"sstream": "cpp",
30+
"stack": "cpp",
31+
"stdexcept": "cpp",
32+
"streambuf": "cpp",
33+
"string": "cpp",
34+
"system_error": "cpp",
35+
"tuple": "cpp",
36+
"type_traits": "cpp",
37+
"typeinfo": "cpp",
38+
"unordered_map": "cpp",
39+
"utility": "cpp",
40+
"vector": "cpp",
41+
"xfacet": "cpp",
42+
"xhash": "cpp",
43+
"xiosbase": "cpp",
44+
"xlocale": "cpp",
45+
"xlocinfo": "cpp",
46+
"xlocmon": "cpp",
47+
"xlocnum": "cpp",
48+
"xloctime": "cpp",
49+
"xmemory": "cpp",
50+
"xstddef": "cpp",
51+
"xstring": "cpp",
52+
"xtr1common": "cpp",
53+
"xtree": "cpp",
54+
"xutility": "cpp",
55+
"array": "cpp",
56+
"iterator": "cpp",
57+
"cstdarg": "cpp",
58+
"locale": "cpp",
59+
"optional": "cpp",
60+
"xlocbuf": "cpp",
61+
"xlocmes": "cpp"
62+
}
63+
}

CMakeLists-GLFW.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
include(ExternalProject)
2+
3+
set(GLFW_INCLUDE_DIR "${CMAKE_BINARY_DIR}/libs/glfw/include/")
4+
set(GLFW_LIBRARY_DIR "${CMAKE_BINARY_DIR}/libs/glfw/lib/")
5+
6+
EXTERNALPROJECT_ADD(
7+
glfw
8+
GIT_REPOSITORY https://github.com/glfw/glfw.git
9+
GIT_TAG 3.3
10+
CMAKE_ARGS
11+
"-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/libs/glfw"
12+
"-DGLFW_BUILD_DOCS=FALSE"
13+
"-DGLFW_BUILD_TESTS=FALSE"
14+
"-DGLFW_BUILD_EXAMPLES=FALSE"
15+
)

CMakeLists.txt

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.0.0)
2+
project(emu-gameboy VERSION 0.1.0)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
6+
include(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists-GLFW.txt)
7+
8+
file(GLOB_RECURSE EMU_SOURCES
9+
"${CMAKE_CURRENT_SOURCE_DIR}/libs/glad/src/glad.c"
10+
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.h"
11+
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
12+
)
13+
14+
include_directories(${GLFW_INCLUDE_DIR})
15+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/glm)
16+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/glad/include)
17+
18+
link_directories(${GLFW_LIBRARY_DIR})
19+
20+
add_executable(emu-gameboy ${EMU_SOURCES})
21+
add_dependencies(emu-gameboy glfw)
22+
target_link_libraries(emu-gameboy glfw3 ${OPENGL_LIBRARIES})
23+
24+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fonts/Minecraft.ttf Minecraft.ttf COPYONLY)
25+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/shaders/rect.vshader shaders/rect.vshader COPYONLY)
26+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/shaders/rect.fshader shaders/rect.fshader COPYONLY)
27+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/shaders/text.vshader shaders/text.vshader COPYONLY)
28+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/shaders/text.fshader shaders/text.fshader COPYONLY)

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Gerrit Gazic
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# A Gameboy emulator written in C++ (WIP)
2+
3+
I started this project to create an emulator which is capable to do emulation in **interpreter mode** and in **jit mode**.
4+
This is not a highly optimized emulator. The aim was to create a code base which is easy to follow for beginners.
5+
This is why each instruction group is implemented in an own class to provide a better implementation overview.
6+
7+
Each instruction group contains a group of the *struct Instruction*. The *struct* contains everything necessary to process the given instruction. This way it should be easy to tell how the **dissasembly**, **interpreter mode** and **jit mode** for each single instruction works.
8+
9+
´´´
10+
struct Instruction
11+
{
12+
short length;
13+
unsigned char opcode;
14+
std::function<std::string (int)> getMnemonic;
15+
//TODO Interpreter executeInterpreter(CPU);
16+
//TODO JIT with DynASM getAsm();
17+
};
18+
´´´
19+
20+
Further more the emulator contains a simple dissasembler and aims to be cycle accurate.
21+
If you are just interested on how the implementation of the instructions were done, just look into the *src/instructions* subfolders.
22+
You will find the hardware implementation of the emulator in the *src/hardware* folder.
23+
24+
## Ressources
25+
26+
- http://gbdev.gg8.se/wiki/articles/Pan_Docs
27+
- http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html
28+
- https://github.com/AntonioND/giibiiadvance/blob/master/docs/TCAGBD.pdf
Binary file not shown.

docs/TCAGBD.pdf

452 KB
Binary file not shown.

fonts/Minecraft.ttf

14.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)