Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperWig committed Oct 2, 2021
0 parents commit 0b3beb3
Show file tree
Hide file tree
Showing 13 changed files with 630 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vs
.vscode
out
build
48 changes: 48 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.14...3.21)
project(CHIP-8 LANGUAGES CXX)

option(USE_FALLBACK "Download and build dependencies from source if not found." OFF)

add_executable(chip-8 "src/main.cpp" "src/CHIP8.cpp")

target_compile_features(chip-8 PRIVATE cxx_std_20)
target_compile_definitions(chip-8 PRIVATE "$<$<CONFIG:Release>:DISABLE_RAYLIB_LOGS>")

find_package(argparse QUIET)
find_package(fmt QUIET)
find_package(raylib QUIET)

if (USE_FALLBACK)
if (NOT argparse_FOUND)
include(FetchContent)
FetchContent_Declare(
argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse
GIT_TAG v2.2
)
FetchContent_MakeAvailable(argparse)
endif()
if (NOT fmt_FOUND)
include(FetchContent)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt
GIT_TAG 8.0.1
)
FetchContent_MakeAvailable(fmt)
endif()
if (NOT raylib_FOUND)
include(FetchContent)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib
GIT_TAG 3.7.0
)
FetchContent_MakeAvailable(raylib)
target_link_libraries(chip-8 PRIVATE raylib)
endif()
endif()

target_link_libraries(chip-8 PRIVATE argparse::argparse fmt::fmt)
target_include_directories(chip-8 PRIVATE ${raylib_INCLUDE_DIRS})
target_link_libraries(chip-8 PRIVATE ${raylib_LIBRARIES})
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2021 Daniel Marshall

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Dan's CHIP-8 Emulator

Nothing particularly special. Uses Raylib for graphics.

# Building:

Dependencies:
* [argparse][]
* [fmtlib][]
* [raylib][]

[argparse] and [fmtlib] aren't exactly _needed_ dependencies, I'm just lazy and also wanted coloured output for one lone error message 🤷‍♂️.

You can use the CMake option `USE_FALLBACK` to download and build these dependencies from source if you don't have them installed. Example:
```cmake
cmake -B build -DUSE_FALLBACK=ON
cmake --build build
```

# Resources Used:

* https://multigesture.net/articles/how-to-write-an-emulator-chip-8-interpreter/
* http://devernay.free.fr/hacks/chip8/C8TECH10.HTM

There may have been more, I just can't remember them. Those were the primary sources, however.

[argparse]: https://github.com/p-ranav/argparse
[fmtlib]: https://github.com/fmtlib/fmt
[raylib]: https://github.com/raysan5/raylib
Binary file added ROMS/invaders.c8
Binary file not shown.
Binary file added ROMS/tests/BC_test.ch8
Binary file not shown.
Binary file added ROMS/tests/c8_test.c8
Binary file not shown.
Binary file added ROMS/tests/test_opcode.ch8
Binary file not shown.
Binary file added ROMS/tetris.c8
Binary file not shown.
47 changes: 47 additions & 0 deletions src/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AllowShortBlocksOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
BasedOnStyle: LLVM
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
BreakBeforeBraces: Custom
ColumnLimit: 0
Cpp11BracedListStyle: false
FixNamespaceComments: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.(h|hpp)>'
Priority: 3
- Regex: '^<.*>'
Priority: 2
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
MaxEmptyLinesToKeep: 10
NamespaceIndentation: All
PointerAlignment: Left
SortIncludes: true
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: false
Loading

0 comments on commit 0b3beb3

Please sign in to comment.