Skip to content

Instantly share code, notes, and snippets.

-- @version 1.0
-- @author cfillion
package.path = reaper.ImGui_GetBuiltinPath() .. '/?.lua'
local ImGui = require 'imgui' '0.9'
local SCRIPT_NAME = 'imgui.lua 0.9 upgrader'
local FLT_MIN, FLT_MAX = ImGui.NumericLimits_Float()
local ctx = ImGui.CreateContext(SCRIPT_NAME)
local code
@cfillion
cfillion / openocd-LPC546xx.cfg
Last active December 12, 2023 22:09
OpenOCD script for LPC546xx via MCU-Link2 (w/o flash support)
set CHIPNAME LPC546xx
set CPUTAPID 0x10CAA02B
adapter driver cmsis-dap
transport select swd
adapter speed 3000
# gdb_memory_map enable
# gdb_flash_program enable
@cfillion
cfillion / gfx-replay.lua
Last active January 23, 2024 22:01
Record and replay gfx code
-- GFXREPLAY_RECORD = true
-- gfx = dofile('/path/to/gfx-replay.lua')
GFX2IMGUI_DEBUG = GFX2IMGUI_DEBUG or false
GFX2IMGUI_MAX_DRAW_CALLS = GFX2IMGUI_MAX_DRAW_CALLS or 1<<13
GFX2IMGUI_NO_BLIT_PREMULTIPLY = GFX2IMGUI_NO_BLIT_PREMULTIPLY or false
GFX2IMGUI_NO_LOG = GFX2IMGUI_NO_LOG or false
local ImGui = {}
for name, func in pairs(reaper) do
@cfillion
cfillion / syntax-highlighting.user.js
Last active April 13, 2024 11:11
Syntax highlighting on the REAPER forum
// ==UserScript==
// @name Syntax highlighting
// @namespace https://cfillion.ca
// @version 1.0.3
// @author cfillion
// @include https://forum.cockos.com/showthread.php*
// @include https://forum.cockos.com/showpost.php*
// @include https://forum.cockos.com/editpost.php*
// @include https://forum.cockos.com/newreply.php*
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.3/highlight.min.js
--dofile(reaper.GetResourcePath() ..
--'/Scripts/ReaTeam Extensions/API/imgui.lua')('0.7')
r = reaper
local demo, cache = {}, {}
function demo.EachEnum(enum)
local enum_cache = cache[enum]
if not enum_cache then
enum_cache = {}
cache[enum] = enum_cache
@cfillion
cfillion / sws_preview_test.lua
Last active March 21, 2024 05:51
SWS preview API test
-- ARCHIVED VERSION
-- latest maintained version is on the ReaTeam Reascripts repository
package.path = reaper.ImGui_GetBuiltinPath() .. '/?.lua'
local ImGui = require 'imgui' '0.9'
local SCRIPT_NAME = 'SWS CF_Preview API demo'
local FLT_MIN, FLT_MAX = ImGui.NumericLimits_Float()
local ctx = ImGui.CreateContext(SCRIPT_NAME)
local sans_serif = ImGui.CreateFont('sans-serif', 13)
@cfillion
cfillion / ja_JP.UTF-8.md
Last active February 26, 2024 14:09
Solution for locale and character encoding issues in Japanese games on Steam Deck

Problem 1

Cannot access filenames containing non-ASCII characters.

Steam Deck's SteamOS 3 provides only one locale named en_US.utf8 (as configured in /etc/locale.gen) but /etc/locale.conf sets LANG to en_US.UTF-8. They don't match, so the effective locale for programs is C and the character set becomes limited to ASCII.

Set the game's launch options in Steam to LANG=en_US.utf8 %command% to solve this.

To fix this for all applications running in desktop mode (eg. to correctly extract games), create a file named ~/.config/plasma-workspace/env/utf8.sh containing (restart desktop mode to apply):

@cfillion
cfillion / reaper_widemsg.cpp
Created May 6, 2022 14:51
Hack to allow input of any characters in Unicode windows
// cl /nologo /O2 reaper_widemsg.cpp User32.lib /link /DLL /OUT:reaper_widemsg.dll
#include <cstdint>
#define REAPERAPI_IMPLEMENT
#include "reaper_plugin_functions.h"
template<typename T>
bool patch(const uintptr_t addr, const T newCode, T *backup = nullptr)
{
// c++ -fPIC -O2 -std=c++14 -DSWELL_PROVIDED_BY_APP -IWDL -IWDL/WDL -dynamiclib reaper_idenoreload.cpp WDL/WDL/swell/swell-modstub.mm -lc++ -framework AppKit -o reaper_ideautoreload.dylib
//
// cl /nologo /O2 reaper_idenoreload.cpp User32.lib /link /OPT:REF /PDBALTPATH:%_PDB% /DLL /OUT:reaper_ideautoreload.dll
#ifndef _WIN32
# include <sys/mman.h>
# include <WDL/wdltypes.h>
#endif
#include <cstdint>
// equivalent to __builtin_return_address(1);
uintptr_t rbp {};
asm("mov %%rbp, %0" : "=r"(rbp));
rbp = *reinterpret_cast<uintptr_t *>(rbp); // dig one level
intptr_t *ret { reinterpret_cast<uintptr_t *>(rbp + 8) };
*ret = s_current->m_redirect;