Skip to content

Instantly share code, notes, and snippets.

View benhall-7's full-sized avatar
🚲

Ben Hall benhall-7

🚲
View GitHub Profile
@benhall-7
benhall-7 / TestCpp
Created April 4, 2024 04:59
Comparison of two functions with the same implementation
(melonDS::NDS *) this = 0x000000012b600000
(melonDS::SPU) $0 = {
AudioLock = 0x0000600003e11440
ApplyBias = true
NDS = 0x000000012b600000
OutputBackbuffer = {
[0] = 0
[1] = 0
[2] = 0
@benhall-7
benhall-7 / glide.lua
Last active November 19, 2022 05:31
Readable Lua interpretation of the gliding statuses from Brawl
PARAMS = {
max_angle = 80,
min_angle = -70,
glide_start_speed_y = 0.75,
glide_start_accel_y = 1,
glide_start_speed_x_mul = 1,
power_start = 1.7,
power_rate = 0.04,
max_speed = 2.2,
end_speed = 0.7,
@benhall-7
benhall-7 / ui_chara_edit.rs
Created June 28, 2021 18:16
An example function that edits and saves a param in ui_chara_db.prc
use prc::*;
use prc::hash40::{Hash40, to_hash40};
fn edit_ui_chara_db() {
// with the param data ready,
let mut root = open("ui_chara_db.prc").unwrap();
// enter the first and only node of the file ("db_root")
let (db_root_hash, db_root) = &mut root.0[0];
assert_eq!(*db_root_hash, to_hash40("db_root"));
@benhall-7
benhall-7 / challenge.py
Created October 2, 2020 06:02
Code Challenge: word representation to number conversion
ONES = {
"one": 1,
"two": 2,
"three": 3,
"four": 4,
"five": 5,
"six": 6,
"seven": 7,
"eight": 8,
"nine": 9,
@benhall-7
benhall-7 / names.py
Created September 29, 2020 02:40
Duplicate name search between two lists with minimal allocation
import time
start_time = time.time()
f = open('names_1.txt', 'r')
names_1 = f.read().split("\n") # List containing 10000 names
f.close()
# takes at most log(n) space, which is less than a second array
names_1.sort()
@benhall-7
benhall-7 / program.rs
Created July 1, 2020 06:20
MIDI Program Name
use serde::{Deserialize, Serialize};
macro_rules! generate_enum {
($first:ident, $($rest:ident),*) => {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum Program {
$first = 0,
$($rest),*
}
@benhall-7
benhall-7 / expanded.rs
Created May 26, 2020 19:16
musicli macro expansion
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
pub mod error {
use std::error;
use std::fmt::Display;
use std::io;
pub enum Error {
@benhall-7
benhall-7 / crc.c
Created February 1, 2020 06:11
hash_crc
#include <string.h>
unsigned long HASH_TABLE[] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
@benhall-7
benhall-7 / main.rs
Last active January 3, 2020 02:44
SSBU const_value_table file generation
// has to be run in --release mode or else the lua_bind_hash method fails (due to integer overflows panicking)
pub mod lua_bind_hash; // https://github.com/ultimate-research/lua-bind-hash/blob/master/lua_bind_hash.rs
use lua_bind_hash as lhash;
use std::fs::File;
use std::io::{BufReader, BufRead, BufWriter, Write};
use std::collections::BTreeMap;
use inflections::case::is_constant_case;
fn main() {
@benhall-7
benhall-7 / terry.xml
Last active November 6, 2019 16:49
Terry stats
<struct index="71">
<hash40 hash="fighter_kind">fighter_kind_dolly</hash40>
<float hash="walk_accel_mul">0.1</float>
<float hash="walk_accel_add">0.03</float>
<float hash="walk_speed_max">0.85</float>
<float hash="walk_slow_speed_mul">0.2</float>
<float hash="walk_middle_ratio">0.33</float>
<float hash="walk_fast_ratio">0.75</float>
<float hash="ground_brake">0.111</float>
<float hash="dash_speed">1.65</float>