Skip to content

Instantly share code, notes, and snippets.

@tuttlem
tuttlem / jenken.hs
Created September 4, 2012 11:19
Scissors, Paper, Rock!
module Main where
import System.IO
import System.Random
data Move = Scissors | Paper | Rock | Unknown deriving (Eq,Show)
data Outcome = Winner | Draw | Loser | ND deriving (Show)
str2Move :: String -> Move
str2Move s = do
@tuttlem
tuttlem / Cards.hs
Created October 10, 2012 12:55
Uno cards and shuffling
module Cards where
import System.Random
import Data.Maybe
import Data.List
import Data.Function
import Test.HUnit
import Test.QuickCheck
@tuttlem
tuttlem / gist:4131027
Created November 22, 2012 12:50
MessageBox bare vs invoke
; ------ Bare syntax ------
push MB_OK
push offset szDlgTitle
push offset szMsg
push 0
call MessageBox
; ------ Invoke syntax ------
invoke MessageBox, 0, ADDR szDlgTitle, ADDR szMsg, MB_OK
@tuttlem
tuttlem / gist:4131056
Created November 22, 2012 12:56
Base includes masm32
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
@tuttlem
tuttlem / gist:4131090
Created November 22, 2012 13:07
MessageBox Masm Heading
; #########################################################################
.386 ; minimum processor needed for 32 bit
.model flat, stdcall ; FLAT memory model & STDCALL calling
option casemap :none ; set code to case sensitive
; #########################################################################
include \masm32\include\windows.inc
include \masm32\include\user32.inc
@tuttlem
tuttlem / gist:4131110
Created November 22, 2012 13:12
MessageBox Masm Body
; #########################################################################
.code
start:
invoke GetModuleHandle, NULL ; provides the instance handle
mov hInstance, eax
invoke GetCommandLine ; provides the command line address
mov szCommandLine, eax
@tuttlem
tuttlem / gist:4137996
Created November 24, 2012 01:40
MessagePump WinMain
WinMain proc hInst :DWORD,
hPrevInst :DWORD,
szCmdLine :DWORD,
nCmdShow :DWORD
LOCAL msg :MSG
MessagePump_Loop:
; take the next message out of the queue to process
@tuttlem
tuttlem / gist:4138762
Created November 24, 2012 07:15
Smoke - main program
.model small
.stack 100h
.code
start:
mov ax, 0013h ; set 320x200x256 mode
int 10h
mov ax, 0a000h ; we can't directly address ES so
@tuttlem
tuttlem / gist:4138777
Created November 24, 2012 07:22
Smoke - palette
setup_palette:
mov cx, 255 ; 256 colour indicies to set
next_colour_idx:
mov al, 255 ; setup al so that we're setting
sub al, cl ; colour indicies from low to high
mov dx, 3c7h ; this port selects the colour index
; that we'll set r,g,b for
@tuttlem
tuttlem / gist:4138788
Created November 24, 2012 07:30
Smoke - random
randomize_lines:
mov cx, 640 ; we're going to set two rows of pixels
; at the bottom of the screen to be
; random colours, so that's 640 pixels
mov di, 63360 ; we're going to start writing these
; pixels on the last two lines so that's
; 64000 - 640