typedef struct {
byte bitfield[9];
//int rbytei;
//int rmaski;
//byte maxbi;
} brightobj;
byte nibblebyte(byte inp1, byte inp2){
byte targ2;
targ2 = ((inp1%16)<<4) + (inp2%16);
return(targ2);
}
brightobj bright_obj(int rbyte, int rmask, byte maxb){
int i, j=0, maxn = 12;
boolean bmask = false;
boolean bread = false;
brightobj ret;
for(i=0; i<maxn; i++){
byte tempin = 0;
bmask = bitRead(rmask, i);
if(bmask){
bread = bitRead(rbyte, i);
tempin = nibblebyte(0, maxb * bread);
ret.bitfield[j] = tempin;
j++;
}
}
//ret.rmaski = rmask;
//ret.rbytei = rbyte;
//ret.maxbi = maxb;
return(ret);
}
brightobj bright_obj2(int rbyte, int rbyte2, int rmask, byte maxb){
int i, j=0, maxn = 12;
boolean bmask = false;
boolean bread = false;
boolean bread2 = false;
brightobj ret;
for(i=0; i<maxn; i++){
byte tempin = 0;
bmask = bitRead(rmask, i);
if(bmask){
bread = bitRead(rbyte, i);
bread2 = bitRead(rbyte2, i);
tempin = nibblebyte(maxn * bread2, maxb * bread);
//tempin = nibbleshift(tempin, maxn * bread);
ret.bitfield[j] = tempin;
j++;
}
}
return(ret);
}
brightobj brightshift(brightobj brightchar, brightobj bshiftx, byte col){
brightobj bshift;
for(int i=0; i<9; i++){
bshift.bitfield[i] = bshiftx.bitfield[i]*16; //low to high nibble shift
}
for(int i=1; i<3; i++){
bshift.bitfield[i-1] += bshiftx.bitfield[i]%16; // low to low ns
bshift.bitfield[3+i-1] += bshiftx.bitfield[3+i]%16; // low to low ns
bshift.bitfield[6+i-1] += bshiftx.bitfield[6+i]%16; // low to low ns
}
if(!(col==3))
for(int i=2; i<9; i+=3){
bshift.bitfield[i] += brightchar.bitfield[i-(2-col)]%16; // push next column
}
return(bshift);
}