Skip to content

Instantly share code, notes, and snippets.

View Bananattack's full-sized avatar

Andrew G. Crowell Bananattack

View GitHub Profile
@Bananattack
Bananattack / inputdemo.asm
Created June 24, 2016 07:00
p80 - A virtual machine for pico8. Mainly just a proof of concept to test ideas to get around pico-8 size limitations.
; Example: move a sprite with buttons (drawn externally during yield)
b0 EQU $0000
b1 EQU $0001
b2 EQU $0002
b3 EQU $0003
b4 EQU $0004
b5 EQU $0005
b6 EQU $0006
b7 EQU $0007
b8 EQU $0008
@Bananattack
Bananattack / readme_zoom2x.md
Last active May 21, 2016 21:13
A two-pass paletted pixel-scaling algorithm that uses weighting counting of adjacent colors and a fitness function (for tie-breaking) to create a 2x scale image. This is not an efficient implementation, just a quick-and-dirty proof of concept.

The "zoom2x" algorithm

by Andrew G. Crowell

A two-pass paletted pixel-scaling algorithm that uses weighting counting of adjacent colors and a fitness function (for tie-breaking) to create a 2x scale image.

This is not an efficient implementation, just a quick-and-dirty proof of concept. So it is mainly useful for offline rendering right now, but a few optimizations to create less temporary memory and it could be made pretty quick. In particular, the best_sample function will create a dictionary every call, resulting in a lot of garbage. This algorithm could directly work on an indexed image instead and then the weight array be a fixed-length array that is the size of the image color palette (possibly 16 or 256-color or whatever) that's shared between calls and just cleared before use, and then this should result in way fewer allocations. Also somebody could write it in a systems language like C++ or Rust instead of Python -- which would also help a lot, and hopefully wouldn't be too bad to port.

Tu

@Bananattack
Bananattack / Instructions - Pico8 Sublime.md
Last active February 5, 2021 19:36
PICO-8 syntax highlighting and theme in Sublime Text 2.

PICO-8 in Sublime Text 2

Syntax Highlighting

  1. Open up your Packages folder by going Preferences >> Browse Packages...
  2. Create a new folder named "Pico8"
  3. Save the Pico8.tmLanguage file there.

Color Scheme

@Bananattack
Bananattack / variant.h
Last active February 27, 2016 22:17
a C++14 single-header variant type. Allows defining type-safe tagged unions with pattern-matching/visiting. probably has some implementation mistakes. Might use this for wiz, my high-level assembly language project.
#ifndef WIZ_VARIANT_H
#define WIZ_VARIANT_H
#include <cstddef>
#include <type_traits>
#include <utility>
namespace wiz {
template<std::size_t... Ns>
struct max_value;