Skip to content

Instantly share code, notes, and snippets.

@tuttlem
tuttlem / gist:4151995
Created November 27, 2012 02:22
Adding 64bit link to C
global add
section .text
add:
mov rax, rdi ; get the first parameter
add rax, rsi ; add the second parameter
; leaving the return value in rax
ret
@tuttlem
tuttlem / gist:4152023
Created November 27, 2012 02:29
Add program 64 (compilation)
gcc -c add.c -o add.o
nasm -f elf64 maths.asm -o maths.o
gcc -m64 add.o maths.o -o add
@tuttlem
tuttlem / gist:4153854
Created November 27, 2012 11:47
Musica - notes info
>>> Notes.by_distance(0)
<musica.notes.Note object at 0x10f961090>
>>> Notes.by_distance(0).__unicode__()
'c'
@tuttlem
tuttlem / gist:4153859
Created November 27, 2012 11:48
Musica - scales info
>>> Scales.scales[0]
<musica.scales.Scale object at 0x10f963090>
>>> Scales.scales[0].name
'Ionian'
>>> Scales.scales[0].intervals
[<musica.intervals.Interval object at 0x10f961950>, <musica.intervals.Interval object at 0x10f9619d0>, <musica.intervals.Interval object at 0x10f961a50>, <musica.intervals.Interval object at 0x10f961a90>, <musica.intervals.Interval object at 0x10f961b10>, <musica.intervals.Interval object at 0x10f961b90>, <musica.intervals.Interval object at 0x10f961c10>]
@tuttlem
tuttlem / gist:4153871
Created November 27, 2012 11:52
Musica - voicing a scale
>>> steps = Scales.scales[0].voice(Notes.by_distance(0))
>>> for s in steps:
... print 'note: ' + s['note'].__unicode__() + ', interval: ' + s['interval'].short_name
...
note: c, interval: PU
note: d, interval: M2
note: e, interval: M3
note: f, interval: P4
note: g, interval: P5
note: a, interval: M6
@tuttlem
tuttlem / gist:4161317
Created November 28, 2012 13:33
RecreateBuffer
RecreateBackBuffer PROC hWin:DWORD
; make sure we've destroyed anything already setup
invoke DestroyBackBuffer, hWin
; get an updated reading on the window's area
invoke GetClientRect, hWin, ADDR clientRect
; acquire a new DC for the window
invoke GetDC, hWin
@tuttlem
tuttlem / gist:4161329
Created November 28, 2012 13:36
DestroyBackBuffer
DestroyBackBuffer PROC hWin:DWORD
; determine if we need to destroy the memory DC
cmp memDC, NULL
je MemoryDCDeallocated
; we do, so kill off these GDI objects
invoke SelectObject, memDC, memOldBitmap
invoke DeleteObject, memBitmap
invoke DeleteDC, memDC
@tuttlem
tuttlem / gist:4161348
Created November 28, 2012 13:38
FlipBackBuffer
FlipBackBuffer PROC hWin:DWORD
LOCAL hDC:HDC
LOCAL ps:PAINTSTRUCT
; start painting the window
invoke BeginPaint, hWin, ADDR ps
mov hDC, eax
; work out the dimensions to blit
@tuttlem
tuttlem / gist:4161383
Created November 28, 2012 13:43
DoubleBuffer - MessagePump
StillRunning:
; check if there are messages on the queue to process
invoke PeekMessage, ADDR msg, NULL, 0, 0, PM_REMOVE
; if not, get on with rendering
cmp eax, 0
je RenderFrame
; dispatch the message as needed
@tuttlem
tuttlem / gist:4161428
Created November 28, 2012 13:48
DoubleBuffer - WndProc
WndProc PROC hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
; determine which message we need to process
cmp uMsg, WM_CREATE
je CreateMessage
cmp uMsg, WM_DESTROY
je DestroyMessage