Skip to content

Instantly share code, notes, and snippets.

View RealNeGate's full-sized avatar

Yasser Arguelles Snape RealNeGate

  • Washington, USA
View GitHub Profile
@bnnm
bnnm / lz4.c
Created March 7, 2020 00:14
LZ4 from XNB decompressor
// Decompresses LZ4 found in XNB (just a test tool for vgmstream).
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
/* Decompresses LZ4 from MonoGame. The original C lib has a lot of modes and configs, but
* MonoGame only uses the core 'block' part, which is a fairly simple LZ77 (has one command
* to copy literal and window values, with variable copy lengths).
@billti
billti / arm64-on-Win10.md
Last active March 13, 2025 20:04
ARM64 Linux on Win10

Below are the steps to get an ARM64 version of Ubuntu running in the QEMU emulator on Windows 10.

Install QEMU

Install for Windows from https://qemu.weilnetz.de/w64/ (I used qemu-w64-setup-20181211.exe)

Put C:\Program Files\qemu on your PATH, and run the below to check it's working (which will list out the CPUs the AArch64 emulator can emulate):

qemu-system-aarch64 -M virt -cpu help
/* clang-format off */
/*
ijss : IncredibleJunior SparseSet
sparse set [1] for bookkeeping of dense<->sparse index mapping or
a building block for a simple LIFO index/handle allocator
[1] https://research.swtch.com/sparse
*/
@cellularmitosis
cellularmitosis / README.md
Last active April 8, 2025 19:17
Jason Pepas' Technical Blog
@nbouteme
nbouteme / ss-fs.glsl
Last active October 29, 2024 09:54
Skyward Sword Brush shader. Accurately emulates what's done with TEVs in a shader. Does NOT include the blurring pass.
#version 300 es
precision highp float;
in vec2 UV;
out vec4 out_color;
uniform float ratio, time;
uniform sampler2D texture0;
const float PI_3 = 1.0471975512;
@fnky
fnky / ANSI.md
Last active April 9, 2025 13:35
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
typedef struct intern_t {
intern_t *next;
uint32_t length; // can be narrower if you want to limit internable string length, which is a good idea.
char str[1];
} intern_t;
hashtable_t string_table;
const char *string_intern(const char *str, uint32_t length) {
uint64_t key = string_hash(str, length);
@idbrii
idbrii / botw-cedec2017.md
Last active January 29, 2025 23:58
An inline image version of Matt Walker's translation of CEDEC 2017 talks by Nintendo

I've been trying to get clarity on to what extent the position-independent data structure tricks in Gob (https://gist.github.com/pervognsen/c25a039fcf8c256141ef0778a1b32a88) are legal or illegal according to the C standard. I always had the impression it would run afoul of strict aliasing or pointer casting restrictions, but I've been digging into the standard, and now I'm no longer so sure. It might be perfectly legal after all?

Here's section 6.3.2.3 on pointer conversions from the C99 draft standard. I'll be referencing the C99 standard throughout this article, but I've verified that the C11 standard hasn't changed in the relevant areas.

"5 An integer may be converted to any pointer type. Except as previously specified, the result is implementation-defined, might not be correctly aligned, might not point to an entity of the referenced type, and might be a trap representation. [56]

6 Any pointer type may be converted to an integer type. Except as previously specified, the result is implementation-defined

typedef struct {
char *address;
char *reference;
} label_t;
void emit_label_reference(label_t *label) {
if (label->address) {
emit4(label->address - emit_pointer);
} else {
char *reference = emit_pointer;