Skip to content

Instantly share code, notes, and snippets.

View mtolly's full-sized avatar

Michael Tolly mtolly

View GitHub Profile
@mtolly
mtolly / titlescreen.asm
Last active August 29, 2015 14:02
pokered - testing, what does togglecall do?
Music_TitleScreen_Ch1::
tempo 0, 144
notetype 12, 10, 0
octave 4
note C_, 4
callchannel ASubroutine
note C_, 4
togglecall
@mtolly
mtolly / titlescreen.asm
Created June 2, 2014 20:25
pokered - unknownmusic0xee appears to be the true pan control?
Music_TitleScreen_Ch1::
tempo 0, 144
duty 3
notetype 12, 10, 0
octave 3
note C_, 8
unknownmusic0xee 50 ; to the left
note E_, 8
unknownmusic0xee 237 ; to the right
note G_, 8
@mtolly
mtolly / locals.rb
Created July 31, 2014 00:11
While hunting for bugs in http://opalrb.org/ I discovered this mind-boggling behavior in standard Ruby
def x
2
end
p x # prints 2
x = 1
p x # prints 1
p x() # prints 2
# The above is... annoying, but makes sense. Here's the real WTF though:
@mtolly
mtolly / imperative.hs
Last active August 29, 2015 14:05
Updated working version of "imperative Haskell" by augustss: http://augustss.blogspot.com/2007/08/programming-in-c-ummm-haskell-heres.html
{-# LANGUAGE Haskell2010, GADTs, Rank2Types, FlexibleInstances #-}
module Main where
import Data.IORef
import Control.Applicative
data X v a where
E :: IO a -> X RValue a
V :: IO a -> (a -> IO ()) -> X v a
@mtolly
mtolly / speed1_ticks1.asm
Created October 16, 2014 02:05
Demonstrates a possible bug in Pokémon Red/Blue's music engine
Music_TitleScreen_Ch1::
tempo 150
octave 2
notetype 1, 10, 0
C_ 1
endchannel
Music_TitleScreen_Ch2::
Music_TitleScreen_Ch3::
Music_TitleScreen_Ch4::
@mtolly
mtolly / local_to_global.asm
Created December 19, 2014 02:30
An assembly file for pokemid by dannye
Music_TitleScreen_Ch1::
tempo 130
volume 7, 7
toggleperfectpitch
duty 0
notetype 6, 15, 7
octave 4
E_ 1
F_ 1
notetype 12, 15, 7
@mtolly
mtolly / vra.hs
Last active August 1, 2018 16:28
Extract game files from Vagante. UPDATE: See https://github.com/mtolly/vagante-extract for new version
{- |
Extracts and injects files from the game Vagante's data.vra.
The format (after a 0x18-byte-long header) is a simple repeating pattern:
- length of filename (4 bytes little-endian)
- filename
- length of file data (4 bytes little-endian)
- file data
The files themselves are all nice standard formats:
OGG, WAV, PNG, JSON, TTF, and OpenGL fragment shader.
-}
{- |
No attempt made to golf, but I did throw some alternate solutions in.
-}
module HW3 where
import Data.List (transpose)
skips :: [a] -> [[a]]
skips xs = zipWith const (map (f xs) [0..]) xs where
-- "zipWith const" clamps the first list to be no longer than the second.
@mtolly
mtolly / async.hs
Last active August 29, 2015 14:19
GHCJS: calling async JS functions in parallel, with time limits
{-# LANGUAGE JavaScriptFFI #-}
module Main where
import Control.Concurrent
import Control.Monad
-- | Very simple, no exception safety. Intended for async JS functions.
parallel :: [IO a] -> IO [a]
parallel fs = do
vars <- forM fs $ \f -> do
@mtolly
mtolly / music.rb
Created April 20, 2015 13:31
My script for copying and compressing music from an archive to a listening device
#!/usr/bin/env ruby
# Run from the destination root (somedevice/music/):
# .../music.rb audiosource/artist1/album1 audiosource/artist2/album2 ...
require 'fileutils'
ARGV.each do |dir|
dir = File.absolute_path(dir)
album = File.basename(dir)