+//PrintToScrollback("cool %d %d %d %d", low, high, lastval, GraphBuffer[i]);\r
+\r
+ /* If we're not working with 1/0s, demod based off clock */\r
+ if (high != 1)\r
+ {\r
+ bit = 0;\r
+ for (i = 0; i < (GraphTraceLen / clock); i++)\r
+ {\r
+ hithigh = 0;\r
+ hitlow = 0;\r
+ first = 1;\r
+\r
+ /* Find out if we hit both high and low peaks */\r
+ for (j = 0; j < clock; j++)\r
+ {\r
+ if (GraphBuffer[(i * clock) + j] == high)\r
+ hithigh = 1;\r
+ else if (GraphBuffer[(i * clock) + j] == low)\r
+ hitlow = 1;\r
+\r
+ /* it doesn't count if it's the first part of our read\r
+ because it's really just trailing from the last sequence */\r
+ if (first && (hithigh || hitlow))\r
+ hithigh = hitlow = 0;\r
+ else\r
+ first = 0;\r
+\r
+ if (hithigh && hitlow)\r
+ break;\r
+ }\r
+\r
+ /* If we didn't hit both high and low peaks, we had a bit transition */\r
+ if (!hithigh || !hitlow)\r
+ bit ^= 1;\r
+\r
+ BitStream[bit2idx++] = bit;\r
+ }\r
+ }\r
+\r
+ /* standard 1/0 bitstream */\r
+ else\r
+ {\r