Skip to content

Commit

Permalink
Merge branch 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
tommitytom committed Nov 1, 2022
2 parents a995471 + 21022fb commit 41b0361
Show file tree
Hide file tree
Showing 19 changed files with 163 additions and 60 deletions.
54 changes: 46 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,59 @@
version: 1.0.{build}
image:
- Visual Studio 2019
environment:
CI_BUILD: true
APPVEYOR_SAVE_CACHE_ON_ERROR: true
APPVEYOR_CACHE_SKIP_RESTORE: true
VcpkgAutoLink: false
dep_secret:
secure: Go1kB2XlFAIQvngM+YPkhD7p+Cmfzo1rcNWCiA8E6Lo=
dep_salt:
secure: 39s+KlQG6Hg9XF4FP6/KW+KrDYYdxj1ZoS4zoiX2LuS62MczMH5hoq2ZOmjyx6wD6qip9xBcltozTX6hn8fK3g==
init:
# Do a clean build if we are on the master branch (usually only for releases)
- ps: IF ($env:APPVEYOR_REPO_BRANCH -eq "master") {$env:APPVEYOR_CACHE_SKIP_RESTORE = "true"}
# Do a clean build if we are on the main branch (usually only for releases)
#- ps: IF ($env:APPVEYOR_REPO_BRANCH -eq "main") {$env:APPVEYOR_CACHE_SKIP_RESTORE = "true"}
- ps: >-
if ($env:APPVEYOR_REPO_TAG -eq "true")
{
$env:RETROPLUG_VERSION = "$env:APPVEYOR_REPO_TAG_NAME"
}
else
{
$env:RETROPLUG_VERSION = "dev-$($env:APPVEYOR_REPO_COMMIT.Substring(0, 7))"
}
Update-AppveyorBuild -Version "$env:RETROPLUG_VERSION"
clone_folder: c:\retroplug
cache: c:\retroplug\build
install:
- ps: iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/appveyor/secure-file/master/install.ps1'))
- cmd: appveyor-tools\secure-file -decrypt ci/dep.7z.enc -secret %dep_secret% -salt %dep_salt%
- sh: ./appveyor-tools/secure-file -decrypt ci/dep.7z.enc -secret $dep_secret -salt $dep_salt

- cmd: appveyor DownloadFile https://github.com/Microsoft/vswhere/releases/download/2.3.2/vswhere.exe
- cmd: appveyor DownloadFile https://github.com/premake/premake-core/releases/download/v5.0.0-alpha16/premake-5.0.0-alpha16-windows.zip
- cmd: appveyor DownloadFile https://github.com/gbdev/rgbds/releases/download/v0.5.1/rgbds-0.5.1-win64.zip

- cmd: 7z e premake-5.0.0-alpha16-windows.zip
- cmd: 7z e rgbds-0.5.1-win64.zip
- cmd: 7z e ci/dep.7z

