Max 5 API Reference
00001 00002 #ifdef WIN32 00003 #include <windows.h> 00004 #else 00005 typedef unsigned long BOOL; 00006 #ifndef TRUE 00007 #define TRUE 1 00008 #define FASE 0 00009 #endif 00010 #endif 00011 00012 00013 // This doesn't do anything! 00014 // pj-offer.dll is a dummy DLL just to establish a 00015 // timeout on the jitter trial. 00016 static long malibu(char c); 00017 static long little(char c); 00018 static long cotton(char c); 00019 static long jiminy(long a, char b); 00020 static void creepy(char *a, unsigned char *b); 00021 00022 int main(void); 00023 int main(void) 00024 { 00025 return 0; 00026 } 00027 00028 00029 BOOL jitter_ok(char *c, unsigned char *r) 00030 { 00031 if (c&&r){ 00032 creepy(c,r); 00033 } 00034 return TRUE; 00035 } 00036 00037 //cp1 00038 static long malibu(char c) 00039 { 00040 switch (c) { 00041 case 'P': return 0; 00042 case '9': return 1; 00043 case 'G': return 2; 00044 case 'E': return 3; 00045 case 'Q': return 4; 00046 case '3': return 5; 00047 case 'N': return 6; 00048 case 'F': return 7; 00049 case '2': return 8; 00050 case 'K': return 9; 00051 case '4': return 10; 00052 case '8': return 11; 00053 case '7': return 12; 00054 case 'Y': return 13; 00055 case 'S': return 14; 00056 case 'U': return 15; 00057 default: return -1; 00058 } 00059 } 00060 00061 //cp2 00062 static long little(char c) 00063 { 00064 switch (c) { 00065 case 'W': return 0; 00066 case 'C': return 1; 00067 case '6': return 2; 00068 case '3': return 3; 00069 case '4': return 4; 00070 case 'A': return 5; 00071 case 'X': return 6; 00072 case 'E': return 7; 00073 case 'L': return 8; 00074 case '2': return 9; 00075 case 'J': return 10; 00076 case '7': return 11; 00077 case 'R': return 12; 00078 case 'Z': return 13; 00079 case 'M': return 14; 00080 case '5': return 15; 00081 default: return -1; 00082 } 00083 } 00084 00085 //cp3 00086 static long satin(char c) 00087 { 00088 switch (c) { 00089 case '2': return 0; 00090 case 'K': return 1; 00091 case '9': return 2; 00092 case '5': return 3; 00093 case 'Z': return 4; 00094 case '3': return 5; 00095 case 'B': return 6; 00096 case 'N': return 7; 00097 case '4': return 8; 00098 case 'S': return 9; 00099 case 'T': return 10; 00100 case 'M': return 11; 00101 case '6': return 12; 00102 case '8': return 13; 00103 case 'C': return 14; 00104 case 'W': return 15; 00105 default: return -1; 00106 } 00107 } 00108 00109 //cp4 00110 static long cotton(char c) 00111 { 00112 switch (c) { 00113 case 'X': return 0; 00114 case '3': return 1; 00115 case 'F': return 2; 00116 case 'G': return 3; 00117 case 'A': return 4; 00118 case 'H': return 5; 00119 case 'R': return 6; 00120 case 'W': return 7; 00121 case '6': return 8; 00122 case '9': return 9; 00123 case '4': return 10; 00124 case '2': return 11; 00125 case 'M': return 12; 00126 case 'E': return 13; 00127 case '5': return 14; 00128 case '7': return 15; 00129 default: return -1; 00130 } 00131 } 00132 00133 //one of four(based on last) 00134 static long jiminy(long a, char b) 00135 { 00136 long t; 00137 00138 switch(a%4) { 00139 case 0: t = malibu(b); break; 00140 case 1: t = little(b); break; 00141 case 2: t = satin(b); break; 00142 case 3: t = cotton(b); break; 00143 default: return -1; 00144 } 00145 00146 if (t<0) return -1; 00147 00148 t -= a%16; 00149 if (t<0) t += 16; 00150 00151 return t; 00152 } 00153 00154 void creepy(char *a, unsigned char *b) //decode 00155 { 00156 long t0,t1,t2,t3; 00157 long v0,v1; 00158 00159 t0 = malibu(a[0]); //always starts with malibu 00160 t1 = jiminy(t0,a[1]); 00161 t2 = jiminy(t1,a[2]); 00162 t3 = jiminy(t2,a[3]); 00163 00164 //funky stuff 00165 v0 = jiminy(t0*t1+t1+t2,a[4]); 00166 v1 = jiminy(t1*t2+v0,a[5]); 00167 00168 b[0] = (unsigned char) ((v0<<4L)|v1); 00169 00170 v0 = jiminy(t0+t3,a[6]); 00171 v1 = jiminy(t1+t2+v0,a[7]); 00172 00173 b[1] = (unsigned char) ((v0<<4L)|v1); 00174 00175 v0 = jiminy(t2*t3+t1+t2,a[8]); 00176 v1 = jiminy(t1*t3+v0,a[9]); 00177 00178 b[2] = (unsigned char) ((v0<<4L)|v1); 00179 00180 v0 = jiminy(t2+t3,a[10]); 00181 v1 = jiminy(t0+t3+v0,a[11]); 00182 00183 b[3] = (unsigned char) ((v0<<4L)|v1); 00184 00185 v0 = jiminy(t1*t3+t1+t2,a[12]); 00186 v1 = jiminy(t0*t2+v0,a[13]); 00187 00188 b[4] = (unsigned char) ((v0<<4L)|v1); 00189 00190 v0 = jiminy(t1+t2,a[14]); 00191 v1 = jiminy(t1+t3+v0,a[15]); 00192 00193 b[5] = (unsigned char) ((v0<<4L)|v1); 00194 00195 } 00196
Copyright © 2008, Cycling '74