Rework the bytecode format to use a much simplified setup: a six-bit timer with

the top two bits reserved for pulse and index state. This is actually smaller,
bandwidth-wise, than the old version, and may be smaller than the crunched
version.
This commit is contained in:
David Given
2020-03-14 18:58:43 +00:00
parent a401173f6d
commit fc2655ecd6
13 changed files with 139 additions and 90 deletions

View File

@@ -49,43 +49,43 @@ static void test_stream_reader()
/* Simple one-byte intervals */
test_convert(
Bytes{ 0x20, 0x20, 0x20, 0x20 },
Bytes{ 0x0f, 0x80, 0x0f, 0x80, 0x0f, 0x80, 0x0f, 0x80 }
Bytes{ 0x8f, 0x8f, 0x8f, 0x8f }
);
/* One-and-a-half-byte intervals */
test_convert(
Bytes{ 0x20, 0x00, 0x10, 0x20, 0x01, 0x10, 0x20 },
Bytes{ 0x0f, 0x80, 0x07, 0x80, 0x0f, 0x80, 0x7f, 0x08, 0x80, 0x0f, 0x80 }
Bytes{ 0x8f, 0x87, 0x8f, 0x3f, 0x3f, 0x89, 0x8f }
);
/* Two-byte intervals */
test_convert(
Bytes{ 0x20, 0x0c, 0x00, 0x10, 0x20, 0x0c, 0x01, 0x10, 0x20 },
Bytes{ 0x0f, 0x80, 0x07, 0x80, 0x0f, 0x80, 0x7f, 0x08, 0x80, 0x0f, 0x80 }
Bytes{ 0x8f, 0x87, 0x8f, 0x3f, 0x3f, 0x89, 0x8f }
);
/* Overflow */
test_convert(
Bytes{ 0x20, 0x0b, 0x10, 0x20 },
Bytes{ 0x0f, 0x80 } + (Bytes{ 0x7f } * 0x101) + Bytes{ 0x63, 0x80, 0x0f, 0x80 }
Bytes{ 0x8f } + (Bytes{ 0x3f } * 0x207) + Bytes{ 0xa9, 0x8f }
);
/* Single-byte nop */
test_convert(
Bytes{ 0x20, 0x08, 0x20 },
Bytes{ 0x0f, 0x80, 0x0f, 0x80 }
Bytes{ 0x8f, 0x8f }
);
/* Double-byte nop */
test_convert(
Bytes{ 0x20, 0x09, 0xde, 0x20 },
Bytes{ 0x0f, 0x80, 0x0f, 0x80 }
Bytes{ 0x8f, 0x8f }
);
/* Triple-byte nop */
test_convert(
Bytes{ 0x20, 0x0a, 0xde, 0xad, 0x20 },
Bytes{ 0x0f, 0x80, 0x0f, 0x80 }
Bytes{ 0x8f, 0x8f }
);
/* OOB block */
@@ -98,7 +98,7 @@ static void test_stream_reader()
0x55, /* payload */
0x20 /* data continues */
},
Bytes{ 0x0f, 0x80, 0x0f, 0x80 }
Bytes{ 0x8f, 0x8f }
);
}