From b925142da142ad3b2600f0fc2636ca4842972c89 Mon Sep 17 00:00:00 2001 From: Brad Grantham Date: Wed, 6 Jun 2018 12:15:58 -0700 Subject: [PATCH] add utilities to turn bitmap to code --- bitmap_to_basic.py | 12 ++++++++++++ bitmap_to_c.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 bitmap_to_basic.py create mode 100644 bitmap_to_c.py diff --git a/bitmap_to_basic.py b/bitmap_to_basic.py new file mode 100644 index 0000000..b24d4ce --- /dev/null +++ b/bitmap_to_basic.py @@ -0,0 +1,12 @@ +import sys + +print "5 HGR : HCOLOR=3" +num = 10 +row = 0 +for line in sys.stdin: + for b in xrange(0, 40): + if line[b * 2] == '*': + print "%d HPLOT %d, %d" % (num, b, row) + num += 10 + row += 1 + diff --git a/bitmap_to_c.py b/bitmap_to_c.py new file mode 100644 index 0000000..2857143 --- /dev/null +++ b/bitmap_to_c.py @@ -0,0 +1,29 @@ +import sys + +maxwidth = 0 + +print "unsigned char bitmap[] = {" + +for line in sys.stdin: + bit = 0 + width = 0 + + for b in xrange(0, 40): + if line[b * 2] == '*': + print "255,", + else: + print "0,", + + width += 1 + bit += 1 + + if False and bit == 7: + print "255,", + width += 1 + bit = 0 + + maxwidth = max(width, maxwidth) + print "// %d, %d" % ( width, bit) + +print "};" +print "// width = %d" % maxwidth