Source file: /~heha/Mikrocontroller/Displays/utft/uno-itdb28.zip/unused.cpp

// TFT painting with 2D world transformation

class WUTFT : public UTFT {
 int xX,yY;	// scaling / reflection, 0x100 == 1:1
 int yX,xY;	// rotation / shearing (read: factor from logical to Physical)
 static int muldiv(int,int);	// optimized version with 24-bit intermediate
 inline int Xtrafo(int x, int y) const	{return muldiv(x,xX)+muldiv(y,yX);}
 inline int Ytrafo(int x, int y) const	{return muldiv(x,xY)+muldiv(y,yY);}
 POINT trafo(int x, int y) const	{POINT p={Xtrafo(x,y),Ytrafo(x,y)}; return p;}
 void clrScale(int v=256,int w=256);
 void setScale(int v,int w);
};

int WUTFT::muldiv(int a, int b) {
#ifdef __AVR__
 int ret;
 asm("	mov	r0,%B1	\n"	// get resulting sign
"	eor	r0,%B2	\n"
"	bst	r0,7	\n"
"	sbrs	%B1,7	\n"	// a=abs(a)
"	rjmp	.+6	\n"
"	com	%B1	\n"
"	neg	%A1	\n"
"	sbci	%B1,-1	\n"
"	sbrs	%B2,7	\n"	// b=abs(b)
"	rjmp	.+6	\n"
"	com	%B2	\n"
"	neg	%A2	\n"
"	sbci	%B2,-1	\n"
"	mul	%A1,%B2	\n"	// LO(a)*HI(b)
"	movw	%A0,r0	\n"
"	mul	%B1,%A2	\n"	//+HI(a)*LO(b)
"	add	%A0,r0	\n"
"	adc	%B0,r1	\n"
"	mul	%B1,%B2	\n"	//+HI(a)*HI(b)<<8
"	add	%B0,r0	\n"
"	clr	r1	\n"
"	brtc	.+6	\n"	// if (t) ret=-ret
"	com	%B0	\n"
"	neg	%A0	\n"
"	sbci	%B0,-1	\n"
:"=&d" (ret) : "d"(a), "d"(b));
 return ret;
#else
 return int((long)a*b>>8);
#endif
}

void WUTFT::clrScale(int u, int v) {
 xX=u; yX=0;	// identity matrix (when v==w==256)
 yX=0; yY=v;
}

void WUTFT::setScale(int u, int v) {
 if (flags&MOVE) {
  POINT p=trafo(u,v);
  xX=muldiv(xX,p.x); yX=muldiv(yX,p.x);
  yX=muldiv(yX,p.y); yY=muldiv(yY,p.y);
  flags&=~MOVE;		// one-time flag!
 }else clrScale(u,v);	// in this case, physical coordinates!!
}

POINT WUTFT::where() const{
 POINT ret;
 int det=muldiv(xX,yY)-muldiv(yX,xY);	// determinant, results in 256 or -256 for 1:1 scaling
 int xx=X-XO;
 int yy=Y-YO;
 ret.x=(long(muldiv(xx,yY)-muldiv(yy,yX))<<8)/det;	// go over inverse matrix
 ret.y=(long(muldiv(xx,xX)-muldiv(yy,xY))<<8)/det;
 return ret;
}

/*
void UTFT::rotateChar(byte c, int x, int y, int pos, int deg)
{
	byte i,j,ch;
	word temp; 
	int newx,newy;
	double radian;
	radian=deg*0.0175;  

	CS(0);

	temp=((c-cfont.start)*((cfont.cx/8)*cfont.y_size));
	for(j=0;j<cfont.y_size;j++) 
	{
		for (int zz=0; zz<(cfont.x_size/8); zz++)
		{
			ch=pgm_read_byte(&cfont.font[temp+zz]); 
			for(i=0;i<8;i++)
			{   
				newx=x+(((i+(zz*8)+(pos*cfont.x_size))*cos(radian))-((j)*sin(radian)));
				newy=y+(((j)*cos(radian))+((i+(zz*8)+(pos*cfont.x_size))*sin(radian)));

				setXY(newx,newy,newx+1,newy+1);
				
				if((ch&(1<<(7-i)))!=0)   
				{
					setPixel((fch<<8)|fcl);
				} 
				else  
				{
					if (!(_transparent&2))
						setPixel((bch<<8)|bcl);
				}   
			}
		}
		temp+=(cfont.x_size/8);
	}
	unsetWindow();
	CS(1);
}
*/

