Allow gfx with less than 200px height.
Allow to set the color for unused cells.
git-svn-id: svn://localhost/thomson@41 85ae3b6b-dc8f-4344-a89d-598714f2e4e5
diff --git a/tools/gfx2mo5/libraw2mo5.c b/tools/gfx2mo5/libraw2mo5.c
index 1eb0d68..64bc24f 100644
--- a/tools/gfx2mo5/libraw2mo5.c
+++ b/tools/gfx2mo5/libraw2mo5.c
@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <string.h>
-unsigned char *raw2mo5(unsigned char *input, bool fixup)
+unsigned char *raw2mo5(unsigned char *input, int height, int fixup)
{
unsigned char *tmpBuffer;
int x,y;
@@ -25,7 +25,7 @@
#define width 320
bool lfo = false;
- for (y = 0; y < 200; y++)
+ for (y = 0; y < height; y++)
for (x = 0; x < 320; x+=8) {
int fore = 255;
int back = 255;
@@ -57,7 +57,7 @@
}
}
- if (fore == 255) fore = 7;
+ if (fore == 255) fore = fixup;
if (fore != 255) {
previous &= 0xF;
previous |= fore << 4;
@@ -70,7 +70,7 @@
// Make sure the last pixel of this GPL and the first of the next GPL
// are both FORME or both FOND, else we get an ugly glitch on the
// EFGJ033 Gate Array MO5!
- if(fixup && oldlfo == !(tmpBuffer[(y*320+x)/8] & 0x80))
+ if(fixup > 0 && oldlfo == !(tmpBuffer[(y*320+x)/8] & 0x80))
{
previous = (previous >> 4) | (previous << 4);
tmpBuffer[(y*320+x)/8] ^= 0xFF;
diff --git a/tools/gfx2mo5/libraw2mo5.h b/tools/gfx2mo5/libraw2mo5.h
index 7234028..e5ce4ad 100644
--- a/tools/gfx2mo5/libraw2mo5.h
+++ b/tools/gfx2mo5/libraw2mo5.h
@@ -9,6 +9,6 @@
#ifndef LIBRAW2mo5_H
#define LIBRAW2mo5_H 1
-unsigned char * raw2mo5(unsigned char *input, bool fixup);
+unsigned char * raw2mo5(unsigned char *input, int height, int fixup);
#endif
diff --git a/tools/gfx2mo5/png2mo5.c b/tools/gfx2mo5/png2mo5.c
index 9fd7a70..3732e14 100644
--- a/tools/gfx2mo5/png2mo5.c
+++ b/tools/gfx2mo5/png2mo5.c
@@ -126,7 +126,7 @@
png_read_image(png_ptr, ptrRow);
- outBuffer = raw2mo5(inBuffer, argc > 3);
+ outBuffer = raw2mo5(inBuffer, height, argc > 3 ? atoi(argv[3]):-1);
int pxsize = width * height / 8;
thomheader[7] = pxsize >> 8;