This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PIL import Image | |
# attempts to convert an image into a format that makes the most of the Sega Genesis graphics hardware | |
# i.e. 64 colours organized into 4 16-colour palettes, with each 8x8 tile using one palette | |
# based on an algorithm described by tokumaru on the NESdev forums | |
# see here: http://forums.nesdev.com/viewtopic.php?f=23&t=14073 | |
BLOCK_SIZE = 8 | |
PALETTE_COUNT = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* based on Pottier and Conchon, Information | |
Flow Inference for Free *) | |
Require Import Autosubst. | |
(* as in the original paper, for now we leave | |
the set of labels entirely abstract *) | |
Inductive term {label : Set} : Type := | |
| Const (k : nat) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; HL = src | |
;; DE = dest | |
Decompress:: | |
.chunk LD A, [HLI] ; get flags | |
LD B, A ; put flags in B | |
LD C, 8 ; 8 commands per chunk | |
.command LD A, [HLI] ; get next byte | |
BIT 0, B ; is this flag hi? | |
JR NZ, .literal ; if so, we have a literal | |
AND A ; otherwise, check for EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Applicative | |
data Regex = | |
Literal Char | |
| Concat Regex Regex | |
| Altern Regex Regex | |
| Star Regex | |
match :: Regex -> String -> Bool | |
match r s = "" `elem` (consume r s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DoRec #-} | |
import Control.Monad.State | |
import Data.Set (Set) | |
import qualified Data.Set as Set | |
data Regex = | |
Literal Char | |
| Concat Regex Regex | |
| Altern Regex Regex | |
| Star Regex |