diff --git a/FluxEngine.cydsn/TopDesign/TopDesign.cysch b/FluxEngine.cydsn/TopDesign/TopDesign.cysch index dbff0d89..5a8947e6 100644 Binary files a/FluxEngine.cydsn/TopDesign/TopDesign.cysch and b/FluxEngine.cydsn/TopDesign/TopDesign.cysch differ diff --git a/FluxEngine.cydsn/UdbSampler/UdbSampler.cysym b/FluxEngine.cydsn/UdbSampler/UdbSampler.cysym index c523a8fa..c785dd34 100644 Binary files a/FluxEngine.cydsn/UdbSampler/UdbSampler.cysym and b/FluxEngine.cydsn/UdbSampler/UdbSampler.cysym differ diff --git a/FluxEngine.cydsn/UdbSampler/UdbSampler.cyudb b/FluxEngine.cydsn/UdbSampler/UdbSampler.cyudb index c70901f0..957272d1 100644 Binary files a/FluxEngine.cydsn/UdbSampler/UdbSampler.cyudb and b/FluxEngine.cydsn/UdbSampler/UdbSampler.cyudb differ diff --git a/lib/fluxmap.cc b/lib/fluxmap.cc index 542e0e4b..eaf549e2 100644 --- a/lib/fluxmap.cc +++ b/lib/fluxmap.cc @@ -9,9 +9,11 @@ uint32_t Fluxmap::getAndIncrement(size_t& index) const while (index < _bytes.size()) { uint8_t b = _bytes[index++]; - ticks += b; - if (!(b & 0x80)) + if (b < 0x80) + ticks += b; + if (b == 0x80) break; + /* everything above 0x80 is ignored for now */ } return ticks; @@ -30,7 +32,8 @@ Fluxmap& Fluxmap::appendBytes(const uint8_t* ptr, size_t len) while (len--) { uint8_t byte = *ptr++; - _ticks += byte; + if (byte < 0x80) + _ticks += byte; bw.write_8(byte); } @@ -40,12 +43,13 @@ Fluxmap& Fluxmap::appendBytes(const uint8_t* ptr, size_t len) Fluxmap& Fluxmap::appendInterval(uint32_t ticks) { - while (ticks >= 0x80) + while (ticks >= 0x7f) { - appendByte(0x80); - ticks -= 0x80; + appendByte(0x7f); + ticks -= 0x7f; } appendByte((uint8_t)ticks); + appendByte(0x80); return *this; } diff --git a/protocol.h b/protocol.h index 88882520..b5776510 100644 --- a/protocol.h +++ b/protocol.h @@ -3,7 +3,7 @@ enum { - FLUXENGINE_VERSION = 3, + FLUXENGINE_VERSION = 4, FLUXENGINE_VID = 0x1209, FLUXENGINE_PID = 0x6e00, diff --git a/tests/kryoflux.cc b/tests/kryoflux.cc index 3e85a346..b24b2781 100644 --- a/tests/kryoflux.cc +++ b/tests/kryoflux.cc @@ -72,43 +72,43 @@ static void test_stream_reader() /* Simple one-byte intervals */ test_convert( Bytes{ 0x20, 0x20, 0x20, 0x20 }, - Bytes{ 0x0f, 0x0f, 0x0f, 0x0f } + Bytes{ 0x0f, 0x80, 0x0f, 0x80, 0x0f, 0x80, 0x0f, 0x80 } ); /* One-and-a-half-byte intervals */ test_convert( Bytes{ 0x20, 0x00, 0x10, 0x20, 0x01, 0x10, 0x20 }, - Bytes{ 0x0f, 0x07, 0x0f, 0x80, 0x07, 0x0f } + Bytes{ 0x0f, 0x80, 0x07, 0x80, 0x0f, 0x80, 0x7f, 0x08, 0x80, 0x0f, 0x80 } ); /* Two-byte intervals */ test_convert( Bytes{ 0x20, 0x0c, 0x00, 0x10, 0x20, 0x0c, 0x01, 0x10, 0x20 }, - Bytes{ 0x0f, 0x07, 0x0f, 0x80, 0x07, 0x0f } + Bytes{ 0x0f, 0x80, 0x07, 0x80, 0x0f, 0x80, 0x7f, 0x08, 0x80, 0x0f, 0x80 } ); /* Overflow */ test_convert( Bytes{ 0x20, 0x0b, 0x10, 0x20 }, - Bytes{ 0x0f } + (Bytes{ 0x80 } * 0xff) + Bytes{ 0x62, 0x0f } + Bytes{ 0x0f, 0x80 } + (Bytes{ 0x7f } * 0x101) + Bytes{ 0x63, 0x80, 0x0f, 0x80 } ); /* Single-byte nop */ test_convert( Bytes{ 0x20, 0x08, 0x20 }, - Bytes{ 0x0f, 0x0f } + Bytes{ 0x0f, 0x80, 0x0f, 0x80 } ); /* Double-byte nop */ test_convert( Bytes{ 0x20, 0x09, 0xde, 0x20 }, - Bytes{ 0x0f, 0x0f } + Bytes{ 0x0f, 0x80, 0x0f, 0x80 } ); /* Triple-byte nop */ test_convert( Bytes{ 0x20, 0x0a, 0xde, 0xad, 0x20 }, - Bytes{ 0x0f, 0x0f } + Bytes{ 0x0f, 0x80, 0x0f, 0x80 } ); /* OOB block */ @@ -121,7 +121,7 @@ static void test_stream_reader() 0x55, /* payload */ 0x20 /* data continues */ }, - Bytes{ 0x0f, 0x0f } + Bytes{ 0x0f, 0x80, 0x0f, 0x80 } ); }