All pastes #29019 Raw Edit

Mine

public text v1 · immutable
#29019 ·published 2005-11-17 15:48 UTC
rendered paste body
static void video_ipod_update_nano(unsigned short * x, int sx, int sy, int mx, int my)
{
	int height,width,rect1, rect2, rect3, rect4;
	unsigned short *addr;
	unsigned short diff = 0;
	addr=x;
/*	sx=0;
	sy=0;*/
	//mx=175;//høyde (max 175)
	//my=175;//bredde (max 175)
	height = (my - sy);
	width = (mx - sx);
	//height=175;
// 	height=132;
// 	width=175;
/*	sy=0;
	height=132;//height = bredden
	width=175;*/
/*	{
		int t;
		t=my;
		my=mx;
		mx=t;
	}*/
	//ADDR16	addr = psd->addr;
	//assert (addr != 0);
	//diff = lcd_width - width;
	if (my > lcd_height) {
		my = lcd_height;
	}
	if (mx > lcd_width) {
		//diff = (lcd_width -mx)*2;
		mx = lcd_width;
	}
/*	height = lcd_height;
	width = lcd_height;*/
	//if (width & 1) width++;

	/* calculate the drawing region */
		//horiz=x vert=y
		rect1 = sx;//start horiz
		rect2 = sy;//start vert
		rect3 = (sx + width) ;//max horiz
		rect4 = (rect2+height);//max vert

	/* setup the drawing region */
		if (rect3 < rect1) {
			int t;
			t = rect1;
			rect1 = rect3;
			rect3 = t;
		}

		if (rect4 < rect2) {
			int t;
			t = rect2;
			rect2 = rect4;
			rect4 = t;
		}

		/* max horiz << 8 | start horiz */
		video_lcd_cmd_data(0x44, (rect3 << 8) | rect1);
		/* max vert << 8 | start vert */
		video_lcd_cmd_data(0x45, (rect4 << 8) | rect2);


		/* position cursor (set AD0-AD15) */
		/* start vert << 8 | start horiz */
		video_lcd_cmd_data(0x21, (rect2 << 8) | rect1);

		/* start drawing */
		video_lcd_send_lo(0x0);
		video_lcd_send_lo(0x22);

	//addr += sx + sy * lcd_width;
// 	height = lcd_height;
// 	width = lcd_height;

	//height = (my - sy);
/*	height=132;
	width = 176;*/
	
	while (height > 0) {
		int h, x, y, pixels_to_write;

		pixels_to_write = (width * height) * 2;

		/* calculate how much we can do in one go */
		h = height;
		if (pixels_to_write > 64000) {
			h = (64000/2) / width;
			pixels_to_write = (width * h) * 2;
		}

		outl(0x10000080, 0x70008A20);
		outl((pixels_to_write - 1) | 0xC0010000, 0x70008A24);
		outl(0x34000000, 0x70008A20);

		/* for each row */
		for (y = 0; y < h; y++)
		{
			/* for each column */
			for (x = 0; x < width; x += 2) {
/*				unsigned two_pixels;
				unsigned tm;
				
				two_pixels = addr[0] | (addr[1] << 16);
				addr += 2;

				while ((inl(0x70008A20) & 0x1000000) == 0);
				
				tm = (two_pixels & ~0xFF0000) >> 8;
				two_pixels = two_pixels & ~0xFF00;
				two_pixels = tm | (two_pixels << 8);


				/-* output 2 pixels *-/
				outl(two_pixels, 0x70008B00);*/
				unsigned two_pixels;

				two_pixels = addr[0] | (addr[1] << 16);
				addr += 2;

				while ((inl(0x70008a20) & 0x1000000) == 0);

				/* output 2 pixels */
				outl(two_pixels, 0x70008b00);
			}

			//addr += diff;
		}

		while ((inl(0x70008A20) & 0x4000000) == 0);

		outl(0x0, 0x70008A24);

		height = height - h;
	}
}