diff --git a/tools/fdec.c b/tools/fdec.c index b092ece..bc3d8a2 100644 --- a/tools/fdec.c +++ b/tools/fdec.c @@ -10,17 +10,18 @@ #define uint8_t unsigned char #define uint16_t unsigned short -#include "ubuntu17.c" +#include "fixed6x9.c" -const struct FONT_DEF * font = &Font_Ubuntu17pt; +const struct FONT_DEF * font = &Font_Fixed6x9; -#define MAXCHR (24*3) +#define MAXCHR (30*6) static uint8_t buf[MAXCHR]; +int height; // Height of character in bytes + int decode(char c){ int off=0; // Offset into au8FontTable for bytestream int length; // Length of character bytestream - int height; // Height of character in bytes int hoff; uint8_t * bufptr=buf; // Output buffer for decoded character @@ -39,14 +40,16 @@ int decode(char c){ // Local function: Get next nibble. int ctr=0; // offset for next nibble + int hilo=0; // 0= high nibble next, 1=low nibble next char gnn(){ // Get next nibble static int byte; - static int hilo=0; // 0= high nibble next, 1=low nibble next int val; + if(hilo==1){ + ctr++; + }; hilo=1-hilo; if(hilo==1){ byte=font->au8FontTable[off+ctr]; - ctr++; val=byte>>4; }else{ val=byte&0x0f; @@ -98,9 +101,10 @@ int decode(char c){ while(ctr ",ctr,hilo,font->au8FontTable[off+ctr]); /* Get next encoded nibble and decode */ nyb=gnn(); - printf("\nCtr: %d, byte: %x, Process: %d\n",ctr, font->au8FontTable[off+ctr], nyb); + printf("Process: %d\n", nyb); if(nyb==15){ repeat++; @@ -122,7 +126,7 @@ int decode(char c){ /* Generate & output bits */ - printf("have %d bits. Got %d (%d)-bits...(r=%d)",pos, nyb, curbit,repeat); + printf("have %d bits. Got %d (%d)-bits...(r=%d)\n",pos, nyb, curbit,repeat); while(nyb-->0){ if(pos==0){ *bufptr=0; @@ -133,7 +137,7 @@ int decode(char c){ pos++; if( hoff>0 && ((bufptr-buf)%height)==(height-1) && (pos==hoff)){ // Incomplete last line. - printf("Incomplete last byte output: %d:",(bufptr-buf)%height); + printf("Incomplete byte (%d bits):",(bufptr-buf)%height); pos=8; }; if(pos==8 ){ @@ -142,7 +146,7 @@ int decode(char c){ if((bufptr-buf)%height==0){ // End of column? while(repeat>0){ for(int y=0;y $b } @charlist; -#init_ttf(); -init_bdf(); + +$::{"init_$type"}(); die "No font name?" if !defined $title; @@ -110,8 +119,7 @@ for (0..$#charlist){ my $char=chr $charlist[$_]; print "### Start $char\n" if($verbose); -# my @char=render_ttf($_); - my @char=render_bdf($_); + my @char=$::{"render_$type"}($_); print C " /* Char ",ord $char," is ",scalar@char,"px wide \@ $offset */\n"; @@ -387,7 +395,7 @@ sub make_bytes{ my @out; while(@enc){ - push @enc,0 if($#enc==2); + push @enc,1 if($#enc==2); push @out,16*(shift@enc)+(shift@enc); }; return @out; @@ -570,7 +578,7 @@ sub init_bdf{ sub render_bdf{ my $ccode=$charlist[shift]; my $tchar=$chars{$ccode}; - print "Char: $ccode:\n",join("\n",@{$tchar}),"\nEND\n"; +# print "Char: $ccode:\n",join("\n",@{$tchar}),"\nEND\n"; return @{$tchar}; };