Skip to content

Instantly share code, notes, and snippets.

View visy's full-sized avatar

Visa-Valtteri Pimiä visy

View GitHub Profile
@visy
visy / lzw.tic
Created July 2, 2023 13:32
TIC-80 LZW graphics compression
pixal="abcdefghijklmnop"
function compressLZW(input)
local dictionary = {}
local result = {}
local dictSize = 256
local p = ""
for i = 0, 255 do
dictionary[string.char(i)] = i
@visy
visy / charmode40x25
Created April 12, 2023 17:51
320x200 image to 40x25 charmode generator
import java.util.*;
import java.util.Comparator;
PImage img;
PImage ditheredImg;
int blockSize = 8;
int numChars = 128;
int ditherSize = 128;
ArrayList<PImage> customCharset;
int[][] pseudographics;
include "64cube.inc"
ENUM $0
frame rBYTE 1
pnt rWORD 1
yc rBYTE 1
lines rBYTE 1
line_pad rBYTE 1
line_end rBYTE 1
@visy
visy / worstcodec.pde
Created May 9, 2021 14:12
16x16 macroblock video codec (aka. worst codec of all time) for 256x256 images
PGraphics source;
PGraphics sparse;
PGraphics filled;
PImage test;
color[] colortab = new color[256*16];
int[] sparsepixels = new int[256*16];
void sampleSparse() {
@visy
visy / rosette.asm
Created July 2, 2017 20:02
"Rosette" - a 16k C64 intro source code
// Uses Kick Assembler
//
// Switch bank in VIC-II
//
// Args:
// bank: bank number to switch to. Valid values: 0-3.
//
.macro SwitchVICBank(bank) {
var freq1 = Slot(1.0);
var ad1 = AdjustableDelay(110.1, freq1);
var lp1 = LowPass();
function dsp(t) {
var tau = Math.PI*2 - t*0.1;
var ts = t % (0.1);
var ts2 = t % 0.15;
freq1(1/(400 + Math.floor(cos(t*tau)*50) + Math.cos(ts2*(100.0-Math.abs((t*1.0))))*100+200*cos(110*t*tau)));
var freq1 = Slot(1.0);
var ad1 = AdjustableDelay(110.1, freq1);
var lp1 = LowPass();
function dsp(t) {
var ts = t % (0.1);
var ts2 = t % 0.15;
freq1(1/(400 + Math.floor(cos(t*tau)*50) + Math.cos(ts2*(100.0-Math.abs((t*2.4))))*100+200*cos(110*t*tau)));
var stroke = arp(ts, 1*noise(), 1, 100) + ad1();
ad1(lp1(stroke, 320000+Math.cos(ts*4.0)*10) * 0.99);