- cmd: set PATH=c:\retroplug;%PATH%
build_script:
- cmd: premake5 vs2019
- cmd: msbuild build/vs2019/ScriptCompiler.vcxproj /property:Configuration=Release /property:Platform=x64
- cmd: c:\retroplug\build\vs2019\bin\x64\Release\ScriptCompiler.exe c:\retroplug\src\compiler.config.lua
- cmd: premake5 vs2019
- cmd: msbuild build/vs2019/RetroPlug-app.vcxproj /property:Configuration=Release /property:Platform=x64
- cmd: deploy.bat
artifacts:
- path: build\deploy\RetroPlug_standalone*.zip
name: 'RetroPlug Standalone Win64'
- path: build\deploy\RetroPlug_vst2*.zip
name: 'RetroPlug VST2 Win64'
deploy:
tag: $(APPVEYOR_REPO_TAG_NAME)
release: 'RetroPlug $(APPVEYOR_BUILD_VERSION)'
description: 'RetroPlug $(APPVEYOR_BUILD_VERSION)'
provider: GitHub
auth_token:
secure: /qpQ094QMnI1maDmM/leovgbLDBFluaEi22tjmdjRTXaDHER2apNW5M9qEvyb8p5
artifact: /.*\.zip/
draft: true
prerelease: false
on:
APPVEYOR_REPO_TAG: true
Binary file added ci/dep.7z.enc
Binary file not shown.
4 changes: 2 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
return {
plugin = {
version = "0.3.0",
version = "0.3.4",
name = "RetroPlug",
author = "tommitytom",
uniqueId = "2wvF",
authorId = "tmtt",
url = "https://tommitytom.co.uk",
email = "[email protected]",
copyright = "Copyright 2020 Tom Yaxley"
copyright = "Copyright 2021 Tom Yaxley"
},
config = {
default = {
Expand Down
4 changes: 2 additions & 2 deletions config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#define SEMVER_MAJOR 0
#define SEMVER_MINOR 3
#define SEMVER_PATCH 2
#define SEMVER_PATCH 4

#define PLUG_NAME "RetroPlug"
#define PLUG_MFR "tommitytom"
#define PLUG_VERSION_HEX 0x00000302
#define PLUG_VERSION_HEX 0x00000304
#define PLUG_VERSION_STR VERSION_STRING(SEMVER_MAJOR, SEMVER_MINOR, SEMVER_PATCH)
#define PLUG_UNIQUE_ID '2wvF'
#define PLUG_MFR_ID 'tmtt'
Expand Down
21 changes: 21 additions & 0 deletions deploy.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if "%RETROPLUG_VERSION%"=="" exit /b 1

echo Deploying RetroPlug "%RETROPLUG_VERSION%"

mkdir build\deploy

premake5 vs2019
msbuild build/vs2019/ScriptCompiler.vcxproj /property:Configuration=Release /property:Platform=x64 /m
build\vs2019\bin\x64\Release\ScriptCompiler.exe src\compiler.config.lua
premake5 vs2019

msbuild build/vs2019/RetroPlug.sln /property:Configuration=Release /property:Platform=x64 /m

copy build\vs2019\bin\x64\Release\RetroPlug_app_x64.exe build\deploy\RetroPlug-%RETROPLUG_VERSION%.exe
copy build\vs2019\bin\x64\Release\RetroPlug_vst2_x64.dll "build\deploy\RetroPlug %RETROPLUG_VERSION% (64bit).dll"

cd build\deploy
7z a RetroPlug_standalone-win64-%RETROPLUG_VERSION%.zip RetroPlug-%RETROPLUG_VERSION%.exe
7z a RetroPlug_vst2-win64-%RETROPLUG_VERSION%.zip "RetroPlug %RETROPLUG_VERSION% (64bit).dll"

cd ..\..
4 changes: 2 additions & 2 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ dofile("scripts/configure.lua")
group "Targets"
iplug2.project.app(retroplugProject)
iplug2.project.vst2(retroplugProject)
iplug2.project.vst3(retroplugProject)
iplug2.project.wam(retroplugProject)
--iplug2.project.vst3(retroplugProject)
--iplug2.project.wam(retroplugProject)

if _OPTIONS["emscripten"] then
local EMSDK_FLAGS = {
Expand Down
21 changes: 3 additions & 18 deletions resources/main.rc
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ BEGIN
MENUITEM "&Preferences...\tCtrl+,", ID_PREFERENCES
MENUITEM "&Quit", ID_QUIT
END
POPUP "&Debug"
BEGIN
MENUITEM "&Live Edit Mode\tCtrl+E", ID_LIVE_EDIT
MENUITEM "&Show Control Bounds\tCtrl+B", ID_SHOW_BOUNDS
MENUITEM "&Show Drawn Area\tCtrl+D", ID_SHOW_DRAWN
MENUITEM "&Show FPS\tCtrl+F", ID_SHOW_FPS
END
POPUP "&Help"
BEGIN
MENUITEM "&About", ID_ABOUT
Expand Down Expand Up @@ -170,14 +163,6 @@ IDI_ICON1 ICON "RetroPlug.ico"
// Accelerator
//

IDR_ACCELERATOR1 ACCELERATORS
BEGIN
VK_OEM_COMMA, ID_PREFERENCES, VIRTKEY, CONTROL, NOINVERT
"B", ID_SHOW_BOUNDS, VIRTKEY, CONTROL, NOINVERT
"D", ID_SHOW_DRAWN, VIRTKEY, CONTROL, NOINVERT
"F", ID_SHOW_FPS, VIRTKEY, CONTROL, NOINVERT
"E", ID_LIVE_EDIT, VIRTKEY, CONTROL, NOINVERT
END


/////////////////////////////////////////////////////////////////////////////
Expand All @@ -202,13 +187,13 @@ BEGIN
BEGIN
BLOCK "040004e4"
BEGIN
VALUE "FileVersion", "0.2.0"
VALUE "ProductVersion", "0.2.0"
VALUE "FileVersion", "0.3.4"
VALUE "ProductVersion", "0.3.4"
VALUE "FileDescription", "RetroPlug"
VALUE "InternalName", "RetroPlug"
VALUE "ProductName", "RetroPlug"
VALUE "CompanyName", "Tom Yaxley"
VALUE "LegalCopyright", "Copyright 2020 Tom Yaxley"
VALUE "LegalCopyright", "Copyright 2021 Tom Yaxley"
VALUE "LegalTrademarks", "VST is a trademark of Steinberg Media Technologies GmbH, Audio Unit is a trademark of Apple, Inc."
END
END
Expand Down
4 changes: 2 additions & 2 deletions src/config/0.3/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
uiComponents = {},
audioComponents = {},
sameBoy = {
model = "auto",
model = "auto", -- auto, dmgB, cgbE, cgbC, agb
gameLink = false,
skipBootRom = false
},
Expand All @@ -15,7 +15,7 @@
},
-- Default project settings
project = {
saveType = "sram",
saveType = "sram", --sram, state
audioRouting = "stereoMixDown",
zoom = 2,
midiRouting = "sendToAll",
Expand Down
23 changes: 23 additions & 0 deletions src/plugin/audio/RetroPlugInstrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,30 @@ void RetroPlugInstrument::ProcessBlock(sample** inputs, sample** outputs, int fr
}

void RetroPlugInstrument::OnIdle() {

}

bool RetroPlugInstrument::OnKeyDown(const IKeyPress& key) {
// Ascii keys do not receive a correct key up event in ableton. This is to
// workaround that.
if (mHost == EHost::kHostAbletonLive && key.utf8[0] != 0) {
_heldKeys.push_back(key.VK);
}

return GetUI()->OnKeyDown(0, 0, key);
}

bool RetroPlugInstrument::OnKeyUp(const IKeyPress& key) {
IKeyPress keyCopy = key;

if (mHost == EHost::kHostAbletonLive && key.VK == 0) {
if (_heldKeys.size()) {
keyCopy.VK = _heldKeys.back();
_heldKeys.pop_back();
}
}

return GetUI()->OnKeyUp(0, 0, keyCopy);
}

bool RetroPlugInstrument::SerializeState(IByteChunk& chunk) {
Expand Down
8 changes: 6 additions & 2 deletions src/plugin/audio/RetroPlugInstrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class RetroPlugInstrument final : public Plugin {

RetroPlugController _controller;

// This vector contains ascii keys that are currently held. It is to work around a bug
// in Ableton Live, where it doesn't tell is what key is being released during a key up event.
std::vector<int> _heldKeys;

public:
RetroPlugInstrument(const InstanceInfo& info);
~RetroPlugInstrument();
Expand All @@ -23,8 +27,8 @@ class RetroPlugInstrument final : public Plugin {
void ProcessMidiMsg(const IMidiMsg& msg) override;
void OnReset() override;
void OnIdle() override;
bool OnKeyDown(const IKeyPress& key) override { return GetUI()->OnKeyDown(0, 0, key); }
bool OnKeyUp(const IKeyPress& key) override { return GetUI()->OnKeyUp(0, 0, key); }
bool OnKeyDown(const IKeyPress& key) override;
bool OnKeyUp(const IKeyPress& key) override;

bool SerializeState(IByteChunk& chunk) override;
int UnserializeState(const IByteChunk& chunk, int startPos) override;
Expand Down
4 changes: 4 additions & 0 deletions src/plugin/controller/RetroPlugController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/basic_file_sink.h>
//#include <spdlog/sinks/msvc_sink.h>

#include "config.h"
#include "platform/Path.h"
Expand Down Expand Up @@ -46,6 +47,9 @@ RetroPlugController::RetroPlugController(double sampleRate)
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>((configPath / "log.txt").string(), true);
file_sink->set_level(spdlog::level::info);

//auto msvc_sink = std::make_shared<spdlog::sinks::msvc_sink_st>();
//msvc_sink->set_level(spdlog::level::debug);

auto logger = std::make_shared<spdlog::logger>("", spdlog::sinks_init_list { console_sink, file_sink });
logger->flush_on(spdlog::level::err);

Expand Down
2 changes: 1 addition & 1 deletion src/retroplug/audio/AudioController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void AudioController::setNode(Node* node) {
ctx->deserializeSystems(componentData);
}

_lua = ctx;
_lua = ctx;
});

node->on<calls::SwapSystem>([&](const SystemSwapDesc& d, SystemSwapDesc& other) {
Expand Down
7 changes: 4 additions & 3 deletions src/retroplug/scripts/audio/Controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,19 @@ function Controller:onMidi(offset, statusByte, data1, data2)
self:emit("onMidi", v, msg)
end
elseif r == MidiChannelRouting.OneChannelPerInstance then
local target = Project.systems[channel]
local target = Project.systems[channel + 1]

if target ~= nil then
local msg = midi.Message(offset, statusByte, data1, data2)
local msg = midi.Message(offset, status << 4, data1, data2)
self:emit("onMidi", target, msg)
end
elseif r == MidiChannelRouting.FourChannelsPerInstance then
local targetIdx = math.floor(channel / 4)
local target = Project.systems[targetIdx + 1]
local channelOffset = targetIdx * 4

if target ~= nil then
local msg = midi.Message(offset, (channel | (status << 4)), data1, data2)
local msg = midi.Message(offset, ((channel - channelOffset) | (status << 4)), data1, data2)
self:emit("onMidi", target, msg)
end
end
Expand Down
10 changes: 6 additions & 4 deletions src/retroplug/scripts/audio/components/LsdjArduinoboy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function LsdjArduinoboy.onMidi(system, msg)
if msg.systemStatus == midi.SystemStatus.TimingClock then
processSync(system, msg.offset)
else
print(enumtil.toEnumString(midi.SystemStatus, msg.systemStatus))
log.info(enumtil.toEnumString(midi.SystemStatus, msg.systemStatus))
end
end

Expand All @@ -125,6 +125,7 @@ function LsdjArduinoboy.onMidi(system, msg)
-- Notes trigger row numbers

if status == midi.Status.NoteOn then
log.info("noteon")
local rowIdx = midiMapRowNumber(msg.channel, msg.note)

if rowIdx ~= -1 then
Expand All @@ -138,9 +139,10 @@ function LsdjArduinoboy.onMidi(system, msg)
system:sendSerialByte(msg.offset, 0xFE)
state.lastRow = -1
end
-- Pseudocode... not sure what to handle here! FL studio does nothing useful when stop is clicked
elseif msg.type == "stop" then
system:sendSerialByte(msg.offset, 0xFE)
elseif status == midi.Status.System then
if msg.systemStatus == midi.SystemStatus.SequenceStop then
system:sendSerialByte(msg.offset, 0xFE)
end
end
end
end
Expand Down
12 changes: 11 additions & 1 deletion src/retroplug/scripts/ui/System.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ end
-- to 'data' is a buffer.
function System:loadRom(data, path)
local d = self._desc
d.sramPath = ""

if d.sramData ~= nil then
d.sramData:clear()
end

local fileData, err
if type(data) == "string" and pathutil.ext(data) == "zip" then
Expand Down Expand Up @@ -154,10 +159,15 @@ function System:saveSram(path)
path = self._desc.sramPath
end

if path == nil then
if path == nil or path == "" then
path = pathutil.changeExt(self._desc.romPath, "sav")
end

if path == nil or path == "" then
log.error("Failed to write .sav - Failed to get a path to save to!")
return
end

log.info("Saving SRAM to " .. path)

self._desc.sramPath = path
Expand Down
10 changes: 10 additions & 0 deletions src/retroplug/scripts/ui/View.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ function View:initProject()
self.model:setup()
end

local function keyToString(key)
for k, v in pairs(Key) do
if v == key then
return k
end
end

return "Unknown (" .. tostring(key) .. ")"
end

function View:onKey(key, down)
if self._keyFilter:onKey(key, down) == true then
self.model:emit("onKey", key, down)
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/iPlug2/IPlug/APP/IPlugAPP_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ void IPlugAPPHost::MIDICallback(double deltatime, std::vector<uint8_t>* pMsg, vo
}
else if (pMsg->size())
{
std::cout << deltatime << std::endl;
//std::cout << deltatime << std::endl;
IMidiMsg msg;
msg.mStatus = pMsg->at(0);
pMsg->size() > 1 ? msg.mData1 = pMsg->at(1) : msg.mData1 = 0;
Expand Down
Loading

0 comments on commit 41b0361

Please sign in to comment.