Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
mkdir build
cd build
cmake ..
cmake --build . -j 8
cmake --build . -j8
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ build/
*.DS_Store
cmake-build-debug/
.idea/
src/.vscode/
.cache/
tests/
.vscode/
src/dmg_boot.gb
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(SDL2 REQUIRED)

if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG")
endif()

add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} SDL2::SDL2 SDL2::SDL2main)
add_subdirectory(src)
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,18 @@ cmake -DDEBUG=on ..
cmake --build . -j8
```

After this run the binary gbemu in the build folder.
# Usage
After building, run the emulator with:
```
./gbemu <boot_rom_path> <game_rom_path>
```

Example:
```
./gbemu ../src/dmg_boot.gb ../tests/tetris.gb
```

Arguments:
- `boot_rom_path`: Path to the DMG boot ROM file (e.g., dmg_boot.gb)
- `game_rom_path`: Path to the Game Boy ROM file to run

53 changes: 53 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

# Default ROM paths (can be overridden with arguments)
BOOT_ROM="../src/dmg_boot.gb"
GAME_ROM="../tests/dmg_sound/rom_singles/02-len ctr.gb"

# Check if arguments were provided
if [ $# -eq 2 ]; then
BOOT_ROM="$1"
GAME_ROM="$2"
fi

current_directory=$(pwd)
last_keyword=$(basename "$current_directory")

if [[ $last_keyword == "build" ]]; then
# Execute commands for the specified directory
echo "Executing commands for build"
echo "removing build directory"
cd ..
rm -r build
cd ..

# Add your commands here
elif [[ $last_keyword == "gbemu" ]]; then
# Execute commands for another directory
echo "Executing commands for gbemu"
echo "Using Boot ROM: $BOOT_ROM"
echo "Using Game ROM: $GAME_ROM"

if [[ -d "$current_directory/build" ]]; then
rm -r build
echo "removing build directory"
echo "making new build directory"
mkdir build
cd build
cmake ..
cmake --build . -j8
./gbemu "$BOOT_ROM" "$GAME_ROM"
else
echo "making new build directory"
mkdir build
cd build
cmake ..
cmake --build . -j8
./gbemu "$BOOT_ROM" "$GAME_ROM"
fi

# Add your commands here
else
# Default case if no match is found
echo "No matching directory found."
fi
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ set(SOURCES
gameBoy.cpp
mmap.cpp
graphics.cpp
audio.cpp
# -------
# Header Files
cpu.h
gameBoy.h
mmap.h
types.h
graphics.h
audio.h
)

target_sources(${PROJECT_NAME} PRIVATE ${SOURCES})
Expand Down
Loading
Loading