Skip to content

Instantly share code, notes, and snippets.

View andrewrcollins's full-sized avatar

Andrew Collins andrewrcollins

View GitHub Profile
@andrewrcollins
andrewrcollins / SNAFUX.PAS
Created January 4, 2012 15:02
#TJHSST ~ Text-Based Landscapes and "Snafux" (Turbo Pascal 5.5)
program The_Revenge_of_the_Snafux_for_IBMs;
uses crt,graph;
type
what = (play,enem,bloc,empt);
loc = record bx,by : integer end;
var
gr,gd,x,y,px,py,opy,opx,ex,ey,oex,oey,lvl,dif : integer;
killed,win,quit : boolean;
grid : array[0..29,0..15] of what;
blok : array[1..100] of loc;
@andrewrcollins
andrewrcollins / weth.c
Created January 4, 2012 16:29
#TJHSST ~ Wire World and WETH
/*
Wires, Electron Tails, and Heads.
W.E.T.H.
A cellular automaton written in response to an article
in the Computer Recreation section of Scientific American.
Cellular automatons are rule based systems which include
the now famous game of LIFE, and its ancestors.
In WETH there are four different types of cells.
Electron Head
@andrewrcollins
andrewrcollins / mic.h
Created January 4, 2012 16:41
#TJHSST ~ MIC-1 Emulator ~ high school microcode project
/* M I C . H
Header file for the type declarations used in the various
MIC??? programs. */
/* defines for accessing the registers with these names. */
#define PC 0
#define AC 1
#define SP 2
#define IR 3
#define TIR 4
@andrewrcollins
andrewrcollins / xlat.asm
Created January 4, 2012 16:53
#TJHSST ~ Misc assembly programs from "Computer Architecture" class
;-----------------------------------------------------------------------;
; XLAT and XLATB ;
; What are they? ;
;-----------------------------------------------------------------------;
.MODEL SMALL
.STACK ; Allocate space for a stack, 1K
.DATA
DIGIT_TABLE DB '0123456789ABCDEF' ; Hex digit table
JUMP_TABLE DB 1 ; Table of jumps, array of pointers
DB 9 ; They folow the sequence
@andrewrcollins
andrewrcollins / arcview.c
Created January 4, 2012 18:11
#TJHSST ~ Huffman encoding/decoding and Hamming codes
/* ARC File Viewer */
#include <stdio.h>
/* The header portion of an ARChive file is as follows. */
typedef struct {
char headerflag; /* This flag is always 0x1a. */
char compresstype; /* In range 1..9 identifies the compression type. */
char filename[13]; /* ASCIIZ format for the filename. */
long int cfilesize; /* The compressed file's size. */
unsigned day : 5; /* Day of creation. */
@andrewrcollins
andrewrcollins / window.c
Created January 4, 2012 18:20
#TJHSST ~ Simple "windowing system" from Computer Systems Lab at TJHSST
/* A "window" unit in C. */
#include <stdio.h>
#include <conio.h>
#include <string.h>
#define HOME 1,1,80,25
#define MAX_WIN 10
#define ACTIVATE 219
#define SINGLE 0
@andrewrcollins
andrewrcollins / dsk.c
Created January 4, 2012 19:33
#TJHSST ~ Stoned II
/* analyze the FAT */
#include <stdio.h>
#include <dos.h>
#include <ctype.h>
#define ReadOnly 0x01
#define Hidden 0x02
#define System 0x04
#define Volume 0x08
#define Directory 0x10
@andrewrcollins
andrewrcollins / stokes.c
Created January 5, 2012 03:16
#TJHSST ~ Stoke's Law of Settling
#include <stdio.h>
#include <math.h>
#include <gl.h>
#include <device.h>
#define GRAVITY (double)(978.032) /* centimeters/second^2 */
#define PI (double)(3.141592653589) /* good enough approximation */
#define DELTAT (double)(0.00025) /* a very small delta time */
#define PRECISION (double)(0.00001) /* some level of precision */
/* a macro used to calculate the volume of a sphere given its diameter. */
@andrewrcollins
andrewrcollins / statistics.c
Created January 5, 2012 03:21
#TJHSST ~ Simple Statistics
/*
Statistics
*/
#include <stdio.h>
#include <math.h>
#include "statisti.h"
main(argc,argv)
int argc;
char *argv[];
@andrewrcollins
andrewrcollins / wolfram_fast.c
Created January 5, 2012 03:29
#TJHSST ~ Wolfram's One-Dimensional Cellular Automata
/*
Wolfram One-Dimensional Cellular Automata
Fast
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "graphics.h"
#include "conio.h"