Skip to content

Instantly share code, notes, and snippets.

@biomood
biomood / MoveSprite.asm
Created May 31, 2011 20:49
A C64 example in assembly that moves a sprite up/down/left/right
;*************************************************
;* Create and move a simple sprite x,y *
;*************************************************
processor 6502
org $1000
;helpful labels
CLEAR = $E544
GETIN = $FFE4
@biomood
biomood / Mergesort.lua
Created August 8, 2011 20:30
MergeSort in Lua
--[[ Implementation of MergeSort --]]
-- main mergesort algorithm
function mergeSort(A, p, r)
-- return if only 1 element
if p < r then
local q = math.floor((p + r)/2)
mergeSort(A, p, q)
mergeSort(A, q+1, r)
merge(A, p, q, r)
@biomood
biomood / TempLogger.cpp
Created May 4, 2011 19:41
Arduino and Python Temperature Logger
#include <OneWire.h>
#include <DallasTemperature.h>
// pin setups
int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
int tempPin = 7;
char recMsg = '0';
@biomood
biomood / HelloWorld_ScreenMemory.asm
Created May 25, 2011 20:35
C64 Assembly Hello World (using screen memory)
;put Hello World using screen address
;rather than jsr $e716
processor 6502
org $1000
jsr $E544 ;clear the screen
;set the screen color memory
lda #0 ;black in A
@biomood
biomood / chumby_framebuffer.c
Created May 1, 2011 19:58
Writing to the frame buffer on a chumby in c
#include <stdio.h>
#include <stdlib.h>
#define FRAMESIZE 320*240*2
char * framebuffer;
void set_screen(FILE * frame);
void set_colour(FILE * frame, char colour[]);
void draw_pixel(int x, int y, char * colour);
char * rgb_to_byte(int red, int green, int blue);
@biomood
biomood / Love2D_KeyTest.lua
Created May 31, 2011 20:43
Love2D code for seeing what key/joystick button is pressed
game = {}
game.button= ""
game.key = ""
function love.load()
success = love.graphics.setMode(320, 240, false, 0)
end
function love.update(dt)
end
@biomood
biomood / HelloWorld.asm
Created May 25, 2011 05:47
C64 Assembly Hello World (using jsr $E716)
processor 6502
org $1000
jsr $e544 ;clear the screen
lda #72 ;load ascii value for H into A
jsr $e716 ;display H from A to screen
lda #69 ;load E into A
jsr $e716 ;display E
#include <IRremote.h>
#include "Timer.h"
#define CMD_CONST_COLOUR (1 << 4)
#define CMD_FLASH (1 << 5)
#define CMD_ALT (1 << 6)
#define CMD_OFF 0
#define COL_RED_K (1 << 4)
#define COL_GREEN_K (1 << 5)
@biomood
biomood / PerlinNoise.c
Created May 21, 2012 19:04
perlin noise in C, uses lodepng library
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include "lodepng.h"
#define WIDTH 400
#define HEIGHT 400
#define PI (3.141592653589793)
@biomood
biomood / Screen.c
Created March 18, 2012 17:30
Lua library for accessing the framebuffer of a chumby
/*
* A Lua library in C to display interface
* with the chumby frame buffer
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>