#define ARRAYSIZE(a) ((sizeof((a)) / sizeof((a)[0])))
#define FILLZERO(obj) (memset(&(obj),0,sizeof((obj))))
+#define STRING(x) #x
+
#endif /*COMMON_H*/
# if it wrote a byte to fd 4, it can take another question
+set aadepth 3
+
+
#---------- library routines ----------
proc manyset {list args} {
# $database($context 0x<bits> 0x<bits>...) = $hex
-set database_magic/char {# ypp-sc-tools pctb font v2}
+set database_magic/char "# ypp-sc-tools pctb font v3 depth=$aadepth"
proc read_database_header/char {f} {
global rows
}
proc approve_decompose_data {specdata} {
- global data
+ global data aadepth
set data $specdata
- regsub-data {^ypp-sc-tools dictionary update v2\n} {}
+ regsub-data "^ypp-sc-tools dictionary update v3 depth=$aadepth\\n" {}
uplevel 1 chop_counted pirate
uplevel 1 chop_counted caller
uplevel 1 chop_counted dict
use IO::Pipe;
use IO::Handle;
+my $aadepth=3;
+
#---------- pixmaps ----------
sub parseentryin__pixmap ($) {
my $w= @d;
- my $pgm= "P2\n$h $w\n7\n";
+ my $maxval= (1<<$aadepth)-1;
+ die 'cannot do [^0...$maxval]!' if $maxval>9;
+
+ my $pgm= "P2\n$h $w\n$maxval\n";
map { # x, left to right
- m/[^0-7]/ and die "$_ ?";
+ m/[^0-$maxval]/ and die "$_ ?";
my $l= $_;
$l =~ s/./ $&/g;
$pgm .= "$l\n";
(stat F) or die $!;
my $fn_i= sprintf "_update.$$-%016x.rdy", (stat _)[1];
-print F "ypp-sc-tools dictionary update v2\n";
+print F "ypp-sc-tools dictionary update v3 depth=$aadepth\n";
foreach my $v ($pirate,$caller,$dict,$ctx,$def,$image,$key,$val) {
printf F "%d\n", length($v) or die $!;
o_flags |= ff_charset_havelocal;
FGETSLINE;
- dbassert(!strcmp(lbuf,"# ypp-sc-tools pctb font v2"));
+ dbassert(!strcmp(lbuf,"# ypp-sc-tools pctb font v3 depth=" STRING(AADEPTH)));
dbassert( dbfile_scanf("%d", &h) == 1);
dbassert(h==rd->h);
#define AADEPTH 3
#define AAMAXVAL ((1<<AADEPTH)-1)
+ /* Change this ? Also change in
+ * dictionary-manager set aadepth
+ * dictionary-update-receiver my $aadepth
+ */
typedef uint32_t Pixcolv;
#if AADEPTH==3
# define PRPIXCOL1 "%0*" PRIo32
+# define PIXCOL_P_PER_FMT 1
+#elif AADEPTH==2
+# define PRPIXCOL1 "%0*" PRIx32
+# define PIXCOL_P_PER_FMT 2
#else
# error need to implement PRPIXCOL1 for this AADEPTH
#endif
-#if PIXCOL_WORDS==3
+# define PIXCOL_FMT_PER_WORD (PIXCOL_P_PER_WORD / PIXCOL_P_PER_FMT)
+
+#if PIXCOL_WORDS==2
+# define PIXCOL_PRFMT \
+ PRPIXCOL1 "-" \
+ PRPIXCOL1
+# define PIXCOL_PRVAL(pixcol) \
+ PIXCOL_FMT_PER_WORD, (pixcol).w[1], \
+ PIXCOL_FMT_PER_WORD, (pixcol).w[0]
+#elif PIXCOL_WORDS==3
# define PIXCOL_PRFMT \
PRPIXCOL1 "-" \
PRPIXCOL1 "-" \
PRPIXCOL1
-# define PIXCOL_PRVAL(pixcol) \
- PIXCOL_P_PER_WORD, (pixcol).w[2], \
- PIXCOL_P_PER_WORD, (pixcol).w[1], \
- PIXCOL_P_PER_WORD, (pixcol).w[0]
+# define PIXCOL_PRVAL(pixcol) \
+ PIXCOL_FMT_PER_WORD, (pixcol).w[2], \
+ PIXCOL_FMT_PER_WORD, (pixcol).w[1], \
+ PIXCOL_FMT_PER_WORD, (pixcol).w[0]
#else
# error need to implement PIXCOL_PR{FMT,VAL} for this PIXCOL_WORDS
#endif