Skip to content

Instantly share code, notes, and snippets.

@AlaskanEmily
AlaskanEmily / em_gb_asm.py
Created September 30, 2025 18:42
em_gb_asm (Emily's Gameboy Assembler)
# Copyright (c) 2021-2025, AlaskanEmily, Transnat Games
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# This Source Code Form is “Incompatible With Secondary Licenses”, as
# defined by the Mozilla Public License, v. 2.0.
import sys
@AlaskanEmily
AlaskanEmily / wu.c
Created March 20, 2025 23:47
Wu line algorithm, partially with SSE intrinsics (UNTESTED)
#include <math.h>
#ifdef _MSC_VER
# define WU_ALIGN(N) __declspec(align(N))
#else
# define WU_ALIGN(N) __attribute__((__aligned__(N)))
#endif
#if (defined _M_AMD64) || (defined __amd64) || (defined __x86_64__)
# include <stdint.h>
# ifdef _MSC_VER
# include <intrin.h>
/* Any copyright of this file is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
#ifndef YYY_TEST_H
#define YYY_TEST_H
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
H4sIANlCsWAA/4WRT2sCMRDFv4rk1ILCzKwV2ZzKUvBShF5LD3GNNZBNZDd7sKKfvTPxvz30Ms y+hH2/97JTLmz6NPqJwXaq3CmQkTX+/NypJnpb996qUlWmXcTg6sFr7ZZ6dgCq5gcoNNAUUSNN EDQUCKDpOGkKrOMUSA1VHfuQVIm0/9oPFf5j48821QEmbPUyn2nAqTgA5r9OCDXhhJ2JnUljIf 6UJ7MA6SJTMBErMninvBPvD0SMFPv0t4kbrnfjr+krif9UzeezZ140glRQcGAQNDjWcUZjcBK0 fFpcQQhkFzS8wYFzPbedbGsfF30yS2eDlVLGDDA+lZ4D5TIoO17iorhg1rPjnQvbrE038qb9tq NjeFWujO/sUPE7L207Ol0eH292NnSxvdwRadV39l7pNt6l9CAm6+0mtrdy2m4kWGs7a9p6zWTB NKJIvYMPW8dm4YJJLgY+M31ai7V6a5zfsrB0q5XjctJWlbD/BX5wq9TGAgAA
@AlaskanEmily
AlaskanEmily / tga_to_gb.py
Created April 3, 2021 22:17
TGA to Gameboy ASM conversion utility
#!/usr/bin/env python
"""Converts a TGA file to an assembly file with sprites."""
debug = False
def _read_8(bytes, at):
b = bytes[at]
if isinstance(b, str):
b = ord(b)
@AlaskanEmily
AlaskanEmily / c_enum.awk
Created April 3, 2020 01:33
Silly awk script that converts C/C++ enum's
BEGIN{
# States:
# 0 enum 1 <name> 2 { 3 name, (*) } 4 ; 0...
# This also means we don't handle a `name = VALUE` situation.
# We would need to lazily emit values to do that.
start=0;
found_enum=1;
found_name=2;
found_open=3;
found_close=4;
@AlaskanEmily
AlaskanEmily / resolution.c
Last active January 8, 2022 17:28
Remote program resolution hacking
/*
* Remote Program Resolution (payload)
*
* Copyright (C) 2019 AlaskanEmily
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
@AlaskanEmily
AlaskanEmily / laa.py
Created September 21, 2019 19:33
Windows large address aware script, much less scary than downloading a random EXE to do it
# I DID NOT WRITE THIS, AND I DON'T REMEMBER WHERE IT'S FROM.
# See http://en.wikibooks.org/wiki/X86_Disassembly/Windows_Executable_Files#PE_Header
# and https://msdn.microsoft.com/en-us/library/ms680349%28v=vs.85%29.aspx
import struct
IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020
PE_HEADER_OFFSET = 60
CHARACTERISTICS_OFFSET = 18
@AlaskanEmily
AlaskanEmily / ITS_A_TRAP.cpp
Created July 30, 2019 20:25
Fun fact, "2" < "10", and "20" < "10".
#include <stdio.h>
#include <stdlib.h>
#include <string>
#define COMPARE(A, B) printf(#A " < " #B ": %s\n", std::string(A) < std::string(B) ? "true" : "false");
int main(int argc, char **argv)
{
(void)argc;
(void)argv;
@AlaskanEmily
AlaskanEmily / mflow.list.m
Last active January 25, 2019 01:59
MFlow, a simple set of layout functions in Mercury, with bindings for C.
% Any copyright is dedicated to the Public Domain.
% http://creativecommons.org/publicdomain/zero/1.0/
:- module mflow.list.
%=============================================================================%
% The few list operations which need to do import_module instead of use_module
% on list.
:- interface.
%=============================================================================%