Skip to content

Instantly share code, notes, and snippets.

@lunasorcery
lunasorcery / im-gay.txt
Created May 20, 2018 16:42
Compressed sprite data for the I'M GAY gba_bios.bin mod.
24 40 03 00 0F 00 40 01 01 00 01 42 42 43 43 C4
44 05 C4 04 C4 0F C4 02 0A 03 C3 01 0E 0C 08 0D
07 09 06 0B AA AB 48 75 EB B8 9C AA 0F FD 85 FA
4F 57 17 E9 79 E7 49 7C 5F 67 FD 47 FE 9C EE 24
FD ED 5F 46 94 57 7C 66 49 0B 40 84 0F AB 2B FA
57 67 24 DC A1 9F EC FF 2A 3E 54 F1 AD AB 52 C5
BE F2 75 91 82 81 2B D6 D6 8B 80 65 76 F2 3F EC
61 FF 1F 75 59 59 75 FC A2 24 D7 D6 0A 65 3C 11
E3 B3 66 A4 F9 5F 8E FF F9 BA FA 7F 10 A7 92 73
6E 39 4C 21 7F 9C 7F C4 FF AD FC B8 33 AE EE E2
#!/usr/bin/env python3
import os
import json
with open('tweets.js') as f:
tweets_str = f.read()
# assume the prefix is universally the same ('window.YTD.tweets.part0 = ')
tweets_json = json.loads(tweets_str[26:])
@lunasorcery
lunasorcery / crc_zeroing.cpp
Created September 7, 2015 16:31
A demonstration of how a custom-crafted CRC table can force a hash of zero.
#include <cstdint>
#include <cstdio>
#define MAX_DATA_SIZE 256
#define USE_MODIFIED_CRC_TAB 0
static uint32_t crc32_tab[] = {
#if !USE_MODIFIED_CRC_TAB
// this is the classic "default" CRC32 table.
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
Replace 104 bytes at $3204 with the following.
This stores the animated color palette for the letters, and the static color palette for the shimmer.
16 70 E0 01 1E 68 B0 01 1F 7C F0 01 0B 64 E0 01
1D 50 60 01 1F 7C F0 01 0B 64 E0 01 1D 50 60 01
1F 7C F0 01 0B 64 E0 01 1D 50 60 01 1F 7C F0 01
0B 64 E0 01 1D 50 60 01 1F 7C F0 01 0B 64 E0 01
1D 50 60 01 1F 7C F0 01 0B 64 E0 01 1D 50 60 01
1F 7C F0 01 1F 7C F0 01 1F 7C F0 01 1F 7C F0 01
1F 00 FF 7F F7 5E EF 3D
; EU 0x087E70E0 / NA 0x087E4230:
; loaded to RAM at 030008f0
; sprite decompression function (8bit indexed)
; r0: compressed sprite source ptr
; r1: vram destination ptr
; r2: width
; r3: height
.arm
add lr, lr, #1
stmdb sp!, {r4-r9}
/* So how does this work?
I'm using ANSI escape sequences to control the behavior of the terminal while
cat is outputting the text. I deliberately place these control sequences inside
comments so the C++ compiler doesn't try to treat them as code.*/
//
/*The commands in the fake code comment move the cursor to the left edge and
clear out the line, allowing the fake code to take the place of the real code.
And this explanation uses similar commands to wipe itself out too. */
//
#include <cstdio>
@lunasorcery
lunasorcery / kill.sh
Created August 17, 2020 20:31
Activity Monitor Moomin
killall "⠀⠀⠀⠀⠀⠀⠀⢠⢦⡀⠀⡰⣩⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀"
killall "⠀⠀⠀⠀⠀⠀⠀⠘⣄⠙⠍⠁⠙⠦⡀⠀⠀⠀⠀⠀⠀⠀⠀"
killall "⠀⠀⠀⠀⠀⠀⠀⠀⡎⠀⠀⡠⠄⠔⠊⠉⠒⠒⠒⢄⠀⠀⠀"
killall "⠀⠀⠀⠀⠀⠀⠀⢀⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢈⠆⠀⠀"
killall "⠀⠀⢠⢤⠜⡆⠀⢸⠀⠰⣄⠀⠀⠀⠀⠀⠀⠀⣠⠎⠀⠀⠀"
killall "⠀⠀⠱⠤⡁⠈⠑⠇⠀⠀⠀⠉⠒⠤⠤⠄⢖⠊⠀⡐⠧⣄⣀"
killall "⠀⠀⠀⠀⠘⢆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⡉⠀⣀⣨⡷"
killall "⠀⠀⠀⠀⠀⠈⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢱⠜⠁⠀⠀"
killall "⠀⠀⠀⠀⠀⠀⢇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣸⠱⡀⠀"
killall "⠀⠀⠀⠀⠀⠀⠸⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠁⠀⣣⠀"
@lunasorcery
lunasorcery / dragon_curve.c
Created February 28, 2013 02:28
The Dragon Curve created using GBDK's 2D plotter APIs. I know it's not entirely optimal code.
// Dragon Curve for Gameboy, using GBDK
// By Will Kirkby 2013
//
// Ported from Eelke Schipper's http://www.khanacademy.org/cs/dragon-curve/1414142328
//
// Use the up and down buttons to
// increase or decrease the number of folds.
//
// (1 << n) is used in place of pow(2, n) for speed purposes.
# https://twitter.com/lunasorcery/status/1295847638840020992
echo "[ Now building... 4 hours remaining ]"
sleep 3
echo "You can skip the wait by spending 40 gems."
echo "What would you like to do?"
read -p "> "
sleep 1
echo "You don't have any gems to spend!"
echo "What would you like to do?"
; partial disassembly from Drome Racers (GBA, 2003)
; fill a flat-colored 2D polygon that's fully inside screen bounds
_WW080006B4_jump_entry1_colored_inbounds_poly:
str r0, [sp, #4] ; back up our current renderstream pointer
; read three verts from the renderstream into (r1,r2,r3)
ldr r1, [r0, #12]
ldr r2, [r0, #16]
ldr r3, [r0, #20]