Skip to content

Instantly share code, notes, and snippets.

View djg's full-sized avatar
💭
I may be slow to respond.

Dan Glastonbury djg

💭
I may be slow to respond.
View GitHub Profile
procedure putpixel(x,y:word;color:byte); assembler;
asm
mov es,sega000
db 66h; xor ax,ax
db 66h; xor bx,bx
mov ax,x
mov bx,y
mov cl,color
db 67h,66h,8dh,1ch,9bh ;{lea ebx,[ebx+ebx*4]}
db 66h; shl bx,6
@ECHO OFF
rem Recompile PS3 shaders from ps3.cg into shader.ps3 for all techniques.
SET CGC=c:\dev\cyclone\Main\Target\win32\runtime\sce-cgc.exe
SET CGNVTOCGB=c:\dev\cyclone\Main\Target\win32\runtime\cgnv2cgbLevelC.exe
SET CONCAT=c:\dev\cyclone\Main\Target\win32\runtime\CompilePS3Shaders_release
attrib -r shader.ps3
DEL /Q *.fp *.fpo *.vp *.vpo shader.ps3
IF EXIST ps3.techniques (
@djg
djg / qq-backup-cl.bat
Created October 1, 2012 23:09
Perforce Backup
@ECHO OFF
SETLOCAL EnableDelayedExpansion
SET CL=%1
IF "_%CL%_"=="__" SET CL=default
SET "r=%__CD__%"
FOR /F "tokens=1,5,6 delims=# " %%a IN ('p4 opened -c %CL%') DO (
FOR /F "tokens=3" %%j IN ('p4 where %%a') DO (
SET p=%%j
7z u -tzip %%b%%c !p:%r%=! > nul
@djg
djg / gist:1541938
Created December 30, 2011 23:05
Please Kill Me
>graphics.lib(material.obj) : error LNK2019: unresolved external symbol "public: __thiscall boost::archive::basic_binary_oprimitive<class boost::archive::binary_oarchive,class std::basic_ostream<char,struct std::char_traits<char> > >::~basic_binary_oprimitive<class boost::archive::binary_oarchive,class std::basic_ostream<char,struct std::char_traits<char> > >(void)" (??1?$basic_binary_oprimitive@Vbinary_oarchive@archive@boost@@V?$basic_ostream@DU?$char_traits@D@std@@@std@@@archive@boost@@QAE@XZ) referenced in function "public: virtual __thiscall boost::archive::binary_oarchive_impl<class boost::archive::binary_oarchive>::~binary_oarchive_impl<class boost::archive::binary_oarchive>(void)" (??1?$binary_oarchive_impl@Vbinary_oarchive@archive@boost@@@archive@boost@@UAE@XZ)
1>graphics.lib(globallighting.obj) : error LNK2001: unresolved external symbol "public: __thiscall boost::archive::basic_binary_oprimitive<class boost::archive::binary_oarchive,class std::basic_ostream<char,struct std::char_traits<char> > >::~b
template <class CODE>
class A
{
protected:
CODE code;
// This is wrong, it needs to me template <class EVENT, class CODE> friend EVENT& createEvent(...)
template <class EVENT>
friend EVENT& createEvent(CODE code, bool down, bool repeat);
};
// Another test. RGB->YCoCg conversion. Think I discovered a problem with negative
// values being returned on RGB->YCoCg->RGB.
#include <stdio.h>
struct IVect { int x, y, z; };
/*
* [Y ] = [ 1/4 1/2 1/4][R] R, G, B = [0..255] => Y = [0..255], Co, Cg = [-128..127]
* [Co] [ 1/2 0 -1/2][G]
* [Cg] [-1/4 1/2 -1/4][B]
// Yet another test. Also had a .obj along side.
#include <winsock2.h>
int
main()
{
u_short x = 1;
x = htons(x);
return x;
// One of many test.cpp I found. I think this one was for examining the generated assembly.
#include "xmmintrin.h"
#if 0
struct Vec3
{
float x, y, z;
__forceinline Vec3() {};
__forceinline Vec3(float X, float Y, float Z) : x(X), y(Y), z(Z) {};
__forceinline Vec3 operator*(const Vec3& t) const { return Vec3(x*t.x, y*t.y, z*t.z); };
// Compile with cl /O2 sorting.cpp winmm.lib
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
void exch(int& a, int& b)
{
int tmp = a; a = b; b = tmp;
}
enum Flags
{
Flag1 = 0x1,
Flag2 = 0x2,
Flag3 = 0x4,
Flag4 = 0x8
};
Flags operator|(Flags a, Flags b)
{