Skip to content

Instantly share code, notes, and snippets.

View scottferg's full-sized avatar

Scott Ferguson scottferg

  • Numerator/InfoScout
  • Chicago, IL
View GitHub Profile
func (p *Ppu) renderTileRow() {
// 32 total loops for 32 tiles, 1 pixel of each
for x := 0; x < 32; x++ {
// for i := a; i < a+0x20; i++ {
attrAddr := 0x23C0 | (p.VramAddress & 0xC00) | int(p.AttributeLocation[p.VramAddress&0x3FF])
shift := p.AttributeShift[p.VramAddress&0x3FF]
attr := ((p.Vram[attrAddr] >> shift) & 0x03) << 2
ntAddress := p.selectNametable((p.VramAddress & 0xC00) >> 10)
t := p.bgPatternTableAddress(p.Vram[(p.VramAddress&0x3FF)+ntAddress])
@scottferg
scottferg / ppu.go
Created September 9, 2012 21:58
Fubar PPU
package main
import (
"math"
)
const (
StatusSpriteOverflow = iota
StatusSprite0Hit
@scottferg
scottferg / ppu.go
Created September 5, 2012 22:16
Partial NES PPU/nametable viewer written in Go
package main
const (
StatusSpriteOverflow = iota
StatusSprite0Hit
StatusVblankStarted
MirroringVertical
MirroringHorizontal
@scottferg
scottferg / apns.go
Created August 29, 2012 16:10
iOS Push notification service in Go
package main
import (
"bytes"
"crypto/tls"
"encoding/binary"
"encoding/hex"
"encoding/json"
"fmt"
package main
type Cpu struct {
X Word
Y Word
A Word
P Word
CycleCount int
StackPointer Word
Verbose bool
@scottferg
scottferg / gist:3189926
Created July 27, 2012 19:16
MenuInflater example
@Override
public boolean onCreateOptionsMenu(Menu aMenu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.my_main_menu, aMenu);
return true;
}
import os
import sys
sys.path.append(os.path.dirname(__file__))
sys.path.append('/usr/local/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
@scottferg
scottferg / adb_install.sh
Created September 15, 2010 14:32
Small shell script to easily deploy an Android debug build to all connected devices using adb
#!/bin/bash
for x in `adb devices | awk '/device$/ {print $1}'`; do
echo `adb -s $x install -r bin/*-debug.apk`
sleep 0;
done
@scottferg
scottferg / salr.js
Created August 31, 2010 01:46 — forked from Rohaq/salr.js
// Copyright (c) 2009, Scott Ferguson
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
@scottferg
scottferg / LinuxMultitouch.py
Created August 24, 2010 02:13
Hard coded multitouch desktop gestures for Ubuntu/GNOME. To use it, enable the Dbus/Scale/Rotate plugins in Compiz.
from pymt import *
import sys, dbus, subprocess, os
import time
class Tracer(MTWidget):
SWIPE_X_THRESHOLD = 220
SWIPE_Y_THRESHOLD = 100
LEFT_SWIPE, RIGHT_SWIPE = range(2)
block = False