Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew G. Crowell Bananattack

View GitHub Profile
@Bananattack
Bananattack / CASTLEVANIA2 BELMONTS REVENGE.txt
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.
View CASTLEVANIA2 BELMONTS REVENGE.txt
CASTLEVANIA2 BEL
----------------
5 sample(s) captured.
Sample #1
---------
HEX:
@Bananattack
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
#ifndef WIZ_UNIQUE_PTR_H
#define WIZ_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
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
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
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 https://gist.github.com/Bananattack/1e2d3bbbf80f9ab63779 -- Probably not as useful in C++17 which has std::variant, but still nice for slightly older compilers.
View variant.h
#ifndef WIZ_UTILITY_VARIANT_H
#define WIZ_UTILITY_VARIANT_H
#include <cstddef>
#include <cassert>
#include <type_traits>
#include <utility>
namespace wiz {
namespace detail {
@Bananattack
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
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 Format.md

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
Bananattack / class_registry.h
Created Oct 10, 2016
class binding + deserialization
View class_registry.h
#ifndef CLASS_REGISTRY_H
#define CLASS_REGISTRY_H
// Uses sajson: https://github.com/chadaustin/sajson
#include "sajson.h"
#include <unordered_map>
#include <memory>
#include <limits>
#include <functional>