Skip to content

Instantly share code, notes, and snippets.

View whitequark's full-sized avatar
🐈‍⬛

Catherine whitequark

🐈‍⬛
View GitHub Profile
@whitequark
whitequark / gist:ed0d0967efab26f2699a7251bf0bd40d
Last active March 13, 2023 11:30
Godox X1T on-air protocol description
CH1 is at 2.413G, format is 250kbps FSK.
All packet bits are inverted wrt nRF24L01+.
<PACKET>:
0xAA 0xAA 0xAA 0xAA 0xC3 0x68 0xC3 0x68 <PAYLOAD>
<PAYLOAD>:
<CONTROL>
<CONFIG>

$ cat ~/fragment8.txt

• The year is 𝟮𝟬𝟴𝟯.

In a post-Amazon world, brain-computer interfaces are widespread. Although expensive, with the total operating cost approaching 20 years of median United States income (and reducing life expectancy by about as much), they are essential for employment. Most people, even young adults, adapt to the newly acquired sensory and control capabilities only in a rudimentary way. Still, this gives you enough of an advantage over your peers that the last two decades saw a steep decline in workplaces where an unaltered human could succeed; or pass a single performance review.

Every parent looking out for their child's future wants to see them transition to the altered life as early as they can—and, since the CLEAR MINDS Act passed in 2061, that means the age of 24. With the prefrontal cortex fully formed and the brain's plasticity almost gone, even the latest low-power hybrid ASIC driving hundreds of implanted electrodes amounts to little more than an awkward way to keep up wit

@whitequark
whitequark / jt51_player.cc
Last active January 22, 2021 02:22
JT51 + CXXRTL + VGM = <3 <3
// Step 1: Obtain Yosys from git.
// Step 2: Download jt51 from https://github.com/jotego/jt51.
// Step 3: Build as follows:
// $ yosys jt51/hdl/*.v -b 'cxxrtl -header' -o jt51_core.cc
// $ CFLAGS="-fbracket-depth=2048 -I$(yosys-config --datdir/include)"
// $ clang++ -O3 $CFLAGS jt51_core.cc jt51_player.cc -o jt51_play
// Step 4: Convert as follows:
// $ python3 vgm2tsv.py music.vgm music.tsv
// Step 5: Play as follows (assuming YM2151 clocked at 4 MHz):
// $ ./jt51_play music.tsv music.wav 4000000
@whitequark
whitequark / jt51_driver.cc
Last active December 22, 2020 12:23
JT51 + CXXRTL = <3
// Step 1: Obtain latest Yosys from https://github.com/YosysHQ/yosys/.
// Step 2: Download jt51 from https://github.com/jotego/jt51.
// Step 3: Build as follows:
// $ yosys jt51/hdl/*.v -b 'cxxrtl -header' -o jt51_core.cc
// $ CFLAGS="-fbracket-depth=2048 -I$(yosys-config --datdir/include)"
// $ clang++ -O3 $CFLAGS jt51_core.cc jt51_driver.cc -o jt51_sim
// Step 4: Enjoy!
#include <fstream>
#include <backends/cxxrtl/cxxrtl_vcd.h>
#lang rosette/safe
(require rosette/lib/angelic
(only-in racket/base syntax->datum))
(define-syntax-rule (define-distinct v x ...)
(begin
(define x v) ...
(assert (distinct? x ...))))
(define-syntax-rule (list-choices x ... sol)
(list (list (evaluate x sol) (syntax->datum #'x)) ...))
@whitequark
whitequark / minlogic.rkt
Last active September 21, 2024 03:52
Logic minimizer with a configurable cost function in 50 lines of Rosette (https://github.com/emina/rosette)
#lang rosette/safe
(require rosette/lib/angelic
rosette/lib/match)
(define (^^ x y) (|| (&& x (! y)) (&& (! x) y)))
(struct lnot (a) #:transparent)
(struct land (a b) #:transparent)
(struct lor (a b) #:transparent)
(struct lxor (a b) #:transparent)
(struct lvar (v) #:transparent)
#lang rosette/safe
(require rosette/lib/angelic
rosette/lib/match)
(current-bitwidth #f)
(require (only-in racket list*))
; bit operations
(define (rotate-right i x)
@whitequark
whitequark / echofile.py
Created October 14, 2019 23:06
file transfer via `echo -ne`
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"file", metavar="FILE", type=argparse.FileType("rb"),
help="source file")
parser.add_argument(
# iCE40HX8K-B-EVN
set_io clk J3
set_io tx B12
lcall _delay_4c
sjmp .
_delay_4c::
; (ljmp delay_4c) ; 0c > 4c
mov acc, dph ; 3c
cjne a, #0, 00000$ ; 4c > 11c [A]
mov acc, dpl ; 3c
subb a, #(24/4+1) ; 2c
inc a ; 1c