#if 0
void UTFT::printNumI(long num, int length, char filler) {
 char buf[25];
 char st[27];
 bool neg=false;
 int c=0, f=0;
 if (!num) {
  if (length!=0) {
   for (c=0; c<(length-1); c++) st[c]=filler;
   st[c]=48;
   st[c+1]=0;
  }else{
   st[0]=48;
   st[1]=0;
  }
 }else{
  if (num<0) {
   neg=true;
   num=-num;
  }
  while (num) {
   buf[c]=48+(num % 10);
   c++;
   num=(num-(num % 10))/10;
  }
  buf[c]=0;
  if (neg) st[0]=45;
  if (length>(c+neg)) {
   for (int i=0; i<(length-c-neg); i++) {
    st[i+neg]=filler;
    f++;
   }
  }
  for (int i=0; i<c; i++) {
   st[i+neg+f]=buf[c-i-1];
  }
  st[c+neg+f]=0;
 }
 print(st);
}
#endif
/*
void UTFT::printNumF(double num, byte dec, int x, int y, char divider, int length, char filler)
{
	char st[27];
	boolean neg=false;

	if (dec<1)
		dec=1;
	else if (dec>5)
		dec=5;

	if (num<0)
		neg = true;

	_convert_float(st, num, length, dec);

	if (divider != '.')
	{
		for (int i=0; i<sizeof(st); i++)
			if (st[i]=='.')
				st[i]=divider;
	}

	if (filler != ' ')
	{
		if (neg)
		{
			st[0]='-';
			for (int i=1; i<sizeof(st); i++)
				if ((st[i]==' ') || (st[i]=='-'))
					st[i]=filler;
		}
		else
		{
			for (int i=0; i<sizeof(st); i++)
				if (st[i]==' ')
					st[i]=filler;
		}
	}

	print(st,x,y);
}
*/
/*
void UTFT::drawBitmap(int x, int y, int sx, int sy, word*data, int scale) {
	unsigned int col;
	int tx, ty, tc, tsx, tsy;

	if (scale==1)
	{
		if (orient==PORTRAIT)
		{
			CS(0);
			setXY(x, y, x+sx-1, y+sy-1);
			for (tc=0; tc<(sx*sy); tc++)
			{
				col=pgm_read_word(&data[tc]);
				LCD_DataW(col);
			}
			CS(1);
		}
		else
		{
			CS(0);
			for (ty=0; ty<sy; ty++)
			{
				setXY(x, y+ty, x+sx-1, y+ty);
				for (tx=sx-1; tx>=0; tx--)
				{
					col=pgm_read_word(&data[(ty*sx)+tx]);
					LCD_DataW(col);
				}
			}
			CS(1);
		}
	}
	else
	{
		if (orient==PORTRAIT)
		{
			CS(0);
			for (ty=0; ty<sy; ty++)
			{
				setXY(x, y+(ty*scale), x+((sx*scale)-1), y+(ty*scale)+scale);
				for (tsy=0; tsy<scale; tsy++)
					for (tx=0; tx<sx; tx++)
					{
						col=pgm_read_word(&data[(ty*sx)+tx]);
						for (tsx=0; tsx<scale; tsx++)
							LCD_DataW(col);
					}
			}
			CS(1);
		}
		else
		{
			CS(0);
			for (ty=0; ty<sy; ty++)
			{
				for (tsy=0; tsy<scale; tsy++)
				{
					setXY(x, y+(ty*scale)+tsy, x+((sx*scale)-1), y+(ty*scale)+tsy);
					for (tx=sx-1; tx>=0; tx--)
					{
						col=pgm_read_word(&data[(ty*sx)+tx]);
						for (tsx=0; tsx<scale; tsx++)
							LCD_DataW(col);
					}
				}
			}
	unsetWindow();
			CS(1);
		}
	}
}

void UTFT::drawBitmap(int x, int y, int sx, int sy, word*data, int deg, int rox, int roy)
{
	unsigned int col;
	int tx, ty, newx, newy;
	double radian;
	radian=deg*0.0175;  

	if (deg==0)
		drawBitmap(x, y, sx, sy, data);
	else
	{
		CS(0);
		for (ty=0; ty<sy; ty++)
			for (tx=0; tx<sx; tx++)
			{
				col=pgm_read_word(&data[(ty*sx)+tx]);

				newx=x+rox+(((tx-rox)*cos(radian))-((ty-roy)*sin(radian)));
				newy=y+roy+(((ty-roy)*cos(radian))+((tx-rox)*sin(radian)));

				setXY(newx, newy, newx, newy);
				LCD_DataW(col);
			}
	unsetWindow();
		CS(1);
	}
}
*/
Detected encoding: ASCII (7 bit)2