mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-24 11:11:02 -07:00
Rework the sampler state machine, with new, better, simpler bytecode at twice
the bandwidth; we now record the state of the index hole.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
enum
|
||||
{
|
||||
FLUXENGINE_VERSION = 3,
|
||||
FLUXENGINE_VERSION = 4,
|
||||
|
||||
FLUXENGINE_VID = 0x1209,
|
||||
FLUXENGINE_PID = 0x6e00,
|
||||
|
||||
@@ -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 }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user