On 06/01/2015 21:22, Kevin O'Connor wrote:
On Tue, Jan 06, 2015 at 08:59:09PM +0100, Paolo Bonzini wrote:
On 06/01/2015 16:49, Kevin O'Connor wrote:
- if (vga_emulate_text()) {
// Read bottom right pixel of the cell to guess bg color
op.y += cheight-1;
handle_gfx_op(&op);
op.y -= cheight-1;
bgattr = op.pixels[7];
fgattr = bgattr ^ 0x7;
car = 1;
- }
It's better to use the top right pixel. The bottom right has a false positive for characters 23 and 95.
Hrmm. How did you test? The script I wrote shows the bottom right as the least number of false positives. With the 8x16 font, there are six false positives, but all six are mirror images of other characters so there is no way to avoid them.
I used the 8x8 font. I suspect that my new favorite testcase (gwbasic, what else) will mess up PRINT "_" if you use the bottom right.
Paolo
-Kevin
$ python ./scripts/countbits.py < vgasrc/vgafonts.c 256 49 83 107 129 113 82 51 16 58 101 110 98 100 103 61 19 78 146 139 132 146 132 72 29 92 136 122 140 154 122 63 17 108 159 142 139 154 147 88 44 81 135 124 116 134 132 59 14 66 123 132 152 134 101 66 13 22 31 42 57 44 30 28 11
256 6 8 21 41 23 21 19 8 14 24 40 57 41 32 26 7 44 78 102 125 110 102 65 13 48 93 92 92 93 110 76 12 51 90 92 99 95 99 81 15 80 146 129 132 138 141 89 26 85 133 109 134 133 140 95 18 99 151 121 134 138 149 114 39 86 129 88 111 120 130 92 13 80 116 84 105 113 134 90 10 47 109 126 148 122 136 83 10 12 16 25 39 30 31 26 6 9 16 28 47 30 27 22 9 6 7 20 33 20 20 20 6
256 6 8 21 41 23 21 19 8 15 24 40 57 41 33 27 7 41 72 95 118 100 89 59 20 43 88 90 85 82 93 75 20 51 83 79 92 81 91 81 21 81 140 126 134 138 134 94 31 79 130 98 122 131 131 89 25 110 153 119 140 146 142 120 52 82 130 91 107 111 120 92 24 85 127 87 103 112 125 95 17 87 117 71 100 105 130 96 18 49 115 134 154 122 136 90 15 9 13 23 40 28 31 23 8 8 13 25 38 29 30 25 8 8 11 23 41 25 22 19 8 6 7 20 33 20 20 20 6
==================================== countbits.py script
import sys
count = 0 counts = [] for line in sys.stdin: if 'vgafont' in line: if counts: print count for i in range(len(counts)): print "%3d" % counts[i], if i % 8 == 7: print print count = 0 counts = [] try: parts = [int(p.strip(), 0) for p in line.split(',') if p.strip()] except ValueError: continue if not parts: continue count += 1 out = [0] * (len(parts) * 8) for i in range(len(parts)): p = parts[i] for j in range(8): if (1<<(7-j)) & p: out[i*8 + j] += 1 if not counts: counts = out else: for i in range(len(out)): counts[i] += out[i]