Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@AliceLR
Last active January 9, 2022 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AliceLR/f74052999dde1db3a7dcda86c324b138 to your computer and use it in GitHub Desktop.
Save AliceLR/f74052999dde1db3a7dcda86c324b138 to your computer and use it in GitHub Desktop.
Digital Symphony module generator :)
#if 0
g++ -O3 -Wall -Wextra dsymgen.cpp -odsymgen
exit
#endif
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <vector>
#define ERROR(...) do{ fprintf(stderr, __VA_ARGS__); fflush(stderr); exit(-1); }while(0)
#if 1
#define DEBUG(...) do{ fprintf(stderr, __VA_ARGS__); fflush(stderr); }while(0)
#else
#define DEBUG(...)
#endif
static constexpr int NUM_SAMPLES = 63;
static constexpr int MAX_ORDERS = 4096;
static constexpr int MAX_PATTERNS = 4096;
struct sample
{
bool present;
uint8_t type;
unsigned length;
unsigned loop_start;
unsigned loop_length;
unsigned volume;
int finetune;
char name[32];
char filename[256];
bool input_is_16bit;
};
struct pattern
{
uint32_t events[64];
static uint32_t pack(unsigned note, unsigned sample, unsigned effect, unsigned param)
{
if(note >= 37)
ERROR("invalid note %u\n", note);
if(sample >= 64)
ERROR("invalid sample %u\n", sample);
if(effect >= 64)
ERROR("invalid effect %u\n", effect);
if(param >= 4096)
ERROR("invalid param %u\n", param);
return note | (sample << 6) | (effect << 14) | (param << 20);
}
};
struct dsym
{
char name[256];
unsigned version;
unsigned num_channels;
unsigned num_orders;
unsigned num_patterns;
unsigned orders[4096][8];
pattern patterns[MAX_PATTERNS];
sample samples[NUM_SAMPLES];
// Loader state.
int current_pattern;
int pos_in_pattern;
};
static void fput16(int value, FILE *fp)
{
fputc(value & 0xff, fp);
fputc(value >> 8, fp);
}
static void fput24(int value, FILE *fp)
{
fputc(value & 0xff, fp);
fputc((value & 0x00ff00) >> 8, fp);
fputc((value & 0xff0000) >> 16, fp);
}
static void fput32(uint32_t value, FILE *fp)
{
fputc(value & 0xff, fp);
fputc((value & 0x0000ff00UL) >> 8, fp);
fputc((value & 0x00ff0000UL) >> 16, fp);
fputc((value & 0xff000000UL) >> 24, fp);
}
/* Sigma-delta 8-bit sample compression. */
struct bitstream
{
std::vector<uint8_t> &out;
uint64_t buf = 0;
unsigned pos = 0;
bitstream(std::vector<uint8_t> &o): out(o) {}
void flush()
{
out.push_back((buf & 0x000000ffUL) >> 0);
out.push_back((buf & 0x0000ff00UL) >> 8);
out.push_back((buf & 0x00ff0000UL) >> 16);
out.push_back((buf & 0xff000000UL) >> 24);
buf >>= 32;
pos -= 32;
}
void write(uint64_t value, unsigned width)
{
buf |= value << pos;
pos += width;
if(pos >= 32)
flush();
}
};
static void sigma_delta_compress(std::vector<uint8_t> &out,
const std::vector<uint8_t> &in)
{
if(in.size() < 1)
return;
bitstream stream(out);
unsigned width = 8;
int8_t delta_min = -127;
int8_t delta_max = 127;
unsigned runlength = 0;
uint8_t prev = in[0];
/* TODO: lower values seem to be better sometimes but not by much. */
static constexpr unsigned max_runlength = 8;
out.push_back(max_runlength);
stream.write(in[0], 8);
for(size_t i = 1; i < in.size(); i++)
{
int8_t delta = static_cast<int8_t>(in[i] - prev);
prev = in[i];
if(delta == -128)
{
/* Pretend this edge case didn't happen... */
prev++;
delta = -127;
}
while(delta < delta_min || delta > delta_max)
{
/* Expand width. */
assert(width < 8);
stream.write(0, width);
width++;
delta_max = (1 << (width - 1)) - 1;
delta_min = -delta_max;
runlength = 0;
//DEBUG("%u: expand width to %d\n", i, width);
}
/* Output delta. */
uint8_t code;
if(delta <= 0)
{
code = 0x01 | (static_cast<uint8_t>(-delta) << 1);
stream.write(code, width);
}
else
{
code = static_cast<uint8_t>(delta) << 1;
stream.write(code, width);
}
//DEBUG("%u: write %02x\n", i, code);
/* Reset the run length for large values. */
if(code >> (width - 1))
{
runlength = 0;
continue;
}
/* Otherwise, increment the run length. */
if(++runlength >= max_runlength)
{
runlength = 0;
/* Shrink width. */
if(width > 1)
{
width--;
delta_max = (1 << (width - 1)) - 1;
delta_min = -delta_max;
//DEBUG("%u: shrink width to %d\n", i, width);
}
}
}
/* Output any remaining bytes + padding. */
stream.flush();
}
/* Template parsing. */
static void read_events(dsym &m, pattern &p, const char *pos)
{
size_t i;
for(i = m.pos_in_pattern; i < 64; i++)
{
unsigned note = 0;
unsigned sample = 0;
unsigned effect = 0;
unsigned param = 0;
if(sscanf(pos, " %i %i %i %i |", &note, &sample, &effect, &param) > 0)
p.events[i] = pattern::pack(note, sample, effect, param);
pos = strchr(pos, '|');
if(!pos)
{
i++;
break;
}
pos++;
}
m.pos_in_pattern = i;
}
static bool read_line(dsym &m, FILE *in)
{
char linebuf[2048];
char str[256];
char *pos;
unsigned num;
if(!fgets(linebuf, sizeof(linebuf), in))
return false;
if(linebuf[0] == '#')
return true;
size_t len = strlen(linebuf);
while(len && (linebuf[len - 1] == '\n' || linebuf[len - 1] == '\r'))
linebuf[--len] = '\0';
if(sscanf(linebuf, "%255s %i :: ", str, &num) == 2 && strcmp(str, "::"))
{
m.current_pattern = -1;
pos = strstr(linebuf, "::");
if(!pos)
ERROR("error parsing line\n");
pos += 2;
if(!strcasecmp(str, "ORDER"))
{
if(num >= MAX_ORDERS)
ERROR("invalid order %u\n", num);
if(m.num_channels == 0)
ERROR("ORDER must follow VOICES\n");
if(m.num_orders < num + 1)
m.num_orders = num + 1;
unsigned order = num;
int num_read = sscanf(pos, " %i %i %i %i %i %i %i %i",
m.orders[order], m.orders[order] + 1, m.orders[order] + 2, m.orders[order] + 3,
m.orders[order] + 4, m.orders[order] + 5, m.orders[order] + 6, m.orders[order] + 7);
if(num_read < 0 || (unsigned)num_read < m.num_channels)
ERROR("error reading order %u: %d\n", order, num_read);
for(size_t i = 0; i < m.num_channels; i++)
{
if(m.orders[order][i] > MAX_PATTERNS) // Allow =MAX_PATTERNS for blank.
ERROR("voice %zu in order %u is invalid pattern %u\n", i + 1, order, num);
}
}
else
if(!strcasecmp(str, "PATTERN"))
{
if(num >= MAX_PATTERNS)
ERROR("invalid pattern %d\n", num);
if(m.num_patterns < num + 1)
m.num_patterns = num + 1;
m.current_pattern = num;
m.pos_in_pattern = 0;
pattern &p = m.patterns[num];
read_events(m, p, pos);
}
else
if(!strcasecmp(str, "SAMPLE") || !strcasecmp(str, "SAMP16") ||
!strcasecmp(str, "SIGMA8") || !strcasecmp(str, "SIGM16"))
{
if(num < 1 || num > 63)
ERROR("invalid sample %d\n", num);
sample &s = m.samples[num - 1];
s.type = 2;
if(!strcasecmp(str, "SAMP16")) s.type = 3, s.input_is_16bit = true;
if(!strcasecmp(str, "SIGMA8")) s.type = 4;
if(!strcasecmp(str, "SIGM16")) s.type = 4, s.input_is_16bit = true;
s.present = true;
if(sscanf(pos, " %i %i %i %i %d %255s %31s",
&s.length, &s.loop_start, &s.loop_length, &s.volume, &s.finetune, s.filename, s.name) < 6)
ERROR("error reading sample %u\n", num);
if(s.volume > 64)
ERROR("invalid volume for sample %u: %u\n", num, s.volume);
if(s.finetune < -8 || s.finetune > 7)
ERROR("invalid finetune for sample %u: %d\n", num, s.finetune);
/*
if(strlen(s.name) > 63)
ERROR("name for sample %u exceeds 63 bytes\n", num);
*/
}
else
ERROR("unknown field '%s'\n", str);
}
else
if(sscanf(linebuf, "%255s :: ", str) == 1 && strcmp(str, "::"))
{
m.current_pattern = -1;
pos = strstr(linebuf, "::");
if(!pos)
ERROR("error parsing line\n");
pos += 2;
if(!strcasecmp(str, "NAME"))
{
if(sscanf(pos, " %255[^\n]s", m.name) < 1)
ERROR("error reading module name\n");
}
else
if(!strcasecmp(str, "VOICES"))
{
if(sscanf(pos, " %d", &num) < 1)
ERROR("malformed VOICES line\n");
if(num < 1 || num > 8)
ERROR("invalid VOICES %d\n", num);
if(m.num_channels != 0)
ERROR("duplicate VOICES\n");
m.num_channels = num;
}
}
else
if(m.current_pattern >= 0 && sscanf(linebuf, " %255s ", str) == 1 && !strcmp(str, "::"))
{
// Continue previous pattern.
pos = strstr(linebuf, "::");
if(!pos)
ERROR("error parsing line\n");
pos += 2;
pattern &p = m.patterns[m.current_pattern];
read_events(m, p, pos);
}
return true;
}
int main()
{
static dsym m{};
unsigned i;
#ifdef _WIN32
_setmode(_fileno(stdout), _O_BINARY);
#endif
/* Header */
if(fscanf(stdin, "BASSTRAK v%u\n", &m.version) < 1)
ERROR("not a Digital Symphony template.\n");
if(m.version > 1)
ERROR("invalid Digital Symphony version (valid values are 0 and 1)\n");
while(read_line(m, stdin));
fclose(stdin);
/* Write */
fputs("\x02\x01\x13\x13\x14\x12\x01\x0b", stdout);
fputc(m.version, stdout);
fputc(m.num_channels, stdout);
fput16(m.num_orders, stdout);
fput16(m.num_patterns, stdout);
fput24(0, stdout); /* Information text length. */
for(i = 0; i < NUM_SAMPLES; i++)
{
sample &s = m.samples[i];
int flags = s.present ? 0 : 0x80;
int len = strlen(s.name);
fputc(flags | len, stdout);
if(s.present)
fput24(s.length >> 1, stdout);
}
fputc(strlen(m.name), stdout);
fputs(m.name, stdout);
fputs("\xff\xff\xff\xff\xff\xff\xff\xff", stdout); /* Effects allowed table. */
if(m.num_orders > 0)
{
fputc(0, stdout); // Packing method.
for(i = 0; i < m.num_orders; i++)
for(size_t j = 0; j < m.num_channels; j++)
fput16(m.orders[i][j], stdout);
}
if(m.num_patterns > 0)
{
for(i = 0; i < m.num_patterns;)
{
fputc(0, stdout); // Packing method.
for(size_t j = 0; i < m.num_patterns && j < 2000; i++, j++)
{
pattern &p = m.patterns[i];
for(size_t r = 0; r < 64; r++)
fput32(p.events[r], stdout);
}
}
}
for(i = 0; i < NUM_SAMPLES; i++)
{
sample &s = m.samples[i];
fputs(s.name, stdout);
if(!s.present)
continue;
fput24(s.loop_start >> 1, stdout);
fput24(s.loop_length >> 1, stdout);
fputc(s.volume, stdout);
fputc((signed char)s.finetune, stdout);
if(!s.length)
continue;
fputc(s.type, stdout); // Sample packing type.
size_t buf_size = s.length;
if(s.input_is_16bit)
buf_size *= 2;
std::vector<uint8_t> buf(buf_size);
FILE *fp = fopen(s.filename, "rb");
if(fp)
{
fread(buf.data(), buf_size, 1, fp);
fclose(fp);
}
else
ERROR("failed to open sample file '%s'\n", s.filename);
switch(s.type)
{
case 0: // signed uncompressed 8-bit log
case 2: // signed uncompressed 8-bit
case 3: // signed uncompressed 16-bit
fwrite(buf.data(), buf_size, 1, stdout);
break;
case 4: // unsigned sigma-delta 8-bit
case 5: // unsigned sigma-delta 8-bit log
{
if(s.input_is_16bit)
{
for(size_t j = 0; j < s.length; j++)
buf[j] = buf[j * 2 + 1];
buf.resize(s.length);
}
/* Convert signed to unsigned. */
for(size_t j = 0; j < s.length; j++)
buf[j] += 128;
std::vector<uint8_t> compressed;
compressed.reserve(s.length);
sigma_delta_compress(compressed, buf);
fwrite(compressed.data(), compressed.size(), 1, stdout);
break;
}
case 1: // signed LZW 8-bit
default:
ERROR("unsupported sample type %u!", s.type);
}
}
return 0;
}
BASSTRAK v1
NAME :: Plastic Meme
VOICES :: 4
SIGM16 1 :: 86896 65536 12800 40 0 piano_musescore.sam piano_musescore.sam
#SAMP16 1 :: 86896 65536 12800 40 0 piano_musescore.sam piano_musescore.sam
# 80424 1400
ORDER 0 :: 0 1 2 3
PATTERN 0 :: 0 0 0x30 0x5 | | | | 22 1 0x9 0x201 | | |
:: 18 1 0x9 0x201 | | | | 15 1 0x9 0x201 | | |
:: 22 1 0x9 0x201
:: | | | | 20 1 0x9 0x201 | | |
:: 17 1 0x9 0x201 | | | | 13 1 0x9 0x201 | | |
:: 20 1 0x9 0x201
:: | | | | 19 1 0x9 0x201 | 0 0 0x32 0
PATTERN 1 :: 0 0 0xf 0x4 | 0 0 0x30 0x4 | | 18 1 0x9 0x201 | 0 0 0xa 0x01 | 0 0 0xa 0x01 | 0 0 0xa 0x01 | 0 0 0xa 1
:: 0 0 0x32 0 | | | | | | | |
:: 0 0 0xf 0x6 | 0 0 0xf 0x2 | 0 0 0xf 0x4 | 17 1 0x9 0x201 | 0 0 0xa 1 | 0 0 0xa 1 | 0 0 0xa 1 | 0 0 0xa 1
:: 0 0 0x32 0 | | | | | | | |
:: | | | 15 1 0x9 0x201 | 0 0 0x32 0
PATTERN 2 :: 0 0 0x2f 0x398 | 0 0 0x30 0x4 | 15 1 0x9 0x201 | 0 0 0xa 0x01 | 0 0 0xa 0x01 | 0 0 0xa 0x01 | 0 0 0xa 0x01 |
:: | | | | 0 0 0x32 0 | | | |
:: | | 13 1 0x9 0x201 | 0 0 0xa 1 | 0 0 0xa 1 | 0 0 0xa 1 | 0 0 0xa 1 |
:: | | | | 0 0 0x32 0
PATTERN 3 :: 0 0 0x30 0x3 | 11 1 0x9 0x201 | | | | | |
:: | | | | | | | |
:: | 10 1 0x9 0x201 | | | | | |
:: | | | | | | | |
:: | | 10 1 0x9 0x201 | 0 0 0x32 0 | | | |
:: | | | | 0 0 0x2f 0xA0
BASSTRAK v1
NAME :: test.module
VOICES :: 4
ORDER 0 :: 0x0000 0x0001 0x0002 0x1000
PATTERN 0 :: 18 1 || 18 1 0x1c 3 | 18 1 0x1c 3 | 18 1 | 0 0 0x1c 3 | 15 1 | 0 0 0x1c 3 | 15 1 | 0 0 0x1c 3 | 15 1 | 0 0 0x1c 3 | 17 1 |||||||| 0 0 0x1c 0
PATTERN 1 :: 8 2 || | | | 0 0 0x1c 3 | 6 2 | 0 0 0x1c 3 | 6 2 | 0 0 0x1c 3 | 6 2 | 0 0 0x1c 3 | 8 2 |||||||| 0 0 0x1c 0
PATTERN 2 :: 6 3 || | | | 0 0 0x1c 3 | 8 3 | 0 0 0x1c 3 | 8 3 | 0 0 0x1c 3 | 8 3 | 0 0 0x1c 3 | 1 3 |||||||| 0 0 0x1c 0
SAMPLE 1 :: 16 0 16 64 0 saw.sam saw.sam
SAMP16 2 :: 16 0 16 64 0 log16.sam log16.sam
SAMPLE 3 :: 32 0 32 32 0 sq.sam sq.sam
BASSTRAK v1
NAME :: symphony.effects
VOICES :: 4
SAMPLE 1 :: 16 0 16 64 0 saw.sam saw.sam
SAMP16 2 :: 16 0 16 64 0 log16.sam log16.sam
SAMPLE 3 :: 32 0 32 64 0 sawsq.sam sawsq.sam
SAMPLE 4 :: 768 0 1 64 0 snare.sam snare.sam
ORDER 0 :: 0 1 2 3
ORDER 1 :: 4 5 6 7
ORDER 2 :: 8 9 10 7
ORDER 3 :: 4 5 6 7
ORDER 4 :: 11 12 10 7
ORDER 5 :: 13 14 15 16
# TESTING:
# TODO: 07 tremolo
# TODO: 19 retrigger
# TODO: 2b line jump
# TODO: 09 set sample offset
# TODO: 0B Position Jump
# TODO: 11 12 1A 1B fine slide + fine vslide
# TODO: 15 finetune
# TODO: 16 loop
# TODO: 1d note delay
# TODO: 1e pattern delay
# TODO: 1f invert loop??
# TODO: 30 stereo
# TODO: 32 unset sample repeat
# TODO: speed over 32.
# TODO: tempo under S3M 32 (above S3M 20, the minimum XMP allows).
#
# Order 0 : 00, 01, 0C, 0D, 0F, 13, 14, 17, 20, 2f
#
PATTERN 0 :: 0 0 0x14 1 | 0 0 0x17 2 | 0 0 0x13 1
:: 13 01 0xc 16 | 0 0 0x20 0x17e | 0 0 0x20 0x17e | 0 0 0x20 0x17e
:: 0 0 0x0 0x17e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e
:: 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e
PATTERN 1 :: 0 0 0x14 2 | 0 0 0x17 2
PATTERN 2 :: 0 0 0x2f 0x3c0 | 0 0 0x2f 0 ||||||
:: 12 03 0xc 0 | 0 0 0x1 0x403 | 0 0 0x1 0x401 | 0 0 0x1 0x401
:: 0 0 0x1 0x401 | 0 0 0x1 0x401 | 0 0 0x1 0x401 | 0 0 0x1 0x401
PATTERN 3 :: 0 0 0xf 3 | 0 0 0xf 0 |||||||||||||| 0 0 0xd 0
#
# Order 1: 02, 03, 04, 05, 06, 0A, 1C, 21, 22, 2A
#
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xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff
:: 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff
:: 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff
:: 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff
:: 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff | 0 0 0x7 0xff
PATTERN 14 :: 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02
:: 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02
:: 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02
:: 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02
:: 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02
:: 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02 | 0 0 0xa 0x02
:: 1 2 0xc 0 | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e
:: 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e | 0 0 0x0 0x27e
PATTERN 15 :: 2 3 | | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301
:: 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301
:: 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301
:: 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301
:: 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301
:: 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301
:: 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301
:: 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301 | 0 0 0x1b 0x301
PATTERN 16 :: 2 3 0x1c 1 |||||||
:: ||||||| 19 4 0x2b 0x30
:: |||||||
:: |||||||
:: |||||||
:: |||||||
:: 19 4 |||||||
:: 2 3 0x1c 1 |||| 19 4 0x19 2 | 0 0 0x19 1 | 19 4 0x19 2 | 0 0 0x19 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment