Skip to content

Instantly share code, notes, and snippets.

@wareya
wareya / declick.lua
Last active April 14, 2024 03:31
declicking lua plugin for protoplug (https://github.com/pac-dev/protoplug)
--[[
name: Declicker
description: >
Declicker for saliva sounds etc. Based on a built-in filter for protoplug (but none of the original code remains).
--]]
require "include/protoplug"
local filters = {}
stereoFx.init()
@wareya
wareya / spi_recorder.ino
Last active April 25, 2024 02:11
long SPI message recorder - rasberry pi pico (rp2040), arduino IDE .ino file (C++)
// wiring example for ripping a PMW3360 SROM: https://i.imgur.com/EspAlvz.jpeg
// set the board to 240mhz or higher for best results (WARNING: higher than 240mhz only works with USB if you overvolt the MCU)
// this implements reading SPI mode 3. if you want a different mode, you need to edit these two lines:
// uint32_t clockval = (1 << pin_clock);
// if (newclock && !clockval && buff_i < buffsize)
#include <pico/stdlib.h>
#define buffsize 50000
@wareya
wareya / rle.rs
Created November 15, 2023 02:36
rle compressor/decompressor that supports word lengths up to 4 bytes
fn big_rle_compress(input : &[u8]) -> Vec<u8>
{
let mut ret = Vec::new();
let mut i = 0;
let mut mode = 0; // 0 - raw, 1 - rle
let mut mode_index = 0;
while i < input.len()
{
@wareya
wareya / text.glsl
Last active September 15, 2023 00:58
GLSL code for rendering numbers without using any textures or hardcoded arrays
// GLSL code for rendering numbers without using any textures or global arrays, using a tiny bitmap font
// for debugging!
// public domain. use under the creative commons zero license (any version)
// warning: the float-to-decimal conversion logic is "incorrect" and can only give around around four or five decimal places of floating point decision
const int _print_number_max_float_digits = 5;
const int _print_number_scale = 2;
const int _print_number_stretch_x = 1;
const int _print_number_stretch_y = 1;
extends Sprite2D
func convolve(base : Image, kernel : Image, offset : Vector2i, stride : Vector2i = Vector2i(1, 1), factor : float = 1.0, bias : float = 0.0):
#var new = Image.create(base.get_size().x/stride.x, base.get_size().y/stride.y, false, Image.FORMAT_RGBA8)
var new = Image.create(base.get_size().x, base.get_size().y, false, Image.FORMAT_RGBAF)
for y in range(0, base.get_size().y):#, stride.y):
for x in range(0, base.get_size().x):#, stride.x):
var sum = Color(0, 0, 0, 0)
var coord = Vector2i(x, y)
// NOTE: inefficient, uses a lot of branches. only for demonstration.
// use under the creative commons zero license, any version
vec3 normal_encode(vec3 normal)
{
// map onto octagon
normal *= 1.0/(abs(normal.x) + abs(normal.y) + abs(normal.z));
// project
float n = normal.x;
float m = normal.y;
// shift projection for back layer
// cargo add sha2 and plotters
use sha2::Digest;
use plotters::prelude::*;
const OUT_FILE_NAME: &'static str = "output-test.png";
fn main() {
// same for Sha512
let mut bins_a = vec!(0; 256);
@wareya
wareya / FollowerAA.omwfx
Created January 12, 2023 10:31
FollowerAA for OpenMW (post-processing AA shader)
uniform_float uRange {
default = 5;
min = 1;
max = 16.0;
step = 1;
description = "How many pixels the algorithm follows to try to detect an edge.";
display_name = "Range";
}
uniform_float uThreshold {
default = 20.0;
@wareya
wareya / ultima_1_ega_png.rs
Created January 9, 2023 04:10
ultima 1 ega row-planar encoder and decoder in rust
use image;
fn ega_to_image(bytes : &Vec<u8>) -> image::RgbaImage
{
let tile_size = [16, 16];
let bits_per_value = 1;
let channel_count = 4;
let palette = [
@wareya
wareya / mesh.rs
Last active November 28, 2022 07:26
use glm::*;
use std::collections::HashMap;
/*
class TileType:
var coord_top : Vector2 = Vector2(1, 4)
var coord_side : Vector2 = Vector2(1, 4)
var coord_bottom : Vector2 = Vector2(1, 4)