1.1 --- a/README.txt Thu May 18 01:58:26 2017 +0200
1.2 +++ b/README.txt Thu May 18 23:50:22 2017 +0200
1.3 @@ -1,3 +1,26 @@
1.4 +Introduction
1.5 +------------
1.6 +
1.7 +The VGAPIC32 project provides software and circuit information to generate an
1.8 +analogue VGA signal from a PIC32 microcontroller.
1.9 +
1.10 +Contact, Copyright and Licence Information
1.11 +------------------------------------------
1.12 +
1.13 +The author can be contacted at the following e-mail address:
1.14 +
1.15 +paul@boddie.org.uk
1.16 +
1.17 +Copyright and licence information can be found in the docs directory - see
1.18 +docs/COPYING.txt and docs/gpl-3.0.txt for more information.
1.19 +
1.20 +
1.21 +
1.22 +Hardware Details
1.23 +================
1.24 +
1.25 +The pin usage of this solution is documented below.
1.26 +
1.27 PIC32MX270F256B-50I/SP Pin Assignments
1.28 --------------------------------------
1.29
1.30 @@ -21,14 +44,23 @@
1.31 Data Signal Routing
1.32 -------------------
1.33
1.34 -D7 -> 220R -> R
1.35 +For one bit of intensity, two bits per colour channel:
1.36 +
1.37 +D7 -> 2200R -> I
1.38 +
1.39 +I -> diode -> R -> diode -> D7
1.40 +I -> diode -> G -> diode -> D7
1.41 +I -> diode -> B -> diode -> D7
1.42 +
1.43 D6 (not connected)
1.44 +
1.45 D5 -> 470R -> R
1.46 -D4 -> 470R -> G
1.47 -D3 -> 1000R -> G
1.48 -D2 -> 2200R -> G
1.49 -D1 -> 220R -> B
1.50 -D0 -> 470R -> B
1.51 +D4 -> 1000R -> R
1.52 +D3 -> 470R -> G
1.53 +D2 -> 1000R -> G
1.54 +D1 -> 470R -> B
1.55 +D0 -> 1000R -> B
1.56 +
1.57 HSYNC -> 3.3V:5V -> HS
1.58 VSYNC -> 3.3V:5V -> VS
1.59
1.60 @@ -58,3 +90,5 @@
1.61 http://papilio.cc/index.php?n=Papilio.VGAWing
1.62
1.63 http://lucidscience.com/pro-vga%20video%20generator-2.aspx
1.64 +
1.65 +https://sites.google.com/site/h2obsession/CBM/C128/rgbi-to-vga
2.1 --- a/tools/makeimage.py Thu May 18 01:58:26 2017 +0200
2.2 +++ b/tools/makeimage.py Thu May 18 23:50:22 2017 +0200
2.3 @@ -2,7 +2,7 @@
2.4
2.5 """
2.6 Convert images for display in an Acorn Electron MODE 2 variant with a pixel
2.7 -layout of R0RGGGBB, giving 128 colours instead of the usual 8 colours.
2.8 +layout of I0RRGGBB, giving 128 colours instead of the usual 8 colours.
2.9
2.10 Copyright (C) 2015, 2017 Paul Boddie <paul@boddie.org.uk>
2.11
2.12 @@ -17,12 +17,6 @@
2.13
2.14 You should have received a copy of the GNU General Public License along
2.15 with this program. If not, see <http://www.gnu.org/licenses/>.
2.16 -
2.17 -----
2.18 -
2.19 -ImageMagick can be used to dither images to a 232 palette before conversion:
2.20 -
2.21 -convert in.png -ordered-dither threshold,4,8,4 out.png
2.22 """
2.23
2.24 from os.path import split, splitext
2.25 @@ -76,15 +70,19 @@
2.26
2.27 else:
2.28 r, g, b = data.next()
2.29 + rm, gm, bm, i = get_values(r, g, b)
2.30 +
2.31 + # Encode the byte value: I0RRGGBB.
2.32 +
2.33 word.insert(0,
2.34 - # R<7> -> D<7>
2.35 - (r & 0x80) |
2.36 - # R<6> -> D<5>
2.37 - ((r & 0x40) >> 1) |
2.38 - # G<7:5> -> D<4:2>
2.39 - ((g >> 5) << 2) |
2.40 + # I -> D<7>
2.41 + (i << 7) |
2.42 + # R<7:6> -> D<5:4>
2.43 + (rm >> 2) |
2.44 + # G<7:6> -> D<3:2>
2.45 + (gm >> 4) |
2.46 # B<7:6> -> D<1:0>
2.47 - (b >> 6))
2.48 + (bm >> 6))
2.49
2.50 flush_word(f, word)
2.51 x += 1
2.52 @@ -96,11 +94,28 @@
2.53 finally:
2.54 f.close()
2.55
2.56 +def get_values(r, g, b):
2.57 +
2.58 + "Return modified values for 'r', 'g' and 'b', plus an intensity bit."
2.59 +
2.60 + rm = r & 0xc0
2.61 + gm = g & 0xc0
2.62 + bm = b & 0xc0
2.63 + rd = r - rm
2.64 + gd = g - gm
2.65 + bd = b - bm
2.66 + i = ((rd ** 2 + gd ** 2 + bd ** 2) ** 0.5) >= 32 and 1 or 0
2.67 + return rm, gm, bm, i
2.68 +
2.69 def make_preview(im):
2.70 imp = PIL.Image.new("RGB", im.size)
2.71 data = []
2.72 for r, g, b in im.getdata():
2.73 - data.append((((r >> 6) << 6), ((g >> 5) << 5), (b >> 6) << 6))
2.74 + rm, gm, bm, i = get_values(r, g, b)
2.75 + r = rm + (i * 32)
2.76 + g = gm + (i * 32)
2.77 + b = bm + (i * 32)
2.78 + data.append((r, g, b))
2.79 imp.putdata(data)
2.80 return imp
2.81