Skip to content

Commit

Permalink
Merge branch 'master' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tommitytom committed Nov 1, 2022
2 parents 312fe76 + 41b0361 commit 40c6f01
Show file tree
Hide file tree
Showing 677 changed files with 93,033 additions and 4,907 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
A frontend for the SameBoy GameBoy emulator, with a focus on music creation. It runs standalone and can be used as an audio plugin (VST) in your favourite DAW!

## Features
- Wraps [SameBoy](https://github.com/LIJI32/SameBoy) v0.14.3
- Wraps [SameBoy](https://github.com/LIJI32/SameBoy) v0.15.7
- Full MIDI support for [mGB](https://github.com/trash80/mGB)
- Syncs [LSDj](https://www.littlesounddj.com) to your DAW
- Emulates various [Arduinoboy](https://github.com/trash80/Arduinoboy) modes
Expand Down
2 changes: 1 addition & 1 deletion premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ project "RetroPlug"

configuration { "not emscripten" }
prebuildcommands {
"%{wks.location}/bin/x64/Release/ScriptCompiler ../../src/compiler.config.lua"
"%{wks.location}/bin/%{cfg.platform}/Debug/ScriptCompiler ../../src/compiler.config.lua"
}

filter { "system:windows", "files:src/retroplug/luawrapper/**" }
Expand Down
24 changes: 22 additions & 2 deletions scripts/sameboy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ project "SameBoyBootRoms"
files { SAMEBOY_DIR .. "BootROMs/**.asm" }

prebuildcommands {
'rgbgfx -h -u -o "%{cfg.objdir}/SameBoyLogo.2bpp" "' .. BOOTROM_DIR .. '/SameBoyLogo.png"',
'rgbgfx -Z -u -c embedded -o "%{cfg.objdir}/SameBoyLogo.2bpp" "' .. BOOTROM_DIR .. '/SameBoyLogo.png"',
'"%{cfg.buildtarget.directory}/pb12" < "%{cfg.objdir}/SameBoyLogo.2bpp" > "%{cfg.objdir}/SameBoyLogo.pb12"'
}

Expand All @@ -57,12 +57,32 @@ project "SameBoyBootRoms"

end

local function getVersion()
local file = io.open("../thirdparty/SameBoy/version.mk", "r")
if file == nil then
error("Failed to detect SameBoy version: version.mk could not be opened")
end

local version = file:read()
local st, en = version:find(":= ")

if st == nil then
error("Failed to detect SameBoy version: version.mk contains invalid data")
end

version = version:sub(en + 1)

file:close()

return version
end

project "SameBoy"
kind "StaticLib"
language "C"
toolset "clang"

defines { "GB_INTERNAL", "GB_DISABLE_TIMEKEEPING" }
defines { "GB_INTERNAL", "GB_DISABLE_TIMEKEEPING", [[GB_VERSION="]] .. getVersion() .. [["]] }

sysincludedirs {
SAMEBOY_DIR .. "Core",
Expand Down
12 changes: 6 additions & 6 deletions src/plugs/SameBoyPlug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
#include <fstream>
#include <xxhash.h>

extern "C" {
#include <gb.h>
}

#include "retroplug/Constants.h"
#include "retroplug/util/SampleConverter.h"
#include "generated/bootroms/agb_boot.h"
Expand All @@ -16,6 +12,10 @@ extern "C" {
#include "generated/bootroms/sgb_boot.h"
#include "generated/bootroms/sgb2_boot.h"

extern "C" {
#include <gb.h>
}

const size_t LINK_TICKS_MAX = 3907;

const size_t MAX_SERIAL_ITEMS = 128;
Expand Down Expand Up @@ -83,7 +83,7 @@ static uint32_t rgbEncode(GB_gameboy_t* gb, uint8_t r, uint8_t g, uint8_t b) {
return 255 << 24 | b << 16 | g << 8 | r;
}

static void vblankHandler(GB_gameboy_t* gb) {
static void vblankHandler(GB_gameboy_t* gb, GB_vblank_type_t type) {
SameBoyPlugState* state = (SameBoyPlugState*)GB_get_user_data(gb);
state->vblankOccurred = true;
}
Expand Down Expand Up @@ -136,7 +136,7 @@ void SameBoyPlug::init(GameboyModel model) {
GB_set_serial_transfer_bit_start_callback(_state.gb, serialStart);
GB_set_serial_transfer_bit_end_callback(_state.gb, serialEnd);

GB_set_color_correction_mode(_state.gb, GB_COLOR_CORRECTION_EMULATE_HARDWARE);
GB_set_color_correction_mode(_state.gb, GB_COLOR_CORRECTION_MODERN_BALANCED);
GB_set_highpass_filter_mode(_state.gb, GB_HIGHPASS_ACCURATE);

GB_set_rendering_disabled(_state.gb, true);
Expand Down
4 changes: 3 additions & 1 deletion src/plugs/SameBoyPlug.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

#include <vector>
#include <queue>
#include <gb_struct_def.h>

#include "retroplug/Messages.h"

struct GB_gameboy_s;
typedef struct GB_gameboy_s GB_gameboy_t;

const size_t PIXEL_WIDTH = 160;
const size_t PIXEL_HEIGHT = 144;
const size_t PIXEL_COUNT = (PIXEL_WIDTH * PIXEL_HEIGHT);
Expand Down
22 changes: 12 additions & 10 deletions src/retroplug/luawrapper/UiLuaContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
#include "platform/Logger.h"
#include "Wrappers.h"

//#ifdef COMPILE_LUA_SCRIPTS
#ifdef COMPILE_LUA_SCRIPTS
#include "generated/CompiledScripts.h"
//#endif
#endif

//#define DEBUG_SCRIPTS

void UiLuaContext::init(AudioContextProxy* proxy, const std::string& path, const std::string& scriptPath) {
_configPath = path;
Expand All @@ -47,7 +49,7 @@ bool UiLuaContext::onKey(VirtualKey key, bool down) {
return res;
}

return false;
return false;
}

void UiLuaContext::onDoubleClick(float x, float y, MouseMod mod) {
Expand Down Expand Up @@ -91,14 +93,14 @@ void UiLuaContext::reload() {
if (_valid) {
callFunc(_viewRoot, "onReloadBegin");
}

shutdown();
setup(false);

if (_valid) {
callFunc(_viewRoot, "onReloadEnd");
}

_haltFrameProcessing = !_valid;
}

Expand Down Expand Up @@ -141,13 +143,13 @@ bool UiLuaContext::setup(bool updateProject) {
_state = new sol::state();
sol::state& s = *_state;

s.open_libraries( sol::lib::base, sol::lib::package, sol::lib::table, sol::lib::string,
s.open_libraries( sol::lib::base, sol::lib::package, sol::lib::table, sol::lib::string,
sol::lib::math, sol::lib::debug, sol::lib::coroutine, sol::lib::io );

std::string packagePath = s["package"]["path"];
packagePath += ";" + _configPath + "/?.lua";

#ifdef COMPILE_LUA_SCRIPTS
#ifndef DEBUG_SCRIPTS
spdlog::info("Using precompiled lua scripts");
s.add_package_loader(CompiledScripts::common::loader);
s.add_package_loader(CompiledScripts::ui::loader);
Expand All @@ -158,7 +160,7 @@ bool UiLuaContext::setup(bool updateProject) {
#endif

s["package"]["path"] = packagePath;

luawrappers::registerCommon(s);
luawrappers::registerChrono(s);
luawrappers::registerLsdj(s);
Expand Down Expand Up @@ -191,7 +193,7 @@ bool UiLuaContext::setup(bool updateProject) {
);

// TODO: Fix naming of this too!
s.create_named_table("nativeutil",
s.create_named_table("nativeutil",
"mergeMenu", mergeMenu
);

Expand Down Expand Up @@ -223,7 +225,7 @@ bool UiLuaContext::setup(bool updateProject) {
}

// Load the users config settings
// TODO: This should probably happen outside of this class since it may be used by the
// TODO: This should probably happen outside of this class since it may be used by the
// audio lua context too.
std::string configPath = _configPath + "/config.lua";
bool configValid = false;
Expand Down
3 changes: 3 additions & 0 deletions src/retroplug/model/ProcessingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ void ProcessingContext::process(float** outputs, size_t frameCount) {
} else {
linkedPlugs[linkedPlugCount++] = plug;
}

plug->pressButtons(_buttonPresses[i].data().presses.data(), _buttonPresses[i].getCount());
_buttonPresses[i].clear();

totalPlugCount++;
}
Expand Down
10 changes: 10 additions & 0 deletions thirdparty/SameBoy-old/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Always use LF line endings for shaders
*.fsh text eol=lf
*.metal text eol=lf

HexFiend/* linguist-vendored
*.inc linguist-language=C
Core/*.h linguist-language=C
SDL/*.h linguist-language=C
Windows/*.h linguist-language=C
Cocoa/*.h linguist-language=Objective-C
3 changes: 3 additions & 0 deletions thirdparty/SameBoy-old/.github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: LIJI32
25 changes: 25 additions & 0 deletions thirdparty/SameBoy-old/.github/actions/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Blargg's Test ROMs by Shay Green <[email protected]>

Acid2 tests by Matt Currie under MIT:

MIT License

Copyright (c) 2020 Matt Currie

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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 23 additions & 0 deletions thirdparty/SameBoy-old/.github/actions/install_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
case `echo $1 | cut -d '-' -f 1` in
ubuntu)
sudo apt-get -qq update
sudo apt-get install -yq bison libpng-dev pkg-config libsdl2-dev
(
cd `mktemp -d`
curl -L https://github.com/rednex/rgbds/archive/v0.4.0.zip > rgbds.zip
unzip rgbds.zip
cd rgbds-*
make -sj
sudo make install
cd ..
rm -rf *
)
;;
macos)
brew install rgbds sdl2
;;
*)
echo "Unsupported OS"
exit 1
;;
esac
Binary file not shown.
33 changes: 33 additions & 0 deletions thirdparty/SameBoy-old/.github/actions/sanity_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
set -e

./build/bin/tester/sameboy_tester --jobs 5 \
--length 45 .github/actions/cgb_sound.gb \
--length 10 .github/actions/cgb-acid2.gbc \
--length 10 .github/actions/dmg-acid2.gb \
--dmg --length 45 .github/actions/dmg_sound-2.gb \
--dmg --length 20 .github/actions/oam_bug-2.gb

mv .github/actions/dmg{,-mode}-acid2.bmp

./build/bin/tester/sameboy_tester \
--dmg --length 10 .github/actions/dmg-acid2.gb

set +e

FAILED_TESTS=`
shasum .github/actions/*.bmp | grep -E -v \(\
64c3fd9a5fe9aee40fe15f3371029c0d2f20f5bc\ \ .github/actions/cgb-acid2.bmp\|\
dbcc438dcea13b5d1b80c5cd06bda2592cc5d9e0\ \ .github/actions/cgb_sound.bmp\|\
0caadf9634e40247ae9c15ff71992e8f77bbf89e\ \ .github/actions/dmg-acid2.bmp\|\
fbdb5e342bfdd2edda3ea5601d35d0ca60d18034\ \ .github/actions/dmg-mode-acid2.bmp\|\
c9e944b7e01078bdeba1819bc2fa9372b111f52d\ \ .github/actions/dmg_sound-2.bmp\|\
f0172cc91867d3343fbd113a2bb98100074be0de\ \ .github/actions/oam_bug-2.bmp\
\)`

if [ -n "$FAILED_TESTS" ] ; then
echo "Failed the following tests:"
echo $FAILED_TESTS | tr " " "\n" | grep -o -E "[^/]+\.bmp" | sed s/.bmp// | sort
exit 1
fi

echo Passed all tests
36 changes: 36 additions & 0 deletions thirdparty/SameBoy-old/.github/workflows/sanity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Bulidability and Sanity"
on: push

jobs:
sanity:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, ubuntu-18.04]
cc: [gcc, clang]
include:
- os: macos-latest
cc: clang
extra_target: cocoa
exclude:
- os: macos-latest
cc: gcc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Install deps
shell: bash
run: |
./.github/actions/install_deps.sh ${{ matrix.os }}
- name: Build
run: |
${{ matrix.cc }} -v; (make -j sdl tester libretro ${{ matrix.extra_target }} CONF=release CC=${{ matrix.cc }} || (echo "==== Build Failed ==="; make sdl tester libretro ${{ matrix.extra_target }} CONF=release CC=${{ matrix.cc }}))
- name: Sanity tests
shell: bash
run: |
./.github/actions/sanity_tests.sh
- name: Upload binaries
uses: actions/upload-artifact@v1
with:
name: sameboy-canary-${{ matrix.os }}-${{ matrix.cc }}
path: build/bin
1 change: 1 addition & 0 deletions thirdparty/SameBoy-old/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
Loading

0 comments on commit 40c6f01

Please sign in to comment.