Skip to content

Instantly share code, notes, and snippets.

@fp64
fp64 / keymap.h
Created December 24, 2025 02:23
Quick-and-dirty conversion between VK_* and SDLK_* keycodes.
// Public Domain under http://unlicense.org, see link for details.
// Quick-and-dirty conversion between VK_* and SDLK_* keycodes.
// Rudimentary, and generally assumes US ANSI keyboard.
static long vk2sdlk(long key)
{
static const long S=1L<<30,lut[256]={
0, 0, 0,S|155, 0, 0, 0, 0, 8, 9, 0, 0,S|156, 13, 0, 0,
0, 0, 0,S| 72,S| 57, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0,S| 1,
Move-optimal solutions to "auto-generated" sokoban level set
(Yoshio Murase, https://www.ne.jp/asahi/ai/yoshio/sokoban/auto52/index.html)
soko001.txt luuluRurrrddlLrruullldlddrdrrUdlluluururrrddLddlluUddrruuLUdrddlluluuRuRDllddrUddrruuL
soko002.txt lllddddrUluuurrddLdlUrruurrddLdLUlldRurrruullllDDrrUdlluurRddlddlUUrrrdLullddrUruuullDDRdrUrruuL
soko003.txt lDLddddlUruuurrdLulDlluRRdDDlUruulldRurDrruL
soko004.txt ldLruulDLDRRdrUUUlldldlddrUUlUUdRRRdrU
soko005.txt ldDurrdLdLLdlluurDDrurruulDrdLLddrUUldlluurDldRurrruulDrdLLLdlUrrrdLL
soko006.txt uluurDrrrrddLLUdrruulLLulldRlddrUUluRdddRRuuLrddlluUrrrrddL
soko007.txt dlluluuRDDlddrruruuLrruullDlDRllddRUluurrdRdrUUdlddLdlU
// Public Domain under http://unlicense.org, see link for details.
// Generator of test cases for PSP vdot instruction.
// Version 1.0.
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@fp64
fp64 / anta.h
Created June 13, 2025 12:50
Processed data (scattering coefficient, phase function, etc.) for models from Optical Properties of Aerosols and Clouds (OPAC). 80% humidity assumed for all models.
static double anta_coef[61][3]={
//wavelength ext.coef sca.coef
// [um] [1/km] [1/km]
{ 2.500E-01,1.387E-02,1.386E-02},
{ 3.000E-01,1.389E-02,1.388E-02},
{ 3.500E-01,1.366E-02,1.364E-02},
{ 4.000E-01,1.321E-02,1.320E-02},
{ 4.500E-01,1.269E-02,1.268E-02},
{ 5.000E-01,1.210E-02,1.210E-02},
{ 5.500E-01,1.149E-02,1.148E-02},
# START OF HEADER
#
# Measured sky radiance data, from [1], converted
# into CIE XYZ tristimulus values (see [2]).
# See also [3] for visualization and additional info.
#
# Location: the roof of Rhodes Hall at Cornell University.
# Latitude: 42.443449
# Longitude: -76.481962
#
@fp64
fp64 / biquadratic.html
Created March 7, 2025 03:05
On integrals of biquadratic gaussians
<h1 class="line" data-line="0">On integrals of biquadratic gaussians</h1>
<p class="line" data-line="2">This short note aims to prove that</p>
<p class="line" data-line="4" align="center"><svg class="svg-preview" id="s2tex_0" style="vertical-align:-13.25626pt; opacity: 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="629" height="46" viewBox="1872.02 1482.793 375.99 27.497"><defs><path id="s35g2-6" d="M4.462-3.415h3.033c.185 0 .381 0 .381-.218s-.196-.218-.381-.218H4.462v-3.01c0-.175 0-.404-.218-.404s-.219.196-.219.37v3.044H.982c-.186 0-.382 0-.382.218s.196.218.382.218h3.043v2.979H.982c-.186 0-.382 0-.382.218S.796 0 .982 0h6.513c.185 0 .381 0 .381-.218s-.196-.218-.381-.218H4.462z"></path><path id="s35g2-7" d="M4.462-1.604h3.033c.185 0 .381 0 .381-.218s-.196-.218-.381-.218H4.462v-2.978h3.033c.185 0 .381 0 .381-.218s-.196-.219-.381-.219H.982c-.186 0-.382 0-.382.219s.196.218.382.218h3.043v2.978H.982c-.186 0-.382 0-.382.218s.196.218.382.218h3.043V1.44c0 .175 0 .37.219.37s.218
@fp64
fp64 / demo.c
Last active February 17, 2025 04:59
Somewhat basic WinAPI & SDL2 graphical program.
// Public Domain under http://unlicense.org, see link for details.
// Self-reference: https://gist.github.com/fp64/1a3166ca35118167af8839b40d4e7b94
// Minimalist version: https://gist.github.com/fp64/2e25143e754424d4a2f592d9493451bc
// Somewhat minimalistic dual-backend C program for plain WinAPI and SDL2,
// that creates a (possibly fullscreen) window and provides keyboard input
// and in-memory colorbuffer to draw to (no GAPI, i.e. softrender).
// Compilation, WinAPI (assuming MinGW):
// gcc -std=c99 -O2 demo.c -o demo.exe -mwindows -static
@fp64
fp64 / demo.c
Last active February 17, 2025 05:09
Basic WinAPI & SDL2 graphical program.
// Public Domain under http://unlicense.org, see link for details.
// Self-reference: https://gist.github.com/fp64/2e25143e754424d4a2f592d9493451bc
// Expanded version: https://gist.github.com/fp64/1a3166ca35118167af8839b40d4e7b94
// Minimalistic dual-backend C program for plain WinAPI and SDL2,
// that creates a (non-resizable) window and provides keyboard input
// and in-memory colorbuffer to draw to (no GAPI, i.e. softrender).
// Compilation, WinAPI (assuming MinGW):
// gcc -std=c99 -O2 demo.c -o demo.exe -mwindows -static
@fp64
fp64 / gohufont-11.h
Last active February 2, 2025 01:17
Gohufont embedded as C-style arrays
// Public Domain under http://unlicense.org, see link for details.
// NOTE: gohufont (https://font.gohu.org/) itself
// is licensed under WTFPL (http://www.wtfpl.net/about/).
// Bitmap font, embeded as a C/C++ array.
// NOTE: this file isn't a "proper" C/C++ header.
// You are expected to e.g. #include it in the middle of a .c file.
// Usage: pixel at position (x,y) from the lower-left
@fp64
fp64 / glhf.cpp
Created November 23, 2024 21:21
A proof-of-concept lossless random-access compressor for GLSL (and C).
// Public Domain under http://unlicense.org, see link for details.
// A lossless random-access compressor for GLSL (and C).
// Version 1.0.
// WARNING: proof-of-concept, may be buggy.
// See https://www.shadertoy.com/view/4cdyWN for usage example.
//
// Compilation:
// g++ -O3 glhf.cpp -o glhf
// Example of usage: