Skip to content

Instantly share code, notes, and snippets.

View micahswitzer's full-sized avatar

Micah Switzer micahswitzer

View GitHub Profile
@micahswitzer
micahswitzer / pcfdump.py
Created April 28, 2021 19:34
Parse PCF tables
#!/usr/bin/env python3
from struct import unpack
from argparse import ArgumentParser, FileType
# Info taken from https://fontforge.org/docs/techref/pcf-format.html
PCF_PROPERTIES = (1<<0)
PCF_ACCELERATORS = (1<<1)
PCF_METRICS = (1<<2)
@micahswitzer
micahswitzer / visitor.zig
Last active December 25, 2021 15:35
Implementation of the visitor pattern in Zig
const std = @import("std");
fn VisitorSet(comptime Argument: type, comptime Return: type, comptime types: anytype) type {
return struct {
const VisitorType = Visitor(Argument, Return, types);
const VisiteeType = Visitee(Argument, Return, types);
const VtableType = VisitorType.VtableType;
};
}
const std = @import("std");
fn comptimeBytes(comptime name: []const u8, comptime instructions: []const u8) []const u8 {\
// won't compile with ".section .bss\n"
asm volatile (".global " ++ name ++ ", " ++ name ++ "_end\njmp " ++ name ++ "_end\n" ++ name ++ ":\n" ++ instructions ++ "\n" ++ name ++ "_end:");
const start = @extern(*const u8, .{ .name = name });
const end = @extern(*const u8, .{ .name = name ++ "_end" });
const size = @ptrToInt(end) - @ptrToInt(start);
var result: []const u8 = undefined;
result.ptr = @ptrCast([*]const u8, start);
@micahswitzer
micahswitzer / Converter.cs
Last active June 25, 2023 03:07
Convert ADOFAI Levels to MIDI
using Fractions;
using Melanchall.DryWetMidi.Composing;
using Melanchall.DryWetMidi.Core;
using Melanchall.DryWetMidi.Interaction;
using Melanchall.DryWetMidi.Multimedia;
using Melanchall.DryWetMidi.MusicTheory;
using Melanchall.DryWetMidi.Standards;
using Note = Melanchall.DryWetMidi.MusicTheory.Note;