Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Alesis Vortex Wireless 2 patch to send MIDI messages when pressing the ribbon bank buttons
from asm import *
blob = open("image.bin", "rb").read()
start_addr = 0x08003000
patch_start = start_addr + len(blob)
assert patch_start % 4 == 0
code = """
.syntax unified
push {r3-r5, lr}
mov r4, r0
mov r5, r1
bl %(change_ribbon_bank)d
add r4, #102
strb r4, [sp,#1]
strb r5, [sp,#2]
mov r0, #0xb0
strb r0, [sp]
movs r1, #3
mov r0, sp
bl %(send_midi_event_a)d
movs r1, #3
mov r0, sp
bl %(send_midi_event_b)d
movs r1, #3
mov r0, sp
bl %(send_midi_event_c)d
pop {r3-r5, pc}
""" % {
"change_ribbon_bank": 0x08008645,
"send_midi_event_a": 0x080045Ad,
"send_midi_event_b": 0x080043F1,
"send_midi_event_c": 0x080046A1,
patch_locs = [
c = THUMBAsm(code, patch_start)
blob +=
for i in patch_locs:
p = THUMBAsm("bl %d" % (c.send_event_and_change_ribbon+1), i)
assert p.start == i
assert len( == 4
blob = blob[:p.start - start_addr] + + blob[p.end - start_addr:]
open("patched_image.bin", "wb").write(blob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment