Skip to content

Instantly share code, notes, and snippets.


Andrew G. Crowell Bananattack

View GitHub Profile
Created Jul 9, 2019
wavedumper script for VBA-rr, along with some samples captured with it (incomplete dumps). public domain, use for whatever you want, no warranty/liability/etc.
5 sample(s) captured.
Sample #1
Bananattack / unique_ptr.h
Created May 22, 2019
A Unique Pointer-like type that gets ensures inlining of most operations, so they work much closer in performance to a raw pointer.
View unique_ptr.h
#include <cstddef>
#include <type_traits>
#ifdef _MSC_VER
#define WIZ_FORCE_INLINE __forceinline
#elif defined(__clang__) || defined(__GNUC__)
#define WIZ_FORCE_INLINE __attribute__((always_inline))
View interpolate.wiz
// Linearly interpolate between two values using progress as weight between them.
// Arguments:
// b = start (0 .. 255)
// c = end (0 .. 255)
// e = progress (0 .. 64),
// 0 = 100% start, 0% end
// 32 = 50% start, 50% end
// 64 = 0% start; 100% end
Bananattack / ai_wander.wiz
Last active Apr 17, 2018
Top-down NES demo in Wiz, using the current work-in-progress of the language. There are some weird things in here, but hopefully some revisions will iron out some of the strange stuff.
View ai_wander.wiz
import "ram";
import "entity";
import "directions";
import "random";
namespace ai_wander {
const direction_wait_base : [u8] = [60];
const direction_wait_random : [u8] = [60];
const wander_speed_lo : [u8] = [128];
const wander_speed_hi : [u8] = [0];
Bananattack / int128.h
Last active Aug 23, 2021
A signed 128-bit integer type. Internally stores its data in Two's Complement within two unsigned 64-bit integer parts. Still needs more testing, but basic implementation is fairly complete.
View int128.h
#ifndef WIZ_UTILITY_INT128_H
#define WIZ_UTILITY_INT128_H
#include <cassert>
#include <cstdint>
#include <cstddef>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <string>
Bananattack / variant.h
Last active Aug 31, 2017
C++14 variant type. Table-based visitor dispatch with O(1) time complexity. Improvement over previous tail-recursive version -- Probably not as useful in C++17 which has std::variant, but still nice for slightly older compilers.
View variant.h
#include <cstddef>
#include <cassert>
#include <type_traits>
#include <utility>
namespace wiz {
namespace detail {
Bananattack / typechecker.hs
Last active Apr 24, 2017
dumping ground for compiler prototyping
View typechecker.hs
-- This is a dumping ground for some ideas on how to implement compiler internals for wiz.
-- Right now does various transformations + checks on statements and expression trees.
-- It's mostly for me to prototype the type-checking and code-generation stuff.
-- I want to dig myself out of a corner with the language, and writing this in a high-level declarative way is kinda nice.
-- After I'm satisfied with how it roughly works, I want to port the implementation in C++
-- In particular, I wanted to know how to handle translating expression trees into
-- accumulated/in-place operations on registers, and forbidding any expressions with temporaries.
-- It turns out if an expression tree of left-associative operations branches only on the left side,
Bananattack / vwf.asm
Created Dec 29, 2016
Game Boy variable width font library. Include and assemble in RGBDS homebrew projects. MIT license.
View vwf.asm
; Variable Width Font Library
; by Andrew G. Crowell (@eggboycolor)
; --
; Copyright (c) 2016 Andrew G. Crowell
; Permission is hereby granted, free of charge, to any person obtaining a copy of
; this software and associated documentation files (the "Software"), to deal in
View Arduboy Platformer Map

Arduboy Platformer Map Format

braindump for planning a little sidescroller on the Arduboy

System Specs

  • 128x64 px screen
  • monochrome 1-bit color (strictly black and white)
  • ATmega32u4 16 MHz cpu
  • 2.5K RAM (~50% reserved by runtime libraries, huge chunk is screen buffer AFAICT, so we have less than NES)
Bananattack / class_registry.h
Created Oct 10, 2016
class binding + deserialization
View class_registry.h
// Uses sajson:
#include "sajson.h"
#include <unordered_map>
#include <memory>
#include <limits>
#include <functional>