Skip to content

Instantly share code, notes, and snippets.

View emoon's full-sized avatar
:octocat:
Hacking on stuff!

Daniel Collin emoon

:octocat:
Hacking on stuff!
View GitHub Profile
#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN
#include <windows.h>
#include <mmsystem.h>
#include <GL/gl.h>
#include "glext.h"
#define XRES 1280
#define YRES 720
(defun-68k integer-rotate-verts (input :reg a0
output :reg a1
matrix :reg a2 as MatrixInt
count :reg d7)
(loop dec count
(move.w (++ input) x)
(move.w (++ input) y)
(move.w (++ input) z)
(move.l x temp_x)
@emoon
emoon / Asm
Last active August 29, 2015 14:04
; Pure Lisp based assembler
(def my-fun (input1 :in d1
input2 :in d2
output :out d0)
(move.l input1 output)
(add.l input2 output))
----------------------------------------------------------------------------------------
; We can also have loop constructions by doing a macro (no need for it to be 'built-in')
VBox
{
PushButton { label = "Test", onPush = "MyNativePush" },
PushButton { label = "Test 2", onPush = function() print("Meh") end },
ComboBox
{
label = "test 4",
items = { "test", "test2" },
RSRESET
Window_Next RS.L 1 ; offset 0
Window_LeftEdge RS.W 1 ; offset 4
..
Window_SIZEOF RS.B 0
move.w #4,d7 ; 4 windows to process
lea Window,a0
.loop
move.w Window_LeftEdge(a0),d0
1 .section __TEXT,__text,regular,pure_instructions
2 .globl _main
3 .align 4, 0x90
4 _main: ## @main
5 .cfi_startproc
6 ## BB#0:
7 push RBP
8 Ltmp2:
9 .cfi_def_cfa_offset 16
10 Ltmp3:
;---------------------------------------------
;create sintab 34 bytes, d7 contains $0000ffff
;---------------------------------------------
lea Sin1024(pc),a0
moveq #0,d0 ;a=0
move.l #12500000,d1 ;b=d
lsr.w #5,d7 ;2048 values
.slop1
extern unsigned int a;
extern unsigned int b;
int main(int c, const char** v)
{
if (a-b<0)
return 0;
return 1;
}
@emoon
emoon / gist:4983834
Last active December 13, 2015 22:19
Find the 4 highest values in an array and their indices
#include <intrin.h>
#include <emmintrin.h>
#include <float.h>
#include <assert.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
const float a[] = { 1, 2, 3, 4, 1.5f, 4, 2, 12, 3, 9, 5, 9, 1, 2, 12, 3, 1, 59, 3, 4, 9 };
const size_t acount = sizeof(a)/sizeof(a[0]);
typedef struct Poly
{
int x, y, z, .. // etc values
struct Poly* next;
} Poly;
Poly* g_sortArray[MaxBuckets];
static void addPoly(Poly* poly, int z)
{